@truly-you/trulyyou-web-sdk 0.1.18 → 0.1.19
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 +5 -0
- package/package.json +1 -1
- package/src/sdk/TrulyYouSDK.ts +27 -0
|
@@ -81,4 +81,9 @@ export declare class TrulyYouSDK {
|
|
|
81
81
|
* Fetch with automatic payload signing
|
|
82
82
|
*/
|
|
83
83
|
fetchWithSignature(url: string, options?: FetchOptions): Promise<FetchResult>;
|
|
84
|
+
/**
|
|
85
|
+
* Public method to probe for keyId - checks localStorage first, then probes TrulyYou frontend via iframe
|
|
86
|
+
* Returns the keyId if found, null otherwise
|
|
87
|
+
*/
|
|
88
|
+
probeForKeyId(): Promise<string | null>;
|
|
84
89
|
}
|
package/package.json
CHANGED
package/src/sdk/TrulyYouSDK.ts
CHANGED
|
@@ -1884,5 +1884,32 @@ export class TrulyYouSDK {
|
|
|
1884
1884
|
throw error
|
|
1885
1885
|
}
|
|
1886
1886
|
}
|
|
1887
|
+
|
|
1888
|
+
/**
|
|
1889
|
+
* Public method to probe for keyId - checks localStorage first, then probes TrulyYou frontend via iframe
|
|
1890
|
+
* Returns the keyId if found, null otherwise
|
|
1891
|
+
*/
|
|
1892
|
+
async probeForKeyId(): Promise<string | null> {
|
|
1893
|
+
// Ensure authFlowId is loaded first
|
|
1894
|
+
await this.ensureAuthFlowIdLoaded()
|
|
1895
|
+
|
|
1896
|
+
if (!this.brandingCache?.authFlowId) {
|
|
1897
|
+
console.warn('[SDK-PROBE]: authFlowId is required but not available')
|
|
1898
|
+
return null
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
const authFlowId = this.brandingCache.authFlowId
|
|
1902
|
+
|
|
1903
|
+
// First, check localStorage (same origin - this app's localStorage)
|
|
1904
|
+
const keyIdFromStorage = this.getKeyIdByAuthFlowId(authFlowId)
|
|
1905
|
+
if (keyIdFromStorage) {
|
|
1906
|
+
console.log('[SDK-PROBE]: Found keyId in same-origin localStorage')
|
|
1907
|
+
return keyIdFromStorage
|
|
1908
|
+
}
|
|
1909
|
+
|
|
1910
|
+
// If not found in same-origin localStorage, probe TrulyYou frontend's localStorage via iframe
|
|
1911
|
+
console.log('[SDK-PROBE]: KeyId not found in same-origin localStorage, probing TrulyYou frontend...')
|
|
1912
|
+
return await this.probeIframeForKey()
|
|
1913
|
+
}
|
|
1887
1914
|
}
|
|
1888
1915
|
|