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