@sparkvault/sdk-js 1.24.4

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.
Files changed (63) hide show
  1. package/README.md +769 -0
  2. package/dist/api-base.d.ts +58 -0
  3. package/dist/auto-init.d.ts +32 -0
  4. package/dist/config.d.ts +41 -0
  5. package/dist/errors.d.ts +30 -0
  6. package/dist/health.d.ts +18 -0
  7. package/dist/http.d.ts +51 -0
  8. package/dist/identity/api.d.ts +110 -0
  9. package/dist/identity/container.d.ts +56 -0
  10. package/dist/identity/handlers/index.d.ts +9 -0
  11. package/dist/identity/handlers/passkey-handler.d.ts +69 -0
  12. package/dist/identity/handlers/sparklink-handler.d.ts +30 -0
  13. package/dist/identity/handlers/totp-handler.d.ts +52 -0
  14. package/dist/identity/index.d.ts +89 -0
  15. package/dist/identity/inline-container.d.ts +65 -0
  16. package/dist/identity/methods.d.ts +23 -0
  17. package/dist/identity/modal.d.ts +82 -0
  18. package/dist/identity/renderer.d.ts +146 -0
  19. package/dist/identity/state.d.ts +98 -0
  20. package/dist/identity/styles.d.ts +22 -0
  21. package/dist/identity/types.d.ts +221 -0
  22. package/dist/identity/utils/cooldown-timer.d.ts +73 -0
  23. package/dist/identity/utils/index.d.ts +5 -0
  24. package/dist/identity/utils.d.ts +39 -0
  25. package/dist/identity/views/app-not-activated.d.ts +21 -0
  26. package/dist/identity/views/base.d.ts +62 -0
  27. package/dist/identity/views/error.d.ts +25 -0
  28. package/dist/identity/views/icons.d.ts +38 -0
  29. package/dist/identity/views/identity-input.d.ts +48 -0
  30. package/dist/identity/views/index.d.ts +16 -0
  31. package/dist/identity/views/loading.d.ts +15 -0
  32. package/dist/identity/views/method-select.d.ts +29 -0
  33. package/dist/identity/views/passkey-prompt.d.ts +24 -0
  34. package/dist/identity/views/passkey.d.ts +38 -0
  35. package/dist/identity/views/service-unavailable.d.ts +21 -0
  36. package/dist/identity/views/sparklink-waiting.d.ts +40 -0
  37. package/dist/identity/views/totp-verify.d.ts +58 -0
  38. package/dist/index.d.ts +733 -0
  39. package/dist/logger.d.ts +45 -0
  40. package/dist/rng/index.d.ts +54 -0
  41. package/dist/rng/types.d.ts +26 -0
  42. package/dist/sparks/index.d.ts +37 -0
  43. package/dist/sparks/types.d.ts +56 -0
  44. package/dist/sparkvault.cjs.js +10167 -0
  45. package/dist/sparkvault.cjs.js.map +1 -0
  46. package/dist/sparkvault.esm.js +10152 -0
  47. package/dist/sparkvault.esm.js.map +1 -0
  48. package/dist/sparkvault.js +2 -0
  49. package/dist/sparkvault.js.map +1 -0
  50. package/dist/utils/base64url.d.ts +41 -0
  51. package/dist/utils/dom.d.ts +17 -0
  52. package/dist/utils/retry.d.ts +32 -0
  53. package/dist/vaults/index.d.ts +109 -0
  54. package/dist/vaults/types.d.ts +128 -0
  55. package/dist/vaults/upload/api.d.ts +36 -0
  56. package/dist/vaults/upload/container.d.ts +57 -0
  57. package/dist/vaults/upload/index.d.ts +75 -0
  58. package/dist/vaults/upload/inline-container.d.ts +75 -0
  59. package/dist/vaults/upload/modal.d.ts +79 -0
  60. package/dist/vaults/upload/renderer.d.ts +70 -0
  61. package/dist/vaults/upload/styles.d.ts +20 -0
  62. package/dist/vaults/upload/types.d.ts +182 -0
  63. package/package.json +63 -0
@@ -0,0 +1,733 @@
1
+ /**
2
+ * SparkVault SDK Configuration
3
+ */
4
+ interface SparkVaultConfig {
5
+ /** Account ID for Identity operations */
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;
17
+ /** Request timeout in milliseconds (default: 30000) */
18
+ timeout?: number;
19
+ /**
20
+ * Preload Identity configuration on SDK init (default: true).
21
+ * When enabled, the /config call is made immediately when the SDK initializes,
22
+ * so verify() opens instantly without waiting for the config fetch.
23
+ * Set to false to defer config loading until verify() is called.
24
+ */
25
+ preloadConfig?: boolean;
26
+ /** Enable backdrop blur on dialogs (default: true) */
27
+ backdropBlur?: boolean;
28
+ }
29
+ interface ResolvedConfig {
30
+ accountId: string;
31
+ timeout: number;
32
+ apiBaseUrl: string;
33
+ identityBaseUrl: string;
34
+ accessToken?: string;
35
+ getAccessToken?: () => string | null | Promise<string | null>;
36
+ apiKey?: string;
37
+ preloadConfig: boolean;
38
+ backdropBlur: boolean;
39
+ }
40
+
41
+ interface HealthCheckOptions {
42
+ timeout?: number;
43
+ }
44
+ interface HealthCheckResult {
45
+ online: boolean;
46
+ status: string;
47
+ httpStatus?: number;
48
+ checkedAt: number;
49
+ error?: string;
50
+ }
51
+ declare class HealthModule {
52
+ private readonly config;
53
+ constructor(config: ResolvedConfig);
54
+ check(options?: HealthCheckOptions): Promise<HealthCheckResult>;
55
+ isOnline(options?: HealthCheckOptions): Promise<boolean>;
56
+ private readStatus;
57
+ }
58
+
59
+ /**
60
+ * Identity Module Types
61
+ */
62
+ type AuthMethod = 'passkey' | 'totp_email' | 'totp_sms' | 'totp_voice' | 'sparklink' | 'social_google' | 'social_apple' | 'social_microsoft' | 'social_github' | 'social_facebook' | 'social_linkedin';
63
+ type Theme = 'light' | 'dark';
64
+ /**
65
+ * Auth context for OIDC or simple redirect flows.
66
+ * Used by hosted login pages to complete authorization flows.
67
+ */
68
+ interface AuthContext {
69
+ /** OIDC auth request ID for authorization code flow */
70
+ authRequestId?: string;
71
+ /** Simple redirect mode configuration */
72
+ simpleMode?: {
73
+ successUrl: string;
74
+ failureUrl: string;
75
+ state?: string;
76
+ /** Opaque server-side verify session backing success/failure URLs */
77
+ sessionId?: string;
78
+ };
79
+ }
80
+ interface VerifyOptions {
81
+ /** Pre-fill email address (mutually exclusive with phone) */
82
+ email?: string;
83
+ /** Pre-fill phone number in E.164 format, e.g. "+14155551234" (mutually exclusive with email) */
84
+ phone?: string;
85
+ /**
86
+ * Target element for inline rendering. Can be:
87
+ * - A CSS selector string (e.g., "#auth-container")
88
+ * - An HTMLElement reference
89
+ * - Omitted for dialog mode (default)
90
+ */
91
+ target?: string | HTMLElement;
92
+ /** Override backdrop blur for this dialog (uses global config if omitted) */
93
+ backdropBlur?: boolean;
94
+ /** Auth context for OIDC/simple mode flows (used by hosted login) */
95
+ authContext?: AuthContext;
96
+ /** Called when user cancels (if omitted, uses server-configured redirect) */
97
+ onCancel?: () => void;
98
+ /** Called when verification completes (if omitted, uses server-configured redirect) */
99
+ onSuccess?: (result: VerifyResult) => void;
100
+ /** Called on error (if omitted, uses server-configured redirect) */
101
+ onError?: (error: Error) => void;
102
+ }
103
+ /** Options for attach() - binds verification to element clicks */
104
+ interface AttachOptions {
105
+ /** Pre-fill email address */
106
+ email?: string;
107
+ /** Pre-fill phone number in E.164 format */
108
+ phone?: string;
109
+ /** Auth context for OIDC/simple mode flows */
110
+ authContext?: AuthContext;
111
+ /** Called when user cancels */
112
+ onCancel?: () => void;
113
+ /** Called when verification completes */
114
+ onSuccess?: (result: VerifyResult) => void;
115
+ /** Called on error */
116
+ onError?: (error: Error) => void;
117
+ }
118
+ interface VerifyResult {
119
+ /** Signed JWT token */
120
+ token: string;
121
+ /** Verified identity (email or phone) */
122
+ identity: string;
123
+ /** Type of identity verified */
124
+ identityType: 'email' | 'phone';
125
+ /** Redirect URL (only present for OIDC/simple mode flows) */
126
+ redirect?: string;
127
+ }
128
+ interface TokenClaims {
129
+ /** Issuer */
130
+ iss: string;
131
+ /** Subject (hashed identity) */
132
+ sub: string;
133
+ /** Audience (account ID for simple tokens, client ID for OIDC) */
134
+ aud: string;
135
+ /** Expiry (Unix seconds) */
136
+ exp: number;
137
+ /** Issued at (Unix seconds) */
138
+ iat: number;
139
+ /** Unique token ID for replay protection */
140
+ jti?: string;
141
+ /** Verified identity (email or phone) */
142
+ identity: string;
143
+ /** Identity type */
144
+ identity_type: 'email' | 'phone';
145
+ /** Verification timestamp (Unix seconds) */
146
+ verified_at: number;
147
+ /** Authentication method used */
148
+ method: string;
149
+ }
150
+
151
+ /**
152
+ * SparkVault SDK Error Types
153
+ */
154
+ declare class SparkVaultError extends Error {
155
+ readonly code: string;
156
+ readonly statusCode?: number;
157
+ readonly details?: Record<string, unknown>;
158
+ constructor(message: string, code: string, statusCode?: number, details?: Record<string, unknown>);
159
+ }
160
+ declare class AuthenticationError extends SparkVaultError {
161
+ constructor(message: string, details?: Record<string, unknown>);
162
+ }
163
+ declare class AuthorizationError extends SparkVaultError {
164
+ constructor(message: string, details?: Record<string, unknown>);
165
+ }
166
+ declare class ValidationError extends SparkVaultError {
167
+ constructor(message: string, details?: Record<string, unknown>);
168
+ }
169
+ declare class NetworkError extends SparkVaultError {
170
+ constructor(message: string, details?: Record<string, unknown>);
171
+ }
172
+ declare class TimeoutError extends SparkVaultError {
173
+ constructor(message?: string);
174
+ }
175
+ declare class UserCancelledError extends SparkVaultError {
176
+ constructor(message?: string);
177
+ }
178
+ declare class PopupBlockedError extends SparkVaultError {
179
+ constructor();
180
+ }
181
+
182
+ /**
183
+ * Identity Module
184
+ *
185
+ * Provides identity verification through dialog or inline UI.
186
+ * Supports passkey, TOTP, SparkLink, and social authentication.
187
+ *
188
+ * @example Dialog mode (immediate)
189
+ * const result = await sv.identity.verify();
190
+ *
191
+ * @example Dialog mode (attached to clicks)
192
+ * sv.identity.attach('.login-btn');
193
+ *
194
+ * @example Inline mode
195
+ * const result = await sv.identity.verify({ target: '#auth-container' });
196
+ */
197
+
198
+ declare class IdentityModule {
199
+ private readonly config;
200
+ private readonly api;
201
+ private renderer;
202
+ private attachedElements;
203
+ constructor(config: ResolvedConfig);
204
+ /**
205
+ * Verify user identity.
206
+ *
207
+ * - Without `target`: Opens a dialog (modal)
208
+ * - With `target`: Renders inline into the specified element
209
+ *
210
+ * @example Dialog mode
211
+ * const result = await sv.identity.verify();
212
+ * console.log(result.token, result.identity);
213
+ *
214
+ * @example Inline mode
215
+ * const result = await sv.identity.verify({
216
+ * target: '#auth-container',
217
+ * email: 'user@example.com'
218
+ * });
219
+ */
220
+ verify(options?: VerifyOptions): Promise<VerifyResult>;
221
+ /**
222
+ * Attach identity verification to element clicks.
223
+ * When any matching element is clicked, opens the verification dialog.
224
+ *
225
+ * @param selector - CSS selector for elements to attach to
226
+ * @param options - Verification options and callbacks
227
+ * @returns Cleanup function to remove event listeners
228
+ *
229
+ * @example
230
+ * const cleanup = sv.identity.attach('.login-btn', {
231
+ * onSuccess: (result) => console.log('Verified:', result.identity)
232
+ * });
233
+ *
234
+ * // Later, remove listeners
235
+ * cleanup();
236
+ */
237
+ attach(selector: string, options?: AttachOptions): () => void;
238
+ /**
239
+ * Verify and decode an identity token.
240
+ * Validates the token structure, expiry, and issuer.
241
+ *
242
+ * Note: For production use, verify the Ed25519 signature server-side
243
+ * using the JWKS endpoint.
244
+ */
245
+ verifyToken(token: string): Promise<TokenClaims>;
246
+ /**
247
+ * Close the identity dialog/inline UI if open.
248
+ */
249
+ close(): void;
250
+ /**
251
+ * Resolve target to an HTMLElement.
252
+ */
253
+ private createInlineContainer;
254
+ /**
255
+ * Open the identity verification modal as a popup. Equivalent to
256
+ * `verify(options)`.
257
+ */
258
+ pop(options?: VerifyOptions): Promise<VerifyResult>;
259
+ /**
260
+ * Render the identity verification UI inline into a target element.
261
+ * Equivalent to `verify({ ...options, target })`.
262
+ */
263
+ render(options: VerifyOptions & {
264
+ target: HTMLElement;
265
+ }): Promise<VerifyResult>;
266
+ }
267
+
268
+ /**
269
+ * Retry Utility with Exponential Backoff
270
+ *
271
+ * Per CLAUDE.md §7: Retries allowed only if idempotent, MUST use exponential backoff.
272
+ */
273
+ interface RetryOptions {
274
+ /** Maximum number of retry attempts (default: 3) */
275
+ maxAttempts?: number;
276
+ /** Base delay in milliseconds (default: 200) */
277
+ baseDelayMs?: number;
278
+ /** Maximum delay in milliseconds (default: 5000) */
279
+ maxDelayMs?: number;
280
+ /** Jitter factor 0-1 to randomize delays (default: 0.2) */
281
+ jitterFactor?: number;
282
+ /** Function to determine if error is retryable (default: checks for network/timeout/5xx) */
283
+ isRetryable?: (error: unknown) => boolean;
284
+ }
285
+
286
+ /**
287
+ * SparkVault SDK HTTP Client
288
+ */
289
+
290
+ interface RequestOptions {
291
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
292
+ headers?: Record<string, string>;
293
+ body?: unknown;
294
+ timeout?: number;
295
+ /** Enable automatic retry with exponential backoff (per CLAUDE.md §7) */
296
+ retry?: boolean | RetryOptions;
297
+ }
298
+ interface ApiResponse<T = unknown> {
299
+ data: T;
300
+ status: number;
301
+ headers: Headers;
302
+ }
303
+ declare class HttpClient {
304
+ private readonly config;
305
+ constructor(config: ResolvedConfig);
306
+ private getDefaultHeaders;
307
+ private getAccessToken;
308
+ request<T = unknown>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
309
+ /**
310
+ * Execute the actual HTTP request (internal implementation)
311
+ */
312
+ private executeRequest;
313
+ /**
314
+ * Check if an error is safe to retry
315
+ * Per CLAUDE.md §7: Only retry on transient/network errors, not client errors
316
+ */
317
+ private isRetryableError;
318
+ private parseResponse;
319
+ private createErrorFromResponse;
320
+ private unwrapApiResponse;
321
+ get<T = unknown>(path: string, options?: Omit<RequestOptions, 'method' | 'body'>): Promise<ApiResponse<T>>;
322
+ post<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
323
+ put<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
324
+ patch<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
325
+ delete<T = unknown>(path: string, options?: Omit<RequestOptions, 'method' | 'body'>): Promise<ApiResponse<T>>;
326
+ /**
327
+ * Request raw binary data (e.g., file downloads).
328
+ * Returns a Blob instead of parsed JSON.
329
+ */
330
+ requestRaw(path: string, options?: RequestOptions): Promise<Blob>;
331
+ /**
332
+ * Execute the actual raw HTTP request (internal implementation)
333
+ */
334
+ private executeRequestRaw;
335
+ }
336
+
337
+ /**
338
+ * Vaults Module Types
339
+ */
340
+ interface CreateVaultOptions {
341
+ /** Vault name */
342
+ name: string;
343
+ /** Store VMK server-side (less secure, more convenient) */
344
+ hostedVmk?: boolean;
345
+ }
346
+ interface Vault {
347
+ /** Vault ID */
348
+ id: string;
349
+ /** Vault name */
350
+ name: string;
351
+ /** Vault Master Key (24 chars) - STORE SECURELY! */
352
+ vmk: string;
353
+ /** Creation timestamp (Unix seconds) */
354
+ createdAt: number;
355
+ /** Whether VMK is hosted server-side */
356
+ hostedVmk: boolean;
357
+ }
358
+ interface UnsealedVault {
359
+ /** Vault ID */
360
+ id: string;
361
+ /** Vault name */
362
+ name: string;
363
+ /** Vault Access Token (short-lived session) */
364
+ vatToken: string;
365
+ /** VAT expiry timestamp (Unix seconds) */
366
+ expiresAt: number;
367
+ /** Number of ingots in vault */
368
+ ingotCount: number;
369
+ /** Total storage used in bytes */
370
+ storageBytes: number;
371
+ }
372
+ interface VaultSummary {
373
+ /** Vault ID */
374
+ id: string;
375
+ /** Vault name */
376
+ name: string;
377
+ /** Creation timestamp (Unix seconds) */
378
+ createdAt: number;
379
+ /** Number of ingots */
380
+ ingotCount: number;
381
+ /** Total storage used in bytes */
382
+ storageBytes: number;
383
+ /** Whether VMK is hosted server-side */
384
+ hostedVmk: boolean;
385
+ }
386
+ interface Ingot {
387
+ /** Ingot ID */
388
+ id: string;
389
+ /** Ingot name */
390
+ name: string;
391
+ /** Content type (MIME) */
392
+ contentType: string;
393
+ /** Size in bytes */
394
+ size: number;
395
+ /** Creation timestamp (Unix seconds) */
396
+ createdAt: number;
397
+ /** Ingot type: 'standard' or 'structured' */
398
+ type: 'standard' | 'structured';
399
+ }
400
+ interface UploadIngotOptions {
401
+ /** File to upload */
402
+ file: File | Blob;
403
+ /** Optional name (defaults to file name) */
404
+ name?: string;
405
+ /** Content type (auto-detected if not provided) */
406
+ contentType?: string;
407
+ /** Progress callback for Forge/TUS upload */
408
+ onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
409
+ }
410
+
411
+ /**
412
+ * Vault Upload Module Types
413
+ *
414
+ * Types for the embedded vault upload widget.
415
+ */
416
+ /**
417
+ * Branding configuration from vault upload info.
418
+ */
419
+ interface UploadBranding {
420
+ /** Organization name */
421
+ organizationName: string;
422
+ /** Light theme logo URL */
423
+ logoLightUrl: string | null;
424
+ /** Dark theme logo URL */
425
+ logoDarkUrl: string | null;
426
+ }
427
+ /**
428
+ * Encryption information for the vault.
429
+ */
430
+ interface EncryptionInfo {
431
+ /** Encryption algorithm (e.g., 'AES-256-GCM') */
432
+ algorithm: string;
433
+ /** Key derivation method (e.g., 'Triple Zero-Trust') */
434
+ keyDerivation: string;
435
+ /** Post-quantum protection status */
436
+ postQuantum: string;
437
+ }
438
+ /**
439
+ * Vault upload configuration from API.
440
+ */
441
+ interface VaultUploadConfig {
442
+ /** Vault ID */
443
+ vaultId: string;
444
+ /** Vault name */
445
+ vaultName: string;
446
+ /** Maximum upload size in bytes */
447
+ maxSizeBytes: number;
448
+ /** Branding information */
449
+ branding: UploadBranding;
450
+ /** Encryption details */
451
+ encryption: EncryptionInfo;
452
+ /** Forge status */
453
+ forgeStatus: 'active' | 'inactive';
454
+ }
455
+ /**
456
+ * Options for upload().
457
+ * - Without `target`: Opens a dialog (modal)
458
+ * - With `target`: Renders inline into the specified element
459
+ */
460
+ interface UploadOptions {
461
+ /** Vault ID to upload to */
462
+ vaultId: string;
463
+ /**
464
+ * Target element for inline rendering. Can be:
465
+ * - A CSS selector string (e.g., "#upload-container")
466
+ * - An HTMLElement reference
467
+ * - Omitted for dialog mode (default)
468
+ */
469
+ target?: string | HTMLElement;
470
+ /** Override backdrop blur for this dialog (uses global config if omitted) */
471
+ backdropBlur?: boolean;
472
+ /** Hide "Upload Another File" button on success screen (for single-file flows) */
473
+ hideUploadAnother?: boolean;
474
+ /** Callback when upload completes successfully (if omitted, uses server-configured redirect) */
475
+ onSuccess?: (result: UploadResult) => void;
476
+ /** Callback when an error occurs (if omitted, uses server-configured redirect) */
477
+ onError?: (error: Error) => void;
478
+ /** Callback when user cancels (if omitted, uses server-configured redirect) */
479
+ onCancel?: () => void;
480
+ /** Callback for upload progress */
481
+ onProgress?: (progress: UploadProgress) => void;
482
+ }
483
+ /** Options for attach() - binds upload to element clicks */
484
+ interface UploadAttachOptions {
485
+ /** Vault ID to upload to */
486
+ vaultId: string;
487
+ /** Callback when upload completes successfully */
488
+ onSuccess?: (result: UploadResult) => void;
489
+ /** Callback when an error occurs */
490
+ onError?: (error: Error) => void;
491
+ /** Callback when user cancels */
492
+ onCancel?: () => void;
493
+ /** Callback for upload progress */
494
+ onProgress?: (progress: UploadProgress) => void;
495
+ }
496
+ /**
497
+ * Upload progress information.
498
+ */
499
+ interface UploadProgress {
500
+ /** Bytes uploaded */
501
+ bytesUploaded: number;
502
+ /** Total bytes */
503
+ bytesTotal: number;
504
+ /** Percentage (0-100) */
505
+ percentage: number;
506
+ /** Current phase */
507
+ phase: 'uploading' | 'ceremony' | 'complete';
508
+ }
509
+ /**
510
+ * Successful upload result.
511
+ */
512
+ interface UploadResult {
513
+ /** Ingot ID */
514
+ ingotId: string;
515
+ /** Vault ID */
516
+ vaultId: string;
517
+ /** Original filename */
518
+ filename: string;
519
+ /** File size in bytes */
520
+ sizeBytes: number;
521
+ /** Upload timestamp (ISO 8601) */
522
+ uploadTime: string;
523
+ }
524
+
525
+ /**
526
+ * Vaults Module
527
+ *
528
+ * Create and manage encrypted vaults and ingots.
529
+ * Uses Triple Zero-Trust encryption (SVMK + AMK + VMK).
530
+ */
531
+
532
+ /**
533
+ * Callable upload interface with methods.
534
+ * Allows both `sv.vaults.upload(options)` and `sv.vaults.upload.attach(selector, options)`.
535
+ */
536
+ interface UploadCallable {
537
+ (options: UploadOptions): Promise<UploadResult>;
538
+ attach(selector: string, options: UploadAttachOptions): () => void;
539
+ close(): void;
540
+ }
541
+ declare class VaultsModule {
542
+ private readonly http;
543
+ private readonly uploadModule;
544
+ /**
545
+ * Upload to a vault with public upload enabled.
546
+ *
547
+ * @example Dialog mode
548
+ * const result = await sv.vaults.upload({ vaultId: 'vlt_abc123' });
549
+ *
550
+ * @example Attach to clicks
551
+ * sv.vaults.upload.attach('.upload-btn', { vaultId: 'vlt_abc123' });
552
+ *
553
+ * @example Inline mode
554
+ * sv.vaults.upload({ vaultId: 'vlt_abc123', target: '#upload-area' });
555
+ */
556
+ readonly upload: UploadCallable;
557
+ constructor(config: ResolvedConfig, http: HttpClient);
558
+ /**
559
+ * Create a new encrypted vault.
560
+ * IMPORTANT: Store the VMK securely - it cannot be recovered!
561
+ *
562
+ * @example
563
+ * const vault = await sv.vaults.create({ name: 'My Vault' });
564
+ * console.log('Save this VMK:', vault.vmk);
565
+ */
566
+ create(options: CreateVaultOptions): Promise<Vault>;
567
+ /**
568
+ * Unseal a vault to access its contents.
569
+ * Returns a short-lived Vault Access Token (VAT).
570
+ *
571
+ * @example
572
+ * const unsealed = await sv.vaults.unseal('vlt_abc', vmk);
573
+ * console.log('Ingots:', unsealed.ingotCount);
574
+ */
575
+ unseal(vaultId: string, vmk: string): Promise<UnsealedVault>;
576
+ /**
577
+ * List all vaults for the account.
578
+ *
579
+ * @example
580
+ * const vaults = await sv.vaults.list();
581
+ * vaults.forEach(v => console.log(v.name));
582
+ */
583
+ list(): Promise<VaultSummary[]>;
584
+ /**
585
+ * Delete a vault and all its ingots.
586
+ * This action is irreversible!
587
+ *
588
+ * @example
589
+ * await sv.vaults.delete('vlt_abc', vmk);
590
+ */
591
+ delete(vaultId: string, vmk: string): Promise<void>;
592
+ /**
593
+ * Upload a file as an ingot to an unsealed vault.
594
+ *
595
+ * @example
596
+ * const ingot = await sv.vaults.uploadIngot(unsealed, {
597
+ * file: myFile,
598
+ * name: 'document.pdf'
599
+ * });
600
+ */
601
+ uploadIngot(vault: UnsealedVault, options: UploadIngotOptions): Promise<Ingot>;
602
+ /**
603
+ * Download an ingot from an unsealed vault.
604
+ *
605
+ * @example
606
+ * const blob = await sv.vaults.downloadIngot(unsealed, 'ing_abc');
607
+ * const url = URL.createObjectURL(blob);
608
+ */
609
+ downloadIngot(vault: UnsealedVault, ingotId: string): Promise<Blob>;
610
+ /**
611
+ * List all ingots in an unsealed vault.
612
+ *
613
+ * @example
614
+ * const ingots = await sv.vaults.listIngots(unsealed);
615
+ * ingots.forEach(i => console.log(i.name, i.size));
616
+ */
617
+ listIngots(vault: UnsealedVault): Promise<Ingot[]>;
618
+ /**
619
+ * Delete an ingot from an unsealed vault.
620
+ *
621
+ * @example
622
+ * await sv.vaults.deleteIngot(unsealed, 'ing_abc');
623
+ */
624
+ deleteIngot(vault: UnsealedVault, ingotId: string): Promise<void>;
625
+ private validateCreateOptions;
626
+ private validateUploadOptions;
627
+ }
628
+
629
+ /**
630
+ * SparkVault Debug Logger
631
+ *
632
+ * Conditional logging that respects debug mode setting.
633
+ * When debug is enabled, logs detailed information to console.
634
+ * When disabled (default), only fatal errors are logged.
635
+ */
636
+ /**
637
+ * Enable or disable debug logging
638
+ */
639
+ declare function setDebugMode(enabled: boolean): void;
640
+ /**
641
+ * Logger object for convenient access
642
+ */
643
+ declare const logger: {
644
+ /**
645
+ * Debug level - verbose details for troubleshooting
646
+ */
647
+ debug: (message: string, ...args: unknown[]) => void;
648
+ /**
649
+ * Info level - general information
650
+ */
651
+ info: (message: string, ...args: unknown[]) => void;
652
+ /**
653
+ * Warn level - warnings that don't prevent operation
654
+ */
655
+ warn: (message: string, ...args: unknown[]) => void;
656
+ /**
657
+ * Error level - always logged regardless of debug mode
658
+ */
659
+ error: (message: string, ...args: unknown[]) => void;
660
+ /**
661
+ * Group related logs together (only in debug mode)
662
+ */
663
+ group: (label: string) => void;
664
+ /**
665
+ * End a log group
666
+ */
667
+ groupEnd: () => void;
668
+ };
669
+
670
+ /**
671
+ * SparkVault JavaScript SDK
672
+ *
673
+ * A unified SDK for Identity and Vaults.
674
+ *
675
+ * @example CDN Usage (Recommended)
676
+ * ```html
677
+ * <script
678
+ * src="https://cdn.sparkvault.com/sdk/v1/sparkvault.js"
679
+ * data-account-id="acc_your_account"
680
+ * ></script>
681
+ *
682
+ * <script>
683
+ * // SDK auto-initializes. Use JavaScript API:
684
+ * SparkVault.identity.attach('.login-btn', {
685
+ * onSuccess: (result) => console.log('Verified:', result.identity)
686
+ * });
687
+ * </script>
688
+ * ```
689
+ *
690
+ * @example npm/Bundler Usage
691
+ * ```typescript
692
+ * import SparkVault from '@sparkvault/sdk';
693
+ *
694
+ * const sv = SparkVault.init({ accountId: 'acc_your_account' });
695
+ *
696
+ * const result = await sv.identity.verify();
697
+ * console.log(result.identity, result.identityType);
698
+ * ```
699
+ */
700
+
701
+ declare class SparkVault {
702
+ /** Identity verification module */
703
+ readonly identity: IdentityModule;
704
+ /** Persistent encrypted storage module */
705
+ readonly vaults: VaultsModule;
706
+ /** API availability checks */
707
+ readonly health: HealthModule;
708
+ private readonly config;
709
+ private constructor();
710
+ /**
711
+ * Initialize the SparkVault SDK.
712
+ *
713
+ * @param config - SDK configuration
714
+ * @returns SparkVault instance
715
+ *
716
+ * @example
717
+ * const sv = SparkVault.init({
718
+ * accountId: 'acc_your_account'
719
+ * });
720
+ */
721
+ static init(config: SparkVaultConfig): SparkVault;
722
+ /** Get the SDK version */
723
+ static get version(): string;
724
+ }
725
+
726
+ declare global {
727
+ interface Window {
728
+ SparkVault: typeof SparkVault | SparkVault;
729
+ }
730
+ }
731
+
732
+ export { AuthenticationError, AuthorizationError, NetworkError, PopupBlockedError, SparkVault, SparkVaultError, TimeoutError, UserCancelledError, ValidationError, SparkVault as default, logger, setDebugMode };
733
+ export type { AuthMethod, CreateVaultOptions, HealthCheckOptions, HealthCheckResult, AttachOptions as IdentityAttachOptions, Ingot, SparkVaultConfig, Theme, TokenClaims, UnsealedVault, UploadAttachOptions, UploadBranding, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, Vault, VaultSummary, VaultUploadConfig, VerifyOptions, VerifyResult };