@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/sparkvault.esm.js
CHANGED
|
@@ -103,8 +103,11 @@ class PopupBlockedError extends SparkVaultError {
|
|
|
103
103
|
|
|
104
104
|
const SPARKVAULT_ROOT_DOMAIN = 'sparkvault.com';
|
|
105
105
|
|
|
106
|
+
/** The person-facing Identity portal host (auth.sv shell + hosted login). */
|
|
107
|
+
const SPARKVAULT_AUTH_HOST = 'auth.sv';
|
|
108
|
+
|
|
106
109
|
const SPARKVAULT_PLATFORM_SV_HOSTS = Object.freeze([
|
|
107
|
-
|
|
110
|
+
SPARKVAULT_AUTH_HOST,
|
|
108
111
|
'x.sv',
|
|
109
112
|
'files.sv',
|
|
110
113
|
'file.sv',
|
|
@@ -146,6 +149,7 @@ const DEFAULT_ALLOWED_DOWNLOAD_HOST_PATTERNS = [
|
|
|
146
149
|
];
|
|
147
150
|
const API_URL = 'https://api.sparkvault.com';
|
|
148
151
|
const IDENTITY_URL = 'https://api.sparkvault.com/v1/products/identity';
|
|
152
|
+
const PORTAL_URL = `https://${SPARKVAULT_AUTH_HOST}`;
|
|
149
153
|
function normalizeApiBaseUrl(url) {
|
|
150
154
|
const trimmed = url.replace(/\/+$/, '');
|
|
151
155
|
return trimmed.endsWith('/v1') ? trimmed.slice(0, -3) : trimmed;
|
|
@@ -159,6 +163,7 @@ function resolveConfig(config) {
|
|
|
159
163
|
timeout: config.timeout ?? 30000,
|
|
160
164
|
apiBaseUrl: normalizeApiBaseUrl(config.apiBaseUrl ?? API_URL),
|
|
161
165
|
identityBaseUrl: normalizeBaseUrl(config.identityBaseUrl ?? IDENTITY_URL),
|
|
166
|
+
portalBaseUrl: normalizeBaseUrl(config.portalBaseUrl ?? PORTAL_URL),
|
|
162
167
|
accessToken: config.accessToken,
|
|
163
168
|
getAccessToken: config.getAccessToken,
|
|
164
169
|
apiKey: config.apiKey,
|
|
@@ -7706,6 +7711,7 @@ function attachClickHandler(selector, onClick) {
|
|
|
7706
7711
|
* @example Inline mode
|
|
7707
7712
|
* const result = await sv.products.identity.verify({ target: '#auth-container' });
|
|
7708
7713
|
*/
|
|
7714
|
+
const PORTAL_SECTIONS = ['home', 'identity', 'security', 'sessions', 'sites'];
|
|
7709
7715
|
function isTokenClaims(payload) {
|
|
7710
7716
|
if (typeof payload !== 'object' || payload === null) {
|
|
7711
7717
|
return false;
|
|
@@ -7732,6 +7738,42 @@ class IdentityModule {
|
|
|
7732
7738
|
this.api.preloadConfig();
|
|
7733
7739
|
}
|
|
7734
7740
|
}
|
|
7741
|
+
/**
|
|
7742
|
+
* Build a deep link into the person's auth.sv Identity portal — where they
|
|
7743
|
+
* manage their verified identity, passkeys, sessions, and connected sites
|
|
7744
|
+
* across every SparkVault-integrated site. Send a signed-in user here to
|
|
7745
|
+
* self-serve;
|
|
7746
|
+
* the portal authenticates them with their own SparkVault Identity.
|
|
7747
|
+
*
|
|
7748
|
+
* @example Manage this site (block/notifications/etc.)
|
|
7749
|
+
* window.location.href = sv.products.identity.portalUrl({ section: 'sites' });
|
|
7750
|
+
*
|
|
7751
|
+
* @example Open the security screen
|
|
7752
|
+
* sv.products.identity.portalUrl({ section: 'security' });
|
|
7753
|
+
*
|
|
7754
|
+
* @returns An absolute URL on the configured `portalBaseUrl` (default https://auth.sv).
|
|
7755
|
+
*/
|
|
7756
|
+
portalUrl(options = {}) {
|
|
7757
|
+
const section = options.section ?? 'home';
|
|
7758
|
+
if (!PORTAL_SECTIONS.includes(section)) {
|
|
7759
|
+
throw new ValidationError(`Unknown portal section: ${section}`, {
|
|
7760
|
+
field: 'section',
|
|
7761
|
+
received: section,
|
|
7762
|
+
});
|
|
7763
|
+
}
|
|
7764
|
+
let path;
|
|
7765
|
+
if (section === 'home') {
|
|
7766
|
+
path = '/';
|
|
7767
|
+
}
|
|
7768
|
+
else if (section === 'sites') {
|
|
7769
|
+
const site = (options.site ?? this.config.accountId).trim();
|
|
7770
|
+
path = site ? `/sites/${encodeURIComponent(site)}` : '/sites';
|
|
7771
|
+
}
|
|
7772
|
+
else {
|
|
7773
|
+
path = `/${section}`;
|
|
7774
|
+
}
|
|
7775
|
+
return new URL(path, this.config.portalBaseUrl).toString();
|
|
7776
|
+
}
|
|
7735
7777
|
/**
|
|
7736
7778
|
* Verify user identity.
|
|
7737
7779
|
*
|