@truly-you/trulyyou-web-sdk 0.1.19 → 0.1.20
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/dist/sdk/TrulyYouSDK.d.ts +3 -1
- package/package.json +1 -1
- package/src/sdk/TrulyYouSDK.ts +14 -7
|
@@ -52,6 +52,7 @@ export declare class TrulyYouSDK {
|
|
|
52
52
|
* Probe iframe to check if key exists in iframe's localStorage
|
|
53
53
|
* Also checks backend to verify key exists and is active
|
|
54
54
|
* REQUIRES authFlowId to be loaded first
|
|
55
|
+
* @param handoff - If true, probes for handoff keyId (with _handoff suffix)
|
|
55
56
|
*/
|
|
56
57
|
private probeIframeForKey;
|
|
57
58
|
/**
|
|
@@ -84,6 +85,7 @@ export declare class TrulyYouSDK {
|
|
|
84
85
|
/**
|
|
85
86
|
* Public method to probe for keyId - checks localStorage first, then probes TrulyYou frontend via iframe
|
|
86
87
|
* Returns the keyId if found, null otherwise
|
|
88
|
+
* @param handoff - If true, probes for handoff keyId (with _handoff suffix)
|
|
87
89
|
*/
|
|
88
|
-
probeForKeyId(): Promise<string | null>;
|
|
90
|
+
probeForKeyId(handoff?: boolean): Promise<string | null>;
|
|
89
91
|
}
|
package/package.json
CHANGED
package/src/sdk/TrulyYouSDK.ts
CHANGED
|
@@ -308,8 +308,9 @@ export class TrulyYouSDK {
|
|
|
308
308
|
* Probe iframe to check if key exists in iframe's localStorage
|
|
309
309
|
* Also checks backend to verify key exists and is active
|
|
310
310
|
* REQUIRES authFlowId to be loaded first
|
|
311
|
+
* @param handoff - If true, probes for handoff keyId (with _handoff suffix)
|
|
311
312
|
*/
|
|
312
|
-
private async probeIframeForKey(): Promise<string | null> {
|
|
313
|
+
private async probeIframeForKey(handoff: boolean = false): Promise<string | null> {
|
|
313
314
|
// Ensure authFlowId is loaded before probing
|
|
314
315
|
await this.ensureAuthFlowIdLoaded()
|
|
315
316
|
|
|
@@ -332,7 +333,10 @@ export class TrulyYouSDK {
|
|
|
332
333
|
// Add authFlowId (guaranteed to exist now after ensureAuthFlowIdLoaded)
|
|
333
334
|
const authFlowId = this.brandingCache!.authFlowId!
|
|
334
335
|
probeUrl.searchParams.set('authFlowId', authFlowId)
|
|
335
|
-
|
|
336
|
+
if (handoff) {
|
|
337
|
+
probeUrl.searchParams.set('handoff', 'true')
|
|
338
|
+
}
|
|
339
|
+
console.log(`[SDK-PROBE]: Adding authFlowId to probe: ${authFlowId}${handoff ? ' (handoff)' : ''}`)
|
|
336
340
|
|
|
337
341
|
iframe.src = probeUrl.toString()
|
|
338
342
|
|
|
@@ -1888,8 +1892,9 @@ export class TrulyYouSDK {
|
|
|
1888
1892
|
/**
|
|
1889
1893
|
* Public method to probe for keyId - checks localStorage first, then probes TrulyYou frontend via iframe
|
|
1890
1894
|
* Returns the keyId if found, null otherwise
|
|
1895
|
+
* @param handoff - If true, probes for handoff keyId (with _handoff suffix)
|
|
1891
1896
|
*/
|
|
1892
|
-
async probeForKeyId(): Promise<string | null> {
|
|
1897
|
+
async probeForKeyId(handoff: boolean = false): Promise<string | null> {
|
|
1893
1898
|
// Ensure authFlowId is loaded first
|
|
1894
1899
|
await this.ensureAuthFlowIdLoaded()
|
|
1895
1900
|
|
|
@@ -1901,15 +1906,17 @@ export class TrulyYouSDK {
|
|
|
1901
1906
|
const authFlowId = this.brandingCache.authFlowId
|
|
1902
1907
|
|
|
1903
1908
|
// First, check localStorage (same origin - this app's localStorage)
|
|
1904
|
-
const
|
|
1909
|
+
const storageKey = handoff ? `trulyYouKeyId_${authFlowId}_handoff` : `trulyYouKeyId_${authFlowId}`
|
|
1910
|
+
const keyIdFromStorage = typeof window !== 'undefined' ? localStorage.getItem(storageKey) : null
|
|
1911
|
+
|
|
1905
1912
|
if (keyIdFromStorage) {
|
|
1906
|
-
console.log(
|
|
1913
|
+
console.log(`[SDK-PROBE]: Found ${handoff ? 'handoff ' : ''}keyId in same-origin localStorage`)
|
|
1907
1914
|
return keyIdFromStorage
|
|
1908
1915
|
}
|
|
1909
1916
|
|
|
1910
1917
|
// If not found in same-origin localStorage, probe TrulyYou frontend's localStorage via iframe
|
|
1911
|
-
console.log(
|
|
1912
|
-
return await this.probeIframeForKey()
|
|
1918
|
+
console.log(`[SDK-PROBE]: ${handoff ? 'Handoff ' : ''}KeyId not found in same-origin localStorage, probing TrulyYou frontend...`)
|
|
1919
|
+
return await this.probeIframeForKey(handoff)
|
|
1913
1920
|
}
|
|
1914
1921
|
}
|
|
1915
1922
|
|