This repository was archived by the owner on Jul 8, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify-tlk-adapter.ts
More file actions
80 lines (68 loc) · 3.04 KB
/
Copy pathverify-tlk-adapter.ts
File metadata and controls
80 lines (68 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env ts-node
/**
* Verification script for TlkIoAdapter fixes
* Tests the iframe embed generation manually
*/
import { TlkIoAdapter } from './src/infrastructure/adapters/TlkIoAdapter';
console.log('=== TlkIoAdapter Verification ===\n');
const adapter = new TlkIoAdapter({
TLKIO_BASE_URL: 'https://tlk.io',
TLKIO_THEME: 'theme--minimal'
});
// Test 1: Forum chat info
console.log('Test 1: Forum Chat Info');
const forumChat = adapter.createForumChatInfo({
forumId: 'gold-forum-1',
memberId: 'member-123',
nickname: 'GoldMember'
});
console.log('Channel ID:', forumChat.channelId);
console.log('Nickname:', forumChat.nickname);
console.log('Embed HTML contains iframe:', forumChat.embedHtml.includes('<iframe'));
console.log('Embed HTML contains sandbox:', forumChat.embedHtml.includes('sandbox='));
console.log('Embed HTML contains allow credentials:', forumChat.embedHtml.includes('allow="credentials"'));
console.log('Full HTML:\n', forumChat.embedHtml);
console.log('\n---\n');
// Test 2: Private chat info
console.log('Test 2: Private Chat Info');
const privateChat = adapter.createPrivateChatInfo({
sessionId: 'session-abc123def456',
memberId: 'member-456',
nickname: 'ChatUser'
});
console.log('Channel ID:', privateChat.channelId);
console.log('Nickname:', privateChat.nickname);
console.log('Embed HTML contains iframe:', privateChat.embedHtml.includes('<iframe'));
console.log('Embed HTML contains sandbox:', privateChat.embedHtml.includes('sandbox='));
console.log('Full HTML:\n', privateChat.embedHtml);
console.log('\n---\n');
// Test 3: XSS protection
console.log('Test 3: XSS Protection');
const xssChat = adapter.createForumChatInfo({
forumId: 'test',
memberId: 'member-789',
nickname: 'User<script>alert("xss")</script>'
});
console.log('XSS test - contains encoded script:', xssChat.embedHtml.includes('<script>'));
console.log('XSS test - does NOT contain raw script:', !xssChat.embedHtml.includes('<script>alert'));
console.log('Full HTML:\n', xssChat.embedHtml);
console.log('\n---\n');
// Test 4: URL encoding
console.log('Test 4: URL Encoding');
const spaceChat = adapter.createForumChatInfo({
forumId: 'test',
memberId: 'member-999',
nickname: 'Test User With Spaces'
});
console.log('URL encoding - contains encoded spaces:', spaceChat.embedHtml.includes('Test%20User%20With%20Spaces'));
console.log('Full HTML:\n', spaceChat.embedHtml);
console.log('\n---\n');
console.log('=== Verification Complete ===');
console.log('\nKey Changes Applied:');
console.log('1. ✓ Added generateIframeEmbed() method with cross-origin support');
console.log('2. ✓ Updated createForumChatInfo() to use iframe embed');
console.log('3. ✓ Updated createPrivateChatInfo() to use iframe embed');
console.log('4. ✓ Added sandbox attributes: allow-same-origin, allow-scripts, allow-forms, allow-popups');
console.log('5. ✓ Added allow="credentials" for cross-origin cookie support');
console.log('6. ✓ Maintained XSS protection with HTML escaping and URL encoding');
console.log('7. ✓ Kept backward compatibility with generateEmbedHtml()');