@lumiapassport/ui-kit 1.12.2 → 1.12.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@
10
10
  # script-src: Added 'unsafe-eval' required by Telegram Widget (uses eval for callbacks)
11
11
  # frame-src: Added https://oauth.telegram.org for Telegram OAuth iframe
12
12
  # NOTE: http://localhost:* in frame-ancestors is for development testing only
13
- Content-Security-Policy: default-src 'self'; script-src 'self' 'wasm-unsafe-eval' 'unsafe-eval' https://telegram.org; style-src 'self' 'unsafe-inline'; img-src 'self' data: https: blob:; font-src 'self'; connect-src 'self' https://*.lumiapassport.com; frame-src https://oauth.telegram.org; frame-ancestors https: http://localhost:*; base-uri 'self'; form-action 'self';
13
+ Content-Security-Policy: default-src 'self'; script-src 'self' 'wasm-unsafe-eval' 'unsafe-eval' https://telegram.org https://static.sumsub.com; style-src 'self' 'unsafe-inline'; img-src 'self' data: https: blob:; font-src 'self'; connect-src 'self' https://*.lumiapassport.com https://*.sumsub.com; frame-src https://oauth.telegram.org https://*.sumsub.com; frame-ancestors https: http://localhost:*; base-uri 'self'; form-action 'self';
14
14
 
15
15
  # Allow iframe embedding from HTTPS sites (domain validation in JS)
16
16
  # X-Frame-Options is NOT set (CSP frame-ancestors takes precedence)
@@ -15,7 +15,7 @@
15
15
  <meta http-equiv="X-Content-Type-Options" content="nosniff" />
16
16
  <meta http-equiv="Referrer-Policy" content="strict-origin-when-cross-origin" />
17
17
 
18
- <title>Lumia Passport Secure Wallet - iframe version 1.12.2</title>
18
+ <title>Lumia Passport Secure Wallet - iframe version 1.12.5</title>
19
19
 
20
20
  <!-- Styles will be injected by build process -->
21
21
  <style>
@@ -0,0 +1,91 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Sumsub KYC - Lumia Passport</title>
7
+
8
+ <style>
9
+ * {
10
+ margin: 0;
11
+ padding: 0;
12
+ box-sizing: border-box;
13
+ }
14
+
15
+ body {
16
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
17
+ background: #ffffff;
18
+ color: #333;
19
+ min-height: 100vh;
20
+ padding: 0;
21
+ margin: 0;
22
+ }
23
+
24
+ #sumsub-websdk-container {
25
+ width: 100%;
26
+ min-height: 100vh;
27
+ }
28
+
29
+ .loading-container {
30
+ display: flex;
31
+ flex-direction: column;
32
+ align-items: center;
33
+ justify-content: center;
34
+ min-height: 100vh;
35
+ gap: 1rem;
36
+ }
37
+
38
+ .spinner {
39
+ width: 40px;
40
+ height: 40px;
41
+ border: 4px solid rgba(102, 126, 234, 0.3);
42
+ border-top-color: #667eea;
43
+ border-radius: 50%;
44
+ animation: spin 1s linear infinite;
45
+ }
46
+
47
+ @keyframes spin {
48
+ to { transform: rotate(360deg); }
49
+ }
50
+
51
+ .error-container {
52
+ display: flex;
53
+ flex-direction: column;
54
+ align-items: center;
55
+ justify-content: center;
56
+ min-height: 100vh;
57
+ padding: 2rem;
58
+ text-align: center;
59
+ }
60
+
61
+ .error-message {
62
+ background: #fee;
63
+ border: 1px solid #fcc;
64
+ border-radius: 8px;
65
+ padding: 1rem;
66
+ color: #c33;
67
+ max-width: 500px;
68
+ }
69
+ </style>
70
+ </head>
71
+ <body>
72
+ <div id="loading" class="loading-container">
73
+ <div class="spinner"></div>
74
+ <p>Initializing KYC verification...</p>
75
+ </div>
76
+
77
+ <div id="error" class="error-container" style="display: none;">
78
+ <div class="error-message">
79
+ <strong>Error:</strong> <span id="error-text"></span>
80
+ </div>
81
+ </div>
82
+
83
+ <div id="sumsub-websdk-container"></div>
84
+
85
+ <!-- Sumsub WebSDK -->
86
+ <script src="https://static.sumsub.com/idensic/static/sns-websdk-builder.js"></script>
87
+
88
+ <!-- Sumsub KYC iframe integration script -->
89
+ <script src="./sumsub.js"></script>
90
+ </body>
91
+ </html>
@@ -0,0 +1,237 @@
1
+ /**
2
+ * Sumsub KYC Iframe Script
3
+ * Handles postMessage communication with parent window and Sumsub SDK integration
4
+ */
5
+
6
+ ;(function () {
7
+ 'use strict'
8
+
9
+ // ========================================
10
+ // State Management
11
+ // ========================================
12
+
13
+ let snsWebSdkInstance = null
14
+ let parentOrigin = null
15
+
16
+ // ========================================
17
+ // Logging
18
+ // ========================================
19
+
20
+ function log(message, data) {
21
+ if (data !== undefined) {
22
+ console.log('[Sumsub KYC]', message, data)
23
+ } else {
24
+ console.log('[Sumsub KYC]', message)
25
+ }
26
+ }
27
+
28
+ // ========================================
29
+ // UI Helpers
30
+ // ========================================
31
+
32
+ function hideLoading() {
33
+ const loading = document.getElementById('loading')
34
+ if (loading) loading.style.display = 'none'
35
+ }
36
+
37
+ function showError(message) {
38
+ const loading = document.getElementById('loading')
39
+ const error = document.getElementById('error')
40
+ const errorText = document.getElementById('error-text')
41
+ const container = document.getElementById('sumsub-websdk-container')
42
+
43
+ if (loading) loading.style.display = 'none'
44
+ if (error) error.style.display = 'flex'
45
+ if (errorText) errorText.textContent = message
46
+ if (container) container.style.display = 'none'
47
+
48
+ log('Error displayed:', message)
49
+ }
50
+
51
+ function showSumsubContainer() {
52
+ const loading = document.getElementById('loading')
53
+ const error = document.getElementById('error')
54
+ const container = document.getElementById('sumsub-websdk-container')
55
+
56
+ if (loading) loading.style.display = 'none'
57
+ if (error) error.style.display = 'none'
58
+ if (container) container.style.display = 'block'
59
+ }
60
+
61
+ // ========================================
62
+ // postMessage Communication
63
+ // ========================================
64
+
65
+ function sendMessageToParent(type, data = {}) {
66
+ if (!parentOrigin) {
67
+ log('Cannot send message: parent origin not set')
68
+ return
69
+ }
70
+
71
+ const message = {
72
+ type: type,
73
+ data: data
74
+ }
75
+
76
+ log('Sending message to parent:', message)
77
+ window.parent.postMessage(message, parentOrigin)
78
+ }
79
+
80
+ // ========================================
81
+ // Sumsub SDK Integration
82
+ // ========================================
83
+
84
+ function requestNewAccessToken() {
85
+ log('Requesting new access token from parent...')
86
+
87
+ return new Promise((resolve, reject) => {
88
+ const timeout = setTimeout(() => {
89
+ window.removeEventListener('message', handler)
90
+ reject(new Error('Token refresh timeout'))
91
+ }, 30000)
92
+
93
+ const handler = (event) => {
94
+ const message = event.data
95
+ if (
96
+ message.type === 'SUMSUB_TOKEN_REFRESH' &&
97
+ message.data?.requestId === requestId &&
98
+ message.data.accessToken
99
+ ) {
100
+ clearTimeout(timeout)
101
+ window.removeEventListener('message', handler)
102
+ log('Received new access token from parent')
103
+ resolve(message.data.accessToken)
104
+ }
105
+ }
106
+
107
+ window.addEventListener('message', handler)
108
+
109
+ const requestId = `token_refresh_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`
110
+ sendMessageToParent('SUMSUB_TOKEN_EXPIRED', { requestId })
111
+ })
112
+ }
113
+
114
+ function launchSumsubSdk(options) {
115
+ log('Launching Sumsub SDK with access token')
116
+
117
+ try {
118
+ if (!window.snsWebSdk) {
119
+ throw new Error('Sumsub SDK not loaded')
120
+ }
121
+
122
+ // Build SDK instance
123
+ snsWebSdkInstance = window.snsWebSdk
124
+ .init(
125
+ options.accessToken,
126
+ // Expiration handler - called when token expires
127
+ () => {
128
+ log('Access token expired, requesting new one...')
129
+ return requestNewAccessToken()
130
+ }
131
+ )
132
+ .withOptions({
133
+ addViewportTag: false,
134
+ adaptIframeHeight: true,
135
+ enableScrollIntoView: true
136
+ })
137
+ .withConf({
138
+ lang: 'en',
139
+ theme: options.theme,
140
+ customizationName: options.customizationName
141
+ })
142
+ .on('idCheck.onError', (error) => {
143
+ log('onError', error)
144
+ sendMessageToParent('SUMSUB_ERROR', { error: error.message || 'Unknown error' })
145
+ })
146
+ .on('idCheck.onResize', (payload) => {
147
+ log('onResize', payload)
148
+ sendMessageToParent('SUMSUB_ON_RESIZE', { height: payload.height })
149
+ })
150
+ .on('idCheck.onInitialized', () => {
151
+ sendMessageToParent('SUMSUB_SDK_ON_INIT')
152
+ })
153
+ .build()
154
+
155
+ // Launch SDK
156
+ snsWebSdkInstance.launch('#sumsub-websdk-container')
157
+
158
+ showSumsubContainer()
159
+ sendMessageToParent('SUMSUB_SDK_ON_BUILD')
160
+ log('Sumsub SDK launched successfully')
161
+ } catch (error) {
162
+ log('Failed to launch Sumsub SDK:', error)
163
+ showError(error.message || 'Failed to initialize KYC verification')
164
+ sendMessageToParent('SUMSUB_INIT_ERROR', { error: error.message })
165
+ }
166
+ }
167
+
168
+ // ========================================
169
+ // Message Handler
170
+ // ========================================
171
+
172
+ function handleMessage(event) {
173
+ // Store parent origin on first valid message
174
+ if (!parentOrigin && event.origin && event.source === window.parent) {
175
+ parentOrigin = event.origin
176
+ log('Parent origin set to:', parentOrigin)
177
+ }
178
+
179
+ const message = event.data
180
+
181
+ // Validate message structure
182
+ if (!message || typeof message !== 'object' || !message.type) {
183
+ return
184
+ }
185
+
186
+ log('Received message:', message)
187
+
188
+ switch (message.type) {
189
+ case 'SUMSUB_INIT':
190
+ // Initialize Sumsub SDK with access token
191
+ if (!message.data?.accessToken) {
192
+ showError('No access token provided')
193
+ sendMessageToParent('SUMSUB_INIT_ERROR', { error: 'No access token provided' })
194
+ return
195
+ }
196
+
197
+ hideLoading()
198
+ launchSumsubSdk({
199
+ accessToken: message.data.accessToken,
200
+ theme: message.data.theme,
201
+ customizationName: message.data.customizationName
202
+ })
203
+ break
204
+
205
+ default:
206
+ log('Unknown message type:', message.type)
207
+ }
208
+ }
209
+
210
+ // ========================================
211
+ // Initialization
212
+ // ========================================
213
+
214
+ window.addEventListener('message', handleMessage)
215
+
216
+ // Notify parent that iframe is ready
217
+ window.addEventListener('load', () => {
218
+ log('Iframe loaded, notifying parent')
219
+
220
+ // Send ready signal to parent with wildcard (parent will send origin back)
221
+ window.parent.postMessage(
222
+ {
223
+ type: 'SUMSUB_IFRAME_LOADED'
224
+ },
225
+ '*'
226
+ )
227
+ })
228
+
229
+ // Cleanup on unload
230
+ window.addEventListener('beforeunload', () => {
231
+ if (snsWebSdkInstance && typeof snsWebSdkInstance.destroy === 'function') {
232
+ snsWebSdkInstance.destroy()
233
+ }
234
+ })
235
+
236
+ log('Sumsub KYC iframe script initialized')
237
+ })()
@@ -3964,7 +3964,7 @@ var SigningManager = class extends TokenRefreshApiClient {
3964
3964
  };
3965
3965
 
3966
3966
  // src/iframe/main.ts
3967
- var IFRAME_VERSION = "1.12.2";
3967
+ var IFRAME_VERSION = "1.12.5";
3968
3968
  var IframeWallet = class {
3969
3969
  constructor() {
3970
3970
  console.log("=".repeat(60));