@sparkvault/sdk-js 8.0.1 → 8.1.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/dist/index.d.ts +22 -29
- package/dist/products/identity/dialog-launcher.d.ts +74 -0
- package/dist/products/identity/handlers/passkey-handler.d.ts +3 -8
- package/dist/products/identity/index.d.ts +9 -10
- package/dist/products/identity/inline-container.d.ts +5 -0
- package/dist/products/identity/popup-launcher.d.ts +60 -0
- package/dist/products/identity/styles.d.ts +10 -1
- package/dist/products/identity/types.d.ts +13 -26
- package/dist/sparkvault.cjs.js +622 -446
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +622 -446
- 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/products/identity/embedder.d.ts +0 -83
package/dist/sparkvault.esm.js
CHANGED
|
@@ -126,6 +126,7 @@ Object.freeze([
|
|
|
126
126
|
SPARKVAULT_ROOT_DOMAIN,
|
|
127
127
|
'app.sparkvault.com',
|
|
128
128
|
'api.sparkvault.com',
|
|
129
|
+
'auth.sparkvault.com',
|
|
129
130
|
'cdn.sparkvault.com',
|
|
130
131
|
'forge.sparkvault.com',
|
|
131
132
|
'img.sparkvault.com',
|
|
@@ -427,7 +428,7 @@ class HealthModule {
|
|
|
427
428
|
* this; clients of the SDK never see any of it.
|
|
428
429
|
*/
|
|
429
430
|
/** Default request timeout in milliseconds (30 seconds). */
|
|
430
|
-
const DEFAULT_TIMEOUT_MS = 30000;
|
|
431
|
+
const DEFAULT_TIMEOUT_MS$1 = 30000;
|
|
431
432
|
/**
|
|
432
433
|
* Combine a fresh timeout with a session close signal into one AbortSignal.
|
|
433
434
|
*
|
|
@@ -460,7 +461,7 @@ function combineTimeoutAndCloseSignals(timeoutMs, closeSignal) {
|
|
|
460
461
|
};
|
|
461
462
|
}
|
|
462
463
|
class SparkVaultApi {
|
|
463
|
-
constructor(timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
464
|
+
constructor(timeoutMs = DEFAULT_TIMEOUT_MS$1) {
|
|
464
465
|
/**
|
|
465
466
|
* Abort controller for the current session. Replaced by resetSession()
|
|
466
467
|
* at the start of every user-facing session — an aborted controller can
|
|
@@ -1335,6 +1336,97 @@ class VerificationState {
|
|
|
1335
1336
|
}
|
|
1336
1337
|
}
|
|
1337
1338
|
|
|
1339
|
+
/**
|
|
1340
|
+
* Popup Launcher
|
|
1341
|
+
*
|
|
1342
|
+
* Opens a top-level popup on the Identity origin and bridges its result back
|
|
1343
|
+
* over postMessage. Used by both the passkey ceremony (which needs a popup so
|
|
1344
|
+
* WebAuthn runs same-origin with the RP id) and the dialog login flow (which
|
|
1345
|
+
* needs a top-level window on the IdP origin so login's first-party SSO cookie
|
|
1346
|
+
* persists).
|
|
1347
|
+
*
|
|
1348
|
+
* The single transfer path: synchronous `window.open` inside the user gesture
|
|
1349
|
+
* (so the browser never blocks it), strict `event.origin` + `data.type`
|
|
1350
|
+
* validation against the caller-supplied trusted origin, a 60s timeout, and a
|
|
1351
|
+
* `window.closed` poll that surfaces a manual close as a cancellation.
|
|
1352
|
+
*/
|
|
1353
|
+
/** Default popup dimensions — a centered login/ceremony window. */
|
|
1354
|
+
const DEFAULT_WIDTH = 480;
|
|
1355
|
+
const DEFAULT_HEIGHT = 640;
|
|
1356
|
+
/** Default timeout for popup operations (60 seconds). */
|
|
1357
|
+
const DEFAULT_TIMEOUT_MS = 60000;
|
|
1358
|
+
/** How often to check whether the user closed the popup manually. */
|
|
1359
|
+
const CLOSED_POLL_INTERVAL_MS = 500;
|
|
1360
|
+
/**
|
|
1361
|
+
* Open a popup and resolve with the first validated result envelope it posts.
|
|
1362
|
+
*
|
|
1363
|
+
* Resolves with the raw `event.data` (the caller inspects its `success`/`error`
|
|
1364
|
+
* fields). Rejects with `PopupBlockedError` when the browser blocked the popup,
|
|
1365
|
+
* `UserCancelledError` when the user closed it manually, and `TimeoutError`
|
|
1366
|
+
* when no result arrived within the timeout.
|
|
1367
|
+
*/
|
|
1368
|
+
class PopupLauncher {
|
|
1369
|
+
openPopup(options) {
|
|
1370
|
+
const width = options.width ?? DEFAULT_WIDTH;
|
|
1371
|
+
const height = options.height ?? DEFAULT_HEIGHT;
|
|
1372
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
1373
|
+
return new Promise((resolve, reject) => {
|
|
1374
|
+
const left = Math.round((window.screen.width - width) / 2);
|
|
1375
|
+
const top = Math.round((window.screen.height - height) / 2);
|
|
1376
|
+
// Synchronous open inside the caller's user gesture — any await before
|
|
1377
|
+
// this point would let the browser treat the popup as programmatic and
|
|
1378
|
+
// block it.
|
|
1379
|
+
const popup = window.open(options.url, options.windowName, `width=${width},height=${height},left=${left},top=${top},popup=1`);
|
|
1380
|
+
if (!popup) {
|
|
1381
|
+
reject(new PopupBlockedError());
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1384
|
+
options.onOpen?.(popup);
|
|
1385
|
+
let settled = false;
|
|
1386
|
+
const cleanup = () => {
|
|
1387
|
+
window.removeEventListener('message', handleMessage);
|
|
1388
|
+
clearTimeout(timeoutId);
|
|
1389
|
+
clearInterval(pollClosedId);
|
|
1390
|
+
};
|
|
1391
|
+
const handleMessage = (event) => {
|
|
1392
|
+
// Only trust the server-validated Identity origin — never the broader
|
|
1393
|
+
// sparkvault.com family (XSS or subdomain-takeover relay).
|
|
1394
|
+
if (event.origin !== options.trustedOrigin) {
|
|
1395
|
+
return;
|
|
1396
|
+
}
|
|
1397
|
+
const data = event.data;
|
|
1398
|
+
// A "ready" ping confirms the window loaded; notify but don't settle.
|
|
1399
|
+
if (options.readyType && data?.type === options.readyType) {
|
|
1400
|
+
options.onReady?.();
|
|
1401
|
+
return;
|
|
1402
|
+
}
|
|
1403
|
+
if (data?.type !== options.resultType) {
|
|
1404
|
+
return;
|
|
1405
|
+
}
|
|
1406
|
+
settled = true;
|
|
1407
|
+
cleanup();
|
|
1408
|
+
resolve(data);
|
|
1409
|
+
};
|
|
1410
|
+
window.addEventListener('message', handleMessage);
|
|
1411
|
+
const timeoutId = setTimeout(() => {
|
|
1412
|
+
if (settled)
|
|
1413
|
+
return;
|
|
1414
|
+
settled = true;
|
|
1415
|
+
cleanup();
|
|
1416
|
+
popup.close();
|
|
1417
|
+
reject(new TimeoutError('Popup operation timed out. Please try again.'));
|
|
1418
|
+
}, timeoutMs);
|
|
1419
|
+
const pollClosedId = setInterval(() => {
|
|
1420
|
+
if (popup.closed && !settled) {
|
|
1421
|
+
settled = true;
|
|
1422
|
+
cleanup();
|
|
1423
|
+
reject(new UserCancelledError('Authentication was cancelled.'));
|
|
1424
|
+
}
|
|
1425
|
+
}, CLOSED_POLL_INTERVAL_MS);
|
|
1426
|
+
});
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1338
1430
|
/**
|
|
1339
1431
|
* Passkey Handler
|
|
1340
1432
|
*
|
|
@@ -1348,11 +1440,11 @@ class VerificationState {
|
|
|
1348
1440
|
* 3. Popup sends result via postMessage
|
|
1349
1441
|
* 4. SDK receives result and returns to caller
|
|
1350
1442
|
*/
|
|
1351
|
-
/**
|
|
1443
|
+
/** Passkey popup window dimensions. */
|
|
1352
1444
|
const POPUP_WIDTH = 450;
|
|
1353
1445
|
const POPUP_HEIGHT = 500;
|
|
1354
|
-
/**
|
|
1355
|
-
const
|
|
1446
|
+
/** `data.type` the passkey popup posts back. */
|
|
1447
|
+
const PASSKEY_RESULT_TYPE = 'sparkvault-passkey-result';
|
|
1356
1448
|
/**
|
|
1357
1449
|
* Handles WebAuthn passkey registration and verification via popup
|
|
1358
1450
|
*/
|
|
@@ -1360,6 +1452,7 @@ class PasskeyHandler {
|
|
|
1360
1452
|
constructor(api, state) {
|
|
1361
1453
|
this.api = api;
|
|
1362
1454
|
this.state = state;
|
|
1455
|
+
this.popupLauncher = new PopupLauncher();
|
|
1363
1456
|
// Extract base URL and account ID from the API's URL construction
|
|
1364
1457
|
// The API uses: `${this.config.identityBaseUrl}/${this.config.accountId}`
|
|
1365
1458
|
// We need to access these values for popup URL construction
|
|
@@ -1522,125 +1615,86 @@ class PasskeyHandler {
|
|
|
1522
1615
|
};
|
|
1523
1616
|
}
|
|
1524
1617
|
/**
|
|
1525
|
-
* Open passkey popup
|
|
1618
|
+
* Open passkey popup (top-level on the Identity origin, so WebAuthn runs
|
|
1619
|
+
* same-origin with the RP id) and wait for its result.
|
|
1526
1620
|
*/
|
|
1527
1621
|
async openPasskeyPopup(mode, registrationToken) {
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1622
|
+
// Registration carries the freshly verified identifier so the backend can
|
|
1623
|
+
// attach the credential to that SVID. Verification carries it too when
|
|
1624
|
+
// known, to scope the ceremony to that person's passkeys; the credential
|
|
1625
|
+
// userHandle still routes completion to the SVID.
|
|
1626
|
+
const params = new URLSearchParams({
|
|
1627
|
+
mode,
|
|
1628
|
+
origin: window.location.origin,
|
|
1629
|
+
});
|
|
1630
|
+
if (this.state.recipient) {
|
|
1631
|
+
const identityParam = this.state.identityType === 'phone' ? 'phone' : 'email';
|
|
1632
|
+
params.set(identityParam, this.state.recipient);
|
|
1633
|
+
}
|
|
1634
|
+
// Add auth context for OIDC/simple mode flows
|
|
1635
|
+
const authContext = this.state.authContext;
|
|
1636
|
+
if (authContext?.authRequestId) {
|
|
1637
|
+
params.set('auth_request_id', authContext.authRequestId);
|
|
1638
|
+
}
|
|
1639
|
+
if (authContext?.simpleMode) {
|
|
1640
|
+
params.set('simple_mode', JSON.stringify({
|
|
1641
|
+
success_url: authContext.simpleMode.successUrl,
|
|
1642
|
+
failure_url: authContext.simpleMode.failureUrl,
|
|
1643
|
+
state: authContext.simpleMode.state,
|
|
1644
|
+
session_id: authContext.simpleMode.sessionId,
|
|
1645
|
+
}));
|
|
1646
|
+
}
|
|
1647
|
+
const hash = mode === 'register' && registrationToken
|
|
1648
|
+
? `#${new URLSearchParams({ registration_token: registrationToken }).toString()}`
|
|
1649
|
+
: '';
|
|
1650
|
+
const popupUrl = `${this.baseUrl}/${this.accountId}/passkey/popup?${params}${hash}`;
|
|
1651
|
+
let message;
|
|
1652
|
+
try {
|
|
1653
|
+
message = await this.popupLauncher.openPopup({
|
|
1654
|
+
url: popupUrl,
|
|
1655
|
+
windowName: 'sparkvault-passkey',
|
|
1656
|
+
width: POPUP_WIDTH,
|
|
1657
|
+
height: POPUP_HEIGHT,
|
|
1658
|
+
resultType: PASSKEY_RESULT_TYPE,
|
|
1659
|
+
trustedOrigin: this.trustedOrigin,
|
|
1536
1660
|
});
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
// Add auth context for OIDC/simple mode flows
|
|
1542
|
-
const authContext = this.state.authContext;
|
|
1543
|
-
if (authContext?.authRequestId) {
|
|
1544
|
-
params.set('auth_request_id', authContext.authRequestId);
|
|
1545
|
-
}
|
|
1546
|
-
if (authContext?.simpleMode) {
|
|
1547
|
-
params.set('simple_mode', JSON.stringify({
|
|
1548
|
-
success_url: authContext.simpleMode.successUrl,
|
|
1549
|
-
failure_url: authContext.simpleMode.failureUrl,
|
|
1550
|
-
state: authContext.simpleMode.state,
|
|
1551
|
-
session_id: authContext.simpleMode.sessionId,
|
|
1552
|
-
}));
|
|
1553
|
-
}
|
|
1554
|
-
const hash = mode === 'register' && registrationToken
|
|
1555
|
-
? `#${new URLSearchParams({ registration_token: registrationToken }).toString()}`
|
|
1556
|
-
: '';
|
|
1557
|
-
const popupUrl = `${this.baseUrl}/${this.accountId}/passkey/popup?${params}${hash}`;
|
|
1558
|
-
// Calculate popup position (centered)
|
|
1559
|
-
const left = Math.round((window.screen.width - POPUP_WIDTH) / 2);
|
|
1560
|
-
const top = Math.round((window.screen.height - POPUP_HEIGHT) / 2);
|
|
1561
|
-
// Open popup
|
|
1562
|
-
const popup = window.open(popupUrl, 'sparkvault-passkey', `width=${POPUP_WIDTH},height=${POPUP_HEIGHT},left=${left},top=${top},popup=1`);
|
|
1563
|
-
if (!popup) {
|
|
1564
|
-
resolve({
|
|
1661
|
+
}
|
|
1662
|
+
catch (error) {
|
|
1663
|
+
if (error instanceof PopupBlockedError) {
|
|
1664
|
+
return {
|
|
1565
1665
|
success: false,
|
|
1566
|
-
error:
|
|
1666
|
+
error: error.message,
|
|
1567
1667
|
errorType: 'popup_blocked',
|
|
1568
|
-
}
|
|
1569
|
-
return;
|
|
1668
|
+
};
|
|
1570
1669
|
}
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1670
|
+
if (error instanceof UserCancelledError) {
|
|
1671
|
+
return {
|
|
1672
|
+
success: false,
|
|
1673
|
+
error: error.message,
|
|
1674
|
+
errorType: 'cancelled',
|
|
1675
|
+
};
|
|
1676
|
+
}
|
|
1677
|
+
return {
|
|
1678
|
+
success: false,
|
|
1679
|
+
error: error instanceof Error ? error.message : 'Passkey operation failed. Please try again.',
|
|
1680
|
+
errorType: 'unknown',
|
|
1577
1681
|
};
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
resolve({
|
|
1592
|
-
success: true,
|
|
1593
|
-
result: {
|
|
1594
|
-
token: data.data.token || '',
|
|
1595
|
-
identity: data.data.identity || this.state.recipient,
|
|
1596
|
-
identityType: data.data.identity_type || 'email',
|
|
1597
|
-
svid: data.data.svid,
|
|
1598
|
-
sessionId: data.data.session_id,
|
|
1599
|
-
refreshToken: data.data.refresh_token,
|
|
1600
|
-
redirect: data.data.redirect,
|
|
1601
|
-
},
|
|
1602
|
-
});
|
|
1603
|
-
}
|
|
1604
|
-
else {
|
|
1605
|
-
resolve(this.handlePopupError(data.error, data.message, data.errorCode));
|
|
1606
|
-
}
|
|
1682
|
+
}
|
|
1683
|
+
if (message.success && message.data) {
|
|
1684
|
+
return {
|
|
1685
|
+
success: true,
|
|
1686
|
+
result: {
|
|
1687
|
+
token: message.data.token || '',
|
|
1688
|
+
identity: message.data.identity || this.state.recipient,
|
|
1689
|
+
identityType: message.data.identity_type || 'email',
|
|
1690
|
+
svid: message.data.svid,
|
|
1691
|
+
sessionId: message.data.session_id,
|
|
1692
|
+
refreshToken: message.data.refresh_token,
|
|
1693
|
+
redirect: message.data.redirect,
|
|
1694
|
+
},
|
|
1607
1695
|
};
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
const timeoutId = setTimeout(() => {
|
|
1611
|
-
if (!resolved) {
|
|
1612
|
-
resolved = true;
|
|
1613
|
-
cleanup();
|
|
1614
|
-
popup.close();
|
|
1615
|
-
resolve({
|
|
1616
|
-
success: false,
|
|
1617
|
-
error: 'Passkey operation timed out. Please try again.',
|
|
1618
|
-
errorType: 'unknown',
|
|
1619
|
-
});
|
|
1620
|
-
}
|
|
1621
|
-
}, POPUP_TIMEOUT_MS);
|
|
1622
|
-
// Poll for popup being closed manually
|
|
1623
|
-
const pollClosedId = setInterval(() => {
|
|
1624
|
-
if (popup.closed && !resolved) {
|
|
1625
|
-
resolved = true;
|
|
1626
|
-
cleanup();
|
|
1627
|
-
resolve({
|
|
1628
|
-
success: false,
|
|
1629
|
-
error: 'Authentication was cancelled.',
|
|
1630
|
-
errorType: 'cancelled',
|
|
1631
|
-
});
|
|
1632
|
-
}
|
|
1633
|
-
}, 500);
|
|
1634
|
-
});
|
|
1635
|
-
}
|
|
1636
|
-
/**
|
|
1637
|
-
* Validate that a postMessage came from the identity service's own
|
|
1638
|
-
* origin. We do not accept the broader sparkvault.com family - a popup
|
|
1639
|
-
* is only opened against `this.baseUrl`, so any other origin is
|
|
1640
|
-
* either an unrelated tab or a forgery attempt.
|
|
1641
|
-
*/
|
|
1642
|
-
isValidMessageOrigin(origin) {
|
|
1643
|
-
return origin === this.trustedOrigin;
|
|
1696
|
+
}
|
|
1697
|
+
return this.handlePopupError(message.error, message.message, message.errorCode);
|
|
1644
1698
|
}
|
|
1645
1699
|
/**
|
|
1646
1700
|
* Handle popup error response
|
|
@@ -1875,12 +1929,13 @@ const STYLE_ID$1 = 'sparkvault-identity-styles';
|
|
|
1875
1929
|
*/
|
|
1876
1930
|
function injectStyles(options) {
|
|
1877
1931
|
if (document.getElementById(STYLE_ID$1)) {
|
|
1878
|
-
|
|
1932
|
+
applyBrandingTheme(options.branding);
|
|
1879
1933
|
updateBlur(options.backdropBlur);
|
|
1880
1934
|
return;
|
|
1881
1935
|
}
|
|
1882
1936
|
const style = document.createElement('style');
|
|
1883
1937
|
style.id = STYLE_ID$1;
|
|
1938
|
+
style.dataset.svTheme = resolveTheme(options.branding);
|
|
1884
1939
|
style.textContent = getStyles(options);
|
|
1885
1940
|
document.head.appendChild(style);
|
|
1886
1941
|
}
|
|
@@ -1895,8 +1950,26 @@ function updateBlur(enabled) {
|
|
|
1895
1950
|
}
|
|
1896
1951
|
}
|
|
1897
1952
|
}
|
|
1898
|
-
|
|
1899
|
-
|
|
1953
|
+
/**
|
|
1954
|
+
* Re-theme the injected stylesheet when the resolved theme (light/dark) changes.
|
|
1955
|
+
*
|
|
1956
|
+
* Styles are first injected with default branding before config loads (so the
|
|
1957
|
+
* UI paints instantly), then `updateBranding` calls this with the tenant's real
|
|
1958
|
+
* `themeMode`. The theme is baked into the generated CSS (not runtime CSS
|
|
1959
|
+
* variables), so a theme switch requires regenerating the stylesheet - a no-op
|
|
1960
|
+
* when the theme is unchanged.
|
|
1961
|
+
*/
|
|
1962
|
+
function applyBrandingTheme(branding) {
|
|
1963
|
+
const style = document.getElementById(STYLE_ID$1);
|
|
1964
|
+
if (!style)
|
|
1965
|
+
return;
|
|
1966
|
+
const theme = resolveTheme(branding);
|
|
1967
|
+
if (style.dataset.svTheme === theme)
|
|
1968
|
+
return;
|
|
1969
|
+
style.dataset.svTheme = theme;
|
|
1970
|
+
style.textContent = getStyles({
|
|
1971
|
+
branding: branding ?? { companyName: '', logoLight: null, logoDark: null },
|
|
1972
|
+
});
|
|
1900
1973
|
}
|
|
1901
1974
|
function resolveTheme(branding) {
|
|
1902
1975
|
// Use themeMode from server config, default to light
|
|
@@ -1906,12 +1979,20 @@ function getStyles(options) {
|
|
|
1906
1979
|
const { branding, backdropBlur } = options;
|
|
1907
1980
|
const isDark = resolveTheme(branding) === 'dark';
|
|
1908
1981
|
const enableBlur = backdropBlur !== false;
|
|
1909
|
-
// Design tokens
|
|
1982
|
+
// Design tokens.
|
|
1983
|
+
//
|
|
1984
|
+
// The brand accent is driven by the `--sv-primary` / `--sv-primary-hover`
|
|
1985
|
+
// CSS custom properties so a host page (e.g. the SparkVault sign-in page) can
|
|
1986
|
+
// tint the whole flow to the tenant's brand color by setting them on `:root`.
|
|
1987
|
+
// The literals are the fallback - when no host sets the variables the UI is
|
|
1988
|
+
// pixel-identical to before. The focus glow is derived from the same accent
|
|
1989
|
+
// via color-mix so it tracks the brand too.
|
|
1990
|
+
const accent = 'var(--sv-primary, #4F46E5)';
|
|
1910
1991
|
const tokens = {
|
|
1911
1992
|
// Colors
|
|
1912
|
-
primary:
|
|
1913
|
-
primaryHover: '#4338CA',
|
|
1914
|
-
primaryLight:
|
|
1993
|
+
primary: accent,
|
|
1994
|
+
primaryHover: 'var(--sv-primary-hover, #4338CA)',
|
|
1995
|
+
primaryLight: `color-mix(in srgb, ${accent} ${isDark ? '20%' : '9%'}, transparent)`,
|
|
1915
1996
|
error: '#DC2626',
|
|
1916
1997
|
errorLight: isDark ? 'rgba(220, 38, 38, 0.15)' : '#FEF2F2',
|
|
1917
1998
|
errorBorder: isDark ? 'rgba(220, 38, 38, 0.3)' : '#FECACA',
|
|
@@ -1923,7 +2004,7 @@ function getStyles(options) {
|
|
|
1923
2004
|
// Borders
|
|
1924
2005
|
border: isDark ? '#262626' : '#E5E5E5',
|
|
1925
2006
|
borderHover: isDark ? '#404040' : '#D4D4D4',
|
|
1926
|
-
borderFocus:
|
|
2007
|
+
borderFocus: accent,
|
|
1927
2008
|
// Text
|
|
1928
2009
|
textPrimary: isDark ? '#FAFAFA' : '#0A0A0A',
|
|
1929
2010
|
textSecondary: isDark ? '#A3A3A3' : '#525252',
|
|
@@ -2021,11 +2102,11 @@ function getStyles(options) {
|
|
|
2021
2102
|
display: flex;
|
|
2022
2103
|
align-items: center;
|
|
2023
2104
|
justify-content: center;
|
|
2024
|
-
background:
|
|
2105
|
+
background: ${tokens.bgSubtle};
|
|
2025
2106
|
border: none;
|
|
2026
2107
|
border-radius: 8px;
|
|
2027
2108
|
cursor: pointer;
|
|
2028
|
-
color: ${tokens.
|
|
2109
|
+
color: ${tokens.textSecondary};
|
|
2029
2110
|
transition: background 0.15s ease, color 0.15s ease;
|
|
2030
2111
|
}
|
|
2031
2112
|
|
|
@@ -2074,6 +2155,7 @@ function getStyles(options) {
|
|
|
2074
2155
|
color: ${tokens.textSecondary};
|
|
2075
2156
|
margin: 0 0 16px 0;
|
|
2076
2157
|
text-align: center;
|
|
2158
|
+
text-wrap: balance;
|
|
2077
2159
|
}
|
|
2078
2160
|
|
|
2079
2161
|
.sv-subtitle strong {
|
|
@@ -3141,6 +3223,130 @@ function getStyles(options) {
|
|
|
3141
3223
|
padding-right: 32px;
|
|
3142
3224
|
}
|
|
3143
3225
|
|
|
3226
|
+
/* Bare mode: the host page owns the surface and chrome, so the container
|
|
3227
|
+
is transparent and edge-free and the body hugs its content. */
|
|
3228
|
+
.sv-inline-bare {
|
|
3229
|
+
border: none;
|
|
3230
|
+
border-radius: 0;
|
|
3231
|
+
background: transparent;
|
|
3232
|
+
height: auto;
|
|
3233
|
+
}
|
|
3234
|
+
|
|
3235
|
+
.sv-inline-bare > .sv-inline-body {
|
|
3236
|
+
min-height: 0;
|
|
3237
|
+
padding-left: 0;
|
|
3238
|
+
padding-right: 0;
|
|
3239
|
+
}
|
|
3240
|
+
|
|
3241
|
+
/* ========================================
|
|
3242
|
+
BRIDGE MODAL (host page, while the sign-in popup runs)
|
|
3243
|
+
======================================== */
|
|
3244
|
+
|
|
3245
|
+
.sv-bridge {
|
|
3246
|
+
text-align: center;
|
|
3247
|
+
padding: 4px 4px 6px;
|
|
3248
|
+
}
|
|
3249
|
+
|
|
3250
|
+
.sv-bridge-dots {
|
|
3251
|
+
display: flex;
|
|
3252
|
+
gap: 6px;
|
|
3253
|
+
align-items: center;
|
|
3254
|
+
justify-content: center;
|
|
3255
|
+
margin-bottom: 20px;
|
|
3256
|
+
}
|
|
3257
|
+
|
|
3258
|
+
.sv-bridge-dots span {
|
|
3259
|
+
width: 7px;
|
|
3260
|
+
height: 7px;
|
|
3261
|
+
border-radius: 50%;
|
|
3262
|
+
background: ${tokens.primary};
|
|
3263
|
+
animation: sv-bridge-pulse 1.3s ease-in-out infinite;
|
|
3264
|
+
}
|
|
3265
|
+
|
|
3266
|
+
.sv-bridge-dots span:nth-child(2) { animation-delay: 0.16s; }
|
|
3267
|
+
.sv-bridge-dots span:nth-child(3) { animation-delay: 0.32s; }
|
|
3268
|
+
|
|
3269
|
+
@keyframes sv-bridge-pulse {
|
|
3270
|
+
0%, 100% { opacity: 0.28; transform: translateY(0); }
|
|
3271
|
+
50% { opacity: 1; transform: translateY(-3px); }
|
|
3272
|
+
}
|
|
3273
|
+
|
|
3274
|
+
/* Warning shown under the logo only when the popup can't be confirmed -
|
|
3275
|
+
blocked, closed, or no result after a few seconds. Hidden on the happy
|
|
3276
|
+
path; appears with a gentle fade. */
|
|
3277
|
+
.sv-bridge-alert {
|
|
3278
|
+
display: flex;
|
|
3279
|
+
align-items: flex-start;
|
|
3280
|
+
gap: 10px;
|
|
3281
|
+
text-align: left;
|
|
3282
|
+
margin: 0 0 22px;
|
|
3283
|
+
padding: 11px 13px;
|
|
3284
|
+
border: 1px solid ${tokens.border};
|
|
3285
|
+
border-radius: 10px;
|
|
3286
|
+
background: ${tokens.bgSubtle};
|
|
3287
|
+
font-size: 13px;
|
|
3288
|
+
line-height: 1.45;
|
|
3289
|
+
opacity: 0;
|
|
3290
|
+
max-height: 0;
|
|
3291
|
+
padding-top: 0;
|
|
3292
|
+
padding-bottom: 0;
|
|
3293
|
+
margin-bottom: 0;
|
|
3294
|
+
border-width: 0;
|
|
3295
|
+
overflow: hidden;
|
|
3296
|
+
transition: opacity 0.25s ease;
|
|
3297
|
+
}
|
|
3298
|
+
|
|
3299
|
+
.sv-bridge-alert.sv-shown {
|
|
3300
|
+
opacity: 1;
|
|
3301
|
+
max-height: 120px;
|
|
3302
|
+
padding-top: 11px;
|
|
3303
|
+
padding-bottom: 11px;
|
|
3304
|
+
margin-bottom: 22px;
|
|
3305
|
+
border-width: 1px;
|
|
3306
|
+
}
|
|
3307
|
+
|
|
3308
|
+
.sv-bridge-alert-icon {
|
|
3309
|
+
flex-shrink: 0;
|
|
3310
|
+
width: 17px;
|
|
3311
|
+
height: 17px;
|
|
3312
|
+
margin-top: 1px;
|
|
3313
|
+
color: #d97706;
|
|
3314
|
+
}
|
|
3315
|
+
|
|
3316
|
+
/* Text stacked over the action, so the message keeps the full width and
|
|
3317
|
+
never wraps to a lone word beside a right-aligned button. */
|
|
3318
|
+
.sv-bridge-alert-body {
|
|
3319
|
+
display: flex;
|
|
3320
|
+
flex-direction: column;
|
|
3321
|
+
align-items: flex-start;
|
|
3322
|
+
gap: 7px;
|
|
3323
|
+
flex: 1;
|
|
3324
|
+
min-width: 0;
|
|
3325
|
+
line-height: 1.35;
|
|
3326
|
+
}
|
|
3327
|
+
|
|
3328
|
+
.sv-bridge-alert-text { color: ${tokens.textSecondary}; }
|
|
3329
|
+
|
|
3330
|
+
.sv-bridge-retry {
|
|
3331
|
+
padding: 0;
|
|
3332
|
+
background: none;
|
|
3333
|
+
border: none;
|
|
3334
|
+
font-family: inherit;
|
|
3335
|
+
font-size: 13px;
|
|
3336
|
+
font-weight: 600;
|
|
3337
|
+
color: ${tokens.primary};
|
|
3338
|
+
text-decoration: underline;
|
|
3339
|
+
text-underline-offset: 2px;
|
|
3340
|
+
cursor: pointer;
|
|
3341
|
+
}
|
|
3342
|
+
|
|
3343
|
+
.sv-bridge-retry:hover { color: ${tokens.primaryHover}; }
|
|
3344
|
+
.sv-bridge-retry:focus-visible { outline: 2px solid ${tokens.borderFocus}; outline-offset: 2px; border-radius: 4px; }
|
|
3345
|
+
|
|
3346
|
+
@media (prefers-reduced-motion: reduce) {
|
|
3347
|
+
.sv-bridge-dots span { animation: none; opacity: 0.5; }
|
|
3348
|
+
}
|
|
3349
|
+
|
|
3144
3350
|
/* ========================================
|
|
3145
3351
|
RESPONSIVE
|
|
3146
3352
|
======================================== */
|
|
@@ -3497,7 +3703,7 @@ const MODAL_ID$1 = 'sparkvault-identity-modal';
|
|
|
3497
3703
|
* Default branding used for immediate modal display before config loads.
|
|
3498
3704
|
* Uses neutral styling that works with both light and dark themes.
|
|
3499
3705
|
*/
|
|
3500
|
-
const DEFAULT_BRANDING$
|
|
3706
|
+
const DEFAULT_BRANDING$2 = {
|
|
3501
3707
|
companyName: '',
|
|
3502
3708
|
logoLight: null,
|
|
3503
3709
|
logoDark: null,
|
|
@@ -3523,7 +3729,7 @@ class ModalContainer {
|
|
|
3523
3729
|
*/
|
|
3524
3730
|
createLoading(options, onClose) {
|
|
3525
3731
|
return this.create({
|
|
3526
|
-
branding: DEFAULT_BRANDING$
|
|
3732
|
+
branding: DEFAULT_BRANDING$2,
|
|
3527
3733
|
backdropBlur: options.backdropBlur,
|
|
3528
3734
|
}, onClose);
|
|
3529
3735
|
}
|
|
@@ -3535,6 +3741,9 @@ class ModalContainer {
|
|
|
3535
3741
|
if (!this.elements)
|
|
3536
3742
|
return;
|
|
3537
3743
|
this.effectiveTheme = resolveTheme(branding);
|
|
3744
|
+
// Re-theme the stylesheet if the tenant's themeMode differs from the
|
|
3745
|
+
// default used at first paint.
|
|
3746
|
+
applyBrandingTheme(branding);
|
|
3538
3747
|
// Update header with real branding
|
|
3539
3748
|
const newHeader = this.createHeader(branding);
|
|
3540
3749
|
if (this.headerElement?.parentNode) {
|
|
@@ -5740,19 +5949,6 @@ const SPARKLINK_CSP_BLOCKED_ERROR = {
|
|
|
5740
5949
|
].join(' '),
|
|
5741
5950
|
code: 'sparklink_csp_blocked',
|
|
5742
5951
|
};
|
|
5743
|
-
/**
|
|
5744
|
-
* Navigate the browser. When the flow runs inside the embed iframe, the host
|
|
5745
|
-
* injects `onNavigate` (via VerifyOptions) so redirects move the customer's
|
|
5746
|
-
* top window rather than the iframe — providers refuse to be framed anyway.
|
|
5747
|
-
* Outside the iframe this falls back to a normal same-window navigation.
|
|
5748
|
-
*/
|
|
5749
|
-
function navigateWith(options, url) {
|
|
5750
|
-
if (options.onNavigate) {
|
|
5751
|
-
options.onNavigate(url);
|
|
5752
|
-
return;
|
|
5753
|
-
}
|
|
5754
|
-
window.location.href = url;
|
|
5755
|
-
}
|
|
5756
5952
|
class IdentityRenderer {
|
|
5757
5953
|
constructor(container, api, options, callbacks) {
|
|
5758
5954
|
// View management
|
|
@@ -6467,7 +6663,7 @@ class IdentityRenderer {
|
|
|
6467
6663
|
this.close();
|
|
6468
6664
|
this.safeOnSuccess(result);
|
|
6469
6665
|
if (typeof result.redirect === 'string' && result.redirect) {
|
|
6470
|
-
|
|
6666
|
+
window.location.href = result.redirect;
|
|
6471
6667
|
}
|
|
6472
6668
|
}
|
|
6473
6669
|
catch (error) {
|
|
@@ -6524,7 +6720,7 @@ class IdentityRenderer {
|
|
|
6524
6720
|
this.close();
|
|
6525
6721
|
this.safeOnSuccess(result.result);
|
|
6526
6722
|
if (typeof result.result.redirect === 'string' && result.result.redirect) {
|
|
6527
|
-
|
|
6723
|
+
window.location.href = result.result.redirect;
|
|
6528
6724
|
}
|
|
6529
6725
|
}
|
|
6530
6726
|
else if (this.renderBlockedInterstitial(result.errorCode)) ;
|
|
@@ -6589,19 +6785,12 @@ class IdentityRenderer {
|
|
|
6589
6785
|
}
|
|
6590
6786
|
handleSocialLogin(provider) {
|
|
6591
6787
|
this.setState({ view: 'oauth-pending', provider });
|
|
6592
|
-
// When embedded, social must originate from the host: the OAuth state and
|
|
6593
|
-
// redirect_uri belong to the customer's top origin, not this iframe (whose
|
|
6594
|
-
// sessionStorage and URL the return would never match). Hand it up.
|
|
6595
|
-
if (this.options.onSocial) {
|
|
6596
|
-
this.options.onSocial(provider);
|
|
6597
|
-
return;
|
|
6598
|
-
}
|
|
6599
6788
|
const state = generateState();
|
|
6600
6789
|
const redirectUri = window.location.origin + window.location.pathname;
|
|
6601
6790
|
sessionStorage.setItem('sv_oauth_state', state);
|
|
6602
6791
|
sessionStorage.setItem('sv_oauth_email', this.recipient);
|
|
6603
6792
|
const authUrl = this.api.getSocialAuthUrl(provider, redirectUri, state, this.verificationState.authContext);
|
|
6604
|
-
|
|
6793
|
+
window.location.href = authUrl;
|
|
6605
6794
|
}
|
|
6606
6795
|
normalizeError(error) {
|
|
6607
6796
|
if (error instanceof IdentityApiError) {
|
|
@@ -6706,7 +6895,7 @@ class IdentityRenderer {
|
|
|
6706
6895
|
this.safeOnSuccess(result);
|
|
6707
6896
|
this.close();
|
|
6708
6897
|
if (typeof result.redirect === 'string' && result.redirect) {
|
|
6709
|
-
|
|
6898
|
+
window.location.href = result.redirect;
|
|
6710
6899
|
}
|
|
6711
6900
|
}
|
|
6712
6901
|
/**
|
|
@@ -7185,290 +7374,286 @@ class IdentityRenderer {
|
|
|
7185
7374
|
}
|
|
7186
7375
|
}
|
|
7187
7376
|
|
|
7188
|
-
/* global HTMLIFrameElement requestAnimationFrame */
|
|
7189
7377
|
/**
|
|
7190
|
-
*
|
|
7378
|
+
* Dialog Launcher
|
|
7191
7379
|
*
|
|
7192
|
-
* Host-side half of the
|
|
7193
|
-
*
|
|
7194
|
-
* the
|
|
7195
|
-
*
|
|
7196
|
-
*
|
|
7197
|
-
*
|
|
7198
|
-
*
|
|
7380
|
+
* Host-side half of the popup login flow. Dialog-mode `verify()` opens a
|
|
7381
|
+
* TOP-LEVEL popup on the Identity origin **directly inside the triggering user
|
|
7382
|
+
* gesture** and, on the host page, shades it with a small branded **bridge
|
|
7383
|
+
* modal** ("continue in the secure window"). The popup (the `chrome: 'bare'`
|
|
7384
|
+
* sign-in page) collects the identifier and runs the whole flow first-party, so
|
|
7385
|
+
* login's `__Host-authsv_sso` cookie persists. Any `email`/`phone` passed to
|
|
7386
|
+
* `verify()` is forwarded as a prefill.
|
|
7199
7387
|
*
|
|
7200
|
-
* The
|
|
7201
|
-
*
|
|
7202
|
-
*
|
|
7388
|
+
* The popup must open synchronously in the gesture or the browser blocks it as
|
|
7389
|
+
* programmatic. `verify()` reaches `start()` through microtask-only awaits (the
|
|
7390
|
+
* redirect-result check does no I/O; the preloaded config resolves from cache),
|
|
7391
|
+
* so transient activation survives.
|
|
7392
|
+
*
|
|
7393
|
+
* It is one dialog. The happy path is clean: logo, a subtle animation, and
|
|
7394
|
+
* "continue in the secure window". A single warning appears under the logo only
|
|
7395
|
+
* when the popup can't be confirmed: it was blocked, it closed, or it never
|
|
7396
|
+
* posted a "ready" ping within `OPEN_TIMEOUT_MS` (so the open/load failed). Its
|
|
7397
|
+
* "Try again" reopens the popup. The header's close ✕ (or backdrop/Escape)
|
|
7398
|
+
* aborts and closes the popup.
|
|
7203
7399
|
*/
|
|
7204
|
-
/**
|
|
7205
|
-
const
|
|
7206
|
-
/**
|
|
7207
|
-
const
|
|
7208
|
-
|
|
7209
|
-
const SOCIAL_TYPE = 'sparkvault-identity-social';
|
|
7210
|
-
/** Sent by the widget once its modal has mounted — proof the frame is alive. */
|
|
7211
|
-
const READY_TYPE = 'sparkvault-identity-ready';
|
|
7400
|
+
/** `data.type` the sign-in popup posts back to the opener. */
|
|
7401
|
+
const LOGIN_RESULT_TYPE = 'sparkvault-login-result';
|
|
7402
|
+
/** `data.type` the sign-in page posts once it has loaded (a liveness ping). */
|
|
7403
|
+
const LOGIN_READY_TYPE = 'sparkvault-login-ready';
|
|
7404
|
+
const DEFAULT_BRANDING$1 = { companyName: '', logoLight: null, logoDark: null };
|
|
7212
7405
|
/**
|
|
7213
|
-
* How long to wait for the
|
|
7214
|
-
*
|
|
7215
|
-
*
|
|
7216
|
-
*
|
|
7217
|
-
* this bounds the "scroll locked, nothing on screen" failure to a few seconds
|
|
7218
|
-
* instead of leaving the host stuck until a manual refresh.
|
|
7406
|
+
* How long to wait for the popup's "ready" ping before warning that the open
|
|
7407
|
+
* may have failed. A real window loads the page and pings within ~1-2s, so this
|
|
7408
|
+
* never fires during normal use (however long the person then takes to sign in);
|
|
7409
|
+
* it only fires when the window opened but the page never loaded.
|
|
7219
7410
|
*/
|
|
7220
|
-
const
|
|
7221
|
-
|
|
7222
|
-
|
|
7411
|
+
const OPEN_TIMEOUT_MS = 8000;
|
|
7412
|
+
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
7413
|
+
function el(tag, className, text) {
|
|
7414
|
+
const node = document.createElement(tag);
|
|
7415
|
+
if (className)
|
|
7416
|
+
node.className = className;
|
|
7417
|
+
if (text != null)
|
|
7418
|
+
node.textContent = text;
|
|
7419
|
+
return node;
|
|
7420
|
+
}
|
|
7421
|
+
/** Small inline warning triangle; `currentColor` lets the CSS tint it amber. */
|
|
7422
|
+
function warningIcon() {
|
|
7423
|
+
const svg = document.createElementNS(SVG_NS, 'svg');
|
|
7424
|
+
svg.setAttribute('viewBox', '0 0 20 20');
|
|
7425
|
+
svg.setAttribute('fill', 'none');
|
|
7426
|
+
svg.classList.add('sv-bridge-alert-icon');
|
|
7427
|
+
const path = (d, attrs) => {
|
|
7428
|
+
const p = document.createElementNS(SVG_NS, 'path');
|
|
7429
|
+
p.setAttribute('d', d);
|
|
7430
|
+
for (const [k, v] of Object.entries(attrs))
|
|
7431
|
+
p.setAttribute(k, v);
|
|
7432
|
+
return p;
|
|
7433
|
+
};
|
|
7434
|
+
svg.appendChild(path('M10 2.75 18.25 17.25H1.75L10 2.75Z', {
|
|
7435
|
+
stroke: 'currentColor', 'stroke-width': '1.5', 'stroke-linejoin': 'round',
|
|
7436
|
+
}));
|
|
7437
|
+
svg.appendChild(path('M10 8.25v3.25', {
|
|
7438
|
+
stroke: 'currentColor', 'stroke-width': '1.5', 'stroke-linecap': 'round',
|
|
7439
|
+
}));
|
|
7440
|
+
const dot = document.createElementNS(SVG_NS, 'circle');
|
|
7441
|
+
dot.setAttribute('cx', '10');
|
|
7442
|
+
dot.setAttribute('cy', '14.5');
|
|
7443
|
+
dot.setAttribute('r', '0.95');
|
|
7444
|
+
dot.setAttribute('fill', 'currentColor');
|
|
7445
|
+
svg.appendChild(dot);
|
|
7446
|
+
return svg;
|
|
7447
|
+
}
|
|
7448
|
+
/**
|
|
7449
|
+
* Opens the sign-in popup for dialog-mode `verify()` and bridges its result
|
|
7450
|
+
* back, behind a single branded host-page modal.
|
|
7451
|
+
*/
|
|
7452
|
+
class DialogLauncher {
|
|
7453
|
+
constructor(config, api, options, callbacks) {
|
|
7223
7454
|
this.config = config;
|
|
7455
|
+
this.api = api;
|
|
7224
7456
|
this.options = options;
|
|
7225
7457
|
this.callbacks = callbacks;
|
|
7226
|
-
this.
|
|
7458
|
+
this.popupLauncher = new PopupLauncher();
|
|
7459
|
+
this.modal = null;
|
|
7460
|
+
this.alertEl = null;
|
|
7461
|
+
this.popupWindow = null;
|
|
7462
|
+
this.openTimer = null;
|
|
7227
7463
|
this.settled = false;
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
this.
|
|
7231
|
-
this.previousBodyOverflow = '';
|
|
7232
|
-
// Only ever trust messages from the Identity origin the SDK is configured
|
|
7233
|
-
// against — never the broader sparkvault.com family.
|
|
7464
|
+
// Bumped on every open so a superseded popup's late result or ready ping
|
|
7465
|
+
// (e.g. the prior window after "Try again") is ignored.
|
|
7466
|
+
this.generation = 0;
|
|
7234
7467
|
this.trustedOrigin = new URL(this.config.identityBaseUrl).origin;
|
|
7235
|
-
this.boundHandleMessage = (event) => this.handleMessage(event);
|
|
7236
|
-
this.boundHandleCspViolation = (event) => this.handleCspViolation(event);
|
|
7237
7468
|
}
|
|
7469
|
+
/** Shade the host with the bridge and open the popup in the caller's gesture. */
|
|
7238
7470
|
start() {
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
// Delegate WebAuthn into the cross-origin widget document so the ceremony
|
|
7243
|
-
// runs there. The widget response also opts in via Permissions-Policy.
|
|
7244
|
-
iframe.setAttribute('allow', 'publickey-credentials-get; publickey-credentials-create');
|
|
7245
|
-
iframe.style.cssText = [
|
|
7246
|
-
'position:fixed',
|
|
7247
|
-
'inset:0',
|
|
7248
|
-
'width:100%',
|
|
7249
|
-
'height:100%',
|
|
7250
|
-
'border:0',
|
|
7251
|
-
'margin:0',
|
|
7252
|
-
'padding:0',
|
|
7253
|
-
'background:transparent',
|
|
7254
|
-
'z-index:2147483647',
|
|
7255
|
-
].join(';');
|
|
7256
|
-
// Promote to its own compositing layer up front. iOS Safari can otherwise
|
|
7257
|
-
// leave a freshly-inserted fixed, full-viewport iframe loaded but UNPAINTED
|
|
7258
|
-
// until the next composite (a scroll, resize, or app foreground) — the
|
|
7259
|
-
// frame even runs, but the dialog only appears after an app switch.
|
|
7260
|
-
iframe.style.transform = 'translateZ(0)';
|
|
7261
|
-
iframe.style.willChange = 'transform';
|
|
7262
|
-
// A network-level load failure (DNS, connection reset) fires onerror; an
|
|
7263
|
-
// HTTP error body or a frame blocked from framing does not, which is what
|
|
7264
|
-
// the readiness timeout below covers.
|
|
7265
|
-
iframe.onerror = () => this.handleFrameUnavailable();
|
|
7266
|
-
this.iframe = iframe;
|
|
7267
|
-
// Lock host scroll while the modal (rendered inside the iframe) is open.
|
|
7268
|
-
this.previousBodyOverflow = document.body.style.overflow;
|
|
7269
|
-
document.body.style.overflow = 'hidden';
|
|
7270
|
-
window.addEventListener('message', this.boundHandleMessage);
|
|
7271
|
-
// A host-page CSP whose frame-src/child-src omits the Identity origin blocks
|
|
7272
|
-
// the iframe before it can load and fires no `onerror`. Catch the violation
|
|
7273
|
-
// so we fail over to the in-page flow at once instead of after the timeout.
|
|
7274
|
-
document.addEventListener('securitypolicyviolation', this.boundHandleCspViolation);
|
|
7275
|
-
document.body.appendChild(iframe);
|
|
7276
|
-
// Force the composite the iframe insertion may not have triggered on iOS,
|
|
7277
|
-
// so the dialog paints on the click rather than only after an app switch.
|
|
7278
|
-
this.forceComposite(iframe);
|
|
7279
|
-
this.readyTimer = setTimeout(() => this.handleFrameUnavailable(), FRAME_READY_TIMEOUT_MS);
|
|
7280
|
-
}
|
|
7281
|
-
/**
|
|
7282
|
-
* Nudge the browser to paint the just-inserted iframe on the next frame.
|
|
7283
|
-
* Reading layout forces a reflow; toggling a transform forces the compositor
|
|
7284
|
-
* to flush the new layer — the workaround for iOS Safari leaving a fixed
|
|
7285
|
-
* full-viewport iframe invisible until an unrelated repaint.
|
|
7286
|
-
*/
|
|
7287
|
-
forceComposite(iframe) {
|
|
7288
|
-
const paint = () => {
|
|
7289
|
-
if (!this.iframe)
|
|
7290
|
-
return;
|
|
7291
|
-
void iframe.offsetHeight;
|
|
7292
|
-
iframe.style.transform = 'translateZ(0) scale(1)';
|
|
7293
|
-
};
|
|
7294
|
-
if (typeof requestAnimationFrame === 'function') {
|
|
7295
|
-
requestAnimationFrame(paint);
|
|
7296
|
-
}
|
|
7297
|
-
else {
|
|
7298
|
-
setTimeout(paint, 16);
|
|
7299
|
-
}
|
|
7471
|
+
this.showBridge();
|
|
7472
|
+
this.openPopup();
|
|
7473
|
+
this.loadBranding();
|
|
7300
7474
|
}
|
|
7475
|
+
/** Tear down the bridge modal and close any popup it opened. */
|
|
7301
7476
|
close() {
|
|
7302
|
-
this.
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
this.
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7312
|
-
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
this.
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
* the customer's top origin so `consumeRedirectResult` validates them on
|
|
7346
|
-
* return. Mirrors the SDK's getSocialAuthUrl.
|
|
7347
|
-
*/
|
|
7348
|
-
startSocial(provider) {
|
|
7349
|
-
// Provider comes from the trusted widget origin, but never build a URL from
|
|
7350
|
-
// an unexpected value.
|
|
7351
|
-
if (!/^[a-z0-9_]+$/i.test(provider))
|
|
7352
|
-
return;
|
|
7353
|
-
const state = generateState();
|
|
7354
|
-
try {
|
|
7355
|
-
sessionStorage.setItem('sv_oauth_state', state);
|
|
7356
|
-
}
|
|
7357
|
-
catch {
|
|
7358
|
-
// Storage disabled (private mode): proceed; the backend still binds state.
|
|
7359
|
-
}
|
|
7360
|
-
const url = new URL(`${this.config.identityBaseUrl}/${this.config.accountId}/social/${provider}`);
|
|
7361
|
-
url.searchParams.set('redirect_uri', window.location.origin + window.location.pathname);
|
|
7362
|
-
url.searchParams.set('state', state);
|
|
7477
|
+
this.clearOpenTimer();
|
|
7478
|
+
this.closePopup();
|
|
7479
|
+
this.modal?.destroy();
|
|
7480
|
+
this.modal = null;
|
|
7481
|
+
this.alertEl = null;
|
|
7482
|
+
}
|
|
7483
|
+
openPopup() {
|
|
7484
|
+
const generation = ++this.generation;
|
|
7485
|
+
this.popupLauncher
|
|
7486
|
+
.openPopup({
|
|
7487
|
+
url: this.buildPopupUrl(),
|
|
7488
|
+
windowName: 'sparkvault-login',
|
|
7489
|
+
resultType: LOGIN_RESULT_TYPE,
|
|
7490
|
+
readyType: LOGIN_READY_TYPE,
|
|
7491
|
+
trustedOrigin: this.trustedOrigin,
|
|
7492
|
+
onOpen: (popup) => {
|
|
7493
|
+
if (generation !== this.generation)
|
|
7494
|
+
return;
|
|
7495
|
+
this.popupWindow = popup;
|
|
7496
|
+
this.scheduleOpenWarning();
|
|
7497
|
+
},
|
|
7498
|
+
// The page loaded and pinged back — the open succeeded, so cancel the
|
|
7499
|
+
// open-failure warning no matter how long the person now takes.
|
|
7500
|
+
onReady: () => { if (generation === this.generation)
|
|
7501
|
+
this.clearOpenTimer(); },
|
|
7502
|
+
})
|
|
7503
|
+
.then((message) => { if (generation === this.generation)
|
|
7504
|
+
this.handleResult(message); })
|
|
7505
|
+
.catch((error) => { if (generation === this.generation)
|
|
7506
|
+
this.handleError(error); });
|
|
7507
|
+
}
|
|
7508
|
+
buildPopupUrl() {
|
|
7509
|
+
const params = new URLSearchParams({ origin: window.location.origin });
|
|
7510
|
+
// Identifier prefill - the popup collects it itself when absent.
|
|
7511
|
+
if (this.options.email) {
|
|
7512
|
+
params.set('email', this.options.email);
|
|
7513
|
+
}
|
|
7514
|
+
else if (this.options.phone) {
|
|
7515
|
+
params.set('phone', this.options.phone);
|
|
7516
|
+
}
|
|
7517
|
+
// Auth context, in the query shape the sign-in page reads server-side:
|
|
7518
|
+
// OIDC rides `auth_request`; simple redirect rides `mode=simple` + the
|
|
7519
|
+
// opaque `session` (the page loads success/failure URLs from the session).
|
|
7363
7520
|
const authContext = this.options.authContext;
|
|
7364
7521
|
if (authContext?.authRequestId) {
|
|
7365
|
-
|
|
7522
|
+
params.set('auth_request', authContext.authRequestId);
|
|
7366
7523
|
}
|
|
7367
|
-
if (authContext?.simpleMode) {
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
: {
|
|
7371
|
-
success_url: authContext.simpleMode.successUrl,
|
|
7372
|
-
failure_url: authContext.simpleMode.failureUrl,
|
|
7373
|
-
state: authContext.simpleMode.state,
|
|
7374
|
-
};
|
|
7375
|
-
url.searchParams.set('simple_mode', JSON.stringify(simpleMode));
|
|
7524
|
+
else if (authContext?.simpleMode?.sessionId) {
|
|
7525
|
+
params.set('mode', 'simple');
|
|
7526
|
+
params.set('session', authContext.simpleMode.sessionId);
|
|
7376
7527
|
}
|
|
7377
|
-
this.
|
|
7378
|
-
window.location.href = url.toString();
|
|
7528
|
+
return `${this.config.identityBaseUrl}/${this.config.accountId}/signin?${params}`;
|
|
7379
7529
|
}
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
* resolves to http(s). The sender is already constrained to the trusted
|
|
7383
|
-
* widget origin, but defense-in-depth across the SparkVault->customer
|
|
7384
|
-
* boundary: compromised widget-origin code must never escalate into script
|
|
7385
|
-
* execution on the embedding page via a javascript:/data: navigation.
|
|
7386
|
-
*/
|
|
7387
|
-
safeNavigate(url) {
|
|
7388
|
-
let resolved;
|
|
7389
|
-
try {
|
|
7390
|
-
resolved = new URL(url, window.location.href);
|
|
7391
|
-
}
|
|
7392
|
-
catch {
|
|
7530
|
+
handleResult(message) {
|
|
7531
|
+
if (this.settled)
|
|
7393
7532
|
return;
|
|
7394
|
-
|
|
7395
|
-
|
|
7533
|
+
if (message.success && message.data) {
|
|
7534
|
+
const result = {
|
|
7535
|
+
token: message.data.token || '',
|
|
7536
|
+
identity: message.data.identity || '',
|
|
7537
|
+
identityType: message.data.identity_type || 'email',
|
|
7538
|
+
svid: message.data.svid,
|
|
7539
|
+
sessionId: message.data.session_id,
|
|
7540
|
+
refreshToken: message.data.refresh_token,
|
|
7541
|
+
redirect: message.data.redirect,
|
|
7542
|
+
};
|
|
7543
|
+
this.finish();
|
|
7544
|
+
this.callbacks.onSuccess(result);
|
|
7396
7545
|
return;
|
|
7397
7546
|
}
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
if (this.options.email)
|
|
7404
|
-
url.searchParams.set('email', this.options.email);
|
|
7405
|
-
if (this.options.phone)
|
|
7406
|
-
url.searchParams.set('phone', this.options.phone);
|
|
7407
|
-
if (this.options.backdropBlur === false)
|
|
7408
|
-
url.searchParams.set('backdrop_blur', 'false');
|
|
7409
|
-
const authContext = this.options.authContext;
|
|
7410
|
-
if (authContext?.authRequestId) {
|
|
7411
|
-
url.searchParams.set('auth_request_id', authContext.authRequestId);
|
|
7412
|
-
}
|
|
7413
|
-
if (authContext?.simpleMode) {
|
|
7414
|
-
url.searchParams.set('simple_mode', JSON.stringify({
|
|
7415
|
-
success_url: authContext.simpleMode.successUrl,
|
|
7416
|
-
failure_url: authContext.simpleMode.failureUrl,
|
|
7417
|
-
state: authContext.simpleMode.state,
|
|
7418
|
-
session_id: authContext.simpleMode.sessionId,
|
|
7419
|
-
}));
|
|
7547
|
+
if (message.error === 'cancelled') {
|
|
7548
|
+
// The person explicitly backed out inside the popup — end the flow rather
|
|
7549
|
+
// than offer to reopen to the same place.
|
|
7550
|
+
this.finishCancel();
|
|
7551
|
+
return;
|
|
7420
7552
|
}
|
|
7421
|
-
|
|
7553
|
+
this.finish();
|
|
7554
|
+
this.callbacks.onError(new SparkVaultError(message.message || message.error || 'Verification failed', message.errorCode || message.error || 'verification_failed'));
|
|
7422
7555
|
}
|
|
7423
|
-
|
|
7424
|
-
if (
|
|
7425
|
-
return;
|
|
7426
|
-
if (this.iframe && event.source !== this.iframe.contentWindow)
|
|
7556
|
+
handleError(error) {
|
|
7557
|
+
if (this.settled)
|
|
7427
7558
|
return;
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
// Cancel the readiness timeout so a slow-but-working frame is never torn
|
|
7433
|
-
// down and recovered in-page.
|
|
7434
|
-
if (data.type === READY_TYPE) {
|
|
7435
|
-
this.ready = true;
|
|
7436
|
-
this.clearReadyTimer();
|
|
7559
|
+
// Blocked (never opened) or closed (gone) - the popup can't be confirmed,
|
|
7560
|
+
// so surface the warning so the user can reopen it.
|
|
7561
|
+
if (error instanceof PopupBlockedError || error instanceof UserCancelledError) {
|
|
7562
|
+
this.showAlert();
|
|
7437
7563
|
return;
|
|
7438
7564
|
}
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
|
|
7565
|
+
this.finish();
|
|
7566
|
+
this.callbacks.onError(error instanceof Error ? error : new Error(String(error)));
|
|
7567
|
+
}
|
|
7568
|
+
/** Create the bridge modal (once) and render its single happy-path body. */
|
|
7569
|
+
showBridge() {
|
|
7570
|
+
if (this.settled)
|
|
7443
7571
|
return;
|
|
7572
|
+
if (!this.modal) {
|
|
7573
|
+
this.modal = new ModalContainer();
|
|
7574
|
+
this.modal.create({ branding: DEFAULT_BRANDING$1, backdropBlur: this.options.backdropBlur }, () => this.abort());
|
|
7444
7575
|
}
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
// iframe; on return the host SDK consumes the redirect token.
|
|
7448
|
-
if (data.type === REDIRECT_TYPE && typeof data.url === 'string') {
|
|
7449
|
-
this.clearReadyTimer();
|
|
7450
|
-
this.safeNavigate(data.url);
|
|
7576
|
+
const body = this.modal.getBody();
|
|
7577
|
+
if (!body)
|
|
7451
7578
|
return;
|
|
7579
|
+
clearChildren(body);
|
|
7580
|
+
const wrap = el('div', 'sv-bridge');
|
|
7581
|
+
// Warning under the logo - collapsed until the popup can't be confirmed.
|
|
7582
|
+
const alert = el('div', 'sv-bridge-alert');
|
|
7583
|
+
alert.appendChild(warningIcon());
|
|
7584
|
+
const alertBody = el('div', 'sv-bridge-alert-body');
|
|
7585
|
+
alertBody.appendChild(el('span', 'sv-bridge-alert-text', 'The sign-in window may not have opened.'));
|
|
7586
|
+
const retry = el('button', 'sv-bridge-retry', 'Try again');
|
|
7587
|
+
retry.type = 'button';
|
|
7588
|
+
retry.addEventListener('click', () => this.retry());
|
|
7589
|
+
alertBody.appendChild(retry);
|
|
7590
|
+
alert.appendChild(alertBody);
|
|
7591
|
+
this.alertEl = alert;
|
|
7592
|
+
const dots = el('div', 'sv-bridge-dots');
|
|
7593
|
+
dots.append(el('span'), el('span'), el('span'));
|
|
7594
|
+
wrap.append(alert, dots, el('h3', 'sv-title', 'Continue in the secure window'), el('p', 'sv-subtitle', 'Finish signing in there. This page updates on its own.'));
|
|
7595
|
+
body.appendChild(wrap);
|
|
7596
|
+
}
|
|
7597
|
+
showAlert() {
|
|
7598
|
+
this.clearOpenTimer();
|
|
7599
|
+
this.alertEl?.classList.add('sv-shown');
|
|
7600
|
+
}
|
|
7601
|
+
hideAlert() {
|
|
7602
|
+
this.alertEl?.classList.remove('sv-shown');
|
|
7603
|
+
}
|
|
7604
|
+
scheduleOpenWarning() {
|
|
7605
|
+
this.clearOpenTimer();
|
|
7606
|
+
this.openTimer = setTimeout(() => this.showAlert(), OPEN_TIMEOUT_MS);
|
|
7607
|
+
}
|
|
7608
|
+
clearOpenTimer() {
|
|
7609
|
+
if (this.openTimer) {
|
|
7610
|
+
clearTimeout(this.openTimer);
|
|
7611
|
+
this.openTimer = null;
|
|
7612
|
+
}
|
|
7613
|
+
}
|
|
7614
|
+
/** "Try again": close any current popup and reopen a fresh one. */
|
|
7615
|
+
retry() {
|
|
7616
|
+
this.hideAlert();
|
|
7617
|
+
this.closePopup();
|
|
7618
|
+
this.openPopup();
|
|
7619
|
+
}
|
|
7620
|
+
/** Fetch branding once and drop the tenant logo into the modal header. */
|
|
7621
|
+
loadBranding() {
|
|
7622
|
+
this.api
|
|
7623
|
+
.getConfig()
|
|
7624
|
+
.then((config) => {
|
|
7625
|
+
if (config.branding && this.modal)
|
|
7626
|
+
this.modal.updateBranding(config.branding);
|
|
7627
|
+
})
|
|
7628
|
+
.catch(() => {
|
|
7629
|
+
// Keep the default chrome - the popup itself is fully branded.
|
|
7630
|
+
});
|
|
7631
|
+
}
|
|
7632
|
+
closePopup() {
|
|
7633
|
+
if (this.popupWindow && !this.popupWindow.closed) {
|
|
7634
|
+
try {
|
|
7635
|
+
this.popupWindow.close();
|
|
7636
|
+
}
|
|
7637
|
+
catch {
|
|
7638
|
+
// Cross-origin navigation or already gone - nothing to close.
|
|
7639
|
+
}
|
|
7452
7640
|
}
|
|
7453
|
-
|
|
7641
|
+
this.popupWindow = null;
|
|
7642
|
+
}
|
|
7643
|
+
/** Explicit abort (close ✕, backdrop, Escape): close the popup and cancel. */
|
|
7644
|
+
abort() {
|
|
7645
|
+
this.finishCancel();
|
|
7646
|
+
}
|
|
7647
|
+
finish() {
|
|
7648
|
+
this.settled = true;
|
|
7649
|
+
this.close();
|
|
7650
|
+
}
|
|
7651
|
+
finishCancel() {
|
|
7652
|
+
if (this.settled)
|
|
7454
7653
|
return;
|
|
7455
7654
|
this.settled = true;
|
|
7456
7655
|
this.close();
|
|
7457
|
-
|
|
7458
|
-
const result = data.result;
|
|
7459
|
-
this.callbacks.onSuccess(result);
|
|
7460
|
-
// Mirror the renderer's belt-and-suspenders: complete a server-issued
|
|
7461
|
-
// redirect from the host's own top window if the customer didn't.
|
|
7462
|
-
if (typeof result.redirect === 'string' && result.redirect) {
|
|
7463
|
-
this.safeNavigate(result.redirect);
|
|
7464
|
-
}
|
|
7465
|
-
}
|
|
7466
|
-
else if (data.cancelled) {
|
|
7467
|
-
this.callbacks.onCancel();
|
|
7468
|
-
}
|
|
7469
|
-
else {
|
|
7470
|
-
this.callbacks.onError(new Error(data.error || 'Verification failed'));
|
|
7471
|
-
}
|
|
7656
|
+
this.callbacks.onCancel();
|
|
7472
7657
|
}
|
|
7473
7658
|
}
|
|
7474
7659
|
|
|
@@ -7519,7 +7704,9 @@ class InlineContainer {
|
|
|
7519
7704
|
injectStyles(styleOptions);
|
|
7520
7705
|
// Create main container
|
|
7521
7706
|
this.container = document.createElement('div');
|
|
7522
|
-
this.container.className =
|
|
7707
|
+
this.container.className = this.containerOptions.bare
|
|
7708
|
+
? 'sv-inline-container sv-inline-bare'
|
|
7709
|
+
: 'sv-inline-container';
|
|
7523
7710
|
// Create header if enabled
|
|
7524
7711
|
if (this.containerOptions.showHeader) {
|
|
7525
7712
|
this.header = this.createHeader({
|
|
@@ -7563,6 +7750,7 @@ class InlineContainer {
|
|
|
7563
7750
|
if (!this.container)
|
|
7564
7751
|
return;
|
|
7565
7752
|
this.effectiveTheme = resolveTheme(branding);
|
|
7753
|
+
applyBrandingTheme(branding);
|
|
7566
7754
|
// Update header with real branding
|
|
7567
7755
|
if (this.containerOptions.showHeader && this.header) {
|
|
7568
7756
|
const newHeader = this.createHeader(branding);
|
|
@@ -7802,7 +7990,7 @@ function isTokenClaims(payload) {
|
|
|
7802
7990
|
class IdentityModule {
|
|
7803
7991
|
constructor(config) {
|
|
7804
7992
|
this.renderer = null;
|
|
7805
|
-
this.
|
|
7993
|
+
this.launcher = null;
|
|
7806
7994
|
this.config = config;
|
|
7807
7995
|
this.api = new IdentityApi(config);
|
|
7808
7996
|
// Preload config in background for instant dialog opening
|
|
@@ -7936,9 +8124,9 @@ class IdentityModule {
|
|
|
7936
8124
|
options.onSuccess?.(redirectResult);
|
|
7937
8125
|
return redirectResult;
|
|
7938
8126
|
}
|
|
7939
|
-
if (this.
|
|
7940
|
-
this.
|
|
7941
|
-
this.
|
|
8127
|
+
if (this.launcher) {
|
|
8128
|
+
this.launcher.close();
|
|
8129
|
+
this.launcher = null;
|
|
7942
8130
|
}
|
|
7943
8131
|
if (this.renderer) {
|
|
7944
8132
|
this.renderer.close();
|
|
@@ -7954,9 +8142,9 @@ class IdentityModule {
|
|
|
7954
8142
|
backdropBlur: options.backdropBlur ?? this.config.backdropBlur,
|
|
7955
8143
|
};
|
|
7956
8144
|
// Inline rendering (target) and explicit local mode run the flow in this
|
|
7957
|
-
// document. Dialog mode
|
|
7958
|
-
//
|
|
7959
|
-
// is how the
|
|
8145
|
+
// document. Dialog mode renders a thin launcher and opens a top-level popup
|
|
8146
|
+
// on the Identity origin for the flow (so login's first-party SSO cookie
|
|
8147
|
+
// persists). `renderMode: 'local'` is how the popup itself runs the flow.
|
|
7960
8148
|
const isInline = !!options.target;
|
|
7961
8149
|
const useLocal = options.renderMode === 'local' || isInline;
|
|
7962
8150
|
let resolveRef;
|
|
@@ -7984,41 +8172,28 @@ class IdentityModule {
|
|
|
7984
8172
|
this.renderer = new IdentityRenderer(container, this.api, mergedOptions, hostCallbacks);
|
|
7985
8173
|
this.renderer.start().catch((error) => {
|
|
7986
8174
|
// A startup failure must surface inside the SparkVault dialog, never
|
|
7987
|
-
// close it silently.
|
|
7988
|
-
//
|
|
7989
|
-
// iframe — leaving the user with a vanished dialog and no error. Render
|
|
7990
|
-
// the error in-dialog instead (consistent with every in-flow error);
|
|
7991
|
-
// the promise settles later via the user's retry/close.
|
|
8175
|
+
// close it silently. Render the error in-dialog instead (consistent with
|
|
8176
|
+
// every in-flow error); the promise settles later via retry/close.
|
|
7992
8177
|
this.renderer?.showStartupError(error);
|
|
7993
8178
|
});
|
|
7994
8179
|
};
|
|
7995
8180
|
if (!useLocal) {
|
|
7996
8181
|
// When the preloaded config has already failed *permanently* — this origin
|
|
7997
8182
|
// is not a verified domain, or the account hasn't configured Identity —
|
|
7998
|
-
// the
|
|
7999
|
-
//
|
|
8000
|
-
//
|
|
8001
|
-
// to the iframe so one-tap passkey login is preserved.
|
|
8183
|
+
// the popup cannot help: the IdP will reject the unverified origin. Render
|
|
8184
|
+
// the error dialog in-page right away instead. Transient failures fall
|
|
8185
|
+
// through to the launcher, which surfaces them in its own dialog.
|
|
8002
8186
|
if (await this.preloadedConfigPermanentlyFailed()) {
|
|
8003
8187
|
startLocalRender(new ModalContainer());
|
|
8004
8188
|
return settledPromise;
|
|
8005
8189
|
}
|
|
8006
|
-
this.
|
|
8007
|
-
|
|
8008
|
-
onFrameUnavailable: () => {
|
|
8009
|
-
// The hosted widget iframe could not load or mount (blocked from
|
|
8010
|
-
// framing, network failure, blank render, or its in-frame SDK never
|
|
8011
|
-
// loaded). Recover by running the verification flow in this document
|
|
8012
|
-
// — the same local path inline rendering uses — so login still works
|
|
8013
|
-
// and the host scroll lock the embedder set has already been released.
|
|
8014
|
-
this.embedder = null;
|
|
8015
|
-
startLocalRender(new ModalContainer());
|
|
8016
|
-
},
|
|
8017
|
-
});
|
|
8018
|
-
this.embedder.start();
|
|
8190
|
+
this.launcher = new DialogLauncher(this.config, this.api, mergedOptions, hostCallbacks);
|
|
8191
|
+
this.launcher.start();
|
|
8019
8192
|
return settledPromise;
|
|
8020
8193
|
}
|
|
8021
|
-
startLocalRender(isInline
|
|
8194
|
+
startLocalRender(isInline
|
|
8195
|
+
? this.createInlineContainer(options.target, options.chrome === 'bare')
|
|
8196
|
+
: new ModalContainer());
|
|
8022
8197
|
return settledPromise;
|
|
8023
8198
|
}
|
|
8024
8199
|
/**
|
|
@@ -8180,14 +8355,13 @@ class IdentityModule {
|
|
|
8180
8355
|
/**
|
|
8181
8356
|
* Close the identity dialog/inline UI if open.
|
|
8182
8357
|
*
|
|
8183
|
-
* Tears down whichever surface is active: the
|
|
8184
|
-
*
|
|
8185
|
-
* or the local renderer (inline / local mode).
|
|
8358
|
+
* Tears down whichever surface is active: the dialog launcher (default dialog
|
|
8359
|
+
* mode) or the local renderer (inline / local mode).
|
|
8186
8360
|
*/
|
|
8187
8361
|
close() {
|
|
8188
|
-
if (this.
|
|
8189
|
-
this.
|
|
8190
|
-
this.
|
|
8362
|
+
if (this.launcher) {
|
|
8363
|
+
this.launcher.close();
|
|
8364
|
+
this.launcher = null;
|
|
8191
8365
|
}
|
|
8192
8366
|
if (this.renderer) {
|
|
8193
8367
|
this.renderer.close();
|
|
@@ -8196,12 +8370,12 @@ class IdentityModule {
|
|
|
8196
8370
|
}
|
|
8197
8371
|
/**
|
|
8198
8372
|
* Whether the preloaded config has already settled as a *permanent* failure
|
|
8199
|
-
* the
|
|
8200
|
-
*
|
|
8201
|
-
*
|
|
8202
|
-
*
|
|
8203
|
-
*
|
|
8204
|
-
*
|
|
8373
|
+
* the popup can't surface (origin not allowed, or product not configured).
|
|
8374
|
+
* Used to skip the launcher and show the error dialog in-page immediately.
|
|
8375
|
+
* Returns false — proceed to the launcher — when config is not preloaded,
|
|
8376
|
+
* still in flight (raced against a short timeout so the common path is never
|
|
8377
|
+
* delayed), resolved, or failed only transiently (the launcher surfaces a
|
|
8378
|
+
* transient failure in its own dialog).
|
|
8205
8379
|
*/
|
|
8206
8380
|
async preloadedConfigPermanentlyFailed() {
|
|
8207
8381
|
if (!this.api.isConfigPreloaded())
|
|
@@ -8224,7 +8398,7 @@ class IdentityModule {
|
|
|
8224
8398
|
/**
|
|
8225
8399
|
* Resolve target to an HTMLElement.
|
|
8226
8400
|
*/
|
|
8227
|
-
createInlineContainer(target) {
|
|
8401
|
+
createInlineContainer(target, bare = false) {
|
|
8228
8402
|
let element;
|
|
8229
8403
|
if (typeof target === 'string') {
|
|
8230
8404
|
const found = document.querySelector(target);
|
|
@@ -8239,7 +8413,9 @@ class IdentityModule {
|
|
|
8239
8413
|
else {
|
|
8240
8414
|
throw new ValidationError('Target must be a CSS selector string or HTMLElement');
|
|
8241
8415
|
}
|
|
8242
|
-
|
|
8416
|
+
// Bare chrome: the host page owns logo + footer + background, so drop the
|
|
8417
|
+
// container's own surface and the SparkVault footer.
|
|
8418
|
+
return new InlineContainer(element, bare ? { bare: true, showFooter: false } : {});
|
|
8243
8419
|
}
|
|
8244
8420
|
// Public-API aliases. The documented method names in the customer-facing
|
|
8245
8421
|
// SDK README and the API docs are pop() and render(); verify() is the
|