@sparkvault/sdk-js 8.6.1 → 8.8.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/index.d.ts +97 -14
- package/dist/products/identity/api.d.ts +9 -1
- package/dist/products/identity/dialog-launcher.d.ts +0 -1
- package/dist/products/identity/index.d.ts +76 -14
- package/dist/products/identity/styles.d.ts +5 -5
- package/dist/products/identity/types.d.ts +30 -0
- package/dist/products/identity/utils.d.ts +33 -0
- package/dist/products/identity/views/icons.d.ts +7 -6
- package/dist/sparkvault.cjs.js +527 -233
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +527 -233
- 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.cjs.js
CHANGED
|
@@ -778,6 +778,91 @@ function generateState() {
|
|
|
778
778
|
crypto.getRandomValues(array);
|
|
779
779
|
return Array.from(array, (b) => b.toString(16).padStart(2, '0')).join('');
|
|
780
780
|
}
|
|
781
|
+
/**
|
|
782
|
+
* Generate a PKCE code_verifier (RFC 7636): 32 random bytes, base64url —
|
|
783
|
+
* 43 URL-safe characters.
|
|
784
|
+
*/
|
|
785
|
+
function generateCodeVerifier() {
|
|
786
|
+
const array = new Uint8Array(32);
|
|
787
|
+
crypto.getRandomValues(array);
|
|
788
|
+
return base64urlEncode(array);
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* Compute the S256 PKCE code_challenge for a verifier:
|
|
792
|
+
* base64url(SHA-256(verifier)).
|
|
793
|
+
*/
|
|
794
|
+
async function computeS256Challenge(codeVerifier) {
|
|
795
|
+
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(codeVerifier));
|
|
796
|
+
return arrayBufferToBase64url(digest);
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* Build the sign-in page URL on the Identity origin. Single source for BOTH
|
|
800
|
+
* delivery modes: the popup (opener + postMessage) and the same-tab redirect
|
|
801
|
+
* (redirect_uri + state + code_challenge → one-time code in the fragment).
|
|
802
|
+
*/
|
|
803
|
+
function buildSigninUrl(config, options, extras) {
|
|
804
|
+
const params = new URLSearchParams({ origin: window.location.origin });
|
|
805
|
+
// Identifier prefill - the sign-in page collects it itself when absent.
|
|
806
|
+
if (options.email) {
|
|
807
|
+
params.set('email', options.email);
|
|
808
|
+
}
|
|
809
|
+
else if (options.phone) {
|
|
810
|
+
params.set('phone', options.phone);
|
|
811
|
+
}
|
|
812
|
+
// Auth context, in the query shape the sign-in page reads server-side:
|
|
813
|
+
// OIDC rides `auth_request`; simple redirect rides `mode=simple` + the
|
|
814
|
+
// opaque `session` (the page loads success/failure URLs from the session).
|
|
815
|
+
const authContext = options.authContext;
|
|
816
|
+
if (authContext?.authRequestId) {
|
|
817
|
+
params.set('auth_request', authContext.authRequestId);
|
|
818
|
+
}
|
|
819
|
+
else if (authContext?.simpleMode?.sessionId) {
|
|
820
|
+
params.set('mode', 'simple');
|
|
821
|
+
params.set('session', authContext.simpleMode.sessionId);
|
|
822
|
+
}
|
|
823
|
+
if (extras) {
|
|
824
|
+
params.set('redirect_uri', extras.redirectUri);
|
|
825
|
+
params.set('state', extras.state);
|
|
826
|
+
params.set('code_challenge', extras.codeChallenge);
|
|
827
|
+
}
|
|
828
|
+
return `${config.identityBaseUrl}/${config.accountId}/signin?${params}`;
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Warm the connection to another origin by injecting `<link rel="preconnect">`
|
|
832
|
+
* hints (one plain for top-level navigations, one `crossorigin` for CORS
|
|
833
|
+
* fetches). The sign-in popup/redirect and every flow API call reuse the open
|
|
834
|
+
* connection, which removes the cold-connection stall mobile browsers hit on
|
|
835
|
+
* the first navigation to the Identity origin. No-op off-DOM, for the page's
|
|
836
|
+
* own origin, and when the hints already exist.
|
|
837
|
+
*/
|
|
838
|
+
function ensurePreconnect(baseUrl) {
|
|
839
|
+
if (typeof document === 'undefined' || typeof window === 'undefined' || !document.head) {
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
let origin;
|
|
843
|
+
try {
|
|
844
|
+
origin = new URL(baseUrl).origin;
|
|
845
|
+
}
|
|
846
|
+
catch {
|
|
847
|
+
return;
|
|
848
|
+
}
|
|
849
|
+
if (origin === window.location.origin) {
|
|
850
|
+
return;
|
|
851
|
+
}
|
|
852
|
+
for (const crossOrigin of [false, true]) {
|
|
853
|
+
const selector = `link[rel="preconnect"][href="${origin}"]${crossOrigin ? '[crossorigin]' : ':not([crossorigin])'}`;
|
|
854
|
+
if (document.head.querySelector(selector)) {
|
|
855
|
+
continue;
|
|
856
|
+
}
|
|
857
|
+
const link = document.createElement('link');
|
|
858
|
+
link.rel = 'preconnect';
|
|
859
|
+
link.href = origin;
|
|
860
|
+
if (crossOrigin) {
|
|
861
|
+
link.crossOrigin = 'anonymous';
|
|
862
|
+
}
|
|
863
|
+
document.head.appendChild(link);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
781
866
|
|
|
782
867
|
/**
|
|
783
868
|
* Identity API Client
|
|
@@ -863,6 +948,19 @@ class IdentityApi extends SparkVaultApi {
|
|
|
863
948
|
const body = identityType === 'phone' ? { phone: identity } : { email: identity };
|
|
864
949
|
return this.request('POST', '/passkey/check', body);
|
|
865
950
|
}
|
|
951
|
+
/**
|
|
952
|
+
* Redeem a one-time sign-in code (with its PKCE verifier) for the sign-in
|
|
953
|
+
* result — the shared return leg for `flow: 'redirect'` and the silent SSO
|
|
954
|
+
* self-heal. The code arrives in the URL fragment after the hosted page
|
|
955
|
+
* navigates back; it is single-use, 60s-lived, and bound to this page's
|
|
956
|
+
* origin server-side.
|
|
957
|
+
*/
|
|
958
|
+
async redeemHandoffCode(code, codeVerifier) {
|
|
959
|
+
return this.request('POST', '/signin/redeem', {
|
|
960
|
+
code,
|
|
961
|
+
code_verifier: codeVerifier,
|
|
962
|
+
});
|
|
963
|
+
}
|
|
866
964
|
/**
|
|
867
965
|
* Build auth context params for API requests (OIDC/simple mode).
|
|
868
966
|
* Converts AuthContext to snake_case params expected by backend.
|
|
@@ -1959,12 +2057,12 @@ class SparkLinkHandler {
|
|
|
1959
2057
|
/**
|
|
1960
2058
|
* Identity Modal Styles
|
|
1961
2059
|
*
|
|
1962
|
-
*
|
|
1963
|
-
* -
|
|
2060
|
+
* SparkVault design system, product register:
|
|
2061
|
+
* - Quiet slate neutrals; Action Blue carries all interactivity
|
|
1964
2062
|
* - 4px base spacing unit for consistency
|
|
1965
|
-
* -
|
|
1966
|
-
* -
|
|
1967
|
-
* -
|
|
2063
|
+
* - Hairline borders over shadows; shadows minimal and DS-weighted
|
|
2064
|
+
* - Restrained motion: 120-280ms, standard/decelerate curves only
|
|
2065
|
+
* - One accent per surface; tenant-tintable via --sv-primary
|
|
1968
2066
|
*/
|
|
1969
2067
|
const STYLE_ID$1 = 'sparkvault-identity-styles';
|
|
1970
2068
|
/**
|
|
@@ -2027,56 +2125,69 @@ function getStyles(options) {
|
|
|
2027
2125
|
// The brand accent is driven by the `--sv-primary` / `--sv-primary-hover`
|
|
2028
2126
|
// CSS custom properties so a host page (e.g. the SparkVault sign-in page) can
|
|
2029
2127
|
// tint the whole flow to the tenant's brand color by setting them on `:root`.
|
|
2030
|
-
// The literals are the fallback - when no host sets the variables the
|
|
2031
|
-
//
|
|
2032
|
-
// via color-mix so
|
|
2033
|
-
|
|
2128
|
+
// The literals are the fallback - when no host sets the variables the flow
|
|
2129
|
+
// renders in SparkVault Action Blue. The soft focus glow and the two-tone
|
|
2130
|
+
// focus ring are both derived from the same accent via color-mix so they
|
|
2131
|
+
// track the tenant tint too.
|
|
2132
|
+
const accent = 'var(--sv-primary, #216bde)';
|
|
2133
|
+
const surface = isDark ? '#030712' : '#ffffff';
|
|
2134
|
+
// Lightened accent for the outer ring of the two-tone focus indicator
|
|
2135
|
+
// (lands on the design system's #4383eb at the default accent).
|
|
2136
|
+
const focusRingColor = `color-mix(in srgb, ${accent} 80%, white)`;
|
|
2034
2137
|
const tokens = {
|
|
2035
2138
|
// Colors
|
|
2036
2139
|
primary: accent,
|
|
2037
|
-
primaryHover: 'var(--sv-primary-hover, #
|
|
2140
|
+
primaryHover: 'var(--sv-primary-hover, #0d5bcd)',
|
|
2038
2141
|
primaryLight: `color-mix(in srgb, ${accent} ${isDark ? '20%' : '9%'}, transparent)`,
|
|
2039
|
-
error: '#
|
|
2040
|
-
errorLight: isDark ? 'rgba(
|
|
2041
|
-
errorBorder: isDark ? 'rgba(
|
|
2142
|
+
error: isDark ? '#e6443d' : '#b02b27',
|
|
2143
|
+
errorLight: isDark ? 'rgba(230, 68, 61, 0.12)' : '#fee2e2',
|
|
2144
|
+
errorBorder: isDark ? 'rgba(230, 68, 61, 0.35)' : '#fecaca',
|
|
2145
|
+
// Filled danger buttons stay on the fixed danger tier (white label, AA in
|
|
2146
|
+
// both themes).
|
|
2147
|
+
danger: '#b02b27',
|
|
2148
|
+
dangerHover: '#9a221f',
|
|
2149
|
+
warningIcon: isDark ? '#e6ad00' : '#8a5600',
|
|
2042
2150
|
// Backgrounds
|
|
2043
|
-
bg:
|
|
2044
|
-
bgSubtle: isDark ? '
|
|
2045
|
-
bgHover: isDark ? '
|
|
2046
|
-
bgInput: isDark ? '
|
|
2151
|
+
bg: surface,
|
|
2152
|
+
bgSubtle: isDark ? 'rgba(255, 255, 255, 0.05)' : '#f8fafc',
|
|
2153
|
+
bgHover: isDark ? 'rgba(255, 255, 255, 0.08)' : '#f1f5f9',
|
|
2154
|
+
bgInput: isDark ? 'rgba(255, 255, 255, 0.04)' : '#ffffff',
|
|
2047
2155
|
// Borders
|
|
2048
|
-
border: isDark ? '
|
|
2049
|
-
borderHover: isDark ? '
|
|
2156
|
+
border: isDark ? 'rgba(255, 255, 255, 0.10)' : '#e2e8f0',
|
|
2157
|
+
borderHover: isDark ? 'rgba(255, 255, 255, 0.18)' : '#cbd5e1',
|
|
2050
2158
|
borderFocus: accent,
|
|
2159
|
+
chevron: isDark ? 'rgba(255, 255, 255, 0.35)' : '#cbd5e1',
|
|
2051
2160
|
// Text
|
|
2052
|
-
textPrimary: isDark ? '
|
|
2053
|
-
textSecondary: isDark ? '
|
|
2054
|
-
textMuted: isDark ? '
|
|
2055
|
-
textOnPrimary: '#
|
|
2056
|
-
//
|
|
2161
|
+
textPrimary: isDark ? 'rgba(255, 255, 255, 0.92)' : '#0f172a',
|
|
2162
|
+
textSecondary: isDark ? 'rgba(255, 255, 255, 0.62)' : '#475569',
|
|
2163
|
+
textMuted: isDark ? 'rgba(255, 255, 255, 0.45)' : '#64748b',
|
|
2164
|
+
textOnPrimary: '#ffffff',
|
|
2165
|
+
// Focus — two-tone ring: inner surface gap + accent-derived outer ring.
|
|
2166
|
+
focusRing: `0 0 0 2px ${surface}, 0 0 0 4px ${focusRingColor}`,
|
|
2167
|
+
// Shadows — DS-weight: lean on hairlines, keep elevation subtle.
|
|
2057
2168
|
shadowSm: isDark
|
|
2058
2169
|
? '0 1px 2px rgba(0, 0, 0, 0.4)'
|
|
2059
|
-
: '0 1px 2px rgba(0, 0, 0, 0.
|
|
2170
|
+
: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
|
|
2060
2171
|
shadowLg: isDark
|
|
2061
|
-
? '0 8px 24px rgba(0, 0, 0, 0.
|
|
2062
|
-
: '0 8px 24px rgba(
|
|
2172
|
+
? '0 8px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.10)'
|
|
2173
|
+
: '0 8px 24px rgba(15, 23, 42, 0.12)',
|
|
2063
2174
|
};
|
|
2064
2175
|
return `
|
|
2065
2176
|
/* ========================================
|
|
2066
2177
|
MOTION SYSTEM — shared duration/easing tokens so every transition in
|
|
2067
|
-
the flow is consistent.
|
|
2068
|
-
|
|
2178
|
+
the flow is consistent. 120/180/280ms tiers; standard and decelerate
|
|
2179
|
+
curves only, never overshoot.
|
|
2069
2180
|
======================================== */
|
|
2070
2181
|
:root {
|
|
2071
|
-
--sv-dur-instant:
|
|
2072
|
-
--sv-dur-fast:
|
|
2073
|
-
--sv-dur-base:
|
|
2074
|
-
--sv-dur-slow:
|
|
2075
|
-
--sv-dur-slower:
|
|
2182
|
+
--sv-dur-instant: 120ms;
|
|
2183
|
+
--sv-dur-fast: 120ms;
|
|
2184
|
+
--sv-dur-base: 180ms;
|
|
2185
|
+
--sv-dur-slow: 280ms;
|
|
2186
|
+
--sv-dur-slower: 280ms;
|
|
2076
2187
|
--sv-ease-standard: cubic-bezier(0.2, 0, 0, 1);
|
|
2077
|
-
--sv-ease-out: cubic-bezier(0
|
|
2078
|
-
--sv-ease-accelerate: cubic-bezier(0.
|
|
2079
|
-
--sv-ease-spring: cubic-bezier(0.
|
|
2188
|
+
--sv-ease-out: cubic-bezier(0, 0, 0.2, 1);
|
|
2189
|
+
--sv-ease-accelerate: cubic-bezier(0.2, 0, 0, 1);
|
|
2190
|
+
--sv-ease-spring: cubic-bezier(0.2, 0, 0, 1);
|
|
2080
2191
|
}
|
|
2081
2192
|
|
|
2082
2193
|
/* Each mounted view enters with a calm fade + rise. Applied by the renderer
|
|
@@ -2101,7 +2212,7 @@ function getStyles(options) {
|
|
|
2101
2212
|
.sv-overlay {
|
|
2102
2213
|
position: fixed;
|
|
2103
2214
|
inset: 0;
|
|
2104
|
-
background: rgba(0, 0, 0,
|
|
2215
|
+
background: ${isDark ? 'rgba(0, 0, 0, 0.7)' : 'rgba(15, 23, 42, 0.6)'};
|
|
2105
2216
|
display: flex;
|
|
2106
2217
|
align-items: center;
|
|
2107
2218
|
justify-content: center;
|
|
@@ -2120,7 +2231,7 @@ function getStyles(options) {
|
|
|
2120
2231
|
|
|
2121
2232
|
.sv-modal {
|
|
2122
2233
|
background: ${tokens.bg};
|
|
2123
|
-
border-radius:
|
|
2234
|
+
border-radius: 12px;
|
|
2124
2235
|
box-shadow: ${tokens.shadowLg};
|
|
2125
2236
|
width: 100%;
|
|
2126
2237
|
max-width: 400px;
|
|
@@ -2141,7 +2252,7 @@ function getStyles(options) {
|
|
|
2141
2252
|
padding: 14px 20px;
|
|
2142
2253
|
border-bottom: 1px solid ${tokens.border};
|
|
2143
2254
|
background: ${tokens.bg};
|
|
2144
|
-
border-radius:
|
|
2255
|
+
border-radius: 12px 12px 0 0;
|
|
2145
2256
|
flex-shrink: 0;
|
|
2146
2257
|
}
|
|
2147
2258
|
|
|
@@ -2179,10 +2290,10 @@ function getStyles(options) {
|
|
|
2179
2290
|
justify-content: center;
|
|
2180
2291
|
background: ${tokens.bgSubtle};
|
|
2181
2292
|
border: none;
|
|
2182
|
-
border-radius:
|
|
2293
|
+
border-radius: 6px;
|
|
2183
2294
|
cursor: pointer;
|
|
2184
2295
|
color: ${tokens.textSecondary};
|
|
2185
|
-
transition: background
|
|
2296
|
+
transition: background var(--sv-dur-fast) var(--sv-ease-standard), color var(--sv-dur-fast) var(--sv-ease-standard);
|
|
2186
2297
|
}
|
|
2187
2298
|
|
|
2188
2299
|
.sv-close-btn:hover {
|
|
@@ -2191,12 +2302,8 @@ function getStyles(options) {
|
|
|
2191
2302
|
}
|
|
2192
2303
|
|
|
2193
2304
|
.sv-close-btn:focus-visible {
|
|
2194
|
-
outline:
|
|
2195
|
-
|
|
2196
|
-
}
|
|
2197
|
-
|
|
2198
|
-
.sv-close-btn:active {
|
|
2199
|
-
transform: scale(0.96);
|
|
2305
|
+
outline: none;
|
|
2306
|
+
box-shadow: ${tokens.focusRing};
|
|
2200
2307
|
}
|
|
2201
2308
|
|
|
2202
2309
|
/* ========================================
|
|
@@ -2216,10 +2323,10 @@ function getStyles(options) {
|
|
|
2216
2323
|
.sv-title {
|
|
2217
2324
|
font-size: 21px;
|
|
2218
2325
|
font-weight: 600;
|
|
2219
|
-
letter-spacing: -0.
|
|
2326
|
+
letter-spacing: -0.02em;
|
|
2220
2327
|
line-height: 1.22;
|
|
2221
2328
|
margin: 0 0 7px 0;
|
|
2222
|
-
text-align:
|
|
2329
|
+
text-align: left;
|
|
2223
2330
|
color: ${tokens.textPrimary};
|
|
2224
2331
|
}
|
|
2225
2332
|
|
|
@@ -2229,10 +2336,17 @@ function getStyles(options) {
|
|
|
2229
2336
|
line-height: 1.5;
|
|
2230
2337
|
color: ${tokens.textSecondary};
|
|
2231
2338
|
margin: 0 0 16px 0;
|
|
2232
|
-
text-align:
|
|
2339
|
+
text-align: left;
|
|
2233
2340
|
text-wrap: balance;
|
|
2234
2341
|
}
|
|
2235
2342
|
|
|
2343
|
+
/* Icon-led ceremony screens (passkey set-up / sign-in) are a fully
|
|
2344
|
+
centered composition: the headline and subtitle follow the glyph. */
|
|
2345
|
+
div:has(> .sv-passkey-icon) ~ .sv-title,
|
|
2346
|
+
div:has(> .sv-passkey-icon) ~ .sv-subtitle {
|
|
2347
|
+
text-align: center;
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2236
2350
|
.sv-subtitle strong {
|
|
2237
2351
|
color: ${tokens.textPrimary};
|
|
2238
2352
|
font-weight: 500;
|
|
@@ -2261,12 +2375,12 @@ function getStyles(options) {
|
|
|
2261
2375
|
font-size: 15px;
|
|
2262
2376
|
font-weight: 400;
|
|
2263
2377
|
line-height: 1.4;
|
|
2264
|
-
border: 1px solid ${tokens.
|
|
2265
|
-
border-radius:
|
|
2378
|
+
border: 1px solid ${tokens.border};
|
|
2379
|
+
border-radius: 8px;
|
|
2266
2380
|
background: ${tokens.bgInput};
|
|
2267
2381
|
color: ${tokens.textPrimary};
|
|
2268
2382
|
box-sizing: border-box;
|
|
2269
|
-
box-shadow:
|
|
2383
|
+
box-shadow: ${tokens.shadowSm};
|
|
2270
2384
|
transition: border-color var(--sv-dur-fast) var(--sv-ease-standard), box-shadow var(--sv-dur-fast) var(--sv-ease-standard);
|
|
2271
2385
|
}
|
|
2272
2386
|
|
|
@@ -2296,7 +2410,7 @@ function getStyles(options) {
|
|
|
2296
2410
|
|
|
2297
2411
|
.sv-input.sv-input-error:focus,
|
|
2298
2412
|
.sv-input.sv-email-input-error:focus {
|
|
2299
|
-
box-shadow: 0 0 0 3px
|
|
2413
|
+
box-shadow: 0 0 0 3px ${tokens.errorLight};
|
|
2300
2414
|
}
|
|
2301
2415
|
|
|
2302
2416
|
/* ========================================
|
|
@@ -2315,15 +2429,15 @@ function getStyles(options) {
|
|
|
2315
2429
|
letter-spacing: -0.006em;
|
|
2316
2430
|
line-height: 1.35;
|
|
2317
2431
|
border: none;
|
|
2318
|
-
border-radius:
|
|
2432
|
+
border-radius: 8px;
|
|
2319
2433
|
cursor: pointer;
|
|
2320
|
-
transition: background var(--sv-dur-fast) var(--sv-ease-standard),
|
|
2434
|
+
transition: background var(--sv-dur-fast) var(--sv-ease-standard), box-shadow var(--sv-dur-fast) var(--sv-ease-standard);
|
|
2321
2435
|
box-sizing: border-box;
|
|
2322
2436
|
}
|
|
2323
2437
|
|
|
2324
2438
|
.sv-btn:focus-visible {
|
|
2325
|
-
outline:
|
|
2326
|
-
|
|
2439
|
+
outline: none;
|
|
2440
|
+
box-shadow: ${tokens.focusRing};
|
|
2327
2441
|
}
|
|
2328
2442
|
|
|
2329
2443
|
.sv-btn:disabled {
|
|
@@ -2331,8 +2445,9 @@ function getStyles(options) {
|
|
|
2331
2445
|
cursor: not-allowed;
|
|
2332
2446
|
}
|
|
2333
2447
|
|
|
2448
|
+
/* Press = visual compression via an inset shadow, never scale. */
|
|
2334
2449
|
.sv-btn:active:not(:disabled) {
|
|
2335
|
-
|
|
2450
|
+
box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.2);
|
|
2336
2451
|
}
|
|
2337
2452
|
|
|
2338
2453
|
/* Primary Button */
|
|
@@ -2348,7 +2463,7 @@ function getStyles(options) {
|
|
|
2348
2463
|
background: ${tokens.primaryHover};
|
|
2349
2464
|
}
|
|
2350
2465
|
|
|
2351
|
-
/* Secondary Button */
|
|
2466
|
+
/* Secondary Button — quiet: subtle fill, hairline border */
|
|
2352
2467
|
.sv-btn-secondary {
|
|
2353
2468
|
background: ${tokens.bgSubtle};
|
|
2354
2469
|
color: ${tokens.textPrimary};
|
|
@@ -2360,25 +2475,26 @@ function getStyles(options) {
|
|
|
2360
2475
|
border-color: ${tokens.borderHover};
|
|
2361
2476
|
}
|
|
2362
2477
|
|
|
2363
|
-
/* Method Button — a full-width row
|
|
2364
|
-
|
|
2478
|
+
/* Method Button — a full-width row with a nudging chevron affordance
|
|
2479
|
+
(added via ::after so no DOM change is needed). The card itself stays
|
|
2480
|
+
planted: hover is a quiet fill + border shift, no translate. */
|
|
2365
2481
|
.sv-btn-method {
|
|
2366
2482
|
position: relative;
|
|
2367
2483
|
background: ${tokens.bg};
|
|
2368
|
-
border: 1px solid ${tokens.
|
|
2369
|
-
border-radius:
|
|
2484
|
+
border: 1px solid ${tokens.border};
|
|
2485
|
+
border-radius: 10px;
|
|
2370
2486
|
color: ${tokens.textPrimary};
|
|
2371
2487
|
text-align: left;
|
|
2372
2488
|
padding: 15px 40px 15px 14px;
|
|
2373
2489
|
margin-bottom: 9px;
|
|
2374
|
-
/* Inset 2px on either side so the focus
|
|
2490
|
+
/* Inset 2px on either side so the focus ring (drawn outside the
|
|
2375
2491
|
border-box) has room to render without clipping against the
|
|
2376
2492
|
dialog's container edges. width:auto pairs with this to prevent
|
|
2377
2493
|
the row from forcing horizontal overflow. */
|
|
2378
2494
|
margin-left: 2px;
|
|
2379
2495
|
margin-right: 2px;
|
|
2380
2496
|
width: calc(100% - 4px);
|
|
2381
|
-
transition:
|
|
2497
|
+
transition: background var(--sv-dur-fast) var(--sv-ease-standard), border-color var(--sv-dur-fast) var(--sv-ease-standard);
|
|
2382
2498
|
}
|
|
2383
2499
|
|
|
2384
2500
|
.sv-btn-method::after {
|
|
@@ -2388,29 +2504,25 @@ function getStyles(options) {
|
|
|
2388
2504
|
top: 50%;
|
|
2389
2505
|
width: 8px;
|
|
2390
2506
|
height: 8px;
|
|
2391
|
-
border-right: 1.6px solid ${tokens.
|
|
2392
|
-
border-top: 1.6px solid ${tokens.
|
|
2507
|
+
border-right: 1.6px solid ${tokens.chevron};
|
|
2508
|
+
border-top: 1.6px solid ${tokens.chevron};
|
|
2393
2509
|
transform: translateY(-50%) rotate(45deg);
|
|
2394
2510
|
transition: transform var(--sv-dur-base) var(--sv-ease-out), border-color var(--sv-dur-fast) var(--sv-ease-standard);
|
|
2395
2511
|
}
|
|
2396
2512
|
|
|
2397
2513
|
.sv-btn-method:hover:not(:disabled)::after {
|
|
2398
2514
|
transform: translateY(-50%) translateX(3px) rotate(45deg);
|
|
2399
|
-
border-color: ${tokens.
|
|
2515
|
+
border-color: ${tokens.primary};
|
|
2400
2516
|
}
|
|
2401
2517
|
|
|
2402
|
-
/* The shared .sv-btn focus rule sets outline-offset:2px which sits
|
|
2403
|
-
outside the row's edges and gets clipped by the parent. Method
|
|
2404
|
-
rows are full-width by design, so render the focus indicator
|
|
2405
|
-
flush against the border instead. */
|
|
2406
2518
|
.sv-btn-method:focus-visible {
|
|
2407
|
-
outline
|
|
2519
|
+
outline: none;
|
|
2520
|
+
box-shadow: ${tokens.focusRing};
|
|
2408
2521
|
}
|
|
2409
2522
|
|
|
2410
2523
|
.sv-btn-method:hover:not(:disabled) {
|
|
2411
2524
|
background: ${tokens.bgSubtle};
|
|
2412
|
-
border-color: ${tokens.
|
|
2413
|
-
transform: translateY(-2px);
|
|
2525
|
+
border-color: ${tokens.borderHover};
|
|
2414
2526
|
}
|
|
2415
2527
|
|
|
2416
2528
|
.sv-btn-method:last-child {
|
|
@@ -2419,13 +2531,13 @@ function getStyles(options) {
|
|
|
2419
2531
|
|
|
2420
2532
|
/* Error Buttons */
|
|
2421
2533
|
.sv-btn-error-primary {
|
|
2422
|
-
background: ${tokens.
|
|
2534
|
+
background: ${tokens.danger};
|
|
2423
2535
|
color: ${tokens.textOnPrimary};
|
|
2424
2536
|
box-shadow: ${tokens.shadowSm};
|
|
2425
2537
|
}
|
|
2426
2538
|
|
|
2427
2539
|
.sv-btn-error-primary:hover:not(:disabled) {
|
|
2428
|
-
background:
|
|
2540
|
+
background: ${tokens.dangerHover};
|
|
2429
2541
|
}
|
|
2430
2542
|
|
|
2431
2543
|
.sv-btn-error-secondary {
|
|
@@ -2450,26 +2562,26 @@ function getStyles(options) {
|
|
|
2450
2562
|
width: 100%;
|
|
2451
2563
|
}
|
|
2452
2564
|
|
|
2565
|
+
/* Bare glyph slot — no container chrome. Quiet slate stroke that takes
|
|
2566
|
+
the accent on row hover. */
|
|
2453
2567
|
.sv-method-icon {
|
|
2454
|
-
width:
|
|
2455
|
-
height:
|
|
2568
|
+
width: 20px;
|
|
2569
|
+
height: 20px;
|
|
2456
2570
|
flex-shrink: 0;
|
|
2457
2571
|
display: flex;
|
|
2458
2572
|
align-items: center;
|
|
2459
2573
|
justify-content: center;
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
color: ${tokens.textSecondary};
|
|
2463
|
-
transition: background var(--sv-dur-fast) var(--sv-ease-standard);
|
|
2574
|
+
color: ${tokens.textMuted};
|
|
2575
|
+
transition: color var(--sv-dur-fast) var(--sv-ease-standard);
|
|
2464
2576
|
}
|
|
2465
2577
|
|
|
2466
2578
|
.sv-btn-method:hover:not(:disabled) .sv-method-icon {
|
|
2467
|
-
|
|
2579
|
+
color: ${tokens.primary};
|
|
2468
2580
|
}
|
|
2469
2581
|
|
|
2470
2582
|
.sv-method-icon svg {
|
|
2471
|
-
width:
|
|
2472
|
-
height:
|
|
2583
|
+
width: 20px;
|
|
2584
|
+
height: 20px;
|
|
2473
2585
|
}
|
|
2474
2586
|
|
|
2475
2587
|
.sv-method-text {
|
|
@@ -2478,13 +2590,13 @@ function getStyles(options) {
|
|
|
2478
2590
|
}
|
|
2479
2591
|
|
|
2480
2592
|
.sv-method-name {
|
|
2481
|
-
font-weight:
|
|
2482
|
-
font-size:
|
|
2593
|
+
font-weight: 600;
|
|
2594
|
+
font-size: 15px;
|
|
2483
2595
|
color: ${tokens.textPrimary};
|
|
2484
2596
|
}
|
|
2485
2597
|
|
|
2486
2598
|
.sv-method-description {
|
|
2487
|
-
font-size:
|
|
2599
|
+
font-size: 13px;
|
|
2488
2600
|
color: ${tokens.textMuted};
|
|
2489
2601
|
margin-top: 1px;
|
|
2490
2602
|
}
|
|
@@ -2509,12 +2621,12 @@ function getStyles(options) {
|
|
|
2509
2621
|
letter-spacing: 0;
|
|
2510
2622
|
font-variant-numeric: tabular-nums;
|
|
2511
2623
|
caret-color: transparent;
|
|
2512
|
-
border: 1px solid ${tokens.
|
|
2513
|
-
border-radius:
|
|
2624
|
+
border: 1px solid ${tokens.border};
|
|
2625
|
+
border-radius: 8px;
|
|
2514
2626
|
background: ${tokens.bgInput};
|
|
2515
2627
|
color: ${tokens.textPrimary};
|
|
2516
2628
|
box-sizing: border-box;
|
|
2517
|
-
transition: border-color var(--sv-dur-fast) var(--sv-ease-standard), box-shadow var(--sv-dur-fast) var(--sv-ease-standard)
|
|
2629
|
+
transition: border-color var(--sv-dur-fast) var(--sv-ease-standard), box-shadow var(--sv-dur-fast) var(--sv-ease-standard);
|
|
2518
2630
|
}
|
|
2519
2631
|
|
|
2520
2632
|
.sv-otp-digit:hover:not(:focus):not(:disabled) {
|
|
@@ -2525,7 +2637,6 @@ function getStyles(options) {
|
|
|
2525
2637
|
outline: none;
|
|
2526
2638
|
border-color: ${tokens.borderFocus};
|
|
2527
2639
|
box-shadow: 0 0 0 3px ${tokens.primaryLight};
|
|
2528
|
-
transform: translateY(-2px);
|
|
2529
2640
|
}
|
|
2530
2641
|
|
|
2531
2642
|
.sv-otp-digit:disabled {
|
|
@@ -2550,7 +2661,7 @@ function getStyles(options) {
|
|
|
2550
2661
|
border: none;
|
|
2551
2662
|
padding: 0;
|
|
2552
2663
|
margin-bottom: 16px;
|
|
2553
|
-
transition: color
|
|
2664
|
+
transition: color var(--sv-dur-fast) var(--sv-ease-standard);
|
|
2554
2665
|
}
|
|
2555
2666
|
|
|
2556
2667
|
.sv-back-link:hover:not(:disabled) {
|
|
@@ -2578,7 +2689,7 @@ function getStyles(options) {
|
|
|
2578
2689
|
padding: 10px 12px;
|
|
2579
2690
|
border-radius: 8px;
|
|
2580
2691
|
font-size: 13px;
|
|
2581
|
-
font-weight:
|
|
2692
|
+
font-weight: 500;
|
|
2582
2693
|
margin-bottom: 16px;
|
|
2583
2694
|
}
|
|
2584
2695
|
|
|
@@ -2634,7 +2745,7 @@ function getStyles(options) {
|
|
|
2634
2745
|
color: ${tokens.textSecondary};
|
|
2635
2746
|
text-decoration: none;
|
|
2636
2747
|
font-weight: 500;
|
|
2637
|
-
transition: color
|
|
2748
|
+
transition: color var(--sv-dur-fast) var(--sv-ease-standard);
|
|
2638
2749
|
}
|
|
2639
2750
|
|
|
2640
2751
|
.sv-footer-link:hover {
|
|
@@ -2694,7 +2805,7 @@ function getStyles(options) {
|
|
|
2694
2805
|
background: ${tokens.bgInput};
|
|
2695
2806
|
color: ${tokens.textPrimary};
|
|
2696
2807
|
box-sizing: border-box;
|
|
2697
|
-
transition: border-color
|
|
2808
|
+
transition: border-color var(--sv-dur-fast) var(--sv-ease-standard), box-shadow var(--sv-dur-fast) var(--sv-ease-standard);
|
|
2698
2809
|
}
|
|
2699
2810
|
|
|
2700
2811
|
.sv-email-input:hover:not(:focus):not(:disabled) {
|
|
@@ -2716,7 +2827,7 @@ function getStyles(options) {
|
|
|
2716
2827
|
}
|
|
2717
2828
|
|
|
2718
2829
|
.sv-email-input-error:focus {
|
|
2719
|
-
box-shadow: 0 0 0 3px
|
|
2830
|
+
box-shadow: 0 0 0 3px ${tokens.errorLight};
|
|
2720
2831
|
}
|
|
2721
2832
|
|
|
2722
2833
|
/* ========================================
|
|
@@ -2771,14 +2882,14 @@ function getStyles(options) {
|
|
|
2771
2882
|
.sv-error-code-label {
|
|
2772
2883
|
font-size: 10px;
|
|
2773
2884
|
font-weight: 600;
|
|
2774
|
-
color: ${isDark ? '#
|
|
2885
|
+
color: ${isDark ? '#e6443d' : '#991b1b'};
|
|
2775
2886
|
text-transform: uppercase;
|
|
2776
2887
|
letter-spacing: 0.05em;
|
|
2777
2888
|
}
|
|
2778
2889
|
|
|
2779
2890
|
.sv-error-code-value {
|
|
2780
2891
|
font-size: 11px;
|
|
2781
|
-
font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Monaco, 'Cascadia Mono', monospace;
|
|
2892
|
+
font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Monaco, 'Cascadia Mono', monospace;
|
|
2782
2893
|
color: ${tokens.error};
|
|
2783
2894
|
font-weight: 500;
|
|
2784
2895
|
}
|
|
@@ -2875,10 +2986,10 @@ function getStyles(options) {
|
|
|
2875
2986
|
justify-content: center;
|
|
2876
2987
|
background: transparent;
|
|
2877
2988
|
border: none;
|
|
2878
|
-
border-radius:
|
|
2989
|
+
border-radius: 6px;
|
|
2879
2990
|
cursor: pointer;
|
|
2880
2991
|
color: ${tokens.textMuted};
|
|
2881
|
-
transition: background
|
|
2992
|
+
transition: background var(--sv-dur-fast) var(--sv-ease-standard), color var(--sv-dur-fast) var(--sv-ease-standard);
|
|
2882
2993
|
z-index: 1;
|
|
2883
2994
|
}
|
|
2884
2995
|
|
|
@@ -2888,12 +2999,8 @@ function getStyles(options) {
|
|
|
2888
2999
|
}
|
|
2889
3000
|
|
|
2890
3001
|
.sv-floating-close:focus-visible {
|
|
2891
|
-
outline:
|
|
2892
|
-
|
|
2893
|
-
}
|
|
2894
|
-
|
|
2895
|
-
.sv-floating-close:active {
|
|
2896
|
-
transform: scale(0.96);
|
|
3002
|
+
outline: none;
|
|
3003
|
+
box-shadow: ${tokens.focusRing};
|
|
2897
3004
|
}
|
|
2898
3005
|
|
|
2899
3006
|
/* ========================================
|
|
@@ -2953,7 +3060,7 @@ function getStyles(options) {
|
|
|
2953
3060
|
|
|
2954
3061
|
.sv-not-activated-title {
|
|
2955
3062
|
font-size: 22px;
|
|
2956
|
-
font-weight:
|
|
3063
|
+
font-weight: 600;
|
|
2957
3064
|
letter-spacing: -0.02em;
|
|
2958
3065
|
line-height: 1.2;
|
|
2959
3066
|
margin: 0 0 10px 0;
|
|
@@ -2975,7 +3082,7 @@ function getStyles(options) {
|
|
|
2975
3082
|
gap: 4px;
|
|
2976
3083
|
padding: 14px 16px;
|
|
2977
3084
|
border: 1px solid ${tokens.border};
|
|
2978
|
-
border-radius:
|
|
3085
|
+
border-radius: 10px;
|
|
2979
3086
|
background: ${tokens.bgSubtle};
|
|
2980
3087
|
text-align: left;
|
|
2981
3088
|
margin-bottom: 22px;
|
|
@@ -3023,7 +3130,7 @@ function getStyles(options) {
|
|
|
3023
3130
|
font-size: 13px;
|
|
3024
3131
|
font-weight: 500;
|
|
3025
3132
|
color: ${tokens.textMuted};
|
|
3026
|
-
transition: color
|
|
3133
|
+
transition: color var(--sv-dur-fast) var(--sv-ease-standard);
|
|
3027
3134
|
align-self: center;
|
|
3028
3135
|
}
|
|
3029
3136
|
|
|
@@ -3032,8 +3139,8 @@ function getStyles(options) {
|
|
|
3032
3139
|
}
|
|
3033
3140
|
|
|
3034
3141
|
.sv-not-activated-dismiss:focus-visible {
|
|
3035
|
-
outline:
|
|
3036
|
-
|
|
3142
|
+
outline: none;
|
|
3143
|
+
box-shadow: ${tokens.focusRing};
|
|
3037
3144
|
border-radius: 6px;
|
|
3038
3145
|
}
|
|
3039
3146
|
|
|
@@ -3078,7 +3185,7 @@ function getStyles(options) {
|
|
|
3078
3185
|
border: none;
|
|
3079
3186
|
padding: 12px 0 0 0;
|
|
3080
3187
|
margin-top: 8px;
|
|
3081
|
-
transition: color
|
|
3188
|
+
transition: color var(--sv-dur-fast) var(--sv-ease-standard);
|
|
3082
3189
|
}
|
|
3083
3190
|
|
|
3084
3191
|
.sv-fallback-link:hover {
|
|
@@ -3139,7 +3246,7 @@ function getStyles(options) {
|
|
|
3139
3246
|
background: none;
|
|
3140
3247
|
border: none;
|
|
3141
3248
|
padding: 12px 0 0 0;
|
|
3142
|
-
transition: color
|
|
3249
|
+
transition: color var(--sv-dur-fast) var(--sv-ease-standard);
|
|
3143
3250
|
}
|
|
3144
3251
|
|
|
3145
3252
|
.sv-skip-link:hover {
|
|
@@ -3157,14 +3264,11 @@ function getStyles(options) {
|
|
|
3157
3264
|
margin-bottom: 16px;
|
|
3158
3265
|
}
|
|
3159
3266
|
|
|
3267
|
+
/* Bare glyph — no tinted circle container. */
|
|
3160
3268
|
.sv-sparklink-icon {
|
|
3161
|
-
width:
|
|
3162
|
-
height:
|
|
3163
|
-
color: ${tokens.
|
|
3164
|
-
background: ${tokens.primaryLight};
|
|
3165
|
-
padding: 14px;
|
|
3166
|
-
border-radius: 50%;
|
|
3167
|
-
box-sizing: content-box;
|
|
3269
|
+
width: 48px;
|
|
3270
|
+
height: 48px;
|
|
3271
|
+
color: ${tokens.textSecondary};
|
|
3168
3272
|
}
|
|
3169
3273
|
|
|
3170
3274
|
.sv-sparklink-waiting {
|
|
@@ -3190,7 +3294,7 @@ function getStyles(options) {
|
|
|
3190
3294
|
|
|
3191
3295
|
.sv-sparklink-waiting-text {
|
|
3192
3296
|
font-size: 13px;
|
|
3193
|
-
font-weight:
|
|
3297
|
+
font-weight: 500;
|
|
3194
3298
|
color: ${tokens.textSecondary};
|
|
3195
3299
|
}
|
|
3196
3300
|
|
|
@@ -3205,9 +3309,10 @@ function getStyles(options) {
|
|
|
3205
3309
|
}
|
|
3206
3310
|
|
|
3207
3311
|
.sv-sparklink-countdown-time {
|
|
3208
|
-
font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Monaco, 'Cascadia Mono', monospace;
|
|
3312
|
+
font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Monaco, 'Cascadia Mono', monospace;
|
|
3209
3313
|
font-weight: 600;
|
|
3210
3314
|
font-size: 14px;
|
|
3315
|
+
font-variant-numeric: tabular-nums;
|
|
3211
3316
|
color: ${tokens.textPrimary};
|
|
3212
3317
|
min-width: 40px;
|
|
3213
3318
|
}
|
|
@@ -3402,7 +3507,7 @@ function getStyles(options) {
|
|
|
3402
3507
|
margin-bottom: 0;
|
|
3403
3508
|
border-width: 0;
|
|
3404
3509
|
overflow: hidden;
|
|
3405
|
-
transition: opacity
|
|
3510
|
+
transition: opacity var(--sv-dur-slow) var(--sv-ease-standard);
|
|
3406
3511
|
}
|
|
3407
3512
|
|
|
3408
3513
|
.sv-bridge-alert.sv-shown {
|
|
@@ -3419,7 +3524,7 @@ function getStyles(options) {
|
|
|
3419
3524
|
width: 17px;
|
|
3420
3525
|
height: 17px;
|
|
3421
3526
|
margin-top: 1px;
|
|
3422
|
-
color:
|
|
3527
|
+
color: ${tokens.warningIcon};
|
|
3423
3528
|
}
|
|
3424
3529
|
|
|
3425
3530
|
/* Text stacked over the action, so the message keeps the full width and
|
|
@@ -3450,7 +3555,7 @@ function getStyles(options) {
|
|
|
3450
3555
|
}
|
|
3451
3556
|
|
|
3452
3557
|
.sv-bridge-retry:hover { color: ${tokens.primaryHover}; }
|
|
3453
|
-
.sv-bridge-retry:focus-visible { outline:
|
|
3558
|
+
.sv-bridge-retry:focus-visible { outline: none; box-shadow: ${tokens.focusRing}; border-radius: 4px; }
|
|
3454
3559
|
|
|
3455
3560
|
@media (prefers-reduced-motion: reduce) {
|
|
3456
3561
|
.sv-bridge-dots span { animation: none; opacity: 0.5; }
|
|
@@ -3503,8 +3608,9 @@ function getStyles(options) {
|
|
|
3503
3608
|
/**
|
|
3504
3609
|
* SVG Icon Factory
|
|
3505
3610
|
*
|
|
3506
|
-
*
|
|
3507
|
-
*
|
|
3611
|
+
* Bare outline glyphs per the SparkVault design system: stroke `currentColor`
|
|
3612
|
+
* so the stylesheet drives color, no tinted container backgrounds, round
|
|
3613
|
+
* caps/joins. Uses proper DOM element creation for security.
|
|
3508
3614
|
*/
|
|
3509
3615
|
function createSvgElement(viewBox, width = 16, height = 16) {
|
|
3510
3616
|
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
@@ -3572,88 +3678,63 @@ function createCloseIcon() {
|
|
|
3572
3678
|
return svg;
|
|
3573
3679
|
}
|
|
3574
3680
|
/**
|
|
3575
|
-
* Passkey icon -
|
|
3681
|
+
* Passkey icon - bare outline key design
|
|
3576
3682
|
*/
|
|
3577
3683
|
function createPasskeyIcon() {
|
|
3578
3684
|
const svg = createSvgElement('0 0 56 56', 56, 56);
|
|
3579
3685
|
svg.classList.add('sv-passkey-icon');
|
|
3580
|
-
//
|
|
3581
|
-
svg.appendChild(createCircle(28, 28, 26, {
|
|
3582
|
-
fill: '#EEF2FF',
|
|
3583
|
-
stroke: '#E0E7FF',
|
|
3584
|
-
'stroke-width': '1',
|
|
3585
|
-
}));
|
|
3586
|
-
// Key icon - centered at 28,28
|
|
3686
|
+
// Key glyph optically centered in the 56px box (footprint unchanged)
|
|
3587
3687
|
const group = document.createElementNS('http://www.w3.org/2000/svg', 'g');
|
|
3588
|
-
group.setAttribute('transform', 'translate(
|
|
3688
|
+
group.setAttribute('transform', 'translate(29.5, 26.5)');
|
|
3589
3689
|
const strokeAttrs = {
|
|
3590
|
-
stroke: '
|
|
3591
|
-
'stroke-width': '
|
|
3690
|
+
stroke: 'currentColor',
|
|
3691
|
+
'stroke-width': '3',
|
|
3592
3692
|
'stroke-linecap': 'round',
|
|
3593
3693
|
'stroke-linejoin': 'round',
|
|
3594
3694
|
fill: 'none',
|
|
3595
3695
|
};
|
|
3596
3696
|
// Key head (circle)
|
|
3597
|
-
group.appendChild(createCircle(-
|
|
3697
|
+
group.appendChild(createCircle(-9.5, -9.5, 9.5, strokeAttrs));
|
|
3598
3698
|
// Key shaft
|
|
3599
|
-
group.appendChild(createPath('M-
|
|
3699
|
+
group.appendChild(createPath('M-2.8 -2.8L16 16', strokeAttrs));
|
|
3600
3700
|
// Key teeth
|
|
3601
|
-
group.appendChild(createPath('
|
|
3602
|
-
group.appendChild(createPath('
|
|
3701
|
+
group.appendChild(createPath('M9.5 9.5L9.5 15.5', strokeAttrs));
|
|
3702
|
+
group.appendChild(createPath('M16 16L16 22', strokeAttrs));
|
|
3603
3703
|
svg.appendChild(group);
|
|
3604
3704
|
return svg;
|
|
3605
3705
|
}
|
|
3606
3706
|
/**
|
|
3607
|
-
*
|
|
3707
|
+
* Bare outline alert triangle shared by the error and expired icons.
|
|
3708
|
+
* Color comes from `currentColor` via the class-specific stylesheet rules.
|
|
3608
3709
|
*/
|
|
3609
|
-
function
|
|
3710
|
+
function createAlertTriangleIcon(className) {
|
|
3610
3711
|
const svg = createSvgElement('0 0 48 48', 48, 48);
|
|
3611
|
-
svg.classList.add(
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
stroke: '#FECACA',
|
|
3616
|
-
'stroke-width': '1',
|
|
3617
|
-
}));
|
|
3618
|
-
// Alert triangle
|
|
3619
|
-
const group = document.createElementNS('http://www.w3.org/2000/svg', 'g');
|
|
3620
|
-
group.setAttribute('transform', 'translate(10, 12)');
|
|
3621
|
-
group.appendChild(createPath('M14 4L2 24h24L14 4z', { fill: '#DC2626' }));
|
|
3622
|
-
// Exclamation
|
|
3623
|
-
group.appendChild(createPath('M14 10v5', {
|
|
3624
|
-
stroke: '#FFFFFF',
|
|
3625
|
-
'stroke-width': '2',
|
|
3712
|
+
svg.classList.add(className);
|
|
3713
|
+
const strokeAttrs = {
|
|
3714
|
+
stroke: 'currentColor',
|
|
3715
|
+
'stroke-width': '2.5',
|
|
3626
3716
|
'stroke-linecap': 'round',
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3717
|
+
'stroke-linejoin': 'round',
|
|
3718
|
+
fill: 'none',
|
|
3719
|
+
};
|
|
3720
|
+
// Triangle outline
|
|
3721
|
+
svg.appendChild(createPath('M24 9L5.5 39h37L24 9z', strokeAttrs));
|
|
3722
|
+
// Exclamation
|
|
3723
|
+
svg.appendChild(createPath('M24 20v8', strokeAttrs));
|
|
3724
|
+
svg.appendChild(createCircle(24, 33.5, 1.5, { fill: 'currentColor' }));
|
|
3630
3725
|
return svg;
|
|
3631
3726
|
}
|
|
3632
3727
|
/**
|
|
3633
|
-
*
|
|
3728
|
+
* Error icon - alert triangle for error states
|
|
3729
|
+
*/
|
|
3730
|
+
function createErrorIcon() {
|
|
3731
|
+
return createAlertTriangleIcon('sv-error-icon');
|
|
3732
|
+
}
|
|
3733
|
+
/**
|
|
3734
|
+
* Expired icon - alert triangle for expired states
|
|
3634
3735
|
*/
|
|
3635
3736
|
function createExpiredIcon() {
|
|
3636
|
-
|
|
3637
|
-
svg.classList.add('sv-expired-icon');
|
|
3638
|
-
// Circle background - muted gray
|
|
3639
|
-
svg.appendChild(createCircle(24, 24, 22, {
|
|
3640
|
-
fill: '#F5F5F5',
|
|
3641
|
-
stroke: '#E5E5E5',
|
|
3642
|
-
'stroke-width': '1',
|
|
3643
|
-
}));
|
|
3644
|
-
// Alert triangle - gray
|
|
3645
|
-
const group = document.createElementNS('http://www.w3.org/2000/svg', 'g');
|
|
3646
|
-
group.setAttribute('transform', 'translate(10, 12)');
|
|
3647
|
-
group.appendChild(createPath('M14 4L2 24h24L14 4z', { fill: '#737373' }));
|
|
3648
|
-
// Exclamation
|
|
3649
|
-
group.appendChild(createPath('M14 10v5', {
|
|
3650
|
-
stroke: '#FFFFFF',
|
|
3651
|
-
'stroke-width': '2',
|
|
3652
|
-
'stroke-linecap': 'round',
|
|
3653
|
-
}));
|
|
3654
|
-
group.appendChild(createCircle(14, 19, 1, { fill: '#FFFFFF' }));
|
|
3655
|
-
svg.appendChild(group);
|
|
3656
|
-
return svg;
|
|
3737
|
+
return createAlertTriangleIcon('sv-expired-icon');
|
|
3657
3738
|
}
|
|
3658
3739
|
/**
|
|
3659
3740
|
* Method icons
|
|
@@ -7834,7 +7915,7 @@ class DialogLauncher {
|
|
|
7834
7915
|
const generation = ++this.generation;
|
|
7835
7916
|
this.popupLauncher
|
|
7836
7917
|
.openPopup({
|
|
7837
|
-
url: this.
|
|
7918
|
+
url: buildSigninUrl(this.config, this.options),
|
|
7838
7919
|
windowName: 'sparkvault-login',
|
|
7839
7920
|
resultType: LOGIN_RESULT_TYPE,
|
|
7840
7921
|
readyType: LOGIN_READY_TYPE,
|
|
@@ -7855,28 +7936,6 @@ class DialogLauncher {
|
|
|
7855
7936
|
.catch((error) => { if (generation === this.generation)
|
|
7856
7937
|
this.handleError(error); });
|
|
7857
7938
|
}
|
|
7858
|
-
buildPopupUrl() {
|
|
7859
|
-
const params = new URLSearchParams({ origin: window.location.origin });
|
|
7860
|
-
// Identifier prefill - the popup collects it itself when absent.
|
|
7861
|
-
if (this.options.email) {
|
|
7862
|
-
params.set('email', this.options.email);
|
|
7863
|
-
}
|
|
7864
|
-
else if (this.options.phone) {
|
|
7865
|
-
params.set('phone', this.options.phone);
|
|
7866
|
-
}
|
|
7867
|
-
// Auth context, in the query shape the sign-in page reads server-side:
|
|
7868
|
-
// OIDC rides `auth_request`; simple redirect rides `mode=simple` + the
|
|
7869
|
-
// opaque `session` (the page loads success/failure URLs from the session).
|
|
7870
|
-
const authContext = this.options.authContext;
|
|
7871
|
-
if (authContext?.authRequestId) {
|
|
7872
|
-
params.set('auth_request', authContext.authRequestId);
|
|
7873
|
-
}
|
|
7874
|
-
else if (authContext?.simpleMode?.sessionId) {
|
|
7875
|
-
params.set('mode', 'simple');
|
|
7876
|
-
params.set('session', authContext.simpleMode.sessionId);
|
|
7877
|
-
}
|
|
7878
|
-
return `${this.config.identityBaseUrl}/${this.config.accountId}/signin?${params}`;
|
|
7879
|
-
}
|
|
7880
7939
|
handleResult(message) {
|
|
7881
7940
|
if (this.settled)
|
|
7882
7941
|
return;
|
|
@@ -8344,6 +8403,10 @@ class IdentityModule {
|
|
|
8344
8403
|
if (config.preloadConfig) {
|
|
8345
8404
|
this.api.preloadConfig();
|
|
8346
8405
|
}
|
|
8406
|
+
// Warm the connection to the Identity origin before sign-in is invoked:
|
|
8407
|
+
// the popup/redirect navigation and every flow API call reuse it, removing
|
|
8408
|
+
// the cold-connection stall mobile browsers hit on first navigation.
|
|
8409
|
+
ensurePreconnect(config.identityBaseUrl);
|
|
8347
8410
|
}
|
|
8348
8411
|
/**
|
|
8349
8412
|
* Build a deep link into the person's auth.sv Identity portal — where they
|
|
@@ -8450,12 +8513,18 @@ class IdentityModule {
|
|
|
8450
8513
|
typeof navigator.credentials.get === 'function');
|
|
8451
8514
|
}
|
|
8452
8515
|
/**
|
|
8453
|
-
*
|
|
8516
|
+
* Sign in through the first-party SparkVault sign-in popup.
|
|
8454
8517
|
*
|
|
8455
8518
|
* This is the single programmatic entry point; `attach()` binds it to element
|
|
8456
|
-
* clicks.
|
|
8457
|
-
*
|
|
8458
|
-
*
|
|
8519
|
+
* clicks. The popup runs the flow top-level on the Identity origin (so
|
|
8520
|
+
* login's `__Host-` hub cookie is a first-party write and cross-domain SSO
|
|
8521
|
+
* works) and posts the result back — the promise resolves with it.
|
|
8522
|
+
*
|
|
8523
|
+
* Resilience: pair this with `handleRedirectResult()` on page load. If the
|
|
8524
|
+
* popup's result is ever lost (a mobile browser discards the backgrounded
|
|
8525
|
+
* opener tab), the next load silently self-heals from the SSO session the
|
|
8526
|
+
* login established. `flow: 'redirect'` opts a caller out of the popup into a
|
|
8527
|
+
* same-tab navigation instead.
|
|
8459
8528
|
*
|
|
8460
8529
|
* @example
|
|
8461
8530
|
* const result = await sv.products.identity.signIn();
|
|
@@ -8465,9 +8534,10 @@ class IdentityModule {
|
|
|
8465
8534
|
return this.runFlow(options);
|
|
8466
8535
|
}
|
|
8467
8536
|
/**
|
|
8468
|
-
* Core flow runner.
|
|
8469
|
-
* (`renderMode: 'local'` /
|
|
8470
|
-
*
|
|
8537
|
+
* Core flow runner. Default mode (no `target`) opens the popup; `flow:
|
|
8538
|
+
* 'redirect'` navigates the tab instead; local mode (`renderMode: 'local'` /
|
|
8539
|
+
* `target`) renders into the current document and powers the
|
|
8540
|
+
* SparkVault-hosted sign-in surfaces (see the internal `render`).
|
|
8471
8541
|
*/
|
|
8472
8542
|
async runFlow(options = {}) {
|
|
8473
8543
|
const redirectResult = await this.consumeRedirectResult();
|
|
@@ -8493,9 +8563,10 @@ class IdentityModule {
|
|
|
8493
8563
|
backdropBlur: options.backdropBlur ?? this.config.backdropBlur,
|
|
8494
8564
|
};
|
|
8495
8565
|
// Inline rendering (target) and explicit local mode run the flow in this
|
|
8496
|
-
// document
|
|
8497
|
-
//
|
|
8498
|
-
//
|
|
8566
|
+
// document — that is how the SparkVault-hosted sign-in page itself runs
|
|
8567
|
+
// the flow. Otherwise sign-in leaves this page: a top-level redirect to
|
|
8568
|
+
// the sign-in page on the Identity origin (so login's first-party SSO
|
|
8569
|
+
// cookie persists), returning via handleRedirectResult().
|
|
8499
8570
|
const isInline = !!options.target;
|
|
8500
8571
|
const useLocal = options.renderMode === 'local' || isInline;
|
|
8501
8572
|
let resolveRef;
|
|
@@ -8531,14 +8602,35 @@ class IdentityModule {
|
|
|
8531
8602
|
if (!useLocal) {
|
|
8532
8603
|
// When the preloaded config has already failed *permanently* — this origin
|
|
8533
8604
|
// is not a verified domain, or the account hasn't configured Identity —
|
|
8534
|
-
// the
|
|
8605
|
+
// the flow cannot help: the IdP will reject the unverified origin. Render
|
|
8535
8606
|
// the error dialog in-page right away instead. Transient failures fall
|
|
8536
|
-
// through
|
|
8607
|
+
// through, and the popup/sign-in page surfaces them in its own dialog.
|
|
8537
8608
|
if (await this.preloadedConfigPermanentlyFailed()) {
|
|
8538
8609
|
startLocalRender(new ModalContainer());
|
|
8539
8610
|
return settledPromise;
|
|
8540
8611
|
}
|
|
8541
|
-
|
|
8612
|
+
// Explicit `flow: 'redirect'` navigates this tab to the sign-in page and
|
|
8613
|
+
// returns via handleRedirectResult() (the escape hatch for hosts that
|
|
8614
|
+
// want to skip the popup on mobile). Then this page is unloading, so the
|
|
8615
|
+
// promise never settles on success; it rejects only if the redirect
|
|
8616
|
+
// cannot start.
|
|
8617
|
+
if (mergedOptions.flow === 'redirect') {
|
|
8618
|
+
if (!await this.startRedirectFlow(mergedOptions)) {
|
|
8619
|
+
hostCallbacks.onError(new ValidationError('Sign-in requires browser session storage. Enable site data for this site and try again.'));
|
|
8620
|
+
}
|
|
8621
|
+
return settledPromise;
|
|
8622
|
+
}
|
|
8623
|
+
// Default: the first-party popup on the Identity origin. Mark a sign-in
|
|
8624
|
+
// as in flight so that if its result is lost (a mobile browser discards
|
|
8625
|
+
// the backgrounded opener tab, killing the postMessage listener),
|
|
8626
|
+
// handleRedirectResult() can silently self-heal on the next load from
|
|
8627
|
+
// the SSO session the popup login established.
|
|
8628
|
+
this.markSignInPending();
|
|
8629
|
+
this.launcher = new DialogLauncher(this.config, this.api, mergedOptions, {
|
|
8630
|
+
onSuccess: (result) => { this.clearSignInPending(); hostCallbacks.onSuccess(result); },
|
|
8631
|
+
onError: (error) => { this.clearSignInPending(); hostCallbacks.onError(error); },
|
|
8632
|
+
onCancel: () => { this.clearSignInPending(); hostCallbacks.onCancel(); },
|
|
8633
|
+
});
|
|
8542
8634
|
this.launcher.start();
|
|
8543
8635
|
return settledPromise;
|
|
8544
8636
|
}
|
|
@@ -8645,13 +8737,212 @@ class IdentityModule {
|
|
|
8645
8737
|
return payload;
|
|
8646
8738
|
}
|
|
8647
8739
|
/**
|
|
8648
|
-
* Complete
|
|
8649
|
-
*
|
|
8650
|
-
*
|
|
8651
|
-
*
|
|
8652
|
-
*
|
|
8653
|
-
*
|
|
8740
|
+
* Complete a sign-in on page load — the return leg of `signIn()`. Call once
|
|
8741
|
+
* on every page load; it resolves `null` when there is nothing to do.
|
|
8742
|
+
*
|
|
8743
|
+
* It handles two cases:
|
|
8744
|
+
* 1. A one-time code is in the URL fragment (`#sv_code=…`) — the popup's
|
|
8745
|
+
* result was lost and self-heal navigated here, or `flow: 'redirect'`
|
|
8746
|
+
* returned. Redeem it server-side and hand the full result to
|
|
8747
|
+
* `onSuccess` (and resolve with it).
|
|
8748
|
+
* 2. A sign-in was in flight but never delivered (a mobile browser
|
|
8749
|
+
* discarded the backgrounded opener tab, killing the popup's
|
|
8750
|
+
* postMessage) — silently re-mint from the SSO session the completed
|
|
8751
|
+
* popup login established, by navigating this tab through the silent SSO
|
|
8752
|
+
* endpoint and straight back with a code (case 1 on return). Nothing is
|
|
8753
|
+
* shown; if there is no live session it comes back logged-out, no oracle.
|
|
8754
|
+
*
|
|
8755
|
+
* The code is one-time, PKCE-bound, and origin-locked — never the token. The
|
|
8756
|
+
* host must still verify `result.token` server-side via the Identity JWKS.
|
|
8757
|
+
*
|
|
8758
|
+
* @example Call on page load; sign-in clicks stay unchanged.
|
|
8759
|
+
* sv.products.identity.handleRedirectResult({
|
|
8760
|
+
* onSuccess: (result) => createSession(result.token),
|
|
8761
|
+
* }).catch((error) => showError(error));
|
|
8654
8762
|
*/
|
|
8763
|
+
async handleRedirectResult(options = {}) {
|
|
8764
|
+
if (typeof window === 'undefined') {
|
|
8765
|
+
return null;
|
|
8766
|
+
}
|
|
8767
|
+
const params = new URLSearchParams((window.location.hash || '').slice(1));
|
|
8768
|
+
if (params.get('sv_code') || params.get('sv_error')) {
|
|
8769
|
+
return this.consumeHandoffFragment(params, options);
|
|
8770
|
+
}
|
|
8771
|
+
// A silent-SSO recovery that found no live session returns `#sso=…`; strip
|
|
8772
|
+
// it so the logged-out load is clean, and do not re-bounce (handled below).
|
|
8773
|
+
if (params.get('sso')) {
|
|
8774
|
+
this.clearUrlFragment();
|
|
8775
|
+
}
|
|
8776
|
+
// No returned result. If a sign-in was in flight and its result never
|
|
8777
|
+
// arrived, self-heal once from the SSO session (mobile opener-tab discard).
|
|
8778
|
+
if (this.consumeSignInPending()) {
|
|
8779
|
+
await this.startRecoveryBounce();
|
|
8780
|
+
}
|
|
8781
|
+
return null;
|
|
8782
|
+
}
|
|
8783
|
+
/** Redeem a returned `#sv_code` (or surface a returned `#sv_error`). */
|
|
8784
|
+
async consumeHandoffFragment(params, options) {
|
|
8785
|
+
const code = params.get('sv_code');
|
|
8786
|
+
const errorCode = params.get('sv_error');
|
|
8787
|
+
// A returned fragment means this sign-in resolved (redeem, cancel, or
|
|
8788
|
+
// error), so retire any pending marker — otherwise it could fire one
|
|
8789
|
+
// spurious silent bounce on a later load inside its TTL.
|
|
8790
|
+
this.clearSignInPending();
|
|
8791
|
+
// Consume exactly once: fragment and one-shot state/verifier are cleared
|
|
8792
|
+
// up front on every path, so a failing result cannot wedge future loads
|
|
8793
|
+
// (and a StrictMode double-invocation finds an empty hash and no-ops).
|
|
8794
|
+
let expectedState = null;
|
|
8795
|
+
let codeVerifier = null;
|
|
8796
|
+
try {
|
|
8797
|
+
expectedState = sessionStorage.getItem('sv_oauth_state');
|
|
8798
|
+
codeVerifier = sessionStorage.getItem('sv_pkce_verifier');
|
|
8799
|
+
sessionStorage.removeItem('sv_oauth_state');
|
|
8800
|
+
sessionStorage.removeItem('sv_pkce_verifier');
|
|
8801
|
+
}
|
|
8802
|
+
catch {
|
|
8803
|
+
// Storage disabled (private mode): state/verifier were never persisted.
|
|
8804
|
+
}
|
|
8805
|
+
this.clearUrlFragment();
|
|
8806
|
+
try {
|
|
8807
|
+
if (errorCode) {
|
|
8808
|
+
if (errorCode === 'cancelled') {
|
|
8809
|
+
options.onCancel?.();
|
|
8810
|
+
return null;
|
|
8811
|
+
}
|
|
8812
|
+
throw new SparkVaultError('Sign-in could not be completed. Please try again.', 'REDIRECT_SIGNIN_FAILED');
|
|
8813
|
+
}
|
|
8814
|
+
if (expectedState && params.get('state') !== expectedState) {
|
|
8815
|
+
throw new ValidationError('Invalid OAuth state');
|
|
8816
|
+
}
|
|
8817
|
+
if (!codeVerifier) {
|
|
8818
|
+
throw new ValidationError('Sign-in session was lost — please sign in again.');
|
|
8819
|
+
}
|
|
8820
|
+
const raw = await this.api.redeemHandoffCode(code, codeVerifier);
|
|
8821
|
+
const result = {
|
|
8822
|
+
token: raw.token,
|
|
8823
|
+
identity: raw.identity,
|
|
8824
|
+
identityType: raw.identity_type,
|
|
8825
|
+
svid: raw.svid ?? undefined,
|
|
8826
|
+
sessionId: raw.session_id ?? undefined,
|
|
8827
|
+
refreshToken: raw.refresh_token ?? undefined,
|
|
8828
|
+
};
|
|
8829
|
+
options.onSuccess?.(result);
|
|
8830
|
+
return result;
|
|
8831
|
+
}
|
|
8832
|
+
catch (error) {
|
|
8833
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
8834
|
+
options.onError?.(err);
|
|
8835
|
+
throw err;
|
|
8836
|
+
}
|
|
8837
|
+
}
|
|
8838
|
+
/**
|
|
8839
|
+
* Silently re-mint the sign-in result from the SSO session the completed
|
|
8840
|
+
* popup login left behind. Navigates this tab through the silent SSO endpoint
|
|
8841
|
+
* (a top-level GET, so the `SameSite=Lax` hub cookie rides along) which,
|
|
8842
|
+
* PKCE-bound, returns a one-time code in the fragment — handled by case 1 on
|
|
8843
|
+
* return. No-op (stays put) if session storage or WebCrypto is unavailable,
|
|
8844
|
+
* so a hostile/degraded environment simply never recovers rather than
|
|
8845
|
+
* erroring.
|
|
8846
|
+
*/
|
|
8847
|
+
async startRecoveryBounce() {
|
|
8848
|
+
const nav = await this.prepareHandoffNavigation(`${this.config.identityBaseUrl}/${this.config.accountId}/sso`);
|
|
8849
|
+
if (nav) {
|
|
8850
|
+
window.location.assign(nav);
|
|
8851
|
+
}
|
|
8852
|
+
}
|
|
8853
|
+
/**
|
|
8854
|
+
* Explicit `flow: 'redirect'` — navigate this tab to the interactive sign-in
|
|
8855
|
+
* page. Plain sign-in carries redirect_uri + state + PKCE challenge and
|
|
8856
|
+
* returns via the fragment code; OIDC/simple modes navigate bare (their
|
|
8857
|
+
* server-rendered pages drive the server-validated redirect back).
|
|
8858
|
+
*
|
|
8859
|
+
* @returns false when the return leg cannot be armed (no session storage or
|
|
8860
|
+
* WebCrypto) — the caller surfaces an actionable error instead of a
|
|
8861
|
+
* silent dead-end.
|
|
8862
|
+
*/
|
|
8863
|
+
async startRedirectFlow(options) {
|
|
8864
|
+
const authContext = options.authContext;
|
|
8865
|
+
if (authContext?.authRequestId || authContext?.simpleMode?.sessionId) {
|
|
8866
|
+
window.location.assign(buildSigninUrl(this.config, options));
|
|
8867
|
+
return true;
|
|
8868
|
+
}
|
|
8869
|
+
const url = await this.prepareHandoffNavigation(buildSigninUrl(this.config, options), (extras) => buildSigninUrl(this.config, options, extras));
|
|
8870
|
+
if (!url) {
|
|
8871
|
+
return false;
|
|
8872
|
+
}
|
|
8873
|
+
window.location.assign(url);
|
|
8874
|
+
return true;
|
|
8875
|
+
}
|
|
8876
|
+
/**
|
|
8877
|
+
* Arm the PKCE + state return leg for a handoff navigation and return the URL
|
|
8878
|
+
* to navigate to (redirect_uri = this exact page; query preserved for app
|
|
8879
|
+
* state, fragment dropped since it is the result channel). Returns null when
|
|
8880
|
+
* session storage or WebCrypto is unavailable so callers can degrade.
|
|
8881
|
+
*/
|
|
8882
|
+
async prepareHandoffNavigation(base, build) {
|
|
8883
|
+
const state = generateState();
|
|
8884
|
+
const codeVerifier = generateCodeVerifier();
|
|
8885
|
+
// Derive the challenge BEFORE persisting: a WebCrypto failure (insecure
|
|
8886
|
+
// context) then leaves no orphaned state/verifier behind in storage.
|
|
8887
|
+
let codeChallenge;
|
|
8888
|
+
try {
|
|
8889
|
+
codeChallenge = await computeS256Challenge(codeVerifier);
|
|
8890
|
+
}
|
|
8891
|
+
catch {
|
|
8892
|
+
return null;
|
|
8893
|
+
}
|
|
8894
|
+
try {
|
|
8895
|
+
sessionStorage.setItem('sv_oauth_state', state);
|
|
8896
|
+
sessionStorage.setItem('sv_pkce_verifier', codeVerifier);
|
|
8897
|
+
}
|
|
8898
|
+
catch {
|
|
8899
|
+
return null;
|
|
8900
|
+
}
|
|
8901
|
+
const redirectUri = `${window.location.origin}${window.location.pathname}${window.location.search}`;
|
|
8902
|
+
if (build) {
|
|
8903
|
+
return build({ redirectUri, state, codeChallenge });
|
|
8904
|
+
}
|
|
8905
|
+
const url = new URL(base);
|
|
8906
|
+
url.searchParams.set('redirect_uri', redirectUri);
|
|
8907
|
+
url.searchParams.set('state', state);
|
|
8908
|
+
url.searchParams.set('code_challenge', codeChallenge);
|
|
8909
|
+
return url.toString();
|
|
8910
|
+
}
|
|
8911
|
+
markSignInPending() {
|
|
8912
|
+
try {
|
|
8913
|
+
sessionStorage.setItem(IdentityModule.PENDING_KEY, String(Date.now()));
|
|
8914
|
+
}
|
|
8915
|
+
catch {
|
|
8916
|
+
// No storage → no self-heal; the popup still delivers when it can.
|
|
8917
|
+
}
|
|
8918
|
+
}
|
|
8919
|
+
clearSignInPending() {
|
|
8920
|
+
try {
|
|
8921
|
+
sessionStorage.removeItem(IdentityModule.PENDING_KEY);
|
|
8922
|
+
}
|
|
8923
|
+
catch {
|
|
8924
|
+
// Nothing to clear.
|
|
8925
|
+
}
|
|
8926
|
+
}
|
|
8927
|
+
/** True once (then cleared) if a recent sign-in is still awaiting its result. */
|
|
8928
|
+
consumeSignInPending() {
|
|
8929
|
+
let raw = null;
|
|
8930
|
+
try {
|
|
8931
|
+
raw = sessionStorage.getItem(IdentityModule.PENDING_KEY);
|
|
8932
|
+
sessionStorage.removeItem(IdentityModule.PENDING_KEY);
|
|
8933
|
+
}
|
|
8934
|
+
catch {
|
|
8935
|
+
return false;
|
|
8936
|
+
}
|
|
8937
|
+
const at = raw ? Number(raw) : NaN;
|
|
8938
|
+
return Number.isFinite(at) && Date.now() - at < IdentityModule.PENDING_TTL_MS;
|
|
8939
|
+
}
|
|
8940
|
+
/** Remove the result fragment from the URL bar (and history entry). */
|
|
8941
|
+
clearUrlFragment() {
|
|
8942
|
+
if (typeof window.history?.replaceState === 'function') {
|
|
8943
|
+
window.history.replaceState(window.history.state, document.title, `${window.location.pathname}${window.location.search}`);
|
|
8944
|
+
}
|
|
8945
|
+
}
|
|
8655
8946
|
async consumeRedirectResult() {
|
|
8656
8947
|
if (typeof window === 'undefined' || !window.location.hash) {
|
|
8657
8948
|
return null;
|
|
@@ -8691,9 +8982,7 @@ class IdentityModule {
|
|
|
8691
8982
|
};
|
|
8692
8983
|
}
|
|
8693
8984
|
finally {
|
|
8694
|
-
|
|
8695
|
-
window.history.replaceState(window.history.state, document.title, `${window.location.pathname}${window.location.search}`);
|
|
8696
|
-
}
|
|
8985
|
+
this.clearUrlFragment();
|
|
8697
8986
|
try {
|
|
8698
8987
|
sessionStorage.removeItem('sv_oauth_state');
|
|
8699
8988
|
sessionStorage.removeItem('sv_oauth_email');
|
|
@@ -8779,6 +9068,11 @@ class IdentityModule {
|
|
|
8779
9068
|
return this.runFlow(options);
|
|
8780
9069
|
}
|
|
8781
9070
|
}
|
|
9071
|
+
// A sign-in is "pending" from popup open until its result arrives; a marker
|
|
9072
|
+
// that outlives a lost result (mobile opener-tab discard clears the message
|
|
9073
|
+
// listener but not sessionStorage) is what lets the next load self-heal.
|
|
9074
|
+
IdentityModule.PENDING_KEY = 'sv_signin_pending';
|
|
9075
|
+
IdentityModule.PENDING_TTL_MS = 10 * 60 * 1000;
|
|
8782
9076
|
|
|
8783
9077
|
/**
|
|
8784
9078
|
* Products Module
|