@sparkvault/sdk-js 2.0.4 → 2.1.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/dist/identity/renderer.d.ts +18 -0
- package/dist/sparkvault.cjs.js +56 -24
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +56 -24
- 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
|
@@ -86,11 +86,29 @@ export declare class IdentityRenderer {
|
|
|
86
86
|
private showMethodSelect;
|
|
87
87
|
private handleIdentitySubmit;
|
|
88
88
|
private getAllowedIdentityTypes;
|
|
89
|
+
/**
|
|
90
|
+
* @param userInitiated True when called from a live click on the picker, so
|
|
91
|
+
* a popup may be opened synchronously within that gesture. False when
|
|
92
|
+
* auto-selected after an async step (e.g. the single enabled method), where
|
|
93
|
+
* opening a popup would be blocked.
|
|
94
|
+
*/
|
|
89
95
|
private handleMethodSelect;
|
|
90
96
|
private handleTotpSubmit;
|
|
91
97
|
private handleSecondFactorSubmit;
|
|
92
98
|
private handleTotpResend;
|
|
93
99
|
private handlePasskeyStart;
|
|
100
|
+
/**
|
|
101
|
+
* Open the verify popup straight from a live picker gesture, showing a
|
|
102
|
+
* loading state while the ceremony runs. window.open inside verify() fires
|
|
103
|
+
* synchronously (before the first await), so it stays within the gesture.
|
|
104
|
+
*/
|
|
105
|
+
private launchPasskeyVerify;
|
|
106
|
+
/**
|
|
107
|
+
* Apply a passkey ceremony result: complete on success, or route to the
|
|
108
|
+
* matching recovery state. Shared by the passkey view and the direct
|
|
109
|
+
* picker launch so both behave identically.
|
|
110
|
+
*/
|
|
111
|
+
private applyPasskeyResult;
|
|
94
112
|
/**
|
|
95
113
|
* Handle fallback from passkey to an identifier-based code.
|
|
96
114
|
* User clicked "Having trouble? Use a code instead".
|
package/dist/sparkvault.cjs.js
CHANGED
|
@@ -5873,7 +5873,7 @@ class IdentityRenderer {
|
|
|
5873
5873
|
return new MethodSelectView({
|
|
5874
5874
|
email: state.email,
|
|
5875
5875
|
methods: state.methods,
|
|
5876
|
-
onSelectMethod: (method) => this.handleMethodSelect(method),
|
|
5876
|
+
onSelectMethod: (method) => this.handleMethodSelect(method, true),
|
|
5877
5877
|
onBack: state.email ? () => this.showIdentityInput() : undefined,
|
|
5878
5878
|
});
|
|
5879
5879
|
case 'totp-verify':
|
|
@@ -6052,7 +6052,13 @@ class IdentityRenderer {
|
|
|
6052
6052
|
getAllowedIdentityTypes() {
|
|
6053
6053
|
return this.verificationState.getAllowedIdentityTypes();
|
|
6054
6054
|
}
|
|
6055
|
-
|
|
6055
|
+
/**
|
|
6056
|
+
* @param userInitiated True when called from a live click on the picker, so
|
|
6057
|
+
* a popup may be opened synchronously within that gesture. False when
|
|
6058
|
+
* auto-selected after an async step (e.g. the single enabled method), where
|
|
6059
|
+
* opening a popup would be blocked.
|
|
6060
|
+
*/
|
|
6061
|
+
async handleMethodSelect(method, userInitiated = false) {
|
|
6056
6062
|
try {
|
|
6057
6063
|
switch (method.type) {
|
|
6058
6064
|
case 'totp': {
|
|
@@ -6080,11 +6086,21 @@ class IdentityRenderer {
|
|
|
6080
6086
|
break;
|
|
6081
6087
|
}
|
|
6082
6088
|
case 'passkey': {
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6089
|
+
if (userInitiated) {
|
|
6090
|
+
// Live picker tap: open the passkey popup directly within this
|
|
6091
|
+
// gesture (window.open in verify() runs before the first await),
|
|
6092
|
+
// skipping the redundant in-widget passkey screen.
|
|
6093
|
+
await this.launchPasskeyVerify();
|
|
6094
|
+
}
|
|
6095
|
+
else {
|
|
6096
|
+
// Auto-selected without a fresh gesture: a popup would be blocked,
|
|
6097
|
+
// so land on the passkey view whose button supplies the gesture.
|
|
6098
|
+
this.setState({
|
|
6099
|
+
view: 'passkey',
|
|
6100
|
+
recipient: this.recipient,
|
|
6101
|
+
mode: 'verify',
|
|
6102
|
+
});
|
|
6103
|
+
}
|
|
6088
6104
|
break;
|
|
6089
6105
|
}
|
|
6090
6106
|
case 'sparklink': {
|
|
@@ -6273,6 +6289,24 @@ class IdentityRenderer {
|
|
|
6273
6289
|
const result = currentMode === 'register'
|
|
6274
6290
|
? await this.passkeyHandler.register()
|
|
6275
6291
|
: await this.passkeyHandler.verify();
|
|
6292
|
+
this.applyPasskeyResult(result, currentMode);
|
|
6293
|
+
}
|
|
6294
|
+
/**
|
|
6295
|
+
* Open the verify popup straight from a live picker gesture, showing a
|
|
6296
|
+
* loading state while the ceremony runs. window.open inside verify() fires
|
|
6297
|
+
* synchronously (before the first await), so it stays within the gesture.
|
|
6298
|
+
*/
|
|
6299
|
+
async launchPasskeyVerify() {
|
|
6300
|
+
this.setState({ view: 'loading' });
|
|
6301
|
+
const result = await this.passkeyHandler.verify();
|
|
6302
|
+
this.applyPasskeyResult(result, 'verify');
|
|
6303
|
+
}
|
|
6304
|
+
/**
|
|
6305
|
+
* Apply a passkey ceremony result: complete on success, or route to the
|
|
6306
|
+
* matching recovery state. Shared by the passkey view and the direct
|
|
6307
|
+
* picker launch so both behave identically.
|
|
6308
|
+
*/
|
|
6309
|
+
applyPasskeyResult(result, currentMode) {
|
|
6276
6310
|
if (result.success && result.result) {
|
|
6277
6311
|
this.close();
|
|
6278
6312
|
this.safeOnSuccess(result.result);
|
|
@@ -6288,24 +6322,22 @@ class IdentityRenderer {
|
|
|
6288
6322
|
message: 'This SparkVault Identity is locked. Visit auth.sv to manage it.',
|
|
6289
6323
|
});
|
|
6290
6324
|
}
|
|
6325
|
+
else if (result.errorType === 'not_found') {
|
|
6326
|
+
// No passkey yet — pivot the same screen to registration.
|
|
6327
|
+
this.setState({
|
|
6328
|
+
view: 'passkey',
|
|
6329
|
+
recipient: this.recipient,
|
|
6330
|
+
mode: 'register',
|
|
6331
|
+
error: result.error,
|
|
6332
|
+
});
|
|
6333
|
+
}
|
|
6291
6334
|
else {
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
this.
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
error: result.error,
|
|
6299
|
-
});
|
|
6300
|
-
}
|
|
6301
|
-
else {
|
|
6302
|
-
this.setState({
|
|
6303
|
-
view: 'passkey',
|
|
6304
|
-
recipient: this.recipient,
|
|
6305
|
-
mode: currentMode,
|
|
6306
|
-
error: result.error,
|
|
6307
|
-
});
|
|
6308
|
-
}
|
|
6335
|
+
this.setState({
|
|
6336
|
+
view: 'passkey',
|
|
6337
|
+
recipient: this.recipient,
|
|
6338
|
+
mode: currentMode,
|
|
6339
|
+
error: result.error,
|
|
6340
|
+
});
|
|
6309
6341
|
}
|
|
6310
6342
|
}
|
|
6311
6343
|
/**
|