@sparkvault/sdk-mobile 7.0.0 → 7.0.2

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.
@@ -0,0 +1,132 @@
1
+ /**
2
+ * The ledger reference of an upload's transfer charge,
3
+ * `forge_ingot_transfer_upload_<first 24 ISTK chars>`: every charge of one
4
+ * upload carries it — Core's activation, Core's charge of an upload that never
5
+ * publishes, Forge's cancel — so whichever lands first is the upload's one
6
+ * ledger row and the others are duplicates.
7
+ *
8
+ * @param {string} istk - The upload's ISTK, as its session carries it
9
+ * @returns {string}
10
+ * @throws {TypeError} When the ISTK is not a string of at least
11
+ * TRANSFER_REFERENCE_ISTK_CHARS characters
12
+ */
13
+ export function uploadTransferReference(istk: string): string;
14
+ /**
15
+ * Why Core revoked the upload token a forge-transactions record is
16
+ * (UPLOAD_TOKEN_REVOCATION's reasons), or null for any other record, or none:
17
+ * the one reading Core's mint and every Forge read of a token apply.
18
+ *
19
+ * @param {Object|null|undefined} record - A forge-transactions record, or none
20
+ * @returns {string|null}
21
+ */
22
+ export function uploadTokenRevocationReason(record: Object | null | undefined): string | null;
23
+ /**
24
+ * The upload publication contract between Forge and Core's activation, and
25
+ * the facts of a transfer token both services spell: its shape, and Core's
26
+ * revocation of an upload's token.
27
+ *
28
+ * Forge stamps UPLOAD_PUBLICATION_PROTOCOL on every upload session it creates
29
+ * and on the final state it hands Core's activation (POST
30
+ * /v1/vaults/:vault_id/ingots/:ingot_id/activate); activation refuses any
31
+ * other version. The two services deploy separately, so a change to what
32
+ * either side sends or expects moves this number: a session or a finalize
33
+ * from the other side's contract then fails closed ("restart the upload")
34
+ * instead of publishing under a contract the other side does not hold.
35
+ *
36
+ * Version 2: an upload's own metadata (content type, original file name,
37
+ * uploader, content HMAC) travels on its upload token and its session, and
38
+ * activation publishes it from the session; the final state Forge sends
39
+ * carries only the storage facts Forge owns.
40
+ *
41
+ * Isomorphic: no Node imports.
42
+ */
43
+ export const UPLOAD_PUBLICATION_PROTOCOL: 2;
44
+ /**
45
+ * An upload's id as both services spell it: `tus_` and the 32 lowercase hex
46
+ * digits of 16 random bytes. An encrypt token that names one (`upload_id`)
47
+ * was staged by Core under it, and Forge keys the upload's session, its chunk
48
+ * prefix and its VAK wrapping by it, so Core finds and settles the upload by
49
+ * the session's id.
50
+ */
51
+ export const UPLOAD_ID_PATTERN: RegExp;
52
+ /** The random bytes an ISTK, the bearer token of one Forge transfer, is spelled from. */
53
+ export const ISTK_BYTES: 32;
54
+ /**
55
+ * An ISTK as Core mints one: the unpadded base64url of its ISTK_BYTES random
56
+ * bytes, 43 characters. Forge reads a presented token as a forge-transactions
57
+ * key only in this shape: the table keys other records too (an upload's token
58
+ * pointer, `UPLOAD_TOKEN#{upload_id}`), which no request may read as a token.
59
+ */
60
+ export const ISTK_PATTERN: RegExp;
61
+ /**
62
+ * How much of an ISTK names a transfer's charge on the usage ledger: enough to
63
+ * be unique to the token, never the whole bearer credential.
64
+ */
65
+ export const TRANSFER_REFERENCE_ISTK_CHARS: 24;
66
+ /**
67
+ * The codes Core's activation refuses an upload with, which Forge's refusal
68
+ * map reads (the status is Core's):
69
+ * - UPLOAD_CONTRACT_MISMATCH (409): a finalize or session from another
70
+ * publication contract than Core's, a mixed deployment that converges — the
71
+ * upload is kept and its finalize tried again.
72
+ * - UPLOAD_PROTOCOL_RETIRED (410): a session from a contract Core no longer
73
+ * publishes, which never can be.
74
+ * - UPLOAD_SUPERSEDED (410): a session a later staging of its ingot
75
+ * superseded, which never can be.
76
+ * - UPLOAD_POOL_FULL (402): an upload the owner's storage pool cannot take at
77
+ * publication, which is final.
78
+ */
79
+ export const UPLOAD_REFUSAL_CODES: Readonly<{
80
+ UPLOAD_CONTRACT_MISMATCH: "UPLOAD_CONTRACT_MISMATCH";
81
+ UPLOAD_PROTOCOL_RETIRED: "UPLOAD_PROTOCOL_RETIRED";
82
+ UPLOAD_SUPERSEDED: "UPLOAD_SUPERSEDED";
83
+ UPLOAD_POOL_FULL: "UPLOAD_POOL_FULL";
84
+ }>;
85
+ /**
86
+ * The refusals of Core's that a new upload of the same file cannot remedy:
87
+ * the owner's storage pool cannot take it (UPLOAD_POOL_FULL), or a later
88
+ * upload of its ingot replaced it (UPLOAD_SUPERSEDED). Any other code Core
89
+ * ends an upload with ends its session alone, which a new upload starts
90
+ * over. Every client reads a terminal answer's code by it
91
+ * (transfer-retry.js): one of these is a refusal it reports in Core's words,
92
+ * any other a gone session.
93
+ */
94
+ export const UPLOAD_FINAL_REFUSAL_CODES: readonly ("UPLOAD_SUPERSEDED" | "UPLOAD_POOL_FULL")[];
95
+ /**
96
+ * The words an upload a later staging of its ingot superseded is refused in
97
+ * (UPLOAD_SUPERSEDED), whichever service meets it: Core's activation, Core's
98
+ * mint of a token it revoked before issuing it, and Forge meeting a token Core
99
+ * revoked when the later staging superseded its upload.
100
+ */
101
+ export const UPLOAD_SUPERSEDED_MESSAGE: "A later upload replaced this one before it finished. The later upload is the one kept, so this one was discarded.";
102
+ /**
103
+ * Core's revocation of an upload's encrypt token: the `status` it writes on
104
+ * the token's forge-transactions record, and the `revoked_reason` beside it,
105
+ * written by the write that ends the upload's staging. Each reason is the
106
+ * refusal every reader of the token answers the upload with from then on,
107
+ * as Core's activation refuses such an upload: Core's mint of a token it
108
+ * revoked before issuing it, and Forge on every request the token, or a
109
+ * session it opened, makes.
110
+ *
111
+ * - UPLOAD_SUPERSEDED: a later staging of its ingot superseded the upload
112
+ * (410 UPLOAD_SUPERSEDED, in UPLOAD_SUPERSEDED_MESSAGE's words), which no
113
+ * new upload remedies;
114
+ * - INGOT_DELETED: the ingot it was staged onto was deleted, by a delete or
115
+ * the cascade of its folder, vault or account (a 404 naming the ingot, as
116
+ * activation answers an upload whose ingot is gone), which ends the upload
117
+ * alone: a new upload can store the file again.
118
+ */
119
+ export const UPLOAD_TOKEN_REVOCATION: Readonly<{
120
+ status: "revoked";
121
+ reasons: Readonly<{
122
+ UPLOAD_SUPERSEDED: "UPLOAD_SUPERSEDED";
123
+ INGOT_DELETED: "INGOT_DELETED";
124
+ }>;
125
+ }>;
126
+ /**
127
+ * The response header that names the code Core refused an upload with for
128
+ * good: Forge sends it on every terminal answer to a tus request, a HEAD's
129
+ * (which has no body) included, so a client tells an upload the owner's pool
130
+ * cannot take from one a later upload superseded without reading a body.
131
+ */
132
+ export const UPLOAD_REFUSAL_HEADER: "X-Upload-Refusal";
@@ -0,0 +1,149 @@
1
+ // GENERATED FILE — do not edit by hand.
2
+ // Source of truth: packages/app-sdk/src/upload-publication.js
3
+ // Regenerate with: pnpm --filter @sparkvault/sdk-mobile build
4
+ /**
5
+ * The upload publication contract between Forge and Core's activation, and
6
+ * the facts of a transfer token both services spell: its shape, and Core's
7
+ * revocation of an upload's token.
8
+ *
9
+ * Forge stamps UPLOAD_PUBLICATION_PROTOCOL on every upload session it creates
10
+ * and on the final state it hands Core's activation (POST
11
+ * /v1/vaults/:vault_id/ingots/:ingot_id/activate); activation refuses any
12
+ * other version. The two services deploy separately, so a change to what
13
+ * either side sends or expects moves this number: a session or a finalize
14
+ * from the other side's contract then fails closed ("restart the upload")
15
+ * instead of publishing under a contract the other side does not hold.
16
+ *
17
+ * Version 2: an upload's own metadata (content type, original file name,
18
+ * uploader, content HMAC) travels on its upload token and its session, and
19
+ * activation publishes it from the session; the final state Forge sends
20
+ * carries only the storage facts Forge owns.
21
+ *
22
+ * Isomorphic: no Node imports.
23
+ */
24
+ export const UPLOAD_PUBLICATION_PROTOCOL = 2;
25
+ /**
26
+ * An upload's id as both services spell it: `tus_` and the 32 lowercase hex
27
+ * digits of 16 random bytes. An encrypt token that names one (`upload_id`)
28
+ * was staged by Core under it, and Forge keys the upload's session, its chunk
29
+ * prefix and its VAK wrapping by it, so Core finds and settles the upload by
30
+ * the session's id.
31
+ */
32
+ export const UPLOAD_ID_PATTERN = /^tus_[0-9a-f]{32}$/;
33
+ /** The random bytes an ISTK, the bearer token of one Forge transfer, is spelled from. */
34
+ export const ISTK_BYTES = 32;
35
+ /**
36
+ * An ISTK as Core mints one: the unpadded base64url of its ISTK_BYTES random
37
+ * bytes, 43 characters. Forge reads a presented token as a forge-transactions
38
+ * key only in this shape: the table keys other records too (an upload's token
39
+ * pointer, `UPLOAD_TOKEN#{upload_id}`), which no request may read as a token.
40
+ */
41
+ export const ISTK_PATTERN = new RegExp(`^[A-Za-z0-9_-]{${Math.ceil((ISTK_BYTES * 4) / 3)}}$`);
42
+ /**
43
+ * How much of an ISTK names a transfer's charge on the usage ledger: enough to
44
+ * be unique to the token, never the whole bearer credential.
45
+ */
46
+ export const TRANSFER_REFERENCE_ISTK_CHARS = 24;
47
+ /**
48
+ * The ledger reference of an upload's transfer charge,
49
+ * `forge_ingot_transfer_upload_<first 24 ISTK chars>`: every charge of one
50
+ * upload carries it — Core's activation, Core's charge of an upload that never
51
+ * publishes, Forge's cancel — so whichever lands first is the upload's one
52
+ * ledger row and the others are duplicates.
53
+ *
54
+ * @param {string} istk - The upload's ISTK, as its session carries it
55
+ * @returns {string}
56
+ * @throws {TypeError} When the ISTK is not a string of at least
57
+ * TRANSFER_REFERENCE_ISTK_CHARS characters
58
+ */
59
+ export function uploadTransferReference(istk) {
60
+ if (typeof istk !== 'string' || istk.length < TRANSFER_REFERENCE_ISTK_CHARS) {
61
+ throw new TypeError(`An upload's transfer reference is named from its ISTK, a string of at least ${TRANSFER_REFERENCE_ISTK_CHARS} characters`);
62
+ }
63
+ return `forge_ingot_transfer_upload_${istk.slice(0, TRANSFER_REFERENCE_ISTK_CHARS)}`;
64
+ }
65
+ /**
66
+ * The codes Core's activation refuses an upload with, which Forge's refusal
67
+ * map reads (the status is Core's):
68
+ * - UPLOAD_CONTRACT_MISMATCH (409): a finalize or session from another
69
+ * publication contract than Core's, a mixed deployment that converges — the
70
+ * upload is kept and its finalize tried again.
71
+ * - UPLOAD_PROTOCOL_RETIRED (410): a session from a contract Core no longer
72
+ * publishes, which never can be.
73
+ * - UPLOAD_SUPERSEDED (410): a session a later staging of its ingot
74
+ * superseded, which never can be.
75
+ * - UPLOAD_POOL_FULL (402): an upload the owner's storage pool cannot take at
76
+ * publication, which is final.
77
+ */
78
+ export const UPLOAD_REFUSAL_CODES = Object.freeze({
79
+ UPLOAD_CONTRACT_MISMATCH: 'UPLOAD_CONTRACT_MISMATCH',
80
+ UPLOAD_PROTOCOL_RETIRED: 'UPLOAD_PROTOCOL_RETIRED',
81
+ UPLOAD_SUPERSEDED: 'UPLOAD_SUPERSEDED',
82
+ UPLOAD_POOL_FULL: 'UPLOAD_POOL_FULL'
83
+ });
84
+ /**
85
+ * The refusals of Core's that a new upload of the same file cannot remedy:
86
+ * the owner's storage pool cannot take it (UPLOAD_POOL_FULL), or a later
87
+ * upload of its ingot replaced it (UPLOAD_SUPERSEDED). Any other code Core
88
+ * ends an upload with ends its session alone, which a new upload starts
89
+ * over. Every client reads a terminal answer's code by it
90
+ * (transfer-retry.js): one of these is a refusal it reports in Core's words,
91
+ * any other a gone session.
92
+ */
93
+ export const UPLOAD_FINAL_REFUSAL_CODES = Object.freeze([
94
+ UPLOAD_REFUSAL_CODES.UPLOAD_POOL_FULL,
95
+ UPLOAD_REFUSAL_CODES.UPLOAD_SUPERSEDED
96
+ ]);
97
+ /**
98
+ * The words an upload a later staging of its ingot superseded is refused in
99
+ * (UPLOAD_SUPERSEDED), whichever service meets it: Core's activation, Core's
100
+ * mint of a token it revoked before issuing it, and Forge meeting a token Core
101
+ * revoked when the later staging superseded its upload.
102
+ */
103
+ export const UPLOAD_SUPERSEDED_MESSAGE = 'A later upload replaced this one before it finished. The later upload is the one kept, so this one was discarded.';
104
+ /**
105
+ * Core's revocation of an upload's encrypt token: the `status` it writes on
106
+ * the token's forge-transactions record, and the `revoked_reason` beside it,
107
+ * written by the write that ends the upload's staging. Each reason is the
108
+ * refusal every reader of the token answers the upload with from then on,
109
+ * as Core's activation refuses such an upload: Core's mint of a token it
110
+ * revoked before issuing it, and Forge on every request the token, or a
111
+ * session it opened, makes.
112
+ *
113
+ * - UPLOAD_SUPERSEDED: a later staging of its ingot superseded the upload
114
+ * (410 UPLOAD_SUPERSEDED, in UPLOAD_SUPERSEDED_MESSAGE's words), which no
115
+ * new upload remedies;
116
+ * - INGOT_DELETED: the ingot it was staged onto was deleted, by a delete or
117
+ * the cascade of its folder, vault or account (a 404 naming the ingot, as
118
+ * activation answers an upload whose ingot is gone), which ends the upload
119
+ * alone: a new upload can store the file again.
120
+ */
121
+ export const UPLOAD_TOKEN_REVOCATION = Object.freeze({
122
+ status: 'revoked',
123
+ reasons: Object.freeze({
124
+ UPLOAD_SUPERSEDED: UPLOAD_REFUSAL_CODES.UPLOAD_SUPERSEDED,
125
+ INGOT_DELETED: 'INGOT_DELETED'
126
+ })
127
+ });
128
+ const REVOCATION_REASONS = Object.values(UPLOAD_TOKEN_REVOCATION.reasons);
129
+ /**
130
+ * Why Core revoked the upload token a forge-transactions record is
131
+ * (UPLOAD_TOKEN_REVOCATION's reasons), or null for any other record, or none:
132
+ * the one reading Core's mint and every Forge read of a token apply.
133
+ *
134
+ * @param {Object|null|undefined} record - A forge-transactions record, or none
135
+ * @returns {string|null}
136
+ */
137
+ export function uploadTokenRevocationReason(record) {
138
+ if (record?.status !== UPLOAD_TOKEN_REVOCATION.status)
139
+ return null;
140
+ return REVOCATION_REASONS.includes(record.revoked_reason) ? record.revoked_reason : null;
141
+ }
142
+ /**
143
+ * The response header that names the code Core refused an upload with for
144
+ * good: Forge sends it on every terminal answer to a tus request, a HEAD's
145
+ * (which has no body) included, so a client tells an upload the owner's pool
146
+ * cannot take from one a later upload superseded without reading a body.
147
+ */
148
+ export const UPLOAD_REFUSAL_HEADER = 'X-Upload-Refusal';
149
+ //# sourceMappingURL=upload-publication.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload-publication.js","sourceRoot":"","sources":["../../src/app-sdk/upload-publication.js"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,8DAA8D;AAC9D,8DAA8D;AAE9D;;;;;;;;;;;;;;;;;;;GAmBG;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,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,CAAC;IACnD,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC;QACrB,iBAAiB,EAAE,oBAAoB,CAAC,iBAAiB;QACzD,aAAa,EAAE,eAAe;KAC/B,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAE1E;;;;;;;GAOG;AACH,MAAM,UAAU,2BAA2B,CAAC,MAAM;IAChD,IAAI,MAAM,EAAE,MAAM,KAAK,uBAAuB,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACnE,OAAO,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3F,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAAkB,CAAC"}
package/dist/config.d.ts CHANGED
@@ -9,6 +9,11 @@ export interface SparkVaultMobileConfig {
9
9
  userAgent?: string;
10
10
  timeoutMs?: number;
11
11
  fileTransferTimeoutMs?: number;
12
+ /**
13
+ * Timeout of a tus create POST and DELETE. A HEAD and the receipt (the
14
+ * PATCH at the final offset) wait HEAD_AND_RECEIPT_TIMEOUT_MS instead:
15
+ * Forge answers either only after its own call to Core.
16
+ */
12
17
  tusPostTimeoutMs?: number;
13
18
  /** Stall watchdog per tus chunk PATCH: aborts after this long with NO upload progress (not an absolute deadline). */
14
19
  tusChunkTimeoutMs?: number;
@@ -31,6 +36,21 @@ export interface SparkVaultMobileConfig {
31
36
  * upload, and every upload when this is unset, streams over XHR.
32
37
  */
33
38
  backgroundUploader?: MobileBackgroundUploader;
39
+ /**
40
+ * Whether the device has a network path right now (an app wires it to its
41
+ * OS network signal). Read when an upload request got no answer: while it
42
+ * answers false the upload waits for `onOnline` instead of spending its
43
+ * retries, then asks Forge where the session stands. Only a definite
44
+ * "offline" should answer false; a path that may come up is online. Given
45
+ * together with `onOnline`, or not at all.
46
+ */
47
+ isOnline?: () => boolean;
48
+ /**
49
+ * Subscribe to the network coming back; returns the unsubscribe. The pair
50
+ * of `isOnline`. A wait it ends is otherwise ended only by the upload's
51
+ * `abortSignal`.
52
+ */
53
+ onOnline?: (listener: () => void) => () => void;
34
54
  logger?: Partial<SparkVaultLogger>;
35
55
  /**
36
56
  * Host allowlist for the backend-issued Forge transfer URLs the SDK sends an
@@ -39,6 +59,11 @@ export interface SparkVaultMobileConfig {
39
59
  */
40
60
  allowedDownloadHostPatterns?: RegExp[];
41
61
  }
62
+ /** The device's network signal, as the upload's offline wait reads it (`isOnline` with `onOnline`). */
63
+ export interface MobileConnectivity {
64
+ isOnline(): boolean;
65
+ onOnline(listener: () => void): () => void;
66
+ }
42
67
  export interface ResolvedMobileConfig {
43
68
  tokenStorage: TokenStorageAdapter;
44
69
  apiBaseUrl: string;
@@ -55,6 +80,7 @@ export interface ResolvedMobileConfig {
55
80
  fileDownloader?: MobileFileDownloader;
56
81
  backgroundTransfer?: MobileBackgroundTransfer;
57
82
  backgroundUploader?: MobileBackgroundUploader;
83
+ connectivity?: MobileConnectivity;
58
84
  logger: SparkVaultLogger;
59
85
  allowedDownloadHostPatterns: RegExp[];
60
86
  }
package/dist/config.js CHANGED
@@ -10,6 +10,18 @@ const noopLogger = {
10
10
  warn: () => undefined,
11
11
  error: () => undefined,
12
12
  };
13
+ /** The `isOnline` / `onOnline` pair as one signal, or none: one without the other cannot wait for the network. */
14
+ function resolveConnectivity(config) {
15
+ const { isOnline, onOnline } = config;
16
+ if (isOnline === undefined && onOnline === undefined)
17
+ return undefined;
18
+ if (typeof isOnline !== 'function' || typeof onOnline !== 'function') {
19
+ throw new SparkVaultValidationError('isOnline and onOnline are given together, as functions', {
20
+ field: typeof isOnline === 'function' ? 'onOnline' : 'isOnline',
21
+ });
22
+ }
23
+ return { isOnline, onOnline };
24
+ }
13
25
  function normalizeBaseUrl(url, field) {
14
26
  if (!url || typeof url !== 'string') {
15
27
  throw new SparkVaultValidationError(`${field} must be a non-empty string`, { field });
@@ -75,6 +87,7 @@ export function resolveMobileConfig(config) {
75
87
  fileDownloader: config.fileDownloader,
76
88
  backgroundTransfer: config.backgroundTransfer,
77
89
  backgroundUploader: config.backgroundUploader,
90
+ connectivity: resolveConnectivity(config),
78
91
  logger: { ...noopLogger, ...config.logger },
79
92
  allowedDownloadHostPatterns: config.allowedDownloadHostPatterns ?? [...SPARKVAULT_OWNED_HOST_PATTERNS],
80
93
  };
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAUzG,OAAO,EAAE,OAAO,EAAgB,MAAM,mBAAmB,CAAC;AAE1D,MAAM,oBAAoB,GAAG,+BAA+B,CAAC;AAC7D,MAAM,yBAAyB,GAAG,WAAW,wBAAwB,EAAE,CAAC;AAExE,MAAM,UAAU,GAAqB;IACnC,KAAK,EAAE,GAAG,EAAE,CAAC,SAAS;IACtB,IAAI,EAAE,GAAG,EAAE,CAAC,SAAS;IACrB,IAAI,EAAE,GAAG,EAAE,CAAC,SAAS;IACrB,KAAK,EAAE,GAAG,EAAE,CAAC,SAAS;CACvB,CAAC;AA8DF,SAAS,gBAAgB,CAAC,GAAW,EAAE,KAAa;IAClD,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACpC,MAAM,IAAI,yBAAyB,CAAC,GAAG,KAAK,6BAA6B,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,GAAG,CAAC,OAAO,CAAC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eAAe,EAAE,gBAAgB,CAAC,MAAM,CAAC,eAAe,IAAI,yBAAyB,EAAE,iBAAiB,CAAC;QACzG,iBAAiB;QACjB,qBAAqB,EAAE,MAAM,CAAC,qBAAqB,IAAI,IAAI;QAC3D,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,2BAA2B;QAC1D,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,KAAK;QACpC,qBAAqB,EAAE,MAAM,CAAC,qBAAqB,IAAI,MAAM;QAC7D,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,IAAI,KAAK;QAClD,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,IAAI,MAAM;QACrD,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,YAAY;QACnC,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;QAC7C,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;QAC7C,YAAY,EAAE,mBAAmB,CAAC,MAAM,CAAC;QACzC,MAAM,EAAE,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE;QAC3C,2BAA2B,EAAE,MAAM,CAAC,2BAA2B,IAAI,CAAC,GAAG,8BAA8B,CAAC;KACvG,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAA4B,EAAE,IAAa;IACrE,OAAO,GAAG,MAAM,CAAC,eAAe,GAAG,OAAO,CAAA,IAAI,MAAM,CAAC,iBAAiB,EAAE,GAAG,IAAI,EAAE,CAAC;AACpF,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -96,21 +96,55 @@ export declare class TusUploadError extends SparkVaultMobileError {
96
96
  readonly cause: Error | null;
97
97
  readonly filename: string | null;
98
98
  readonly fileSize: number | null;
99
- readonly phase: 'create' | 'upload' | 'network' | 'timeout' | 'cancelled' | 'stalled' | 'unknown';
99
+ /**
100
+ * Where the upload stopped: `finalize` is after the transfer, when every
101
+ * byte was on Forge but the ingot was not confirmed published.
102
+ */
103
+ readonly phase: 'create' | 'upload' | 'finalize' | 'network' | 'timeout' | 'cancelled' | 'stalled' | 'unknown';
100
104
  /**
101
105
  * True when Forge no longer has the session (it answered a status
102
- * `isSessionGone` recognises: expired or terminated), or the session
103
- * cannot carry this file. The persisted session is worthless, so the
104
- * caller starts a fresh upload instead of retrying it.
106
+ * `isSessionGone` recognises, or the expiry it named has passed), or the
107
+ * session cannot carry this file. The persisted session is worthless, so
108
+ * the caller starts a fresh upload instead of retrying it.
105
109
  */
106
110
  readonly sessionLost: boolean;
111
+ /**
112
+ * The `Retry-After` of the answer that ended the upload, in ms: the
113
+ * earliest a next attempt can expect another answer. Null when that answer
114
+ * named none, or no answer arrived.
115
+ */
116
+ readonly retryAfterMs: number | null;
117
+ /**
118
+ * True when every byte is on Forge and the session is intact but the ingot
119
+ * was not confirmed published: the vault did not read it `active` within
120
+ * the activation poll budget, or Forge was still saving the file at the
121
+ * upload's idle limit (code `upload_received_publishing`; it finishes
122
+ * without this device). The caller retries later by resuming the session
123
+ * it persisted, which asks Forge for the receipt again and sends no bytes.
124
+ */
125
+ readonly retryLater: boolean;
126
+ /**
127
+ * The code Core ended this upload with, as Forge named it. With code
128
+ * `upload_refused` a final refusal (`UPLOAD_POOL_FULL`: the account's
129
+ * storage pool cannot take it; `UPLOAD_SUPERSEDED`: a later upload replaced
130
+ * it), whose message is Core's own sentence and which no new upload of the
131
+ * same file remedies; with `sessionLost` any other code (`NOT_FOUND`: the
132
+ * file the upload was for is gone; `UPLOAD_PROTOCOL_RETIRED`; a 412's),
133
+ * which a fresh upload starts over from. Null when the answer named none.
134
+ */
135
+ readonly coreCode: string | null;
107
136
  constructor(message: string, options?: {
108
137
  cause?: Error | null;
109
138
  httpStatus?: number | null;
139
+ /** The error's code when it names an outcome of its own; otherwise the HTTP status, or `tus_upload_error`. */
140
+ code?: string;
110
141
  filename?: string | null;
111
142
  fileSize?: number | null;
112
143
  phase?: TusUploadError['phase'];
113
144
  sessionLost?: boolean;
145
+ retryAfterMs?: number | null;
146
+ retryLater?: boolean;
147
+ coreCode?: string | null;
114
148
  });
115
149
  /**
116
150
  * Wrap an error the SDK did not produce (a `fileReader` read, an
package/dist/errors.js CHANGED
@@ -118,7 +118,7 @@ export class IngotNameHeldError extends SparkVaultMobileError {
118
118
  export class TusUploadError extends SparkVaultMobileError {
119
119
  constructor(message, options = {}) {
120
120
  super(message, {
121
- code: options.httpStatus ?? 'tus_upload_error',
121
+ code: options.code ?? options.httpStatus ?? 'tus_upload_error',
122
122
  statusCode: options.httpStatus ?? undefined,
123
123
  });
124
124
  this.name = 'TusUploadError';
@@ -127,6 +127,9 @@ export class TusUploadError extends SparkVaultMobileError {
127
127
  this.fileSize = options.fileSize ?? null;
128
128
  this.phase = options.phase ?? 'unknown';
129
129
  this.sessionLost = options.sessionLost ?? false;
130
+ this.retryAfterMs = options.retryAfterMs ?? null;
131
+ this.retryLater = options.retryLater ?? false;
132
+ this.coreCode = options.coreCode ?? null;
130
133
  Object.setPrototypeOf(this, TusUploadError.prototype);
131
134
  }
132
135
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAMzG,SAAS,eAAe,CAAC,KAAc;IACrC,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,WAAW,CAAC;AACtD,CAAC;AAED,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAM9C,YACE,OAAe,EACf,UAKI,EAAE;QAEN,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,kBAAkB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B;QAAE,OAAO,KAAK,CAAC;IAC3D,MAAM,MAAM,GAAG,GAAG,YAAY,qBAAqB,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;IACjF,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,GAAG,GAAG,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACrF,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAC/B,UAAkB,EAClB,SAAuB;IAEvB,IAAI,UAAU,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IAEpC,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC;IACnC,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,EAAE,OAAO,IAAI,SAAS,CAAC,OAAO,IAAI,SAAS,CAAC;IAC3E,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC;IACzC,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC;IAE5B,IAAI,IAAI,KAAK,eAAe,EAAE,CAAC;QAC7B,OAAO,IAAI,iBAAiB,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,IAAI,KAAK,gBAAgB,EAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,CAAC;QACnC,IAAI,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9B,OAAO,IAAI,kBAAkB,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { SparkVaultMobile, createSparkVaultMobileClient, } from './client.js';
2
- export type { SparkVaultMobileConfig, ResolvedMobileConfig, } from './config.js';
2
+ export type { MobileConnectivity, SparkVaultMobileConfig, ResolvedMobileConfig, } from './config.js';
3
3
  export type { AuthEvent, AuthEventListener, } from './http.js';
4
4
  export { MobileProductsClient, MobileIdentityClient, } from './products/index.js';
5
5
  export { MobileAccountClient, } from './account.js';
@@ -17,7 +17,7 @@ export { MobileNotifyClient, } from './notify.js';
17
17
  export type { NotificationInboxState, NotificationMarkState, NotificationRow, ListNotificationsOptions, ListNotificationsResponse, UnreadCountResponse, MarkNotificationStateOptions, MarkNotificationStateResponse, NotificationBulkMarkState, MarkAllNotificationsStateOptions, MarkAllNotificationsStateResponse, MarkAllReadResult, RegisterDeviceResponse, } from './notify.js';
18
18
  export { MobileBillingClient, } from './billing.js';
19
19
  export { MobileUsersClient, } from './users.js';
20
- export { isSessionGone, MobileTusUploader, parseForgeUrl, } from './tus.js';
20
+ export { isSessionExpired, isSessionGone, MobileTusUploader, parseForgeUrl, } from './tus.js';
21
21
  export type { TusUploadFromUriOptions, TusResumeSession, TusSessionProbe, ParsedForgeUrl, } from './tus.js';
22
22
  export { base64EncodeUtf8, base64UrlToBytes, base64UrlToUtf8, bytesToUtf8, base64ToBytes, bytesToBase64, bytesToBase64url, utf8ToBytes, } from './encoding.js';
23
23
  export { BackgroundTransferError, gateErrorFromBody, IngotNameHeldError, IngotNotReadyError, isAuthError, isIngotNameHeldError, isIngotNotReadyError, isNetworkError, isNotFoundError, isRateLimitError, isReadOnlyVaultError, isRetryableDownloadError, isVatExpiredError, PlanRequiredError, vatRefusalReason, QuotaExceededError, SparkVaultAuthenticationError, SparkVaultAuthorizationError, SparkVaultMobileError, SparkVaultNetworkError, SparkVaultTimeoutError, SparkVaultValidationError, TusUploadError, } from './errors.js';
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ export { MobileEntropyClient, } from './entropy.js';
10
10
  export { MobileNotifyClient, } from './notify.js';
11
11
  export { MobileBillingClient, } from './billing.js';
12
12
  export { MobileUsersClient, } from './users.js';
13
- export { isSessionGone, MobileTusUploader, parseForgeUrl, } from './tus.js';
13
+ export { isSessionExpired, isSessionGone, MobileTusUploader, parseForgeUrl, } from './tus.js';
14
14
  export { base64EncodeUtf8, base64UrlToBytes, base64UrlToUtf8, bytesToUtf8, base64ToBytes, bytesToBase64, bytesToBase64url, utf8ToBytes, } from './encoding.js';
15
15
  export { BackgroundTransferError, gateErrorFromBody, IngotNameHeldError, IngotNotReadyError, isAuthError, isIngotNameHeldError, isIngotNotReadyError, isNetworkError, isNotFoundError, isRateLimitError, isReadOnlyVaultError, isRetryableDownloadError, isVatExpiredError, PlanRequiredError, vatRefusalReason, QuotaExceededError, SparkVaultAuthenticationError, SparkVaultAuthorizationError, SparkVaultMobileError, SparkVaultNetworkError, SparkVaultTimeoutError, SparkVaultValidationError, TusUploadError, } from './errors.js';
16
16
  export { VAT_REFUSAL_REASONS, endsVatSession } from './app-sdk/vat-refusal.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AASrB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AAcrB,OAAO,EACL,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAKrB,OAAO,EACL,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAUrB,OAAO,EACL,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAMtB,OAAO,EACL,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAgBrB,OAAO,EACL,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,aAAa,GACd,MAAM,UAAU,CAAC;AAOlB,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,WAAW,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,6BAA6B,EAC7B,4BAA4B,EAC5B,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI/E,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AAUrB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AAcrB,OAAO,EACL,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAKrB,OAAO,EACL,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAUrB,OAAO,EACL,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAMtB,OAAO,EACL,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAgBrB,OAAO,EACL,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,aAAa,GACd,MAAM,UAAU,CAAC;AAOlB,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,WAAW,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,6BAA6B,EAC7B,4BAA4B,EAC5B,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI/E,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,iBAAiB,CAAC"}
package/dist/ingots.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { ResolvedMobileConfig } from './config.js';
2
2
  import type { MobileHttpClient } from './http.js';
3
+ import { type TusSessionProbe } from './tus.js';
3
4
  import type { DebugLogger, HashCheckResponse, Ingot, IngotAccessLog, IngotAccessStats, IngotInvite, IngotSharingConfig, ListIngotsResponse, FolderContentsResponse, IngotUploadSession, UploadAbortBehavior, UploadProgressCallback, UploadResult, UploadTransferPolicy, UploadTransport } from './types.js';
4
5
  /**
5
6
  * What the server does when a create's name is already held in the target
@@ -68,6 +69,12 @@ export interface UploadFromUriOptions extends UploadOptions {
68
69
  * attempt or a relaunch instead of re-sending bytes Forge already holds.
69
70
  */
70
71
  onSessionCreated?: (session: IngotUploadSession) => void;
72
+ /**
73
+ * Invoked whenever the session's expiry changes (see
74
+ * `TusUploadFromUriOptions.onSessionExpiry`): a caller that persists the
75
+ * session keeps its `expiresAt` current with it.
76
+ */
77
+ onSessionExpiry?: (expiresAt: number | null) => void;
71
78
  /** See `UploadTransport`; default `foreground`. */
72
79
  transport?: UploadTransport;
73
80
  /** Network policy for the OS transfer engine; see `UploadTransferPolicy`. Default: both allowed. */
@@ -96,11 +103,18 @@ export interface ResumeUploadOptions {
96
103
  fileUri: string;
97
104
  fileSize: number;
98
105
  name: string;
99
- /** The persisted tus session handed to `onSessionCreated`. */
106
+ /**
107
+ * The persisted tus session handed to `onSessionCreated`, with the expiry
108
+ * the caller keeps for it (`onSessionExpiry`): a session past it is
109
+ * refused as `sessionLost` before any request.
110
+ */
100
111
  session: {
101
112
  uploadUrl: string;
102
113
  istk: string;
114
+ expiresAt?: number | null;
103
115
  };
116
+ /** See `UploadFromUriOptions.onSessionExpiry`. */
117
+ onSessionExpiry?: (expiresAt: number | null) => void;
104
118
  /** See `UploadTransport`; default `foreground`. */
105
119
  transport?: UploadTransport;
106
120
  /** Network policy for the OS transfer engine; see `UploadTransferPolicy`. Default: both allowed. */
@@ -202,10 +216,10 @@ export declare class MobileIngotsClient {
202
216
  * sent, then the ingot is verified active exactly as a fresh upload is.
203
217
  *
204
218
  * A `TusUploadError` with `sessionLost` means Forge no longer has the
205
- * session (expired or terminated); the caller drops it and starts over
206
- * with `uploadFromUri`. A session `uploadUrl` that is not an upload session
207
- * on an allowed transfer host is refused (SparkVaultValidationError) before
208
- * the ISTK or a byte is sent anywhere.
219
+ * session (its expiry passed, or it was terminated); the caller drops it
220
+ * and starts over with `uploadFromUri`. A session `uploadUrl` that is not
221
+ * an upload session on an allowed transfer host is refused
222
+ * (SparkVaultValidationError) before the ISTK or a byte is sent anywhere.
209
223
  */
210
224
  resumeUpload(options: ResumeUploadOptions): Promise<UploadResult>;
211
225
  /**
@@ -219,11 +233,7 @@ export declare class MobileIngotsClient {
219
233
  probeUploadSession(session: {
220
234
  uploadUrl: string;
221
235
  istk: string;
222
- }): Promise<{
223
- offset: number;
224
- length: number;
225
- chunkSize: number;
226
- } | null>;
236
+ }): Promise<TusSessionProbe | null>;
227
237
  /**
228
238
  * Release a tus session the caller kept on Forge (`abortBehavior: 'keep'`)
229
239
  * and has since abandoned, so Forge drops the chunks it holds and settles
@@ -305,15 +315,17 @@ export declare class MobileIngotsClient {
305
315
  getAccessStats(vaultId: string, ingotId: string, vat: string): Promise<IngotAccessStats>;
306
316
  purgeAccessLogs(vaultId: string, ingotId: string, vat: string): Promise<void>;
307
317
  /**
308
- * Wait for a just-uploaded ingot to finish server-side finalization.
318
+ * Read a just-uploaded ingot until the server reports it `active`.
309
319
  *
310
- * The bytes are already fully uploaded and the ingot record exists before
311
- * this runs, so this NEVER re-creates or re-uploads anything - it only polls
312
- * status. A still-`uploading` ingot after the poll budget
313
- * is returned as success, not thrown: the transport completed and the ingot
314
- * exists, so treating it as a failure would make the caller re-run the whole
315
- * upload and mint a DUPLICATE ingot (re-streaming the entire file and
316
- * double-billing storage). Finalization completes asynchronously server-side.
320
+ * The upload resolved on Forge's receipt (a 2xx to the PATCH at the final
321
+ * offset, which Forge answers only once the ingot is published), so a read
322
+ * that is not `active` yet is a read lagging that publication, which the
323
+ * poll waits out. It never re-creates or re-uploads anything. A row still
324
+ * not `active` past the poll budget is never reported as a success: it
325
+ * throws a `TusUploadError` whose `retryLater` is set (every byte is
326
+ * received, publication is unconfirmed), so the caller resumes the session
327
+ * it persisted later, which asks Forge for the receipt again and sends no
328
+ * bytes, rather than recording a backup the vault may not hold.
317
329
  */
318
330
  private verifyIngotActive;
319
331
  private verifyDownloadedFile;