@sparkvault/sdk-js 8.8.0 → 8.8.1
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.d.ts +11 -2
- package/dist/products/identity/index.d.ts +11 -2
- package/dist/sparkvault.cjs.js +65 -20
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +65 -20
- package/dist/sparkvault.esm.js.map +1 -1
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -469,14 +469,14 @@ declare class IdentityModule {
|
|
|
469
469
|
* session storage or WebCrypto is unavailable so callers can degrade.
|
|
470
470
|
*/
|
|
471
471
|
private prepareHandoffNavigation;
|
|
472
|
-
private static readonly PENDING_KEY;
|
|
473
|
-
private static readonly PENDING_TTL_MS;
|
|
474
472
|
private markSignInPending;
|
|
475
473
|
private clearSignInPending;
|
|
476
474
|
/** True once (then cleared) if a recent sign-in is still awaiting its result. */
|
|
477
475
|
private consumeSignInPending;
|
|
478
476
|
/** Remove the result fragment from the URL bar (and history entry). */
|
|
479
477
|
private clearUrlFragment;
|
|
478
|
+
/** Drop the one-shot PKCE state/verifier a redirect bounce staged. */
|
|
479
|
+
private clearOneShotAuthState;
|
|
480
480
|
private consumeRedirectResult;
|
|
481
481
|
/**
|
|
482
482
|
* Close the identity dialog/inline UI if open.
|
|
@@ -1909,6 +1909,15 @@ declare class SparkVault {
|
|
|
1909
1909
|
* });
|
|
1910
1910
|
*/
|
|
1911
1911
|
static init(config: SparkVaultConfig): SparkVault;
|
|
1912
|
+
/**
|
|
1913
|
+
* Whether a sign-in needs completing on this page load — a returned handoff
|
|
1914
|
+
* fragment, or a popup whose result was lost (a mobile opener-tab discard).
|
|
1915
|
+
* Side effect-free and instance-free, so a host that defers SDK init for
|
|
1916
|
+
* performance can cheaply decide whether to boot the SDK and call
|
|
1917
|
+
* `products.identity.handleRedirectResult()` on a given load, without reaching
|
|
1918
|
+
* into the SDK's internal storage keys.
|
|
1919
|
+
*/
|
|
1920
|
+
static isRecoveryPending(): boolean;
|
|
1912
1921
|
/** Get the SDK version */
|
|
1913
1922
|
static get version(): string;
|
|
1914
1923
|
}
|
|
@@ -12,6 +12,15 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import type { ResolvedConfig } from '../../config';
|
|
14
14
|
import type { VerifyOptions, VerifyResult, SignInOptions, SignInResult, TokenClaims, AttachOptions, PortalUrlOptions, RedirectResultOptions } from './types';
|
|
15
|
+
/**
|
|
16
|
+
* Whether `handleRedirectResult()` has anything to do on this load — a returned
|
|
17
|
+
* sign-in fragment to consume, or a pending sign-in to self-heal. Public + side
|
|
18
|
+
* effect-free (peeks, never consumes) so a host that defers SDK init for
|
|
19
|
+
* performance can cheaply decide whether to boot the SDK on a given page load,
|
|
20
|
+
* WITHOUT reaching into the SDK's internal storage keys. Exposed as
|
|
21
|
+
* `SparkVault.isRecoveryPending()`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isSignInRecoveryPending(): boolean;
|
|
15
24
|
export declare class IdentityModule {
|
|
16
25
|
private readonly config;
|
|
17
26
|
private readonly api;
|
|
@@ -170,14 +179,14 @@ export declare class IdentityModule {
|
|
|
170
179
|
* session storage or WebCrypto is unavailable so callers can degrade.
|
|
171
180
|
*/
|
|
172
181
|
private prepareHandoffNavigation;
|
|
173
|
-
private static readonly PENDING_KEY;
|
|
174
|
-
private static readonly PENDING_TTL_MS;
|
|
175
182
|
private markSignInPending;
|
|
176
183
|
private clearSignInPending;
|
|
177
184
|
/** True once (then cleared) if a recent sign-in is still awaiting its result. */
|
|
178
185
|
private consumeSignInPending;
|
|
179
186
|
/** Remove the result fragment from the URL bar (and history entry). */
|
|
180
187
|
private clearUrlFragment;
|
|
188
|
+
/** Drop the one-shot PKCE state/verifier a redirect bounce staged. */
|
|
189
|
+
private clearOneShotAuthState;
|
|
181
190
|
private consumeRedirectResult;
|
|
182
191
|
/**
|
|
183
192
|
* Close the identity dialog/inline UI if open.
|
package/dist/sparkvault.cjs.js
CHANGED
|
@@ -8378,6 +8378,40 @@ function attachClickHandler(selector, onClick) {
|
|
|
8378
8378
|
* sv.products.identity.attach('.login-btn');
|
|
8379
8379
|
*/
|
|
8380
8380
|
const PORTAL_SECTIONS = ['home', 'identity', 'security', 'sessions', 'sites'];
|
|
8381
|
+
// A sign-in is "pending" from popup open until its result arrives; a marker
|
|
8382
|
+
// that outlives a lost result (a mobile opener-tab discard clears the message
|
|
8383
|
+
// listener but not sessionStorage) is what lets the next load self-heal.
|
|
8384
|
+
const PENDING_KEY = 'sv_signin_pending';
|
|
8385
|
+
const PENDING_TTL_MS = 10 * 60 * 1000;
|
|
8386
|
+
/** True when the pending marker is present and still within its TTL. */
|
|
8387
|
+
function hasFreshPendingMarker() {
|
|
8388
|
+
let raw = null;
|
|
8389
|
+
try {
|
|
8390
|
+
raw = sessionStorage.getItem(PENDING_KEY);
|
|
8391
|
+
}
|
|
8392
|
+
catch {
|
|
8393
|
+
return false;
|
|
8394
|
+
}
|
|
8395
|
+
const at = raw ? Number(raw) : NaN;
|
|
8396
|
+
return Number.isFinite(at) && Date.now() - at < PENDING_TTL_MS;
|
|
8397
|
+
}
|
|
8398
|
+
/**
|
|
8399
|
+
* Whether `handleRedirectResult()` has anything to do on this load — a returned
|
|
8400
|
+
* sign-in fragment to consume, or a pending sign-in to self-heal. Public + side
|
|
8401
|
+
* effect-free (peeks, never consumes) so a host that defers SDK init for
|
|
8402
|
+
* performance can cheaply decide whether to boot the SDK on a given page load,
|
|
8403
|
+
* WITHOUT reaching into the SDK's internal storage keys. Exposed as
|
|
8404
|
+
* `SparkVault.isRecoveryPending()`.
|
|
8405
|
+
*/
|
|
8406
|
+
function isSignInRecoveryPending() {
|
|
8407
|
+
if (typeof window === 'undefined') {
|
|
8408
|
+
return false;
|
|
8409
|
+
}
|
|
8410
|
+
if (/[#&](sv_code|sv_error|sso)=/.test(window.location.hash || '')) {
|
|
8411
|
+
return true;
|
|
8412
|
+
}
|
|
8413
|
+
return hasFreshPendingMarker();
|
|
8414
|
+
}
|
|
8381
8415
|
function isTokenClaims(payload) {
|
|
8382
8416
|
if (typeof payload !== 'object' || payload === null) {
|
|
8383
8417
|
return false;
|
|
@@ -8769,9 +8803,12 @@ class IdentityModule {
|
|
|
8769
8803
|
return this.consumeHandoffFragment(params, options);
|
|
8770
8804
|
}
|
|
8771
8805
|
// A silent-SSO recovery that found no live session returns `#sso=…`; strip
|
|
8772
|
-
// it so the logged-out load is clean,
|
|
8806
|
+
// it so the logged-out load is clean, retire the one-shot state/verifier the
|
|
8807
|
+
// outbound bounce staged (dead now — no code came back), and do not re-bounce
|
|
8808
|
+
// (handled below).
|
|
8773
8809
|
if (params.get('sso')) {
|
|
8774
8810
|
this.clearUrlFragment();
|
|
8811
|
+
this.clearOneShotAuthState();
|
|
8775
8812
|
}
|
|
8776
8813
|
// No returned result. If a sign-in was in flight and its result never
|
|
8777
8814
|
// arrived, self-heal once from the SSO session (mobile opener-tab discard).
|
|
@@ -8796,8 +8833,7 @@ class IdentityModule {
|
|
|
8796
8833
|
try {
|
|
8797
8834
|
expectedState = sessionStorage.getItem('sv_oauth_state');
|
|
8798
8835
|
codeVerifier = sessionStorage.getItem('sv_pkce_verifier');
|
|
8799
|
-
|
|
8800
|
-
sessionStorage.removeItem('sv_pkce_verifier');
|
|
8836
|
+
this.clearOneShotAuthState();
|
|
8801
8837
|
}
|
|
8802
8838
|
catch {
|
|
8803
8839
|
// Storage disabled (private mode): state/verifier were never persisted.
|
|
@@ -8910,7 +8946,7 @@ class IdentityModule {
|
|
|
8910
8946
|
}
|
|
8911
8947
|
markSignInPending() {
|
|
8912
8948
|
try {
|
|
8913
|
-
sessionStorage.setItem(
|
|
8949
|
+
sessionStorage.setItem(PENDING_KEY, String(Date.now()));
|
|
8914
8950
|
}
|
|
8915
8951
|
catch {
|
|
8916
8952
|
// No storage → no self-heal; the popup still delivers when it can.
|
|
@@ -8918,7 +8954,7 @@ class IdentityModule {
|
|
|
8918
8954
|
}
|
|
8919
8955
|
clearSignInPending() {
|
|
8920
8956
|
try {
|
|
8921
|
-
sessionStorage.removeItem(
|
|
8957
|
+
sessionStorage.removeItem(PENDING_KEY);
|
|
8922
8958
|
}
|
|
8923
8959
|
catch {
|
|
8924
8960
|
// Nothing to clear.
|
|
@@ -8926,16 +8962,9 @@ class IdentityModule {
|
|
|
8926
8962
|
}
|
|
8927
8963
|
/** True once (then cleared) if a recent sign-in is still awaiting its result. */
|
|
8928
8964
|
consumeSignInPending() {
|
|
8929
|
-
|
|
8930
|
-
|
|
8931
|
-
|
|
8932
|
-
sessionStorage.removeItem(IdentityModule.PENDING_KEY);
|
|
8933
|
-
}
|
|
8934
|
-
catch {
|
|
8935
|
-
return false;
|
|
8936
|
-
}
|
|
8937
|
-
const at = raw ? Number(raw) : NaN;
|
|
8938
|
-
return Number.isFinite(at) && Date.now() - at < IdentityModule.PENDING_TTL_MS;
|
|
8965
|
+
const fresh = hasFreshPendingMarker();
|
|
8966
|
+
this.clearSignInPending();
|
|
8967
|
+
return fresh;
|
|
8939
8968
|
}
|
|
8940
8969
|
/** Remove the result fragment from the URL bar (and history entry). */
|
|
8941
8970
|
clearUrlFragment() {
|
|
@@ -8943,6 +8972,16 @@ class IdentityModule {
|
|
|
8943
8972
|
window.history.replaceState(window.history.state, document.title, `${window.location.pathname}${window.location.search}`);
|
|
8944
8973
|
}
|
|
8945
8974
|
}
|
|
8975
|
+
/** Drop the one-shot PKCE state/verifier a redirect bounce staged. */
|
|
8976
|
+
clearOneShotAuthState() {
|
|
8977
|
+
try {
|
|
8978
|
+
sessionStorage.removeItem('sv_oauth_state');
|
|
8979
|
+
sessionStorage.removeItem('sv_pkce_verifier');
|
|
8980
|
+
}
|
|
8981
|
+
catch {
|
|
8982
|
+
// Storage disabled: nothing was persisted, nothing to clear.
|
|
8983
|
+
}
|
|
8984
|
+
}
|
|
8946
8985
|
async consumeRedirectResult() {
|
|
8947
8986
|
if (typeof window === 'undefined' || !window.location.hash) {
|
|
8948
8987
|
return null;
|
|
@@ -9068,11 +9107,6 @@ class IdentityModule {
|
|
|
9068
9107
|
return this.runFlow(options);
|
|
9069
9108
|
}
|
|
9070
9109
|
}
|
|
9071
|
-
// A sign-in is "pending" from popup open until its result arrives; a marker
|
|
9072
|
-
// that outlives a lost result (mobile opener-tab discard clears the message
|
|
9073
|
-
// listener but not sessionStorage) is what lets the next load self-heal.
|
|
9074
|
-
IdentityModule.PENDING_KEY = 'sv_signin_pending';
|
|
9075
|
-
IdentityModule.PENDING_TTL_MS = 10 * 60 * 1000;
|
|
9076
9110
|
|
|
9077
9111
|
/**
|
|
9078
9112
|
* Products Module
|
|
@@ -13596,6 +13630,17 @@ class SparkVault {
|
|
|
13596
13630
|
static init(config) {
|
|
13597
13631
|
return new SparkVault(config);
|
|
13598
13632
|
}
|
|
13633
|
+
/**
|
|
13634
|
+
* Whether a sign-in needs completing on this page load — a returned handoff
|
|
13635
|
+
* fragment, or a popup whose result was lost (a mobile opener-tab discard).
|
|
13636
|
+
* Side effect-free and instance-free, so a host that defers SDK init for
|
|
13637
|
+
* performance can cheaply decide whether to boot the SDK and call
|
|
13638
|
+
* `products.identity.handleRedirectResult()` on a given load, without reaching
|
|
13639
|
+
* into the SDK's internal storage keys.
|
|
13640
|
+
*/
|
|
13641
|
+
static isRecoveryPending() {
|
|
13642
|
+
return isSignInRecoveryPending();
|
|
13643
|
+
}
|
|
13599
13644
|
/** Get the SDK version */
|
|
13600
13645
|
static get version() {
|
|
13601
13646
|
return '__VERSION__';
|