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