@sparkvault/sdk 1.1.5 → 1.8.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/README.md +8 -8
- package/dist/auto-init.d.ts +11 -30
- package/dist/config.d.ts +3 -0
- package/dist/identity/api.d.ts +12 -8
- package/dist/identity/handlers/passkey-handler.d.ts +25 -8
- package/dist/identity/handlers/sparklink-handler.d.ts +4 -2
- package/dist/identity/index.d.ts +50 -32
- package/dist/identity/renderer.d.ts +8 -0
- package/dist/identity/state.d.ts +4 -1
- package/dist/identity/types.d.ts +54 -17
- package/dist/identity/views/icons.d.ts +1 -5
- package/dist/identity/views/passkey-prompt.d.ts +2 -0
- package/dist/identity/views/totp-verify.d.ts +1 -1
- package/dist/index.d.ts +283 -248
- package/dist/sparkvault.cjs.js +3435 -1074
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +3435 -1074
- package/dist/sparkvault.esm.js.map +1 -1
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/dist/utils/base64url.d.ts +1 -9
- package/dist/vaults/index.d.ts +27 -1
- package/dist/vaults/upload/api.d.ts +35 -0
- package/dist/vaults/upload/container.d.ts +57 -0
- package/dist/vaults/upload/index.d.ts +79 -0
- package/dist/vaults/upload/inline-container.d.ts +75 -0
- package/dist/vaults/upload/modal.d.ts +79 -0
- package/dist/vaults/upload/renderer.d.ts +55 -0
- package/dist/vaults/upload/styles.d.ts +20 -0
- package/dist/vaults/upload/types.d.ts +183 -0
- package/package.json +6 -7
- package/dist/rng/index.d.ts +0 -54
- package/dist/rng/types.d.ts +0 -26
- package/dist/sparks/index.d.ts +0 -37
- package/dist/sparks/types.d.ts +0 -56
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ interface SparkVaultConfig {
|
|
|
13
13
|
* Set to false to defer config loading until verify() is called.
|
|
14
14
|
*/
|
|
15
15
|
preloadConfig?: boolean;
|
|
16
|
+
/** Enable backdrop blur on dialogs (default: true) */
|
|
17
|
+
backdropBlur?: boolean;
|
|
16
18
|
}
|
|
17
19
|
interface ResolvedConfig {
|
|
18
20
|
accountId: string;
|
|
@@ -20,36 +22,65 @@ interface ResolvedConfig {
|
|
|
20
22
|
apiBaseUrl: string;
|
|
21
23
|
identityBaseUrl: string;
|
|
22
24
|
preloadConfig: boolean;
|
|
25
|
+
backdropBlur: boolean;
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
/**
|
|
26
29
|
* Identity Module Types
|
|
27
30
|
*/
|
|
28
|
-
type AuthMethod = 'passkey' | 'totp_email' | 'totp_sms' | 'totp_voice' | '
|
|
31
|
+
type AuthMethod = 'passkey' | 'totp_email' | 'totp_sms' | 'totp_voice' | 'sparklink' | 'social_google' | 'social_apple' | 'social_microsoft' | 'social_github' | 'social_facebook' | 'social_linkedin';
|
|
29
32
|
type Theme = 'light' | 'dark';
|
|
33
|
+
/**
|
|
34
|
+
* Auth context for OIDC or simple redirect flows.
|
|
35
|
+
* Used by hosted login pages to complete authorization flows.
|
|
36
|
+
*/
|
|
37
|
+
interface AuthContext {
|
|
38
|
+
/** OIDC auth request ID for authorization code flow */
|
|
39
|
+
authRequestId?: string;
|
|
40
|
+
/** Simple redirect mode configuration */
|
|
41
|
+
simpleMode?: {
|
|
42
|
+
successUrl: string;
|
|
43
|
+
failureUrl: string;
|
|
44
|
+
state?: string;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
30
47
|
interface VerifyOptions {
|
|
31
48
|
/** Pre-fill email address (mutually exclusive with phone) */
|
|
32
49
|
email?: string;
|
|
33
50
|
/** Pre-fill phone number in E.164 format, e.g. "+14155551234" (mutually exclusive with email) */
|
|
34
51
|
phone?: string;
|
|
35
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* Target element for inline rendering. Can be:
|
|
54
|
+
* - A CSS selector string (e.g., "#auth-container")
|
|
55
|
+
* - An HTMLElement reference
|
|
56
|
+
* - Omitted for dialog mode (default)
|
|
57
|
+
*/
|
|
58
|
+
target?: string | HTMLElement;
|
|
59
|
+
/** Override backdrop blur for this dialog (uses global config if omitted) */
|
|
36
60
|
backdropBlur?: boolean;
|
|
37
|
-
/**
|
|
61
|
+
/** Auth context for OIDC/simple mode flows (used by hosted login) */
|
|
62
|
+
authContext?: AuthContext;
|
|
63
|
+
/** Called when user cancels (if omitted, uses server-configured redirect) */
|
|
38
64
|
onCancel?: () => void;
|
|
39
|
-
/** Called when verification completes (
|
|
65
|
+
/** Called when verification completes (if omitted, uses server-configured redirect) */
|
|
40
66
|
onSuccess?: (result: VerifyResult) => void;
|
|
41
|
-
/** Called on error (
|
|
67
|
+
/** Called on error (if omitted, uses server-configured redirect) */
|
|
42
68
|
onError?: (error: Error) => void;
|
|
43
69
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
70
|
+
/** Options for attach() - binds verification to element clicks */
|
|
71
|
+
interface AttachOptions {
|
|
72
|
+
/** Pre-fill email address */
|
|
73
|
+
email?: string;
|
|
74
|
+
/** Pre-fill phone number in E.164 format */
|
|
75
|
+
phone?: string;
|
|
76
|
+
/** Auth context for OIDC/simple mode flows */
|
|
77
|
+
authContext?: AuthContext;
|
|
78
|
+
/** Called when user cancels */
|
|
79
|
+
onCancel?: () => void;
|
|
80
|
+
/** Called when verification completes */
|
|
81
|
+
onSuccess?: (result: VerifyResult) => void;
|
|
82
|
+
/** Called on error */
|
|
83
|
+
onError?: (error: Error) => void;
|
|
53
84
|
}
|
|
54
85
|
interface VerifyResult {
|
|
55
86
|
/** Signed JWT token */
|
|
@@ -58,6 +89,8 @@ interface VerifyResult {
|
|
|
58
89
|
identity: string;
|
|
59
90
|
/** Type of identity verified */
|
|
60
91
|
identityType: 'email' | 'phone';
|
|
92
|
+
/** Redirect URL (only present for OIDC/simple mode flows) */
|
|
93
|
+
redirect?: string;
|
|
61
94
|
}
|
|
62
95
|
interface TokenClaims {
|
|
63
96
|
/** Issuer */
|
|
@@ -85,67 +118,85 @@ interface TokenClaims {
|
|
|
85
118
|
/**
|
|
86
119
|
* Identity Module
|
|
87
120
|
*
|
|
88
|
-
* Provides identity verification through
|
|
89
|
-
* Supports passkey, TOTP,
|
|
121
|
+
* Provides identity verification through dialog or inline UI.
|
|
122
|
+
* Supports passkey, TOTP, SparkLink, and social authentication.
|
|
123
|
+
*
|
|
124
|
+
* @example Dialog mode (immediate)
|
|
125
|
+
* const result = await sv.identity.verify();
|
|
126
|
+
*
|
|
127
|
+
* @example Dialog mode (attached to clicks)
|
|
128
|
+
* sv.identity.attach('.login-btn');
|
|
129
|
+
*
|
|
130
|
+
* @example Inline mode
|
|
131
|
+
* const result = await sv.identity.verify({ target: '#auth-container' });
|
|
90
132
|
*/
|
|
91
133
|
|
|
92
134
|
declare class IdentityModule {
|
|
93
135
|
private readonly config;
|
|
94
136
|
private readonly api;
|
|
95
137
|
private renderer;
|
|
138
|
+
private attachedElements;
|
|
96
139
|
constructor(config: ResolvedConfig);
|
|
97
140
|
/**
|
|
98
|
-
*
|
|
99
|
-
* Returns when user successfully verifies their identity.
|
|
141
|
+
* Verify user identity.
|
|
100
142
|
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
143
|
+
* - Without `target`: Opens a dialog (modal)
|
|
144
|
+
* - With `target`: Renders inline into the specified element
|
|
145
|
+
*
|
|
146
|
+
* @example Dialog mode
|
|
147
|
+
* const result = await sv.identity.verify();
|
|
148
|
+
* console.log(result.token, result.identity);
|
|
149
|
+
*
|
|
150
|
+
* @example Inline mode
|
|
151
|
+
* const result = await sv.identity.verify({
|
|
152
|
+
* target: '#auth-container',
|
|
103
153
|
* email: 'user@example.com'
|
|
104
154
|
* });
|
|
105
|
-
* console.log(result.token, result.identity, result.identityType);
|
|
106
155
|
*/
|
|
107
|
-
|
|
156
|
+
verify(options?: VerifyOptions): Promise<VerifyResult>;
|
|
108
157
|
/**
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* directly into the specified element.
|
|
158
|
+
* Attach identity verification to element clicks.
|
|
159
|
+
* When any matching element is clicked, opens the verification dialog.
|
|
112
160
|
*
|
|
113
|
-
* @
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* target: document.getElementById('auth-container'),
|
|
117
|
-
* email: 'user@example.com'
|
|
118
|
-
* });
|
|
161
|
+
* @param selector - CSS selector for elements to attach to
|
|
162
|
+
* @param options - Verification options and callbacks
|
|
163
|
+
* @returns Cleanup function to remove event listeners
|
|
119
164
|
*
|
|
120
165
|
* @example
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* target: dialogContentElement,
|
|
124
|
-
* showHeader: false,
|
|
125
|
-
* showFooter: false
|
|
166
|
+
* const cleanup = sv.identity.attach('.login-btn', {
|
|
167
|
+
* onSuccess: (result) => console.log('Verified:', result.identity)
|
|
126
168
|
* });
|
|
169
|
+
*
|
|
170
|
+
* // Later, remove listeners
|
|
171
|
+
* cleanup();
|
|
127
172
|
*/
|
|
128
|
-
|
|
173
|
+
attach(selector: string, options?: AttachOptions): () => void;
|
|
129
174
|
/**
|
|
130
175
|
* Verify and decode an identity token.
|
|
131
176
|
* Validates the token structure, expiry, and issuer.
|
|
132
177
|
*
|
|
133
178
|
* Note: For production use, verify the Ed25519 signature server-side
|
|
134
179
|
* using the JWKS endpoint.
|
|
135
|
-
*
|
|
136
|
-
* @example
|
|
137
|
-
* const claims = await sv.identity.verifyToken(token);
|
|
138
|
-
* console.log(claims.identity, claims.identity_type, claims.method);
|
|
139
180
|
*/
|
|
140
181
|
verifyToken(token: string): Promise<TokenClaims>;
|
|
141
182
|
/**
|
|
142
|
-
* Close the identity
|
|
183
|
+
* Close the identity dialog/inline UI if open.
|
|
143
184
|
*/
|
|
144
185
|
close(): void;
|
|
145
186
|
/**
|
|
146
|
-
*
|
|
187
|
+
* Resolve target to an HTMLElement.
|
|
147
188
|
*/
|
|
148
|
-
|
|
189
|
+
private createInlineContainer;
|
|
190
|
+
/**
|
|
191
|
+
* @deprecated Use `verify()` instead. Will be removed in v2.0.
|
|
192
|
+
*/
|
|
193
|
+
pop(options?: VerifyOptions): Promise<VerifyResult>;
|
|
194
|
+
/**
|
|
195
|
+
* @deprecated Use `verify({ target })` instead. Will be removed in v2.0.
|
|
196
|
+
*/
|
|
197
|
+
render(options: VerifyOptions & {
|
|
198
|
+
target: HTMLElement;
|
|
199
|
+
}): Promise<VerifyResult>;
|
|
149
200
|
}
|
|
150
201
|
|
|
151
202
|
/**
|
|
@@ -214,80 +265,6 @@ declare class HttpClient {
|
|
|
214
265
|
private executeRequestRaw;
|
|
215
266
|
}
|
|
216
267
|
|
|
217
|
-
/**
|
|
218
|
-
* Sparks Module Types
|
|
219
|
-
*/
|
|
220
|
-
interface CreateSparkOptions {
|
|
221
|
-
/** Secret payload to encrypt */
|
|
222
|
-
payload: string | Uint8Array;
|
|
223
|
-
/** Time-to-live in seconds (default: 3600) */
|
|
224
|
-
ttl?: number;
|
|
225
|
-
/** Maximum number of reads before destruction (default: 1) */
|
|
226
|
-
maxReads?: number;
|
|
227
|
-
/** Optional password protection */
|
|
228
|
-
password?: string;
|
|
229
|
-
/** Optional name/label for the spark */
|
|
230
|
-
name?: string;
|
|
231
|
-
}
|
|
232
|
-
interface Spark {
|
|
233
|
-
/** Spark ID */
|
|
234
|
-
id: string;
|
|
235
|
-
/** Direct URL to read the spark */
|
|
236
|
-
url: string;
|
|
237
|
-
/** Expiry timestamp (Unix seconds) */
|
|
238
|
-
expiresAt: number;
|
|
239
|
-
/** Maximum reads remaining */
|
|
240
|
-
maxReads: number;
|
|
241
|
-
/** Name/label if provided */
|
|
242
|
-
name?: string;
|
|
243
|
-
}
|
|
244
|
-
interface SparkPayload {
|
|
245
|
-
/** Decrypted data */
|
|
246
|
-
data: string | Uint8Array;
|
|
247
|
-
/** When the spark was read (Unix seconds) */
|
|
248
|
-
readAt: number;
|
|
249
|
-
/** Whether the spark was destroyed after reading */
|
|
250
|
-
burned: boolean;
|
|
251
|
-
/** Reads remaining (0 if burned) */
|
|
252
|
-
readsRemaining: number;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Sparks Module
|
|
257
|
-
*
|
|
258
|
-
* Create and read ephemeral encrypted secrets.
|
|
259
|
-
* Sparks are destroyed after being read (burn-on-read).
|
|
260
|
-
*/
|
|
261
|
-
|
|
262
|
-
declare class SparksModule {
|
|
263
|
-
private readonly http;
|
|
264
|
-
constructor(http: HttpClient);
|
|
265
|
-
/**
|
|
266
|
-
* Create an ephemeral encrypted secret.
|
|
267
|
-
*
|
|
268
|
-
* @example
|
|
269
|
-
* const spark = await sv.sparks.create({
|
|
270
|
-
* payload: 'my secret data',
|
|
271
|
-
* ttl: 3600,
|
|
272
|
-
* maxReads: 1
|
|
273
|
-
* });
|
|
274
|
-
* console.log(spark.url);
|
|
275
|
-
*/
|
|
276
|
-
create(options: CreateSparkOptions): Promise<Spark>;
|
|
277
|
-
/**
|
|
278
|
-
* Read and burn a spark.
|
|
279
|
-
* The spark is destroyed after the configured number of reads.
|
|
280
|
-
*
|
|
281
|
-
* @example
|
|
282
|
-
* const payload = await sv.sparks.read('spk_abc123');
|
|
283
|
-
* console.log(payload.data);
|
|
284
|
-
*/
|
|
285
|
-
read(id: string, password?: string): Promise<SparkPayload>;
|
|
286
|
-
private validateCreateOptions;
|
|
287
|
-
private encodePayload;
|
|
288
|
-
private decodePayload;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
268
|
/**
|
|
292
269
|
* Vaults Module Types
|
|
293
270
|
*/
|
|
@@ -360,6 +337,153 @@ interface UploadIngotOptions {
|
|
|
360
337
|
contentType?: string;
|
|
361
338
|
}
|
|
362
339
|
|
|
340
|
+
/**
|
|
341
|
+
* Vault Upload Module Types
|
|
342
|
+
*
|
|
343
|
+
* Types for the embedded vault upload widget.
|
|
344
|
+
*/
|
|
345
|
+
/**
|
|
346
|
+
* Branding configuration from vault upload info.
|
|
347
|
+
*/
|
|
348
|
+
interface UploadBranding {
|
|
349
|
+
/** Organization name */
|
|
350
|
+
organizationName: string;
|
|
351
|
+
/** Light theme logo URL */
|
|
352
|
+
logoLightUrl: string | null;
|
|
353
|
+
/** Dark theme logo URL */
|
|
354
|
+
logoDarkUrl: string | null;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Encryption information for the vault.
|
|
358
|
+
*/
|
|
359
|
+
interface EncryptionInfo {
|
|
360
|
+
/** Encryption algorithm (e.g., 'AES-256-GCM') */
|
|
361
|
+
algorithm: string;
|
|
362
|
+
/** Key derivation method (e.g., 'Triple Zero-Trust') */
|
|
363
|
+
keyDerivation: string;
|
|
364
|
+
/** Post-quantum protection status */
|
|
365
|
+
postQuantum: string;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Vault upload configuration from API.
|
|
369
|
+
*/
|
|
370
|
+
interface VaultUploadConfig {
|
|
371
|
+
/** Vault ID */
|
|
372
|
+
vaultId: string;
|
|
373
|
+
/** Vault name */
|
|
374
|
+
vaultName: string;
|
|
375
|
+
/** Maximum upload size in bytes */
|
|
376
|
+
maxSizeBytes: number;
|
|
377
|
+
/** Branding information */
|
|
378
|
+
branding: UploadBranding;
|
|
379
|
+
/** Encryption details */
|
|
380
|
+
encryption: EncryptionInfo;
|
|
381
|
+
/** Forge status */
|
|
382
|
+
forgeStatus: 'active' | 'inactive';
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Options for upload().
|
|
386
|
+
* - Without `target`: Opens a dialog (modal)
|
|
387
|
+
* - With `target`: Renders inline into the specified element
|
|
388
|
+
*/
|
|
389
|
+
interface UploadOptions {
|
|
390
|
+
/** Vault ID to upload to */
|
|
391
|
+
vaultId: string;
|
|
392
|
+
/**
|
|
393
|
+
* Target element for inline rendering. Can be:
|
|
394
|
+
* - A CSS selector string (e.g., "#upload-container")
|
|
395
|
+
* - An HTMLElement reference
|
|
396
|
+
* - Omitted for dialog mode (default)
|
|
397
|
+
*/
|
|
398
|
+
target?: string | HTMLElement;
|
|
399
|
+
/** Override backdrop blur for this dialog (uses global config if omitted) */
|
|
400
|
+
backdropBlur?: boolean;
|
|
401
|
+
/** Callback when upload completes successfully (if omitted, uses server-configured redirect) */
|
|
402
|
+
onSuccess?: (result: UploadResult) => void;
|
|
403
|
+
/** Callback when an error occurs (if omitted, uses server-configured redirect) */
|
|
404
|
+
onError?: (error: Error) => void;
|
|
405
|
+
/** Callback when user cancels (if omitted, uses server-configured redirect) */
|
|
406
|
+
onCancel?: () => void;
|
|
407
|
+
/** Callback for upload progress */
|
|
408
|
+
onProgress?: (progress: UploadProgress) => void;
|
|
409
|
+
}
|
|
410
|
+
/** Options for attach() - binds upload to element clicks */
|
|
411
|
+
interface UploadAttachOptions {
|
|
412
|
+
/** Vault ID to upload to */
|
|
413
|
+
vaultId: string;
|
|
414
|
+
/** Callback when upload completes successfully */
|
|
415
|
+
onSuccess?: (result: UploadResult) => void;
|
|
416
|
+
/** Callback when an error occurs */
|
|
417
|
+
onError?: (error: Error) => void;
|
|
418
|
+
/** Callback when user cancels */
|
|
419
|
+
onCancel?: () => void;
|
|
420
|
+
/** Callback for upload progress */
|
|
421
|
+
onProgress?: (progress: UploadProgress) => void;
|
|
422
|
+
}
|
|
423
|
+
/** @deprecated Use UploadOptions instead */
|
|
424
|
+
type UploadPopOptions = UploadOptions;
|
|
425
|
+
/** @deprecated Use UploadOptions instead */
|
|
426
|
+
type UploadRenderOptions = UploadOptions;
|
|
427
|
+
/**
|
|
428
|
+
* Upload progress information.
|
|
429
|
+
*/
|
|
430
|
+
interface UploadProgress {
|
|
431
|
+
/** Bytes uploaded */
|
|
432
|
+
bytesUploaded: number;
|
|
433
|
+
/** Total bytes */
|
|
434
|
+
bytesTotal: number;
|
|
435
|
+
/** Percentage (0-100) */
|
|
436
|
+
percentage: number;
|
|
437
|
+
/** Current phase */
|
|
438
|
+
phase: 'uploading' | 'ceremony' | 'complete';
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Successful upload result.
|
|
442
|
+
*/
|
|
443
|
+
interface UploadResult {
|
|
444
|
+
/** Ingot ID */
|
|
445
|
+
ingotId: string;
|
|
446
|
+
/** Vault ID */
|
|
447
|
+
vaultId: string;
|
|
448
|
+
/** Original filename */
|
|
449
|
+
filename: string;
|
|
450
|
+
/** File size in bytes */
|
|
451
|
+
sizeBytes: number;
|
|
452
|
+
/** Upload timestamp (ISO 8601) */
|
|
453
|
+
uploadTime: string;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* SparkVault SDK Error Types
|
|
458
|
+
*/
|
|
459
|
+
declare class SparkVaultError extends Error {
|
|
460
|
+
readonly code: string;
|
|
461
|
+
readonly statusCode?: number;
|
|
462
|
+
readonly details?: Record<string, unknown>;
|
|
463
|
+
constructor(message: string, code: string, statusCode?: number, details?: Record<string, unknown>);
|
|
464
|
+
}
|
|
465
|
+
declare class AuthenticationError extends SparkVaultError {
|
|
466
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
467
|
+
}
|
|
468
|
+
declare class AuthorizationError extends SparkVaultError {
|
|
469
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
470
|
+
}
|
|
471
|
+
declare class ValidationError extends SparkVaultError {
|
|
472
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
473
|
+
}
|
|
474
|
+
declare class NetworkError extends SparkVaultError {
|
|
475
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
476
|
+
}
|
|
477
|
+
declare class TimeoutError extends SparkVaultError {
|
|
478
|
+
constructor(message?: string);
|
|
479
|
+
}
|
|
480
|
+
declare class UserCancelledError extends SparkVaultError {
|
|
481
|
+
constructor(message?: string);
|
|
482
|
+
}
|
|
483
|
+
declare class PopupBlockedError extends SparkVaultError {
|
|
484
|
+
constructor();
|
|
485
|
+
}
|
|
486
|
+
|
|
363
487
|
/**
|
|
364
488
|
* Vaults Module
|
|
365
489
|
*
|
|
@@ -367,9 +491,32 @@ interface UploadIngotOptions {
|
|
|
367
491
|
* Uses Triple Zero-Trust encryption (SVMK + AMK + VMK).
|
|
368
492
|
*/
|
|
369
493
|
|
|
494
|
+
/**
|
|
495
|
+
* Callable upload interface with methods.
|
|
496
|
+
* Allows both `sv.vaults.upload(options)` and `sv.vaults.upload.attach(selector, options)`.
|
|
497
|
+
*/
|
|
498
|
+
interface UploadCallable {
|
|
499
|
+
(options: UploadOptions): Promise<UploadResult>;
|
|
500
|
+
attach(selector: string, options: UploadAttachOptions): () => void;
|
|
501
|
+
close(): void;
|
|
502
|
+
}
|
|
370
503
|
declare class VaultsModule {
|
|
371
504
|
private readonly http;
|
|
372
|
-
|
|
505
|
+
private readonly uploadModule;
|
|
506
|
+
/**
|
|
507
|
+
* Upload to a vault with public upload enabled.
|
|
508
|
+
*
|
|
509
|
+
* @example Dialog mode
|
|
510
|
+
* const result = await sv.vaults.upload({ vaultId: 'vlt_abc123' });
|
|
511
|
+
*
|
|
512
|
+
* @example Attach to clicks
|
|
513
|
+
* sv.vaults.upload.attach('.upload-btn', { vaultId: 'vlt_abc123' });
|
|
514
|
+
*
|
|
515
|
+
* @example Inline mode
|
|
516
|
+
* sv.vaults.upload({ vaultId: 'vlt_abc123', target: '#upload-area' });
|
|
517
|
+
*/
|
|
518
|
+
readonly upload: UploadCallable;
|
|
519
|
+
constructor(config: ResolvedConfig, http: HttpClient);
|
|
373
520
|
/**
|
|
374
521
|
* Create a new encrypted vault.
|
|
375
522
|
* IMPORTANT: Store the VMK securely - it cannot be recovered!
|
|
@@ -441,80 +588,6 @@ declare class VaultsModule {
|
|
|
441
588
|
private validateUploadOptions;
|
|
442
589
|
}
|
|
443
590
|
|
|
444
|
-
/**
|
|
445
|
-
* RNG Module Types
|
|
446
|
-
*/
|
|
447
|
-
type RNGFormat = 'hex' | 'base64' | 'base64url' | 'alphanumeric' | 'alphanumeric-mixed' | 'password' | 'numeric' | 'uuid' | 'bytes';
|
|
448
|
-
interface GenerateOptions {
|
|
449
|
-
/** Number of bytes to generate (1-1024) */
|
|
450
|
-
bytes: number;
|
|
451
|
-
/** Output format (default: 'base64url') */
|
|
452
|
-
format?: RNGFormat;
|
|
453
|
-
}
|
|
454
|
-
interface RandomResult {
|
|
455
|
-
/** Generated random value */
|
|
456
|
-
value: string | number[];
|
|
457
|
-
/** Number of bytes generated */
|
|
458
|
-
bytes: number;
|
|
459
|
-
/** Format used */
|
|
460
|
-
format: RNGFormat;
|
|
461
|
-
/** Reference ID for billing/audit */
|
|
462
|
-
referenceId: string;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
/**
|
|
466
|
-
* RNG Module
|
|
467
|
-
*
|
|
468
|
-
* Generate cryptographically secure random numbers.
|
|
469
|
-
* Uses hybrid entropy from AWS KMS HSM + local CSPRNG.
|
|
470
|
-
*/
|
|
471
|
-
|
|
472
|
-
declare class RNGModule {
|
|
473
|
-
private readonly http;
|
|
474
|
-
constructor(http: HttpClient);
|
|
475
|
-
/**
|
|
476
|
-
* Generate cryptographically secure random bytes.
|
|
477
|
-
*
|
|
478
|
-
* @example
|
|
479
|
-
* const result = await sv.rng.generate({ bytes: 32, format: 'hex' });
|
|
480
|
-
* console.log(result.value);
|
|
481
|
-
*/
|
|
482
|
-
generate(options: GenerateOptions): Promise<RandomResult>;
|
|
483
|
-
/**
|
|
484
|
-
* Generate a random UUID v4.
|
|
485
|
-
*
|
|
486
|
-
* @example
|
|
487
|
-
* const uuid = await sv.rng.uuid();
|
|
488
|
-
* console.log(uuid); // 'f47ac10b-58cc-4372-a567-0e02b2c3d479'
|
|
489
|
-
*/
|
|
490
|
-
uuid(): Promise<string>;
|
|
491
|
-
/**
|
|
492
|
-
* Generate a random hex string.
|
|
493
|
-
*
|
|
494
|
-
* @example
|
|
495
|
-
* const hex = await sv.rng.hex(16);
|
|
496
|
-
* console.log(hex); // '1a2b3c4d5e6f7890...'
|
|
497
|
-
*/
|
|
498
|
-
hex(bytes: number): Promise<string>;
|
|
499
|
-
/**
|
|
500
|
-
* Generate a random alphanumeric string.
|
|
501
|
-
*
|
|
502
|
-
* @example
|
|
503
|
-
* const code = await sv.rng.alphanumeric(8);
|
|
504
|
-
* console.log(code); // 'A1B2C3D4'
|
|
505
|
-
*/
|
|
506
|
-
alphanumeric(bytes: number): Promise<string>;
|
|
507
|
-
/**
|
|
508
|
-
* Generate a random password with special characters.
|
|
509
|
-
*
|
|
510
|
-
* @example
|
|
511
|
-
* const password = await sv.rng.password(16);
|
|
512
|
-
* console.log(password); // 'aB3$xY7!mN9@pQ2#'
|
|
513
|
-
*/
|
|
514
|
-
password(bytes: number): Promise<string>;
|
|
515
|
-
private validateOptions;
|
|
516
|
-
}
|
|
517
|
-
|
|
518
591
|
/**
|
|
519
592
|
* SparkVault Debug Logger
|
|
520
593
|
*
|
|
@@ -556,80 +629,42 @@ declare const logger: {
|
|
|
556
629
|
groupEnd: () => void;
|
|
557
630
|
};
|
|
558
631
|
|
|
559
|
-
/**
|
|
560
|
-
* SparkVault SDK Error Types
|
|
561
|
-
*/
|
|
562
|
-
declare class SparkVaultError extends Error {
|
|
563
|
-
readonly code: string;
|
|
564
|
-
readonly statusCode?: number;
|
|
565
|
-
readonly details?: Record<string, unknown>;
|
|
566
|
-
constructor(message: string, code: string, statusCode?: number, details?: Record<string, unknown>);
|
|
567
|
-
}
|
|
568
|
-
declare class AuthenticationError extends SparkVaultError {
|
|
569
|
-
constructor(message: string, details?: Record<string, unknown>);
|
|
570
|
-
}
|
|
571
|
-
declare class AuthorizationError extends SparkVaultError {
|
|
572
|
-
constructor(message: string, details?: Record<string, unknown>);
|
|
573
|
-
}
|
|
574
|
-
declare class ValidationError extends SparkVaultError {
|
|
575
|
-
constructor(message: string, details?: Record<string, unknown>);
|
|
576
|
-
}
|
|
577
|
-
declare class NetworkError extends SparkVaultError {
|
|
578
|
-
constructor(message: string, details?: Record<string, unknown>);
|
|
579
|
-
}
|
|
580
|
-
declare class TimeoutError extends SparkVaultError {
|
|
581
|
-
constructor(message?: string);
|
|
582
|
-
}
|
|
583
|
-
declare class UserCancelledError extends SparkVaultError {
|
|
584
|
-
constructor(message?: string);
|
|
585
|
-
}
|
|
586
|
-
declare class PopupBlockedError extends SparkVaultError {
|
|
587
|
-
constructor();
|
|
588
|
-
}
|
|
589
|
-
|
|
590
632
|
/**
|
|
591
633
|
* SparkVault JavaScript SDK
|
|
592
634
|
*
|
|
593
|
-
* A unified SDK for Identity
|
|
635
|
+
* A unified SDK for Identity and Vaults.
|
|
594
636
|
*
|
|
595
|
-
* @example
|
|
637
|
+
* @example CDN Usage (Recommended)
|
|
596
638
|
* ```html
|
|
597
639
|
* <script
|
|
598
|
-
* async
|
|
599
640
|
* src="https://cdn.sparkvault.com/sdk/v1/sparkvault.js"
|
|
600
641
|
* data-account-id="acc_your_account"
|
|
601
|
-
* data-attach-selector=".js-sparkvault-auth"
|
|
602
|
-
* data-success-url="https://example.com/auth/verify-token"
|
|
603
|
-
* data-debug="true"
|
|
604
642
|
* ></script>
|
|
605
643
|
*
|
|
606
|
-
* <button class="js-sparkvault-auth">Login with SparkVault</button>
|
|
607
|
-
* ```
|
|
608
|
-
*
|
|
609
|
-
* @example Manual Init
|
|
610
|
-
* ```html
|
|
611
|
-
* <script src="https://cdn.sparkvault.com/sdk/v1/sparkvault.js"></script>
|
|
612
644
|
* <script>
|
|
613
|
-
*
|
|
614
|
-
*
|
|
645
|
+
* // SDK auto-initializes. Use JavaScript API:
|
|
646
|
+
* SparkVault.identity.attach('.login-btn', {
|
|
647
|
+
* onSuccess: (result) => console.log('Verified:', result.identity)
|
|
615
648
|
* });
|
|
616
|
-
*
|
|
617
|
-
* // Open identity verification modal
|
|
618
|
-
* const result = await sv.identity.pop();
|
|
619
|
-
* console.log(result.identity, result.identityType);
|
|
620
649
|
* </script>
|
|
621
650
|
* ```
|
|
651
|
+
*
|
|
652
|
+
* @example npm/Bundler Usage
|
|
653
|
+
* ```typescript
|
|
654
|
+
* import SparkVault from '@sparkvault/sdk';
|
|
655
|
+
*
|
|
656
|
+
* const sv = SparkVault.init({ accountId: 'acc_your_account' });
|
|
657
|
+
*
|
|
658
|
+
* const result = await sv.identity.verify();
|
|
659
|
+
* console.log(result.identity, result.identityType);
|
|
660
|
+
* ```
|
|
622
661
|
*/
|
|
623
662
|
|
|
624
663
|
declare class SparkVault {
|
|
625
664
|
/** Identity verification module */
|
|
626
665
|
readonly identity: IdentityModule;
|
|
627
|
-
/** Ephemeral encrypted secrets module */
|
|
628
|
-
readonly sparks: SparksModule;
|
|
629
666
|
/** Persistent encrypted storage module */
|
|
630
667
|
readonly vaults: VaultsModule;
|
|
631
|
-
/** Cryptographic random number generation module */
|
|
632
|
-
readonly rng: RNGModule;
|
|
633
668
|
private readonly config;
|
|
634
669
|
private constructor();
|
|
635
670
|
/**
|
|
@@ -650,9 +685,9 @@ declare class SparkVault {
|
|
|
650
685
|
|
|
651
686
|
declare global {
|
|
652
687
|
interface Window {
|
|
653
|
-
SparkVault: typeof SparkVault;
|
|
688
|
+
SparkVault: typeof SparkVault | SparkVault;
|
|
654
689
|
}
|
|
655
690
|
}
|
|
656
691
|
|
|
657
692
|
export { AuthenticationError, AuthorizationError, NetworkError, PopupBlockedError, SparkVault, SparkVaultError, TimeoutError, UserCancelledError, ValidationError, SparkVault as default, logger, setDebugMode };
|
|
658
|
-
export type { AuthMethod,
|
|
693
|
+
export type { AuthMethod, CreateVaultOptions, AttachOptions as IdentityAttachOptions, Ingot, SparkVaultConfig, Theme, TokenClaims, UnsealedVault, UploadAttachOptions, UploadBranding, UploadIngotOptions, UploadOptions, UploadPopOptions, UploadProgress, UploadRenderOptions, UploadResult, Vault, VaultSummary, VaultUploadConfig, VerifyOptions, VerifyResult };
|