@sparkvault/sdk-js 1.27.7 → 2.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SparkVault JavaScript SDK
2
2
 
3
- The official SparkVault JavaScript SDK for browser applications. Add passwordless authentication to your app in minutes with zero-config integration or full programmatic control.
3
+ The official SparkVault JavaScript SDK for browser applications. Add passwordless verification to your app in minutes with CDN auto-init or full programmatic control.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@sparkvault/sdk-js.svg)](https://www.npmjs.com/package/@sparkvault/sdk-js)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
@@ -8,10 +8,11 @@ The official SparkVault JavaScript SDK for browser applications. Add passwordles
8
8
  ## Table of Contents
9
9
 
10
10
  - [Installation](#installation)
11
- - [Zero-Config Integration](#zero-config-integration)
11
+ - [CDN Auto-Init](#cdn-auto-init)
12
12
  - [Manual Initialization](#manual-initialization)
13
13
  - [Identity Verification](#identity-verification)
14
14
  - [Backend Token Verification](#backend-token-verification)
15
+ - [Full OIDC/BFF Session Ownership](#full-oidcbff-session-ownership)
15
16
  - [React Integration](#react-integration)
16
17
  - [Error Handling](#error-handling)
17
18
  - [TypeScript Support](#typescript-support)
@@ -40,44 +41,39 @@ yarn add @sparkvault/sdk-js
40
41
  - `sparkvault.esm.js` — ES modules for modern bundlers
41
42
  - `sparkvault.cjs.js` — CommonJS for Node.js
42
43
 
43
- ## Zero-Config Integration
44
-
45
- Add SparkVault authentication to your site with a single script tag — no JavaScript required!
44
+ ## CDN Auto-Init
46
45
 
47
46
  ```html
48
- <!-- Add this single script tag -->
49
47
  <script
50
48
  async
51
49
  src="https://cdn.sparkvault.com/sdk/v1/sparkvault.js"
52
50
  data-account-id="acc_YOUR_ACCOUNT_ID"
53
- data-attach-selector=".login-btn"
54
- data-success-url="/auth/verify-token"
55
51
  ></script>
56
52
 
57
- <!-- Any element matching the selector becomes a login button -->
58
53
  <button class="login-btn">Sign In</button>
59
- <a href="#" class="login-btn">Create Account</a>
54
+
55
+ <script>
56
+ SparkVault.identity.attach('.login-btn', {
57
+ onSuccess: async (result) => {
58
+ await fetch('/api/auth/verify', {
59
+ method: 'POST',
60
+ headers: { 'Content-Type': 'application/json' },
61
+ body: JSON.stringify({ token: result.token })
62
+ });
63
+ }
64
+ });
65
+ </script>
60
66
  ```
61
67
 
62
- That's it! The SDK automatically:
63
- - Initializes with your account ID
64
- - Attaches click handlers to all matching elements
65
- - Opens the verification modal when clicked
66
- - POSTs the result to your success URL
67
- - Watches for dynamically added elements (MutationObserver)
68
+ The script auto-initializes `SparkVault` with your account ID. Use
69
+ `SparkVault.identity.attach()` or `SparkVault.identity.pop()` to open the
70
+ verification UI and handle the result.
68
71
 
69
72
  ### Data Attributes
70
73
 
71
74
  | Attribute | Required | Description |
72
75
  |-----------|----------|-------------|
73
76
  | `data-account-id` | Yes | Your SparkVault account ID (required for auto-init) |
74
- | `data-attach-selector` | No | CSS selector for elements to attach click handlers |
75
- | `data-success-url` | No | URL to POST `{ token, identity, identityType }` on success |
76
- | `data-success-function` | No | Global function name to call on success (e.g., `"MyApp.auth.onSuccess"`) |
77
- | `data-error-url` | No | URL to redirect on error (appends `?error=message`) |
78
- | `data-error-function` | No | Global function name to call on error |
79
- | `data-preload-config` | No | Set to `"false"` to defer config loading. Default: true |
80
- | `data-timeout` | No | Request timeout in milliseconds. Default: 30000 |
81
77
  | `data-debug` | No | Set to `"true"` for verbose console logging |
82
78
 
83
79
  ### Complete Example
@@ -87,25 +83,24 @@ That's it! The SDK automatically:
87
83
  async
88
84
  src="https://cdn.sparkvault.com/sdk/v1/sparkvault.js"
89
85
  data-account-id="acc_YOUR_ACCOUNT_ID"
90
- data-attach-selector=".js-sparkvault-auth"
91
- data-success-url="https://example.com/auth/verify-token"
92
- data-success-function="onSparkVaultSuccess"
93
- data-error-function="onSparkVaultError"
94
86
  data-debug="true"
95
87
  ></script>
96
88
 
97
89
  <script>
98
- // Optional: Define callback functions
99
- function onSparkVaultSuccess(result) {
100
- console.log('Verified:', result.identity);
101
- console.log('Token:', result.token);
102
- // The SDK will also POST to data-success-url
103
- }
104
-
105
- function onSparkVaultError(error) {
106
- console.error('Error:', error.message);
107
- alert('Authentication failed. Please try again.');
108
- }
90
+ SparkVault.identity.attach('.js-sparkvault-auth', {
91
+ onSuccess: async (result) => {
92
+ const response = await fetch('/api/auth/verify', {
93
+ method: 'POST',
94
+ headers: { 'Content-Type': 'application/json' },
95
+ body: JSON.stringify({ token: result.token })
96
+ });
97
+ if (!response.ok) throw new Error('Verification failed');
98
+ window.location.assign('/dashboard');
99
+ },
100
+ onError: (error) => {
101
+ console.error('SparkVault verification failed:', error.message);
102
+ }
103
+ });
109
104
  </script>
110
105
 
111
106
  <!-- Multiple elements can use the same selector -->
@@ -113,32 +108,23 @@ That's it! The SDK automatically:
113
108
  <a href="#" class="js-sparkvault-auth">Login with SparkVault</a>
114
109
  ```
115
110
 
116
- ### Success URL Response
111
+ ### Verification Result
117
112
 
118
- When you specify `data-success-url`, the SDK POSTs the verification result:
113
+ The SDK returns this shape from `identity.pop()`, `identity.verify()`, and
114
+ `identity.attach()` callbacks:
119
115
 
120
116
  ```json
121
117
  {
122
118
  "token": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...",
123
119
  "identity": "user@example.com",
124
- "identityType": "email"
120
+ "identityType": "email",
121
+ "svid": "ing_019e66a4e27875f2822ede0e4f5d8792",
122
+ "sessionId": "sess_abc123"
125
123
  }
126
124
  ```
127
125
 
128
- Your backend can respond with redirect instructions:
129
-
130
- ```javascript
131
- // Option 1: Redirect to a URL
132
- { "redirectUrl": "/dashboard" }
133
- // or
134
- { "redirect_url": "/dashboard" }
135
-
136
- // Option 2: Reload the current page
137
- { "reload": true }
138
-
139
- // Option 3: Return data (no automatic action)
140
- { "success": true, "user": { "id": 123, "email": "user@example.com" } }
141
- ```
126
+ Send `token` to your backend and verify it with the Identity JWKS before
127
+ trusting any claim. Use `svid` as the canonical user key in your application.
142
128
 
143
129
  ### Manual Trigger from JavaScript
144
130
 
@@ -146,9 +132,8 @@ You can also trigger authentication programmatically using the `SparkVault` glob
146
132
 
147
133
  ```javascript
148
134
  // Trigger authentication from anywhere in your code
149
- SparkVault.identity.pop();
150
-
151
- // This uses your configured success/error handlers
135
+ const result = await SparkVault.identity.pop();
136
+ await sendTokenToBackend(result.token);
152
137
  ```
153
138
 
154
139
  ```html
@@ -237,6 +222,9 @@ await fetch('/api/auth/login', {
237
222
  | `token` | `string` | Signed JWT token (Ed25519). Verify this on your backend. |
238
223
  | `identity` | `string` | The verified email address or phone number |
239
224
  | `identityType` | `"email" \| "phone"` | Type of identity that was verified |
225
+ | `svid` | `string` | Canonical SparkVault ID for the person |
226
+ | `sessionId` | `string` | Managed Identity session ID |
227
+ | `refreshToken` | `string` | Present only for flows that intentionally return managed-session refresh material |
240
228
 
241
229
  ### Example with Options
242
230
 
@@ -309,8 +297,12 @@ app.post('/api/auth/login', async (req, res) => {
309
297
  algorithms: ['EdDSA']
310
298
  });
311
299
 
312
- // Token is valid! Create user session
313
- const user = await findOrCreateUser(payload.identity, payload.identity_type);
300
+ // Token is valid. SVID is the canonical identity reference.
301
+ const svid = payload.svid || payload.sub;
302
+ const user = await findOrCreateUserBySvid(svid, {
303
+ identity: payload.identity,
304
+ identityType: payload.identity_type
305
+ });
314
306
  req.session.userId = user.id;
315
307
 
316
308
  res.json({ success: true, user });
@@ -356,8 +348,13 @@ def login():
356
348
  try:
357
349
  claims = verify_identity_token(token)
358
350
 
359
- # Create session
360
- user = find_or_create_user(claims['identity'], claims['identity_type'])
351
+ # SVID is the canonical identity reference.
352
+ svid = claims.get('svid') or claims['sub']
353
+ user = find_or_create_user_by_svid(
354
+ svid,
355
+ identity=claims['identity'],
356
+ identity_type=claims['identity_type']
357
+ )
361
358
  session['user_id'] = user.id
362
359
 
363
360
  return jsonify({'success': True, 'user': user.to_dict()})
@@ -416,8 +413,11 @@ func loginHandler(w http.ResponseWriter, r *http.Request) {
416
413
  return
417
414
  }
418
415
 
419
- identity, _ := token.Get("identity")
420
- // Create session with identity...
416
+ svid, _ := token.Get("svid")
417
+ if svid == nil {
418
+ svid, _ = token.Subject()
419
+ }
420
+ // Find or create your local user by SVID.
421
421
  }
422
422
  ```
423
423
 
@@ -460,7 +460,8 @@ class AuthController < ApplicationController
460
460
  def login
461
461
  claims = verify_identity_token(params[:token])
462
462
 
463
- user = User.find_or_create_by(email: claims['identity'])
463
+ svid = claims['svid'] || claims['sub']
464
+ user = User.find_or_create_by!(svid: svid)
464
465
  session[:user_id] = user.id
465
466
 
466
467
  render json: { success: true, user: user }
@@ -477,8 +478,11 @@ When decoded, the JWT token contains these claims:
477
478
  ```json
478
479
  {
479
480
  "iss": "https://api.sparkvault.com/v1/products/identity/acc_xxx",
480
- "sub": "identity:a1b2c3d4e5f67890",
481
+ "sub": "ing_019e66a4e27875f2822ede0e4f5d8792",
481
482
  "aud": "acc_xxx",
483
+ "svid": "ing_019e66a4e27875f2822ede0e4f5d8792",
484
+ "session_id": "sess_abc123",
485
+ "token_version": 0,
482
486
  "identity": "user@example.com",
483
487
  "identity_type": "email",
484
488
  "method": "totp_email",
@@ -492,8 +496,11 @@ When decoded, the JWT token contains these claims:
492
496
  | Claim | Type | Description |
493
497
  |-------|------|-------------|
494
498
  | `iss` | `string` | Issuer URL — always verify this matches expected value |
495
- | `sub` | `string` | Subject — hashed identity for consistent user identification |
499
+ | `sub` | `string` | Subject — equals the SVID for managed Identity tokens |
496
500
  | `aud` | `string` | Audience — your account ID |
501
+ | `svid` | `string` | Canonical SparkVault ID for the person |
502
+ | `session_id` | `string` | Managed Identity session ID |
503
+ | `token_version` | `number` | Managed-session version used for revocation/introspection |
497
504
  | `identity` | `string` | The verified email address or phone number |
498
505
  | `identity_type` | `string` | `"email"` or `"phone"` |
499
506
  | `method` | `string` | Authentication method used (e.g., `"totp_email"`, `"passkey"`) |
@@ -502,6 +509,27 @@ When decoded, the JWT token contains these claims:
502
509
  | `exp` | `number` | Expiration timestamp |
503
510
  | `jti` | `string` | Unique token ID for replay protection |
504
511
 
512
+ ## Full OIDC/BFF Session Ownership
513
+
514
+ The JavaScript SDK simple flow is a signed verification proof. It is ideal when
515
+ your backend already owns app sessions and only needs to know which SVID was
516
+ verified.
517
+
518
+ For replacing a production login/session system, use SparkVault Identity as the
519
+ OIDC provider and put a backend-for-frontend (BFF) boundary in front of your
520
+ application:
521
+
522
+ 1. Redirect the browser to `/v1/products/identity/{account_id}/authorize` with PKCE.
523
+ 2. Exchange the callback `code` for `id_token`, `access_token`, and `refresh_token` server-side.
524
+ 3. Store refresh/session material only in encrypted or signed `HttpOnly`, `Secure`, `SameSite=Lax` cookies.
525
+ 4. Keep refresh tokens out of browser JavaScript.
526
+ 5. Validate access JWTs locally with cached JWKS for ordinary API requests.
527
+ 6. Call `/introspect` only for sensitive mutations, account settings, admin/moderation actions, suspicious sessions, or short cached hard checks.
528
+ 7. On logout, call `/revoke` with the current refresh token, then clear local cookies.
529
+
530
+ Application data should key people by `svid`. Keep username, roles, profile,
531
+ preferences, uploads, and moderation state in your application database.
532
+
505
533
  ## React Integration
506
534
 
507
535
  ```jsx
@@ -701,11 +729,15 @@ script-src https://cdn.sparkvault.com;
701
729
 
702
730
  1. **Initialize Once** — Create the SparkVault instance once when your app loads, not on every login attempt. The SDK preloads configuration for instant modal opening.
703
731
 
704
- 2. **Always Verify Server-Side** — Never trust client-side token validation in production. Always verify the JWT signature on your backend using the JWKS endpoint before creating a session.
732
+ 2. **Always Verify Server-Side** — Never trust client-side token validation in production. Always verify the JWT signature on your backend using the JWKS endpoint before trusting claims or issuing an app session.
705
733
 
706
734
  3. **Handle Cancellation Gracefully** — Users may close the modal without completing verification. This throws a `UserCancelledError` — handle it gracefully rather than showing an error message.
707
735
 
708
- 4. **Cache JWKS Keys** — The JWKS endpoint returns public keys with caching headers. Use a library like `jose` that handles caching automatically, or cache keys for 5-10 minutes.
736
+ 4. **Key Users by SVID** — Use `svid` or `sub` as the canonical identity reference. Email and phone are user-facing attributes, not durable account keys.
737
+
738
+ 5. **Cache JWKS Keys** — The JWKS endpoint returns public keys with caching headers. Use a library like `jose` that handles caching automatically, or cache keys for 5-10 minutes.
739
+
740
+ 6. **Use OIDC/BFF for Managed Sessions** — The SDK simple flow gives you a signed proof. Use OIDC when you want SparkVault-owned refresh rotation, revocation, introspection, and logout.
709
741
 
710
742
  ## Browser Support
711
743
 
@@ -30,7 +30,7 @@ export interface PasskeyResult {
30
30
  */
31
31
  export interface PasskeyCheckResult {
32
32
  /** Whether the identifier is valid (email domain or phone format) */
33
- emailValid: boolean;
33
+ identityValid: boolean;
34
34
  /** Whether the resolved SVID has registered passkeys */
35
35
  hasPasskey: boolean;
36
36
  }
@@ -42,10 +42,17 @@ export declare class PasskeyHandler {
42
42
  private readonly state;
43
43
  private readonly baseUrl;
44
44
  private readonly accountId;
45
+ /**
46
+ * Exact origin the passkey popup must postMessage from. Derived from the
47
+ * configured identityBaseUrl so we never accept a result from an
48
+ * unrelated SparkVault subdomain (XSS or subdomain-takeover relay).
49
+ */
50
+ private readonly trustedOrigin;
45
51
  constructor(api: IdentityApi, state: VerificationState);
46
52
  /**
47
- * Check if the current identifier resolves to an SVID with registered passkeys.
48
- * @returns Check result with emailValid and hasPasskey, or null on error
53
+ * Resolve the current identifier (email or phone) to its SVID and report
54
+ * whether that SVID has any registered passkeys.
55
+ * @returns Check result with identityValid and hasPasskey, or null on error
49
56
  */
50
57
  checkPasskey(): Promise<PasskeyCheckResult | null>;
51
58
  /**
@@ -61,7 +68,10 @@ export declare class PasskeyHandler {
61
68
  */
62
69
  private openPasskeyPopup;
63
70
  /**
64
- * Validate that a message origin is from sparkvault.com domain
71
+ * Validate that a postMessage came from the identity service's own
72
+ * origin. We do not accept the broader sparkvault.com family - a popup
73
+ * is only opened against `this.baseUrl`, so any other origin is
74
+ * either an unrelated tab or a forgery attempt.
65
75
  */
66
76
  private isValidMessageOrigin;
67
77
  /**
@@ -71,6 +71,12 @@ export declare class IdentityRenderer {
71
71
  private destroyCurrentView;
72
72
  private createViewForState;
73
73
  private showIdentityInput;
74
+ /**
75
+ * Render the picker. With `autoRoute` left default, a recipient that
76
+ * already has a passkey is sent straight to the WebAuthn view; pass
77
+ * `false` from the passkey view's back arrow so the user lands on the
78
+ * actual list of alternatives instead of bouncing back to passkey.
79
+ */
74
80
  private showMethodSelect;
75
81
  private handleIdentitySubmit;
76
82
  private getAllowedIdentityTypes;
@@ -102,24 +102,6 @@ Object.freeze([
102
102
  ...SPARKVAULT_PLATFORM_SV_HOSTS
103
103
  ]);
104
104
 
105
- function normalizeHostname(hostname) {
106
- if (typeof hostname !== 'string') return '';
107
- return hostname.trim().toLowerCase().replace(/\.$/, '');
108
- }
109
-
110
- function isSparkVaultRootOrSubdomain(hostname) {
111
- const normalized = normalizeHostname(hostname);
112
- return normalized === SPARKVAULT_ROOT_DOMAIN || normalized.endsWith(`.${SPARKVAULT_ROOT_DOMAIN}`);
113
- }
114
-
115
- function isSparkVaultPlatformSvHost(hostname) {
116
- return SPARKVAULT_PLATFORM_SV_HOSTS.includes(normalizeHostname(hostname));
117
- }
118
-
119
- function isSparkVaultOwnedHostname(hostname) {
120
- return isSparkVaultRootOrSubdomain(hostname) || isSparkVaultPlatformSvHost(hostname);
121
- }
122
-
123
105
  /**
124
106
  * SparkVault SDK Configuration
125
107
  */
@@ -1541,17 +1523,19 @@ class PasskeyHandler {
1541
1523
  const config = api.config;
1542
1524
  this.baseUrl = config.identityBaseUrl;
1543
1525
  this.accountId = config.accountId;
1526
+ this.trustedOrigin = new URL(this.baseUrl).origin;
1544
1527
  }
1545
1528
  /**
1546
- * Check if the current identifier resolves to an SVID with registered passkeys.
1547
- * @returns Check result with emailValid and hasPasskey, or null on error
1529
+ * Resolve the current identifier (email or phone) to its SVID and report
1530
+ * whether that SVID has any registered passkeys.
1531
+ * @returns Check result with identityValid and hasPasskey, or null on error
1548
1532
  */
1549
1533
  async checkPasskey() {
1550
1534
  try {
1551
1535
  const response = await this.api.checkPasskey(this.state.recipient, this.state.identityType);
1552
1536
  this.state.setPasskeyStatus(response.has_passkey);
1553
1537
  return {
1554
- emailValid: response.identity_valid,
1538
+ identityValid: response.identity_valid,
1555
1539
  hasPasskey: response.has_passkey,
1556
1540
  };
1557
1541
  }
@@ -1690,16 +1674,13 @@ class PasskeyHandler {
1690
1674
  });
1691
1675
  }
1692
1676
  /**
1693
- * Validate that a message origin is from sparkvault.com domain
1677
+ * Validate that a postMessage came from the identity service's own
1678
+ * origin. We do not accept the broader sparkvault.com family - a popup
1679
+ * is only opened against `this.baseUrl`, so any other origin is
1680
+ * either an unrelated tab or a forgery attempt.
1694
1681
  */
1695
1682
  isValidMessageOrigin(origin) {
1696
- try {
1697
- const url = new URL(origin);
1698
- return url.protocol === 'https:' && url.origin === origin && !url.port && isSparkVaultOwnedHostname(url.hostname);
1699
- }
1700
- catch {
1701
- return false;
1702
- }
1683
+ return origin === this.trustedOrigin;
1703
1684
  }
1704
1685
  /**
1705
1686
  * Handle popup error response
@@ -5576,9 +5557,12 @@ class IdentityRenderer {
5576
5557
  onBack: isFromPrompt
5577
5558
  ? () => this.handlePasskeyRegistrationSkip()
5578
5559
  : state.mode === 'verify'
5579
- // From passkey verify, enable fallback so showMethodSelect doesn't loop back
5560
+ // Back returns to the picker with passkey still listed.
5561
+ // autoRoute=false prevents the auto-jump from sending the
5562
+ // user straight back to this view. If no fallback methods
5563
+ // exist at all, fall through to identity-input.
5580
5564
  ? this.passkeyFallbackMethodsAvailable()
5581
- ? () => this.handlePasskeyFallback()
5565
+ ? () => this.showMethodSelect({ autoRoute: false })
5582
5566
  : this.recipient
5583
5567
  ? () => this.showIdentityInput()
5584
5568
  : undefined
@@ -5627,7 +5611,14 @@ class IdentityRenderer {
5627
5611
  showIdentityInput(error) {
5628
5612
  this.setState({ view: 'identity-input', error });
5629
5613
  }
5630
- async showMethodSelect() {
5614
+ /**
5615
+ * Render the picker. With `autoRoute` left default, a recipient that
5616
+ * already has a passkey is sent straight to the WebAuthn view; pass
5617
+ * `false` from the passkey view's back arrow so the user lands on the
5618
+ * actual list of alternatives instead of bouncing back to passkey.
5619
+ */
5620
+ async showMethodSelect(options = {}) {
5621
+ const autoRoute = options.autoRoute !== false;
5631
5622
  if (!this.sdkConfig)
5632
5623
  return;
5633
5624
  // Defensive: ensure methods is always an array
@@ -5652,6 +5643,17 @@ class IdentityRenderer {
5652
5643
  // Email users can use email-based methods
5653
5644
  return m.identityType === 'email' || m.identityType === undefined;
5654
5645
  });
5646
+ // Resolve identifier -> SVID -> has_passkey exactly once per flow. The
5647
+ // result drives both the picker (hide Passkey when there is none) and
5648
+ // the post-verify "add a passkey?" prompt (skip when there already is
5649
+ // one). Cached on verificationState; later reads short-circuit.
5650
+ const { passkey } = this.verificationState;
5651
+ if (passkey.hasPasskey === null && methods.some((m) => m.type === 'passkey')) {
5652
+ await this.passkeyHandler.checkPasskey();
5653
+ }
5654
+ if (this.verificationState.passkey.hasPasskey === false) {
5655
+ methods = methods.filter((m) => m.type !== 'passkey');
5656
+ }
5655
5657
  }
5656
5658
  else {
5657
5659
  // No PII prompt is needed when only SVID-routed methods are enabled.
@@ -5668,6 +5670,19 @@ class IdentityRenderer {
5668
5670
  });
5669
5671
  return;
5670
5672
  }
5673
+ // When a passkey is already registered for this identifier, jump
5674
+ // straight to the WebAuthn ceremony instead of asking the user to
5675
+ // pick a method — it is the safest, fastest option. The back arrow on
5676
+ // the passkey view re-enters this method with autoRoute=false so the
5677
+ // user lands on the full picker (passkey still listed) and can pick
5678
+ // a code or SparkLink instead.
5679
+ if (autoRoute
5680
+ && this.verificationState.passkey.hasPasskey === true
5681
+ && !this.verificationState.passkey.isFallbackMode
5682
+ && methods.some((m) => m.type === 'passkey')) {
5683
+ this.setState({ view: 'passkey', recipient: this.recipient, mode: 'verify' });
5684
+ return;
5685
+ }
5671
5686
  if (methods.length === 1) {
5672
5687
  this.handleMethodSelect(methods[0]);
5673
5688
  return;
@@ -6006,7 +6021,7 @@ class IdentityRenderer {
6006
6021
  if (passkey.hasPasskey === null) {
6007
6022
  const checkResult = await this.passkeyHandler.checkPasskey();
6008
6023
  // Only prompt if the verified identifier resolves to an SVID without a passkey.
6009
- return checkResult !== null && checkResult.emailValid && !checkResult.hasPasskey;
6024
+ return checkResult !== null && checkResult.identityValid && !checkResult.hasPasskey;
6010
6025
  }
6011
6026
  return !passkey.hasPasskey;
6012
6027
  }