@sparkvault/sdk-js 11.2.4 → 11.2.6

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.d.ts CHANGED
@@ -2699,10 +2699,13 @@ declare class IngotsModule {
2699
2699
  * no longer holds (it expired, was cancelled, or its ingot was removed)
2700
2700
  * rejects with code `session_gone`, and only a new upload session — a new
2701
2701
  * {@link createUpload}, or {@link upload} again — can store the file. An
2702
- * upload the server refused for good (the account's storage pool cannot
2703
- * take it, or a later upload replaced it) rejects with code
2704
- * `upload_refused`, its message the server's own sentence and its code in
2705
- * `details.coreCode`: a new upload is no remedy. A publication the server
2702
+ * upload the server refused (the account's storage pool cannot take it, a
2703
+ * later upload replaced it, or its vault is scheduled for deletion: a 409
2704
+ * `VAULT_DELETION_SCHEDULED`, whose session the server keeps until the
2705
+ * deletion runs or is cancelled, or the session lapses on its own) rejects
2706
+ * at once with code `upload_refused`, its message the server's own sentence
2707
+ * and its code in `details.coreCode`: a new upload is no remedy. A
2708
+ * publication the server
2706
2709
  * still defers at the transfer's idle limit rejects with code
2707
2710
  * `upload_received_publishing`: every byte is received, and the server
2708
2711
  * finishes the publication on its own, so never upload the file again; a
@@ -2732,8 +2735,11 @@ declare class IngotsModule {
2732
2735
  *
2733
2736
  * It rejects as {@link sendUpload} does: `session_gone` once the server no
2734
2737
  * longer holds the session (it expired, was cancelled, or ended when the
2735
- * server refused to publish it), `upload_refused` for an upload refused for
2736
- * good, `upload_received_publishing` again for a publication the server
2738
+ * server refused to publish it), `upload_refused` for an upload the server
2739
+ * refused (its storage pool, a later upload, or its vault scheduled for
2740
+ * deletion, a 409 `VAULT_DELETION_SCHEDULED` that keeps the session, so a
2741
+ * resume once the deletion is cancelled goes on while the session stands),
2742
+ * `upload_received_publishing` again for a publication the server
2737
2743
  * still defers at the transfer's idle limit, which leaves the session to
2738
2744
  * resume again later. A session URL that is not an upload session on an
2739
2745
  * allowed transfer host is refused (`invalid_forge_url`), and one whose
@@ -2765,9 +2771,10 @@ declare class IngotsModule {
2765
2771
  *
2766
2772
  * Creates the upload session, streams the file to Forge over TUS, then
2767
2773
  * confirms the server finalized the upload before resolving. A file the
2768
- * server refused for good — another upload of it superseded this one, at
2769
- * its create or while it streamed, or the storage pool cannot take it —
2770
- * rejects with code `upload_refused`, as {@link sendUpload} does.
2774
+ * server refused — another upload of it superseded this one, at its create
2775
+ * or while it streamed, the storage pool cannot take it, or its vault is
2776
+ * scheduled for deletion (a 409 `VAULT_DELETION_SCHEDULED`) — rejects with
2777
+ * code `upload_refused`, as {@link sendUpload} does.
2771
2778
  *
2772
2779
  * @example
2773
2780
  * const ingot = await sv.ingots.upload(unsealed, {
package/dist/index.mjs CHANGED
@@ -29,7 +29,9 @@ function isTransientHttpStatus(status) {
29
29
  * The upload publication contract between Forge and Core's activation, and
30
30
  * the facts of a transfer token both services spell: its shape, the
31
31
  * publication it is bound to (a content version, and the one an ingot row
32
- * names), and Core's revocation of an upload's token.
32
+ * names), Core's revocation of an upload's token, and the refusals of Core's
33
+ * a transfer's answer names (the header, and the lock of a vault scheduled
34
+ * for deletion).
33
35
  *
34
36
  * Forge stamps UPLOAD_PUBLICATION_PROTOCOL on every upload session it creates
35
37
  * and on the final state it hands Core's activation (POST
@@ -110,10 +112,37 @@ const UPLOAD_TOKEN_REVOCATION = Object.freeze({
110
112
  Object.values(UPLOAD_TOKEN_REVOCATION.reasons);
111
113
 
112
114
  /**
113
- * The response header that names the code Core refused an upload with for
114
- * good: Forge sends it on every terminal answer to a tus request, a HEAD's
115
- * (which has no body) included, so a client tells an upload the owner's pool
116
- * cannot take from one a later upload superseded without reading a body.
115
+ * The code Core refuses every use of a vault's content with (409) while the
116
+ * vault is scheduled for deletion, until a company admin cancels the
117
+ * deletion or it runs and the vault is gone: a transfer token's use, each
118
+ * request of a transfer (Forge asks Core before every one and relays the
119
+ * refusal naming this code), and an upload's activation, which Forge defers.
120
+ * The lock refuses an upload's requests and never ends its session, so a
121
+ * client keeps the session and reports the lock. The session still lapses
122
+ * on its own idle window (upload-expiry.js), which is shorter than the
123
+ * deletion's delay: an upload resumed after a cancelled deletion goes on from
124
+ * its offset while the session stands, and starts over once it has lapsed.
125
+ */
126
+ const VAULT_DELETION_SCHEDULED = 'VAULT_DELETION_SCHEDULED';
127
+
128
+ /**
129
+ * The words a vault scheduled for deletion refuses every use of its content
130
+ * in (VAULT_DELETION_SCHEDULED), whichever service or client meets it:
131
+ * Core's refusal, and a client's report of it from an answer with no body
132
+ * to carry Core's (a HEAD's, naming the code in UPLOAD_REFUSAL_HEADER alone).
133
+ */
134
+ const VAULT_DELETION_SCHEDULED_MESSAGE =
135
+ 'This vault is scheduled for deletion. Cancel its deletion in vault settings before accessing its contents.';
136
+
137
+ /**
138
+ * The response header that names the code of a refusal Core decided: Forge
139
+ * sends it on every terminal answer to a tus request (a 404, 410 or 412) and
140
+ * on every answer relaying Core's decision about a transfer's vault (the 409
141
+ * VAULT_DELETION_SCHEDULED, a 404 naming the vault), a download's and a
142
+ * HEAD's (which has no body) included, so a
143
+ * client tells an upload the owner's pool cannot take from one a later
144
+ * upload superseded, and Core's lock from another request holding the
145
+ * session's lease, without reading a body.
117
146
  */
118
147
  const UPLOAD_REFUSAL_HEADER = 'X-Upload-Refusal';
119
148
 
@@ -138,20 +167,29 @@ const UPLOAD_REFUSAL_HEADER = 'X-Upload-Refusal';
138
167
  * both bounds start over whenever the server confirms progress.
139
168
  *
140
169
  * Forge's own answers beyond the general rule:
141
- * - the 409, in two kinds: one carrying `Upload-Offset` names where the
142
- * session stands (continue from there), and one without it means another
143
- * request holds the session's write lease, a chunk or the finalization
144
- * (retry after its `Retry-After`);
145
- * - a terminal answer (a 404, 410 or 412) names the code Core ended the
146
- * upload with: its error envelope in `error.details.coreCode` for the
147
- * refusals it words itself, and every one of them in `X-Upload-Refusal`,
148
- * which is all a HEAD's answer, having no body, can carry; the body's code
149
- * wins when both name one. The code decides the verdict: a full storage
150
- * pool or a later upload that replaced this one is a refusal no new upload
151
- * of the same file remedies, and any other code (the file the upload was
152
- * for gone, a retired contract, a replacement base that moved on, a code
153
- * this policy does not know) ends the session, which a new upload can
154
- * start over;
170
+ * - an answer naming a refusal Core decided names Core's code: a terminal
171
+ * answer (a 404, 410 or 412) the code Core ended the upload with, and a 409
172
+ * relaying Core's refusal of the transfer the code Core refused it with.
173
+ * Its error envelope names it in `error.details.coreCode` (for the refusals
174
+ * Forge words itself and the ones it relays from Core's check of a
175
+ * transfer), and every one of them in `X-Upload-Refusal`, which is all a
176
+ * HEAD's answer, having no body, can carry; the body's code wins when both
177
+ * name one;
178
+ * - the 409, in three kinds: one carrying `Upload-Offset` names where the
179
+ * session stands (continue from there); one naming Core's code is Core's
180
+ * refusal of the transfer in its vault's current state, a vault scheduled
181
+ * for deletion (VAULT_DELETION_SCHEDULED), which keeps the session (until
182
+ * it lapses on its 72 h idle window, upload-expiry.js) and which neither
183
+ * the same request nor a new upload gets past until a person cancels the
184
+ * deletion, so it is reported, never retried; and one naming
185
+ * neither means another request holds the session's write lease, a chunk
186
+ * or the finalization (retry after its `Retry-After`);
187
+ * - a terminal answer's code decides its verdict: a full storage pool or a
188
+ * later upload that replaced this one is a refusal no new upload of the
189
+ * same file remedies, and any other code (the file the upload was for
190
+ * gone, a retired contract, a replacement base that moved on, a code this
191
+ * policy does not know) ends the session, which a new upload can start
192
+ * over;
155
193
  * - a 503 carrying `Retry-After` to the receipt (the PATCH at the final
156
194
  * offset) is a deferral: Forge holds every byte and is still publishing,
157
195
  * and finishes without the client, so it is asked again, each time after a
@@ -178,10 +216,10 @@ const TRANSFER_VERDICT = Object.freeze({
178
216
  /** 2xx: the request did what it asked. */
179
217
  OK: 'ok',
180
218
  /**
181
- * No answer (a reset, a timeout), 408, 425, 429, a 5xx, or a 409 without
182
- * `Upload-Offset` (another request holds the session's lease): back off,
183
- * never sooner than `Retry-After`, then ask the server's offset before
184
- * sending a chunk again.
219
+ * No answer (a reset, a timeout), 408, 425, 429, a 5xx, or a 409 naming
220
+ * neither an `Upload-Offset` nor a code of Core's (another request holds
221
+ * the session's lease): back off, never sooner than `Retry-After`, then ask
222
+ * the server's offset before sending a chunk again.
185
223
  */
186
224
  RETRY: 'retry',
187
225
  /** 409 with `Upload-Offset`: the session stands elsewhere; continue from that offset at once. */
@@ -200,10 +238,11 @@ const TRANSFER_VERDICT = Object.freeze({
200
238
  */
201
239
  GONE: 'gone',
202
240
  /**
203
- * Any other status, or a 404, 410 or 412 naming a final refusal of Core's
204
- * (`coreCode`: UPLOAD_POOL_FULL, UPLOAD_SUPERSEDED): the server's verdict on
205
- * this request, which repeating it, or a new upload of the same file,
206
- * earns again.
241
+ * Any other status, a 404, 410 or 412 naming a final refusal of Core's
242
+ * (`coreCode`: UPLOAD_POOL_FULL, UPLOAD_SUPERSEDED), or a 409 naming any
243
+ * code of Core's (`coreCode`: VAULT_DELETION_SCHEDULED, whose session
244
+ * stands): the server's verdict on this request, which repeating it, or a
245
+ * new upload of the same file, earns again.
207
246
  */
208
247
  REFUSED: 'refused'
209
248
  });
@@ -223,6 +262,12 @@ const SERVICE_UNAVAILABLE = 503;
223
262
  */
224
263
  const TERMINAL_STATUSES = new Set([404, 410, 412]);
225
264
 
265
+ /**
266
+ * Forge's 409: about where the session stands (`Upload-Offset`), another
267
+ * request's lease on it, or Core's refusal of the transfer, relayed.
268
+ */
269
+ const CONFLICT = 409;
270
+
226
271
  /** Core's error codes are upper-case words joined by underscores; anything else names no code. */
227
272
  const CORE_CODE = /^[A-Z][A-Z0-9_]{0,63}$/;
228
273
 
@@ -263,12 +308,14 @@ const DEFAULT_MAX_CONSECUTIVE_FAILURES = 8;
263
308
  * @property {number|null} retryAfterMs - The answer's `Retry-After`, in ms from
264
309
  * the answer (an HTTP-date already past reads as 0); null when absent or unreadable
265
310
  * @property {number|null} offset - The answer's `Upload-Offset`; null when absent or unreadable
266
- * @property {string|null} coreCode - The code Core ended the upload with, as a
267
- * terminal answer named it (a 404, 410 or 412: its body's details or, those
268
- * naming none, its `X-Upload-Refusal`): REFUSED for a final refusal
269
- * (`UPLOAD_POOL_FULL`, `UPLOAD_SUPERSEDED`), GONE for any other code
270
- * (`NOT_FOUND`, `UPLOAD_PROTOCOL_RETIRED`, a 412's, one this policy does not
271
- * know); null when the answer names none
311
+ * @property {string|null} coreCode - The code of the refusal Core decided, as
312
+ * the answer named it (a 404, 410 or 412, or a 409 naming no offset: its
313
+ * body's details or, those naming none, its `X-Upload-Refusal`): REFUSED for
314
+ * any code a 409 names (`VAULT_DELETION_SCHEDULED`) and for a terminal
315
+ * answer's final refusal (`UPLOAD_POOL_FULL`, `UPLOAD_SUPERSEDED`), GONE for
316
+ * any other code a terminal answer names (`NOT_FOUND`,
317
+ * `UPLOAD_PROTOCOL_RETIRED`, a 412's, one this policy does not know); null
318
+ * when the answer names none
272
319
  */
273
320
 
274
321
  /**
@@ -307,7 +354,7 @@ function classifyTransferResponse({ status, headers = null, details = null, rece
307
354
  }
308
355
  const header = (name) => (headers === null ? null : headers(name));
309
356
  const offset = readCount(header(UPLOAD_OFFSET_HEADER));
310
- const coreCode = TERMINAL_STATUSES.has(status)
357
+ const coreCode = mayNameCoreCode(status, offset)
311
358
  ? coreCodeIn(details) ?? coreCodeOf(header(UPLOAD_REFUSAL_HEADER))
312
359
  : null;
313
360
  const retryAfterMs = readRetryAfterMs(header(RETRY_AFTER_HEADER), now);
@@ -319,14 +366,28 @@ function classifyTransferResponse({ status, headers = null, details = null, rece
319
366
  };
320
367
  }
321
368
 
369
+ /**
370
+ * Whether an answer may name the code of a refusal Core decided: a terminal
371
+ * answer does, and so does a 409 naming no offset. A 409 carrying
372
+ * `Upload-Offset` is Forge's own, about where the session stands.
373
+ */
374
+ function mayNameCoreCode(status, offset) {
375
+ return TERMINAL_STATUSES.has(status) || (status === CONFLICT && offset === null);
376
+ }
377
+
322
378
  /**
323
379
  * The verdict on a status that came with an answer: `offset` its readable
324
- * `Upload-Offset`, `coreCode` the code of Core's a terminal answer names,
380
+ * `Upload-Offset`, `coreCode` the code of Core's the answer names,
325
381
  * `deferral` whether it answered the receipt with a readable `Retry-After`.
326
382
  */
327
383
  function verdictFor(status, { offset, coreCode, deferral }) {
328
384
  if (status >= 200 && status < 300) return TRANSFER_VERDICT.OK;
329
- if (status === 409) return offset === null ? TRANSFER_VERDICT.RETRY : TRANSFER_VERDICT.RESYNC;
385
+ if (status === CONFLICT) {
386
+ if (offset !== null) return TRANSFER_VERDICT.RESYNC;
387
+ // Core's 409 refuses the transfer in its vault's current state: the
388
+ // session stands, and the same request or a new upload earns it again.
389
+ return coreCode === null ? TRANSFER_VERDICT.RETRY : TRANSFER_VERDICT.REFUSED;
390
+ }
330
391
  if (coreCode !== null) return UPLOAD_FINAL_REFUSAL_CODES.includes(coreCode) ? TRANSFER_VERDICT.REFUSED : TRANSFER_VERDICT.GONE;
331
392
  if (status === 404 || status === 410) return TRANSFER_VERDICT.GONE;
332
393
  if (deferral && status === SERVICE_UNAVAILABLE) return TRANSFER_VERDICT.DEFERRED;
@@ -11751,22 +11812,25 @@ const SESSION_GONE_MESSAGE = 'Upload could not be finished: the server has ended
11751
11812
  */
11752
11813
  const RECEIVED_PUBLISHING_MESSAGE = 'The server received every byte of this file and is still saving it. It finishes on its own.';
11753
11814
  /**
11754
- * The copy a person reads for a final refusal whose answer carried no
11755
- * sentence of Core's (a HEAD's, which has no body, naming Core's code in
11756
- * `X-Upload-Refusal` alone): this SDK's own words for each code, none of them
11815
+ * The copy a person reads for a refusal whose answer carried no sentence of
11816
+ * Core's (a HEAD's, which has no body, naming Core's code in
11817
+ * `X-Upload-Refusal` alone): this SDK's own words for each final refusal,
11818
+ * and Core's own for its lock of a vault scheduled for deletion, none of them
11757
11819
  * asking for the file again.
11758
11820
  */
11759
11821
  const REFUSAL_WORDING = new Map([
11760
11822
  [UPLOAD_REFUSAL_CODES.UPLOAD_POOL_FULL, 'This upload could not be saved: the owner\'s storage cannot take the file.'],
11761
11823
  [UPLOAD_REFUSAL_CODES.UPLOAD_SUPERSEDED, 'This upload was not saved: a newer upload of this file replaced it.'],
11824
+ [VAULT_DELETION_SCHEDULED, VAULT_DELETION_SCHEDULED_MESSAGE],
11762
11825
  ]);
11763
11826
  /** The copy for a final refusal of a code this SDK has no words of its own for. */
11764
11827
  const REFUSED_MESSAGE = 'This upload could not be saved: the server refused it.';
11765
11828
  /**
11766
- * The error of an upload Core refused for good (UPLOAD_FINAL_REFUSAL_CODES):
11767
- * `upload_refused` in Core's own sentence, this SDK's for an answer that
11768
- * carried none (a HEAD's), Core's code in `details.coreCode`; never retried,
11769
- * and no new upload of the same file remedies it. The one reading of that
11829
+ * The error of an upload Core refused (UPLOAD_FINAL_REFUSAL_CODES, or the 409
11830
+ * of a vault scheduled for deletion, VAULT_DELETION_SCHEDULED, whose session
11831
+ * stands): `upload_refused` in Core's own sentence, this SDK's for an answer
11832
+ * that carried none (a HEAD's), Core's code in `details.coreCode`; never
11833
+ * retried, and no new upload of the same file remedies it. The one reading of that
11770
11834
  * verdict, whichever answer carries it: a transfer answer naming Core's code
11771
11835
  * ({@link readTransferAnswer}), or Core's own refusal of the request that
11772
11836
  * stages the upload ({@link stagingRefusal}).
@@ -12143,9 +12207,10 @@ class UploadApi extends SparkVaultApi {
12143
12207
  * otherwise a HEAD after the backoff ({@link offsetAfterFailure}); a session
12144
12208
  * the server no longer holds throws `session_gone`, which only a new upload
12145
12209
  * recovers from (any code of Core's the server named rides
12146
- * `details.coreCode`); an upload Core refused for good (a full storage pool,
12147
- * a later upload that replaced it) throws `upload_refused` in Core's words,
12148
- * which no new upload recovers from. While the browser is offline, the loop
12210
+ * `details.coreCode`); an upload Core refused (a full storage pool, a later
12211
+ * upload that replaced it, its vault scheduled for deletion, whose 409 names
12212
+ * Core's code) throws `upload_refused` in Core's words at once, which no new
12213
+ * upload recovers from. While the browser is offline, the loop
12149
12214
  * waits for the network instead of spending attempts.
12150
12215
  *
12151
12216
  * Resolves only once the server has confirmed finalization
@@ -12355,8 +12420,9 @@ class UploadApi extends SparkVaultApi {
12355
12420
  * the publication on its own. A 503 naming no `Retry-After` is no deferral
12356
12421
  * of Forge's, so it is polled as a failure. A 400 is the server's verdict
12357
12422
  * and fails immediately, as does the refusal Core decided
12358
- * (`upload_refused`); a 409 naming an earlier offset means bytes are
12359
- * missing, and the upload continues from there.
12423
+ * (`upload_refused`, a 409 naming Core's code among them); a 409 naming an
12424
+ * earlier offset means bytes are missing, and the upload continues from
12425
+ * there.
12360
12426
  */
12361
12427
  async confirmServerFinalized(transfer) {
12362
12428
  let consecutiveTimeouts = 0;
@@ -14101,6 +14167,12 @@ function formatBytes(bytes, decimals = 1) {
14101
14167
  * Orchestrates view state and rendering for vault upload flows.
14102
14168
  * Manages the complete upload lifecycle: form, uploading, ceremony, completion.
14103
14169
  */
14170
+ /**
14171
+ * What an outside uploader reads when the vault is scheduled for deletion:
14172
+ * the vault takes no files now. Core's own sentence, which tells the vault's
14173
+ * admin how to cancel the deletion, is the console's, never this page's.
14174
+ */
14175
+ const VAULT_NOT_ACCEPTING_MESSAGE = 'This vault isn\'t accepting files right now, so your file was not saved. Please contact the person who shared this upload page with you.';
14104
14176
  /**
14105
14177
  * Ceremony steps for the cryptographic visualization.
14106
14178
  */
@@ -14886,10 +14958,23 @@ class UploadRenderer {
14886
14958
  statusCode: error.statusCode,
14887
14959
  });
14888
14960
  }
14961
+ else if (error.code === VAULT_DELETION_SCHEDULED || error.details?.coreCode === VAULT_DELETION_SCHEDULED) {
14962
+ // The vault is scheduled for deletion, refused at the upload's start
14963
+ // or while its bytes moved. Core's sentence tells the vault's admin
14964
+ // how to cancel the deletion; the person on this page is an outside
14965
+ // uploader, told only that the vault takes no files now.
14966
+ this.setState({
14967
+ view: 'error',
14968
+ title: 'Uploads Paused',
14969
+ message: VAULT_NOT_ACCEPTING_MESSAGE,
14970
+ code: error.code,
14971
+ statusCode: error.statusCode,
14972
+ });
14973
+ }
14889
14974
  else if (error.code === 'upload_refused') {
14890
- // Core refused the upload for good, in its own words (whom to contact
14891
- // about a full storage pool, or the later upload that replaced this
14892
- // one): a sentence that never asks for the file again.
14975
+ // Core refused the upload, in its own words (whom to contact about a
14976
+ // full storage pool, or the later upload that replaced this one): a
14977
+ // sentence that never asks for the file again.
14893
14978
  this.setState({
14894
14979
  view: 'error',
14895
14980
  title: 'Upload Not Saved',
@@ -15700,21 +15785,35 @@ async function attemptWith(source, state, options) {
15700
15785
  assertDownloadUrl(link, options.isAllowedHost);
15701
15786
  }
15702
15787
  catch (error) {
15703
- return { ok: false, error, outcome: mintOutcome(error) };
15788
+ if (!(error instanceof SparkVaultError) || typeof error.statusCode !== 'number') {
15789
+ return { ok: false, error, outcome: UNANSWERED };
15790
+ }
15791
+ const outcome = mintOutcome(error, error.statusCode);
15792
+ return { ok: false, error: outcome.coreCode === null ? error : namingCoreCode(error, outcome.coreCode), outcome };
15704
15793
  }
15705
15794
  return attemptDownload(link, state, options);
15706
15795
  }
15707
15796
  /**
15708
- * The transfer policy's reading of a failed mint. The HTTP client read the
15709
- * answer when it built the error: its status gives the verdict (a refused link
15710
- * is a 400, so final) and the `Retry-After` it named rides on the error
15797
+ * The transfer policy's reading of a mint Core refused. The HTTP client read
15798
+ * the answer when it built the error: its status gives the verdict (a refused
15799
+ * link is a 400, so final) and the `Retry-After` it named rides on the error
15711
15800
  * (`retryAfterMs`), so a mint Core defers waits out Core's floor exactly as a
15712
- * deferred Forge answer does. A failure with no status got no answer.
15801
+ * deferred Forge answer does. Core's lock of a vault scheduled for deletion
15802
+ * (409 VAULT_DELETION_SCHEDULED) is read by its code, as the policy reads
15803
+ * Forge's relay of it on the download itself: final at once. Any other 409
15804
+ * keeps its status's reading.
15805
+ */
15806
+ function mintOutcome(error, status) {
15807
+ const details = error.code === VAULT_DELETION_SCHEDULED ? { coreCode: error.code } : null;
15808
+ return { ...classifyTransferResponse({ status, details }), retryAfterMs: error.retryAfterMs };
15809
+ }
15810
+ /**
15811
+ * Core's refusal of a mint as its caller sees it: Core's sentence, code and
15812
+ * details, with the code in `details.coreCode`, where a refused download
15813
+ * names it too, so one reading tells the lock whichever answer met it.
15713
15814
  */
15714
- function mintOutcome(error) {
15715
- if (!(error instanceof SparkVaultError) || typeof error.statusCode !== 'number')
15716
- return UNANSWERED;
15717
- return { ...classifyTransferResponse({ status: error.statusCode }), retryAfterMs: error.retryAfterMs };
15815
+ function namingCoreCode(error, coreCode) {
15816
+ return new SparkVaultError(error.message, error.code, error.statusCode, { ...error.details, coreCode }, error.retryAfterMs);
15718
15817
  }
15719
15818
  /**
15720
15819
  * Fetch one link: the rest of the file held, conditioned on its validator,
@@ -15749,11 +15848,8 @@ async function attemptDownload(link, state, options) {
15749
15848
  ? { signal: controller.signal, headers: { Range: `bytes=${resume.at}-`, 'If-Range': resume.validator } }
15750
15849
  : { signal: controller.signal }), DOWNLOAD_TTFB_TIMEOUT_MS, controller, 'Download timed out waiting for response headers');
15751
15850
  if (!response.ok) {
15752
- return {
15753
- ok: false,
15754
- error: new SparkVaultError(`Download failed with status ${response.status}`, 'download_failed', response.status),
15755
- outcome: classifyTransferResponse({ status: response.status, headers: (name) => response.headers.get(name) }),
15756
- };
15851
+ const outcome = classifyTransferResponse({ status: response.status, headers: (name) => response.headers.get(name) });
15852
+ return { ok: false, error: await refusedDownloadError(response, outcome, controller), outcome };
15757
15853
  }
15758
15854
  if (resume && response.status === 206) {
15759
15855
  const continued = continuation(response, resume);
@@ -15809,6 +15905,24 @@ async function attemptDownload(link, state, options) {
15809
15905
  signal?.removeEventListener('abort', abortFromCaller);
15810
15906
  }
15811
15907
  }
15908
+ /**
15909
+ * The error a download answered with a failure throws once nothing retries
15910
+ * it. A refusal Core decided names Core's code (the 409 of a vault scheduled
15911
+ * for deletion, in X-Upload-Refusal), and is reported in Core's own sentence,
15912
+ * read from the answer's body under the idle deadline, with the code in
15913
+ * `details.coreCode`; any other failure by its status.
15914
+ */
15915
+ async function refusedDownloadError(response, outcome, controller) {
15916
+ const statusMessage = `Download failed with status ${response.status}`;
15917
+ const { coreCode } = outcome;
15918
+ if (outcome.verdict !== TRANSFER_VERDICT.REFUSED || coreCode === null) {
15919
+ return new SparkVaultError(statusMessage, 'download_failed', response.status);
15920
+ }
15921
+ const served = await withDeadline(readApiFailure(response), DOWNLOAD_IDLE_TIMEOUT_MS, controller, 'Download timed out reading the refusal');
15922
+ // Only a body naming the same code carries Core's sentence for it.
15923
+ const message = served.code === coreCode ? served.message : statusMessage;
15924
+ return new SparkVaultError(message, 'download_failed', response.status, { coreCode });
15925
+ }
15812
15926
  /**
15813
15927
  * The failure of a body that ended at a length other than the one its
15814
15928
  * response declared: what the caller sees once the transfer can no longer
@@ -16218,10 +16332,13 @@ class IngotsModule {
16218
16332
  * no longer holds (it expired, was cancelled, or its ingot was removed)
16219
16333
  * rejects with code `session_gone`, and only a new upload session — a new
16220
16334
  * {@link createUpload}, or {@link upload} again — can store the file. An
16221
- * upload the server refused for good (the account's storage pool cannot
16222
- * take it, or a later upload replaced it) rejects with code
16223
- * `upload_refused`, its message the server's own sentence and its code in
16224
- * `details.coreCode`: a new upload is no remedy. A publication the server
16335
+ * upload the server refused (the account's storage pool cannot take it, a
16336
+ * later upload replaced it, or its vault is scheduled for deletion: a 409
16337
+ * `VAULT_DELETION_SCHEDULED`, whose session the server keeps until the
16338
+ * deletion runs or is cancelled, or the session lapses on its own) rejects
16339
+ * at once with code `upload_refused`, its message the server's own sentence
16340
+ * and its code in `details.coreCode`: a new upload is no remedy. A
16341
+ * publication the server
16225
16342
  * still defers at the transfer's idle limit rejects with code
16226
16343
  * `upload_received_publishing`: every byte is received, and the server
16227
16344
  * finishes the publication on its own, so never upload the file again; a
@@ -16255,8 +16372,11 @@ class IngotsModule {
16255
16372
  *
16256
16373
  * It rejects as {@link sendUpload} does: `session_gone` once the server no
16257
16374
  * longer holds the session (it expired, was cancelled, or ended when the
16258
- * server refused to publish it), `upload_refused` for an upload refused for
16259
- * good, `upload_received_publishing` again for a publication the server
16375
+ * server refused to publish it), `upload_refused` for an upload the server
16376
+ * refused (its storage pool, a later upload, or its vault scheduled for
16377
+ * deletion, a 409 `VAULT_DELETION_SCHEDULED` that keeps the session, so a
16378
+ * resume once the deletion is cancelled goes on while the session stands),
16379
+ * `upload_received_publishing` again for a publication the server
16260
16380
  * still defers at the transfer's idle limit, which leaves the session to
16261
16381
  * resume again later. A session URL that is not an upload session on an
16262
16382
  * allowed transfer host is refused (`invalid_forge_url`), and one whose
@@ -16305,9 +16425,10 @@ class IngotsModule {
16305
16425
  *
16306
16426
  * Creates the upload session, streams the file to Forge over TUS, then
16307
16427
  * confirms the server finalized the upload before resolving. A file the
16308
- * server refused for good — another upload of it superseded this one, at
16309
- * its create or while it streamed, or the storage pool cannot take it —
16310
- * rejects with code `upload_refused`, as {@link sendUpload} does.
16428
+ * server refused — another upload of it superseded this one, at its create
16429
+ * or while it streamed, the storage pool cannot take it, or its vault is
16430
+ * scheduled for deletion (a 409 `VAULT_DELETION_SCHEDULED`) — rejects with
16431
+ * code `upload_refused`, as {@link sendUpload} does.
16311
16432
  *
16312
16433
  * @example
16313
16434
  * const ingot = await sv.ingots.upload(unsealed, {
@@ -17440,7 +17561,7 @@ class SparkVault {
17440
17561
  }
17441
17562
  /** Get the SDK version */
17442
17563
  static get version() {
17443
- return '11.2.4';
17564
+ return '11.2.6';
17444
17565
  }
17445
17566
  }
17446
17567
  if (typeof window !== 'undefined') {