@sparkvault/sdk-js 8.8.2 → 8.8.4
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/renderer.d.ts +18 -0
- package/dist/products/identity/views/icons.d.ts +4 -1
- package/dist/products/identity/views/method-select.d.ts +3 -0
- package/dist/sparkvault.cjs.js +88 -19
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +88 -19
- 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
package/dist/sparkvault.esm.js
CHANGED
|
@@ -1257,7 +1257,7 @@ const METHOD_REGISTRY = {
|
|
|
1257
1257
|
type: 'passkey',
|
|
1258
1258
|
name: 'Passkey',
|
|
1259
1259
|
description: 'Use biometrics or security key',
|
|
1260
|
-
icon: '
|
|
1260
|
+
icon: 'fingerprint',
|
|
1261
1261
|
},
|
|
1262
1262
|
sparklink: {
|
|
1263
1263
|
id: 'sparklink',
|
|
@@ -2483,13 +2483,6 @@ function getStyles(options) {
|
|
|
2483
2483
|
text-align: left;
|
|
2484
2484
|
padding: 15px 40px 15px 14px;
|
|
2485
2485
|
margin-bottom: 9px;
|
|
2486
|
-
/* Inset 2px on either side so the focus ring (drawn outside the
|
|
2487
|
-
border-box) has room to render without clipping against the
|
|
2488
|
-
dialog's container edges. width:auto pairs with this to prevent
|
|
2489
|
-
the row from forcing horizontal overflow. */
|
|
2490
|
-
margin-left: 2px;
|
|
2491
|
-
margin-right: 2px;
|
|
2492
|
-
width: calc(100% - 4px);
|
|
2493
2486
|
transition: background var(--sv-dur-fast) var(--sv-ease-standard), border-color var(--sv-dur-fast) var(--sv-ease-standard);
|
|
2494
2487
|
}
|
|
2495
2488
|
|
|
@@ -3446,6 +3439,11 @@ function getStyles(options) {
|
|
|
3446
3439
|
min-height: 0;
|
|
3447
3440
|
padding-left: 0;
|
|
3448
3441
|
padding-right: 0;
|
|
3442
|
+
/* The host page owns the scroll and the surrounding padding in bare
|
|
3443
|
+
mode, so this body never scrolls internally. Keep overflow visible
|
|
3444
|
+
so a focused control's ring paints into the host padding instead of
|
|
3445
|
+
being clipped flat against this edgeless body's sides. */
|
|
3446
|
+
overflow: visible;
|
|
3449
3447
|
}
|
|
3450
3448
|
|
|
3451
3449
|
/* ========================================
|
|
@@ -3733,12 +3731,22 @@ function createExpiredIcon() {
|
|
|
3733
3731
|
return createAlertTriangleIcon('sv-expired-icon');
|
|
3734
3732
|
}
|
|
3735
3733
|
/**
|
|
3736
|
-
* Method icons
|
|
3734
|
+
* Method icons. Every `MethodMetadata.icon` value in the registry must have a
|
|
3735
|
+
* case here. The returned glyph is tagged with `data-sv-method-icon` so a
|
|
3736
|
+
* mismatch is visible in the DOM (and assertable in tests) instead of a wrong
|
|
3737
|
+
* glyph silently standing in for the method.
|
|
3737
3738
|
*/
|
|
3738
3739
|
function createMethodIcon(iconName) {
|
|
3740
|
+
const svg = methodIconGlyph(iconName);
|
|
3741
|
+
svg.setAttribute('data-sv-method-icon', iconName);
|
|
3742
|
+
return svg;
|
|
3743
|
+
}
|
|
3744
|
+
function methodIconGlyph(iconName) {
|
|
3739
3745
|
switch (iconName) {
|
|
3740
3746
|
case 'email':
|
|
3741
3747
|
return createEmailIcon();
|
|
3748
|
+
case 'sms':
|
|
3749
|
+
return createSmsIcon();
|
|
3742
3750
|
case 'phone':
|
|
3743
3751
|
return createPhoneIcon();
|
|
3744
3752
|
case 'fingerprint':
|
|
@@ -3762,7 +3770,9 @@ function createMethodIcon(iconName) {
|
|
|
3762
3770
|
case 'users':
|
|
3763
3771
|
return createUsersIcon();
|
|
3764
3772
|
default:
|
|
3765
|
-
|
|
3773
|
+
// Neutral placeholder — deliberately NOT the email envelope, so an
|
|
3774
|
+
// unmapped icon name surfaces the gap instead of impersonating email.
|
|
3775
|
+
return createGenericMethodIcon();
|
|
3766
3776
|
}
|
|
3767
3777
|
}
|
|
3768
3778
|
function createEmailIcon() {
|
|
@@ -3775,6 +3785,20 @@ function createEmailIcon() {
|
|
|
3775
3785
|
svg.appendChild(createPath('M18 5l-8 5.5L2 5'));
|
|
3776
3786
|
return svg;
|
|
3777
3787
|
}
|
|
3788
|
+
function createSmsIcon() {
|
|
3789
|
+
// Chat bubble — the text-message channel, distinct from the voice-call
|
|
3790
|
+
// handset (createPhoneIcon) so SMS and voice OTP read differently.
|
|
3791
|
+
const svg = createSvgElement('0 0 20 20', 20, 20);
|
|
3792
|
+
svg.setAttribute('stroke', 'currentColor');
|
|
3793
|
+
svg.setAttribute('stroke-width', '1.5');
|
|
3794
|
+
svg.setAttribute('stroke-linecap', 'round');
|
|
3795
|
+
svg.setAttribute('stroke-linejoin', 'round');
|
|
3796
|
+
svg.appendChild(createPath('M4 3.75h12A1.75 1.75 0 0117.75 5.5v5A1.75 1.75 0 0116 12.25H8.5L5 15.25V12.25H4A1.75 1.75 0 012.25 10.5v-5A1.75 1.75 0 014 3.75z'));
|
|
3797
|
+
svg.appendChild(createCircle(7, 8, 0.75, { fill: 'currentColor', stroke: 'none' }));
|
|
3798
|
+
svg.appendChild(createCircle(10, 8, 0.75, { fill: 'currentColor', stroke: 'none' }));
|
|
3799
|
+
svg.appendChild(createCircle(13, 8, 0.75, { fill: 'currentColor', stroke: 'none' }));
|
|
3800
|
+
return svg;
|
|
3801
|
+
}
|
|
3778
3802
|
function createPhoneIcon() {
|
|
3779
3803
|
const svg = createSvgElement('0 0 20 20', 20, 20);
|
|
3780
3804
|
svg.setAttribute('stroke', 'currentColor');
|
|
@@ -3784,6 +3808,18 @@ function createPhoneIcon() {
|
|
|
3784
3808
|
svg.appendChild(createPath('M18 14v2.5a1.5 1.5 0 01-1.64 1.5 14.85 14.85 0 01-6.47-2.3 14.63 14.63 0 01-4.5-4.5A14.85 14.85 0 013.1 4.64 1.5 1.5 0 014.59 3H7.1a1.5 1.5 0 011.5 1.29 9.63 9.63 0 00.52 2.11 1.5 1.5 0 01-.34 1.58l-.95.95a12 12 0 004.5 4.5l.95-.95a1.5 1.5 0 011.58-.34 9.63 9.63 0 002.11.52A1.5 1.5 0 0118 14z'));
|
|
3785
3809
|
return svg;
|
|
3786
3810
|
}
|
|
3811
|
+
function createGenericMethodIcon() {
|
|
3812
|
+
// Neutral rounded badge with a center dot — a placeholder for an unmapped
|
|
3813
|
+
// icon name, deliberately unlike any real method glyph.
|
|
3814
|
+
const svg = createSvgElement('0 0 20 20', 20, 20);
|
|
3815
|
+
svg.setAttribute('stroke', 'currentColor');
|
|
3816
|
+
svg.setAttribute('stroke-width', '1.5');
|
|
3817
|
+
svg.setAttribute('stroke-linecap', 'round');
|
|
3818
|
+
svg.setAttribute('stroke-linejoin', 'round');
|
|
3819
|
+
svg.appendChild(createPath('M6 2.75h8A3.25 3.25 0 0117.25 6v8A3.25 3.25 0 0114 17.25H6A3.25 3.25 0 012.75 14V6A3.25 3.25 0 016 2.75z'));
|
|
3820
|
+
svg.appendChild(createCircle(10, 10, 1.25, { fill: 'currentColor', stroke: 'none' }));
|
|
3821
|
+
return svg;
|
|
3822
|
+
}
|
|
3787
3823
|
function createFingerprintIcon() {
|
|
3788
3824
|
const svg = createSvgElement('0 0 20 20', 20, 20);
|
|
3789
3825
|
svg.setAttribute('stroke', 'currentColor');
|
|
@@ -4575,7 +4611,8 @@ class MethodSelectView {
|
|
|
4575
4611
|
const link = document.createElement('button');
|
|
4576
4612
|
link.className = 'sv-back-link';
|
|
4577
4613
|
link.appendChild(createBackArrowIcon());
|
|
4578
|
-
|
|
4614
|
+
const label = this.props.identityType === 'phone' ? ' Change phone number' : ' Change email';
|
|
4615
|
+
link.appendChild(document.createTextNode(label));
|
|
4579
4616
|
link.addEventListener('click', this.boundHandleBack);
|
|
4580
4617
|
return link;
|
|
4581
4618
|
}
|
|
@@ -6243,18 +6280,44 @@ class IdentityRenderer {
|
|
|
6243
6280
|
this.passkeyHandler = new PasskeyHandler(api, this.verificationState);
|
|
6244
6281
|
this.otpHandler = new OtpHandler(api, this.verificationState);
|
|
6245
6282
|
this.sparkLinkHandler = new SparkLinkHandler(api, this.verificationState);
|
|
6246
|
-
//
|
|
6247
|
-
|
|
6248
|
-
this.verificationState.setIdentity(options.email, 'email');
|
|
6249
|
-
}
|
|
6250
|
-
else if (options.phone) {
|
|
6251
|
-
this.verificationState.setIdentity(options.phone, 'phone');
|
|
6252
|
-
}
|
|
6283
|
+
// Seed the identity being verified from the render options.
|
|
6284
|
+
this.applyInitialIdentity();
|
|
6253
6285
|
// Set auth context for OIDC/simple mode flows
|
|
6254
6286
|
if (options.authContext) {
|
|
6255
6287
|
this.verificationState.setAuthContext(options.authContext);
|
|
6256
6288
|
}
|
|
6257
6289
|
}
|
|
6290
|
+
/**
|
|
6291
|
+
* Seed the verification identity from the render options, deriving the
|
|
6292
|
+
* channel (email vs phone) from the value itself rather than trusting which
|
|
6293
|
+
* option field carried it. The hosted login forwards a simple-mode identity
|
|
6294
|
+
* hint — which may be a phone number — as `email`; keying off the value keeps
|
|
6295
|
+
* the method list AND the OTP delivery target aligned with the real channel
|
|
6296
|
+
* instead of falling back to the email methods. Normalizes to E.164 /
|
|
6297
|
+
* lowercased email so the code goes to the canonical identifier.
|
|
6298
|
+
*/
|
|
6299
|
+
applyInitialIdentity() {
|
|
6300
|
+
const explicitPhone = typeof this.options.phone === 'string' && this.options.phone.length > 0;
|
|
6301
|
+
const raw = explicitPhone ? this.options.phone : this.options.email;
|
|
6302
|
+
if (!raw)
|
|
6303
|
+
return;
|
|
6304
|
+
if (explicitPhone || looksLikePhone(raw)) {
|
|
6305
|
+
this.verificationState.setIdentity(validatePhone(raw) ?? raw, 'phone');
|
|
6306
|
+
}
|
|
6307
|
+
else {
|
|
6308
|
+
this.verificationState.setIdentity(validateEmail(raw) ?? raw, 'email');
|
|
6309
|
+
}
|
|
6310
|
+
}
|
|
6311
|
+
/**
|
|
6312
|
+
* True when the identifier is fixed by the flow and the person must prove
|
|
6313
|
+
* that exact identity — the invite / simple-redirect case. There is no
|
|
6314
|
+
* identifier-entry step to return to, so the picker must not offer a
|
|
6315
|
+
* "change identity" back link that would let them verify a different
|
|
6316
|
+
* identifier than the one they were invited as.
|
|
6317
|
+
*/
|
|
6318
|
+
isIdentityFixed() {
|
|
6319
|
+
return this.verificationState.authContext?.simpleMode !== undefined;
|
|
6320
|
+
}
|
|
6258
6321
|
/**
|
|
6259
6322
|
* Fire the host's onSuccess callback, swallowing any exception so a
|
|
6260
6323
|
* misbehaving host handler can't block the post-success redirect the
|
|
@@ -6634,9 +6697,15 @@ class IdentityRenderer {
|
|
|
6634
6697
|
case 'method-select':
|
|
6635
6698
|
return new MethodSelectView({
|
|
6636
6699
|
email: state.email,
|
|
6700
|
+
identityType: this.identityType,
|
|
6637
6701
|
methods: state.methods,
|
|
6638
6702
|
onSelectMethod: (method) => this.handleMethodSelect(method, true),
|
|
6639
|
-
|
|
6703
|
+
// Offer "change identity" only when the person can actually enter a
|
|
6704
|
+
// different identifier. An invite/simple-redirect fixes the identity,
|
|
6705
|
+
// so there is no identifier-input step to return to.
|
|
6706
|
+
onBack: state.email && !this.isIdentityFixed()
|
|
6707
|
+
? () => this.showIdentityInput()
|
|
6708
|
+
: undefined,
|
|
6640
6709
|
});
|
|
6641
6710
|
case 'otp-verify':
|
|
6642
6711
|
return new OtpVerifyView({
|