@sparkvault/sdk-js 8.4.0 → 8.6.0
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 +2 -2
- package/dist/products/identity/handlers/passkey-handler.d.ts +11 -1
- 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 +183 -11
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +183 -11
- package/dist/sparkvault.esm.js.map +1 -1
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -825,8 +825,8 @@ MIT License - see [LICENSE](LICENSE) for details.
|
|
|
825
825
|
|
|
826
826
|
## Links
|
|
827
827
|
|
|
828
|
-
- [SparkVault Documentation](https://
|
|
829
|
-
- [SDK API Reference](https://
|
|
828
|
+
- [SparkVault Documentation](https://sparkvault.com/api/docs/)
|
|
829
|
+
- [SDK API Reference](https://sparkvault.com/api/docs/sdk-js/)
|
|
830
830
|
- [GitHub Repository](https://github.com/Spark-Vault/platform)
|
|
831
831
|
- [npm Package](https://www.npmjs.com/package/@sparkvault/sdk-js)
|
|
832
832
|
- [Report Issues](https://github.com/Spark-Vault/platform/issues)
|
|
@@ -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
|
/**
|
|
@@ -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
|
@@ -1447,6 +1447,15 @@ class PopupLauncher {
|
|
|
1447
1447
|
/** Passkey popup window dimensions. */
|
|
1448
1448
|
const POPUP_WIDTH = 450;
|
|
1449
1449
|
const POPUP_HEIGHT = 500;
|
|
1450
|
+
/**
|
|
1451
|
+
* Device-level hint the Identity API sets on every completed passkey login
|
|
1452
|
+
* (products/product-identity/src/utils/passkey-hint-cookie.js — the cookie
|
|
1453
|
+
* NAME is the wire contract between the two). Host-locked to the Identity
|
|
1454
|
+
* origin and deliberately JS-readable, it means "a passkey login has completed
|
|
1455
|
+
* in this browser", which is what licenses auto-starting the discoverable
|
|
1456
|
+
* ceremony for returning people without ever prompting first-time visitors.
|
|
1457
|
+
*/
|
|
1458
|
+
const PASSKEY_HINT_COOKIE = '__Host-authsv_passkey';
|
|
1450
1459
|
/** `data.type` the passkey popup posts back. */
|
|
1451
1460
|
const PASSKEY_RESULT_TYPE = 'sparkvault-passkey-result';
|
|
1452
1461
|
/**
|
|
@@ -1507,9 +1516,9 @@ class PasskeyHandler {
|
|
|
1507
1516
|
* supported in cross-origin iframes, so the embedded widget uses the inline
|
|
1508
1517
|
* path.)
|
|
1509
1518
|
*/
|
|
1510
|
-
async verify() {
|
|
1519
|
+
async verify(signal) {
|
|
1511
1520
|
if (this.canRunCeremonyInline()) {
|
|
1512
|
-
return this.verifyInline();
|
|
1521
|
+
return this.verifyInline(signal);
|
|
1513
1522
|
}
|
|
1514
1523
|
return this.openPasskeyPopup('verify');
|
|
1515
1524
|
}
|
|
@@ -1523,11 +1532,27 @@ class PasskeyHandler {
|
|
|
1523
1532
|
&& !!navigator.credentials
|
|
1524
1533
|
&& window.location.origin === this.trustedOrigin;
|
|
1525
1534
|
}
|
|
1535
|
+
/**
|
|
1536
|
+
* True when the discoverable ceremony may be fired WITHOUT a user gesture:
|
|
1537
|
+
* the flow is running on the Identity origin (the inline ceremony needs no
|
|
1538
|
+
* popup, so no gesture) AND this browser carries the passkey-hint cookie —
|
|
1539
|
+
* a passkey login has completed here before. First visits never see an
|
|
1540
|
+
* unprompted system sheet.
|
|
1541
|
+
*/
|
|
1542
|
+
canAutoVerify() {
|
|
1543
|
+
if (!this.canRunCeremonyInline())
|
|
1544
|
+
return false;
|
|
1545
|
+
return document.cookie
|
|
1546
|
+
.split(';')
|
|
1547
|
+
.some((part) => part.trim().startsWith(`${PASSKEY_HINT_COOKIE}=1`));
|
|
1548
|
+
}
|
|
1526
1549
|
/**
|
|
1527
1550
|
* Run the discoverable verification ceremony directly in this document and
|
|
1528
1551
|
* map the outcome onto the same PasskeyResult shape the popup produces.
|
|
1552
|
+
* An optional AbortSignal cancels the pending system sheet (the auto-started
|
|
1553
|
+
* ceremony's "Use another method" escape hatch).
|
|
1529
1554
|
*/
|
|
1530
|
-
async verifyInline() {
|
|
1555
|
+
async verifyInline(signal) {
|
|
1531
1556
|
try {
|
|
1532
1557
|
// When the widget has an identifier, scope the ceremony to that person's
|
|
1533
1558
|
// passkeys so the authenticator offers only the matching credential;
|
|
@@ -1535,6 +1560,7 @@ class PasskeyHandler {
|
|
|
1535
1560
|
const identityType = this.state.identityType === 'phone' ? 'phone' : 'email';
|
|
1536
1561
|
const challenge = await this.api.startPasskeyVerify(this.state.recipient, identityType, this.state.authContext);
|
|
1537
1562
|
const credential = await navigator.credentials.get({
|
|
1563
|
+
...(signal ? { signal } : {}),
|
|
1538
1564
|
publicKey: {
|
|
1539
1565
|
challenge: base64urlToArrayBuffer(challenge.challenge),
|
|
1540
1566
|
rpId: challenge.rpId,
|
|
@@ -1580,8 +1606,10 @@ class PasskeyHandler {
|
|
|
1580
1606
|
* (cancelled, identity locked, no passkey → registration).
|
|
1581
1607
|
*/
|
|
1582
1608
|
mapInlineCeremonyError(error) {
|
|
1583
|
-
// User dismissed the system sheet
|
|
1584
|
-
|
|
1609
|
+
// User dismissed the system sheet or no credential was available
|
|
1610
|
+
// (NotAllowedError), or the caller aborted the pending ceremony via its
|
|
1611
|
+
// AbortSignal (AbortError). Both end the ceremony without a credential.
|
|
1612
|
+
if (error instanceof Error && (error.name === 'NotAllowedError' || error.name === 'AbortError')) {
|
|
1585
1613
|
return {
|
|
1586
1614
|
success: false,
|
|
1587
1615
|
error: 'Authentication was cancelled. Please try again.',
|
|
@@ -4188,6 +4216,7 @@ class IdentityInputView {
|
|
|
4188
4216
|
this.inputElement = null;
|
|
4189
4217
|
this.labelElement = null;
|
|
4190
4218
|
this.submitButton = null;
|
|
4219
|
+
this.passkeyLink = null;
|
|
4191
4220
|
this.errorContainer = null;
|
|
4192
4221
|
this.focusTimeoutId = null;
|
|
4193
4222
|
this.detectedType = 'email';
|
|
@@ -4200,6 +4229,7 @@ class IdentityInputView {
|
|
|
4200
4229
|
}
|
|
4201
4230
|
};
|
|
4202
4231
|
this.boundHandleSubmit = () => this.handleSubmit();
|
|
4232
|
+
this.boundHandlePasskey = props.onPasskey ? () => props.onPasskey() : null;
|
|
4203
4233
|
}
|
|
4204
4234
|
get allowsBoth() {
|
|
4205
4235
|
return this.props.allowedTypes.includes('email') && this.props.allowedTypes.includes('phone');
|
|
@@ -4255,6 +4285,13 @@ class IdentityInputView {
|
|
|
4255
4285
|
this.submitButton.addEventListener('click', this.boundHandleSubmit);
|
|
4256
4286
|
formSection.appendChild(this.submitButton);
|
|
4257
4287
|
container.appendChild(formSection);
|
|
4288
|
+
if (this.boundHandlePasskey) {
|
|
4289
|
+
this.passkeyLink = document.createElement('button');
|
|
4290
|
+
this.passkeyLink.className = 'sv-fallback-link';
|
|
4291
|
+
this.passkeyLink.textContent = 'Sign in with a passkey';
|
|
4292
|
+
this.passkeyLink.addEventListener('click', this.boundHandlePasskey);
|
|
4293
|
+
container.appendChild(this.passkeyLink);
|
|
4294
|
+
}
|
|
4258
4295
|
this.focusTimeoutId = setTimeout(() => this.inputElement?.focus(), 50);
|
|
4259
4296
|
return container;
|
|
4260
4297
|
}
|
|
@@ -4398,6 +4435,9 @@ class IdentityInputView {
|
|
|
4398
4435
|
if (this.submitButton) {
|
|
4399
4436
|
this.submitButton.removeEventListener('click', this.boundHandleSubmit);
|
|
4400
4437
|
}
|
|
4438
|
+
if (this.passkeyLink && this.boundHandlePasskey) {
|
|
4439
|
+
this.passkeyLink.removeEventListener('click', this.boundHandlePasskey);
|
|
4440
|
+
}
|
|
4401
4441
|
}
|
|
4402
4442
|
}
|
|
4403
4443
|
|
|
@@ -5065,6 +5105,55 @@ class PasskeyView {
|
|
|
5065
5105
|
}
|
|
5066
5106
|
}
|
|
5067
5107
|
|
|
5108
|
+
/**
|
|
5109
|
+
* Passkey Auto-Verify View
|
|
5110
|
+
*
|
|
5111
|
+
* Shown behind the browser's passkey sheet while an auto-started discoverable
|
|
5112
|
+
* ceremony runs (returning browsers carrying the passkey-hint cookie). The
|
|
5113
|
+
* ceremony was fired without a click, so this screen has no action button —
|
|
5114
|
+
* only a live status and an escape hatch to the identifier form for anyone
|
|
5115
|
+
* who wants a different method (or whose sheet hangs).
|
|
5116
|
+
*/
|
|
5117
|
+
class PasskeyAutoView {
|
|
5118
|
+
constructor(props) {
|
|
5119
|
+
this.fallbackLink = null;
|
|
5120
|
+
this.props = props;
|
|
5121
|
+
this.boundHandleFallback = () => this.props.onUseAnotherMethod();
|
|
5122
|
+
}
|
|
5123
|
+
render() {
|
|
5124
|
+
const container = div();
|
|
5125
|
+
const iconContainer = div();
|
|
5126
|
+
iconContainer.appendChild(createPasskeyIcon());
|
|
5127
|
+
const title = document.createElement('h3');
|
|
5128
|
+
title.className = 'sv-title';
|
|
5129
|
+
title.textContent = 'Signing you in';
|
|
5130
|
+
const subtitle = document.createElement('p');
|
|
5131
|
+
subtitle.className = 'sv-subtitle';
|
|
5132
|
+
subtitle.textContent = 'Use your passkey to continue';
|
|
5133
|
+
const spinner = document.createElement('div');
|
|
5134
|
+
spinner.className = 'sv-spinner';
|
|
5135
|
+
spinner.setAttribute('role', 'status');
|
|
5136
|
+
spinner.setAttribute('aria-label', 'Waiting for your passkey');
|
|
5137
|
+
const spinnerRow = div('sv-loading');
|
|
5138
|
+
spinnerRow.appendChild(spinner);
|
|
5139
|
+
this.fallbackLink = document.createElement('button');
|
|
5140
|
+
this.fallbackLink.className = 'sv-fallback-link';
|
|
5141
|
+
this.fallbackLink.textContent = 'Use another method';
|
|
5142
|
+
this.fallbackLink.addEventListener('click', this.boundHandleFallback);
|
|
5143
|
+
container.appendChild(iconContainer);
|
|
5144
|
+
container.appendChild(title);
|
|
5145
|
+
container.appendChild(subtitle);
|
|
5146
|
+
container.appendChild(spinnerRow);
|
|
5147
|
+
container.appendChild(this.fallbackLink);
|
|
5148
|
+
return container;
|
|
5149
|
+
}
|
|
5150
|
+
destroy() {
|
|
5151
|
+
if (this.fallbackLink) {
|
|
5152
|
+
this.fallbackLink.removeEventListener('click', this.boundHandleFallback);
|
|
5153
|
+
}
|
|
5154
|
+
}
|
|
5155
|
+
}
|
|
5156
|
+
|
|
5068
5157
|
/**
|
|
5069
5158
|
* Passkey Registration Prompt View
|
|
5070
5159
|
*
|
|
@@ -6040,6 +6129,9 @@ class IdentityRenderer {
|
|
|
6040
6129
|
this.currentView = null;
|
|
6041
6130
|
this.focusTimeoutId = null;
|
|
6042
6131
|
this.morphTimer = null;
|
|
6132
|
+
// Live discoverable (no-identifier) ceremony. The controller cancels the
|
|
6133
|
+
// pending browser sheet when the person escapes to the identifier form.
|
|
6134
|
+
this.discoverableVerifyAbort = null;
|
|
6043
6135
|
// Post-login recommendation pipeline: the verified result to finalize with,
|
|
6044
6136
|
// and the remaining server-recommended steps to walk before finalizing.
|
|
6045
6137
|
this.postLoginResult = null;
|
|
@@ -6251,6 +6343,10 @@ class IdentityRenderer {
|
|
|
6251
6343
|
close() {
|
|
6252
6344
|
// Cancel all pending API requests first
|
|
6253
6345
|
this.api.abort();
|
|
6346
|
+
// A pending discoverable ceremony would otherwise hold the browser sheet
|
|
6347
|
+
// open against a dialog that no longer exists.
|
|
6348
|
+
this.discoverableVerifyAbort?.abort();
|
|
6349
|
+
this.discoverableVerifyAbort = null;
|
|
6254
6350
|
if (this.focusTimeoutId !== null) {
|
|
6255
6351
|
clearTimeout(this.focusTimeoutId);
|
|
6256
6352
|
this.focusTimeoutId = null;
|
|
@@ -6279,6 +6375,58 @@ class IdentityRenderer {
|
|
|
6279
6375
|
await this.showMethodSelect();
|
|
6280
6376
|
return;
|
|
6281
6377
|
}
|
|
6378
|
+
// Returning browser on the Identity origin (passkey-hint cookie present):
|
|
6379
|
+
// auto-start the discoverable ceremony instead of asking for an identifier
|
|
6380
|
+
// — the Google-style one-touch return. A cancel lands on the identifier
|
|
6381
|
+
// form, which keeps a "Sign in with a passkey" way back in.
|
|
6382
|
+
if (this.canDiscoverableVerify()) {
|
|
6383
|
+
void this.launchDiscoverableVerify();
|
|
6384
|
+
return;
|
|
6385
|
+
}
|
|
6386
|
+
this.showIdentityInput();
|
|
6387
|
+
}
|
|
6388
|
+
/**
|
|
6389
|
+
* True when the discoverable ceremony may be started without a gesture and
|
|
6390
|
+
* this account actually offers passkey login: the flow runs on the Identity
|
|
6391
|
+
* origin, the browser carries the passkey hint, and `passkey` is among the
|
|
6392
|
+
* account's enabled methods.
|
|
6393
|
+
*/
|
|
6394
|
+
canDiscoverableVerify() {
|
|
6395
|
+
if (!this.passkeyHandler.canAutoVerify())
|
|
6396
|
+
return false;
|
|
6397
|
+
const methods = enrichMethods(this.sdkConfig?.methods ?? []);
|
|
6398
|
+
return methods.some((m) => m.type === 'passkey');
|
|
6399
|
+
}
|
|
6400
|
+
/**
|
|
6401
|
+
* Run the no-identifier discoverable ceremony behind the passkey-auto view.
|
|
6402
|
+
* Fired on open for returning browsers and from the identifier form's
|
|
6403
|
+
* "Sign in with a passkey" shortcut. Anything short of a terminal outcome
|
|
6404
|
+
* (dismissed sheet, no credential on the device, transient failure) falls
|
|
6405
|
+
* back to the identifier form with no error banner — the person simply
|
|
6406
|
+
* lands where a first-time visitor starts.
|
|
6407
|
+
*/
|
|
6408
|
+
async launchDiscoverableVerify() {
|
|
6409
|
+
this.discoverableVerifyAbort = new AbortController();
|
|
6410
|
+
const { signal } = this.discoverableVerifyAbort;
|
|
6411
|
+
this.setState({ view: 'passkey-auto' });
|
|
6412
|
+
const result = await this.passkeyHandler.verify(signal);
|
|
6413
|
+
if (signal.aborted) {
|
|
6414
|
+
// The person already escaped to the identifier form; the aborted
|
|
6415
|
+
// ceremony's result is stale.
|
|
6416
|
+
return;
|
|
6417
|
+
}
|
|
6418
|
+
this.discoverableVerifyAbort = null;
|
|
6419
|
+
if (this.applyTerminalPasskeyResult(result))
|
|
6420
|
+
return;
|
|
6421
|
+
this.showIdentityInput();
|
|
6422
|
+
}
|
|
6423
|
+
/**
|
|
6424
|
+
* Abort the pending discoverable ceremony (dismisses the browser sheet where
|
|
6425
|
+
* the platform allows) and land on the identifier form.
|
|
6426
|
+
*/
|
|
6427
|
+
cancelDiscoverableVerify() {
|
|
6428
|
+
this.discoverableVerifyAbort?.abort();
|
|
6429
|
+
this.discoverableVerifyAbort = null;
|
|
6282
6430
|
this.showIdentityInput();
|
|
6283
6431
|
}
|
|
6284
6432
|
render() {
|
|
@@ -6389,6 +6537,11 @@ class IdentityRenderer {
|
|
|
6389
6537
|
initialValue: this.recipient,
|
|
6390
6538
|
error: state.error,
|
|
6391
6539
|
onSubmit: (result) => this.handleIdentitySubmit(result),
|
|
6540
|
+
// Returning browsers keep a one-tap way back into the discoverable
|
|
6541
|
+
// ceremony (e.g. after dismissing the auto-started sheet).
|
|
6542
|
+
onPasskey: this.canDiscoverableVerify()
|
|
6543
|
+
? () => { void this.launchDiscoverableVerify(); }
|
|
6544
|
+
: undefined,
|
|
6392
6545
|
});
|
|
6393
6546
|
case 'method-select':
|
|
6394
6547
|
return new MethodSelectView({
|
|
@@ -6440,6 +6593,10 @@ class IdentityRenderer {
|
|
|
6440
6593
|
: undefined,
|
|
6441
6594
|
});
|
|
6442
6595
|
}
|
|
6596
|
+
case 'passkey-auto':
|
|
6597
|
+
return new PasskeyAutoView({
|
|
6598
|
+
onUseAnotherMethod: () => this.cancelDiscoverableVerify(),
|
|
6599
|
+
});
|
|
6443
6600
|
case 'passkey-prompt':
|
|
6444
6601
|
return new PasskeyPromptView({
|
|
6445
6602
|
identityLabel: state.recipient,
|
|
@@ -6872,27 +7029,42 @@ class IdentityRenderer {
|
|
|
6872
7029
|
this.applyPasskeyResult(result, 'verify', fallbackToList);
|
|
6873
7030
|
}
|
|
6874
7031
|
/**
|
|
6875
|
-
*
|
|
6876
|
-
*
|
|
6877
|
-
*
|
|
7032
|
+
* Handle the terminal passkey outcomes every entry point shares: a verified
|
|
7033
|
+
* login (close + onSuccess + redirect), a blocked-Identity interstitial, or
|
|
7034
|
+
* a locked identity. Returns false for the retryable failures each caller
|
|
7035
|
+
* routes according to its own flow.
|
|
6878
7036
|
*/
|
|
6879
|
-
|
|
7037
|
+
applyTerminalPasskeyResult(result) {
|
|
6880
7038
|
if (result.success && result.result) {
|
|
6881
7039
|
this.close();
|
|
6882
7040
|
this.safeOnSuccess(result.result);
|
|
6883
7041
|
if (typeof result.result.redirect === 'string' && result.result.redirect) {
|
|
6884
7042
|
window.location.href = result.result.redirect;
|
|
6885
7043
|
}
|
|
7044
|
+
return true;
|
|
6886
7045
|
}
|
|
6887
|
-
|
|
6888
|
-
|
|
7046
|
+
if (this.renderBlockedInterstitial(result.errorCode)) {
|
|
7047
|
+
// Terminal interstitial already rendered — the owner must subscribe.
|
|
7048
|
+
return true;
|
|
7049
|
+
}
|
|
7050
|
+
if (result.errorCode === 'identity_locked') {
|
|
6889
7051
|
// Dedicated state — retrying cannot unlock the identity.
|
|
6890
7052
|
this.setState({
|
|
6891
7053
|
view: 'error',
|
|
6892
7054
|
code: 'identity_locked',
|
|
6893
7055
|
message: 'This SparkVault Identity is locked. Visit auth.sv to manage it.',
|
|
6894
7056
|
});
|
|
7057
|
+
return true;
|
|
6895
7058
|
}
|
|
7059
|
+
return false;
|
|
7060
|
+
}
|
|
7061
|
+
/**
|
|
7062
|
+
* Apply a passkey ceremony result: complete on success, or route to the
|
|
7063
|
+
* matching recovery state. Shared by the passkey view and the direct
|
|
7064
|
+
* picker launch so both behave identically.
|
|
7065
|
+
*/
|
|
7066
|
+
applyPasskeyResult(result, currentMode, fallbackToList = false) {
|
|
7067
|
+
if (this.applyTerminalPasskeyResult(result)) ;
|
|
6896
7068
|
else if (fallbackToList && this.passkeyFallbackMethodsAvailable()) {
|
|
6897
7069
|
// Auto-launched passkey that the person cancelled or that failed: drop to
|
|
6898
7070
|
// the full method list (passkey still listed) rather than a passkey-only
|