@sparkvault/sdk-js 8.5.0 → 8.6.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/products/identity/handlers/passkey-handler.d.ts +11 -1
- package/dist/products/identity/popup-launcher.d.ts +4 -3
- package/dist/products/identity/renderer.d.ts +29 -0
- package/dist/products/identity/types.d.ts +2 -0
- package/dist/products/identity/views/identity-input.d.ts +8 -0
- package/dist/products/identity/views/index.d.ts +1 -0
- package/dist/products/identity/views/passkey-auto.d.ts +22 -0
- package/dist/sparkvault.cjs.js +198 -15
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +198 -15
- 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
|
@@ -75,15 +75,25 @@ export declare class PasskeyHandler {
|
|
|
75
75
|
* supported in cross-origin iframes, so the embedded widget uses the inline
|
|
76
76
|
* path.)
|
|
77
77
|
*/
|
|
78
|
-
verify(): Promise<PasskeyResult>;
|
|
78
|
+
verify(signal?: AbortSignal): Promise<PasskeyResult>;
|
|
79
79
|
/**
|
|
80
80
|
* True when the SDK is running ON the Identity origin and the browser exposes
|
|
81
81
|
* WebAuthn — the only place an inline ceremony's rpId matches the document.
|
|
82
82
|
*/
|
|
83
83
|
private canRunCeremonyInline;
|
|
84
|
+
/**
|
|
85
|
+
* True when the discoverable ceremony may be fired WITHOUT a user gesture:
|
|
86
|
+
* the flow is running on the Identity origin (the inline ceremony needs no
|
|
87
|
+
* popup, so no gesture) AND this browser carries the passkey-hint cookie —
|
|
88
|
+
* a passkey login has completed here before. First visits never see an
|
|
89
|
+
* unprompted system sheet.
|
|
90
|
+
*/
|
|
91
|
+
canAutoVerify(): boolean;
|
|
84
92
|
/**
|
|
85
93
|
* Run the discoverable verification ceremony directly in this document and
|
|
86
94
|
* map the outcome onto the same PasskeyResult shape the popup produces.
|
|
95
|
+
* An optional AbortSignal cancels the pending system sheet (the auto-started
|
|
96
|
+
* ceremony's "Use another method" escape hatch).
|
|
87
97
|
*/
|
|
88
98
|
private verifyInline;
|
|
89
99
|
/**
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
*
|
|
10
10
|
* The single transfer path: synchronous `window.open` inside the user gesture
|
|
11
11
|
* (so the browser never blocks it), strict `event.origin` + `data.type`
|
|
12
|
-
* validation against the caller-supplied trusted origin, a
|
|
13
|
-
* `window.closed` poll that surfaces a manual
|
|
12
|
+
* validation against the caller-supplied trusted origin, a 30-minute
|
|
13
|
+
* abandoned-window backstop, and a `window.closed` poll that surfaces a manual
|
|
14
|
+
* close as a cancellation.
|
|
14
15
|
*/
|
|
15
16
|
/** Minimal shape every popup result envelope shares. */
|
|
16
17
|
export interface PopupResultEnvelope {
|
|
@@ -30,7 +31,7 @@ export interface OpenPopupOptions {
|
|
|
30
31
|
width?: number;
|
|
31
32
|
/** Popup height in px (default 640). */
|
|
32
33
|
height?: number;
|
|
33
|
-
/** Timeout in ms before giving up and closing the popup (default
|
|
34
|
+
/** Timeout in ms before giving up and closing the popup (default 30 minutes). */
|
|
34
35
|
timeoutMs?: number;
|
|
35
36
|
/**
|
|
36
37
|
* Called synchronously with the popup window the moment it opens, so the
|
|
@@ -24,6 +24,7 @@ export declare class IdentityRenderer {
|
|
|
24
24
|
private currentView;
|
|
25
25
|
private focusTimeoutId;
|
|
26
26
|
private morphTimer;
|
|
27
|
+
private discoverableVerifyAbort;
|
|
27
28
|
private postLoginResult;
|
|
28
29
|
private postLoginQueue;
|
|
29
30
|
private sparkLinkWs;
|
|
@@ -94,6 +95,27 @@ export declare class IdentityRenderer {
|
|
|
94
95
|
private get viewState();
|
|
95
96
|
private setState;
|
|
96
97
|
private showInitialAuthStep;
|
|
98
|
+
/**
|
|
99
|
+
* True when the discoverable ceremony may be started without a gesture and
|
|
100
|
+
* this account actually offers passkey login: the flow runs on the Identity
|
|
101
|
+
* origin, the browser carries the passkey hint, and `passkey` is among the
|
|
102
|
+
* account's enabled methods.
|
|
103
|
+
*/
|
|
104
|
+
private canDiscoverableVerify;
|
|
105
|
+
/**
|
|
106
|
+
* Run the no-identifier discoverable ceremony behind the passkey-auto view.
|
|
107
|
+
* Fired on open for returning browsers and from the identifier form's
|
|
108
|
+
* "Sign in with a passkey" shortcut. Anything short of a terminal outcome
|
|
109
|
+
* (dismissed sheet, no credential on the device, transient failure) falls
|
|
110
|
+
* back to the identifier form with no error banner — the person simply
|
|
111
|
+
* lands where a first-time visitor starts.
|
|
112
|
+
*/
|
|
113
|
+
private launchDiscoverableVerify;
|
|
114
|
+
/**
|
|
115
|
+
* Abort the pending discoverable ceremony (dismisses the browser sheet where
|
|
116
|
+
* the platform allows) and land on the identifier form.
|
|
117
|
+
*/
|
|
118
|
+
private cancelDiscoverableVerify;
|
|
97
119
|
private render;
|
|
98
120
|
private destroyCurrentView;
|
|
99
121
|
/**
|
|
@@ -141,6 +163,13 @@ export declare class IdentityRenderer {
|
|
|
141
163
|
* synchronously (before the first await), so it stays within the gesture.
|
|
142
164
|
*/
|
|
143
165
|
private launchPasskeyVerify;
|
|
166
|
+
/**
|
|
167
|
+
* Handle the terminal passkey outcomes every entry point shares: a verified
|
|
168
|
+
* login (close + onSuccess + redirect), a blocked-Identity interstitial, or
|
|
169
|
+
* a locked identity. Returns false for the retryable failures each caller
|
|
170
|
+
* routes according to its own flow.
|
|
171
|
+
*/
|
|
172
|
+
private applyTerminalPasskeyResult;
|
|
144
173
|
/**
|
|
145
174
|
* Apply a passkey ceremony result: complete on success, or route to the
|
|
146
175
|
* matching recovery state. Shared by the passkey view and the direct
|
|
@@ -19,18 +19,26 @@ export interface IdentityInputViewProps {
|
|
|
19
19
|
error?: string;
|
|
20
20
|
/** Called with validated identity */
|
|
21
21
|
onSubmit: (result: IdentityInputResult) => void;
|
|
22
|
+
/**
|
|
23
|
+
* When set, offer a "Sign in with a passkey" shortcut below the form —
|
|
24
|
+
* the way back into the discoverable ceremony for a returning browser
|
|
25
|
+
* whose auto-started prompt was dismissed.
|
|
26
|
+
*/
|
|
27
|
+
onPasskey?: () => void;
|
|
22
28
|
}
|
|
23
29
|
export declare class IdentityInputView implements View {
|
|
24
30
|
private readonly props;
|
|
25
31
|
private inputElement;
|
|
26
32
|
private labelElement;
|
|
27
33
|
private submitButton;
|
|
34
|
+
private passkeyLink;
|
|
28
35
|
private errorContainer;
|
|
29
36
|
private focusTimeoutId;
|
|
30
37
|
private detectedType;
|
|
31
38
|
private readonly boundHandleInput;
|
|
32
39
|
private readonly boundHandleKeyDown;
|
|
33
40
|
private readonly boundHandleSubmit;
|
|
41
|
+
private readonly boundHandlePasskey;
|
|
34
42
|
constructor(props: IdentityInputViewProps);
|
|
35
43
|
private get allowsBoth();
|
|
36
44
|
private get allowsEmail();
|
|
@@ -10,6 +10,7 @@ export * from './method-select';
|
|
|
10
10
|
export * from './otp-verify';
|
|
11
11
|
export * from './two-factor';
|
|
12
12
|
export * from './passkey';
|
|
13
|
+
export * from './passkey-auto';
|
|
13
14
|
export * from './passkey-prompt';
|
|
14
15
|
export * from './backup-verify';
|
|
15
16
|
export * from './sparklink-waiting';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passkey Auto-Verify View
|
|
3
|
+
*
|
|
4
|
+
* Shown behind the browser's passkey sheet while an auto-started discoverable
|
|
5
|
+
* ceremony runs (returning browsers carrying the passkey-hint cookie). The
|
|
6
|
+
* ceremony was fired without a click, so this screen has no action button —
|
|
7
|
+
* only a live status and an escape hatch to the identifier form for anyone
|
|
8
|
+
* who wants a different method (or whose sheet hangs).
|
|
9
|
+
*/
|
|
10
|
+
import type { View } from './base';
|
|
11
|
+
export interface PasskeyAutoViewProps {
|
|
12
|
+
/** Abort the pending ceremony and fall back to the identifier form. */
|
|
13
|
+
onUseAnotherMethod: () => void;
|
|
14
|
+
}
|
|
15
|
+
export declare class PasskeyAutoView implements View {
|
|
16
|
+
private readonly props;
|
|
17
|
+
private fallbackLink;
|
|
18
|
+
private readonly boundHandleFallback;
|
|
19
|
+
constructor(props: PasskeyAutoViewProps);
|
|
20
|
+
render(): HTMLElement;
|
|
21
|
+
destroy(): void;
|
|
22
|
+
}
|
package/dist/sparkvault.cjs.js
CHANGED
|
@@ -1351,14 +1351,25 @@ class VerificationState {
|
|
|
1351
1351
|
*
|
|
1352
1352
|
* The single transfer path: synchronous `window.open` inside the user gesture
|
|
1353
1353
|
* (so the browser never blocks it), strict `event.origin` + `data.type`
|
|
1354
|
-
* validation against the caller-supplied trusted origin, a
|
|
1355
|
-
* `window.closed` poll that surfaces a manual
|
|
1354
|
+
* validation against the caller-supplied trusted origin, a 30-minute
|
|
1355
|
+
* abandoned-window backstop, and a `window.closed` poll that surfaces a manual
|
|
1356
|
+
* close as a cancellation.
|
|
1356
1357
|
*/
|
|
1357
1358
|
/** Default popup dimensions — a centered login/ceremony window. */
|
|
1358
1359
|
const DEFAULT_WIDTH = 480;
|
|
1359
1360
|
const DEFAULT_HEIGHT = 640;
|
|
1360
|
-
/**
|
|
1361
|
-
|
|
1361
|
+
/**
|
|
1362
|
+
* Default timeout for popup operations: 30 minutes. This is an
|
|
1363
|
+
* abandoned-window backstop — never a liveness gate. A person mid-login is
|
|
1364
|
+
* often slow for legitimate reasons (waiting out an OTP resend backoff,
|
|
1365
|
+
* fetching their phone for a cross-device passkey, hunting for an alternative
|
|
1366
|
+
* method), and yanking the window away from them mid-flow is far worse than
|
|
1367
|
+
* letting an orphaned promise linger. Active cancellation is handled
|
|
1368
|
+
* elsewhere: the `window.closed` poll catches a manual close within 500ms and
|
|
1369
|
+
* an explicit in-popup cancel posts back immediately; server-side challenge
|
|
1370
|
+
* TTLs (OTP expiry, auth-request lifetime) bound how stale a completion can be.
|
|
1371
|
+
*/
|
|
1372
|
+
const DEFAULT_TIMEOUT_MS = 30 * 60 * 1000;
|
|
1362
1373
|
/** How often to check whether the user closed the popup manually. */
|
|
1363
1374
|
const CLOSED_POLL_INTERVAL_MS = 500;
|
|
1364
1375
|
/**
|
|
@@ -1447,6 +1458,15 @@ class PopupLauncher {
|
|
|
1447
1458
|
/** Passkey popup window dimensions. */
|
|
1448
1459
|
const POPUP_WIDTH = 450;
|
|
1449
1460
|
const POPUP_HEIGHT = 500;
|
|
1461
|
+
/**
|
|
1462
|
+
* Device-level hint the Identity API sets on every completed passkey login
|
|
1463
|
+
* (products/product-identity/src/utils/passkey-hint-cookie.js — the cookie
|
|
1464
|
+
* NAME is the wire contract between the two). Host-locked to the Identity
|
|
1465
|
+
* origin and deliberately JS-readable, it means "a passkey login has completed
|
|
1466
|
+
* in this browser", which is what licenses auto-starting the discoverable
|
|
1467
|
+
* ceremony for returning people without ever prompting first-time visitors.
|
|
1468
|
+
*/
|
|
1469
|
+
const PASSKEY_HINT_COOKIE = '__Host-authsv_passkey';
|
|
1450
1470
|
/** `data.type` the passkey popup posts back. */
|
|
1451
1471
|
const PASSKEY_RESULT_TYPE = 'sparkvault-passkey-result';
|
|
1452
1472
|
/**
|
|
@@ -1507,9 +1527,9 @@ class PasskeyHandler {
|
|
|
1507
1527
|
* supported in cross-origin iframes, so the embedded widget uses the inline
|
|
1508
1528
|
* path.)
|
|
1509
1529
|
*/
|
|
1510
|
-
async verify() {
|
|
1530
|
+
async verify(signal) {
|
|
1511
1531
|
if (this.canRunCeremonyInline()) {
|
|
1512
|
-
return this.verifyInline();
|
|
1532
|
+
return this.verifyInline(signal);
|
|
1513
1533
|
}
|
|
1514
1534
|
return this.openPasskeyPopup('verify');
|
|
1515
1535
|
}
|
|
@@ -1523,11 +1543,27 @@ class PasskeyHandler {
|
|
|
1523
1543
|
&& !!navigator.credentials
|
|
1524
1544
|
&& window.location.origin === this.trustedOrigin;
|
|
1525
1545
|
}
|
|
1546
|
+
/**
|
|
1547
|
+
* True when the discoverable ceremony may be fired WITHOUT a user gesture:
|
|
1548
|
+
* the flow is running on the Identity origin (the inline ceremony needs no
|
|
1549
|
+
* popup, so no gesture) AND this browser carries the passkey-hint cookie —
|
|
1550
|
+
* a passkey login has completed here before. First visits never see an
|
|
1551
|
+
* unprompted system sheet.
|
|
1552
|
+
*/
|
|
1553
|
+
canAutoVerify() {
|
|
1554
|
+
if (!this.canRunCeremonyInline())
|
|
1555
|
+
return false;
|
|
1556
|
+
return document.cookie
|
|
1557
|
+
.split(';')
|
|
1558
|
+
.some((part) => part.trim().startsWith(`${PASSKEY_HINT_COOKIE}=1`));
|
|
1559
|
+
}
|
|
1526
1560
|
/**
|
|
1527
1561
|
* Run the discoverable verification ceremony directly in this document and
|
|
1528
1562
|
* map the outcome onto the same PasskeyResult shape the popup produces.
|
|
1563
|
+
* An optional AbortSignal cancels the pending system sheet (the auto-started
|
|
1564
|
+
* ceremony's "Use another method" escape hatch).
|
|
1529
1565
|
*/
|
|
1530
|
-
async verifyInline() {
|
|
1566
|
+
async verifyInline(signal) {
|
|
1531
1567
|
try {
|
|
1532
1568
|
// When the widget has an identifier, scope the ceremony to that person's
|
|
1533
1569
|
// passkeys so the authenticator offers only the matching credential;
|
|
@@ -1535,6 +1571,7 @@ class PasskeyHandler {
|
|
|
1535
1571
|
const identityType = this.state.identityType === 'phone' ? 'phone' : 'email';
|
|
1536
1572
|
const challenge = await this.api.startPasskeyVerify(this.state.recipient, identityType, this.state.authContext);
|
|
1537
1573
|
const credential = await navigator.credentials.get({
|
|
1574
|
+
...(signal ? { signal } : {}),
|
|
1538
1575
|
publicKey: {
|
|
1539
1576
|
challenge: base64urlToArrayBuffer(challenge.challenge),
|
|
1540
1577
|
rpId: challenge.rpId,
|
|
@@ -1580,8 +1617,10 @@ class PasskeyHandler {
|
|
|
1580
1617
|
* (cancelled, identity locked, no passkey → registration).
|
|
1581
1618
|
*/
|
|
1582
1619
|
mapInlineCeremonyError(error) {
|
|
1583
|
-
// User dismissed the system sheet
|
|
1584
|
-
|
|
1620
|
+
// User dismissed the system sheet or no credential was available
|
|
1621
|
+
// (NotAllowedError), or the caller aborted the pending ceremony via its
|
|
1622
|
+
// AbortSignal (AbortError). Both end the ceremony without a credential.
|
|
1623
|
+
if (error instanceof Error && (error.name === 'NotAllowedError' || error.name === 'AbortError')) {
|
|
1585
1624
|
return {
|
|
1586
1625
|
success: false,
|
|
1587
1626
|
error: 'Authentication was cancelled. Please try again.',
|
|
@@ -4188,6 +4227,7 @@ class IdentityInputView {
|
|
|
4188
4227
|
this.inputElement = null;
|
|
4189
4228
|
this.labelElement = null;
|
|
4190
4229
|
this.submitButton = null;
|
|
4230
|
+
this.passkeyLink = null;
|
|
4191
4231
|
this.errorContainer = null;
|
|
4192
4232
|
this.focusTimeoutId = null;
|
|
4193
4233
|
this.detectedType = 'email';
|
|
@@ -4200,6 +4240,7 @@ class IdentityInputView {
|
|
|
4200
4240
|
}
|
|
4201
4241
|
};
|
|
4202
4242
|
this.boundHandleSubmit = () => this.handleSubmit();
|
|
4243
|
+
this.boundHandlePasskey = props.onPasskey ? () => props.onPasskey() : null;
|
|
4203
4244
|
}
|
|
4204
4245
|
get allowsBoth() {
|
|
4205
4246
|
return this.props.allowedTypes.includes('email') && this.props.allowedTypes.includes('phone');
|
|
@@ -4255,6 +4296,13 @@ class IdentityInputView {
|
|
|
4255
4296
|
this.submitButton.addEventListener('click', this.boundHandleSubmit);
|
|
4256
4297
|
formSection.appendChild(this.submitButton);
|
|
4257
4298
|
container.appendChild(formSection);
|
|
4299
|
+
if (this.boundHandlePasskey) {
|
|
4300
|
+
this.passkeyLink = document.createElement('button');
|
|
4301
|
+
this.passkeyLink.className = 'sv-fallback-link';
|
|
4302
|
+
this.passkeyLink.textContent = 'Sign in with a passkey';
|
|
4303
|
+
this.passkeyLink.addEventListener('click', this.boundHandlePasskey);
|
|
4304
|
+
container.appendChild(this.passkeyLink);
|
|
4305
|
+
}
|
|
4258
4306
|
this.focusTimeoutId = setTimeout(() => this.inputElement?.focus(), 50);
|
|
4259
4307
|
return container;
|
|
4260
4308
|
}
|
|
@@ -4398,6 +4446,9 @@ class IdentityInputView {
|
|
|
4398
4446
|
if (this.submitButton) {
|
|
4399
4447
|
this.submitButton.removeEventListener('click', this.boundHandleSubmit);
|
|
4400
4448
|
}
|
|
4449
|
+
if (this.passkeyLink && this.boundHandlePasskey) {
|
|
4450
|
+
this.passkeyLink.removeEventListener('click', this.boundHandlePasskey);
|
|
4451
|
+
}
|
|
4401
4452
|
}
|
|
4402
4453
|
}
|
|
4403
4454
|
|
|
@@ -5065,6 +5116,55 @@ class PasskeyView {
|
|
|
5065
5116
|
}
|
|
5066
5117
|
}
|
|
5067
5118
|
|
|
5119
|
+
/**
|
|
5120
|
+
* Passkey Auto-Verify View
|
|
5121
|
+
*
|
|
5122
|
+
* Shown behind the browser's passkey sheet while an auto-started discoverable
|
|
5123
|
+
* ceremony runs (returning browsers carrying the passkey-hint cookie). The
|
|
5124
|
+
* ceremony was fired without a click, so this screen has no action button —
|
|
5125
|
+
* only a live status and an escape hatch to the identifier form for anyone
|
|
5126
|
+
* who wants a different method (or whose sheet hangs).
|
|
5127
|
+
*/
|
|
5128
|
+
class PasskeyAutoView {
|
|
5129
|
+
constructor(props) {
|
|
5130
|
+
this.fallbackLink = null;
|
|
5131
|
+
this.props = props;
|
|
5132
|
+
this.boundHandleFallback = () => this.props.onUseAnotherMethod();
|
|
5133
|
+
}
|
|
5134
|
+
render() {
|
|
5135
|
+
const container = div();
|
|
5136
|
+
const iconContainer = div();
|
|
5137
|
+
iconContainer.appendChild(createPasskeyIcon());
|
|
5138
|
+
const title = document.createElement('h3');
|
|
5139
|
+
title.className = 'sv-title';
|
|
5140
|
+
title.textContent = 'Signing you in';
|
|
5141
|
+
const subtitle = document.createElement('p');
|
|
5142
|
+
subtitle.className = 'sv-subtitle';
|
|
5143
|
+
subtitle.textContent = 'Use your passkey to continue';
|
|
5144
|
+
const spinner = document.createElement('div');
|
|
5145
|
+
spinner.className = 'sv-spinner';
|
|
5146
|
+
spinner.setAttribute('role', 'status');
|
|
5147
|
+
spinner.setAttribute('aria-label', 'Waiting for your passkey');
|
|
5148
|
+
const spinnerRow = div('sv-loading');
|
|
5149
|
+
spinnerRow.appendChild(spinner);
|
|
5150
|
+
this.fallbackLink = document.createElement('button');
|
|
5151
|
+
this.fallbackLink.className = 'sv-fallback-link';
|
|
5152
|
+
this.fallbackLink.textContent = 'Use another method';
|
|
5153
|
+
this.fallbackLink.addEventListener('click', this.boundHandleFallback);
|
|
5154
|
+
container.appendChild(iconContainer);
|
|
5155
|
+
container.appendChild(title);
|
|
5156
|
+
container.appendChild(subtitle);
|
|
5157
|
+
container.appendChild(spinnerRow);
|
|
5158
|
+
container.appendChild(this.fallbackLink);
|
|
5159
|
+
return container;
|
|
5160
|
+
}
|
|
5161
|
+
destroy() {
|
|
5162
|
+
if (this.fallbackLink) {
|
|
5163
|
+
this.fallbackLink.removeEventListener('click', this.boundHandleFallback);
|
|
5164
|
+
}
|
|
5165
|
+
}
|
|
5166
|
+
}
|
|
5167
|
+
|
|
5068
5168
|
/**
|
|
5069
5169
|
* Passkey Registration Prompt View
|
|
5070
5170
|
*
|
|
@@ -6040,6 +6140,9 @@ class IdentityRenderer {
|
|
|
6040
6140
|
this.currentView = null;
|
|
6041
6141
|
this.focusTimeoutId = null;
|
|
6042
6142
|
this.morphTimer = null;
|
|
6143
|
+
// Live discoverable (no-identifier) ceremony. The controller cancels the
|
|
6144
|
+
// pending browser sheet when the person escapes to the identifier form.
|
|
6145
|
+
this.discoverableVerifyAbort = null;
|
|
6043
6146
|
// Post-login recommendation pipeline: the verified result to finalize with,
|
|
6044
6147
|
// and the remaining server-recommended steps to walk before finalizing.
|
|
6045
6148
|
this.postLoginResult = null;
|
|
@@ -6251,6 +6354,10 @@ class IdentityRenderer {
|
|
|
6251
6354
|
close() {
|
|
6252
6355
|
// Cancel all pending API requests first
|
|
6253
6356
|
this.api.abort();
|
|
6357
|
+
// A pending discoverable ceremony would otherwise hold the browser sheet
|
|
6358
|
+
// open against a dialog that no longer exists.
|
|
6359
|
+
this.discoverableVerifyAbort?.abort();
|
|
6360
|
+
this.discoverableVerifyAbort = null;
|
|
6254
6361
|
if (this.focusTimeoutId !== null) {
|
|
6255
6362
|
clearTimeout(this.focusTimeoutId);
|
|
6256
6363
|
this.focusTimeoutId = null;
|
|
@@ -6279,6 +6386,58 @@ class IdentityRenderer {
|
|
|
6279
6386
|
await this.showMethodSelect();
|
|
6280
6387
|
return;
|
|
6281
6388
|
}
|
|
6389
|
+
// Returning browser on the Identity origin (passkey-hint cookie present):
|
|
6390
|
+
// auto-start the discoverable ceremony instead of asking for an identifier
|
|
6391
|
+
// — the Google-style one-touch return. A cancel lands on the identifier
|
|
6392
|
+
// form, which keeps a "Sign in with a passkey" way back in.
|
|
6393
|
+
if (this.canDiscoverableVerify()) {
|
|
6394
|
+
void this.launchDiscoverableVerify();
|
|
6395
|
+
return;
|
|
6396
|
+
}
|
|
6397
|
+
this.showIdentityInput();
|
|
6398
|
+
}
|
|
6399
|
+
/**
|
|
6400
|
+
* True when the discoverable ceremony may be started without a gesture and
|
|
6401
|
+
* this account actually offers passkey login: the flow runs on the Identity
|
|
6402
|
+
* origin, the browser carries the passkey hint, and `passkey` is among the
|
|
6403
|
+
* account's enabled methods.
|
|
6404
|
+
*/
|
|
6405
|
+
canDiscoverableVerify() {
|
|
6406
|
+
if (!this.passkeyHandler.canAutoVerify())
|
|
6407
|
+
return false;
|
|
6408
|
+
const methods = enrichMethods(this.sdkConfig?.methods ?? []);
|
|
6409
|
+
return methods.some((m) => m.type === 'passkey');
|
|
6410
|
+
}
|
|
6411
|
+
/**
|
|
6412
|
+
* Run the no-identifier discoverable ceremony behind the passkey-auto view.
|
|
6413
|
+
* Fired on open for returning browsers and from the identifier form's
|
|
6414
|
+
* "Sign in with a passkey" shortcut. Anything short of a terminal outcome
|
|
6415
|
+
* (dismissed sheet, no credential on the device, transient failure) falls
|
|
6416
|
+
* back to the identifier form with no error banner — the person simply
|
|
6417
|
+
* lands where a first-time visitor starts.
|
|
6418
|
+
*/
|
|
6419
|
+
async launchDiscoverableVerify() {
|
|
6420
|
+
this.discoverableVerifyAbort = new AbortController();
|
|
6421
|
+
const { signal } = this.discoverableVerifyAbort;
|
|
6422
|
+
this.setState({ view: 'passkey-auto' });
|
|
6423
|
+
const result = await this.passkeyHandler.verify(signal);
|
|
6424
|
+
if (signal.aborted) {
|
|
6425
|
+
// The person already escaped to the identifier form; the aborted
|
|
6426
|
+
// ceremony's result is stale.
|
|
6427
|
+
return;
|
|
6428
|
+
}
|
|
6429
|
+
this.discoverableVerifyAbort = null;
|
|
6430
|
+
if (this.applyTerminalPasskeyResult(result))
|
|
6431
|
+
return;
|
|
6432
|
+
this.showIdentityInput();
|
|
6433
|
+
}
|
|
6434
|
+
/**
|
|
6435
|
+
* Abort the pending discoverable ceremony (dismisses the browser sheet where
|
|
6436
|
+
* the platform allows) and land on the identifier form.
|
|
6437
|
+
*/
|
|
6438
|
+
cancelDiscoverableVerify() {
|
|
6439
|
+
this.discoverableVerifyAbort?.abort();
|
|
6440
|
+
this.discoverableVerifyAbort = null;
|
|
6282
6441
|
this.showIdentityInput();
|
|
6283
6442
|
}
|
|
6284
6443
|
render() {
|
|
@@ -6389,6 +6548,11 @@ class IdentityRenderer {
|
|
|
6389
6548
|
initialValue: this.recipient,
|
|
6390
6549
|
error: state.error,
|
|
6391
6550
|
onSubmit: (result) => this.handleIdentitySubmit(result),
|
|
6551
|
+
// Returning browsers keep a one-tap way back into the discoverable
|
|
6552
|
+
// ceremony (e.g. after dismissing the auto-started sheet).
|
|
6553
|
+
onPasskey: this.canDiscoverableVerify()
|
|
6554
|
+
? () => { void this.launchDiscoverableVerify(); }
|
|
6555
|
+
: undefined,
|
|
6392
6556
|
});
|
|
6393
6557
|
case 'method-select':
|
|
6394
6558
|
return new MethodSelectView({
|
|
@@ -6440,6 +6604,10 @@ class IdentityRenderer {
|
|
|
6440
6604
|
: undefined,
|
|
6441
6605
|
});
|
|
6442
6606
|
}
|
|
6607
|
+
case 'passkey-auto':
|
|
6608
|
+
return new PasskeyAutoView({
|
|
6609
|
+
onUseAnotherMethod: () => this.cancelDiscoverableVerify(),
|
|
6610
|
+
});
|
|
6443
6611
|
case 'passkey-prompt':
|
|
6444
6612
|
return new PasskeyPromptView({
|
|
6445
6613
|
identityLabel: state.recipient,
|
|
@@ -6872,27 +7040,42 @@ class IdentityRenderer {
|
|
|
6872
7040
|
this.applyPasskeyResult(result, 'verify', fallbackToList);
|
|
6873
7041
|
}
|
|
6874
7042
|
/**
|
|
6875
|
-
*
|
|
6876
|
-
*
|
|
6877
|
-
*
|
|
7043
|
+
* Handle the terminal passkey outcomes every entry point shares: a verified
|
|
7044
|
+
* login (close + onSuccess + redirect), a blocked-Identity interstitial, or
|
|
7045
|
+
* a locked identity. Returns false for the retryable failures each caller
|
|
7046
|
+
* routes according to its own flow.
|
|
6878
7047
|
*/
|
|
6879
|
-
|
|
7048
|
+
applyTerminalPasskeyResult(result) {
|
|
6880
7049
|
if (result.success && result.result) {
|
|
6881
7050
|
this.close();
|
|
6882
7051
|
this.safeOnSuccess(result.result);
|
|
6883
7052
|
if (typeof result.result.redirect === 'string' && result.result.redirect) {
|
|
6884
7053
|
window.location.href = result.result.redirect;
|
|
6885
7054
|
}
|
|
7055
|
+
return true;
|
|
6886
7056
|
}
|
|
6887
|
-
|
|
6888
|
-
|
|
7057
|
+
if (this.renderBlockedInterstitial(result.errorCode)) {
|
|
7058
|
+
// Terminal interstitial already rendered — the owner must subscribe.
|
|
7059
|
+
return true;
|
|
7060
|
+
}
|
|
7061
|
+
if (result.errorCode === 'identity_locked') {
|
|
6889
7062
|
// Dedicated state — retrying cannot unlock the identity.
|
|
6890
7063
|
this.setState({
|
|
6891
7064
|
view: 'error',
|
|
6892
7065
|
code: 'identity_locked',
|
|
6893
7066
|
message: 'This SparkVault Identity is locked. Visit auth.sv to manage it.',
|
|
6894
7067
|
});
|
|
7068
|
+
return true;
|
|
6895
7069
|
}
|
|
7070
|
+
return false;
|
|
7071
|
+
}
|
|
7072
|
+
/**
|
|
7073
|
+
* Apply a passkey ceremony result: complete on success, or route to the
|
|
7074
|
+
* matching recovery state. Shared by the passkey view and the direct
|
|
7075
|
+
* picker launch so both behave identically.
|
|
7076
|
+
*/
|
|
7077
|
+
applyPasskeyResult(result, currentMode, fallbackToList = false) {
|
|
7078
|
+
if (this.applyTerminalPasskeyResult(result)) ;
|
|
6896
7079
|
else if (fallbackToList && this.passkeyFallbackMethodsAvailable()) {
|
|
6897
7080
|
// Auto-launched passkey that the person cancelled or that failed: drop to
|
|
6898
7081
|
// the full method list (passkey still listed) rather than a passkey-only
|