@truly-you/trulyyou-web-sdk 0.1.16 → 0.1.17
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.
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/sdk/TrulyYouSDK.ts +0 -42
package/package.json
CHANGED
package/src/sdk/TrulyYouSDK.ts
CHANGED
|
@@ -301,94 +301,52 @@ export class TrulyYouSDK {
|
|
|
301
301
|
}
|
|
302
302
|
|
|
303
303
|
iframe.src = probeUrl.toString()
|
|
304
|
-
|
|
305
|
-
console.log('[SDK-PROBE]: Creating probe iframe with URL:', probeUrl.toString())
|
|
306
|
-
console.log('[SDK-PROBE]: Current origin:', origin)
|
|
307
|
-
console.log('[SDK-PROBE]: Frontend URL:', this.frontendUrl)
|
|
308
304
|
|
|
309
305
|
let timeout: NodeJS.Timeout | undefined
|
|
310
|
-
let globalTimeout: NodeJS.Timeout | undefined
|
|
311
306
|
let backendCheckPromise: Promise<boolean> | null = null
|
|
312
|
-
let globalListener: ((e: MessageEvent) => void) | undefined
|
|
313
307
|
|
|
314
308
|
const cleanup = () => {
|
|
315
309
|
window.removeEventListener('message', handleMessage)
|
|
316
|
-
if (globalListener) {
|
|
317
|
-
window.removeEventListener('message', globalListener)
|
|
318
|
-
}
|
|
319
310
|
if (iframe.parentNode) {
|
|
320
311
|
iframe.parentNode.removeChild(iframe)
|
|
321
312
|
}
|
|
322
313
|
if (timeout) {
|
|
323
314
|
clearTimeout(timeout)
|
|
324
315
|
}
|
|
325
|
-
if (globalTimeout) {
|
|
326
|
-
clearTimeout(globalTimeout)
|
|
327
|
-
}
|
|
328
316
|
}
|
|
329
317
|
|
|
330
318
|
const handleMessage = async (event: MessageEvent) => {
|
|
331
319
|
const data = event.data as any
|
|
332
320
|
|
|
333
|
-
// Log ALL messages during probe to debug
|
|
334
|
-
console.log('[SDK-PROBE-DEBUG]: Message received - type:', data?.type, 'origin:', event.origin, 'data:', data)
|
|
335
|
-
|
|
336
321
|
// Only process probe-related messages
|
|
337
322
|
if (data?.type === 'KEY_CHECK_RESULT' || data?.type === 'KEY_CHECK_FAILED') {
|
|
338
|
-
console.log('[SDK-PROBE]: Processing probe message:', event.data, 'from origin:', event.origin)
|
|
339
|
-
|
|
340
323
|
try {
|
|
341
324
|
const frontendOrigin = new URL(this.frontendUrl).origin
|
|
342
|
-
console.log('[SDK-PROBE]: Checking origin - expected:', frontendOrigin, 'received:', event.origin)
|
|
343
325
|
if (event.origin !== frontendOrigin) {
|
|
344
|
-
console.log('[SDK-PROBE]: Origin mismatch, ignoring message')
|
|
345
326
|
return
|
|
346
327
|
}
|
|
347
|
-
|
|
348
328
|
} catch (e) {
|
|
349
|
-
console.log('[SDK-PROBE]: Origin check failed, using hostname fallback')
|
|
350
329
|
if (!event.origin.includes(window.location.hostname)) {
|
|
351
|
-
console.log('[SDK-PROBE]: Hostname not in origin, ignoring message')
|
|
352
330
|
return
|
|
353
331
|
}
|
|
354
332
|
}
|
|
355
|
-
|
|
356
|
-
console.log('[SDK-PROBE]: Message passed origin check, type:', data?.type)
|
|
357
333
|
|
|
358
334
|
if (data?.type === 'KEY_CHECK_RESULT') {
|
|
359
|
-
console.log('[SDK-PROBE]: KEY_CHECK_RESULT received - hasKey:', data.hasKey, 'keyId:', data.keyId)
|
|
360
335
|
cleanup()
|
|
361
336
|
if (data.hasKey && data.keyId) {
|
|
362
|
-
// Key found in localStorage - it will be validated when used in /api/signatures/create
|
|
363
337
|
resolve(data.keyId)
|
|
364
338
|
} else {
|
|
365
339
|
resolve(null)
|
|
366
340
|
}
|
|
367
341
|
} else if (data?.type === 'KEY_CHECK_FAILED') {
|
|
368
|
-
console.log('[SDK-PROBE]: KEY_CHECK_FAILED received')
|
|
369
342
|
cleanup()
|
|
370
343
|
resolve(null)
|
|
371
344
|
}
|
|
372
345
|
}
|
|
373
346
|
}
|
|
374
347
|
|
|
375
|
-
console.log('[SDK-PROBE]: Registering message listener on window')
|
|
376
348
|
window.addEventListener('message', handleMessage)
|
|
377
|
-
console.log('[SDK-PROBE]: Message listener registered, appending iframe')
|
|
378
349
|
document.body.appendChild(iframe)
|
|
379
|
-
console.log('[SDK-PROBE]: Iframe appended to body, waiting for response...')
|
|
380
|
-
|
|
381
|
-
// Also add a temporary global listener to see if ANY messages arrive
|
|
382
|
-
globalListener = (e: MessageEvent) => {
|
|
383
|
-
console.log('[SDK-PROBE-GLOBAL]: Any message received:', e.data, 'from:', e.origin)
|
|
384
|
-
}
|
|
385
|
-
window.addEventListener('message', globalListener)
|
|
386
|
-
globalTimeout = setTimeout(() => {
|
|
387
|
-
if (globalListener) {
|
|
388
|
-
window.removeEventListener('message', globalListener)
|
|
389
|
-
console.log('[SDK-PROBE-GLOBAL]: Removed temporary global listener')
|
|
390
|
-
}
|
|
391
|
-
}, 5000)
|
|
392
350
|
|
|
393
351
|
// Timeout to allow for React hydration on sign page
|
|
394
352
|
timeout = setTimeout(() => {
|