@truly-you/trulyyou-web-sdk 0.1.22 → 0.1.23
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 +50 -0
|
@@ -88,4 +88,9 @@ export declare class TrulyYouSDK {
|
|
|
88
88
|
* @param handoff - If true, probes for handoff keyId (with _handoff suffix)
|
|
89
89
|
*/
|
|
90
90
|
probeForKeyId(handoff?: boolean): Promise<string | null>;
|
|
91
|
+
/**
|
|
92
|
+
* Clear all keys (both handoff and non-handoff) from localStorage
|
|
93
|
+
* Clears from both same-origin localStorage and TrulyYou frontend's localStorage via iframe
|
|
94
|
+
*/
|
|
95
|
+
clearAllKeys(): Promise<void>;
|
|
91
96
|
}
|
package/package.json
CHANGED
package/src/sdk/TrulyYouSDK.ts
CHANGED
|
@@ -1969,5 +1969,55 @@ export class TrulyYouSDK {
|
|
|
1969
1969
|
console.log(`[SDK-PROBE]: ${handoff ? 'Handoff ' : ''}KeyId not found in same-origin localStorage, probing TrulyYou frontend...`)
|
|
1970
1970
|
return await this.probeIframeForKey(handoff)
|
|
1971
1971
|
}
|
|
1972
|
+
|
|
1973
|
+
/**
|
|
1974
|
+
* Clear all keys (both handoff and non-handoff) from localStorage
|
|
1975
|
+
* Clears from both same-origin localStorage and TrulyYou frontend's localStorage via iframe
|
|
1976
|
+
*/
|
|
1977
|
+
async clearAllKeys(): Promise<void> {
|
|
1978
|
+
// Ensure authFlowId is loaded first
|
|
1979
|
+
await this.ensureAuthFlowIdLoaded()
|
|
1980
|
+
|
|
1981
|
+
if (!this.brandingCache?.authFlowId) {
|
|
1982
|
+
console.warn('[SDK-CLEAR]: authFlowId is required but not available')
|
|
1983
|
+
return
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
const authFlowId = this.brandingCache.authFlowId
|
|
1987
|
+
|
|
1988
|
+
// Clear from same-origin localStorage
|
|
1989
|
+
if (typeof window !== 'undefined') {
|
|
1990
|
+
const regularKey = `trulyYouKeyId_${authFlowId}`
|
|
1991
|
+
const handoffKey = `trulyYouKeyId_${authFlowId}_handoff`
|
|
1992
|
+
|
|
1993
|
+
localStorage.removeItem(regularKey)
|
|
1994
|
+
localStorage.removeItem(handoffKey)
|
|
1995
|
+
|
|
1996
|
+
console.log('[SDK-CLEAR]: ✅ Cleared keys from same-origin localStorage:', regularKey, handoffKey)
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
// Also clear from TrulyYou frontend's localStorage via iframe
|
|
2000
|
+
try {
|
|
2001
|
+
const iframe = document.createElement('iframe')
|
|
2002
|
+
iframe.style.cssText = 'position: fixed; top: -9999px; left: -9999px; width: 1px; height: 1px; border: none; opacity: 0; pointer-events: none;'
|
|
2003
|
+
|
|
2004
|
+
const clearUrl = new URL(`${this.frontendUrl}/clear-keys.html`)
|
|
2005
|
+
clearUrl.searchParams.set('authFlowId', authFlowId)
|
|
2006
|
+
|
|
2007
|
+
iframe.src = clearUrl.toString()
|
|
2008
|
+
document.body.appendChild(iframe)
|
|
2009
|
+
|
|
2010
|
+
// Clean up after a delay
|
|
2011
|
+
setTimeout(() => {
|
|
2012
|
+
if (iframe.parentNode) {
|
|
2013
|
+
iframe.parentNode.removeChild(iframe)
|
|
2014
|
+
}
|
|
2015
|
+
}, 2000)
|
|
2016
|
+
|
|
2017
|
+
console.log('[SDK-CLEAR]: ✅ Cleared keys from TrulyYou frontend localStorage via iframe')
|
|
2018
|
+
} catch (error) {
|
|
2019
|
+
console.warn('[SDK-CLEAR]: Failed to clear keys from TrulyYou frontend localStorage:', error)
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
1972
2022
|
}
|
|
1973
2023
|
|