@sparkvault/sdk-mobile 7.0.0 → 7.0.1

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,93 @@
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.
6
+ *
7
+ * Forge stamps UPLOAD_PUBLICATION_PROTOCOL on every upload session it creates
8
+ * and on the final state it hands Core's activation (POST
9
+ * /v1/vaults/:vault_id/ingots/:ingot_id/activate); activation refuses any
10
+ * other version. The two services deploy separately, so a change to what
11
+ * either side sends or expects moves this number: a session or a finalize
12
+ * from the other side's contract then fails closed ("restart the upload")
13
+ * instead of publishing under a contract the other side does not hold.
14
+ *
15
+ * Version 2: an upload's own metadata (content type, original file name,
16
+ * uploader, content HMAC) travels on its upload token and its session, and
17
+ * activation publishes it from the session; the final state Forge sends
18
+ * carries only the storage facts Forge owns.
19
+ *
20
+ * Isomorphic: no Node imports.
21
+ */
22
+ export const UPLOAD_PUBLICATION_PROTOCOL = 2;
23
+ /**
24
+ * An upload's id as both services spell it: `tus_` and the 32 lowercase hex
25
+ * digits of 16 random bytes. An encrypt token that names one (`upload_id`)
26
+ * was staged by Core under it, and Forge keys the upload's session, its chunk
27
+ * prefix and its VAK wrapping by it, so Core finds and settles the upload by
28
+ * the session's id.
29
+ */
30
+ export const UPLOAD_ID_PATTERN = /^tus_[0-9a-f]{32}$/;
31
+ /**
32
+ * How much of an ISTK names a transfer's charge on the usage ledger: enough to
33
+ * be unique to the token, never the whole bearer credential.
34
+ */
35
+ export const TRANSFER_REFERENCE_ISTK_CHARS = 24;
36
+ /**
37
+ * The ledger reference of an upload's transfer charge,
38
+ * `forge_ingot_transfer_upload_<first 24 ISTK chars>`: every charge of one
39
+ * upload carries it — Core's activation, Core's charge of an upload that never
40
+ * publishes, Forge's cancel — so whichever lands first is the upload's one
41
+ * ledger row and the others are duplicates.
42
+ *
43
+ * @param {string} istk - The upload's ISTK, as its session carries it
44
+ * @returns {string}
45
+ * @throws {TypeError} When the ISTK is not a string of at least
46
+ * TRANSFER_REFERENCE_ISTK_CHARS characters
47
+ */
48
+ export function uploadTransferReference(istk) {
49
+ if (typeof istk !== 'string' || istk.length < TRANSFER_REFERENCE_ISTK_CHARS) {
50
+ throw new TypeError(`An upload's transfer reference is named from its ISTK, a string of at least ${TRANSFER_REFERENCE_ISTK_CHARS} characters`);
51
+ }
52
+ return `forge_ingot_transfer_upload_${istk.slice(0, TRANSFER_REFERENCE_ISTK_CHARS)}`;
53
+ }
54
+ /**
55
+ * The codes Core's activation refuses an upload with, which Forge's refusal
56
+ * map reads (the status is Core's):
57
+ * - UPLOAD_CONTRACT_MISMATCH (409): a finalize or session from another
58
+ * publication contract than Core's, a mixed deployment that converges — the
59
+ * upload is kept and its finalize tried again.
60
+ * - UPLOAD_PROTOCOL_RETIRED (410): a session from a contract Core no longer
61
+ * publishes, which never can be.
62
+ * - UPLOAD_SUPERSEDED (410): a session a later staging of its ingot
63
+ * superseded, which never can be.
64
+ * - UPLOAD_POOL_FULL (402): an upload the owner's storage pool cannot take at
65
+ * publication, which is final.
66
+ */
67
+ export const UPLOAD_REFUSAL_CODES = Object.freeze({
68
+ UPLOAD_CONTRACT_MISMATCH: 'UPLOAD_CONTRACT_MISMATCH',
69
+ UPLOAD_PROTOCOL_RETIRED: 'UPLOAD_PROTOCOL_RETIRED',
70
+ UPLOAD_SUPERSEDED: 'UPLOAD_SUPERSEDED',
71
+ UPLOAD_POOL_FULL: 'UPLOAD_POOL_FULL'
72
+ });
73
+ /**
74
+ * The refusals of Core's that a new upload of the same file cannot remedy:
75
+ * the owner's storage pool cannot take it (UPLOAD_POOL_FULL), or a later
76
+ * upload of its ingot replaced it (UPLOAD_SUPERSEDED). Any other code Core
77
+ * ends an upload with ends its session alone, which a new upload starts
78
+ * over. Every client reads a terminal answer's code by it
79
+ * (transfer-retry.js): one of these is a refusal it reports in Core's words,
80
+ * any other a gone session.
81
+ */
82
+ export const UPLOAD_FINAL_REFUSAL_CODES = Object.freeze([
83
+ UPLOAD_REFUSAL_CODES.UPLOAD_POOL_FULL,
84
+ UPLOAD_REFUSAL_CODES.UPLOAD_SUPERSEDED
85
+ ]);
86
+ /**
87
+ * The response header that names the code Core refused an upload with for
88
+ * good: Forge sends it on every terminal answer to a tus request, a HEAD's
89
+ * (which has no body) included, so a client tells an upload the owner's pool
90
+ * cannot take from one a later upload superseded without reading a body.
91
+ */
92
+ export const UPLOAD_REFUSAL_HEADER = 'X-Upload-Refusal';
93
+ //# 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;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AAEtD;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,CAAC;AAEhD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAI;IAC1C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,6BAA6B,EAAE,CAAC;QAC5E,MAAM,IAAI,SAAS,CACjB,+EAA+E,6BAA6B,aAAa,CAC1H,CAAC;IACJ,CAAC;IACD,OAAO,+BAA+B,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,6BAA6B,CAAC,EAAE,CAAC;AACvF,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC;IAChD,wBAAwB,EAAE,0BAA0B;IACpD,uBAAuB,EAAE,yBAAyB;IAClD,iBAAiB,EAAE,mBAAmB;IACtC,gBAAgB,EAAE,kBAAkB;CACrC,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC,MAAM,CAAC;IACtD,oBAAoB,CAAC,gBAAgB;IACrC,oBAAoB,CAAC,iBAAiB;CACvC,CAAC,CAAC;AAEH;;;;;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,MAAM,EAAE,EAAE,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,YAAY,CACnB,GAAW,EACX,OAA8C;IAE9C,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAChC,MAAM,IAAI,yBAAyB,CAAC,oDAAoD,CAAC,CAAC;IAC5F,CAAC;IAED,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAC7C,IAAI,CAAC,SAAS,IAAI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,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,CAAC;QAC/C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC/D,CAAC;CACF;AAED,MAAM,OAAO,yBAA0B,SAAQ,qBAAqB;I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B,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;
package/dist/ingots.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { readForgeTransferUrl } from './app-sdk/forge-url.js';
2
2
  import { INGOT_ACCESS_EVENT_TYPES, readIngotAccess } from './app-sdk/ingot-access-log.js';
3
- import { IngotNameHeldError, IngotNotReadyError, isRetryableDownloadError, SparkVaultMobileError, SparkVaultValidationError, } from './errors.js';
3
+ import { IngotNameHeldError, IngotNotReadyError, isRetryableDownloadError, SparkVaultMobileError, SparkVaultValidationError, TusUploadError, } from './errors.js';
4
4
  import { allowsHost, MobileTusUploader } from './tus.js';
5
5
  import { validateIngotId, validateResourceId, validateVaultId } from './validation.js';
6
6
  import { apiPath } from './request-path.js';
@@ -92,6 +92,7 @@ export class MobileIngotsClient {
92
92
  filename: name,
93
93
  forgeUrl: init.forgeUrl,
94
94
  onSessionCreated: session => options.onSessionCreated?.({ ...session, ingotId: init.ingotId, created }),
95
+ onSessionExpiry: options.onSessionExpiry,
95
96
  transport: options.transport,
96
97
  transferPolicy: options.transferPolicy,
97
98
  onProgress: options.onProgress,
@@ -99,7 +100,7 @@ export class MobileIngotsClient {
99
100
  abortBehavior: options.abortBehavior,
100
101
  debug: options.debug,
101
102
  });
102
- const ingot = await this.verifyIngotActive(options.vaultId, init.ingotId, options.vat, options.debug);
103
+ const ingot = await this.verifyIngotActive({ vaultId: options.vaultId, ingotId: init.ingotId, vat: options.vat }, { filename: name, fileSize: options.fileSize }, options.debug);
103
104
  return {
104
105
  ingot_id: init.ingotId,
105
106
  name,
@@ -119,10 +120,10 @@ export class MobileIngotsClient {
119
120
  * sent, then the ingot is verified active exactly as a fresh upload is.
120
121
  *
121
122
  * A `TusUploadError` with `sessionLost` means Forge no longer has the
122
- * session (expired or terminated); the caller drops it and starts over
123
- * with `uploadFromUri`. A session `uploadUrl` that is not an upload session
124
- * on an allowed transfer host is refused (SparkVaultValidationError) before
125
- * the ISTK or a byte is sent anywhere.
123
+ * session (its expiry passed, or it was terminated); the caller drops it
124
+ * and starts over with `uploadFromUri`. A session `uploadUrl` that is not
125
+ * an upload session on an allowed transfer host is refused
126
+ * (SparkVaultValidationError) before the ISTK or a byte is sent anywhere.
126
127
  */
127
128
  async resumeUpload(options) {
128
129
  validateVaultId(options.vaultId);
@@ -135,6 +136,7 @@ export class MobileIngotsClient {
135
136
  fileSize: options.fileSize,
136
137
  filename: options.name,
137
138
  resume: options.session,
139
+ onSessionExpiry: options.onSessionExpiry,
138
140
  transport: options.transport,
139
141
  transferPolicy: options.transferPolicy,
140
142
  onProgress: options.onProgress,
@@ -142,7 +144,7 @@ export class MobileIngotsClient {
142
144
  abortBehavior: options.abortBehavior,
143
145
  debug: options.debug,
144
146
  });
145
- const ingot = await this.verifyIngotActive(options.vaultId, options.ingotId, options.vat, options.debug);
147
+ const ingot = await this.verifyIngotActive({ vaultId: options.vaultId, ingotId: options.ingotId, vat: options.vat }, { filename: options.name, fileSize: options.fileSize }, options.debug);
146
148
  return {
147
149
  ingot_id: options.ingotId,
148
150
  name: options.name,
@@ -240,6 +242,7 @@ export class MobileIngotsClient {
240
242
  forgeUrl: response.data.forge_url,
241
243
  // A replace never mints an ingot: the row is the caller's existing one.
242
244
  onSessionCreated: session => options.onSessionCreated?.({ ...session, ingotId, created: false }),
245
+ onSessionExpiry: options.onSessionExpiry,
243
246
  transport: options.transport,
244
247
  transferPolicy: options.transferPolicy,
245
248
  onProgress,
@@ -247,7 +250,7 @@ export class MobileIngotsClient {
247
250
  abortBehavior: options.abortBehavior,
248
251
  debug,
249
252
  });
250
- const ingot = await this.verifyIngotActive(vaultId, response.data.ingot_id, vat, debug);
253
+ const ingot = await this.verifyIngotActive({ vaultId, ingotId: response.data.ingot_id, vat }, { filename: name, fileSize }, debug);
251
254
  return {
252
255
  ingot_id: response.data.ingot_id,
253
256
  name,
@@ -473,17 +476,20 @@ export class MobileIngotsClient {
473
476
  throw new SparkVaultValidationError('Ingot audit logs are read-only. Configure vault access-log retention to expire old entries.');
474
477
  }
475
478
  /**
476
- * Wait for a just-uploaded ingot to finish server-side finalization.
479
+ * Read a just-uploaded ingot until the server reports it `active`.
477
480
  *
478
- * The bytes are already fully uploaded and the ingot record exists before
479
- * this runs, so this NEVER re-creates or re-uploads anything - it only polls
480
- * status. A still-`uploading` ingot after the poll budget
481
- * is returned as success, not thrown: the transport completed and the ingot
482
- * exists, so treating it as a failure would make the caller re-run the whole
483
- * upload and mint a DUPLICATE ingot (re-streaming the entire file and
484
- * double-billing storage). Finalization completes asynchronously server-side.
481
+ * The upload resolved on Forge's receipt (a 2xx to the PATCH at the final
482
+ * offset, which Forge answers only once the ingot is published), so a read
483
+ * that is not `active` yet is a read lagging that publication, which the
484
+ * poll waits out. It never re-creates or re-uploads anything. A row still
485
+ * not `active` past the poll budget is never reported as a success: it
486
+ * throws a `TusUploadError` whose `retryLater` is set (every byte is
487
+ * received, publication is unconfirmed), so the caller resumes the session
488
+ * it persisted later, which asks Forge for the receipt again and sends no
489
+ * bytes, rather than recording a backup the vault may not hold.
485
490
  */
486
- async verifyIngotActive(vaultId, ingotId, vat, debug) {
491
+ async verifyIngotActive(ingotRef, upload, debug) {
492
+ const { vaultId, ingotId, vat } = ingotRef;
487
493
  const deadline = Date.now() + MobileIngotsClient.INGOT_STATUS_POLL_BUDGET_MS;
488
494
  let delay = MobileIngotsClient.INGOT_STATUS_POLL_INITIAL_MS;
489
495
  let ingot = await this.get(vaultId, ingotId, vat);
@@ -491,8 +497,8 @@ export class MobileIngotsClient {
491
497
  const remaining = deadline - Date.now();
492
498
  if (remaining <= 0) {
493
499
  debug?.log(`Ingot ${ingotId} still '${ingot.status}' after ${MobileIngotsClient.INGOT_STATUS_POLL_BUDGET_MS}ms; ` +
494
- 'upload transport is complete, finalizing asynchronously');
495
- return ingot;
500
+ 'the upload is received and will be confirmed on a later attempt');
501
+ throw new TusUploadError(`Upload received; the vault has not confirmed ingot ${ingotId} published yet (status ${ingot.status ?? 'unknown'})`, { ...upload, phase: 'finalize', retryLater: true });
496
502
  }
497
503
  await new Promise(resolve => setTimeout(resolve, Math.min(delay, remaining)));
498
504
  delay = Math.min(delay * 2, MobileIngotsClient.INGOT_STATUS_POLL_MAX_MS);