@sparkvault/sdk-js 12.0.2 → 12.0.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.
- package/dist/errors.d.ts +10 -0
- package/dist/index.cjs +365 -87
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +198 -81
- package/dist/index.mjs +364 -88
- package/dist/index.mjs.map +1 -1
- package/dist/ingots/index.d.ts +54 -7
- package/dist/ingots/types.d.ts +55 -2
- package/dist/products/identity/index.d.ts +6 -2
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/dist/vaults/upload/api.d.ts +9 -0
- package/dist/vaults/upload/renderer.d.ts +5 -0
- package/dist/vaults/upload/types.d.ts +16 -0
- package/package.json +1 -1
package/dist/ingots/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { type ResolvedConfig } from '../config';
|
|
13
13
|
import { HttpClient } from '../http';
|
|
14
|
-
import type { UnsealedVault, Ingot, IngotUpload, CreatedIngot, IngotDownloadLink, CreateUploadOptions, UploadIngotOptions, SendUploadOptions, ResumeUploadOptions, UploadSession, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, FolderContents, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions,
|
|
14
|
+
import type { UnsealedVault, Ingot, IngotUpload, UploadEnd, CreatedIngot, IngotDownloadLink, CreateUploadOptions, UploadIngotOptions, SendUploadOptions, ResumeUploadOptions, UploadSession, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, FolderContents, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvitation, IngotAccessLogPage, AccessLogsOptions, HashCheckResponse } from './types';
|
|
15
15
|
export declare class IngotsModule {
|
|
16
16
|
private readonly config;
|
|
17
17
|
private readonly http;
|
|
@@ -24,7 +24,9 @@ export declare class IngotsModule {
|
|
|
24
24
|
* transfer yourself; otherwise prefer {@link upload}. A create another
|
|
25
25
|
* upload of the same file superseded before its token was issued rejects
|
|
26
26
|
* with code `upload_refused` (`details.coreCode` UPLOAD_SUPERSEDED): the
|
|
27
|
-
* later upload is the one kept, so a new upload is no remedy.
|
|
27
|
+
* later upload is the one kept, so a new upload is no remedy. An upload
|
|
28
|
+
* you give up (you cancel its transfer, or it fails for good) ends with the
|
|
29
|
+
* file its create made through {@link endUpload}, given this result.
|
|
28
30
|
*
|
|
29
31
|
* @example
|
|
30
32
|
* const session = await sv.ingots.createUpload({
|
|
@@ -34,6 +36,37 @@ export declare class IngotsModule {
|
|
|
34
36
|
* console.log(session.uploadUrl);
|
|
35
37
|
*/
|
|
36
38
|
createUpload(options: CreateUploadOptions): Promise<IngotUpload>;
|
|
39
|
+
/**
|
|
40
|
+
* End an upload you give up (you cancelled its transfer, or it failed for
|
|
41
|
+
* good) with the file its create made ({@link createUpload}'s result): the
|
|
42
|
+
* server deletes the ingot only while it is still that upload's unfinished
|
|
43
|
+
* file, ending the upload first, so a publication racing the end is decided
|
|
44
|
+
* before anything goes. Never give up one the server received whole
|
|
45
|
+
* ({@link isReceivedUploadFailure}): the server publishes or ends it on its
|
|
46
|
+
* own. Resolves `deleted` once the vault holds the file no longer, deleted
|
|
47
|
+
* now or already gone. Resolves `kept` when this end deleted nothing, which
|
|
48
|
+
* {@link get} shows as it is now: the upload published the file, or a later
|
|
49
|
+
* upload took it over, before the end reached the server, or, with no
|
|
50
|
+
* request sent, the create did not make it (`created: false`) or names no
|
|
51
|
+
* upload (`uploadId: null`), since a delete without its upload would take
|
|
52
|
+
* whatever file stands. Any other failure rejects, the file left as it was.
|
|
53
|
+
* {@link upload} ends an upload it cannot finish this way by itself.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* const upload = await sv.ingots.createUpload({ vault: unsealed, name: file.name,
|
|
57
|
+
* contentType: file.type, sizeBytes: file.size });
|
|
58
|
+
* try {
|
|
59
|
+
* await sv.ingots.sendUpload(upload.uploadUrl, file, { signal: controller.signal });
|
|
60
|
+
* } catch (error) {
|
|
61
|
+
* if (!isReceivedUploadFailure(error) &&
|
|
62
|
+
* await sv.ingots.endUpload(unsealed, upload) === 'kept') {
|
|
63
|
+
* // The end deleted nothing (the upload published the file, say): show it as it is.
|
|
64
|
+
* showIngot(await sv.ingots.get(unsealed, upload.id));
|
|
65
|
+
* }
|
|
66
|
+
* throw error;
|
|
67
|
+
* }
|
|
68
|
+
*/
|
|
69
|
+
endUpload(vault: UnsealedVault, upload: Pick<IngotUpload, 'id' | 'created' | 'uploadId'>): Promise<UploadEnd>;
|
|
37
70
|
/**
|
|
38
71
|
* Send a file's bytes to an upload session — the `uploadUrl` a
|
|
39
72
|
* {@link createUpload} returned — over the resumable transfer every SDK
|
|
@@ -120,7 +153,11 @@ export declare class IngotsModule {
|
|
|
120
153
|
* server refused — another upload of it superseded this one, at its create
|
|
121
154
|
* or while it streamed, the storage pool cannot take it, or its vault is
|
|
122
155
|
* scheduled for deletion (a 409 `VAULT_DELETION_SCHEDULED`) — rejects with
|
|
123
|
-
* code `upload_refused`, as {@link sendUpload} does.
|
|
156
|
+
* code `upload_refused`, as {@link sendUpload} does. An upload that rejects
|
|
157
|
+
* any way but one the server received whole ({@link isReceivedUploadFailure}:
|
|
158
|
+
* the server publishes or ends that one on its own) is given up: the end of
|
|
159
|
+
* it with the file its create made ({@link endUpload}) starts as it
|
|
160
|
+
* rejects, without holding up its own error.
|
|
124
161
|
*
|
|
125
162
|
* @example
|
|
126
163
|
* const ingot = await sv.ingots.upload(unsealed, {
|
|
@@ -128,6 +165,12 @@ export declare class IngotsModule {
|
|
|
128
165
|
* });
|
|
129
166
|
*/
|
|
130
167
|
upload(vault: UnsealedVault, options: UploadIngotOptions): Promise<CreatedIngot>;
|
|
168
|
+
/**
|
|
169
|
+
* End an upload this flow gave up ({@link endUpload}) without holding up
|
|
170
|
+
* the error its caller is answered with: an end that fails leaves the file
|
|
171
|
+
* to the server's expiry of abandoned uploads, and is logged.
|
|
172
|
+
*/
|
|
173
|
+
private endGivenUp;
|
|
131
174
|
/**
|
|
132
175
|
* Replace an existing ingot's content (high-level flow). Rejects as
|
|
133
176
|
* {@link upload} does, a replacement another upload of the same ingot
|
|
@@ -253,13 +296,16 @@ export declare class IngotsModule {
|
|
|
253
296
|
*/
|
|
254
297
|
updateSharingConfig(vault: UnsealedVault, ingotId: string, config: UpdateIngotSharingOptions): Promise<IngotSharingConfig>;
|
|
255
298
|
/**
|
|
256
|
-
* Invite an identity to
|
|
257
|
-
*
|
|
299
|
+
* Invite an identity to an ingot's invite-only share, or share an ingot not
|
|
300
|
+
* yet shared invite-only with it. A public or authenticated share refuses
|
|
301
|
+
* it (a ValidationError) and changes nothing: set its visibility to
|
|
302
|
+
* `invite_only` first. The identity type (email or phone) is inferred
|
|
303
|
+
* server-side from the identity value.
|
|
258
304
|
*
|
|
259
305
|
* @example
|
|
260
306
|
* await sv.ingots.addInvite(unsealed, 'ing_abc', 'user@example.com');
|
|
261
307
|
*/
|
|
262
|
-
addInvite(vault: UnsealedVault, ingotId: string, identity: string): Promise<
|
|
308
|
+
addInvite(vault: UnsealedVault, ingotId: string, identity: string): Promise<IngotInvitation>;
|
|
263
309
|
/**
|
|
264
310
|
* Revoke an ingot sharing invite.
|
|
265
311
|
*
|
|
@@ -302,5 +348,6 @@ export declare class IngotsModule {
|
|
|
302
348
|
}
|
|
303
349
|
export { NAME_CONFLICT_POLICIES } from './types';
|
|
304
350
|
export { fetchDownload } from './fetch-download';
|
|
351
|
+
export { isReceivedUploadFailure } from '../vaults/upload/api';
|
|
305
352
|
export type { FetchDownloadOptions, FetchedDownload } from './fetch-download';
|
|
306
|
-
export type { NameConflictPolicy, UnsealedVault, Ingot, IngotUpload, CreatedIngot, IngotDownloadLink, CreateUploadOptions, UploadIngotOptions, SendUploadOptions, ResumeUploadOptions, UploadSession, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, FolderContents, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvite, IngotAccessLog, IngotAccessLogPage, AccessLogsOptions, HashCheckResponse, } from './types';
|
|
353
|
+
export type { NameConflictPolicy, UnsealedVault, Ingot, IngotUpload, UploadEnd, CreatedIngot, IngotDownloadLink, CreateUploadOptions, UploadIngotOptions, SendUploadOptions, ResumeUploadOptions, UploadSession, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, FolderContents, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvite, IngotInvitation, IngotAccessLog, IngotAccessLogPage, AccessLogsOptions, HashCheckResponse, } from './types';
|
package/dist/ingots/types.d.ts
CHANGED
|
@@ -87,7 +87,22 @@ export interface IngotUpload {
|
|
|
87
87
|
* ingot already holding the name (false, as `onNameConflict` allowed).
|
|
88
88
|
*/
|
|
89
89
|
created: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* The upload the create staged onto the ingot (Core's `upload_id`): the id
|
|
92
|
+
* Forge keys the upload's session by, and the `contentVersion` the ingot
|
|
93
|
+
* reads once the upload publishes. Giving the upload up ends it with the
|
|
94
|
+
* file the create made through this id (`endUpload`). Null when the server
|
|
95
|
+
* named none.
|
|
96
|
+
*/
|
|
97
|
+
uploadId: string | null;
|
|
90
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* What became of a given-up upload's file (`endUpload`): `deleted`, the vault
|
|
101
|
+
* holds it no longer (this end deleted it, or it was already gone); `kept`,
|
|
102
|
+
* this end deleted nothing, and a read of it by id (`get`) shows the file as
|
|
103
|
+
* it is now.
|
|
104
|
+
*/
|
|
105
|
+
export type UploadEnd = 'deleted' | 'kept';
|
|
91
106
|
/** A finalized ingot, returned by the high-level upload/replace flows. */
|
|
92
107
|
export interface CreatedIngot {
|
|
93
108
|
/** Ingot ID */
|
|
@@ -292,6 +307,16 @@ export interface IngotSharingConfig {
|
|
|
292
307
|
shared: boolean;
|
|
293
308
|
/** Visibility mode */
|
|
294
309
|
visibility?: 'invite_only' | 'authenticated' | 'public';
|
|
310
|
+
/** The share's permanent files.sv URL, the link its recipients open; null while the ingot is not shared */
|
|
311
|
+
publicUrl: string | null;
|
|
312
|
+
/** The share's link code (the URL's last segment); null while the ingot is not shared */
|
|
313
|
+
linkCode: string | null;
|
|
314
|
+
/** Whether the vault's public file sharing is on */
|
|
315
|
+
sharingEnabled: boolean;
|
|
316
|
+
/** Whether the vault makes every ingot public, which pins this one to public */
|
|
317
|
+
vaultAllIngotsPublic: boolean;
|
|
318
|
+
/** The vault's share recipient session length, in seconds */
|
|
319
|
+
sessionLengthSeconds: number;
|
|
295
320
|
/** Active invites */
|
|
296
321
|
invites?: IngotInvite[];
|
|
297
322
|
}
|
|
@@ -310,6 +335,15 @@ export interface IngotInvite {
|
|
|
310
335
|
identity: string;
|
|
311
336
|
/** Identity type */
|
|
312
337
|
identityType: 'email' | 'phone';
|
|
338
|
+
/** When this identity was invited (Unix seconds) */
|
|
339
|
+
invitedAt: number;
|
|
340
|
+
}
|
|
341
|
+
/** An invitation addInvite made or resent. */
|
|
342
|
+
export interface IngotInvitation extends IngotInvite {
|
|
343
|
+
/** The URL this invitee was sent: the share's files.sv URL, with their own token when the share invites several */
|
|
344
|
+
shareUrl: string;
|
|
345
|
+
/** Whether the invitation was delivered by email or text */
|
|
346
|
+
delivered: boolean;
|
|
313
347
|
}
|
|
314
348
|
/**
|
|
315
349
|
* An ingot access-log entry: a download that delivered the file, a SparkLink
|
|
@@ -377,9 +411,13 @@ export interface ReplaceIngotResponse {
|
|
|
377
411
|
forge_url: string;
|
|
378
412
|
expires_at: number;
|
|
379
413
|
}
|
|
380
|
-
/**
|
|
414
|
+
/**
|
|
415
|
+
* POST /ingots — `created` says whether the name was minted or its holder
|
|
416
|
+
* staged onto, and `upload_id` names the upload the create staged.
|
|
417
|
+
*/
|
|
381
418
|
export interface CreateIngotResponse extends ReplaceIngotResponse {
|
|
382
419
|
created: boolean;
|
|
420
|
+
upload_id?: string;
|
|
383
421
|
}
|
|
384
422
|
export interface ListIngotsResponse {
|
|
385
423
|
ingots: IngotWire[];
|
|
@@ -410,9 +448,17 @@ export interface DownloadIngotResponse {
|
|
|
410
448
|
size_bytes: number;
|
|
411
449
|
content_type: string;
|
|
412
450
|
}
|
|
451
|
+
/** A sharing answer (apps/api/src/ingots/sharing.js formatSharingConfig). */
|
|
413
452
|
export interface IngotSharingConfigResponse {
|
|
453
|
+
ingot_id: string;
|
|
454
|
+
vault_id: string;
|
|
455
|
+
sharing_enabled: boolean;
|
|
414
456
|
shared: boolean;
|
|
415
|
-
visibility?: 'invite_only' | 'authenticated' | 'public';
|
|
457
|
+
visibility?: 'invite_only' | 'authenticated' | 'public' | null;
|
|
458
|
+
public_url: string | null;
|
|
459
|
+
link_code: string | null;
|
|
460
|
+
vault_all_ingots_public: boolean;
|
|
461
|
+
session_length_seconds: number;
|
|
416
462
|
invites?: IngotInviteResponse[];
|
|
417
463
|
}
|
|
418
464
|
/** An invite as the sharing answers carry it (apps/api/src/ingots/sharing.js). */
|
|
@@ -420,4 +466,11 @@ export interface IngotInviteResponse {
|
|
|
420
466
|
invite_id: string;
|
|
421
467
|
identity: string;
|
|
422
468
|
identity_type: 'email' | 'phone';
|
|
469
|
+
expires_at: null;
|
|
470
|
+
created_at: number;
|
|
471
|
+
}
|
|
472
|
+
/** An invite answer (apps/api/src/ingots/sharing.js inviteIdentity). */
|
|
473
|
+
export interface IngotInvitationResponse extends IngotInviteResponse {
|
|
474
|
+
share_url: string;
|
|
475
|
+
delivered: boolean;
|
|
423
476
|
}
|
|
@@ -54,8 +54,12 @@ export declare class IdentityModule {
|
|
|
54
54
|
* `IdentityModule.isFedcmAvailable()` and fall back to `signIn()` otherwise.
|
|
55
55
|
*
|
|
56
56
|
* @returns the verified result, or `null` when the browser has no FedCM
|
|
57
|
-
* support (so the caller can fall back). Throws `UserCancelledError` when
|
|
58
|
-
*
|
|
57
|
+
* support (so the caller can fall back). Throws `UserCancelledError` when
|
|
58
|
+
* the browser ends the request without a credential: the person dismissed
|
|
59
|
+
* the chooser, or the browser had no SparkVault account to offer (the
|
|
60
|
+
* browser reports both alike). Throws `IdentityProviderError`, carrying
|
|
61
|
+
* SparkVault's own error code, when SparkVault answered the sign-in with an
|
|
62
|
+
* error.
|
|
59
63
|
*
|
|
60
64
|
* @example
|
|
61
65
|
* const result = (await sv.products.identity.isFedcmAvailable())
|