@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.d.ts CHANGED
@@ -2584,8 +2584,11 @@ declare class IngotsModule {
2584
2584
  */
2585
2585
  private requestUploadSession;
2586
2586
  /**
2587
- * Run the canonical TUS transfer for a created/replaced ingot, then confirm
2588
- * the server finalized the upload before reporting success.
2587
+ * Run the canonical TUS transfer for a created/replaced ingot.
2588
+ *
2589
+ * The transfer resolves only once the server has confirmed finalization, so
2590
+ * the ingot this returns is always a published one — never a stored file
2591
+ * whose ingot never went active.
2589
2592
  */
2590
2593
  private transferAndFinalize;
2591
2594
  private validateFile;
package/dist/index.mjs CHANGED
@@ -9959,17 +9959,25 @@ const CHUNK_INACTIVITY_TIMEOUT_MS = 60000;
9959
9959
  const CHUNK_MAX_ATTEMPTS = 3;
9960
9960
  const CHUNK_RETRY_BASE_MS = 500;
9961
9961
  /**
9962
- * Server-side finalization confirmation poll.
9962
+ * Retry budget for the finalization receipt.
9963
9963
  *
9964
- * After the last chunk is PATCHed, Forge advances the session offset (and
9965
- * flips the ingot to `active`) only once the chunk has actually committed to
9966
- * S3. We re-read the server's *own persisted* `Upload-Offset` via a TUS HEAD
9967
- * — independent of the offset the PATCH response claimed — and require it to
9968
- * reach the declared total before reporting success.
9964
+ * Forge answers the zero-length PATCH with a 409 while another writer is still
9965
+ * inside the finalizer, so the confirmation has to out-wait a finalization
9966
+ * already in flight rather than give up on it — a budget measured in seconds
9967
+ * rather than in the sub-second blips a chunk retry recovers from.
9969
9968
  */
9970
- const FINALIZE_POLL_MAX = 10;
9971
- const FINALIZE_POLL_MS = 1000;
9972
- /** Promise-wrapped delay, for retry backoff and finalization polling. */
9969
+ const FINALIZE_MAX_ATTEMPTS = 10;
9970
+ const FINALIZE_RETRY_MS = 1000;
9971
+ /**
9972
+ * How many consecutive timeouts end the confirmation early.
9973
+ *
9974
+ * A genuinely slow finalize shows up as ONE timeout — the PATCH that started
9975
+ * the re-drive — followed by 409s from the writer that is working on it.
9976
+ * Back-to-back timeouts mean nobody is answering at all, and spending the full
9977
+ * budget on a black-holed socket would freeze the widget at 100% for minutes
9978
+ * with nothing for the user to act on.
9979
+ */
9980
+ const FINALIZE_MAX_CONSECUTIVE_TIMEOUTS = 2;
9973
9981
  /**
9974
9982
  * A delay that a cancel cuts short: resolves after `ms`, rejects with the
9975
9983
  * canonical cancelled error the moment the signal aborts.
@@ -9992,22 +10000,25 @@ function abortableDelay(ms, signal) {
9992
10000
  signal.addEventListener('abort', onAbort, { once: true });
9993
10001
  });
9994
10002
  }
9995
- function delay(ms) {
9996
- return new Promise(resolve => setTimeout(resolve, ms));
9997
- }
9998
10003
  /**
9999
- * Whether a failed chunk PATCH is worth another attempt.
10004
+ * Whether a failed transfer request is worth another attempt. Every retrying
10005
+ * stage of an upload asks this one question:
10000
10006
  *
10001
- * A transport-level failure (status 0 — a dropped connection, or the
10002
- * inactivity watchdog aborting a silent socket) says nothing about whether the
10003
- * bytes reached Forge, 409 is Forge's documented "another writer holds the
10004
- * session lease; re-check the offset and retry", and a 5xx is a server-side
10005
- * blip. Every other outcome is the server's considered answer about this exact
10006
- * chunk — a rejected offset, a bad ISTK, a vanished session, or a 2xx carrying
10007
- * a protocol-violating offset — and re-sending would only earn it again. A
10008
- * cancelled session is the user's decision, never a failure to retry.
10009
- */
10010
- function isRetryableChunkFailure(error) {
10007
+ * - the chunk PATCH loop — may this chunk be re-sent?
10008
+ * - the resume-HEAD loop — may the session's offset be re-read?
10009
+ * - the finalization receipt — may publication be asked about again?
10010
+ *
10011
+ * A transport-level failure (status 0 — a dropped connection, a timeout, or
10012
+ * the inactivity watchdog aborting a silent socket) says nothing about whether
10013
+ * the request reached Forge, 409 is Forge's documented "another writer holds
10014
+ * the session lease; re-check and retry" (on the receipt: a finalizer is
10015
+ * running right now), and a 5xx is a server-side blip. Every other outcome is
10016
+ * the server's considered answer about this exact request — a rejected offset,
10017
+ * a bad ISTK, a vanished session, or a 2xx carrying a protocol-violating
10018
+ * offset — and re-sending would only earn it again. A cancelled session is the
10019
+ * user's decision, never a failure to retry.
10020
+ */
10021
+ function isRetryableTransferFailure(error) {
10011
10022
  if (!(error instanceof UploadApiError))
10012
10023
  return false;
10013
10024
  // Verdicts, not blips: a cancel is the user's decision, and an invalid or
@@ -10020,14 +10031,25 @@ function isRetryableChunkFailure(error) {
10020
10031
  const status = error.statusCode ?? 0;
10021
10032
  return status === 0 || status === 409 || status >= 500;
10022
10033
  }
10034
+ /**
10035
+ * A server's error body, reduced to something safe to carry on an error:
10036
+ * whitespace collapsed and length clipped, so an HTML error page or a stack
10037
+ * trace can never become the payload.
10038
+ */
10039
+ const ERROR_DETAIL_MAX_CHARS = 200;
10040
+ function summarizeErrorBody(body) {
10041
+ return body.replace(/\s+/g, ' ').trim().slice(0, ERROR_DETAIL_MAX_CHARS);
10042
+ }
10023
10043
  const RESUME_CHECK = {
10024
10044
  name: 'Upload resume check',
10025
10045
  code: 'resume_check_failed',
10046
+ serverFailureMessage: 'Upload could not be resumed: the server no longer recognizes this upload session.',
10026
10047
  networkMessage: 'Unable to resume upload. Please check your connection and try again.',
10027
10048
  };
10028
10049
  const FINALIZATION_CHECK = {
10029
10050
  name: 'Upload finalization check',
10030
10051
  code: 'finalization_check_failed',
10052
+ serverFailureMessage: 'Upload could not be confirmed: the server did not finalize the file.',
10031
10053
  networkMessage: 'Unable to confirm upload. Please check your connection and try again.',
10032
10054
  };
10033
10055
  class UploadApi extends SparkVaultApi {
@@ -10116,8 +10138,9 @@ class UploadApi extends SparkVaultApi {
10116
10138
  * offset rather than failing the whole transfer — see {@link CHUNK_MAX_ATTEMPTS}
10117
10139
  * and {@link readResumeOffset}.
10118
10140
  *
10119
- * Returns the TUS session URL so the caller can confirm server-side
10120
- * finalization via {@link verifyUploadFinalized} before reporting success.
10141
+ * Resolves only once the server has confirmed finalization
10142
+ * ({@link confirmServerFinalized}), so a caller that gets a resolved promise
10143
+ * is always looking at a published ingot.
10121
10144
  */
10122
10145
  async uploadFileToForge(file, forgeUrl, onProgress) {
10123
10146
  if (typeof XMLHttpRequest === 'undefined') {
@@ -10146,13 +10169,6 @@ class UploadApi extends SparkVaultApi {
10146
10169
  }
10147
10170
  }
10148
10171
  : undefined;
10149
- // A successful final-chunk PATCH is the server's finalization receipt:
10150
- // Forge finalizes (publishes the ingot, moves the counters) BEFORE it
10151
- // acknowledges that chunk with a 204. An offset learned from a resume
10152
- // HEAD carries no such receipt — the server persists the final offset
10153
- // before it finalizes — so a completion reached through the resume path
10154
- // must be confirmed explicitly after the loop.
10155
- let finalizeAcknowledged = false;
10156
10172
  while (offset < file.size) {
10157
10173
  if (this.isAborted()) {
10158
10174
  throw new UploadApiError('Upload cancelled', 'cancelled', 0);
@@ -10161,14 +10177,11 @@ class UploadApi extends SparkVaultApi {
10161
10177
  try {
10162
10178
  offset = await this.patchChunk(uploadUrl, file.slice(offset, chunkEnd), offset, file.size, monotonicProgress);
10163
10179
  failedAttempts = 0;
10164
- if (offset >= file.size) {
10165
- finalizeAcknowledged = true;
10166
- }
10167
10180
  continue;
10168
10181
  }
10169
10182
  catch (error) {
10170
10183
  failedAttempts += 1;
10171
- if (failedAttempts >= CHUNK_MAX_ATTEMPTS || !isRetryableChunkFailure(error)) {
10184
+ if (failedAttempts >= CHUNK_MAX_ATTEMPTS || !isRetryableTransferFailure(error)) {
10172
10185
  throw error;
10173
10186
  }
10174
10187
  }
@@ -10183,11 +10196,11 @@ class UploadApi extends SparkVaultApi {
10183
10196
  for (;;) {
10184
10197
  await abortableDelay(CHUNK_RETRY_BASE_MS * 2 ** (failedAttempts - 1), this.getAbortSignal());
10185
10198
  try {
10186
- serverOffset = await this.readResumeOffset(uploadUrl, file.size);
10199
+ serverOffset = await this.readResumeOffset(uploadUrl, file.size, session.chunkSize);
10187
10200
  break;
10188
10201
  }
10189
10202
  catch (headError) {
10190
- if (!isRetryableChunkFailure(headError)) {
10203
+ if (!isRetryableTransferFailure(headError)) {
10191
10204
  throw headError;
10192
10205
  }
10193
10206
  failedAttempts += 1;
@@ -10196,14 +10209,6 @@ class UploadApi extends SparkVaultApi {
10196
10209
  }
10197
10210
  }
10198
10211
  }
10199
- // Forge advances a session's offset only in whole committed chunks, so a
10200
- // legitimate resume point is always chunk-aligned (or the file end). A
10201
- // misaligned offset is a corrupt session, and resuming from it would
10202
- // send a short non-final chunk Forge rejects anyway — fail it as the
10203
- // protocol violation it is instead.
10204
- if (serverOffset % session.chunkSize !== 0 && serverOffset !== file.size) {
10205
- throw new UploadApiError(`Server returned misaligned upload offset (${serverOffset})`, 'invalid_offset', 0);
10206
- }
10207
10212
  if (serverOffset > offset) {
10208
10213
  // Bytes reached the server despite the failure, so the transfer is
10209
10214
  // alive: the budget is earned back rather than spent down across the
@@ -10212,86 +10217,85 @@ class UploadApi extends SparkVaultApi {
10212
10217
  }
10213
10218
  offset = serverOffset;
10214
10219
  }
10215
- if (!finalizeAcknowledged) {
10216
- await this.confirmServerFinalized(uploadUrl, file.size);
10217
- }
10218
- return uploadUrl;
10220
+ await this.confirmServerFinalized(uploadUrl, file.size);
10219
10221
  }
10220
10222
  /**
10221
- * Confirm the server finalized a fully received upload.
10223
+ * Confirm the server finalized a fully received upload — the one receipt
10224
+ * every transfer ends on.
10225
+ *
10226
+ * The server persists the session's final offset BEFORE it finalizes, so a
10227
+ * HEAD offset proves receipt and never publication: it can equal the file
10228
+ * size while finalization failed or is still running, and reporting that as
10229
+ * success would hand the user a stored file whose ingot was never published.
10230
+ * The zero-length PATCH at the final offset is the server's finalization
10231
+ * re-drive — it short-circuits to 204 on an already-finalized session, and
10232
+ * on a received-but-unfinalized one it answers only after publication.
10222
10233
  *
10223
- * The server persists the session's final offset BEFORE it finalizes, so an
10224
- * offset read from a resume HEAD can equal the file size while finalization
10225
- * failed or is still running — treating that offset as success would report
10226
- * a stored file whose ingot was never published. The zero-length PATCH at
10227
- * the final offset is the server's finalization re-drive: it answers 2xx
10228
- * only once finalization has actually completed, the same receipt a
10229
- * successful final chunk carries.
10234
+ * A 409 means another writer is inside the finalizer right now; that is the
10235
+ * outcome the budget exists for, so the retry waits it out rather than
10236
+ * failing a transfer that is about to succeed. A 400 is the opposite — the
10237
+ * server is behind the offset we claim — and fails immediately.
10230
10238
  */
10231
10239
  async confirmServerFinalized(uploadUrl, totalSize) {
10232
- let attempts = 0;
10233
- for (;;) {
10240
+ let consecutiveTimeouts = 0;
10241
+ for (let attempt = 1;; attempt++) {
10242
+ // An already-aborted session must not reach fetch: without
10243
+ // `AbortSignal.any` the combined signal only learns about a close that
10244
+ // arrives later, so the request would otherwise go out post-cancel.
10234
10245
  if (this.isAborted()) {
10235
10246
  throw new UploadApiError('Upload cancelled', 'cancelled', 0);
10236
10247
  }
10237
- const closeSignal = this.getAbortSignal();
10238
- const { signal, dispose } = combineTimeoutAndCloseSignals(this.timeoutMs, closeSignal);
10239
10248
  try {
10240
- let response;
10241
- try {
10242
- response = await fetch(uploadUrl, {
10243
- method: 'PATCH',
10244
- headers: {
10245
- 'Tus-Resumable': TUS_VERSION,
10246
- 'Upload-Offset': String(totalSize),
10247
- 'Content-Type': 'application/offset+octet-stream',
10248
- },
10249
- signal,
10250
- });
10251
- }
10252
- catch {
10253
- if (closeSignal.aborted) {
10254
- throw new UploadApiError('Upload cancelled', 'cancelled', 0);
10255
- }
10256
- throw new UploadApiError('Upload finalization check failed: network error', 'finalization_check_failed', 0);
10257
- }
10258
- if (response.ok) {
10259
- return;
10260
- }
10261
- throw new UploadApiError(`Upload finalization check failed: ${response.status}`, 'finalization_check_failed', response.status);
10249
+ await this.tusRequest(uploadUrl, {
10250
+ method: 'PATCH',
10251
+ headers: {
10252
+ 'Tus-Resumable': TUS_VERSION,
10253
+ 'Upload-Offset': String(totalSize),
10254
+ 'Content-Type': 'application/offset+octet-stream',
10255
+ },
10256
+ }, FINALIZATION_CHECK);
10257
+ return;
10262
10258
  }
10263
10259
  catch (error) {
10264
- if (!isRetryableChunkFailure(error)) {
10265
- throw error;
10266
- }
10267
- attempts += 1;
10268
- if (attempts >= CHUNK_MAX_ATTEMPTS) {
10260
+ const timedOut = error instanceof UploadApiError && error.code === 'timeout';
10261
+ // Any answer at all — a 409 above all — proves someone is on the other
10262
+ // end, so the timeout tally starts over.
10263
+ consecutiveTimeouts = timedOut ? consecutiveTimeouts + 1 : 0;
10264
+ if (attempt >= FINALIZE_MAX_ATTEMPTS ||
10265
+ consecutiveTimeouts >= FINALIZE_MAX_CONSECUTIVE_TIMEOUTS ||
10266
+ !isRetryableTransferFailure(error)) {
10269
10267
  throw error;
10270
10268
  }
10271
- await abortableDelay(CHUNK_RETRY_BASE_MS * 2 ** (attempts - 1), this.getAbortSignal());
10272
- }
10273
- finally {
10274
- dispose();
10269
+ await abortableDelay(FINALIZE_RETRY_MS, this.getAbortSignal());
10275
10270
  }
10276
10271
  }
10277
10272
  }
10278
10273
  /**
10279
- * Read the offset a failed chunk should resume from.
10274
+ * Read the offset a failed chunk should resume from — the one place a
10275
+ * server-reported resume point is judged.
10280
10276
  *
10281
10277
  * Forge commits a chunk before it answers, so a PATCH that died in transit
10282
10278
  * may have landed in full or not at all (never in part — the chunk object
10283
10279
  * is written atomically before the offset advances); only the session's own
10284
10280
  * persisted offset knows which, and the client's arithmetic is worthless
10285
- * here. An offset past the declared total is a protocol violation rather
10286
- * than a resume point: honoring it would end the loop early and report a
10287
- * partial upload as complete, the same trap {@link patchChunk} guards
10288
- * against on a PATCH's own offset.
10281
+ * here.
10282
+ *
10283
+ * Two contracts disqualify an answer. TUS sanity: an offset past the
10284
+ * declared total would end the loop early and report a partial upload as
10285
+ * complete, the same trap {@link patchChunk} guards against on a PATCH's own
10286
+ * offset. Forge chunk granularity: a session advances only in whole
10287
+ * committed chunks, so an offset that is neither chunk-aligned nor the file
10288
+ * end is a corrupt session, and resuming from it would send a short
10289
+ * non-final chunk Forge rejects anyway.
10289
10290
  */
10290
- async readResumeOffset(uploadUrl, totalSize) {
10291
+ async readResumeOffset(uploadUrl, totalSize, chunkSize) {
10291
10292
  const offset = await this.headUploadOffset(uploadUrl, RESUME_CHECK);
10292
10293
  if (offset > totalSize) {
10293
10294
  throw new UploadApiError(`Server returned invalid upload offset (${offset})`, 'invalid_offset', 0);
10294
10295
  }
10296
+ if (offset % chunkSize !== 0 && offset !== totalSize) {
10297
+ throw new UploadApiError(`Server returned misaligned upload offset (${offset})`, 'invalid_offset', 0);
10298
+ }
10295
10299
  return offset;
10296
10300
  }
10297
10301
  /**
@@ -10423,77 +10427,58 @@ class UploadApi extends SparkVaultApi {
10423
10427
  });
10424
10428
  }
10425
10429
  /**
10426
- * Confirm the upload was finalized SERVER-SIDE before reporting success.
10427
- *
10428
- * The TUS PATCH loop trusts a server-provided `Upload-Offset`; a buggy or
10429
- * malicious Forge could return an inflated offset before every chunk was
10430
- * actually committed and encrypted. This re-reads the server's own
10431
- * persisted offset via a TUS HEAD (which Forge only advances on a real S3
10432
- * commit) and requires it to reach the declared total — the web equivalent
10433
- * of the mobile SDK's `verifyIngotActive` (status === 'active') guarantee.
10434
- *
10435
- * Polls because the final chunk's commit and the offset write can lag the
10436
- * PATCH acknowledgement by a moment. Throws on a non-2xx HEAD, on a session
10437
- * that never reaches the expected offset within the poll budget, or on a
10438
- * cancelled session — never reports a half-finished upload as done.
10430
+ * Read the server's persisted upload offset via a TUS HEAD request — the one
10431
+ * place the client asks Forge where a session really stands.
10439
10432
  *
10440
- * @param uploadUrl - The TUS session URL (Forge `Location`, ISTK-bound).
10441
- * @param expectedOffset - The declared total upload size in bytes.
10433
+ * @param check - Which caller this read serves; shapes the failure copy.
10442
10434
  */
10443
- async verifyUploadFinalized(uploadUrl, expectedOffset) {
10444
- let lastOffset = null;
10445
- for (let attempt = 1; attempt <= FINALIZE_POLL_MAX; attempt++) {
10446
- if (this.isAborted()) {
10447
- throw new UploadApiError('Upload cancelled', 'cancelled', 0);
10448
- }
10449
- const offset = await this.headUploadOffset(uploadUrl, FINALIZATION_CHECK);
10450
- lastOffset = offset;
10451
- if (offset >= expectedOffset) {
10452
- return;
10453
- }
10454
- if (attempt < FINALIZE_POLL_MAX) {
10455
- await delay(FINALIZE_POLL_MS);
10456
- }
10435
+ async headUploadOffset(uploadUrl, check) {
10436
+ const response = await this.tusRequest(uploadUrl, { method: 'HEAD', headers: { 'Tus-Resumable': TUS_VERSION } }, check);
10437
+ const header = response.headers.get('Upload-Offset');
10438
+ const offset = header !== null ? parseInt(header, 10) : NaN;
10439
+ if (!Number.isFinite(offset) || offset < 0) {
10440
+ throw new UploadApiError(`${check.name} returned an invalid offset`, check.code, response.status);
10457
10441
  }
10458
- throw new UploadApiError('Upload could not be confirmed: the server never finalized the file. ' +
10459
- `Confirmed ${lastOffset ?? 0} of ${expectedOffset} bytes.`, 'finalization_unconfirmed', 0, { confirmedBytes: lastOffset ?? 0, expectedBytes: expectedOffset });
10442
+ return offset;
10460
10443
  }
10461
10444
  /**
10462
- * Read the server's persisted upload offset via a TUS HEAD request — the one
10463
- * place the client asks Forge where a session really stands, for both
10464
- * mid-upload resume and end-of-upload confirmation.
10445
+ * Issue one bodyless TUS request — the single transport behind every
10446
+ * non-chunk call this client makes (resume HEAD, finalization PATCH).
10465
10447
  *
10466
- * Uses raw `fetch` rather than the JSON envelope helper: TUS responses
10467
- * carry an empty body and surface state in the `Upload-Offset` header.
10468
- * Honors the session abort signal and request timeout like every other
10469
- * client call.
10448
+ * Uses raw `fetch` rather than the JSON envelope helper: TUS responses carry
10449
+ * an empty body and surface state in headers. Honors the session abort
10450
+ * signal and request timeout like every other client call, and resolves only
10451
+ * on a 2xx so no caller has to re-check `response.ok`.
10470
10452
  *
10471
- * @param check - Which caller this read serves; shapes the failure copy.
10453
+ * @param check - Which caller this request serves; shapes the failure copy.
10472
10454
  */
10473
- async headUploadOffset(uploadUrl, check) {
10455
+ async tusRequest(uploadUrl, init, check) {
10456
+ // Capture the session's close signal now, not in the catch: resetSession()
10457
+ // can swap the controller while this request is in flight, and reading the
10458
+ // live one would misreport a genuine cancel as a timeout.
10474
10459
  const closeSignal = this.getAbortSignal();
10475
- const { signal: combinedSignal, dispose } = combineTimeoutAndCloseSignals(this.timeoutMs, closeSignal);
10460
+ const { signal, dispose } = combineTimeoutAndCloseSignals(this.timeoutMs, closeSignal);
10476
10461
  try {
10477
10462
  const response = await fetch(uploadUrl, {
10478
- method: 'HEAD',
10479
- headers: { 'Tus-Resumable': TUS_VERSION },
10480
- signal: combinedSignal,
10463
+ method: init.method,
10464
+ headers: init.headers,
10465
+ signal,
10481
10466
  });
10482
10467
  if (!response.ok) {
10483
- throw new UploadApiError(`${check.name} failed: ${response.status}`, check.code, response.status);
10468
+ // Read the body even though the message does not need it: an unread
10469
+ // body pins its connection, and a retried receipt would strand one per
10470
+ // attempt. What it says is the only server-side detail this client
10471
+ // ever sees, so it rides along in `details` for support.
10472
+ const detail = summarizeErrorBody(await response.text().catch(() => ''));
10473
+ throw new UploadApiError(check.serverFailureMessage, check.code, response.status, { status: response.status, ...(detail ? { serverDetail: detail } : {}) });
10484
10474
  }
10485
- const header = response.headers.get('Upload-Offset');
10486
- const offset = header !== null ? parseInt(header, 10) : NaN;
10487
- if (!Number.isFinite(offset) || offset < 0) {
10488
- throw new UploadApiError(`${check.name} returned an invalid offset`, check.code, response.status);
10489
- }
10490
- return offset;
10475
+ return response;
10491
10476
  }
10492
10477
  catch (error) {
10493
10478
  if (error instanceof SparkVaultError)
10494
10479
  throw error;
10495
10480
  if (error != null && typeof error === 'object' && 'name' in error && error.name === 'AbortError') {
10496
- if (this.isAborted()) {
10481
+ if (closeSignal.aborted) {
10497
10482
  throw new UploadApiError('Upload cancelled', 'cancelled', 0);
10498
10483
  }
10499
10484
  throw new UploadApiError(`${check.name} timed out after ${this.timeoutMs}ms`, 'timeout', 0);
@@ -12887,8 +12872,10 @@ class UploadRenderer {
12887
12872
  progress: 0,
12888
12873
  bytesUploaded: 0,
12889
12874
  });
12890
- // Upload file over the canonical TUS transfer path
12891
- const uploadUrl = await this.api.uploadFileToForge(file, forgeUrl, (bytesUploaded, bytesTotal) => {
12875
+ // Upload file over the canonical TUS transfer path. It resolves only
12876
+ // once the server has confirmed finalization, so a non-finalized upload
12877
+ // throws here and never reaches the success ceremony.
12878
+ await this.api.uploadFileToForge(file, forgeUrl, (bytesUploaded, bytesTotal) => {
12892
12879
  const progress = Math.round((bytesUploaded / bytesTotal) * 100);
12893
12880
  this.setState({
12894
12881
  view: 'uploading',
@@ -12905,12 +12892,6 @@ class UploadRenderer {
12905
12892
  phase: 'uploading',
12906
12893
  });
12907
12894
  });
12908
- // Confirm the server actually finalized the upload before celebrating.
12909
- // The TUS loop trusts a server-provided offset; this re-reads the
12910
- // server's own persisted offset and requires it to reach the file size,
12911
- // mirroring the mobile SDK's active-status check. A non-finalized
12912
- // upload throws here and never reaches the success ceremony.
12913
- await this.api.verifyUploadFinalized(uploadUrl, file.size);
12914
12895
  // Run ceremony animation
12915
12896
  await this.runCeremony(file, ingotId, requestId);
12916
12897
  // Complete
@@ -14012,15 +13993,14 @@ class IngotsModule {
14012
13993
  return response.data;
14013
13994
  }
14014
13995
  /**
14015
- * Run the canonical TUS transfer for a created/replaced ingot, then confirm
14016
- * the server finalized the upload before reporting success.
13996
+ * Run the canonical TUS transfer for a created/replaced ingot.
13997
+ *
13998
+ * The transfer resolves only once the server has confirmed finalization, so
13999
+ * the ingot this returns is always a published one — never a stored file
14000
+ * whose ingot never went active.
14017
14001
  */
14018
14002
  async transferAndFinalize(created, file, onProgress) {
14019
- const uploadUrl = await this.uploadApi.uploadFileToForge(file, created.forge_url, onProgress);
14020
- // Confirm the server actually finalized the upload before reporting
14021
- // success — the TUS loop's offsets alone don't prove the final chunk
14022
- // committed and the ingot went active.
14023
- await this.uploadApi.verifyUploadFinalized(uploadUrl, file.size);
14003
+ await this.uploadApi.uploadFileToForge(file, created.forge_url, onProgress);
14024
14004
  return {
14025
14005
  id: created.ingot_id,
14026
14006
  name: created.name,
@@ -14182,7 +14162,8 @@ async function fetchBlobWithLivenessBounds(url) {
14182
14162
  throw error;
14183
14163
  }
14184
14164
  const contentType = response.headers.get('content-type') ?? '';
14185
- // Where the environment exposes no readable body, the transfer keeps
14165
+ // Safari 10.1-14.4 ships fetch without `Response.body`, and the SDK's
14166
+ // support floor reaches back into that range. There the transfer keeps
14186
14167
  // whole-transfer wall-clock semantics: blob() surfaces no chunk arrivals, so
14187
14168
  // there is no liveness to observe.
14188
14169
  if (!response.body) {
@@ -15076,7 +15057,7 @@ class SparkVault {
15076
15057
  }
15077
15058
  /** Get the SDK version */
15078
15059
  static get version() {
15079
- return '9.2.1';
15060
+ return '9.2.3';
15080
15061
  }
15081
15062
  }
15082
15063
  if (typeof window !== 'undefined') {