@sparkvault/sdk-js 5.0.1 → 6.0.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/config.d.ts +3 -0
- package/dist/index.d.ts +32 -0
- package/dist/products/identity/index.d.ts +17 -1
- package/dist/products/identity/types.d.ts +13 -0
- package/dist/sparkvault.cjs.js +43 -1
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +43 -1
- 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/config.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export interface SparkVaultConfig {
|
|
|
8
8
|
apiBaseUrl?: string;
|
|
9
9
|
/** Identity Product API base URL. Defaults to https://api.sparkvault.com/v1/products/identity. */
|
|
10
10
|
identityBaseUrl?: string;
|
|
11
|
+
/** auth.sv portal origin for self-service deep links (`portalUrl()`). Defaults to https://auth.sv. */
|
|
12
|
+
portalBaseUrl?: string;
|
|
11
13
|
/** Static SparkVault Core access token for authenticated API calls. */
|
|
12
14
|
accessToken?: string;
|
|
13
15
|
/** Dynamic SparkVault Core access token provider for authenticated API calls. */
|
|
@@ -37,6 +39,7 @@ export interface ResolvedConfig {
|
|
|
37
39
|
timeout: number;
|
|
38
40
|
apiBaseUrl: string;
|
|
39
41
|
identityBaseUrl: string;
|
|
42
|
+
portalBaseUrl: string;
|
|
40
43
|
accessToken?: string;
|
|
41
44
|
getAccessToken?: () => string | null | Promise<string | null>;
|
|
42
45
|
apiKey?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ interface SparkVaultConfig {
|
|
|
8
8
|
apiBaseUrl?: string;
|
|
9
9
|
/** Identity Product API base URL. Defaults to https://api.sparkvault.com/v1/products/identity. */
|
|
10
10
|
identityBaseUrl?: string;
|
|
11
|
+
/** auth.sv portal origin for self-service deep links (`portalUrl()`). Defaults to https://auth.sv. */
|
|
12
|
+
portalBaseUrl?: string;
|
|
11
13
|
/** Static SparkVault Core access token for authenticated API calls. */
|
|
12
14
|
accessToken?: string;
|
|
13
15
|
/** Dynamic SparkVault Core access token provider for authenticated API calls. */
|
|
@@ -37,6 +39,7 @@ interface ResolvedConfig {
|
|
|
37
39
|
timeout: number;
|
|
38
40
|
apiBaseUrl: string;
|
|
39
41
|
identityBaseUrl: string;
|
|
42
|
+
portalBaseUrl: string;
|
|
40
43
|
accessToken?: string;
|
|
41
44
|
getAccessToken?: () => string | null | Promise<string | null>;
|
|
42
45
|
apiKey?: string;
|
|
@@ -154,6 +157,19 @@ type Recommendation = {
|
|
|
154
157
|
type: 'backup_identifier';
|
|
155
158
|
missingType: 'email' | 'phone';
|
|
156
159
|
};
|
|
160
|
+
/** A self-service screen in the auth.sv Identity portal. */
|
|
161
|
+
type PortalSection = 'home' | 'identity' | 'security' | 'sessions' | 'sites';
|
|
162
|
+
/** Options for building an auth.sv portal deep link (`portalUrl()`). */
|
|
163
|
+
interface PortalUrlOptions {
|
|
164
|
+
/** Which portal screen to open. Defaults to `'home'`. */
|
|
165
|
+
section?: PortalSection;
|
|
166
|
+
/**
|
|
167
|
+
* Focus a specific connected site on the Sites screen (an `acc_…` account ID).
|
|
168
|
+
* When `section` is `'sites'` and `site` is omitted, defaults to this SDK's
|
|
169
|
+
* own `accountId` — i.e. "manage this site". Ignored for other sections.
|
|
170
|
+
*/
|
|
171
|
+
site?: string;
|
|
172
|
+
}
|
|
157
173
|
interface VerifyResult {
|
|
158
174
|
/** Signed JWT token */
|
|
159
175
|
token: string;
|
|
@@ -275,6 +291,22 @@ declare class IdentityModule {
|
|
|
275
291
|
private renderer;
|
|
276
292
|
private embedder;
|
|
277
293
|
constructor(config: ResolvedConfig);
|
|
294
|
+
/**
|
|
295
|
+
* Build a deep link into the person's auth.sv Identity portal — where they
|
|
296
|
+
* manage their verified identity, passkeys, sessions, and connected sites
|
|
297
|
+
* across every SparkVault-integrated site. Send a signed-in user here to
|
|
298
|
+
* self-serve;
|
|
299
|
+
* the portal authenticates them with their own SparkVault Identity.
|
|
300
|
+
*
|
|
301
|
+
* @example Manage this site (block/notifications/etc.)
|
|
302
|
+
* window.location.href = sv.products.identity.portalUrl({ section: 'sites' });
|
|
303
|
+
*
|
|
304
|
+
* @example Open the security screen
|
|
305
|
+
* sv.products.identity.portalUrl({ section: 'security' });
|
|
306
|
+
*
|
|
307
|
+
* @returns An absolute URL on the configured `portalBaseUrl` (default https://auth.sv).
|
|
308
|
+
*/
|
|
309
|
+
portalUrl(options?: PortalUrlOptions): string;
|
|
278
310
|
/**
|
|
279
311
|
* Verify user identity.
|
|
280
312
|
*
|
|
@@ -14,13 +14,29 @@
|
|
|
14
14
|
* const result = await sv.products.identity.verify({ target: '#auth-container' });
|
|
15
15
|
*/
|
|
16
16
|
import type { ResolvedConfig } from '../../config';
|
|
17
|
-
import type { VerifyOptions, VerifyResult, TokenClaims, AttachOptions } from './types';
|
|
17
|
+
import type { VerifyOptions, VerifyResult, TokenClaims, AttachOptions, PortalUrlOptions } from './types';
|
|
18
18
|
export declare class IdentityModule {
|
|
19
19
|
private readonly config;
|
|
20
20
|
private readonly api;
|
|
21
21
|
private renderer;
|
|
22
22
|
private embedder;
|
|
23
23
|
constructor(config: ResolvedConfig);
|
|
24
|
+
/**
|
|
25
|
+
* Build a deep link into the person's auth.sv Identity portal — where they
|
|
26
|
+
* manage their verified identity, passkeys, sessions, and connected sites
|
|
27
|
+
* across every SparkVault-integrated site. Send a signed-in user here to
|
|
28
|
+
* self-serve;
|
|
29
|
+
* the portal authenticates them with their own SparkVault Identity.
|
|
30
|
+
*
|
|
31
|
+
* @example Manage this site (block/notifications/etc.)
|
|
32
|
+
* window.location.href = sv.products.identity.portalUrl({ section: 'sites' });
|
|
33
|
+
*
|
|
34
|
+
* @example Open the security screen
|
|
35
|
+
* sv.products.identity.portalUrl({ section: 'security' });
|
|
36
|
+
*
|
|
37
|
+
* @returns An absolute URL on the configured `portalBaseUrl` (default https://auth.sv).
|
|
38
|
+
*/
|
|
39
|
+
portalUrl(options?: PortalUrlOptions): string;
|
|
24
40
|
/**
|
|
25
41
|
* Verify user identity.
|
|
26
42
|
*
|
|
@@ -91,6 +91,19 @@ export type Recommendation = {
|
|
|
91
91
|
};
|
|
92
92
|
/** Canonical dismiss key for a recommendation (suppresses it server-side 30d). */
|
|
93
93
|
export type RecommendationKey = 'passkey' | 'backup_email' | 'backup_phone';
|
|
94
|
+
/** A self-service screen in the auth.sv Identity portal. */
|
|
95
|
+
export type PortalSection = 'home' | 'identity' | 'security' | 'sessions' | 'sites';
|
|
96
|
+
/** Options for building an auth.sv portal deep link (`portalUrl()`). */
|
|
97
|
+
export interface PortalUrlOptions {
|
|
98
|
+
/** Which portal screen to open. Defaults to `'home'`. */
|
|
99
|
+
section?: PortalSection;
|
|
100
|
+
/**
|
|
101
|
+
* Focus a specific connected site on the Sites screen (an `acc_…` account ID).
|
|
102
|
+
* When `section` is `'sites'` and `site` is omitted, defaults to this SDK's
|
|
103
|
+
* own `accountId` — i.e. "manage this site". Ignored for other sections.
|
|
104
|
+
*/
|
|
105
|
+
site?: string;
|
|
106
|
+
}
|
|
94
107
|
export interface VerifyResult {
|
|
95
108
|
/** Signed JWT token */
|
|
96
109
|
token: string;
|
package/dist/sparkvault.cjs.js
CHANGED
|
@@ -107,8 +107,11 @@ class PopupBlockedError extends SparkVaultError {
|
|
|
107
107
|
|
|
108
108
|
const SPARKVAULT_ROOT_DOMAIN = 'sparkvault.com';
|
|
109
109
|
|
|
110
|
+
/** The person-facing Identity portal host (auth.sv shell + hosted login). */
|
|
111
|
+
const SPARKVAULT_AUTH_HOST = 'auth.sv';
|
|
112
|
+
|
|
110
113
|
const SPARKVAULT_PLATFORM_SV_HOSTS = Object.freeze([
|
|
111
|
-
|
|
114
|
+
SPARKVAULT_AUTH_HOST,
|
|
112
115
|
'x.sv',
|
|
113
116
|
'files.sv',
|
|
114
117
|
'file.sv',
|
|
@@ -150,6 +153,7 @@ const DEFAULT_ALLOWED_DOWNLOAD_HOST_PATTERNS = [
|
|
|
150
153
|
];
|
|
151
154
|
const API_URL = 'https://api.sparkvault.com';
|
|
152
155
|
const IDENTITY_URL = 'https://api.sparkvault.com/v1/products/identity';
|
|
156
|
+
const PORTAL_URL = `https://${SPARKVAULT_AUTH_HOST}`;
|
|
153
157
|
function normalizeApiBaseUrl(url) {
|
|
154
158
|
const trimmed = url.replace(/\/+$/, '');
|
|
155
159
|
return trimmed.endsWith('/v1') ? trimmed.slice(0, -3) : trimmed;
|
|
@@ -163,6 +167,7 @@ function resolveConfig(config) {
|
|
|
163
167
|
timeout: config.timeout ?? 30000,
|
|
164
168
|
apiBaseUrl: normalizeApiBaseUrl(config.apiBaseUrl ?? API_URL),
|
|
165
169
|
identityBaseUrl: normalizeBaseUrl(config.identityBaseUrl ?? IDENTITY_URL),
|
|
170
|
+
portalBaseUrl: normalizeBaseUrl(config.portalBaseUrl ?? PORTAL_URL),
|
|
166
171
|
accessToken: config.accessToken,
|
|
167
172
|
getAccessToken: config.getAccessToken,
|
|
168
173
|
apiKey: config.apiKey,
|
|
@@ -7710,6 +7715,7 @@ function attachClickHandler(selector, onClick) {
|
|
|
7710
7715
|
* @example Inline mode
|
|
7711
7716
|
* const result = await sv.products.identity.verify({ target: '#auth-container' });
|
|
7712
7717
|
*/
|
|
7718
|
+
const PORTAL_SECTIONS = ['home', 'identity', 'security', 'sessions', 'sites'];
|
|
7713
7719
|
function isTokenClaims(payload) {
|
|
7714
7720
|
if (typeof payload !== 'object' || payload === null) {
|
|
7715
7721
|
return false;
|
|
@@ -7736,6 +7742,42 @@ class IdentityModule {
|
|
|
7736
7742
|
this.api.preloadConfig();
|
|
7737
7743
|
}
|
|
7738
7744
|
}
|
|
7745
|
+
/**
|
|
7746
|
+
* Build a deep link into the person's auth.sv Identity portal — where they
|
|
7747
|
+
* manage their verified identity, passkeys, sessions, and connected sites
|
|
7748
|
+
* across every SparkVault-integrated site. Send a signed-in user here to
|
|
7749
|
+
* self-serve;
|
|
7750
|
+
* the portal authenticates them with their own SparkVault Identity.
|
|
7751
|
+
*
|
|
7752
|
+
* @example Manage this site (block/notifications/etc.)
|
|
7753
|
+
* window.location.href = sv.products.identity.portalUrl({ section: 'sites' });
|
|
7754
|
+
*
|
|
7755
|
+
* @example Open the security screen
|
|
7756
|
+
* sv.products.identity.portalUrl({ section: 'security' });
|
|
7757
|
+
*
|
|
7758
|
+
* @returns An absolute URL on the configured `portalBaseUrl` (default https://auth.sv).
|
|
7759
|
+
*/
|
|
7760
|
+
portalUrl(options = {}) {
|
|
7761
|
+
const section = options.section ?? 'home';
|
|
7762
|
+
if (!PORTAL_SECTIONS.includes(section)) {
|
|
7763
|
+
throw new ValidationError(`Unknown portal section: ${section}`, {
|
|
7764
|
+
field: 'section',
|
|
7765
|
+
received: section,
|
|
7766
|
+
});
|
|
7767
|
+
}
|
|
7768
|
+
let path;
|
|
7769
|
+
if (section === 'home') {
|
|
7770
|
+
path = '/';
|
|
7771
|
+
}
|
|
7772
|
+
else if (section === 'sites') {
|
|
7773
|
+
const site = (options.site ?? this.config.accountId).trim();
|
|
7774
|
+
path = site ? `/sites/${encodeURIComponent(site)}` : '/sites';
|
|
7775
|
+
}
|
|
7776
|
+
else {
|
|
7777
|
+
path = `/${section}`;
|
|
7778
|
+
}
|
|
7779
|
+
return new URL(path, this.config.portalBaseUrl).toString();
|
|
7780
|
+
}
|
|
7739
7781
|
/**
|
|
7740
7782
|
* Verify user identity.
|
|
7741
7783
|
*
|