@sparkvault/sdk-js 2.2.1 → 2.2.3
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/errors.d.ts +23 -0
- package/dist/http.d.ts +38 -24
- package/dist/identity/api.d.ts +9 -1
- package/dist/identity/embedder.d.ts +8 -0
- package/dist/identity/handlers/sparklink-handler.d.ts +2 -0
- package/dist/identity/index.d.ts +4 -1
- package/dist/identity/renderer.d.ts +21 -0
- package/dist/identity/state.d.ts +2 -22
- package/dist/identity/types.d.ts +2 -0
- package/dist/index.d.ts +78 -44
- package/dist/sparkvault.cjs.js +839 -928
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +838 -929
- 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/errors.d.ts
CHANGED
|
@@ -16,6 +16,29 @@ export declare class AuthorizationError extends SparkVaultError {
|
|
|
16
16
|
export declare class ValidationError extends SparkVaultError {
|
|
17
17
|
constructor(message: string, details?: Record<string, unknown>);
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* The pooled-capacity resource a quota gate refers to.
|
|
21
|
+
* Storage and bandwidth gates surface low-capacity nudges and CTAs; seats and
|
|
22
|
+
* identity gate issuance (invites, DVAKs).
|
|
23
|
+
*/
|
|
24
|
+
export type QuotaResource = 'storage' | 'bandwidth' | 'seats' | 'identity';
|
|
25
|
+
/**
|
|
26
|
+
* Plan required gate (402 PLAN_REQUIRED) — the account has no active
|
|
27
|
+
* subscription and attempted a billable/create action. Surface a subscribe CTA
|
|
28
|
+
* to admins, or "ask your account admin" to members.
|
|
29
|
+
*/
|
|
30
|
+
export declare class PlanRequiredError extends SparkVaultError {
|
|
31
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Quota exceeded gate (402 QUOTA_EXCEEDED) — a pooled-capacity or seat limit is
|
|
35
|
+
* exhausted. `resource` identifies which pool so callers can branch on the CTA
|
|
36
|
+
* (add a capacity block for storage/bandwidth, free a seat for seats).
|
|
37
|
+
*/
|
|
38
|
+
export declare class QuotaExceededError extends SparkVaultError {
|
|
39
|
+
readonly resource?: QuotaResource;
|
|
40
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
41
|
+
}
|
|
19
42
|
export declare class NetworkError extends SparkVaultError {
|
|
20
43
|
constructor(message: string, details?: Record<string, unknown>);
|
|
21
44
|
}
|
package/dist/http.d.ts
CHANGED
|
@@ -2,17 +2,46 @@
|
|
|
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
|
-
|
|
12
|
-
|
|
10
|
+
}
|
|
11
|
+
/** Capacity state for a pool, driving low-capacity nudges in the UI. */
|
|
12
|
+
export type PoolState = 'ok' | 'notice' | 'warning' | 'exhausted';
|
|
13
|
+
/** Shared storage-pool capacity snapshot carried on `meta.pools`. */
|
|
14
|
+
export interface StoragePool {
|
|
15
|
+
used_gb: number;
|
|
16
|
+
limit_gb: number;
|
|
17
|
+
pct: number;
|
|
18
|
+
state: PoolState;
|
|
19
|
+
}
|
|
20
|
+
/** Shared bandwidth-pool capacity snapshot carried on `meta.pools`. */
|
|
21
|
+
export interface BandwidthPool {
|
|
22
|
+
used_gb: number;
|
|
23
|
+
limit_gb: number;
|
|
24
|
+
pct: number;
|
|
25
|
+
state: PoolState;
|
|
26
|
+
/** ISO timestamp when the bandwidth cycle resets. */
|
|
27
|
+
cycle_resets_at: string;
|
|
28
|
+
}
|
|
29
|
+
/** Pooled-capacity snapshot that rides on every response's `meta`. */
|
|
30
|
+
export interface PoolsMeta {
|
|
31
|
+
storage: StoragePool;
|
|
32
|
+
bandwidth: BandwidthPool;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Response envelope metadata. `pools` rides on responses so clients can render
|
|
36
|
+
* low-capacity nudges without a separate fetch. Unknown fields are preserved.
|
|
37
|
+
*/
|
|
38
|
+
export interface ResponseMeta {
|
|
39
|
+
pools?: PoolsMeta;
|
|
40
|
+
[key: string]: unknown;
|
|
13
41
|
}
|
|
14
42
|
export interface ApiResponse<T = unknown> {
|
|
15
43
|
data: T;
|
|
44
|
+
meta?: ResponseMeta;
|
|
16
45
|
status: number;
|
|
17
46
|
headers: Headers;
|
|
18
47
|
}
|
|
@@ -22,30 +51,15 @@ export declare class HttpClient {
|
|
|
22
51
|
private getDefaultHeaders;
|
|
23
52
|
private getAccessToken;
|
|
24
53
|
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
54
|
private parseResponse;
|
|
35
55
|
private createErrorFromResponse;
|
|
36
56
|
private unwrapApiResponse;
|
|
57
|
+
/**
|
|
58
|
+
* Pull the `meta` envelope (carrying `pools` capacity snapshots) off a
|
|
59
|
+
* standard `{ data, meta }` response. Returns undefined for bare responses.
|
|
60
|
+
*/
|
|
61
|
+
private extractResponseMeta;
|
|
37
62
|
get<T = unknown>(path: string, options?: Omit<RequestOptions, 'method' | 'body'>): Promise<ApiResponse<T>>;
|
|
38
63
|
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
64
|
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
65
|
}
|
package/dist/identity/api.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import type { ResolvedConfig } from '../config';
|
|
8
8
|
import { SparkVaultApi } from '../api-base';
|
|
9
9
|
import { SparkVaultError } from '../errors';
|
|
10
|
-
import type { SdkConfig, TotpSendResponse, TotpVerifyResponse, PasskeyChallengeResponse, PasskeyVerifyResponse, SecondFactorVerifyResponse, SparkLinkSendResponse, AuthContext } from './types';
|
|
10
|
+
import type { SdkConfig, TotpSendResponse, TotpVerifyResponse, PasskeyChallengeResponse, PasskeyVerifyResponse, SecondFactorVerifyResponse, SparkLinkSendResponse, AuthContext, VerifyResult } from './types';
|
|
11
11
|
export declare class IdentityApi extends SparkVaultApi {
|
|
12
12
|
private readonly config;
|
|
13
13
|
/** Cached config promise - allows preloading and deduplication */
|
|
@@ -113,6 +113,14 @@ export declare class IdentityApi extends SparkVaultApi {
|
|
|
113
113
|
* Includes connectionId for WebSocket push notification of verification result.
|
|
114
114
|
*/
|
|
115
115
|
sendSparkLink(email: string, connectionId: string, authContext?: AuthContext): Promise<SparkLinkSendResponse>;
|
|
116
|
+
/**
|
|
117
|
+
* Claim the SparkLink verification result by kindling — the WebSocket-loss
|
|
118
|
+
* fallback. The SDK calls this when its socket was suspended with the tab and
|
|
119
|
+
* it refocuses. Returns the verified result, or null while still pending (not
|
|
120
|
+
* yet clicked) or already consumed. The read burns the server-side spark, so
|
|
121
|
+
* the result can be claimed exactly once.
|
|
122
|
+
*/
|
|
123
|
+
consumeSparkLinkResult(kindling: string): Promise<VerifyResult | null>;
|
|
116
124
|
}
|
|
117
125
|
export declare class IdentityApiError extends SparkVaultError {
|
|
118
126
|
constructor(message: string, code: string, statusCode: number, details?: Record<string, unknown>);
|
|
@@ -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
|
/**
|
|
@@ -24,6 +24,10 @@ export declare class IdentityRenderer {
|
|
|
24
24
|
private currentView;
|
|
25
25
|
private focusTimeoutId;
|
|
26
26
|
private sparkLinkWs;
|
|
27
|
+
private sparkLinkKindling;
|
|
28
|
+
private sparkLinkVisibilityHandler;
|
|
29
|
+
private sparkLinkClaiming;
|
|
30
|
+
private sparkLinkRetryTimer;
|
|
27
31
|
constructor(container: Container, api: IdentityApi, options: VerifyOptions, callbacks: RendererCallbacks);
|
|
28
32
|
/**
|
|
29
33
|
* Fire the host's onSuccess callback, swallowing any exception so a
|
|
@@ -169,6 +173,23 @@ export declare class IdentityRenderer {
|
|
|
169
173
|
* delegate navigation entirely to the SDK.
|
|
170
174
|
*/
|
|
171
175
|
private handleSparkLinkVerified;
|
|
176
|
+
/**
|
|
177
|
+
* Arm the WebSocket-loss fallback for the waiting screen.
|
|
178
|
+
*
|
|
179
|
+
* While waiting for the emailed link, the socket can be dropped when the tab
|
|
180
|
+
* is suspended (mobile: the user leaves to the mail app). On refocus, if the
|
|
181
|
+
* socket is no longer open, reclaim the verified result once by kindling. A
|
|
182
|
+
* single ~2s retry covers returning before the server finished writing it.
|
|
183
|
+
* Deliberately NOT a polling loop — it fires only on refocus, and only when
|
|
184
|
+
* the socket is actually gone.
|
|
185
|
+
*/
|
|
186
|
+
private armSparkLinkRefocusClaim;
|
|
187
|
+
/**
|
|
188
|
+
* Reclaim the verified result by kindling. Single attempt; if still pending
|
|
189
|
+
* and allowRetry, schedule exactly one ~2s retry, then stop (the next refocus
|
|
190
|
+
* or Resend can try again).
|
|
191
|
+
*/
|
|
192
|
+
private claimSparkLinkResult;
|
|
172
193
|
/**
|
|
173
194
|
* Clean up SparkLink WebSocket connection.
|
|
174
195
|
*/
|
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/identity/types.d.ts
CHANGED
|
@@ -237,6 +237,8 @@ export interface SecondFactorVerifyResponse {
|
|
|
237
237
|
export interface SparkLinkSendResponse {
|
|
238
238
|
sparkId: string;
|
|
239
239
|
expiresAt: number;
|
|
240
|
+
/** Login-ceremony handle for the WebSocket-loss fallback claim (see api.consumeSparkLinkResult). */
|
|
241
|
+
kindling?: string;
|
|
240
242
|
}
|
|
241
243
|
export type IdentityViewState = {
|
|
242
244
|
view: 'loading';
|
package/dist/index.d.ts
CHANGED
|
@@ -205,6 +205,29 @@ declare class AuthorizationError extends SparkVaultError {
|
|
|
205
205
|
declare class ValidationError extends SparkVaultError {
|
|
206
206
|
constructor(message: string, details?: Record<string, unknown>);
|
|
207
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* The pooled-capacity resource a quota gate refers to.
|
|
210
|
+
* Storage and bandwidth gates surface low-capacity nudges and CTAs; seats and
|
|
211
|
+
* identity gate issuance (invites, DVAKs).
|
|
212
|
+
*/
|
|
213
|
+
type QuotaResource = 'storage' | 'bandwidth' | 'seats' | 'identity';
|
|
214
|
+
/**
|
|
215
|
+
* Plan required gate (402 PLAN_REQUIRED) — the account has no active
|
|
216
|
+
* subscription and attempted a billable/create action. Surface a subscribe CTA
|
|
217
|
+
* to admins, or "ask your account admin" to members.
|
|
218
|
+
*/
|
|
219
|
+
declare class PlanRequiredError extends SparkVaultError {
|
|
220
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Quota exceeded gate (402 QUOTA_EXCEEDED) — a pooled-capacity or seat limit is
|
|
224
|
+
* exhausted. `resource` identifies which pool so callers can branch on the CTA
|
|
225
|
+
* (add a capacity block for storage/bandwidth, free a seat for seats).
|
|
226
|
+
*/
|
|
227
|
+
declare class QuotaExceededError extends SparkVaultError {
|
|
228
|
+
readonly resource?: QuotaResource;
|
|
229
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
230
|
+
}
|
|
208
231
|
declare class NetworkError extends SparkVaultError {
|
|
209
232
|
constructor(message: string, details?: Record<string, unknown>);
|
|
210
233
|
}
|
|
@@ -239,7 +262,6 @@ declare class IdentityModule {
|
|
|
239
262
|
private readonly api;
|
|
240
263
|
private renderer;
|
|
241
264
|
private embedder;
|
|
242
|
-
private attachedElements;
|
|
243
265
|
constructor(config: ResolvedConfig);
|
|
244
266
|
/**
|
|
245
267
|
* Verify user identity.
|
|
@@ -292,6 +314,10 @@ declare class IdentityModule {
|
|
|
292
314
|
private consumeRedirectResult;
|
|
293
315
|
/**
|
|
294
316
|
* Close the identity dialog/inline UI if open.
|
|
317
|
+
*
|
|
318
|
+
* Tears down whichever surface is active: the hosted-widget iframe
|
|
319
|
+
* (default dialog mode — also releases the embedder's host scroll lock)
|
|
320
|
+
* or the local renderer (inline / local mode).
|
|
295
321
|
*/
|
|
296
322
|
close(): void;
|
|
297
323
|
/**
|
|
@@ -322,38 +348,50 @@ declare class IdentityModule {
|
|
|
322
348
|
}): Promise<VerifyResult>;
|
|
323
349
|
}
|
|
324
350
|
|
|
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
351
|
/**
|
|
344
352
|
* SparkVault SDK HTTP Client
|
|
345
353
|
*/
|
|
346
354
|
|
|
347
355
|
interface RequestOptions {
|
|
348
|
-
method?: 'GET' | 'POST' | '
|
|
356
|
+
method?: 'GET' | 'POST' | 'DELETE';
|
|
349
357
|
headers?: Record<string, string>;
|
|
350
358
|
body?: unknown;
|
|
351
359
|
timeout?: number;
|
|
352
|
-
|
|
353
|
-
|
|
360
|
+
}
|
|
361
|
+
/** Capacity state for a pool, driving low-capacity nudges in the UI. */
|
|
362
|
+
type PoolState = 'ok' | 'notice' | 'warning' | 'exhausted';
|
|
363
|
+
/** Shared storage-pool capacity snapshot carried on `meta.pools`. */
|
|
364
|
+
interface StoragePool {
|
|
365
|
+
used_gb: number;
|
|
366
|
+
limit_gb: number;
|
|
367
|
+
pct: number;
|
|
368
|
+
state: PoolState;
|
|
369
|
+
}
|
|
370
|
+
/** Shared bandwidth-pool capacity snapshot carried on `meta.pools`. */
|
|
371
|
+
interface BandwidthPool {
|
|
372
|
+
used_gb: number;
|
|
373
|
+
limit_gb: number;
|
|
374
|
+
pct: number;
|
|
375
|
+
state: PoolState;
|
|
376
|
+
/** ISO timestamp when the bandwidth cycle resets. */
|
|
377
|
+
cycle_resets_at: string;
|
|
378
|
+
}
|
|
379
|
+
/** Pooled-capacity snapshot that rides on every response's `meta`. */
|
|
380
|
+
interface PoolsMeta {
|
|
381
|
+
storage: StoragePool;
|
|
382
|
+
bandwidth: BandwidthPool;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Response envelope metadata. `pools` rides on responses so clients can render
|
|
386
|
+
* low-capacity nudges without a separate fetch. Unknown fields are preserved.
|
|
387
|
+
*/
|
|
388
|
+
interface ResponseMeta {
|
|
389
|
+
pools?: PoolsMeta;
|
|
390
|
+
[key: string]: unknown;
|
|
354
391
|
}
|
|
355
392
|
interface ApiResponse<T = unknown> {
|
|
356
393
|
data: T;
|
|
394
|
+
meta?: ResponseMeta;
|
|
357
395
|
status: number;
|
|
358
396
|
headers: Headers;
|
|
359
397
|
}
|
|
@@ -363,32 +401,17 @@ declare class HttpClient {
|
|
|
363
401
|
private getDefaultHeaders;
|
|
364
402
|
private getAccessToken;
|
|
365
403
|
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
404
|
private parseResponse;
|
|
376
405
|
private createErrorFromResponse;
|
|
377
406
|
private unwrapApiResponse;
|
|
407
|
+
/**
|
|
408
|
+
* Pull the `meta` envelope (carrying `pools` capacity snapshots) off a
|
|
409
|
+
* standard `{ data, meta }` response. Returns undefined for bare responses.
|
|
410
|
+
*/
|
|
411
|
+
private extractResponseMeta;
|
|
378
412
|
get<T = unknown>(path: string, options?: Omit<RequestOptions, 'method' | 'body'>): Promise<ApiResponse<T>>;
|
|
379
413
|
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
414
|
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
415
|
}
|
|
393
416
|
|
|
394
417
|
/**
|
|
@@ -624,11 +647,22 @@ interface UploadCallable {
|
|
|
624
647
|
(options: UploadOptions): Promise<UploadResult>;
|
|
625
648
|
attach(selector: string, options: UploadAttachOptions): () => void;
|
|
626
649
|
close(): void;
|
|
650
|
+
/** Open the upload widget as a popup. Equivalent to calling `upload(options)`. */
|
|
651
|
+
pop(options: UploadOptions): Promise<UploadResult>;
|
|
652
|
+
/** Render the upload widget inline. Equivalent to `upload({ ...options, target })`. */
|
|
653
|
+
render(options: UploadOptions): Promise<UploadResult>;
|
|
627
654
|
}
|
|
628
655
|
declare class VaultsModule {
|
|
629
656
|
private readonly config;
|
|
630
657
|
private readonly http;
|
|
631
658
|
private readonly uploadModule;
|
|
659
|
+
/**
|
|
660
|
+
* Forge transfer client for authenticated ingot uploads. A dedicated
|
|
661
|
+
* instance: the widget's own client is session-scoped (reset/aborted with
|
|
662
|
+
* the widget lifecycle), and sharing it would let a widget close() abort
|
|
663
|
+
* an unrelated uploadIngot() transfer.
|
|
664
|
+
*/
|
|
665
|
+
private readonly uploadApi;
|
|
632
666
|
/**
|
|
633
667
|
* Upload to a vault with public upload enabled.
|
|
634
668
|
*
|
|
@@ -818,5 +852,5 @@ declare global {
|
|
|
818
852
|
}
|
|
819
853
|
}
|
|
820
854
|
|
|
821
|
-
export { AuthenticationError, AuthorizationError, NetworkError, PopupBlockedError, SparkVault, SparkVaultError, TimeoutError, UserCancelledError, ValidationError, SparkVault as default, logger, setDebugMode };
|
|
822
|
-
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 };
|
|
855
|
+
export { AuthenticationError, AuthorizationError, NetworkError, PlanRequiredError, PopupBlockedError, QuotaExceededError, SparkVault, SparkVaultError, TimeoutError, UserCancelledError, ValidationError, SparkVault as default, logger, setDebugMode };
|
|
856
|
+
export type { ApiResponse, AuthMethod, BandwidthPool, CreateVaultOptions, CreatedIngot, HealthCheckOptions, HealthCheckResult, AttachOptions as IdentityAttachOptions, Ingot, PoolState, PoolsMeta, QuotaResource, ResponseMeta, SparkVaultConfig, StoragePool, Theme, TokenClaims, UnsealedVault, UploadAttachOptions, UploadBranding, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, Vault, VaultSummary, VaultUploadConfig, VerifyOptions, VerifyResult };
|