@sparkvault/sdk-js 8.1.1 → 8.2.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/README.md +34 -33
- package/dist/config.d.ts +1 -1
- package/dist/index.d.ts +38 -33
- package/dist/products/identity/index.d.ts +30 -33
- package/dist/products/identity/types.d.ts +8 -0
- package/dist/sparkvault.cjs.js +47 -46
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +47 -46
- 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
|
@@ -153,7 +153,7 @@ const DEFAULT_ALLOWED_DOWNLOAD_HOST_PATTERNS = [
|
|
|
153
153
|
/\.cloudfront\.net$/i,
|
|
154
154
|
];
|
|
155
155
|
const API_URL = 'https://api.sparkvault.com';
|
|
156
|
-
const IDENTITY_URL = 'https://
|
|
156
|
+
const IDENTITY_URL = 'https://auth.sparkvault.com';
|
|
157
157
|
const PORTAL_URL = `https://${SPARKVAULT_AUTH_HOST}`;
|
|
158
158
|
function normalizeApiBaseUrl(url) {
|
|
159
159
|
const trimmed = url.replace(/\/+$/, '');
|
|
@@ -5939,11 +5939,18 @@ class OriginNotAllowedView {
|
|
|
5939
5939
|
* Uses extracted handlers for OTP and Passkey operations.
|
|
5940
5940
|
*/
|
|
5941
5941
|
/**
|
|
5942
|
-
* End-user copy for a blocked Identity. Intentionally
|
|
5943
|
-
* the trial, billing, usage, or any owner-facing internal.
|
|
5944
|
-
*
|
|
5942
|
+
* End-user copy for a blocked Identity. Intentionally non-leaky — it never names
|
|
5943
|
+
* the trial, billing, usage, or any owner-facing internal. When the site's
|
|
5944
|
+
* company name is known it is surfaced so the screen reads as the site's own and
|
|
5945
|
+
* the visitor is pointed back to the site for help (never to SparkVault). The
|
|
5946
|
+
* site owner is nudged to subscribe through their own dashboard and emails.
|
|
5945
5947
|
*/
|
|
5946
|
-
|
|
5948
|
+
function blockedSignInMessage(companyName) {
|
|
5949
|
+
const name = companyName?.trim();
|
|
5950
|
+
return name
|
|
5951
|
+
? `Sign-in for ${name} is temporarily unavailable. Please contact them for assistance.`
|
|
5952
|
+
: 'Sign-in is temporarily unavailable. Please contact the site owner for assistance.';
|
|
5953
|
+
}
|
|
5947
5954
|
const BLOCKED_ERROR_CODES = new Set(IDENTITY_BLOCKED_ERROR_CODES);
|
|
5948
5955
|
const SPARKLINK_CSP_BLOCKED_ERROR = {
|
|
5949
5956
|
message: [
|
|
@@ -6582,7 +6589,7 @@ class IdentityRenderer {
|
|
|
6582
6589
|
this.setState({
|
|
6583
6590
|
view: 'error',
|
|
6584
6591
|
code,
|
|
6585
|
-
message:
|
|
6592
|
+
message: blockedSignInMessage(this.verificationState.sdkConfig?.branding?.companyName),
|
|
6586
6593
|
});
|
|
6587
6594
|
return true;
|
|
6588
6595
|
}
|
|
@@ -7963,17 +7970,14 @@ function attachClickHandler(selector, onClick) {
|
|
|
7963
7970
|
/**
|
|
7964
7971
|
* Identity Module
|
|
7965
7972
|
*
|
|
7966
|
-
*
|
|
7973
|
+
* Passwordless sign-in through the first-party SparkVault popup.
|
|
7967
7974
|
* Supports passkey, OTP, SparkLink, and social authentication.
|
|
7968
7975
|
*
|
|
7969
|
-
* @example
|
|
7970
|
-
* const result = await sv.products.identity.
|
|
7976
|
+
* @example Programmatic
|
|
7977
|
+
* const result = await sv.products.identity.signIn();
|
|
7971
7978
|
*
|
|
7972
|
-
* @example
|
|
7979
|
+
* @example Attached to clicks
|
|
7973
7980
|
* sv.products.identity.attach('.login-btn');
|
|
7974
|
-
*
|
|
7975
|
-
* @example Inline mode
|
|
7976
|
-
* const result = await sv.products.identity.verify({ target: '#auth-container' });
|
|
7977
7981
|
*/
|
|
7978
7982
|
const PORTAL_SECTIONS = ['home', 'identity', 'security', 'sessions', 'sites'];
|
|
7979
7983
|
function isTokenClaims(payload) {
|
|
@@ -8045,7 +8049,7 @@ class IdentityModule {
|
|
|
8045
8049
|
* the browser surfaces a "Continue as …" prompt with no popup, redirect, or
|
|
8046
8050
|
* typing. Requires a registered `clientId` in the SDK config and a browser
|
|
8047
8051
|
* with FedCM support — callers should feature-detect with
|
|
8048
|
-
* `IdentityModule.isFedcmAvailable()` and fall back to `
|
|
8052
|
+
* `IdentityModule.isFedcmAvailable()` and fall back to `signIn()` otherwise.
|
|
8049
8053
|
*
|
|
8050
8054
|
* @returns the verified result, or `null` when the browser has no FedCM
|
|
8051
8055
|
* support (so the caller can fall back). Throws `UserCancelledError` when the
|
|
@@ -8053,8 +8057,8 @@ class IdentityModule {
|
|
|
8053
8057
|
*
|
|
8054
8058
|
* @example
|
|
8055
8059
|
* const result = (await sv.products.identity.isFedcmAvailable())
|
|
8056
|
-
* ? await sv.products.identity.signInWithFedcm().catch(() => sv.products.identity.
|
|
8057
|
-
* : await sv.products.identity.
|
|
8060
|
+
* ? await sv.products.identity.signInWithFedcm().catch(() => sv.products.identity.signIn())
|
|
8061
|
+
* : await sv.products.identity.signIn();
|
|
8058
8062
|
*/
|
|
8059
8063
|
async signInWithFedcm(options = {}) {
|
|
8060
8064
|
if (!IdentityModule.isFedcmAvailable()) {
|
|
@@ -8107,22 +8111,26 @@ class IdentityModule {
|
|
|
8107
8111
|
typeof navigator.credentials.get === 'function');
|
|
8108
8112
|
}
|
|
8109
8113
|
/**
|
|
8110
|
-
*
|
|
8114
|
+
* Open the SparkVault sign-in popup and resolve with the verified identity.
|
|
8111
8115
|
*
|
|
8112
|
-
*
|
|
8113
|
-
*
|
|
8116
|
+
* This is the single programmatic entry point; `attach()` binds it to element
|
|
8117
|
+
* clicks. There is no inline/in-page mode — sign-in always runs in the
|
|
8118
|
+
* first-party popup on the Identity origin, so login's `__Host-` hub cookie is
|
|
8119
|
+
* a first-party write and cross-domain SSO works.
|
|
8114
8120
|
*
|
|
8115
|
-
* @example
|
|
8116
|
-
* const result = await sv.products.identity.
|
|
8121
|
+
* @example
|
|
8122
|
+
* const result = await sv.products.identity.signIn();
|
|
8117
8123
|
* console.log(result.token, result.identity);
|
|
8118
|
-
*
|
|
8119
|
-
* @example Inline mode
|
|
8120
|
-
* const result = await sv.products.identity.verify({
|
|
8121
|
-
* target: '#auth-container',
|
|
8122
|
-
* email: 'user@example.com'
|
|
8123
|
-
* });
|
|
8124
8124
|
*/
|
|
8125
|
-
async
|
|
8125
|
+
async signIn(options = {}) {
|
|
8126
|
+
return this.runFlow(options);
|
|
8127
|
+
}
|
|
8128
|
+
/**
|
|
8129
|
+
* Core flow runner. Dialog mode (no `target`) opens the popup; local mode
|
|
8130
|
+
* (`renderMode: 'local'` / `target`) renders into the current document and
|
|
8131
|
+
* powers the SparkVault-hosted sign-in surfaces (see the internal `render`).
|
|
8132
|
+
*/
|
|
8133
|
+
async runFlow(options = {}) {
|
|
8126
8134
|
const redirectResult = await this.consumeRedirectResult();
|
|
8127
8135
|
if (redirectResult) {
|
|
8128
8136
|
options.onSuccess?.(redirectResult);
|
|
@@ -8220,7 +8228,7 @@ class IdentityModule {
|
|
|
8220
8228
|
const handleClick = async (event) => {
|
|
8221
8229
|
event.preventDefault();
|
|
8222
8230
|
try {
|
|
8223
|
-
await this.
|
|
8231
|
+
await this.signIn({
|
|
8224
8232
|
email: options.email,
|
|
8225
8233
|
phone: options.phone,
|
|
8226
8234
|
authContext: options.authContext,
|
|
@@ -8259,7 +8267,7 @@ class IdentityModule {
|
|
|
8259
8267
|
*
|
|
8260
8268
|
* To trust a token (e.g. before keying records by `claims.svid`), verify the
|
|
8261
8269
|
* Ed25519 signature server-side against the Identity JWKS endpoint
|
|
8262
|
-
* (
|
|
8270
|
+
* (`https://auth.sparkvault.com/{account_id}/.well-known/jwks.json`). See docs/SDK.md.
|
|
8263
8271
|
*/
|
|
8264
8272
|
decodeToken(token) {
|
|
8265
8273
|
if (!token || typeof token !== 'string') {
|
|
@@ -8316,8 +8324,8 @@ class IdentityModule {
|
|
|
8316
8324
|
}
|
|
8317
8325
|
// Once a token is present it must be consumed exactly once: the hash and
|
|
8318
8326
|
// one-shot OAuth state are cleared whether validation succeeds or fails.
|
|
8319
|
-
// A failing token left in the URL would make every subsequent
|
|
8320
|
-
// re-consume and re-reject it before the dialog could ever open
|
|
8327
|
+
// A failing token left in the URL would make every subsequent signIn()
|
|
8328
|
+
// re-consume and re-reject it before the dialog could ever open, so login
|
|
8321
8329
|
// would stay wedged until the user manually edited the URL.
|
|
8322
8330
|
try {
|
|
8323
8331
|
let expectedState = null;
|
|
@@ -8421,22 +8429,15 @@ class IdentityModule {
|
|
|
8421
8429
|
// container's own surface and the SparkVault footer.
|
|
8422
8430
|
return new InlineContainer(element, bare ? { bare: true, showFooter: false } : {});
|
|
8423
8431
|
}
|
|
8424
|
-
// Public-API aliases. The documented method names in the customer-facing
|
|
8425
|
-
// SDK README and the API docs are pop() and render(); verify() is the
|
|
8426
|
-
// underlying primitive. Both remain canonical entry points.
|
|
8427
8432
|
/**
|
|
8428
|
-
*
|
|
8429
|
-
*
|
|
8430
|
-
|
|
8431
|
-
|
|
8432
|
-
|
|
8433
|
-
}
|
|
8434
|
-
/**
|
|
8435
|
-
* Render the identity verification UI inline into a target element.
|
|
8436
|
-
* Equivalent to `verify({ ...options, target })`.
|
|
8433
|
+
* Render the flow into a page element instead of a popup.
|
|
8434
|
+
*
|
|
8435
|
+
* @internal Used only by the SparkVault-hosted sign-in popup and hosted login
|
|
8436
|
+
* page (which own their chrome and pass `renderMode: 'local'`). Customer
|
|
8437
|
+
* integrations have no inline mode — use `signIn()` / `attach()`.
|
|
8437
8438
|
*/
|
|
8438
8439
|
async render(options) {
|
|
8439
|
-
return this.
|
|
8440
|
+
return this.runFlow(options);
|
|
8440
8441
|
}
|
|
8441
8442
|
}
|
|
8442
8443
|
|
|
@@ -12931,7 +12932,7 @@ function autoInit(SparkVaultClass) {
|
|
|
12931
12932
|
*
|
|
12932
12933
|
* const sv = SparkVault.init({ accountId: 'acc_your_account' });
|
|
12933
12934
|
*
|
|
12934
|
-
* const result = await sv.products.identity.
|
|
12935
|
+
* const result = await sv.products.identity.signIn();
|
|
12935
12936
|
* console.log(result.identity, result.identityType);
|
|
12936
12937
|
* ```
|
|
12937
12938
|
*/
|