@sparkvault/sdk 1.24.0 → 1.24.2
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 +19 -0
- package/dist/health.d.ts +18 -0
- package/dist/http.d.ts +3 -0
- package/dist/identity/api.d.ts +13 -8
- package/dist/index.d.ts +65 -11
- package/dist/sparkvault.cjs.js +291 -53
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +291 -53
- package/dist/sparkvault.esm.js.map +1 -1
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/dist/vaults/index.d.ts +5 -3
- package/dist/vaults/types.d.ts +28 -16
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
|
@@ -4,6 +4,16 @@
|
|
|
4
4
|
export interface SparkVaultConfig {
|
|
5
5
|
/** Account ID for Identity operations */
|
|
6
6
|
accountId: string;
|
|
7
|
+
/** Core API origin. Defaults to https://api.sparkvault.com. A trailing /v1 is accepted and normalized. */
|
|
8
|
+
apiBaseUrl?: string;
|
|
9
|
+
/** Identity App API base URL. Defaults to https://api.sparkvault.com/v1/apps/identity. */
|
|
10
|
+
identityBaseUrl?: string;
|
|
11
|
+
/** Static SparkVault Core access token for authenticated API calls. */
|
|
12
|
+
accessToken?: string;
|
|
13
|
+
/** Dynamic SparkVault Core access token provider for authenticated API calls. */
|
|
14
|
+
getAccessToken?: () => string | null | Promise<string | null>;
|
|
15
|
+
/** Optional API key for server-side SDK use. */
|
|
16
|
+
apiKey?: string;
|
|
7
17
|
/** Request timeout in milliseconds (default: 30000) */
|
|
8
18
|
timeout?: number;
|
|
9
19
|
/**
|
|
@@ -15,14 +25,23 @@ export interface SparkVaultConfig {
|
|
|
15
25
|
preloadConfig?: boolean;
|
|
16
26
|
/** Enable backdrop blur on dialogs (default: true) */
|
|
17
27
|
backdropBlur?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Optional host allowlist for backend-issued ingot download URLs.
|
|
30
|
+
* When omitted, the SDK preserves the existing HTTPS-only validation behavior.
|
|
31
|
+
*/
|
|
32
|
+
allowedDownloadHostPatterns?: RegExp[];
|
|
18
33
|
}
|
|
19
34
|
export interface ResolvedConfig {
|
|
20
35
|
accountId: string;
|
|
21
36
|
timeout: number;
|
|
22
37
|
apiBaseUrl: string;
|
|
23
38
|
identityBaseUrl: string;
|
|
39
|
+
accessToken?: string;
|
|
40
|
+
getAccessToken?: () => string | null | Promise<string | null>;
|
|
41
|
+
apiKey?: string;
|
|
24
42
|
preloadConfig: boolean;
|
|
25
43
|
backdropBlur: boolean;
|
|
44
|
+
allowedDownloadHostPatterns?: RegExp[];
|
|
26
45
|
}
|
|
27
46
|
export declare function resolveConfig(config: SparkVaultConfig): ResolvedConfig;
|
|
28
47
|
export declare function validateConfig(config: SparkVaultConfig): void;
|
package/dist/health.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ResolvedConfig } from './config';
|
|
2
|
+
export interface HealthCheckOptions {
|
|
3
|
+
timeout?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface HealthCheckResult {
|
|
6
|
+
online: boolean;
|
|
7
|
+
status: string;
|
|
8
|
+
httpStatus?: number;
|
|
9
|
+
checkedAt: number;
|
|
10
|
+
error?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class HealthModule {
|
|
13
|
+
private readonly config;
|
|
14
|
+
constructor(config: ResolvedConfig);
|
|
15
|
+
check(options?: HealthCheckOptions): Promise<HealthCheckResult>;
|
|
16
|
+
isOnline(options?: HealthCheckOptions): Promise<boolean>;
|
|
17
|
+
private readStatus;
|
|
18
|
+
}
|
package/dist/http.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export interface ApiResponse<T = unknown> {
|
|
|
19
19
|
export declare class HttpClient {
|
|
20
20
|
private readonly config;
|
|
21
21
|
constructor(config: ResolvedConfig);
|
|
22
|
+
private getDefaultHeaders;
|
|
23
|
+
private getAccessToken;
|
|
22
24
|
request<T = unknown>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
23
25
|
/**
|
|
24
26
|
* Execute the actual HTTP request (internal implementation)
|
|
@@ -31,6 +33,7 @@ export declare class HttpClient {
|
|
|
31
33
|
private isRetryableError;
|
|
32
34
|
private parseResponse;
|
|
33
35
|
private createErrorFromResponse;
|
|
36
|
+
private unwrapApiResponse;
|
|
34
37
|
get<T = unknown>(path: string, options?: Omit<RequestOptions, 'method' | 'body'>): Promise<ApiResponse<T>>;
|
|
35
38
|
post<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
|
|
36
39
|
put<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
|
package/dist/identity/api.d.ts
CHANGED
|
@@ -35,13 +35,18 @@ export declare class IdentityApi extends SparkVaultApi {
|
|
|
35
35
|
*/
|
|
36
36
|
isConfigPreloaded(): boolean;
|
|
37
37
|
/**
|
|
38
|
-
* Check if an email has registered passkeys
|
|
38
|
+
* Check if an identity (email or phone) has registered passkeys.
|
|
39
39
|
*
|
|
40
40
|
* Returns:
|
|
41
|
-
* -
|
|
42
|
-
*
|
|
41
|
+
* - identity_valid: identity passes per-type validity check
|
|
42
|
+
* (email: MX lookup; phone: E.164 format)
|
|
43
|
+
* - has_passkey: whether any passkeys are registered for this identity
|
|
44
|
+
* (cross-tenant — single global RP)
|
|
45
|
+
* - email_valid: legacy alias for identity_valid, present for backward
|
|
46
|
+
* compatibility with older SDK versions
|
|
43
47
|
*/
|
|
44
|
-
checkPasskey(
|
|
48
|
+
checkPasskey(identity: string, identityType?: 'email' | 'phone'): Promise<{
|
|
49
|
+
identity_valid: boolean;
|
|
45
50
|
email_valid: boolean;
|
|
46
51
|
has_passkey: boolean;
|
|
47
52
|
}>;
|
|
@@ -68,9 +73,9 @@ export declare class IdentityApi extends SparkVaultApi {
|
|
|
68
73
|
authContext?: AuthContext;
|
|
69
74
|
}): Promise<TotpVerifyResponse>;
|
|
70
75
|
/**
|
|
71
|
-
* Start passkey registration
|
|
76
|
+
* Start passkey registration for an identity (email or phone).
|
|
72
77
|
*/
|
|
73
|
-
startPasskeyRegister(
|
|
78
|
+
startPasskeyRegister(identity: string, identityType?: 'email' | 'phone'): Promise<PasskeyChallengeResponse>;
|
|
74
79
|
/**
|
|
75
80
|
* Complete passkey registration
|
|
76
81
|
*/
|
|
@@ -79,9 +84,9 @@ export declare class IdentityApi extends SparkVaultApi {
|
|
|
79
84
|
credential: PublicKeyCredential;
|
|
80
85
|
}): Promise<PasskeyVerifyResponse>;
|
|
81
86
|
/**
|
|
82
|
-
* Start passkey verification
|
|
87
|
+
* Start passkey verification for an identity (email or phone).
|
|
83
88
|
*/
|
|
84
|
-
startPasskeyVerify(
|
|
89
|
+
startPasskeyVerify(identity: string, identityType?: 'email' | 'phone', authContext?: AuthContext): Promise<PasskeyChallengeResponse>;
|
|
85
90
|
/**
|
|
86
91
|
* Complete passkey verification
|
|
87
92
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,16 @@
|
|
|
4
4
|
interface SparkVaultConfig {
|
|
5
5
|
/** Account ID for Identity operations */
|
|
6
6
|
accountId: string;
|
|
7
|
+
/** Core API origin. Defaults to https://api.sparkvault.com. A trailing /v1 is accepted and normalized. */
|
|
8
|
+
apiBaseUrl?: string;
|
|
9
|
+
/** Identity App API base URL. Defaults to https://api.sparkvault.com/v1/apps/identity. */
|
|
10
|
+
identityBaseUrl?: string;
|
|
11
|
+
/** Static SparkVault Core access token for authenticated API calls. */
|
|
12
|
+
accessToken?: string;
|
|
13
|
+
/** Dynamic SparkVault Core access token provider for authenticated API calls. */
|
|
14
|
+
getAccessToken?: () => string | null | Promise<string | null>;
|
|
15
|
+
/** Optional API key for server-side SDK use. */
|
|
16
|
+
apiKey?: string;
|
|
7
17
|
/** Request timeout in milliseconds (default: 30000) */
|
|
8
18
|
timeout?: number;
|
|
9
19
|
/**
|
|
@@ -15,14 +25,41 @@ interface SparkVaultConfig {
|
|
|
15
25
|
preloadConfig?: boolean;
|
|
16
26
|
/** Enable backdrop blur on dialogs (default: true) */
|
|
17
27
|
backdropBlur?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Optional host allowlist for backend-issued ingot download URLs.
|
|
30
|
+
* When omitted, the SDK preserves the existing HTTPS-only validation behavior.
|
|
31
|
+
*/
|
|
32
|
+
allowedDownloadHostPatterns?: RegExp[];
|
|
18
33
|
}
|
|
19
34
|
interface ResolvedConfig {
|
|
20
35
|
accountId: string;
|
|
21
36
|
timeout: number;
|
|
22
37
|
apiBaseUrl: string;
|
|
23
38
|
identityBaseUrl: string;
|
|
39
|
+
accessToken?: string;
|
|
40
|
+
getAccessToken?: () => string | null | Promise<string | null>;
|
|
41
|
+
apiKey?: string;
|
|
24
42
|
preloadConfig: boolean;
|
|
25
43
|
backdropBlur: boolean;
|
|
44
|
+
allowedDownloadHostPatterns?: RegExp[];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface HealthCheckOptions {
|
|
48
|
+
timeout?: number;
|
|
49
|
+
}
|
|
50
|
+
interface HealthCheckResult {
|
|
51
|
+
online: boolean;
|
|
52
|
+
status: string;
|
|
53
|
+
httpStatus?: number;
|
|
54
|
+
checkedAt: number;
|
|
55
|
+
error?: string;
|
|
56
|
+
}
|
|
57
|
+
declare class HealthModule {
|
|
58
|
+
private readonly config;
|
|
59
|
+
constructor(config: ResolvedConfig);
|
|
60
|
+
check(options?: HealthCheckOptions): Promise<HealthCheckResult>;
|
|
61
|
+
isOnline(options?: HealthCheckOptions): Promise<boolean>;
|
|
62
|
+
private readStatus;
|
|
26
63
|
}
|
|
27
64
|
|
|
28
65
|
/**
|
|
@@ -272,6 +309,8 @@ interface ApiResponse<T = unknown> {
|
|
|
272
309
|
declare class HttpClient {
|
|
273
310
|
private readonly config;
|
|
274
311
|
constructor(config: ResolvedConfig);
|
|
312
|
+
private getDefaultHeaders;
|
|
313
|
+
private getAccessToken;
|
|
275
314
|
request<T = unknown>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
276
315
|
/**
|
|
277
316
|
* Execute the actual HTTP request (internal implementation)
|
|
@@ -284,6 +323,7 @@ declare class HttpClient {
|
|
|
284
323
|
private isRetryableError;
|
|
285
324
|
private parseResponse;
|
|
286
325
|
private createErrorFromResponse;
|
|
326
|
+
private unwrapApiResponse;
|
|
287
327
|
get<T = unknown>(path: string, options?: Omit<RequestOptions, 'method' | 'body'>): Promise<ApiResponse<T>>;
|
|
288
328
|
post<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
|
|
289
329
|
put<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
|
|
@@ -324,16 +364,14 @@ interface Vault {
|
|
|
324
364
|
interface UnsealedVault {
|
|
325
365
|
/** Vault ID */
|
|
326
366
|
id: string;
|
|
327
|
-
/** Vault
|
|
328
|
-
name: string;
|
|
329
|
-
/** Vault Access Token (short-lived session) */
|
|
367
|
+
/** Vault Access Token (short-lived session, required for all ingot operations) */
|
|
330
368
|
vatToken: string;
|
|
369
|
+
/** VAT issued-at timestamp (Unix seconds) */
|
|
370
|
+
issuedAt: number;
|
|
331
371
|
/** VAT expiry timestamp (Unix seconds) */
|
|
332
372
|
expiresAt: number;
|
|
333
|
-
/**
|
|
334
|
-
|
|
335
|
-
/** Total storage used in bytes */
|
|
336
|
-
storageBytes: number;
|
|
373
|
+
/** VAT lifetime in seconds */
|
|
374
|
+
ttlSeconds: number;
|
|
337
375
|
}
|
|
338
376
|
interface VaultSummary {
|
|
339
377
|
/** Vault ID */
|
|
@@ -360,8 +398,18 @@ interface Ingot {
|
|
|
360
398
|
size: number;
|
|
361
399
|
/** Creation timestamp (Unix seconds) */
|
|
362
400
|
createdAt: number;
|
|
363
|
-
|
|
364
|
-
|
|
401
|
+
}
|
|
402
|
+
interface CreatedIngot {
|
|
403
|
+
/** Ingot ID */
|
|
404
|
+
id: string;
|
|
405
|
+
/** Ingot name */
|
|
406
|
+
name: string;
|
|
407
|
+
/** Content type (MIME) */
|
|
408
|
+
contentType: string;
|
|
409
|
+
/** Size in bytes */
|
|
410
|
+
size: number;
|
|
411
|
+
/** Forge upload session expiry (Unix seconds) */
|
|
412
|
+
uploadExpiresAt: number;
|
|
365
413
|
}
|
|
366
414
|
interface UploadIngotOptions {
|
|
367
415
|
/** File to upload */
|
|
@@ -370,6 +418,8 @@ interface UploadIngotOptions {
|
|
|
370
418
|
name?: string;
|
|
371
419
|
/** Content type (auto-detected if not provided) */
|
|
372
420
|
contentType?: string;
|
|
421
|
+
/** Progress callback for Forge/TUS upload */
|
|
422
|
+
onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
|
|
373
423
|
}
|
|
374
424
|
|
|
375
425
|
/**
|
|
@@ -503,6 +553,7 @@ interface UploadCallable {
|
|
|
503
553
|
close(): void;
|
|
504
554
|
}
|
|
505
555
|
declare class VaultsModule {
|
|
556
|
+
private readonly config;
|
|
506
557
|
private readonly http;
|
|
507
558
|
private readonly uploadModule;
|
|
508
559
|
/**
|
|
@@ -562,7 +613,7 @@ declare class VaultsModule {
|
|
|
562
613
|
* name: 'document.pdf'
|
|
563
614
|
* });
|
|
564
615
|
*/
|
|
565
|
-
uploadIngot(vault: UnsealedVault, options: UploadIngotOptions): Promise<
|
|
616
|
+
uploadIngot(vault: UnsealedVault, options: UploadIngotOptions): Promise<CreatedIngot>;
|
|
566
617
|
/**
|
|
567
618
|
* Download an ingot from an unsealed vault.
|
|
568
619
|
*
|
|
@@ -588,6 +639,7 @@ declare class VaultsModule {
|
|
|
588
639
|
deleteIngot(vault: UnsealedVault, ingotId: string): Promise<void>;
|
|
589
640
|
private validateCreateOptions;
|
|
590
641
|
private validateUploadOptions;
|
|
642
|
+
private validateDownloadUrl;
|
|
591
643
|
}
|
|
592
644
|
|
|
593
645
|
/**
|
|
@@ -667,6 +719,8 @@ declare class SparkVault {
|
|
|
667
719
|
readonly identity: IdentityModule;
|
|
668
720
|
/** Persistent encrypted storage module */
|
|
669
721
|
readonly vaults: VaultsModule;
|
|
722
|
+
/** API availability checks */
|
|
723
|
+
readonly health: HealthModule;
|
|
670
724
|
private readonly config;
|
|
671
725
|
private constructor();
|
|
672
726
|
/**
|
|
@@ -692,4 +746,4 @@ declare global {
|
|
|
692
746
|
}
|
|
693
747
|
|
|
694
748
|
export { AuthenticationError, AuthorizationError, NetworkError, PopupBlockedError, SparkVault, SparkVaultError, TimeoutError, UserCancelledError, ValidationError, SparkVault as default, logger, setDebugMode };
|
|
695
|
-
export type { AuthMethod, CreateVaultOptions, AttachOptions as IdentityAttachOptions, Ingot, SparkVaultConfig, Theme, TokenClaims, UnsealedVault, UploadAttachOptions, UploadBranding, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, Vault, VaultSummary, VaultUploadConfig, VerifyOptions, VerifyResult };
|
|
749
|
+
export type { AuthMethod, CreateVaultOptions, CreatedIngot, HealthCheckOptions, HealthCheckResult, AttachOptions as IdentityAttachOptions, Ingot, SparkVaultConfig, Theme, TokenClaims, UnsealedVault, UploadAttachOptions, UploadBranding, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, Vault, VaultSummary, VaultUploadConfig, VerifyOptions, VerifyResult };
|