@sparkvault/sdk-js 2.0.1 → 2.0.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.
@@ -12,12 +12,12 @@ import type { VaultUploadConfig } from './types';
12
12
  * SparkVaultError — no duplicate `httpStatus` field.
13
13
  */
14
14
  export declare class UploadApiError extends SparkVaultError {
15
- constructor(message: string, code: string, statusCode: number);
15
+ constructor(message: string, code: string, statusCode: number, details?: Record<string, unknown>);
16
16
  }
17
17
  export declare class UploadApi extends SparkVaultApi {
18
18
  private readonly config;
19
19
  constructor(config: ResolvedConfig);
20
- protected makeError(message: string, code: string, statusCode: number): UploadApiError;
20
+ protected makeError(message: string, code: string, statusCode: number, details?: Record<string, unknown>): UploadApiError;
21
21
  /**
22
22
  * Issue a request and unwrap the standard `{ data, meta }` envelope.
23
23
  */
@@ -33,4 +33,32 @@ export declare class UploadApi extends SparkVaultApi {
33
33
  forgeUrl: string;
34
34
  ingotId: string;
35
35
  }>;
36
+ /**
37
+ * Confirm the upload was finalized SERVER-SIDE before reporting success.
38
+ *
39
+ * The TUS PATCH loop trusts a server-provided `Upload-Offset`; a buggy or
40
+ * malicious Forge could return an inflated offset before every chunk was
41
+ * actually committed and encrypted. This re-reads the server's own
42
+ * persisted offset via a TUS HEAD (which Forge only advances on a real S3
43
+ * commit) and requires it to reach the declared total — the web equivalent
44
+ * of the mobile SDK's `verifyIngotActive` (status === 'active') guarantee.
45
+ *
46
+ * Polls because the final chunk's commit and the offset write can lag the
47
+ * PATCH acknowledgement by a moment. Throws on a non-2xx HEAD, on a session
48
+ * that never reaches the expected offset within the poll budget, or on a
49
+ * cancelled session — never reports a half-finished upload as done.
50
+ *
51
+ * @param uploadUrl - The TUS session URL (Forge `Location`, ISTK-bound).
52
+ * @param expectedOffset - The declared total upload size in bytes.
53
+ */
54
+ verifyUploadFinalized(uploadUrl: string, expectedOffset: number): Promise<void>;
55
+ /**
56
+ * Read the server's persisted upload offset via a TUS HEAD request.
57
+ *
58
+ * Uses raw `fetch` rather than the JSON envelope helper: TUS responses
59
+ * carry an empty body and surface state in the `Upload-Offset` header.
60
+ * Honors the session abort signal and request timeout like every other
61
+ * client call.
62
+ */
63
+ private headUploadOffset;
36
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparkvault/sdk-js",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "SparkVault JavaScript SDK - Identity Verification and Encrypted Vaults",
5
5
  "type": "module",
6
6
  "main": "dist/sparkvault.cjs.js",