@sparkvault/sdk-js 9.0.0 → 9.0.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 CHANGED
@@ -579,7 +579,7 @@ declare class IdentityModule {
579
579
  private consumeSignInPending;
580
580
  /** Remove the result fragment from the URL bar (and history entry). */
581
581
  private clearUrlFragment;
582
- /** Drop the one-shot PKCE state/verifier (+ recovery hint) a bounce staged. */
582
+ /** Drop the one-shot PKCE state/verifier a bounce staged. */
583
583
  private clearOneShotAuthState;
584
584
  private consumeRedirectResult;
585
585
  /**
package/dist/index.mjs CHANGED
@@ -8574,18 +8574,6 @@ const PORTAL_SECTIONS = ['home', 'identity', 'security', 'sessions', 'sites'];
8574
8574
  // listener but not sessionStorage) is what lets the next load self-heal.
8575
8575
  const PENDING_KEY = 'sv_signin_pending';
8576
8576
  const PENDING_TTL_MS = 10 * 60 * 1000;
8577
- // One-shot: the identifier the recovery bounce is re-minting for. Written only
8578
- // by the recovery bounce; the return leg consumes it to verify the redeemed
8579
- // result is for that same account (see consumeHandoffFragment).
8580
- const RECOVERY_HINT_KEY = 'sv_recovery_hint';
8581
- /**
8582
- * Normalize an identifier for equality, mirroring the server: trim, and
8583
- * lowercase emails (a value containing '@'). Phones compare trimmed-exact.
8584
- */
8585
- function normalizeIdentity(value) {
8586
- const trimmed = value.trim();
8587
- return trimmed.includes('@') ? trimmed.toLowerCase() : trimmed;
8588
- }
8589
8577
  /**
8590
8578
  * Read and parse the pending marker — JSON `{ at, hint }`, where `hint` is the
8591
8579
  * email or phone the sign-in was started with (null when the flow collects the
@@ -9087,11 +9075,9 @@ class IdentityModule {
9087
9075
  // (and a StrictMode double-invocation finds an empty hash and no-ops).
9088
9076
  let expectedState = null;
9089
9077
  let codeVerifier = null;
9090
- let expectedRecoveryIdentity = null;
9091
9078
  try {
9092
9079
  expectedState = sessionStorage.getItem('sv_oauth_state');
9093
9080
  codeVerifier = sessionStorage.getItem('sv_pkce_verifier');
9094
- expectedRecoveryIdentity = sessionStorage.getItem(RECOVERY_HINT_KEY);
9095
9081
  this.clearOneShotAuthState();
9096
9082
  }
9097
9083
  catch {
@@ -9112,6 +9098,12 @@ class IdentityModule {
9112
9098
  if (!codeVerifier) {
9113
9099
  throw new ValidationError('Sign-in session was lost — please sign in again.');
9114
9100
  }
9101
+ // WHICH account the code carries is settled where it is minted, never
9102
+ // here: the code is PKCE- and origin-bound to this tab, and a recovery
9103
+ // bounce only ever mints for the account its `login_hint` named (see
9104
+ // startRecoveryBounce). The redeemed result exposes just that account's
9105
+ // PRIMARY identifier — not necessarily the one the caller signed in
9106
+ // with — so re-checking it here could only discard valid sign-ins.
9115
9107
  const raw = await this.api.redeemHandoffCode(code, codeVerifier);
9116
9108
  const result = {
9117
9109
  token: raw.token,
@@ -9121,18 +9113,6 @@ class IdentityModule {
9121
9113
  sessionId: raw.session_id ?? undefined,
9122
9114
  refreshToken: raw.refresh_token ?? undefined,
9123
9115
  };
9124
- // A recovery bounce carries the identifier the interrupted sign-in was
9125
- // addressing, but /sso treats a hint matching no hub session like no hint
9126
- // at all (anti-oracle) — so the bounce can come back holding a DIFFERENT
9127
- // single-eligible account. The client is the one place that knows which
9128
- // account the person was signing in to: a mismatched result is discarded,
9129
- // never handed to the host (a wrong-account handoff). Silent — no
9130
- // onError — falling through to interactive sign-in, matching the recovery
9131
- // flow's non-oracle posture.
9132
- if (expectedRecoveryIdentity &&
9133
- normalizeIdentity(expectedRecoveryIdentity) !== normalizeIdentity(result.identity)) {
9134
- return null;
9135
- }
9136
9116
  options.onSuccess?.(result);
9137
9117
  return result;
9138
9118
  }
@@ -9153,22 +9133,12 @@ class IdentityModule {
9153
9133
  */
9154
9134
  async startRecoveryBounce(loginHint) {
9155
9135
  const sso = new URL(`${this.config.identityBaseUrl}/${this.config.accountId}/sso`);
9156
- // With several hub sessions, login_hint tells /sso which account the
9157
- // interrupted sign-in was addressing, so recovery never re-mints another.
9158
- // Also stash it one-shot: a hint matching no hub session deliberately
9159
- // behaves server-side like no hint at all (anti-oracle), so the return leg
9160
- // must verify the redeemed identity is the one this sign-in was for.
9161
- try {
9162
- if (loginHint) {
9163
- sessionStorage.setItem(RECOVERY_HINT_KEY, loginHint);
9164
- }
9165
- else {
9166
- sessionStorage.removeItem(RECOVERY_HINT_KEY);
9167
- }
9168
- }
9169
- catch {
9170
- // No storage → prepareHandoffNavigation bails below; nothing to verify.
9171
- }
9136
+ // With several hub sessions, login_hint names the account the interrupted
9137
+ // sign-in was addressing, and it is the whole wrong-account defence: /sso
9138
+ // mints silently ONLY for a hint that matched exactly one hub session's
9139
+ // verified identifiers — every unsatisfiable hint (a stranger's address, an
9140
+ // ambiguous match, an account not eligible here) comes back with no result
9141
+ // at all rather than a different account's.
9172
9142
  if (loginHint) {
9173
9143
  sso.searchParams.set('login_hint', loginHint);
9174
9144
  }
@@ -9176,16 +9146,6 @@ class IdentityModule {
9176
9146
  if (nav) {
9177
9147
  window.location.assign(nav);
9178
9148
  }
9179
- else {
9180
- // The bounce never left (no storage or WebCrypto) — retire the stash so
9181
- // it cannot linger into an unrelated later return leg.
9182
- try {
9183
- sessionStorage.removeItem(RECOVERY_HINT_KEY);
9184
- }
9185
- catch {
9186
- // Storage disabled: nothing was persisted, nothing to clear.
9187
- }
9188
- }
9189
9149
  }
9190
9150
  /**
9191
9151
  * Explicit `flow: 'redirect'` — navigate this tab to the interactive sign-in
@@ -9285,12 +9245,11 @@ class IdentityModule {
9285
9245
  window.history.replaceState(window.history.state, document.title, `${window.location.pathname}${window.location.search}`);
9286
9246
  }
9287
9247
  }
9288
- /** Drop the one-shot PKCE state/verifier (+ recovery hint) a bounce staged. */
9248
+ /** Drop the one-shot PKCE state/verifier a bounce staged. */
9289
9249
  clearOneShotAuthState() {
9290
9250
  try {
9291
9251
  sessionStorage.removeItem('sv_oauth_state');
9292
9252
  sessionStorage.removeItem('sv_pkce_verifier');
9293
- sessionStorage.removeItem(RECOVERY_HINT_KEY);
9294
9253
  }
9295
9254
  catch {
9296
9255
  // Storage disabled: nothing was persisted, nothing to clear.
@@ -14793,7 +14752,7 @@ class SparkVault {
14793
14752
  }
14794
14753
  /** Get the SDK version */
14795
14754
  static get version() {
14796
- return '9.0.0';
14755
+ return '9.0.1';
14797
14756
  }
14798
14757
  }
14799
14758
  if (typeof window !== 'undefined') {