@sparkvault/sdk-js 2.2.1 → 2.2.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/api-base.d.ts +12 -0
- package/dist/http.d.ts +1 -24
- package/dist/identity/embedder.d.ts +8 -0
- package/dist/identity/index.d.ts +4 -1
- package/dist/identity/state.d.ts +2 -22
- package/dist/index.d.ts +16 -42
- package/dist/sparkvault.cjs.js +643 -911
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +643 -911
- package/dist/sparkvault.esm.js.map +1 -1
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/dist/utils/dom.d.ts +13 -4
- package/dist/vaults/index.d.ts +11 -0
- package/dist/vaults/upload/api.d.ts +31 -0
- package/dist/vaults/upload/chrome.d.ts +35 -0
- package/dist/vaults/upload/index.d.ts +3 -1
- package/dist/vaults/upload/inline-container.d.ts +0 -1
- package/dist/vaults/upload/modal.d.ts +0 -1
- package/dist/vaults/upload/renderer.d.ts +17 -8
- package/dist/vaults/upload/styles.d.ts +3 -11
- package/package.json +1 -1
- package/dist/utils/retry.d.ts +0 -32
package/dist/api-base.d.ts
CHANGED
|
@@ -23,6 +23,18 @@ export interface RawResponse {
|
|
|
23
23
|
data: unknown;
|
|
24
24
|
status: number;
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Combine a fresh timeout with a session close signal into one AbortSignal.
|
|
28
|
+
*
|
|
29
|
+
* The returned dispose() MUST run in a finally block: it clears the timeout
|
|
30
|
+
* and unlinks the close listener (the fallback path for browsers without
|
|
31
|
+
* AbortSignal.any) so nothing leaks across requests. Callers discriminate
|
|
32
|
+
* close-vs-timeout afterwards by checking the close signal's aborted flag.
|
|
33
|
+
*/
|
|
34
|
+
export declare function combineTimeoutAndCloseSignals(timeoutMs: number, closeSignal: AbortSignal): {
|
|
35
|
+
signal: AbortSignal;
|
|
36
|
+
dispose: () => void;
|
|
37
|
+
};
|
|
26
38
|
export declare abstract class SparkVaultApi {
|
|
27
39
|
protected readonly timeoutMs: number;
|
|
28
40
|
/**
|
package/dist/http.d.ts
CHANGED
|
@@ -2,14 +2,11 @@
|
|
|
2
2
|
* SparkVault SDK HTTP Client
|
|
3
3
|
*/
|
|
4
4
|
import type { ResolvedConfig } from './config';
|
|
5
|
-
import { type RetryOptions } from './utils/retry';
|
|
6
5
|
export interface RequestOptions {
|
|
7
|
-
method?: 'GET' | 'POST' | '
|
|
6
|
+
method?: 'GET' | 'POST' | 'DELETE';
|
|
8
7
|
headers?: Record<string, string>;
|
|
9
8
|
body?: unknown;
|
|
10
9
|
timeout?: number;
|
|
11
|
-
/** Enable automatic retry with exponential backoff (per CLAUDE.md §7) */
|
|
12
|
-
retry?: boolean | RetryOptions;
|
|
13
10
|
}
|
|
14
11
|
export interface ApiResponse<T = unknown> {
|
|
15
12
|
data: T;
|
|
@@ -22,30 +19,10 @@ export declare class HttpClient {
|
|
|
22
19
|
private getDefaultHeaders;
|
|
23
20
|
private getAccessToken;
|
|
24
21
|
request<T = unknown>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
25
|
-
/**
|
|
26
|
-
* Execute the actual HTTP request (internal implementation)
|
|
27
|
-
*/
|
|
28
|
-
private executeRequest;
|
|
29
|
-
/**
|
|
30
|
-
* Check if an error is safe to retry
|
|
31
|
-
* Per CLAUDE.md §7: Only retry on transient/network errors, not client errors
|
|
32
|
-
*/
|
|
33
|
-
private isRetryableError;
|
|
34
22
|
private parseResponse;
|
|
35
23
|
private createErrorFromResponse;
|
|
36
24
|
private unwrapApiResponse;
|
|
37
25
|
get<T = unknown>(path: string, options?: Omit<RequestOptions, 'method' | 'body'>): Promise<ApiResponse<T>>;
|
|
38
26
|
post<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
|
|
39
|
-
put<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
|
|
40
|
-
patch<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
|
|
41
27
|
delete<T = unknown>(path: string, options?: Omit<RequestOptions, 'method' | 'body'>): Promise<ApiResponse<T>>;
|
|
42
|
-
/**
|
|
43
|
-
* Request raw binary data (e.g., file downloads).
|
|
44
|
-
* Returns a Blob instead of parsed JSON.
|
|
45
|
-
*/
|
|
46
|
-
requestRaw(path: string, options?: RequestOptions): Promise<Blob>;
|
|
47
|
-
/**
|
|
48
|
-
* Execute the actual raw HTTP request (internal implementation)
|
|
49
|
-
*/
|
|
50
|
-
private executeRequestRaw;
|
|
51
28
|
}
|
|
@@ -69,6 +69,14 @@ export declare class WidgetEmbedder {
|
|
|
69
69
|
* return. Mirrors the SDK's getSocialAuthUrl.
|
|
70
70
|
*/
|
|
71
71
|
private startSocial;
|
|
72
|
+
/**
|
|
73
|
+
* Navigate the host top window to a widget-supplied URL — only when it
|
|
74
|
+
* resolves to http(s). The sender is already constrained to the trusted
|
|
75
|
+
* widget origin, but defense-in-depth across the SparkVault->customer
|
|
76
|
+
* boundary: compromised widget-origin code must never escalate into script
|
|
77
|
+
* execution on the embedding page via a javascript:/data: navigation.
|
|
78
|
+
*/
|
|
79
|
+
private safeNavigate;
|
|
72
80
|
private buildUrl;
|
|
73
81
|
private handleMessage;
|
|
74
82
|
}
|
package/dist/identity/index.d.ts
CHANGED
|
@@ -20,7 +20,6 @@ export declare class IdentityModule {
|
|
|
20
20
|
private readonly api;
|
|
21
21
|
private renderer;
|
|
22
22
|
private embedder;
|
|
23
|
-
private attachedElements;
|
|
24
23
|
constructor(config: ResolvedConfig);
|
|
25
24
|
/**
|
|
26
25
|
* Verify user identity.
|
|
@@ -73,6 +72,10 @@ export declare class IdentityModule {
|
|
|
73
72
|
private consumeRedirectResult;
|
|
74
73
|
/**
|
|
75
74
|
* Close the identity dialog/inline UI if open.
|
|
75
|
+
*
|
|
76
|
+
* Tears down whichever surface is active: the hosted-widget iframe
|
|
77
|
+
* (default dialog mode — also releases the embedder's host scroll lock)
|
|
78
|
+
* or the local renderer (inline / local mode).
|
|
76
79
|
*/
|
|
77
80
|
close(): void;
|
|
78
81
|
/**
|
package/dist/identity/state.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Verification State Manager
|
|
3
3
|
*
|
|
4
|
-
* Single source of truth for all verification flow state
|
|
5
|
-
* Centralizes scattered state from IdentityRenderer for:
|
|
4
|
+
* Single source of truth for all verification flow state:
|
|
6
5
|
* - Predictable state transitions
|
|
7
6
|
* - Easier debugging and testing
|
|
8
7
|
* - Clear data ownership
|
|
9
8
|
*/
|
|
10
|
-
import type { SdkConfig, VerifyResult, IdentityViewState,
|
|
9
|
+
import type { SdkConfig, VerifyResult, IdentityViewState, AuthContext } from './types';
|
|
11
10
|
import type { IdentityType } from './views';
|
|
12
11
|
/**
|
|
13
12
|
* Passkey-specific state
|
|
@@ -40,24 +39,9 @@ export declare class VerificationState {
|
|
|
40
39
|
private _authContext;
|
|
41
40
|
private readonly _passkey;
|
|
42
41
|
private readonly _totp;
|
|
43
|
-
private readonly listeners;
|
|
44
|
-
/**
|
|
45
|
-
* Subscribe to state changes
|
|
46
|
-
* @param listener - Callback invoked on state change
|
|
47
|
-
* @returns Unsubscribe function
|
|
48
|
-
*/
|
|
49
|
-
subscribe(listener: (state: IdentityViewState) => void): () => void;
|
|
50
|
-
/**
|
|
51
|
-
* Notify all listeners of state change
|
|
52
|
-
*/
|
|
53
|
-
private notify;
|
|
54
42
|
get sdkConfig(): SdkConfig | null;
|
|
55
43
|
setConfig(config: SdkConfig): void;
|
|
56
44
|
get accountId(): string;
|
|
57
|
-
/**
|
|
58
|
-
* Get enriched methods filtered by the fallback identifier type.
|
|
59
|
-
*/
|
|
60
|
-
getAvailableMethods(): MethodMetadata[];
|
|
61
45
|
/**
|
|
62
46
|
* Check if passkey method is enabled in config
|
|
63
47
|
*/
|
|
@@ -90,9 +74,5 @@ export declare class VerificationState {
|
|
|
90
74
|
get totp(): Readonly<TotpState>;
|
|
91
75
|
setKindling(kindling: string): void;
|
|
92
76
|
setTotpMethod(method: 'email' | 'sms' | 'voice'): void;
|
|
93
|
-
/**
|
|
94
|
-
* Reset state for new verification attempt
|
|
95
|
-
*/
|
|
96
|
-
reset(): void;
|
|
97
77
|
}
|
|
98
78
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -239,7 +239,6 @@ declare class IdentityModule {
|
|
|
239
239
|
private readonly api;
|
|
240
240
|
private renderer;
|
|
241
241
|
private embedder;
|
|
242
|
-
private attachedElements;
|
|
243
242
|
constructor(config: ResolvedConfig);
|
|
244
243
|
/**
|
|
245
244
|
* Verify user identity.
|
|
@@ -292,6 +291,10 @@ declare class IdentityModule {
|
|
|
292
291
|
private consumeRedirectResult;
|
|
293
292
|
/**
|
|
294
293
|
* Close the identity dialog/inline UI if open.
|
|
294
|
+
*
|
|
295
|
+
* Tears down whichever surface is active: the hosted-widget iframe
|
|
296
|
+
* (default dialog mode — also releases the embedder's host scroll lock)
|
|
297
|
+
* or the local renderer (inline / local mode).
|
|
295
298
|
*/
|
|
296
299
|
close(): void;
|
|
297
300
|
/**
|
|
@@ -322,35 +325,15 @@ declare class IdentityModule {
|
|
|
322
325
|
}): Promise<VerifyResult>;
|
|
323
326
|
}
|
|
324
327
|
|
|
325
|
-
/**
|
|
326
|
-
* Retry Utility with Exponential Backoff
|
|
327
|
-
*
|
|
328
|
-
* Per CLAUDE.md §7: Retries allowed only if idempotent, MUST use exponential backoff.
|
|
329
|
-
*/
|
|
330
|
-
interface RetryOptions {
|
|
331
|
-
/** Maximum number of retry attempts (default: 3) */
|
|
332
|
-
maxAttempts?: number;
|
|
333
|
-
/** Base delay in milliseconds (default: 200) */
|
|
334
|
-
baseDelayMs?: number;
|
|
335
|
-
/** Maximum delay in milliseconds (default: 5000) */
|
|
336
|
-
maxDelayMs?: number;
|
|
337
|
-
/** Jitter factor 0-1 to randomize delays (default: 0.2) */
|
|
338
|
-
jitterFactor?: number;
|
|
339
|
-
/** Function to determine if error is retryable (default: checks for network/timeout/5xx) */
|
|
340
|
-
isRetryable?: (error: unknown) => boolean;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
328
|
/**
|
|
344
329
|
* SparkVault SDK HTTP Client
|
|
345
330
|
*/
|
|
346
331
|
|
|
347
332
|
interface RequestOptions {
|
|
348
|
-
method?: 'GET' | 'POST' | '
|
|
333
|
+
method?: 'GET' | 'POST' | 'DELETE';
|
|
349
334
|
headers?: Record<string, string>;
|
|
350
335
|
body?: unknown;
|
|
351
336
|
timeout?: number;
|
|
352
|
-
/** Enable automatic retry with exponential backoff (per CLAUDE.md §7) */
|
|
353
|
-
retry?: boolean | RetryOptions;
|
|
354
337
|
}
|
|
355
338
|
interface ApiResponse<T = unknown> {
|
|
356
339
|
data: T;
|
|
@@ -363,32 +346,12 @@ declare class HttpClient {
|
|
|
363
346
|
private getDefaultHeaders;
|
|
364
347
|
private getAccessToken;
|
|
365
348
|
request<T = unknown>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
366
|
-
/**
|
|
367
|
-
* Execute the actual HTTP request (internal implementation)
|
|
368
|
-
*/
|
|
369
|
-
private executeRequest;
|
|
370
|
-
/**
|
|
371
|
-
* Check if an error is safe to retry
|
|
372
|
-
* Per CLAUDE.md §7: Only retry on transient/network errors, not client errors
|
|
373
|
-
*/
|
|
374
|
-
private isRetryableError;
|
|
375
349
|
private parseResponse;
|
|
376
350
|
private createErrorFromResponse;
|
|
377
351
|
private unwrapApiResponse;
|
|
378
352
|
get<T = unknown>(path: string, options?: Omit<RequestOptions, 'method' | 'body'>): Promise<ApiResponse<T>>;
|
|
379
353
|
post<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
|
|
380
|
-
put<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
|
|
381
|
-
patch<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
|
|
382
354
|
delete<T = unknown>(path: string, options?: Omit<RequestOptions, 'method' | 'body'>): Promise<ApiResponse<T>>;
|
|
383
|
-
/**
|
|
384
|
-
* Request raw binary data (e.g., file downloads).
|
|
385
|
-
* Returns a Blob instead of parsed JSON.
|
|
386
|
-
*/
|
|
387
|
-
requestRaw(path: string, options?: RequestOptions): Promise<Blob>;
|
|
388
|
-
/**
|
|
389
|
-
* Execute the actual raw HTTP request (internal implementation)
|
|
390
|
-
*/
|
|
391
|
-
private executeRequestRaw;
|
|
392
355
|
}
|
|
393
356
|
|
|
394
357
|
/**
|
|
@@ -624,11 +587,22 @@ interface UploadCallable {
|
|
|
624
587
|
(options: UploadOptions): Promise<UploadResult>;
|
|
625
588
|
attach(selector: string, options: UploadAttachOptions): () => void;
|
|
626
589
|
close(): void;
|
|
590
|
+
/** Open the upload widget as a popup. Equivalent to calling `upload(options)`. */
|
|
591
|
+
pop(options: UploadOptions): Promise<UploadResult>;
|
|
592
|
+
/** Render the upload widget inline. Equivalent to `upload({ ...options, target })`. */
|
|
593
|
+
render(options: UploadOptions): Promise<UploadResult>;
|
|
627
594
|
}
|
|
628
595
|
declare class VaultsModule {
|
|
629
596
|
private readonly config;
|
|
630
597
|
private readonly http;
|
|
631
598
|
private readonly uploadModule;
|
|
599
|
+
/**
|
|
600
|
+
* Forge transfer client for authenticated ingot uploads. A dedicated
|
|
601
|
+
* instance: the widget's own client is session-scoped (reset/aborted with
|
|
602
|
+
* the widget lifecycle), and sharing it would let a widget close() abort
|
|
603
|
+
* an unrelated uploadIngot() transfer.
|
|
604
|
+
*/
|
|
605
|
+
private readonly uploadApi;
|
|
632
606
|
/**
|
|
633
607
|
* Upload to a vault with public upload enabled.
|
|
634
608
|
*
|