@sparkvault/sdk-js 2.2.5 → 4.1.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.
Files changed (57) hide show
  1. package/README.md +5 -5
  2. package/dist/auto-init.d.ts +1 -1
  3. package/dist/entropy/index.d.ts +28 -0
  4. package/dist/entropy/types.d.ts +32 -0
  5. package/dist/folders/index.d.ts +77 -0
  6. package/dist/folders/types.d.ts +64 -0
  7. package/dist/http.d.ts +3 -1
  8. package/dist/index.d.ts +982 -78
  9. package/dist/ingots/index.d.ts +183 -0
  10. package/dist/ingots/types.d.ts +286 -0
  11. package/dist/{identity → products/identity}/api.d.ts +8 -7
  12. package/dist/{identity → products/identity}/embedder.d.ts +1 -1
  13. package/dist/{identity → products/identity}/index.d.ts +7 -7
  14. package/dist/{identity → products/identity}/types.d.ts +15 -0
  15. package/dist/{identity → products/identity}/utils.d.ts +1 -1
  16. package/dist/products/index.d.ts +18 -0
  17. package/dist/sparks/index.d.ts +65 -0
  18. package/dist/sparks/types.d.ts +174 -0
  19. package/dist/sparkvault.cjs.js +1102 -111
  20. package/dist/sparkvault.cjs.js.map +1 -1
  21. package/dist/sparkvault.esm.js +1096 -112
  22. package/dist/sparkvault.esm.js.map +1 -1
  23. package/dist/sparkvault.js +1 -1
  24. package/dist/sparkvault.js.map +1 -1
  25. package/dist/vaults/index.d.ts +102 -34
  26. package/dist/vaults/types.d.ts +121 -57
  27. package/dist/vaults/upload/api.d.ts +1 -1
  28. package/package.json +1 -1
  29. /package/dist/{identity → products/identity}/container.d.ts +0 -0
  30. /package/dist/{identity → products/identity}/handlers/index.d.ts +0 -0
  31. /package/dist/{identity → products/identity}/handlers/passkey-handler.d.ts +0 -0
  32. /package/dist/{identity → products/identity}/handlers/sparklink-handler.d.ts +0 -0
  33. /package/dist/{identity → products/identity}/handlers/totp-handler.d.ts +0 -0
  34. /package/dist/{identity → products/identity}/inline-container.d.ts +0 -0
  35. /package/dist/{identity → products/identity}/methods.d.ts +0 -0
  36. /package/dist/{identity → products/identity}/modal.d.ts +0 -0
  37. /package/dist/{identity → products/identity}/renderer.d.ts +0 -0
  38. /package/dist/{identity → products/identity}/state.d.ts +0 -0
  39. /package/dist/{identity → products/identity}/styles.d.ts +0 -0
  40. /package/dist/{identity → products/identity}/utils/cooldown-timer.d.ts +0 -0
  41. /package/dist/{identity → products/identity}/utils/index.d.ts +0 -0
  42. /package/dist/{identity → products/identity}/views/backup-verify.d.ts +0 -0
  43. /package/dist/{identity → products/identity}/views/base.d.ts +0 -0
  44. /package/dist/{identity → products/identity}/views/error.d.ts +0 -0
  45. /package/dist/{identity → products/identity}/views/icons.d.ts +0 -0
  46. /package/dist/{identity → products/identity}/views/identity-input.d.ts +0 -0
  47. /package/dist/{identity → products/identity}/views/index.d.ts +0 -0
  48. /package/dist/{identity → products/identity}/views/loading.d.ts +0 -0
  49. /package/dist/{identity → products/identity}/views/method-select.d.ts +0 -0
  50. /package/dist/{identity → products/identity}/views/origin-not-allowed.d.ts +0 -0
  51. /package/dist/{identity → products/identity}/views/passkey-prompt.d.ts +0 -0
  52. /package/dist/{identity → products/identity}/views/passkey.d.ts +0 -0
  53. /package/dist/{identity → products/identity}/views/product-not-configured.d.ts +0 -0
  54. /package/dist/{identity → products/identity}/views/service-unavailable.d.ts +0 -0
  55. /package/dist/{identity → products/identity}/views/sparklink-waiting.d.ts +0 -0
  56. /package/dist/{identity → products/identity}/views/totp-verify.d.ts +0 -0
  57. /package/dist/{identity → products/identity}/views/two-factor.d.ts +0 -0
@@ -1,12 +1,14 @@
1
1
  /**
2
2
  * Vaults Module
3
3
  *
4
- * Create and manage encrypted vaults and ingots.
5
- * Uses Triple Zero-Trust encryption (SVMK + AMK + VMK).
4
+ * Create and manage encrypted vaults (the control plane). Uses Triple
5
+ * Zero-Trust encryption (SVMK + AMK + VMK). Ingot, folder, spark, and entropy
6
+ * operations live in their own modules; this module owns the vault record,
7
+ * its sharing/upload configuration, and the browser upload widget.
6
8
  */
7
9
  import type { ResolvedConfig } from '../config';
8
10
  import { HttpClient } from '../http';
9
- import type { CreateVaultOptions, Vault, UnsealedVault, VaultSummary, Ingot, CreatedIngot, UploadIngotOptions } from './types';
11
+ import type { CreateVaultOptions, Vault, UnsealedVault, VaultSummary, VaultDetail, UpdatedVault, VaultSharingConfig, VaultSharingOptions, AccessLogRetention, VaultUploadSettings, UpdateVaultUploadOptions } from './types';
10
12
  import { type UploadOptions, type UploadAttachOptions, type UploadResult } from './upload';
11
13
  /**
12
14
  * Callable upload interface with methods.
@@ -22,16 +24,8 @@ export interface UploadCallable {
22
24
  render(options: UploadOptions): Promise<UploadResult>;
23
25
  }
24
26
  export declare class VaultsModule {
25
- private readonly config;
26
27
  private readonly http;
27
28
  private readonly uploadModule;
28
- /**
29
- * Forge transfer client for authenticated ingot uploads. A dedicated
30
- * instance: the widget's own client is session-scoped (reset/aborted with
31
- * the widget lifecycle), and sharing it would let a widget close() abort
32
- * an unrelated uploadIngot() transfer.
33
- */
34
- private readonly uploadApi;
35
29
  /**
36
30
  * Upload to a vault with public upload enabled.
37
31
  *
@@ -61,7 +55,7 @@ export declare class VaultsModule {
61
55
  *
62
56
  * @example
63
57
  * const unsealed = await sv.vaults.unseal('vlt_abc', vmk);
64
- * console.log('Ingots:', unsealed.ingotCount);
58
+ * console.log('Token:', unsealed.vatToken);
65
59
  */
66
60
  unseal(vaultId: string, vmk: string): Promise<UnsealedVault>;
67
61
  /**
@@ -73,50 +67,124 @@ export declare class VaultsModule {
73
67
  */
74
68
  list(): Promise<VaultSummary[]>;
75
69
  /**
76
- * Delete a vault and all its ingots.
77
- * This action is irreversible!
70
+ * Get a single vault's detail.
71
+ *
72
+ * @example
73
+ * const vault = await sv.vaults.get('vlt_abc');
74
+ * console.log(vault.status, vault.ingotCount);
75
+ */
76
+ get(vaultId: string): Promise<VaultDetail>;
77
+ /**
78
+ * Rename a vault.
79
+ *
80
+ * @example
81
+ * await sv.vaults.update('vlt_abc', { name: 'Renamed Vault' });
82
+ */
83
+ update(vaultId: string, options: {
84
+ name: string;
85
+ }): Promise<UpdatedVault>;
86
+ /**
87
+ * Seal a vault, revoking all active access tokens.
88
+ *
89
+ * @example
90
+ * await sv.vaults.seal('vlt_abc');
91
+ */
92
+ seal(vaultId: string): Promise<void>;
93
+ /**
94
+ * Delete a vault and all its ingots. This action is irreversible!
78
95
  *
79
96
  * @example
80
97
  * await sv.vaults.delete('vlt_abc', vmk);
81
98
  */
82
99
  delete(vaultId: string, vmk: string): Promise<void>;
83
100
  /**
84
- * Upload a file as an ingot to an unsealed vault.
101
+ * Get a vault's public-sharing configuration.
102
+ *
103
+ * @example
104
+ * const sharing = await sv.vaults.getSharingConfig('vlt_abc');
105
+ */
106
+ getSharingConfig(vaultId: string): Promise<VaultSharingConfig>;
107
+ /**
108
+ * Enable public sharing for a vault.
109
+ *
110
+ * @example
111
+ * await sv.vaults.enableSharing('vlt_abc', vmk, { sessionLengthSeconds: 3600 });
112
+ */
113
+ enableSharing(vaultId: string, vmk: string, options?: VaultSharingOptions): Promise<VaultSharingConfig>;
114
+ /**
115
+ * Disable public sharing for a vault.
116
+ *
117
+ * @example
118
+ * await sv.vaults.disableSharing('vlt_abc');
119
+ */
120
+ disableSharing(vaultId: string): Promise<VaultSharingConfig>;
121
+ /**
122
+ * Update a vault's sharing configuration (without changing enabled state).
123
+ *
124
+ * @example
125
+ * await sv.vaults.updateSharingConfig('vlt_abc', { allIngotsPublic: true });
126
+ */
127
+ updateSharingConfig(vaultId: string, config: VaultSharingOptions): Promise<VaultSharingConfig>;
128
+ /**
129
+ * Get a vault's access-log retention window.
130
+ *
131
+ * @example
132
+ * const { retentionSeconds } = await sv.vaults.getAccessLogRetention('vlt_abc');
133
+ */
134
+ getAccessLogRetention(vaultId: string): Promise<AccessLogRetention>;
135
+ /**
136
+ * Update a vault's access-log retention window.
137
+ *
138
+ * @example
139
+ * await sv.vaults.updateAccessLogRetention('vlt_abc', 7776000);
140
+ */
141
+ updateAccessLogRetention(vaultId: string, seconds: number): Promise<AccessLogRetention>;
142
+ /**
143
+ * Get a vault's upload-channel configuration.
144
+ *
145
+ * @example
146
+ * const upload = await sv.vaults.getUploadConfig('vlt_abc');
147
+ */
148
+ getUploadConfig(vaultId: string): Promise<VaultUploadSettings>;
149
+ /**
150
+ * Enable the public upload portal for a vault.
151
+ *
152
+ * @example
153
+ * await sv.vaults.enableUploadPortal('vlt_abc', vmk);
154
+ */
155
+ enableUploadPortal(vaultId: string, vmk: string): Promise<VaultUploadSettings>;
156
+ /**
157
+ * Disable the public upload portal for a vault.
85
158
  *
86
159
  * @example
87
- * const ingot = await sv.vaults.uploadIngot(unsealed, {
88
- * file: myFile,
89
- * name: 'document.pdf'
90
- * });
160
+ * await sv.vaults.disableUploadPortal('vlt_abc');
91
161
  */
92
- uploadIngot(vault: UnsealedVault, options: UploadIngotOptions): Promise<CreatedIngot>;
162
+ disableUploadPortal(vaultId: string): Promise<VaultUploadSettings>;
93
163
  /**
94
- * Download an ingot from an unsealed vault.
164
+ * Enable the upload widget for a vault.
95
165
  *
96
166
  * @example
97
- * const blob = await sv.vaults.downloadIngot(unsealed, 'ing_abc');
98
- * const url = URL.createObjectURL(blob);
167
+ * await sv.vaults.enableUploadWidget('vlt_abc', vmk);
99
168
  */
100
- downloadIngot(vault: UnsealedVault, ingotId: string): Promise<Blob>;
169
+ enableUploadWidget(vaultId: string, vmk: string): Promise<VaultUploadSettings>;
101
170
  /**
102
- * List all ingots in an unsealed vault.
171
+ * Disable the upload widget for a vault.
103
172
  *
104
173
  * @example
105
- * const ingots = await sv.vaults.listIngots(unsealed);
106
- * ingots.forEach(i => console.log(i.name, i.size));
174
+ * await sv.vaults.disableUploadWidget('vlt_abc');
107
175
  */
108
- listIngots(vault: UnsealedVault): Promise<Ingot[]>;
176
+ disableUploadWidget(vaultId: string): Promise<VaultUploadSettings>;
109
177
  /**
110
- * Delete an ingot from an unsealed vault.
178
+ * Update a vault's upload settings (max size, notification email).
111
179
  *
112
180
  * @example
113
- * await sv.vaults.deleteIngot(unsealed, 'ing_abc');
181
+ * await sv.vaults.updateUploadConfig('vlt_abc', { maxSizeBytes: 1048576 });
114
182
  */
115
- deleteIngot(vault: UnsealedVault, ingotId: string): Promise<void>;
183
+ updateUploadConfig(vaultId: string, config: UpdateVaultUploadOptions): Promise<VaultUploadSettings>;
184
+ private toggleUploadChannel;
185
+ private normalizeVaultId;
116
186
  private validateCreateOptions;
117
- private validateUploadOptions;
118
- private validateDownloadUrl;
119
187
  }
120
- export type { CreateVaultOptions, Vault, UnsealedVault, VaultSummary, Ingot, CreatedIngot, UploadIngotOptions, } from './types';
188
+ export type { CreateVaultOptions, Vault, UnsealedVault, VaultSummary, VaultDetail, UpdatedVault, VaultSharingConfig, VaultSharingOptions, AccessLogRetention, VaultUploadSettings, UpdateVaultUploadOptions, } from './types';
121
189
  export type { UploadOptions, UploadAttachOptions, UploadResult, UploadProgress, VaultUploadConfig, UploadBranding, } from './upload';
122
190
  export { VaultUploadModule, UploadApiError } from './upload';
@@ -4,8 +4,6 @@
4
4
  export interface CreateVaultOptions {
5
5
  /** Vault name */
6
6
  name: string;
7
- /** Store VMK server-side (less secure, more convenient) */
8
- hostedVmk?: boolean;
9
7
  }
10
8
  export interface Vault {
11
9
  /** Vault ID */
@@ -16,14 +14,6 @@ export interface Vault {
16
14
  vmk: string;
17
15
  /** Creation timestamp (Unix seconds) */
18
16
  createdAt: number;
19
- /** Whether VMK is hosted server-side */
20
- hostedVmk: boolean;
21
- }
22
- export interface UnsealVaultOptions {
23
- /** Vault ID */
24
- vaultId: string;
25
- /** Vault Master Key */
26
- vmk: string;
27
17
  }
28
18
  export interface UnsealedVault {
29
19
  /** Vault ID */
@@ -48,49 +38,97 @@ export interface VaultSummary {
48
38
  ingotCount: number;
49
39
  /** Total storage used in bytes */
50
40
  storageBytes: number;
51
- /** Whether VMK is hosted server-side */
52
- hostedVmk: boolean;
53
41
  }
54
- export interface Ingot {
55
- /** Ingot ID */
42
+ /** A single vault's detail, as returned by get. */
43
+ export interface VaultDetail {
44
+ /** Vault ID */
56
45
  id: string;
57
- /** Ingot name */
46
+ /** Vault name */
58
47
  name: string;
59
- /** Content type (MIME) */
60
- contentType: string;
61
- /** Size in bytes */
62
- size: number;
48
+ /** Optional description */
49
+ description: string | null;
50
+ /** Sealed/unsealed status */
51
+ status: string;
52
+ /** Number of ingots */
53
+ ingotCount: number;
54
+ /** Total storage used in bytes */
55
+ storageBytes: number;
63
56
  /** Creation timestamp (Unix seconds) */
64
57
  createdAt: number;
58
+ /** Last unseal timestamp (Unix seconds), or null */
59
+ lastUnsealedAt: number | null;
60
+ /** Lifetime unseal count */
61
+ unsealCount: number;
65
62
  }
66
- export interface CreatedIngot {
67
- /** Ingot ID */
63
+ /** The result of renaming a vault. */
64
+ export interface UpdatedVault {
65
+ /** Vault ID */
68
66
  id: string;
69
- /** Ingot name */
67
+ /** Vault name */
70
68
  name: string;
71
- /** Content type (MIME) */
72
- contentType: string;
73
- /** Size in bytes */
74
- size: number;
75
- /** Forge upload session expiry (Unix seconds) */
76
- uploadExpiresAt: number;
77
- }
78
- export interface UploadIngotOptions {
79
- /** File to upload */
80
- file: File | Blob;
81
- /** Optional name (defaults to file name) */
82
- name?: string;
83
- /** Content type (auto-detected if not provided) */
84
- contentType?: string;
85
- /** Progress callback for Forge/TUS upload */
86
- onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
69
+ /** Optional description */
70
+ description: string | null;
71
+ /** Update timestamp (Unix seconds) */
72
+ updatedAt: number;
73
+ }
74
+ /** Vault public-sharing configuration. */
75
+ export interface VaultSharingConfig {
76
+ /** Vault ID */
77
+ vaultId: string;
78
+ /** Whether public sharing is enabled */
79
+ publicSharingEnabled: boolean;
80
+ /** Whether all ingots are public */
81
+ allIngotsPublic: boolean;
82
+ /** Public-session lifetime in seconds, or null */
83
+ sessionLengthSeconds: number | null;
84
+ /** Timestamp sharing was enabled (Unix seconds), or null */
85
+ enabledAt: number | null;
86
+ }
87
+ /** Options for enabling/updating vault sharing. */
88
+ export interface VaultSharingOptions {
89
+ /** Make all ingots public */
90
+ allIngotsPublic?: boolean;
91
+ /** Public-session lifetime in seconds */
92
+ sessionLengthSeconds?: number;
93
+ }
94
+ /** Vault access-log retention configuration. */
95
+ export interface AccessLogRetention {
96
+ /** Vault ID */
97
+ vaultId: string;
98
+ /** Retention window in seconds */
99
+ retentionSeconds: number;
100
+ }
101
+ /** Vault upload-channel configuration. */
102
+ export interface VaultUploadSettings {
103
+ /** Vault ID */
104
+ vaultId: string;
105
+ /** Whether the upload portal is enabled */
106
+ uploadPortalEnabled: boolean;
107
+ /** Timestamp the portal was enabled (Unix seconds), or null */
108
+ uploadPortalEnabledAt: number | null;
109
+ /** Whether the upload widget is enabled */
110
+ uploadWidgetEnabled: boolean;
111
+ /** Timestamp the widget was enabled (Unix seconds), or null */
112
+ uploadWidgetEnabledAt: number | null;
113
+ /** Max upload size in bytes, or null for the account default */
114
+ maxSizeBytes: number | null;
115
+ /** Upload notification email, or null */
116
+ notificationEmail: string | null;
117
+ /** Public portal URL (present when the portal is enabled) */
118
+ portalUrl?: string;
119
+ }
120
+ /** Options for updating vault upload settings. */
121
+ export interface UpdateVaultUploadOptions {
122
+ /** Max upload size in bytes */
123
+ maxSizeBytes?: number;
124
+ /** Upload notification email, or null to clear */
125
+ notificationEmail?: string | null;
87
126
  }
88
127
  export interface CreateVaultResponse {
89
128
  vault_id: string;
90
129
  name: string;
91
130
  vmk: string;
92
131
  created_at: number;
93
- hosted_vmk: boolean;
94
132
  }
95
133
  export interface UnsealVaultResponse {
96
134
  vat: string;
@@ -106,27 +144,53 @@ export interface ListVaultsResponse {
106
144
  created_at: number;
107
145
  ingot_count: number;
108
146
  storage_bytes: number;
109
- hosted_vmk: boolean;
110
147
  }[];
111
148
  }
112
- export interface ListIngotsResponse {
113
- ingots: {
114
- ingot_id: string;
115
- name: string;
116
- content_type: string;
117
- size_bytes: number;
118
- created_at: number;
119
- }[];
149
+ export interface VaultDetailResponse {
150
+ vault_id: string;
151
+ name: string;
152
+ description?: string | null;
153
+ status: string;
154
+ ingot_count?: number;
155
+ storage_bytes?: number;
156
+ created_at: number;
157
+ last_unsealed_at?: number | null;
158
+ unseal_count?: number;
120
159
  }
121
- export interface CreateIngotResponse {
122
- ingot_id: string;
160
+ export interface UpdateVaultResponse {
161
+ vault_id: string;
123
162
  name: string;
124
- content_type: string;
125
- size_bytes: number;
126
- status: 'uploading';
127
- forge_url: string;
128
- expires_at: number;
163
+ description?: string | null;
164
+ updated_at: number;
129
165
  }
130
- export interface DownloadIngotResponse {
131
- download_url: string;
166
+ export interface VaultSharingConfigResponse {
167
+ vault_id: string;
168
+ public_sharing_enabled: boolean;
169
+ all_ingots_public: boolean;
170
+ session_length_seconds: number | null;
171
+ enabled_at: number | null;
172
+ }
173
+ export interface AccessLogRetentionResponse {
174
+ vault_id: string;
175
+ access_log_retention_seconds: number;
176
+ }
177
+ export interface VaultUploadSettingsResponse {
178
+ vault_id: string;
179
+ upload_portal_enabled: boolean;
180
+ upload_portal_enabled_at?: number | null;
181
+ upload_widget_enabled: boolean;
182
+ upload_widget_enabled_at?: number | null;
183
+ max_size_bytes?: number | null;
184
+ notification_email?: string | null;
185
+ portal_url?: string;
186
+ }
187
+ export interface UploadChannelToggleResponse {
188
+ vault_id: string;
189
+ upload_portal_enabled?: boolean;
190
+ upload_portal_enabled_at?: number;
191
+ upload_widget_enabled?: boolean;
192
+ upload_widget_enabled_at?: number;
193
+ enabled_at?: number;
194
+ disabled_at?: number;
195
+ portal_url?: string;
132
196
  }
@@ -37,7 +37,7 @@ export declare class UploadApi extends SparkVaultApi {
37
37
  * Upload a file to Forge over the TUS resumable protocol (v1.0.0).
38
38
  *
39
39
  * The single canonical browser transfer path — the upload widget and the
40
- * authenticated `uploadIngot` flow both go through here (CLAUDE.md: one
40
+ * authenticated `ingots.upload` flow both go through here (CLAUDE.md: one
41
41
  * transfer path). Creates the session, PATCHes chunks sized by the server's
42
42
  * `X-Chunk-Size` (50MB default, which keeps every request under CDN body
43
43
  * caps such as Cloudflare's 100MB), validates every server-reported offset,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparkvault/sdk-js",
3
- "version": "2.2.5",
3
+ "version": "4.1.0",
4
4
  "description": "SparkVault JavaScript SDK - Identity Verification and Encrypted Vaults",
5
5
  "type": "module",
6
6
  "main": "dist/sparkvault.cjs.js",
File without changes
File without changes