@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
|
@@ -33,6 +33,24 @@ export declare class IdentityRenderer {
|
|
|
33
33
|
private sparkLinkClaiming;
|
|
34
34
|
private sparkLinkRetryTimer;
|
|
35
35
|
constructor(container: Container, api: IdentityApi, options: VerifyOptions, callbacks: RendererCallbacks);
|
|
36
|
+
/**
|
|
37
|
+
* Seed the verification identity from the render options, deriving the
|
|
38
|
+
* channel (email vs phone) from the value itself rather than trusting which
|
|
39
|
+
* option field carried it. The hosted login forwards a simple-mode identity
|
|
40
|
+
* hint — which may be a phone number — as `email`; keying off the value keeps
|
|
41
|
+
* the method list AND the OTP delivery target aligned with the real channel
|
|
42
|
+
* instead of falling back to the email methods. Normalizes to E.164 /
|
|
43
|
+
* lowercased email so the code goes to the canonical identifier.
|
|
44
|
+
*/
|
|
45
|
+
private applyInitialIdentity;
|
|
46
|
+
/**
|
|
47
|
+
* True when the identifier is fixed by the flow and the person must prove
|
|
48
|
+
* that exact identity — the invite / simple-redirect case. There is no
|
|
49
|
+
* identifier-entry step to return to, so the picker must not offer a
|
|
50
|
+
* "change identity" back link that would let them verify a different
|
|
51
|
+
* identifier than the one they were invited as.
|
|
52
|
+
*/
|
|
53
|
+
private isIdentityFixed;
|
|
36
54
|
/**
|
|
37
55
|
* Fire the host's onSuccess callback, swallowing any exception so a
|
|
38
56
|
* misbehaving host handler can't block the post-success redirect the
|
|
@@ -34,6 +34,9 @@ export declare function createErrorIcon(): SVGSVGElement;
|
|
|
34
34
|
*/
|
|
35
35
|
export declare function createExpiredIcon(): SVGSVGElement;
|
|
36
36
|
/**
|
|
37
|
-
* Method icons
|
|
37
|
+
* Method icons. Every `MethodMetadata.icon` value in the registry must have a
|
|
38
|
+
* case here. The returned glyph is tagged with `data-sv-method-icon` so a
|
|
39
|
+
* mismatch is visible in the DOM (and assertable in tests) instead of a wrong
|
|
40
|
+
* glyph silently standing in for the method.
|
|
38
41
|
*/
|
|
39
42
|
export declare function createMethodIcon(iconName: string): SVGSVGElement;
|
|
@@ -4,9 +4,12 @@
|
|
|
4
4
|
* Displays available authentication methods for the user to choose from.
|
|
5
5
|
*/
|
|
6
6
|
import type { View } from './base';
|
|
7
|
+
import type { IdentityType } from './identity-input';
|
|
7
8
|
import type { MethodMetadata } from '../types';
|
|
8
9
|
export interface MethodSelectViewProps {
|
|
9
10
|
email?: string;
|
|
11
|
+
/** Channel of the identifier being verified — drives the back-link label. */
|
|
12
|
+
identityType?: IdentityType;
|
|
10
13
|
methods: MethodMetadata[];
|
|
11
14
|
onSelectMethod: (method: MethodMetadata) => void;
|
|
12
15
|
onBack?: () => void;
|
package/dist/sparkvault.cjs.js
CHANGED
|
@@ -1261,7 +1261,7 @@ const METHOD_REGISTRY = {
|
|
|
1261
1261
|
type: 'passkey',
|
|
1262
1262
|
name: 'Passkey',
|
|
1263
1263
|
description: 'Use biometrics or security key',
|
|
1264
|
-
icon: '
|
|
1264
|
+
icon: 'fingerprint',
|
|
1265
1265
|
},
|
|
1266
1266
|
sparklink: {
|
|
1267
1267
|
id: 'sparklink',
|
|
@@ -2487,13 +2487,6 @@ function getStyles(options) {
|
|
|
2487
2487
|
text-align: left;
|
|
2488
2488
|
padding: 15px 40px 15px 14px;
|
|
2489
2489
|
margin-bottom: 9px;
|
|
2490
|
-
/* Inset 2px on either side so the focus ring (drawn outside the
|
|
2491
|
-
border-box) has room to render without clipping against the
|
|
2492
|
-
dialog's container edges. width:auto pairs with this to prevent
|
|
2493
|
-
the row from forcing horizontal overflow. */
|
|
2494
|
-
margin-left: 2px;
|
|
2495
|
-
margin-right: 2px;
|
|
2496
|
-
width: calc(100% - 4px);
|
|
2497
2490
|
transition: background var(--sv-dur-fast) var(--sv-ease-standard), border-color var(--sv-dur-fast) var(--sv-ease-standard);
|
|
2498
2491
|
}
|
|
2499
2492
|
|
|
@@ -3450,6 +3443,11 @@ function getStyles(options) {
|
|
|
3450
3443
|
min-height: 0;
|
|
3451
3444
|
padding-left: 0;
|
|
3452
3445
|
padding-right: 0;
|
|
3446
|
+
/* The host page owns the scroll and the surrounding padding in bare
|
|
3447
|
+
mode, so this body never scrolls internally. Keep overflow visible
|
|
3448
|
+
so a focused control's ring paints into the host padding instead of
|
|
3449
|
+
being clipped flat against this edgeless body's sides. */
|
|
3450
|
+
overflow: visible;
|
|
3453
3451
|
}
|
|
3454
3452
|
|
|
3455
3453
|
/* ========================================
|
|
@@ -3737,12 +3735,22 @@ function createExpiredIcon() {
|
|
|
3737
3735
|
return createAlertTriangleIcon('sv-expired-icon');
|
|
3738
3736
|
}
|
|
3739
3737
|
/**
|
|
3740
|
-
* Method icons
|
|
3738
|
+
* Method icons. Every `MethodMetadata.icon` value in the registry must have a
|
|
3739
|
+
* case here. The returned glyph is tagged with `data-sv-method-icon` so a
|
|
3740
|
+
* mismatch is visible in the DOM (and assertable in tests) instead of a wrong
|
|
3741
|
+
* glyph silently standing in for the method.
|
|
3741
3742
|
*/
|
|
3742
3743
|
function createMethodIcon(iconName) {
|
|
3744
|
+
const svg = methodIconGlyph(iconName);
|
|
3745
|
+
svg.setAttribute('data-sv-method-icon', iconName);
|
|
3746
|
+
return svg;
|
|
3747
|
+
}
|
|
3748
|
+
function methodIconGlyph(iconName) {
|
|
3743
3749
|
switch (iconName) {
|
|
3744
3750
|
case 'email':
|
|
3745
3751
|
return createEmailIcon();
|
|
3752
|
+
case 'sms':
|
|
3753
|
+
return createSmsIcon();
|
|
3746
3754
|
case 'phone':
|
|
3747
3755
|
return createPhoneIcon();
|
|
3748
3756
|
case 'fingerprint':
|
|
@@ -3766,7 +3774,9 @@ function createMethodIcon(iconName) {
|
|
|
3766
3774
|
case 'users':
|
|
3767
3775
|
return createUsersIcon();
|
|
3768
3776
|
default:
|
|
3769
|
-
|
|
3777
|
+
// Neutral placeholder — deliberately NOT the email envelope, so an
|
|
3778
|
+
// unmapped icon name surfaces the gap instead of impersonating email.
|
|
3779
|
+
return createGenericMethodIcon();
|
|
3770
3780
|
}
|
|
3771
3781
|
}
|
|
3772
3782
|
function createEmailIcon() {
|
|
@@ -3779,6 +3789,20 @@ function createEmailIcon() {
|
|
|
3779
3789
|
svg.appendChild(createPath('M18 5l-8 5.5L2 5'));
|
|
3780
3790
|
return svg;
|
|
3781
3791
|
}
|
|
3792
|
+
function createSmsIcon() {
|
|
3793
|
+
// Chat bubble — the text-message channel, distinct from the voice-call
|
|
3794
|
+
// handset (createPhoneIcon) so SMS and voice OTP read differently.
|
|
3795
|
+
const svg = createSvgElement('0 0 20 20', 20, 20);
|
|
3796
|
+
svg.setAttribute('stroke', 'currentColor');
|
|
3797
|
+
svg.setAttribute('stroke-width', '1.5');
|
|
3798
|
+
svg.setAttribute('stroke-linecap', 'round');
|
|
3799
|
+
svg.setAttribute('stroke-linejoin', 'round');
|
|
3800
|
+
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'));
|
|
3801
|
+
svg.appendChild(createCircle(7, 8, 0.75, { fill: 'currentColor', stroke: 'none' }));
|
|
3802
|
+
svg.appendChild(createCircle(10, 8, 0.75, { fill: 'currentColor', stroke: 'none' }));
|
|
3803
|
+
svg.appendChild(createCircle(13, 8, 0.75, { fill: 'currentColor', stroke: 'none' }));
|
|
3804
|
+
return svg;
|
|
3805
|
+
}
|
|
3782
3806
|
function createPhoneIcon() {
|
|
3783
3807
|
const svg = createSvgElement('0 0 20 20', 20, 20);
|
|
3784
3808
|
svg.setAttribute('stroke', 'currentColor');
|
|
@@ -3788,6 +3812,18 @@ function createPhoneIcon() {
|
|
|
3788
3812
|
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'));
|
|
3789
3813
|
return svg;
|
|
3790
3814
|
}
|
|
3815
|
+
function createGenericMethodIcon() {
|
|
3816
|
+
// Neutral rounded badge with a center dot — a placeholder for an unmapped
|
|
3817
|
+
// icon name, deliberately unlike any real method glyph.
|
|
3818
|
+
const svg = createSvgElement('0 0 20 20', 20, 20);
|
|
3819
|
+
svg.setAttribute('stroke', 'currentColor');
|
|
3820
|
+
svg.setAttribute('stroke-width', '1.5');
|
|
3821
|
+
svg.setAttribute('stroke-linecap', 'round');
|
|
3822
|
+
svg.setAttribute('stroke-linejoin', 'round');
|
|
3823
|
+
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'));
|
|
3824
|
+
svg.appendChild(createCircle(10, 10, 1.25, { fill: 'currentColor', stroke: 'none' }));
|
|
3825
|
+
return svg;
|
|
3826
|
+
}
|
|
3791
3827
|
function createFingerprintIcon() {
|
|
3792
3828
|
const svg = createSvgElement('0 0 20 20', 20, 20);
|
|
3793
3829
|
svg.setAttribute('stroke', 'currentColor');
|
|
@@ -4579,7 +4615,8 @@ class MethodSelectView {
|
|
|
4579
4615
|
const link = document.createElement('button');
|
|
4580
4616
|
link.className = 'sv-back-link';
|
|
4581
4617
|
link.appendChild(createBackArrowIcon());
|
|
4582
|
-
|
|
4618
|
+
const label = this.props.identityType === 'phone' ? ' Change phone number' : ' Change email';
|
|
4619
|
+
link.appendChild(document.createTextNode(label));
|
|
4583
4620
|
link.addEventListener('click', this.boundHandleBack);
|
|
4584
4621
|
return link;
|
|
4585
4622
|
}
|
|
@@ -6247,18 +6284,44 @@ class IdentityRenderer {
|
|
|
6247
6284
|
this.passkeyHandler = new PasskeyHandler(api, this.verificationState);
|
|
6248
6285
|
this.otpHandler = new OtpHandler(api, this.verificationState);
|
|
6249
6286
|
this.sparkLinkHandler = new SparkLinkHandler(api, this.verificationState);
|
|
6250
|
-
//
|
|
6251
|
-
|
|
6252
|
-
this.verificationState.setIdentity(options.email, 'email');
|
|
6253
|
-
}
|
|
6254
|
-
else if (options.phone) {
|
|
6255
|
-
this.verificationState.setIdentity(options.phone, 'phone');
|
|
6256
|
-
}
|
|
6287
|
+
// Seed the identity being verified from the render options.
|
|
6288
|
+
this.applyInitialIdentity();
|
|
6257
6289
|
// Set auth context for OIDC/simple mode flows
|
|
6258
6290
|
if (options.authContext) {
|
|
6259
6291
|
this.verificationState.setAuthContext(options.authContext);
|
|
6260
6292
|
}
|
|
6261
6293
|
}
|
|
6294
|
+
/**
|
|
6295
|
+
* Seed the verification identity from the render options, deriving the
|
|
6296
|
+
* channel (email vs phone) from the value itself rather than trusting which
|
|
6297
|
+
* option field carried it. The hosted login forwards a simple-mode identity
|
|
6298
|
+
* hint — which may be a phone number — as `email`; keying off the value keeps
|
|
6299
|
+
* the method list AND the OTP delivery target aligned with the real channel
|
|
6300
|
+
* instead of falling back to the email methods. Normalizes to E.164 /
|
|
6301
|
+
* lowercased email so the code goes to the canonical identifier.
|
|
6302
|
+
*/
|
|
6303
|
+
applyInitialIdentity() {
|
|
6304
|
+
const explicitPhone = typeof this.options.phone === 'string' && this.options.phone.length > 0;
|
|
6305
|
+
const raw = explicitPhone ? this.options.phone : this.options.email;
|
|
6306
|
+
if (!raw)
|
|
6307
|
+
return;
|
|
6308
|
+
if (explicitPhone || looksLikePhone(raw)) {
|
|
6309
|
+
this.verificationState.setIdentity(validatePhone(raw) ?? raw, 'phone');
|
|
6310
|
+
}
|
|
6311
|
+
else {
|
|
6312
|
+
this.verificationState.setIdentity(validateEmail(raw) ?? raw, 'email');
|
|
6313
|
+
}
|
|
6314
|
+
}
|
|
6315
|
+
/**
|
|
6316
|
+
* True when the identifier is fixed by the flow and the person must prove
|
|
6317
|
+
* that exact identity — the invite / simple-redirect case. There is no
|
|
6318
|
+
* identifier-entry step to return to, so the picker must not offer a
|
|
6319
|
+
* "change identity" back link that would let them verify a different
|
|
6320
|
+
* identifier than the one they were invited as.
|
|
6321
|
+
*/
|
|
6322
|
+
isIdentityFixed() {
|
|
6323
|
+
return this.verificationState.authContext?.simpleMode !== undefined;
|
|
6324
|
+
}
|
|
6262
6325
|
/**
|
|
6263
6326
|
* Fire the host's onSuccess callback, swallowing any exception so a
|
|
6264
6327
|
* misbehaving host handler can't block the post-success redirect the
|
|
@@ -6638,9 +6701,15 @@ class IdentityRenderer {
|
|
|
6638
6701
|
case 'method-select':
|
|
6639
6702
|
return new MethodSelectView({
|
|
6640
6703
|
email: state.email,
|
|
6704
|
+
identityType: this.identityType,
|
|
6641
6705
|
methods: state.methods,
|
|
6642
6706
|
onSelectMethod: (method) => this.handleMethodSelect(method, true),
|
|
6643
|
-
|
|
6707
|
+
// Offer "change identity" only when the person can actually enter a
|
|
6708
|
+
// different identifier. An invite/simple-redirect fixes the identity,
|
|
6709
|
+
// so there is no identifier-input step to return to.
|
|
6710
|
+
onBack: state.email && !this.isIdentityFixed()
|
|
6711
|
+
? () => this.showIdentityInput()
|
|
6712
|
+
: undefined,
|
|
6644
6713
|
});
|
|
6645
6714
|
case 'otp-verify':
|
|
6646
6715
|
return new OtpVerifyView({
|