@sparkvault/sdk-js 19.0.0 → 19.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.
- package/README.md +26 -4
- package/dist/npm/chunks/index-BnP-2w0t.cjs +13025 -0
- package/dist/npm/chunks/index-BnP-2w0t.cjs.map +1 -0
- package/dist/npm/chunks/index-CgR08uMG.mjs +12960 -0
- package/dist/npm/chunks/index-CgR08uMG.mjs.map +1 -0
- package/dist/npm/identity.cjs +23 -0
- package/dist/npm/identity.cjs.map +1 -0
- package/dist/npm/identity.mjs +12 -0
- package/dist/npm/identity.mjs.map +1 -0
- package/dist/{index.cjs → npm/index.cjs} +799 -13755
- package/dist/npm/index.cjs.map +1 -0
- package/dist/{index.mjs → npm/index.mjs} +200 -13155
- package/dist/npm/index.mjs.map +1 -0
- package/dist/sparkvault-identity.js +2 -0
- package/dist/sparkvault-identity.js.map +1 -0
- package/dist/sparkvault.js +1 -1
- package/dist/types/identity.d.ts +8 -0
- package/dist/{index.d.ts → types/index.d.ts} +4 -790
- package/dist/types/shared/errors-C-gjmGBs.d.ts +800 -0
- package/package.json +20 -9
- package/dist/api-base.d.ts +0 -116
- package/dist/auto-init.d.ts +0 -32
- package/dist/config.d.ts +0 -79
- package/dist/entropy/index.d.ts +0 -35
- package/dist/entropy/types.d.ts +0 -32
- package/dist/errors.d.ts +0 -146
- package/dist/folders/index.d.ts +0 -102
- package/dist/folders/types.d.ts +0 -91
- package/dist/health.d.ts +0 -18
- package/dist/http.d.ts +0 -46
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/ingots/fetch-download.d.ts +0 -78
- package/dist/ingots/history.d.ts +0 -4
- package/dist/ingots/index.d.ts +0 -388
- package/dist/ingots/revision.d.ts +0 -4
- package/dist/ingots/types.d.ts +0 -556
- package/dist/logger.d.ts +0 -32
- package/dist/notify/index.d.ts +0 -154
- package/dist/notify/types.d.ts +0 -232
- package/dist/products/help-desk/client.d.ts +0 -198
- package/dist/products/help-desk/desk-id.d.ts +0 -2
- package/dist/products/help-desk/form-draft.d.ts +0 -37
- package/dist/products/help-desk/form-types.d.ts +0 -123
- package/dist/products/help-desk/form.d.ts +0 -83
- package/dist/products/help-desk/index.d.ts +0 -47
- package/dist/products/help-desk/kb-client.d.ts +0 -48
- package/dist/products/help-desk/kb-types.d.ts +0 -59
- package/dist/products/help-desk/modal.d.ts +0 -8
- package/dist/products/help-desk/styles.d.ts +0 -9
- package/dist/products/help-desk/support-analytics-types.d.ts +0 -32
- package/dist/products/help-desk/support-analytics.d.ts +0 -3
- package/dist/products/help-desk/support-brand.d.ts +0 -49
- package/dist/products/help-desk/support-controller.d.ts +0 -4
- package/dist/products/help-desk/support-history.d.ts +0 -38
- package/dist/products/help-desk/support-launcher.d.ts +0 -12
- package/dist/products/help-desk/support-styles.d.ts +0 -14
- package/dist/products/help-desk/support-types.d.ts +0 -66
- package/dist/products/help-desk/support-view.d.ts +0 -173
- package/dist/products/help-desk/types.d.ts +0 -285
- package/dist/products/help-desk/widget-identity.d.ts +0 -32
- package/dist/products/identity/api.d.ts +0 -237
- package/dist/products/identity/container.d.ts +0 -44
- package/dist/products/identity/dialog-launcher.d.ts +0 -133
- package/dist/products/identity/federation-flow.d.ts +0 -31
- package/dist/products/identity/handlers/otp-handler.d.ts +0 -69
- package/dist/products/identity/handlers/passkey-handler.d.ts +0 -105
- package/dist/products/identity/handlers/sparklink-handler.d.ts +0 -34
- package/dist/products/identity/index.d.ts +0 -296
- package/dist/products/identity/inline-container.d.ts +0 -53
- package/dist/products/identity/methods.d.ts +0 -19
- package/dist/products/identity/modal.d.ts +0 -51
- package/dist/products/identity/pending-signin.d.ts +0 -102
- package/dist/products/identity/popup-launcher.d.ts +0 -73
- package/dist/products/identity/renderer.d.ts +0 -525
- package/dist/products/identity/state.d.ts +0 -84
- package/dist/products/identity/styles.d.ts +0 -31
- package/dist/products/identity/types.d.ts +0 -561
- package/dist/products/identity/utils/cooldown-timer.d.ts +0 -73
- package/dist/products/identity/utils.d.ts +0 -85
- package/dist/products/identity/views/backup-verify.d.ts +0 -42
- package/dist/products/identity/views/base.d.ts +0 -51
- package/dist/products/identity/views/error.d.ts +0 -65
- package/dist/products/identity/views/icons.d.ts +0 -41
- package/dist/products/identity/views/identity-input.d.ts +0 -80
- package/dist/products/identity/views/index.d.ts +0 -20
- package/dist/products/identity/views/loading.d.ts +0 -23
- package/dist/products/identity/views/method-button.d.ts +0 -14
- package/dist/products/identity/views/method-select.d.ts +0 -42
- package/dist/products/identity/views/origin-not-allowed.d.ts +0 -25
- package/dist/products/identity/views/otp-verify.d.ts +0 -58
- package/dist/products/identity/views/passkey-auto.d.ts +0 -22
- package/dist/products/identity/views/passkey-prompt.d.ts +0 -25
- package/dist/products/identity/views/passkey.d.ts +0 -38
- package/dist/products/identity/views/product-not-configured.d.ts +0 -21
- package/dist/products/identity/views/service-unavailable.d.ts +0 -21
- package/dist/products/identity/views/sms-consent.d.ts +0 -16
- package/dist/products/identity/views/sparklink-waiting.d.ts +0 -40
- package/dist/products/identity/views/two-factor.d.ts +0 -37
- package/dist/products/index.d.ts +0 -51
- package/dist/products/messaging/index.d.ts +0 -38
- package/dist/products/messaging/types.d.ts +0 -162
- package/dist/products/notify/index.d.ts +0 -436
- package/dist/products/notify/project-types.d.ts +0 -44
- package/dist/products/notify/projects.d.ts +0 -15
- package/dist/products/notify/types.d.ts +0 -1327
- package/dist/products/structured-ingots/index.d.ts +0 -31
- package/dist/products/structured-ingots/types-client.d.ts +0 -19
- package/dist/products/structured-ingots/types.d.ts +0 -293
- package/dist/products/structured-ingots/validation.d.ts +0 -25
- package/dist/request-path.d.ts +0 -44
- package/dist/sparks/index.d.ts +0 -91
- package/dist/sparks/types.d.ts +0 -304
- package/dist/ui/chrome.d.ts +0 -16
- package/dist/ui/ds-tokens.d.ts +0 -59
- package/dist/ui/inline-shell.d.ts +0 -19
- package/dist/ui/live-region.d.ts +0 -15
- package/dist/ui/modal-shell.d.ts +0 -67
- package/dist/ui/target.d.ts +0 -6
- package/dist/utils/dom.d.ts +0 -26
- package/dist/vault-session.d.ts +0 -2
- package/dist/vaults/index.d.ts +0 -254
- package/dist/vaults/types.d.ts +0 -368
- package/dist/vaults/upload/api.d.ts +0 -310
- package/dist/vaults/upload/chrome.d.ts +0 -21
- package/dist/vaults/upload/container.d.ts +0 -37
- package/dist/vaults/upload/index.d.ts +0 -76
- package/dist/vaults/upload/inline-container.d.ts +0 -41
- package/dist/vaults/upload/modal.d.ts +0 -55
- package/dist/vaults/upload/renderer.d.ts +0 -150
- package/dist/vaults/upload/styles.d.ts +0 -14
- package/dist/vaults/upload/types.d.ts +0 -220
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The one browser transfer for a signed ingot download link: fetch it into a
|
|
3
|
-
* Blob under liveness bounds, resuming from the bytes it holds when the caller
|
|
4
|
-
* can mint another link. `sv.ingots.download` uses it, and so can a caller
|
|
5
|
-
* that mints its own link (`createDownloadLink`, or its own authenticated
|
|
6
|
-
* call) and needs cancellation, byte progress, resumption or the published
|
|
7
|
-
* revision.
|
|
8
|
-
*/
|
|
9
|
-
export interface FetchDownloadOptions {
|
|
10
|
-
/** Cancels the transfer, a wait between attempts included; the returned promise rejects with the signal's reason. */
|
|
11
|
-
signal?: AbortSignal;
|
|
12
|
-
/**
|
|
13
|
-
* Bytes received so far and the file's declared length (0 when the server
|
|
14
|
-
* declared none). A resumed transfer counts the bytes it already held; one
|
|
15
|
-
* that has to start over (the file was replaced meanwhile, or the server
|
|
16
|
-
* named nothing to resume against) counts from 0 again.
|
|
17
|
-
*/
|
|
18
|
-
onProgress?: (loaded: number, total: number) => void;
|
|
19
|
-
/**
|
|
20
|
-
* The published revision the caller read. A response naming another one is
|
|
21
|
-
* refused (code `content_changed`) before its body is read: the bytes would
|
|
22
|
-
* not be the file the caller described.
|
|
23
|
-
*/
|
|
24
|
-
expectedContentVersion?: string | null;
|
|
25
|
-
/**
|
|
26
|
-
* The hosts a download link may name (handed the lowercased host name);
|
|
27
|
-
* SparkVault's own hosts when omitted. `sv.ingots.download` passes the
|
|
28
|
-
* client's `allowedDownloadHostPatterns`. A minted link is held to it too.
|
|
29
|
-
*/
|
|
30
|
-
isAllowedHost?: (hostname: string) => boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Mints a fresh download link for the same ingot, resolving to its URL. A
|
|
33
|
-
* link is single-use: Forge claims it the moment the request arrives, so a
|
|
34
|
-
* second fetch answers 401 even after a first whose answer never came back.
|
|
35
|
-
* Given this, a failed transfer is retried under the platform's transfer
|
|
36
|
-
* policy (`@sparkvault/app-sdk/transfer-retry`) on a link minted first:
|
|
37
|
-
* from the first byte it lacks (`Range`, conditioned by `If-Range` on the
|
|
38
|
-
* publication's ETag) once bytes have arrived from a response that named a
|
|
39
|
-
* strong ETag and `Accept-Ranges: bytes`, and from the first byte otherwise.
|
|
40
|
-
* A mint that rejects with a `SparkVaultError` is read by its `statusCode`
|
|
41
|
-
* and `retryAfterMs` as a transfer answer is, so a mint the server refuses
|
|
42
|
-
* ends the download and one it throttles is retried no sooner than its
|
|
43
|
-
* `Retry-After`; any other rejection is taken for a request that got no
|
|
44
|
-
* answer, and retried. Without it, any failure is final.
|
|
45
|
-
*/
|
|
46
|
-
remint?: () => Promise<string>;
|
|
47
|
-
}
|
|
48
|
-
export interface FetchedDownload {
|
|
49
|
-
blob: Blob;
|
|
50
|
-
/** The revision the bytes are (the response's X-Content-Version), or null when the server named none. */
|
|
51
|
-
contentVersion: string | null;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Refuse a download link that is not a Forge decrypt URL on an allowed host
|
|
55
|
-
* (SparkVault's own when the caller names none), by the one reading of a
|
|
56
|
-
* Core-issued transfer URL (app-sdk forge-url): https, no credentials, port or
|
|
57
|
-
* fragment, the decrypt path, exactly one ISTK. The ISTK is a bearer
|
|
58
|
-
* credential for the transfer, so nothing is sent to a link this refuses.
|
|
59
|
-
*
|
|
60
|
-
* @throws {ValidationError} 'Invalid download URL', with `details.reason` naming the refusal
|
|
61
|
-
*/
|
|
62
|
-
export declare function assertDownloadUrl(url: string, isAllowedHost?: (hostname: string) => boolean): void;
|
|
63
|
-
/**
|
|
64
|
-
* Fetch a signed download URL as a Blob under liveness bounds: one deadline
|
|
65
|
-
* for each response's headers, then an idle deadline rearmed on every body
|
|
66
|
-
* chunk. Nothing caps the transfer as a whole, so file size never decides
|
|
67
|
-
* whether a download can finish. The link is single-use, so a failed transfer
|
|
68
|
-
* is retried only through `options.remint`, on a link minted for the retry. A
|
|
69
|
-
* link that is not a Forge decrypt URL on an allowed host, the first or a
|
|
70
|
-
* minted one, is refused before anything is sent to it (assertDownloadUrl).
|
|
71
|
-
*/
|
|
72
|
-
export declare function fetchDownload(url: string, options?: FetchDownloadOptions): Promise<FetchedDownload>;
|
|
73
|
-
/**
|
|
74
|
-
* {@link fetchDownload} for a caller whose every link is minted, the first
|
|
75
|
-
* included: a mint that fails before any byte has moved is retried under the
|
|
76
|
-
* same policy as any other failure. `sv.ingots.download` runs this.
|
|
77
|
-
*/
|
|
78
|
-
export declare function fetchMintedDownload(mint: () => Promise<string>, options?: Omit<FetchDownloadOptions, 'remint'>): Promise<FetchedDownload>;
|
package/dist/ingots/history.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { IngotHistory, IngotHistoryResponse } from './types';
|
|
2
|
-
/** Core files and Structured Ingots expose the same retained publication metadata. */
|
|
3
|
-
export declare function mapIngotHistory(data: IngotHistoryResponse): IngotHistory;
|
|
4
|
-
export declare function requireVersionId(value: unknown): string;
|
package/dist/ingots/index.d.ts
DELETED
|
@@ -1,388 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Ingots Module
|
|
3
|
-
*
|
|
4
|
-
* Data-plane operations on the contents of an *unsealed* vault. Every method
|
|
5
|
-
* takes the {@link UnsealedVault} returned by `sv.vaults.unseal(...)` and
|
|
6
|
-
* authenticates with its short-lived Vault Access Token (VAT).
|
|
7
|
-
*
|
|
8
|
-
* Uploads and downloads run over the single canonical Forge TUS transfer path
|
|
9
|
-
* (shared with the public upload widget), with server-side finalization and
|
|
10
|
-
* download-host allowlisting enforced, with no per-size branching.
|
|
11
|
-
*/
|
|
12
|
-
import { type ResolvedConfig } from '../config';
|
|
13
|
-
import { HttpClient } from '../http';
|
|
14
|
-
import type { UnsealedVault, Ingot, IngotUpload, UploadEnd, CreatedIngot, IngotDownloadLink, IngotDownload, IngotHistory, IngotVersionDownloadLink, DeleteIngotOptions, DownloadIngotOptions, CreateUploadOptions, UploadIngotOptions, SendUploadOptions, ResumeUploadOptions, UploadSession, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, FolderContents, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvitation, IngotAccessLogPage, AccessLogsOptions, HashCheckResponse } from './types';
|
|
15
|
-
export declare class IngotsModule {
|
|
16
|
-
private readonly config;
|
|
17
|
-
private readonly http;
|
|
18
|
-
constructor(config: ResolvedConfig, http: HttpClient);
|
|
19
|
-
/**
|
|
20
|
-
* Create an ingot upload session (discrete primitive).
|
|
21
|
-
*
|
|
22
|
-
* Reserves the ingot record and returns the Forge upload URL (carrying the
|
|
23
|
-
* ISTK upload session token). Use this when you want to drive the TUS
|
|
24
|
-
* transfer yourself; otherwise prefer {@link upload}. A create another
|
|
25
|
-
* upload of the same file superseded before its token was issued rejects
|
|
26
|
-
* with code `upload_refused` (`details.coreCode` UPLOAD_SUPERSEDED): the
|
|
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.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* const session = await sv.ingots.createUpload({
|
|
33
|
-
* vault: unsealed, name: 'report.pdf',
|
|
34
|
-
* contentType: 'application/pdf', sizeBytes: file.size,
|
|
35
|
-
* });
|
|
36
|
-
* console.log(session.uploadUrl);
|
|
37
|
-
*/
|
|
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>;
|
|
70
|
-
/**
|
|
71
|
-
* Send a file's bytes to an upload session (the `uploadUrl` a
|
|
72
|
-
* {@link createUpload} returned) over the resumable transfer every SDK
|
|
73
|
-
* upload uses. Resolves only once the server confirms the ingot is
|
|
74
|
-
* published, so a resolved promise never stands for a stored file whose
|
|
75
|
-
* ingot never went live.
|
|
76
|
-
*
|
|
77
|
-
* Transient failures are retried inside the transfer; a session the server
|
|
78
|
-
* no longer holds (it expired, was cancelled, or its ingot was removed)
|
|
79
|
-
* rejects with code `session_gone`, and only a new upload session (a new
|
|
80
|
-
* {@link createUpload}, or {@link upload} again) can store the file. An
|
|
81
|
-
* upload the server refused (the account's storage pool cannot take it, a
|
|
82
|
-
* later upload replaced it, or its vault is scheduled for deletion: a 409
|
|
83
|
-
* `VAULT_DELETION_SCHEDULED`, whose session the server keeps until the
|
|
84
|
-
* deletion runs or is cancelled, or the session lapses on its own) rejects
|
|
85
|
-
* at once with code `upload_refused`, its message the server's own sentence
|
|
86
|
-
* and its code in `details.coreCode`: a new upload is no remedy. A
|
|
87
|
-
* publication the server
|
|
88
|
-
* still defers at the transfer's idle limit rejects with code
|
|
89
|
-
* `upload_received_publishing`: every byte is received, and the server
|
|
90
|
-
* finishes the publication on its own, so never upload the file again; a
|
|
91
|
-
* caller that kept the session (`onSessionCreated`) learns what became of
|
|
92
|
-
* it with {@link resumeUpload}. A chunk's upload progress needs the
|
|
93
|
-
* browser's XMLHttpRequest: where there is none (a Node server) it rejects
|
|
94
|
-
* with code `environment_unsupported` before any request; a server sends
|
|
95
|
-
* the bytes over tus to `uploadUrl` itself.
|
|
96
|
-
*
|
|
97
|
-
* @param options.signal - Cancels this transfer (it rejects with code
|
|
98
|
-
* `cancelled`); other transfers carry on.
|
|
99
|
-
* @param options.onProgress - Bytes sent so far and the file size; never runs backwards.
|
|
100
|
-
* @param options.onSessionCreated - Hands over the upload's session once
|
|
101
|
-
* Forge opens it, before the first byte is sent.
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* const session = await sv.ingots.createUpload({ vault: unsealed, name: file.name,
|
|
105
|
-
* contentType: file.type, sizeBytes: file.size });
|
|
106
|
-
* await sv.ingots.sendUpload(session.uploadUrl, file, { signal: controller.signal });
|
|
107
|
-
*/
|
|
108
|
-
sendUpload(uploadUrl: string, file: File | Blob, options?: SendUploadOptions): Promise<void>;
|
|
109
|
-
/**
|
|
110
|
-
* Continue an upload in the session a {@link sendUpload} opened for the same
|
|
111
|
-
* file (the `session` its `onSessionCreated` handed over): Forge is asked
|
|
112
|
-
* where the session stands, only the bytes it lacks are sent, and the
|
|
113
|
-
* promise resolves once the server confirms the ingot is published. A
|
|
114
|
-
* session that already holds every byte sends none and only asks: this is
|
|
115
|
-
* how a caller follows an upload that ended `upload_received_publishing`
|
|
116
|
-
* until the server publishes it or ends it.
|
|
117
|
-
*
|
|
118
|
-
* It rejects as {@link sendUpload} does: `session_gone` once the server no
|
|
119
|
-
* longer holds the session (it expired, was cancelled, or ended when the
|
|
120
|
-
* server refused to publish it), `upload_refused` for an upload the server
|
|
121
|
-
* refused (its storage pool, a later upload, or its vault scheduled for
|
|
122
|
-
* deletion, a 409 `VAULT_DELETION_SCHEDULED` that keeps the session, so a
|
|
123
|
-
* resume once the deletion is cancelled goes on while the session stands),
|
|
124
|
-
* `upload_received_publishing` again for a publication the server
|
|
125
|
-
* still defers at the transfer's idle limit, which leaves the session to
|
|
126
|
-
* resume again later. A session URL that is not an upload session on an
|
|
127
|
-
* allowed transfer host is refused (`invalid_forge_url`), and one whose
|
|
128
|
-
* upload is not this file's length (`session_mismatch`), before a byte is
|
|
129
|
-
* sent.
|
|
130
|
-
*
|
|
131
|
-
* @param options.signal - Cancels this transfer (it rejects with code
|
|
132
|
-
* `cancelled`); the session stays as it stands.
|
|
133
|
-
* @param options.onProgress - Bytes the session holds so far and the file size; never runs backwards.
|
|
134
|
-
*
|
|
135
|
-
* @example
|
|
136
|
-
* let session;
|
|
137
|
-
* try {
|
|
138
|
-
* await sv.ingots.sendUpload(upload.uploadUrl, file, { onSessionCreated: (s) => { session = s; } });
|
|
139
|
-
* } catch (error) {
|
|
140
|
-
* if (error.code !== 'upload_received_publishing') throw error;
|
|
141
|
-
* await sv.ingots.resumeUpload(session, file);
|
|
142
|
-
* }
|
|
143
|
-
*/
|
|
144
|
-
resumeUpload(session: UploadSession, file: File | Blob, options?: ResumeUploadOptions): Promise<void>;
|
|
145
|
-
/**
|
|
146
|
-
* Run one transfer on a transfer client of its own: its abort is scoped to
|
|
147
|
-
* its own session, so cancelling one upload never touches another in
|
|
148
|
-
* flight, and the caller's signal cancels it (code `cancelled`).
|
|
149
|
-
*/
|
|
150
|
-
private runTransfer;
|
|
151
|
-
/**
|
|
152
|
-
* Upload a file as a new ingot (high-level flow).
|
|
153
|
-
*
|
|
154
|
-
* Creates the upload session, streams the file to Forge over TUS, then
|
|
155
|
-
* confirms the server finalized the upload before resolving. A file the
|
|
156
|
-
* server refused (another upload of it superseded this one, at its create
|
|
157
|
-
* or while it streamed, the storage pool cannot take it, or its vault is
|
|
158
|
-
* scheduled for deletion (a 409 `VAULT_DELETION_SCHEDULED`)) rejects with
|
|
159
|
-
* code `upload_refused`, as {@link sendUpload} does. An upload that rejects
|
|
160
|
-
* any way but one the server received whole ({@link isReceivedUploadFailure}:
|
|
161
|
-
* the server publishes or ends that one on its own) is given up: the end of
|
|
162
|
-
* it with the file its create made ({@link endUpload}) starts as it
|
|
163
|
-
* rejects, without holding up its own error. It needs the browser's
|
|
164
|
-
* XMLHttpRequest, as {@link sendUpload} does: in a server process it
|
|
165
|
-
* rejects with code `environment_unsupported` before any request, so no
|
|
166
|
-
* create stages an ingot it cannot send.
|
|
167
|
-
*
|
|
168
|
-
* @example
|
|
169
|
-
* const ingot = await sv.ingots.upload(unsealed, {
|
|
170
|
-
* file: myFile, name: 'document.pdf'
|
|
171
|
-
* });
|
|
172
|
-
*/
|
|
173
|
-
upload(vault: UnsealedVault, options: UploadIngotOptions): Promise<CreatedIngot>;
|
|
174
|
-
/**
|
|
175
|
-
* End an upload this flow gave up ({@link endUpload}) without holding up
|
|
176
|
-
* the error its caller is answered with: an end that fails leaves the file
|
|
177
|
-
* to the server's expiry of abandoned uploads, and is logged.
|
|
178
|
-
*/
|
|
179
|
-
private endGivenUp;
|
|
180
|
-
/**
|
|
181
|
-
* Replace an existing ingot's content (high-level flow). Rejects as
|
|
182
|
-
* {@link upload} does, a replacement another upload of the same ingot
|
|
183
|
-
* superseded included (`upload_refused`), and `environment_unsupported`
|
|
184
|
-
* before the replacement is staged where there is no XMLHttpRequest.
|
|
185
|
-
*
|
|
186
|
-
* @example
|
|
187
|
-
* const original = await sv.ingots.downloadWithRevision(unsealed, 'ing_abc');
|
|
188
|
-
* await sv.ingots.replace(unsealed, 'ing_abc', {
|
|
189
|
-
* file: updatedFile, expectedRevision: original.revision,
|
|
190
|
-
* });
|
|
191
|
-
*/
|
|
192
|
-
replace(vault: UnsealedVault, ingotId: string, options: ReplaceIngotOptions): Promise<CreatedIngot>;
|
|
193
|
-
/**
|
|
194
|
-
* Rename an ingot.
|
|
195
|
-
*
|
|
196
|
-
* @example
|
|
197
|
-
* await sv.ingots.rename(unsealed, 'ing_abc', 'new-name.pdf');
|
|
198
|
-
*/
|
|
199
|
-
rename(vault: UnsealedVault, ingotId: string, name: string): Promise<Ingot>;
|
|
200
|
-
/**
|
|
201
|
-
* Move an ingot to a folder, or to the vault root with `null`.
|
|
202
|
-
*
|
|
203
|
-
* @example
|
|
204
|
-
* await sv.ingots.move(unsealed, 'ing_abc', 'fld_xyz');
|
|
205
|
-
* await sv.ingots.move(unsealed, 'ing_abc', null); // root
|
|
206
|
-
*/
|
|
207
|
-
move(vault: UnsealedVault, ingotId: string, folderId: string | null): Promise<Ingot>;
|
|
208
|
-
/**
|
|
209
|
-
* Delete an ingot.
|
|
210
|
-
*
|
|
211
|
-
* @example
|
|
212
|
-
* const original = await sv.ingots.get(unsealed, 'ing_abc');
|
|
213
|
-
* if (!original.revision) throw new Error('This server does not support guarded deletion');
|
|
214
|
-
* await sv.ingots.delete(unsealed, original.id, { expectedRevision: original.revision });
|
|
215
|
-
*/
|
|
216
|
-
delete(vault: UnsealedVault, ingotId: string, options?: DeleteIngotOptions): Promise<void>;
|
|
217
|
-
/**
|
|
218
|
-
* Get ingot metadata.
|
|
219
|
-
*
|
|
220
|
-
* @example
|
|
221
|
-
* const ingot = await sv.ingots.get(unsealed, 'ing_abc');
|
|
222
|
-
*/
|
|
223
|
-
get(vault: UnsealedVault, ingotId: string): Promise<Ingot>;
|
|
224
|
-
/**
|
|
225
|
-
* List ingots in an unsealed vault, one page at a time in the vault index's
|
|
226
|
-
* order: follow `nextCursor`. `sortBy` orders only the page answered; for
|
|
227
|
-
* one order across a vault, search or list a folder's contents.
|
|
228
|
-
*
|
|
229
|
-
* @example
|
|
230
|
-
* const { ingots } = await sv.ingots.list(unsealed);
|
|
231
|
-
*/
|
|
232
|
-
list(vault: UnsealedVault, options?: ListIngotsOptions): Promise<IngotPage>;
|
|
233
|
-
/**
|
|
234
|
-
* Search ingots in an unsealed vault, one page at a time. A page can hold
|
|
235
|
-
* fewer ingots than `limit`, even none, while more remain: follow
|
|
236
|
-
* `nextCursor` until it is absent, never stop on the count.
|
|
237
|
-
*
|
|
238
|
-
* @example
|
|
239
|
-
* let cursor: string | undefined;
|
|
240
|
-
* do {
|
|
241
|
-
* const page = await sv.ingots.search(unsealed, { q: 'invoice', cursor });
|
|
242
|
-
* page.ingots.forEach((i) => console.log(i.name));
|
|
243
|
-
* cursor = page.nextCursor;
|
|
244
|
-
* } while (cursor);
|
|
245
|
-
*/
|
|
246
|
-
search(vault: UnsealedVault, options?: SearchIngotsOptions): Promise<IngotPage>;
|
|
247
|
-
/**
|
|
248
|
-
* List one page of a folder's, or the vault root's, children: every direct
|
|
249
|
-
* subfolder first, then the ingots directly in it in creation order
|
|
250
|
-
* ({@link FolderContents}). Pass a page's `nextPageToken` back as
|
|
251
|
-
* `pageToken`, with the same folder and order, until it is null.
|
|
252
|
-
*
|
|
253
|
-
* @example
|
|
254
|
-
* let pageToken: string | undefined;
|
|
255
|
-
* do {
|
|
256
|
-
* const page = await sv.ingots.listContents(unsealed, { folderId: 'fld_x', pageToken });
|
|
257
|
-
* page.folders.forEach((f) => console.log(f.name));
|
|
258
|
-
* page.ingots.forEach((i) => console.log(i.name));
|
|
259
|
-
* pageToken = page.nextPageToken ?? undefined;
|
|
260
|
-
* } while (pageToken);
|
|
261
|
-
*/
|
|
262
|
-
listContents(vault: UnsealedVault, options?: ListContentsOptions): Promise<FolderContents>;
|
|
263
|
-
/** List previous publications of a file, newest first. Structured objects use their product's history method. */
|
|
264
|
-
listVersions(vault: UnsealedVault, ingotId: string): Promise<IngotHistory>;
|
|
265
|
-
/** Mint a one-use link to a retained file publication; use downloadVersion to verify the served bytes. */
|
|
266
|
-
createVersionDownloadLink(vault: UnsealedVault, ingotId: string, versionId: string): Promise<IngotVersionDownloadLink>;
|
|
267
|
-
/** Download a retained file publication; never substitutes the current bytes if history is unavailable. */
|
|
268
|
-
downloadVersion(vault: UnsealedVault, ingotId: string, versionId: string): Promise<Blob>;
|
|
269
|
-
/**
|
|
270
|
-
* Create a signed download link for an ingot (discrete primitive).
|
|
271
|
-
*
|
|
272
|
-
* Validates the returned URL against the download-host allowlist. Use this
|
|
273
|
-
* when you want the URL itself; otherwise prefer {@link download}. The link
|
|
274
|
-
* is single-use: Forge claims it the moment a request arrives, so a retry or
|
|
275
|
-
* a resume needs a link of its own (`fetchDownload`'s `remint`).
|
|
276
|
-
* Automatic display/prefetch should pass `{ countAsActivity: false }` so
|
|
277
|
-
* loading visible content does not extend the vault's inactivity deadline.
|
|
278
|
-
*
|
|
279
|
-
* @example
|
|
280
|
-
* const link = await sv.ingots.createDownloadLink(unsealed, 'ing_abc');
|
|
281
|
-
* const { blob } = await fetchDownload(link.downloadUrl, {
|
|
282
|
-
* remint: async () => (await sv.ingots.createDownloadLink(unsealed, 'ing_abc')).downloadUrl,
|
|
283
|
-
* });
|
|
284
|
-
*/
|
|
285
|
-
createDownloadLink(vault: UnsealedVault, ingotId: string, options?: DownloadIngotOptions): Promise<IngotDownloadLink>;
|
|
286
|
-
/**
|
|
287
|
-
* Download an ingot as a Blob (high-level flow).
|
|
288
|
-
*
|
|
289
|
-
* Every attempt fetches a signed link minted for it ({@link createDownloadLink}:
|
|
290
|
-
* a link is single-use), under liveness bounds, never a cap on total
|
|
291
|
-
* duration: a deadline on the response headers, then an idle deadline
|
|
292
|
-
* rearmed on every body chunk. A failure the platform's transfer policy
|
|
293
|
-
* retries (`@sparkvault/app-sdk/transfer-retry`: no answer, 408, 425, 429 or
|
|
294
|
-
* a 5xx, a mint's included) is retried after the policy's backoff, never
|
|
295
|
-
* sooner than `Retry-After`, until its budget ends. Once bytes have arrived
|
|
296
|
-
* the retry resumes from the first byte it lacks, conditioned on the
|
|
297
|
-
* publication's ETag (`If-Range`), so a stall at 90% fetches only the rest;
|
|
298
|
-
* a file replaced meanwhile starts over as its new content, and one served
|
|
299
|
-
* with no strong ETag starts over from its first byte. Any other refusal,
|
|
300
|
-
* and a link that is not a Forge decrypt URL on an allowed host, is final.
|
|
301
|
-
*
|
|
302
|
-
* @example
|
|
303
|
-
* const ingot = await sv.ingots.get(unsealed, 'ing_abc');
|
|
304
|
-
* const blob = await sv.ingots.download(unsealed, 'ing_abc');
|
|
305
|
-
* // Saved under the name Forge would send, as opaque bytes, which no
|
|
306
|
-
* // browser renames by a type (see Ingot.downloadFilename).
|
|
307
|
-
* const link = document.createElement('a');
|
|
308
|
-
* link.href = URL.createObjectURL(new Blob([blob], { type: 'application/octet-stream' }));
|
|
309
|
-
* link.download = ingot.downloadFilename;
|
|
310
|
-
* link.click();
|
|
311
|
-
*/
|
|
312
|
-
download(vault: UnsealedVault, ingotId: string, options?: DownloadIngotOptions): Promise<Blob>;
|
|
313
|
-
/**
|
|
314
|
-
* Download bytes with their identity-bound revision. Use the returned revision
|
|
315
|
-
* for replace/delete preconditions; the link's earlier metadata may already
|
|
316
|
-
* have been superseded when Forge begins serving the bytes.
|
|
317
|
-
*/
|
|
318
|
-
downloadWithRevision(vault: UnsealedVault, ingotId: string, options?: DownloadIngotOptions): Promise<IngotDownload>;
|
|
319
|
-
/**
|
|
320
|
-
* Get an ingot's sharing configuration.
|
|
321
|
-
*
|
|
322
|
-
* @example
|
|
323
|
-
* const sharing = await sv.ingots.getSharingConfig(unsealed, 'ing_abc');
|
|
324
|
-
*/
|
|
325
|
-
getSharingConfig(vault: UnsealedVault, ingotId: string): Promise<IngotSharingConfig>;
|
|
326
|
-
/**
|
|
327
|
-
* Update an ingot's sharing configuration.
|
|
328
|
-
*
|
|
329
|
-
* @example
|
|
330
|
-
* await sv.ingots.updateSharingConfig(unsealed, 'ing_abc', { shared: true });
|
|
331
|
-
*/
|
|
332
|
-
updateSharingConfig(vault: UnsealedVault, ingotId: string, config: UpdateIngotSharingOptions): Promise<IngotSharingConfig>;
|
|
333
|
-
/**
|
|
334
|
-
* Invite an identity to an ingot's invite-only share, or share an ingot not
|
|
335
|
-
* yet shared invite-only with it. A public or authenticated share refuses
|
|
336
|
-
* it (a ValidationError) and changes nothing: set its visibility to
|
|
337
|
-
* `invite_only` first. The identity type (email or phone) is inferred
|
|
338
|
-
* server-side from the identity value.
|
|
339
|
-
*
|
|
340
|
-
* @example
|
|
341
|
-
* await sv.ingots.addInvite(unsealed, 'ing_abc', 'user@example.com');
|
|
342
|
-
*/
|
|
343
|
-
addInvite(vault: UnsealedVault, ingotId: string, identity: string): Promise<IngotInvitation>;
|
|
344
|
-
/**
|
|
345
|
-
* Revoke an ingot sharing invite.
|
|
346
|
-
*
|
|
347
|
-
* @example
|
|
348
|
-
* await sv.ingots.revokeInvite(unsealed, 'ing_abc', 'inv_123');
|
|
349
|
-
*/
|
|
350
|
-
revokeInvite(vault: UnsealedVault, ingotId: string, inviteId: string): Promise<void>;
|
|
351
|
-
/**
|
|
352
|
-
* Batch content-HMAC existence check: the pre-upload dedup handshake.
|
|
353
|
-
* Returns which of the supplied vault-keyed HMACs already exist on active
|
|
354
|
-
* ingots in the vault, so callers can skip transferring those bytes.
|
|
355
|
-
*
|
|
356
|
-
* @example
|
|
357
|
-
* const { found } = await sv.ingots.checkContentHmacs(unsealed, [hmac1, hmac2]);
|
|
358
|
-
*/
|
|
359
|
-
checkContentHmacs(vault: UnsealedVault, hashes: string[]): Promise<HashCheckResponse>;
|
|
360
|
-
/**
|
|
361
|
-
* Get an ingot's access logs.
|
|
362
|
-
*
|
|
363
|
-
* @example
|
|
364
|
-
* const { logs } = await sv.ingots.getAccessLogs(unsealed, 'ing_abc');
|
|
365
|
-
*/
|
|
366
|
-
getAccessLogs(vault: UnsealedVault, ingotId: string, options?: AccessLogsOptions): Promise<IngotAccessLogPage>;
|
|
367
|
-
/**
|
|
368
|
-
* Request a Forge upload session for a new ingot.
|
|
369
|
-
* Shared by createUpload and upload: the single ingot-create path.
|
|
370
|
-
*/
|
|
371
|
-
private requestUploadSession;
|
|
372
|
-
/**
|
|
373
|
-
* Run the canonical TUS transfer for a created/replaced ingot.
|
|
374
|
-
*
|
|
375
|
-
* The transfer resolves only once the server has confirmed finalization, so
|
|
376
|
-
* the ingot this returns is always a published one, never a stored file
|
|
377
|
-
* whose ingot never went active.
|
|
378
|
-
*/
|
|
379
|
-
private transferAndFinalize;
|
|
380
|
-
private validateFile;
|
|
381
|
-
/** The client's transfer-host allowlist (`allowedDownloadHostPatterns`), as a download link is read against it. */
|
|
382
|
-
private readonly allowsTransferHost;
|
|
383
|
-
}
|
|
384
|
-
export { NAME_CONFLICT_POLICIES } from './types';
|
|
385
|
-
export { fetchDownload } from './fetch-download';
|
|
386
|
-
export { isReceivedUploadFailure } from '../vaults/upload/api';
|
|
387
|
-
export type { FetchDownloadOptions, FetchedDownload } from './fetch-download';
|
|
388
|
-
export type { NameConflictPolicy, UnsealedVault, Ingot, IngotUpload, UploadEnd, CreatedIngot, IngotDownloadLink, IngotDownload, IngotVersion, IngotHistory, IngotVersionDownloadLink, DeleteIngotOptions, DownloadIngotOptions, CreateUploadOptions, UploadIngotOptions, SendUploadOptions, ResumeUploadOptions, UploadSession, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, FolderContents, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvite, IngotInvitation, IngotAccessLog, IngotAccessLogPage, AccessLogsOptions, HashCheckResponse, } from './types';
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/** Validate an opaque server revision without interpreting it as a credential. */
|
|
2
|
-
export declare function expectedRevision(value: unknown): string | undefined;
|
|
3
|
-
/** Older servers omit the revision; never invent a precondition from metadata. */
|
|
4
|
-
export declare function readRevision(value: unknown): string | undefined;
|