@truly-you/trulyyou-web-sdk 0.1.8 → 0.1.10
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 +1 -1
- package/package.json +1 -1
- package/src/sdk/TrulyYouSDK.ts +16 -16
|
@@ -69,7 +69,7 @@ export declare class TrulyYouSDK {
|
|
|
69
69
|
uri: string;
|
|
70
70
|
method: string;
|
|
71
71
|
headers?: any;
|
|
72
|
-
}, signatureId?: string): Promise<SigningResult>;
|
|
72
|
+
}, signatureId?: string, existingKeyId?: string): Promise<SigningResult>;
|
|
73
73
|
/**
|
|
74
74
|
* Fetch with automatic payload signing
|
|
75
75
|
*/
|
package/package.json
CHANGED
package/src/sdk/TrulyYouSDK.ts
CHANGED
|
@@ -1657,7 +1657,7 @@ export class TrulyYouSDK {
|
|
|
1657
1657
|
uri: string
|
|
1658
1658
|
method: string
|
|
1659
1659
|
headers?: any
|
|
1660
|
-
}, signatureId?: string): Promise<SigningResult> {
|
|
1660
|
+
}, signatureId?: string, existingKeyId?: string): Promise<SigningResult> {
|
|
1661
1661
|
try {
|
|
1662
1662
|
// Step 1: Check if desktop device first - desktop uses WebSocket handoff (no key probe needed)
|
|
1663
1663
|
if (this.isDesktopDevice()) {
|
|
@@ -1668,21 +1668,24 @@ export class TrulyYouSDK {
|
|
|
1668
1668
|
return await this.signWithWebSocketHandoff(apiCallStructure, signatureId)
|
|
1669
1669
|
}
|
|
1670
1670
|
|
|
1671
|
-
// Step 2: Mobile device -
|
|
1672
|
-
|
|
1673
|
-
let keyId = await this.probeIframeForKey()
|
|
1671
|
+
// Step 2: Mobile device - use existing keyId if provided, otherwise probe
|
|
1672
|
+
let keyId = existingKeyId
|
|
1674
1673
|
|
|
1675
1674
|
if (!keyId) {
|
|
1676
|
-
|
|
1677
|
-
console.log('[SDK]: No valid active key found (missing, invalid, revoked, or expired), opening enrollment popup...')
|
|
1678
|
-
await this.enrollWithPopup()
|
|
1679
|
-
|
|
1680
|
-
// Step 4: After enrollment, probe again to verify new key is active
|
|
1675
|
+
console.log('[SDK]: Mobile device detected, probing iframe for existing key...')
|
|
1681
1676
|
keyId = await this.probeIframeForKey()
|
|
1682
1677
|
|
|
1683
1678
|
if (!keyId) {
|
|
1684
|
-
|
|
1679
|
+
// Step 3: No valid active key found (missing, invalid, revoked, or expired) - open enrollment popup
|
|
1680
|
+
console.log('[SDK]: No valid active key found (missing, invalid, revoked, or expired), opening enrollment popup...')
|
|
1681
|
+
keyId = await this.enrollWithPopup()
|
|
1682
|
+
|
|
1683
|
+
if (!keyId) {
|
|
1684
|
+
throw new Error('Enrollment completed but no valid active key found')
|
|
1685
|
+
}
|
|
1685
1686
|
}
|
|
1687
|
+
} else {
|
|
1688
|
+
console.log('[SDK]: Using existing keyId from enrollment:', keyId)
|
|
1686
1689
|
}
|
|
1687
1690
|
|
|
1688
1691
|
console.log('[SDK]: Valid active key found, signing with keyId:', keyId)
|
|
@@ -1760,10 +1763,7 @@ export class TrulyYouSDK {
|
|
|
1760
1763
|
if (!keyId) {
|
|
1761
1764
|
// No key found, trigger enrollment
|
|
1762
1765
|
console.log('[SDK]: No key in iframe either, opening enrollment popup...')
|
|
1763
|
-
await this.enrollWithPopup()
|
|
1764
|
-
|
|
1765
|
-
// After enrollment, probe again to get the new key
|
|
1766
|
-
keyId = await this.probeIframeForKey()
|
|
1766
|
+
keyId = await this.enrollWithPopup()
|
|
1767
1767
|
|
|
1768
1768
|
if (!keyId) {
|
|
1769
1769
|
throw new Error('Enrollment completed but no key found. Please try again.')
|
|
@@ -1802,8 +1802,8 @@ export class TrulyYouSDK {
|
|
|
1802
1802
|
throw new Error('Failed to create signature: ' + (errorData.error || 'Creation request failed'))
|
|
1803
1803
|
}
|
|
1804
1804
|
|
|
1805
|
-
// Now sign the payload (pass signatureId for desktop handoff)
|
|
1806
|
-
const signingResult = await this.signPayload(apiCallStructure, signatureId)
|
|
1805
|
+
// Now sign the payload (pass signatureId for desktop handoff, and keyId if we have it)
|
|
1806
|
+
const signingResult = await this.signPayload(apiCallStructure, signatureId, keyId || undefined)
|
|
1807
1807
|
|
|
1808
1808
|
// Make the actual API call with signature and signatureId in header
|
|
1809
1809
|
// Use keyId from signingResult (Device B's keyId for handoff, or localStorage keyId for mobile)
|