@sparkvault/sdk-js 8.8.4 → 8.9.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.
@@ -21,6 +21,7 @@ export declare class IdentityRenderer {
21
21
  private readonly passkeyHandler;
22
22
  private readonly otpHandler;
23
23
  private readonly sparkLinkHandler;
24
+ private identityPrefilled;
24
25
  private currentView;
25
26
  private focusTimeoutId;
26
27
  private morphTimer;
@@ -6254,6 +6254,12 @@ const SPARKLINK_CSP_BLOCKED_ERROR = {
6254
6254
  };
6255
6255
  class IdentityRenderer {
6256
6256
  constructor(container, api, options, callbacks) {
6257
+ // True only when the identifier was prefilled by the flow (invite / simple
6258
+ // redirect), not typed by the person. Gates the "identity is fixed" behavior
6259
+ // so a no-hint simple-mode session where the person types their own
6260
+ // identifier still gets a change-identity back link and single-method
6261
+ // auto-proceed.
6262
+ this.identityPrefilled = false;
6257
6263
  // View management
6258
6264
  this.currentView = null;
6259
6265
  this.focusTimeoutId = null;
@@ -6311,6 +6317,8 @@ class IdentityRenderer {
6311
6317
  else {
6312
6318
  this.verificationState.setIdentity(validateEmail(raw) ?? raw, 'email');
6313
6319
  }
6320
+ // The flow supplied the identifier — it is fixed, not user-changeable.
6321
+ this.identityPrefilled = true;
6314
6322
  }
6315
6323
  /**
6316
6324
  * True when the identifier is fixed by the flow and the person must prove
@@ -6320,7 +6328,8 @@ class IdentityRenderer {
6320
6328
  * identifier than the one they were invited as.
6321
6329
  */
6322
6330
  isIdentityFixed() {
6323
- return this.verificationState.authContext?.simpleMode !== undefined;
6331
+ return this.identityPrefilled
6332
+ && this.verificationState.authContext?.simpleMode !== undefined;
6324
6333
  }
6325
6334
  /**
6326
6335
  * Fire the host's onSuccess callback, swallowing any exception so a
@@ -6904,7 +6913,14 @@ class IdentityRenderer {
6904
6913
  void this.launchPasskeyVerify(true);
6905
6914
  return;
6906
6915
  }
6907
- if (methods.length === 1) {
6916
+ // A single enabled method normally auto-fires so the recipient skips a
6917
+ // redundant one-item picker. But when the identity is fixed by an invite,
6918
+ // auto-firing an OTP would silently send a code (another SMS/email) the
6919
+ // instant the recipient opens the link, with no consent and re-sent on every
6920
+ // reload. In that case render the picker as a one-tap consent gate instead;
6921
+ // the recipient taps to request the code. (Passkey auto-route above still
6922
+ // applies — a biometric prompt costs nothing and can be dismissed.)
6923
+ if (methods.length === 1 && !this.isIdentityFixed()) {
6908
6924
  this.handleMethodSelect(methods[0]);
6909
6925
  return;
6910
6926
  }
@@ -6916,6 +6932,9 @@ class IdentityRenderer {
6916
6932
  }
6917
6933
  handleIdentitySubmit(result) {
6918
6934
  this.verificationState.setIdentity(result.value, result.type);
6935
+ // The person typed this identifier, so it is theirs to change — a no-hint
6936
+ // simple-mode session must keep the back link + single-method auto-proceed.
6937
+ this.identityPrefilled = false;
6919
6938
  this.showMethodSelect();
6920
6939
  }
6921
6940
  getAllowedIdentityTypes() {