@sparkvault/sdk-js 7.0.2 → 8.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 +34 -5
- package/dist/index.d.ts +3 -3
- package/dist/products/identity/api.d.ts +7 -7
- package/dist/products/identity/handlers/index.d.ts +1 -1
- package/dist/products/identity/handlers/{totp-handler.d.ts → otp-handler.d.ts} +15 -15
- package/dist/products/identity/index.d.ts +1 -1
- package/dist/products/identity/renderer.d.ts +5 -5
- package/dist/products/identity/state.d.ts +8 -8
- package/dist/products/identity/types.d.ts +6 -6
- package/dist/products/identity/views/base.d.ts +2 -2
- package/dist/products/identity/views/index.d.ts +1 -1
- package/dist/products/identity/views/{totp-verify.d.ts → otp-verify.d.ts} +5 -5
- package/dist/products/index.d.ts +1 -1
- package/dist/sparkvault.cjs.js +95 -95
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +95 -95
- 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/dist/sparkvault.esm.js
CHANGED
|
@@ -880,20 +880,20 @@ class IdentityApi extends SparkVaultApi {
|
|
|
880
880
|
return params;
|
|
881
881
|
}
|
|
882
882
|
/**
|
|
883
|
-
* Send
|
|
883
|
+
* Send OTP code to email or phone
|
|
884
884
|
*/
|
|
885
|
-
async
|
|
886
|
-
return this.request('POST', '/
|
|
885
|
+
async sendOtp(params) {
|
|
886
|
+
return this.request('POST', '/otp/send', {
|
|
887
887
|
recipient: params.recipient,
|
|
888
888
|
method: params.method,
|
|
889
889
|
...this.buildAuthContextParams(params.authContext),
|
|
890
890
|
});
|
|
891
891
|
}
|
|
892
892
|
/**
|
|
893
|
-
* Verify
|
|
893
|
+
* Verify OTP code
|
|
894
894
|
*/
|
|
895
|
-
async
|
|
896
|
-
return this.request('POST', '/
|
|
895
|
+
async verifyOtp(params) {
|
|
896
|
+
return this.request('POST', '/otp/verify', {
|
|
897
897
|
kindling: params.kindling,
|
|
898
898
|
pin: params.pin,
|
|
899
899
|
recipient: params.recipient,
|
|
@@ -1129,25 +1129,25 @@ class IdentityApiError extends SparkVaultError {
|
|
|
1129
1129
|
*/
|
|
1130
1130
|
const METHOD_REGISTRY = {
|
|
1131
1131
|
// Core methods
|
|
1132
|
-
|
|
1133
|
-
id: '
|
|
1134
|
-
type: '
|
|
1132
|
+
otp_email: {
|
|
1133
|
+
id: 'otp_email',
|
|
1134
|
+
type: 'otp',
|
|
1135
1135
|
identityType: 'email',
|
|
1136
1136
|
name: 'Email code',
|
|
1137
1137
|
description: 'Get a one-time code via email',
|
|
1138
1138
|
icon: 'email',
|
|
1139
1139
|
},
|
|
1140
|
-
|
|
1141
|
-
id: '
|
|
1142
|
-
type: '
|
|
1140
|
+
otp_sms: {
|
|
1141
|
+
id: 'otp_sms',
|
|
1142
|
+
type: 'otp',
|
|
1143
1143
|
identityType: 'phone',
|
|
1144
1144
|
name: 'Text message',
|
|
1145
1145
|
description: 'Get a one-time code via SMS',
|
|
1146
1146
|
icon: 'sms',
|
|
1147
1147
|
},
|
|
1148
|
-
|
|
1149
|
-
id: '
|
|
1150
|
-
type: '
|
|
1148
|
+
otp_voice: {
|
|
1149
|
+
id: 'otp_voice',
|
|
1150
|
+
type: 'otp',
|
|
1151
1151
|
identityType: 'phone',
|
|
1152
1152
|
name: 'Voice call',
|
|
1153
1153
|
description: 'Get a one-time code via phone call',
|
|
@@ -1263,8 +1263,8 @@ class VerificationState {
|
|
|
1263
1263
|
isFallbackMode: false,
|
|
1264
1264
|
pendingResult: null,
|
|
1265
1265
|
};
|
|
1266
|
-
//
|
|
1267
|
-
this.
|
|
1266
|
+
// OTP state
|
|
1267
|
+
this._otp = {
|
|
1268
1268
|
kindling: '',
|
|
1269
1269
|
method: null,
|
|
1270
1270
|
};
|
|
@@ -1323,15 +1323,15 @@ class VerificationState {
|
|
|
1323
1323
|
setPendingResult(result) {
|
|
1324
1324
|
this._passkey.pendingResult = result;
|
|
1325
1325
|
}
|
|
1326
|
-
// ---
|
|
1327
|
-
get
|
|
1328
|
-
return this.
|
|
1326
|
+
// --- OTP State ---
|
|
1327
|
+
get otp() {
|
|
1328
|
+
return this._otp;
|
|
1329
1329
|
}
|
|
1330
1330
|
setKindling(kindling) {
|
|
1331
|
-
this.
|
|
1331
|
+
this._otp.kindling = kindling;
|
|
1332
1332
|
}
|
|
1333
|
-
|
|
1334
|
-
this.
|
|
1333
|
+
setOtpMethod(method) {
|
|
1334
|
+
this._otp.method = method;
|
|
1335
1335
|
}
|
|
1336
1336
|
}
|
|
1337
1337
|
|
|
@@ -1678,32 +1678,32 @@ class PasskeyHandler {
|
|
|
1678
1678
|
}
|
|
1679
1679
|
|
|
1680
1680
|
/**
|
|
1681
|
-
*
|
|
1681
|
+
* OTP Handler
|
|
1682
1682
|
*
|
|
1683
|
-
* Single responsibility:
|
|
1684
|
-
* Extracts
|
|
1683
|
+
* Single responsibility: OTP code sending and verification.
|
|
1684
|
+
* Extracts OTP logic from IdentityRenderer for better separation of concerns.
|
|
1685
1685
|
*/
|
|
1686
1686
|
/**
|
|
1687
|
-
* Handles
|
|
1687
|
+
* Handles OTP code sending and verification
|
|
1688
1688
|
*/
|
|
1689
|
-
class
|
|
1689
|
+
class OtpHandler {
|
|
1690
1690
|
constructor(api, state) {
|
|
1691
1691
|
this.api = api;
|
|
1692
1692
|
this.state = state;
|
|
1693
1693
|
}
|
|
1694
1694
|
/**
|
|
1695
|
-
* Send
|
|
1695
|
+
* Send OTP code via email, SMS, or voice
|
|
1696
1696
|
*/
|
|
1697
1697
|
async send(method) {
|
|
1698
1698
|
try {
|
|
1699
|
-
const response = await this.api.
|
|
1699
|
+
const response = await this.api.sendOtp({
|
|
1700
1700
|
recipient: this.state.recipient,
|
|
1701
1701
|
method,
|
|
1702
1702
|
authContext: this.state.authContext,
|
|
1703
1703
|
});
|
|
1704
1704
|
// Update state with kindling
|
|
1705
1705
|
this.state.setKindling(response.kindling);
|
|
1706
|
-
this.state.
|
|
1706
|
+
this.state.setOtpMethod(method);
|
|
1707
1707
|
return {
|
|
1708
1708
|
success: true,
|
|
1709
1709
|
kindling: response.kindling,
|
|
@@ -1721,18 +1721,18 @@ class TotpHandler {
|
|
|
1721
1721
|
}
|
|
1722
1722
|
}
|
|
1723
1723
|
/**
|
|
1724
|
-
* Resend
|
|
1724
|
+
* Resend OTP code
|
|
1725
1725
|
*/
|
|
1726
1726
|
async resend() {
|
|
1727
|
-
const method = this.state.
|
|
1727
|
+
const method = this.state.otp.method;
|
|
1728
1728
|
if (!method) {
|
|
1729
1729
|
return {
|
|
1730
1730
|
success: false,
|
|
1731
|
-
error: 'No
|
|
1731
|
+
error: 'No OTP method set',
|
|
1732
1732
|
};
|
|
1733
1733
|
}
|
|
1734
1734
|
try {
|
|
1735
|
-
const response = await this.api.
|
|
1735
|
+
const response = await this.api.sendOtp({
|
|
1736
1736
|
recipient: this.state.recipient,
|
|
1737
1737
|
method,
|
|
1738
1738
|
authContext: this.state.authContext,
|
|
@@ -1756,10 +1756,10 @@ class TotpHandler {
|
|
|
1756
1756
|
}
|
|
1757
1757
|
}
|
|
1758
1758
|
/**
|
|
1759
|
-
* Verify
|
|
1759
|
+
* Verify OTP code
|
|
1760
1760
|
*/
|
|
1761
1761
|
async verify(code) {
|
|
1762
|
-
const kindling = this.state.
|
|
1762
|
+
const kindling = this.state.otp.kindling;
|
|
1763
1763
|
if (!kindling) {
|
|
1764
1764
|
return {
|
|
1765
1765
|
success: false,
|
|
@@ -1767,7 +1767,7 @@ class TotpHandler {
|
|
|
1767
1767
|
};
|
|
1768
1768
|
}
|
|
1769
1769
|
try {
|
|
1770
|
-
const response = await this.api.
|
|
1770
|
+
const response = await this.api.verifyOtp({
|
|
1771
1771
|
kindling,
|
|
1772
1772
|
pin: code,
|
|
1773
1773
|
recipient: this.state.recipient,
|
|
@@ -2302,17 +2302,17 @@ function getStyles(options) {
|
|
|
2302
2302
|
}
|
|
2303
2303
|
|
|
2304
2304
|
/* ========================================
|
|
2305
|
-
|
|
2305
|
+
OTP INPUT
|
|
2306
2306
|
======================================== */
|
|
2307
2307
|
|
|
2308
|
-
.sv-
|
|
2308
|
+
.sv-otp-input-group {
|
|
2309
2309
|
display: flex;
|
|
2310
2310
|
gap: 8px;
|
|
2311
2311
|
justify-content: center;
|
|
2312
2312
|
margin-bottom: 16px;
|
|
2313
2313
|
}
|
|
2314
2314
|
|
|
2315
|
-
.sv-
|
|
2315
|
+
.sv-otp-digit {
|
|
2316
2316
|
width: 44px;
|
|
2317
2317
|
height: 52px;
|
|
2318
2318
|
text-align: center;
|
|
@@ -2327,17 +2327,17 @@ function getStyles(options) {
|
|
|
2327
2327
|
transition: border-color 0.15s ease, box-shadow 0.15s ease;
|
|
2328
2328
|
}
|
|
2329
2329
|
|
|
2330
|
-
.sv-
|
|
2330
|
+
.sv-otp-digit:hover:not(:focus):not(:disabled) {
|
|
2331
2331
|
border-color: ${tokens.borderHover};
|
|
2332
2332
|
}
|
|
2333
2333
|
|
|
2334
|
-
.sv-
|
|
2334
|
+
.sv-otp-digit:focus {
|
|
2335
2335
|
outline: none;
|
|
2336
2336
|
border-color: ${tokens.borderFocus};
|
|
2337
2337
|
box-shadow: 0 0 0 3px ${tokens.primaryLight};
|
|
2338
2338
|
}
|
|
2339
2339
|
|
|
2340
|
-
.sv-
|
|
2340
|
+
.sv-otp-digit:disabled {
|
|
2341
2341
|
opacity: 0.5;
|
|
2342
2342
|
cursor: not-allowed;
|
|
2343
2343
|
}
|
|
@@ -2847,7 +2847,7 @@ function getStyles(options) {
|
|
|
2847
2847
|
}
|
|
2848
2848
|
|
|
2849
2849
|
/* ========================================
|
|
2850
|
-
|
|
2850
|
+
OTP VIEW
|
|
2851
2851
|
======================================== */
|
|
2852
2852
|
|
|
2853
2853
|
.sv-resend-container {
|
|
@@ -3160,7 +3160,7 @@ function getStyles(options) {
|
|
|
3160
3160
|
padding: 24px 28px;
|
|
3161
3161
|
}
|
|
3162
3162
|
|
|
3163
|
-
.sv-
|
|
3163
|
+
.sv-otp-digit {
|
|
3164
3164
|
width: 40px;
|
|
3165
3165
|
height: 48px;
|
|
3166
3166
|
font-size: 18px;
|
|
@@ -3172,11 +3172,11 @@ function getStyles(options) {
|
|
|
3172
3172
|
}
|
|
3173
3173
|
|
|
3174
3174
|
@media (max-width: 360px) {
|
|
3175
|
-
.sv-
|
|
3175
|
+
.sv-otp-input-group {
|
|
3176
3176
|
gap: 6px;
|
|
3177
3177
|
}
|
|
3178
3178
|
|
|
3179
|
-
.sv-
|
|
3179
|
+
.sv-otp-digit {
|
|
3180
3180
|
width: 36px;
|
|
3181
3181
|
height: 44px;
|
|
3182
3182
|
font-size: 16px;
|
|
@@ -3860,10 +3860,10 @@ function looksLikePhone(input) {
|
|
|
3860
3860
|
return /^[+(\d]/.test(trimmed) && !/[@.]/.test(trimmed);
|
|
3861
3861
|
}
|
|
3862
3862
|
/**
|
|
3863
|
-
* Validate
|
|
3863
|
+
* Validate OTP code format.
|
|
3864
3864
|
* Returns sanitized code or null if invalid.
|
|
3865
3865
|
*/
|
|
3866
|
-
function
|
|
3866
|
+
function validateOtpCode(code) {
|
|
3867
3867
|
const digits = code.replace(/\D/g, '');
|
|
3868
3868
|
if (digits.length === 6) {
|
|
3869
3869
|
return digits;
|
|
@@ -4219,12 +4219,12 @@ class MethodSelectView {
|
|
|
4219
4219
|
}
|
|
4220
4220
|
|
|
4221
4221
|
/**
|
|
4222
|
-
*
|
|
4222
|
+
* OTP Verification View
|
|
4223
4223
|
*
|
|
4224
|
-
* Collects and validates the 6-digit
|
|
4224
|
+
* Collects and validates the 6-digit OTP code sent via email, SMS, or voice.
|
|
4225
4225
|
*/
|
|
4226
4226
|
const CODE_LENGTH = 6;
|
|
4227
|
-
class
|
|
4227
|
+
class OtpVerifyView {
|
|
4228
4228
|
constructor(props) {
|
|
4229
4229
|
this.inputElements = [];
|
|
4230
4230
|
this.submitButton = null;
|
|
@@ -4301,14 +4301,14 @@ class TotpVerifyView {
|
|
|
4301
4301
|
return link;
|
|
4302
4302
|
}
|
|
4303
4303
|
createInputGroup() {
|
|
4304
|
-
const group = div('sv-
|
|
4304
|
+
const group = div('sv-otp-input-group');
|
|
4305
4305
|
for (let i = 0; i < CODE_LENGTH; i++) {
|
|
4306
4306
|
const input = document.createElement('input');
|
|
4307
4307
|
input.type = 'text';
|
|
4308
4308
|
input.inputMode = 'numeric';
|
|
4309
4309
|
input.pattern = '[0-9]*';
|
|
4310
4310
|
input.maxLength = 1;
|
|
4311
|
-
input.className = 'sv-
|
|
4311
|
+
input.className = 'sv-otp-digit';
|
|
4312
4312
|
input.autocomplete = 'one-time-code';
|
|
4313
4313
|
input.setAttribute('aria-label', `Digit ${i + 1} of ${CODE_LENGTH}`);
|
|
4314
4314
|
// Create and store handlers for proper cleanup
|
|
@@ -4415,7 +4415,7 @@ class TotpVerifyView {
|
|
|
4415
4415
|
return;
|
|
4416
4416
|
}
|
|
4417
4417
|
const code = this.getCode();
|
|
4418
|
-
const validCode =
|
|
4418
|
+
const validCode = validateOtpCode(code);
|
|
4419
4419
|
if (!validCode) {
|
|
4420
4420
|
this.showError('Please enter the complete 6-digit code');
|
|
4421
4421
|
return;
|
|
@@ -5723,7 +5723,7 @@ class OriginNotAllowedView {
|
|
|
5723
5723
|
* Identity View Renderer
|
|
5724
5724
|
*
|
|
5725
5725
|
* Orchestrates view state and rendering for identity verification flows.
|
|
5726
|
-
* Uses extracted handlers for
|
|
5726
|
+
* Uses extracted handlers for OTP and Passkey operations.
|
|
5727
5727
|
*/
|
|
5728
5728
|
/**
|
|
5729
5729
|
* End-user copy for a blocked Identity. Intentionally generic — it never names
|
|
@@ -5779,7 +5779,7 @@ class IdentityRenderer {
|
|
|
5779
5779
|
this.verificationState = new VerificationState();
|
|
5780
5780
|
// Initialize handlers with shared state
|
|
5781
5781
|
this.passkeyHandler = new PasskeyHandler(api, this.verificationState);
|
|
5782
|
-
this.
|
|
5782
|
+
this.otpHandler = new OtpHandler(api, this.verificationState);
|
|
5783
5783
|
this.sparkLinkHandler = new SparkLinkHandler(api, this.verificationState);
|
|
5784
5784
|
// Set initial identity from options
|
|
5785
5785
|
if (options.email) {
|
|
@@ -6046,14 +6046,14 @@ class IdentityRenderer {
|
|
|
6046
6046
|
onSelectMethod: (method) => this.handleMethodSelect(method, true),
|
|
6047
6047
|
onBack: state.email ? () => this.showIdentityInput() : undefined,
|
|
6048
6048
|
});
|
|
6049
|
-
case '
|
|
6050
|
-
return new
|
|
6049
|
+
case 'otp-verify':
|
|
6050
|
+
return new OtpVerifyView({
|
|
6051
6051
|
email: state.email,
|
|
6052
6052
|
method: state.method,
|
|
6053
6053
|
error: state.error,
|
|
6054
6054
|
backoffExpires: state.backoffExpires,
|
|
6055
|
-
onSubmit: (code) => this.
|
|
6056
|
-
onResend: () => this.
|
|
6055
|
+
onSubmit: (code) => this.handleOtpSubmit(code),
|
|
6056
|
+
onResend: () => this.handleOtpResend(),
|
|
6057
6057
|
onBack: () => this.showMethodSelect(),
|
|
6058
6058
|
});
|
|
6059
6059
|
case 'two-factor':
|
|
@@ -6104,7 +6104,7 @@ class IdentityRenderer {
|
|
|
6104
6104
|
onSkip: () => this.handleBackupSkip(),
|
|
6105
6105
|
});
|
|
6106
6106
|
case 'backup-code':
|
|
6107
|
-
return new
|
|
6107
|
+
return new OtpVerifyView({
|
|
6108
6108
|
email: state.value,
|
|
6109
6109
|
method: state.method,
|
|
6110
6110
|
error: state.error,
|
|
@@ -6256,29 +6256,29 @@ class IdentityRenderer {
|
|
|
6256
6256
|
async handleMethodSelect(method, userInitiated = false) {
|
|
6257
6257
|
try {
|
|
6258
6258
|
switch (method.type) {
|
|
6259
|
-
case '
|
|
6260
|
-
const
|
|
6259
|
+
case 'otp': {
|
|
6260
|
+
const otpMethod = method.id === 'otp_sms'
|
|
6261
6261
|
? 'sms'
|
|
6262
|
-
: method.id === '
|
|
6262
|
+
: method.id === 'otp_voice'
|
|
6263
6263
|
? 'voice'
|
|
6264
6264
|
: 'email';
|
|
6265
6265
|
this.setState({ view: 'loading' });
|
|
6266
|
-
const result = await this.
|
|
6266
|
+
const result = await this.otpHandler.send(otpMethod);
|
|
6267
6267
|
if (!result.success) {
|
|
6268
6268
|
if (this.renderBlockedInterstitial(result.errorCode))
|
|
6269
6269
|
return;
|
|
6270
6270
|
this.setState({
|
|
6271
6271
|
view: 'error',
|
|
6272
6272
|
message: result.error ?? 'Failed to send code',
|
|
6273
|
-
code: '
|
|
6273
|
+
code: 'otp_send_failed',
|
|
6274
6274
|
});
|
|
6275
6275
|
return;
|
|
6276
6276
|
}
|
|
6277
6277
|
this.setState({
|
|
6278
|
-
view: '
|
|
6278
|
+
view: 'otp-verify',
|
|
6279
6279
|
email: this.recipient,
|
|
6280
|
-
method:
|
|
6281
|
-
kindling: this.verificationState.
|
|
6280
|
+
method: otpMethod,
|
|
6281
|
+
kindling: this.verificationState.otp.kindling,
|
|
6282
6282
|
});
|
|
6283
6283
|
break;
|
|
6284
6284
|
}
|
|
@@ -6328,7 +6328,7 @@ class IdentityRenderer {
|
|
|
6328
6328
|
// A blocked Identity (trial exhausted/expired, paid capacity) is
|
|
6329
6329
|
// terminal — show the "sign-in unavailable" interstitial, not a
|
|
6330
6330
|
// retryable "Try Again" that invites retrying a permanently-blocked
|
|
6331
|
-
// login. Mirrors the
|
|
6331
|
+
// login. Mirrors the otp send path.
|
|
6332
6332
|
if (this.renderBlockedInterstitial(result.errorCode))
|
|
6333
6333
|
return;
|
|
6334
6334
|
this.setState({
|
|
@@ -6386,11 +6386,11 @@ class IdentityRenderer {
|
|
|
6386
6386
|
});
|
|
6387
6387
|
return true;
|
|
6388
6388
|
}
|
|
6389
|
-
async
|
|
6390
|
-
if (this.viewState.view !== '
|
|
6389
|
+
async handleOtpSubmit(code) {
|
|
6390
|
+
if (this.viewState.view !== 'otp-verify')
|
|
6391
6391
|
return;
|
|
6392
|
-
const currentMethod = this.verificationState.
|
|
6393
|
-
const result = await this.
|
|
6392
|
+
const currentMethod = this.verificationState.otp.method ?? 'email';
|
|
6393
|
+
const result = await this.otpHandler.verify(code);
|
|
6394
6394
|
if (result.secondFactor) {
|
|
6395
6395
|
this.setState({
|
|
6396
6396
|
view: 'two-factor',
|
|
@@ -6417,33 +6417,33 @@ class IdentityRenderer {
|
|
|
6417
6417
|
const errorMsg = result.error?.toLowerCase() ?? '';
|
|
6418
6418
|
if (errorMsg.includes('expired')) {
|
|
6419
6419
|
// Auto-resend a new code
|
|
6420
|
-
const resendResult = await this.
|
|
6420
|
+
const resendResult = await this.otpHandler.resend();
|
|
6421
6421
|
if (resendResult.success) {
|
|
6422
6422
|
this.setState({
|
|
6423
|
-
view: '
|
|
6423
|
+
view: 'otp-verify',
|
|
6424
6424
|
email: this.recipient,
|
|
6425
6425
|
method: currentMethod,
|
|
6426
|
-
kindling: this.verificationState.
|
|
6426
|
+
kindling: this.verificationState.otp.kindling,
|
|
6427
6427
|
error: 'Code expired. We\'ve sent a new one.',
|
|
6428
6428
|
});
|
|
6429
6429
|
return;
|
|
6430
6430
|
}
|
|
6431
6431
|
// Resend failed - show error
|
|
6432
6432
|
this.setState({
|
|
6433
|
-
view: '
|
|
6433
|
+
view: 'otp-verify',
|
|
6434
6434
|
email: this.recipient,
|
|
6435
6435
|
method: currentMethod,
|
|
6436
|
-
kindling: this.verificationState.
|
|
6436
|
+
kindling: this.verificationState.otp.kindling,
|
|
6437
6437
|
error: resendResult.error ?? 'Code expired and failed to resend.',
|
|
6438
6438
|
});
|
|
6439
6439
|
return;
|
|
6440
6440
|
}
|
|
6441
6441
|
// Other verification failure
|
|
6442
6442
|
this.setState({
|
|
6443
|
-
view: '
|
|
6443
|
+
view: 'otp-verify',
|
|
6444
6444
|
email: this.recipient,
|
|
6445
6445
|
method: currentMethod,
|
|
6446
|
-
kindling: this.verificationState.
|
|
6446
|
+
kindling: this.verificationState.otp.kindling,
|
|
6447
6447
|
error: result.error ?? 'Invalid code. Please try again.',
|
|
6448
6448
|
backoffExpires: result.backoffExpires,
|
|
6449
6449
|
});
|
|
@@ -6477,19 +6477,19 @@ class IdentityRenderer {
|
|
|
6477
6477
|
this.setState({ view: 'two-factor', ticket, methods, error: message });
|
|
6478
6478
|
}
|
|
6479
6479
|
}
|
|
6480
|
-
async
|
|
6481
|
-
if (this.viewState.view !== '
|
|
6480
|
+
async handleOtpResend() {
|
|
6481
|
+
if (this.viewState.view !== 'otp-verify')
|
|
6482
6482
|
return;
|
|
6483
|
-
const currentMethod = this.verificationState.
|
|
6484
|
-
const result = await this.
|
|
6483
|
+
const currentMethod = this.verificationState.otp.method ?? 'email';
|
|
6484
|
+
const result = await this.otpHandler.resend();
|
|
6485
6485
|
if (!result.success) {
|
|
6486
6486
|
if (this.renderBlockedInterstitial(result.errorCode))
|
|
6487
6487
|
return;
|
|
6488
6488
|
this.setState({
|
|
6489
|
-
view: '
|
|
6489
|
+
view: 'otp-verify',
|
|
6490
6490
|
email: this.recipient,
|
|
6491
6491
|
method: currentMethod,
|
|
6492
|
-
kindling: this.verificationState.
|
|
6492
|
+
kindling: this.verificationState.otp.kindling,
|
|
6493
6493
|
error: result.error ?? 'Failed to resend code',
|
|
6494
6494
|
});
|
|
6495
6495
|
}
|
|
@@ -7160,27 +7160,27 @@ class IdentityRenderer {
|
|
|
7160
7160
|
}
|
|
7161
7161
|
}
|
|
7162
7162
|
/**
|
|
7163
|
-
* Handle fallback from SparkLink to
|
|
7163
|
+
* Handle fallback from SparkLink to OTP verification code.
|
|
7164
7164
|
*/
|
|
7165
7165
|
async handleSparkLinkFallback() {
|
|
7166
7166
|
this.cleanupSparkLink();
|
|
7167
7167
|
this.setState({ view: 'loading' });
|
|
7168
|
-
const result = await this.
|
|
7168
|
+
const result = await this.otpHandler.send('email');
|
|
7169
7169
|
if (!result.success) {
|
|
7170
7170
|
if (this.renderBlockedInterstitial(result.errorCode))
|
|
7171
7171
|
return;
|
|
7172
7172
|
this.setState({
|
|
7173
7173
|
view: 'error',
|
|
7174
7174
|
message: result.error ?? 'Failed to send code',
|
|
7175
|
-
code: '
|
|
7175
|
+
code: 'otp_send_failed',
|
|
7176
7176
|
});
|
|
7177
7177
|
return;
|
|
7178
7178
|
}
|
|
7179
7179
|
this.setState({
|
|
7180
|
-
view: '
|
|
7180
|
+
view: 'otp-verify',
|
|
7181
7181
|
email: this.recipient,
|
|
7182
7182
|
method: 'email',
|
|
7183
|
-
kindling: this.verificationState.
|
|
7183
|
+
kindling: this.verificationState.otp.kindling,
|
|
7184
7184
|
});
|
|
7185
7185
|
}
|
|
7186
7186
|
}
|
|
@@ -7772,7 +7772,7 @@ function attachClickHandler(selector, onClick) {
|
|
|
7772
7772
|
* Identity Module
|
|
7773
7773
|
*
|
|
7774
7774
|
* Provides identity verification through dialog or inline UI.
|
|
7775
|
-
* Supports passkey,
|
|
7775
|
+
* Supports passkey, OTP, SparkLink, and social authentication.
|
|
7776
7776
|
*
|
|
7777
7777
|
* @example Dialog mode (immediate)
|
|
7778
7778
|
* const result = await sv.products.identity.verify();
|