@sparkvault/sdk-js 8.10.6 → 8.11.0
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 +28 -0
- package/dist/ingots/index.d.ts +11 -2
- package/dist/ingots/types.d.ts +20 -0
- package/dist/sparkvault.cjs.js +24 -1
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +24 -1
- package/dist/sparkvault.esm.js.map +1 -1
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1090,6 +1090,11 @@ interface Ingot {
|
|
|
1090
1090
|
createdAt: number;
|
|
1091
1091
|
/** Containing folder ID, or null at the vault root */
|
|
1092
1092
|
folderId: string | null;
|
|
1093
|
+
/**
|
|
1094
|
+
* Client-computed, vault-keyed HMAC of the plaintext (43-char base64url),
|
|
1095
|
+
* or null when the uploader did not supply one.
|
|
1096
|
+
*/
|
|
1097
|
+
contentHmac: string | null;
|
|
1093
1098
|
}
|
|
1094
1099
|
/** The discrete primitive returned by createUpload — a Forge TUS session. */
|
|
1095
1100
|
interface IngotUpload {
|
|
@@ -1144,6 +1149,8 @@ interface CreateUploadOptions {
|
|
|
1144
1149
|
folder?: string;
|
|
1145
1150
|
/** Existing folder ID to upload into. Mutually exclusive with `folder`. */
|
|
1146
1151
|
folderId?: string;
|
|
1152
|
+
/** Vault-keyed plaintext HMAC (43-char base64url) to store on the ingot. */
|
|
1153
|
+
contentHmac?: string;
|
|
1147
1154
|
}
|
|
1148
1155
|
/** Options for the high-level upload flow. */
|
|
1149
1156
|
interface UploadIngotOptions {
|
|
@@ -1157,6 +1164,8 @@ interface UploadIngotOptions {
|
|
|
1157
1164
|
folder?: string;
|
|
1158
1165
|
/** Existing folder ID to upload into. Mutually exclusive with `folder`. */
|
|
1159
1166
|
folderId?: string;
|
|
1167
|
+
/** Vault-keyed plaintext HMAC (43-char base64url) to store on the ingot. */
|
|
1168
|
+
contentHmac?: string;
|
|
1160
1169
|
/** Progress callback for the Forge/TUS transfer */
|
|
1161
1170
|
onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
|
|
1162
1171
|
}
|
|
@@ -1166,6 +1175,8 @@ interface ReplaceIngotOptions {
|
|
|
1166
1175
|
file: File | Blob;
|
|
1167
1176
|
/** Optional new name (defaults to file name) */
|
|
1168
1177
|
name?: string;
|
|
1178
|
+
/** Vault-keyed plaintext HMAC (43-char base64url) for the NEW content. */
|
|
1179
|
+
contentHmac?: string;
|
|
1169
1180
|
/** Content type (auto-detected from the file if not provided) */
|
|
1170
1181
|
contentType?: string;
|
|
1171
1182
|
/** Progress callback for the Forge/TUS transfer */
|
|
@@ -1280,6 +1291,14 @@ interface AccessLogsOptions {
|
|
|
1280
1291
|
/** Pagination cursor */
|
|
1281
1292
|
cursor?: string;
|
|
1282
1293
|
}
|
|
1294
|
+
/** One hash-check hit: this HMAC exists on an active ingot in the vault. */
|
|
1295
|
+
interface HashCheckMatch {
|
|
1296
|
+
content_hmac: string;
|
|
1297
|
+
ingot_id: string;
|
|
1298
|
+
}
|
|
1299
|
+
interface HashCheckResponse {
|
|
1300
|
+
found: HashCheckMatch[];
|
|
1301
|
+
}
|
|
1283
1302
|
|
|
1284
1303
|
/**
|
|
1285
1304
|
* Ingots Module
|
|
@@ -1441,6 +1460,15 @@ declare class IngotsModule {
|
|
|
1441
1460
|
* await sv.ingots.revokeInvite(unsealed, 'ing_abc', 'inv_123');
|
|
1442
1461
|
*/
|
|
1443
1462
|
revokeInvite(vault: UnsealedVault, ingotId: string, inviteId: string): Promise<void>;
|
|
1463
|
+
/**
|
|
1464
|
+
* Batch content-HMAC existence check — the pre-upload dedup handshake.
|
|
1465
|
+
* Returns which of the supplied vault-keyed HMACs already exist on active
|
|
1466
|
+
* ingots in the vault, so callers can skip transferring those bytes.
|
|
1467
|
+
*
|
|
1468
|
+
* @example
|
|
1469
|
+
* const { found } = await sv.ingots.checkContentHmacs(unsealed, [hmac1, hmac2]);
|
|
1470
|
+
*/
|
|
1471
|
+
checkContentHmacs(vault: UnsealedVault, hashes: string[]): Promise<HashCheckResponse>;
|
|
1444
1472
|
/**
|
|
1445
1473
|
* Get an ingot's access logs.
|
|
1446
1474
|
*
|
package/dist/ingots/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import type { ResolvedConfig } from '../config';
|
|
13
13
|
import { HttpClient } from '../http';
|
|
14
|
-
import type { UnsealedVault, Ingot, IngotUpload, CreatedIngot, IngotDownloadLink, CreateUploadOptions, UploadIngotOptions, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvite, AddInviteOptions, IngotAccessLogPage, AccessLogsOptions } from './types';
|
|
14
|
+
import type { UnsealedVault, Ingot, IngotUpload, CreatedIngot, IngotDownloadLink, CreateUploadOptions, UploadIngotOptions, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvite, AddInviteOptions, IngotAccessLogPage, AccessLogsOptions, HashCheckResponse } from './types';
|
|
15
15
|
export declare class IngotsModule {
|
|
16
16
|
private readonly config;
|
|
17
17
|
private readonly http;
|
|
@@ -160,6 +160,15 @@ export declare class IngotsModule {
|
|
|
160
160
|
* await sv.ingots.revokeInvite(unsealed, 'ing_abc', 'inv_123');
|
|
161
161
|
*/
|
|
162
162
|
revokeInvite(vault: UnsealedVault, ingotId: string, inviteId: string): Promise<void>;
|
|
163
|
+
/**
|
|
164
|
+
* Batch content-HMAC existence check — the pre-upload dedup handshake.
|
|
165
|
+
* Returns which of the supplied vault-keyed HMACs already exist on active
|
|
166
|
+
* ingots in the vault, so callers can skip transferring those bytes.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* const { found } = await sv.ingots.checkContentHmacs(unsealed, [hmac1, hmac2]);
|
|
170
|
+
*/
|
|
171
|
+
checkContentHmacs(vault: UnsealedVault, hashes: string[]): Promise<HashCheckResponse>;
|
|
163
172
|
/**
|
|
164
173
|
* Get an ingot's access logs.
|
|
165
174
|
*
|
|
@@ -180,4 +189,4 @@ export declare class IngotsModule {
|
|
|
180
189
|
private validateFile;
|
|
181
190
|
private validateDownloadUrl;
|
|
182
191
|
}
|
|
183
|
-
export type { UnsealedVault, Ingot, IngotUpload, CreatedIngot, IngotDownloadLink, CreateUploadOptions, UploadIngotOptions, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvite, AddInviteOptions, IngotAccessLog, IngotAccessLogPage, AccessLogsOptions, } from './types';
|
|
192
|
+
export type { UnsealedVault, Ingot, IngotUpload, CreatedIngot, IngotDownloadLink, CreateUploadOptions, UploadIngotOptions, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvite, AddInviteOptions, IngotAccessLog, IngotAccessLogPage, AccessLogsOptions, HashCheckMatch, HashCheckResponse, } from './types';
|
package/dist/ingots/types.d.ts
CHANGED
|
@@ -24,6 +24,11 @@ export interface Ingot {
|
|
|
24
24
|
createdAt: number;
|
|
25
25
|
/** Containing folder ID, or null at the vault root */
|
|
26
26
|
folderId: string | null;
|
|
27
|
+
/**
|
|
28
|
+
* Client-computed, vault-keyed HMAC of the plaintext (43-char base64url),
|
|
29
|
+
* or null when the uploader did not supply one.
|
|
30
|
+
*/
|
|
31
|
+
contentHmac: string | null;
|
|
27
32
|
}
|
|
28
33
|
/** The discrete primitive returned by createUpload — a Forge TUS session. */
|
|
29
34
|
export interface IngotUpload {
|
|
@@ -78,6 +83,8 @@ export interface CreateUploadOptions {
|
|
|
78
83
|
folder?: string;
|
|
79
84
|
/** Existing folder ID to upload into. Mutually exclusive with `folder`. */
|
|
80
85
|
folderId?: string;
|
|
86
|
+
/** Vault-keyed plaintext HMAC (43-char base64url) to store on the ingot. */
|
|
87
|
+
contentHmac?: string;
|
|
81
88
|
}
|
|
82
89
|
/** Options for the high-level upload flow. */
|
|
83
90
|
export interface UploadIngotOptions {
|
|
@@ -91,6 +98,8 @@ export interface UploadIngotOptions {
|
|
|
91
98
|
folder?: string;
|
|
92
99
|
/** Existing folder ID to upload into. Mutually exclusive with `folder`. */
|
|
93
100
|
folderId?: string;
|
|
101
|
+
/** Vault-keyed plaintext HMAC (43-char base64url) to store on the ingot. */
|
|
102
|
+
contentHmac?: string;
|
|
94
103
|
/** Progress callback for the Forge/TUS transfer */
|
|
95
104
|
onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
|
|
96
105
|
}
|
|
@@ -100,6 +109,8 @@ export interface ReplaceIngotOptions {
|
|
|
100
109
|
file: File | Blob;
|
|
101
110
|
/** Optional new name (defaults to file name) */
|
|
102
111
|
name?: string;
|
|
112
|
+
/** Vault-keyed plaintext HMAC (43-char base64url) for the NEW content. */
|
|
113
|
+
contentHmac?: string;
|
|
103
114
|
/** Content type (auto-detected from the file if not provided) */
|
|
104
115
|
contentType?: string;
|
|
105
116
|
/** Progress callback for the Forge/TUS transfer */
|
|
@@ -222,6 +233,15 @@ export interface IngotWire {
|
|
|
222
233
|
status?: string;
|
|
223
234
|
created_at?: number;
|
|
224
235
|
folder_id?: string | null;
|
|
236
|
+
content_hmac?: string | null;
|
|
237
|
+
}
|
|
238
|
+
/** One hash-check hit: this HMAC exists on an active ingot in the vault. */
|
|
239
|
+
export interface HashCheckMatch {
|
|
240
|
+
content_hmac: string;
|
|
241
|
+
ingot_id: string;
|
|
242
|
+
}
|
|
243
|
+
export interface HashCheckResponse {
|
|
244
|
+
found: HashCheckMatch[];
|
|
225
245
|
}
|
|
226
246
|
export interface CreateIngotResponse {
|
|
227
247
|
ingot_id: string;
|
package/dist/sparkvault.cjs.js
CHANGED
|
@@ -12732,6 +12732,7 @@ class IngotsModule {
|
|
|
12732
12732
|
name: options.name,
|
|
12733
12733
|
content_type: options.contentType,
|
|
12734
12734
|
size_bytes: options.sizeBytes,
|
|
12735
|
+
contentHmac: options.contentHmac,
|
|
12735
12736
|
folder: options.folder,
|
|
12736
12737
|
folderId: options.folderId,
|
|
12737
12738
|
});
|
|
@@ -12766,6 +12767,7 @@ class IngotsModule {
|
|
|
12766
12767
|
name,
|
|
12767
12768
|
content_type: contentType,
|
|
12768
12769
|
size_bytes: options.file.size,
|
|
12770
|
+
contentHmac: options.contentHmac,
|
|
12769
12771
|
folder: options.folder,
|
|
12770
12772
|
folderId: options.folderId,
|
|
12771
12773
|
});
|
|
@@ -12782,7 +12784,12 @@ class IngotsModule {
|
|
|
12782
12784
|
const cleanId = normalizeIngotId(ingotId);
|
|
12783
12785
|
const name = options.name ?? getBlobName(options.file);
|
|
12784
12786
|
const contentType = options.contentType ?? options.file.type ?? 'application/octet-stream';
|
|
12785
|
-
const response = await this.http.put(`/v1/vaults/${vault.id}/ingots/${cleanId}`, {
|
|
12787
|
+
const response = await this.http.put(`/v1/vaults/${vault.id}/ingots/${cleanId}`, {
|
|
12788
|
+
name,
|
|
12789
|
+
content_type: contentType,
|
|
12790
|
+
size_bytes: options.file.size,
|
|
12791
|
+
...(options.contentHmac && { content_hmac: options.contentHmac }),
|
|
12792
|
+
}, { headers: { 'X-Vault-Access-Token': vault.vatToken } });
|
|
12786
12793
|
if (!response.data.forge_url) {
|
|
12787
12794
|
throw new ValidationError('Replace endpoint did not return a Forge upload URL');
|
|
12788
12795
|
}
|
|
@@ -12994,6 +13001,18 @@ class IngotsModule {
|
|
|
12994
13001
|
const cleanId = normalizeIngotId(ingotId);
|
|
12995
13002
|
await this.http.delete(`/v1/vaults/${vault.id}/ingots/${cleanId}/sharing/invite/${inviteId}`, { headers: { 'X-Vault-Access-Token': vault.vatToken } });
|
|
12996
13003
|
}
|
|
13004
|
+
/**
|
|
13005
|
+
* Batch content-HMAC existence check — the pre-upload dedup handshake.
|
|
13006
|
+
* Returns which of the supplied vault-keyed HMACs already exist on active
|
|
13007
|
+
* ingots in the vault, so callers can skip transferring those bytes.
|
|
13008
|
+
*
|
|
13009
|
+
* @example
|
|
13010
|
+
* const { found } = await sv.ingots.checkContentHmacs(unsealed, [hmac1, hmac2]);
|
|
13011
|
+
*/
|
|
13012
|
+
async checkContentHmacs(vault, hashes) {
|
|
13013
|
+
const response = await this.http.post(`/v1/vaults/${vault.id}/ingots/hash-check`, { hashes }, { headers: { 'X-Vault-Access-Token': vault.vatToken } });
|
|
13014
|
+
return response.data;
|
|
13015
|
+
}
|
|
12997
13016
|
/**
|
|
12998
13017
|
* Get an ingot's access logs.
|
|
12999
13018
|
*
|
|
@@ -13028,6 +13047,9 @@ class IngotsModule {
|
|
|
13028
13047
|
else if (body.folderId) {
|
|
13029
13048
|
payload.folder_id = body.folderId;
|
|
13030
13049
|
}
|
|
13050
|
+
if (body.contentHmac) {
|
|
13051
|
+
payload.content_hmac = body.contentHmac;
|
|
13052
|
+
}
|
|
13031
13053
|
const response = await this.http.post(`/v1/vaults/${vault.id}/ingots`, payload, { headers: { 'X-Vault-Access-Token': vault.vatToken } });
|
|
13032
13054
|
if (!response.data.forge_url) {
|
|
13033
13055
|
throw new ValidationError('Upload endpoint did not return a Forge upload URL');
|
|
@@ -13097,6 +13119,7 @@ function mapIngot(wire) {
|
|
|
13097
13119
|
status: wire.status ?? 'active',
|
|
13098
13120
|
createdAt: wire.created_at ?? 0,
|
|
13099
13121
|
folderId: wire.folder_id ?? null,
|
|
13122
|
+
contentHmac: wire.content_hmac ?? null,
|
|
13100
13123
|
};
|
|
13101
13124
|
}
|
|
13102
13125
|
function mapIngotPage(response) {
|