@truly-you/trulyyou-web-sdk 0.1.5 → 0.1.6

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/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@truly-you/trulyyou-web-sdk",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "TrulyYou Web SDK for secure authentication and payload signing",
5
5
  "type": "module",
6
6
  "main": "dist/index.esm.js",
7
7
  "module": "dist/index.esm.js",
8
+ "unpkg": "dist/index.umd.js",
8
9
  "types": "dist/index.d.ts",
9
10
  "private": false,
10
11
  "publishConfig": {
@@ -288,6 +288,10 @@ export class TrulyYouSDK {
288
288
  probeUrl.searchParams.set('probe', 'true')
289
289
  probeUrl.searchParams.set('origin', origin)
290
290
  iframe.src = probeUrl.toString()
291
+
292
+ console.log('[SDK-PROBE]: Creating probe iframe with URL:', probeUrl.toString())
293
+ console.log('[SDK-PROBE]: Current origin:', origin)
294
+ console.log('[SDK-PROBE]: Frontend URL:', this.frontendUrl)
291
295
 
292
296
  let timeout: NodeJS.Timeout | undefined
293
297
  let backendCheckPromise: Promise<boolean> | null = null
@@ -303,16 +307,29 @@ export class TrulyYouSDK {
303
307
  }
304
308
 
305
309
  const handleMessage = async (event: MessageEvent) => {
310
+ console.log('[SDK-PROBE]: Received message:', event.data, 'from origin:', event.origin)
311
+
306
312
  try {
307
313
  const frontendOrigin = new URL(this.frontendUrl).origin
308
- if (event.origin !== frontendOrigin) return
314
+ console.log('[SDK-PROBE]: Checking origin - expected:', frontendOrigin, 'received:', event.origin)
315
+ if (event.origin !== frontendOrigin) {
316
+ console.log('[SDK-PROBE]: Origin mismatch, ignoring message')
317
+ return
318
+ }
309
319
 
310
320
  } catch (e) {
311
- if (!event.origin.includes(window.location.hostname)) return
321
+ console.log('[SDK-PROBE]: Origin check failed, using hostname fallback')
322
+ if (!event.origin.includes(window.location.hostname)) {
323
+ console.log('[SDK-PROBE]: Hostname not in origin, ignoring message')
324
+ return
325
+ }
312
326
  }
313
327
 
314
328
  const data = event.data as any
329
+ console.log('[SDK-PROBE]: Message passed origin check, type:', data?.type)
330
+
315
331
  if (data?.type === 'KEY_CHECK_RESULT') {
332
+ console.log('[SDK-PROBE]: KEY_CHECK_RESULT received - hasKey:', data.hasKey, 'keyId:', data.keyId)
316
333
  cleanup()
317
334
  if (data.hasKey && data.keyId) {
318
335
  // Key found in localStorage - it will be validated when used in /api/signatures/create
@@ -321,6 +338,7 @@ export class TrulyYouSDK {
321
338
  resolve(null)
322
339
  }
323
340
  } else if (data?.type === 'KEY_CHECK_FAILED') {
341
+ console.log('[SDK-PROBE]: KEY_CHECK_FAILED received')
324
342
  cleanup()
325
343
  resolve(null)
326
344
  }
@@ -328,13 +346,16 @@ export class TrulyYouSDK {
328
346
 
329
347
  window.addEventListener('message', handleMessage)
330
348
  document.body.appendChild(iframe)
349
+ console.log('[SDK-PROBE]: Iframe appended to body, waiting for response...')
331
350
 
332
351
  // Short timeout to keep UX snappy
333
352
  timeout = setTimeout(() => {
353
+ console.log('[SDK-PROBE]: Timeout reached (1500ms), no response from iframe')
334
354
  cleanup()
335
355
  resolve(null)
336
356
  }, 1500)
337
- } catch {
357
+ } catch (error) {
358
+ console.error('[SDK-PROBE]: Error in probeIframeForKey:', error)
338
359
  resolve(null)
339
360
  }
340
361
  })