@sparkvault/sdk-js 9.2.1 → 9.2.3
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/index.cjs +149 -168
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.mjs +149 -168
- package/dist/index.mjs.map +1 -1
- package/dist/ingots/index.d.ts +5 -2
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/dist/vaults/upload/api.d.ts +41 -41
- package/package.json +1 -1
|
@@ -48,33 +48,46 @@ export declare class UploadApi extends SparkVaultApi {
|
|
|
48
48
|
* offset rather than failing the whole transfer — see {@link CHUNK_MAX_ATTEMPTS}
|
|
49
49
|
* and {@link readResumeOffset}.
|
|
50
50
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
51
|
+
* Resolves only once the server has confirmed finalization
|
|
52
|
+
* ({@link confirmServerFinalized}), so a caller that gets a resolved promise
|
|
53
|
+
* is always looking at a published ingot.
|
|
53
54
|
*/
|
|
54
|
-
uploadFileToForge(file: File | Blob, forgeUrl: string, onProgress?: (bytesUploaded: number, bytesTotal: number) => void): Promise<
|
|
55
|
+
uploadFileToForge(file: File | Blob, forgeUrl: string, onProgress?: (bytesUploaded: number, bytesTotal: number) => void): Promise<void>;
|
|
55
56
|
/**
|
|
56
|
-
* Confirm the server finalized a fully received upload
|
|
57
|
+
* Confirm the server finalized a fully received upload — the one receipt
|
|
58
|
+
* every transfer ends on.
|
|
57
59
|
*
|
|
58
|
-
* The server persists the session's final offset BEFORE it finalizes, so
|
|
59
|
-
* offset
|
|
60
|
-
* failed or is still running
|
|
61
|
-
* a stored file whose ingot was never published.
|
|
62
|
-
* the final offset is the server's finalization
|
|
63
|
-
*
|
|
64
|
-
*
|
|
60
|
+
* The server persists the session's final offset BEFORE it finalizes, so a
|
|
61
|
+
* HEAD offset proves receipt and never publication: it can equal the file
|
|
62
|
+
* size while finalization failed or is still running, and reporting that as
|
|
63
|
+
* success would hand the user a stored file whose ingot was never published.
|
|
64
|
+
* The zero-length PATCH at the final offset is the server's finalization
|
|
65
|
+
* re-drive — it short-circuits to 204 on an already-finalized session, and
|
|
66
|
+
* on a received-but-unfinalized one it answers only after publication.
|
|
67
|
+
*
|
|
68
|
+
* A 409 means another writer is inside the finalizer right now; that is the
|
|
69
|
+
* outcome the budget exists for, so the retry waits it out rather than
|
|
70
|
+
* failing a transfer that is about to succeed. A 400 is the opposite — the
|
|
71
|
+
* server is behind the offset we claim — and fails immediately.
|
|
65
72
|
*/
|
|
66
73
|
private confirmServerFinalized;
|
|
67
74
|
/**
|
|
68
|
-
* Read the offset a failed chunk should resume from
|
|
75
|
+
* Read the offset a failed chunk should resume from — the one place a
|
|
76
|
+
* server-reported resume point is judged.
|
|
69
77
|
*
|
|
70
78
|
* Forge commits a chunk before it answers, so a PATCH that died in transit
|
|
71
79
|
* may have landed in full or not at all (never in part — the chunk object
|
|
72
80
|
* is written atomically before the offset advances); only the session's own
|
|
73
81
|
* persisted offset knows which, and the client's arithmetic is worthless
|
|
74
|
-
* here.
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
82
|
+
* here.
|
|
83
|
+
*
|
|
84
|
+
* Two contracts disqualify an answer. TUS sanity: an offset past the
|
|
85
|
+
* declared total would end the loop early and report a partial upload as
|
|
86
|
+
* complete, the same trap {@link patchChunk} guards against on a PATCH's own
|
|
87
|
+
* offset. Forge chunk granularity: a session advances only in whole
|
|
88
|
+
* committed chunks, so an offset that is neither chunk-aligned nor the file
|
|
89
|
+
* end is a corrupt session, and resuming from it would send a short
|
|
90
|
+
* non-final chunk Forge rejects anyway.
|
|
78
91
|
*/
|
|
79
92
|
private readResumeOffset;
|
|
80
93
|
/**
|
|
@@ -95,35 +108,22 @@ export declare class UploadApi extends SparkVaultApi {
|
|
|
95
108
|
*/
|
|
96
109
|
private patchChunk;
|
|
97
110
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* The TUS PATCH loop trusts a server-provided `Upload-Offset`; a buggy or
|
|
101
|
-
* malicious Forge could return an inflated offset before every chunk was
|
|
102
|
-
* actually committed and encrypted. This re-reads the server's own
|
|
103
|
-
* persisted offset via a TUS HEAD (which Forge only advances on a real S3
|
|
104
|
-
* commit) and requires it to reach the declared total — the web equivalent
|
|
105
|
-
* of the mobile SDK's `verifyIngotActive` (status === 'active') guarantee.
|
|
106
|
-
*
|
|
107
|
-
* Polls because the final chunk's commit and the offset write can lag the
|
|
108
|
-
* PATCH acknowledgement by a moment. Throws on a non-2xx HEAD, on a session
|
|
109
|
-
* that never reaches the expected offset within the poll budget, or on a
|
|
110
|
-
* cancelled session — never reports a half-finished upload as done.
|
|
111
|
+
* Read the server's persisted upload offset via a TUS HEAD request — the one
|
|
112
|
+
* place the client asks Forge where a session really stands.
|
|
111
113
|
*
|
|
112
|
-
* @param
|
|
113
|
-
* @param expectedOffset - The declared total upload size in bytes.
|
|
114
|
+
* @param check - Which caller this read serves; shapes the failure copy.
|
|
114
115
|
*/
|
|
115
|
-
|
|
116
|
+
private headUploadOffset;
|
|
116
117
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* mid-upload resume and end-of-upload confirmation.
|
|
118
|
+
* Issue one bodyless TUS request — the single transport behind every
|
|
119
|
+
* non-chunk call this client makes (resume HEAD, finalization PATCH).
|
|
120
120
|
*
|
|
121
|
-
* Uses raw `fetch` rather than the JSON envelope helper: TUS responses
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
121
|
+
* Uses raw `fetch` rather than the JSON envelope helper: TUS responses carry
|
|
122
|
+
* an empty body and surface state in headers. Honors the session abort
|
|
123
|
+
* signal and request timeout like every other client call, and resolves only
|
|
124
|
+
* on a 2xx so no caller has to re-check `response.ok`.
|
|
125
125
|
*
|
|
126
|
-
* @param check - Which caller this
|
|
126
|
+
* @param check - Which caller this request serves; shapes the failure copy.
|
|
127
127
|
*/
|
|
128
|
-
private
|
|
128
|
+
private tusRequest;
|
|
129
129
|
}
|