@sparkvault/sdk-js 8.10.5 → 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 +30 -1
- package/dist/ingots/index.d.ts +11 -2
- package/dist/ingots/types.d.ts +20 -0
- package/dist/products/identity/index.d.ts +2 -1
- package/dist/sparkvault.cjs.js +30 -3
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +30 -3
- 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
|
@@ -336,7 +336,8 @@ declare class IdentityModule {
|
|
|
336
336
|
/**
|
|
337
337
|
* One-click sign-in through the browser's native FedCM account chooser.
|
|
338
338
|
*
|
|
339
|
-
* When the person is already signed into
|
|
339
|
+
* When the person is already signed into SparkVault Identity (carrying the
|
|
340
|
+
* SSO hub session on the Identity origin),
|
|
340
341
|
* the browser surfaces a "Continue as …" prompt with no popup, redirect, or
|
|
341
342
|
* typing. Requires a registered `clientId` in the SDK config and a browser
|
|
342
343
|
* with FedCM support — callers should feature-detect with
|
|
@@ -1089,6 +1090,11 @@ interface Ingot {
|
|
|
1089
1090
|
createdAt: number;
|
|
1090
1091
|
/** Containing folder ID, or null at the vault root */
|
|
1091
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;
|
|
1092
1098
|
}
|
|
1093
1099
|
/** The discrete primitive returned by createUpload — a Forge TUS session. */
|
|
1094
1100
|
interface IngotUpload {
|
|
@@ -1143,6 +1149,8 @@ interface CreateUploadOptions {
|
|
|
1143
1149
|
folder?: string;
|
|
1144
1150
|
/** Existing folder ID to upload into. Mutually exclusive with `folder`. */
|
|
1145
1151
|
folderId?: string;
|
|
1152
|
+
/** Vault-keyed plaintext HMAC (43-char base64url) to store on the ingot. */
|
|
1153
|
+
contentHmac?: string;
|
|
1146
1154
|
}
|
|
1147
1155
|
/** Options for the high-level upload flow. */
|
|
1148
1156
|
interface UploadIngotOptions {
|
|
@@ -1156,6 +1164,8 @@ interface UploadIngotOptions {
|
|
|
1156
1164
|
folder?: string;
|
|
1157
1165
|
/** Existing folder ID to upload into. Mutually exclusive with `folder`. */
|
|
1158
1166
|
folderId?: string;
|
|
1167
|
+
/** Vault-keyed plaintext HMAC (43-char base64url) to store on the ingot. */
|
|
1168
|
+
contentHmac?: string;
|
|
1159
1169
|
/** Progress callback for the Forge/TUS transfer */
|
|
1160
1170
|
onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
|
|
1161
1171
|
}
|
|
@@ -1165,6 +1175,8 @@ interface ReplaceIngotOptions {
|
|
|
1165
1175
|
file: File | Blob;
|
|
1166
1176
|
/** Optional new name (defaults to file name) */
|
|
1167
1177
|
name?: string;
|
|
1178
|
+
/** Vault-keyed plaintext HMAC (43-char base64url) for the NEW content. */
|
|
1179
|
+
contentHmac?: string;
|
|
1168
1180
|
/** Content type (auto-detected from the file if not provided) */
|
|
1169
1181
|
contentType?: string;
|
|
1170
1182
|
/** Progress callback for the Forge/TUS transfer */
|
|
@@ -1279,6 +1291,14 @@ interface AccessLogsOptions {
|
|
|
1279
1291
|
/** Pagination cursor */
|
|
1280
1292
|
cursor?: string;
|
|
1281
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
|
+
}
|
|
1282
1302
|
|
|
1283
1303
|
/**
|
|
1284
1304
|
* Ingots Module
|
|
@@ -1440,6 +1460,15 @@ declare class IngotsModule {
|
|
|
1440
1460
|
* await sv.ingots.revokeInvite(unsealed, 'ing_abc', 'inv_123');
|
|
1441
1461
|
*/
|
|
1442
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>;
|
|
1443
1472
|
/**
|
|
1444
1473
|
* Get an ingot's access logs.
|
|
1445
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;
|
|
@@ -46,7 +46,8 @@ export declare class IdentityModule {
|
|
|
46
46
|
/**
|
|
47
47
|
* One-click sign-in through the browser's native FedCM account chooser.
|
|
48
48
|
*
|
|
49
|
-
* When the person is already signed into
|
|
49
|
+
* When the person is already signed into SparkVault Identity (carrying the
|
|
50
|
+
* SSO hub session on the Identity origin),
|
|
50
51
|
* the browser surfaces a "Continue as …" prompt with no popup, redirect, or
|
|
51
52
|
* typing. Requires a registered `clientId` in the SDK config and a browser
|
|
52
53
|
* with FedCM support — callers should feature-detect with
|
package/dist/sparkvault.cjs.js
CHANGED
|
@@ -8574,7 +8574,8 @@ class IdentityModule {
|
|
|
8574
8574
|
/**
|
|
8575
8575
|
* One-click sign-in through the browser's native FedCM account chooser.
|
|
8576
8576
|
*
|
|
8577
|
-
* When the person is already signed into
|
|
8577
|
+
* When the person is already signed into SparkVault Identity (carrying the
|
|
8578
|
+
* SSO hub session on the Identity origin),
|
|
8578
8579
|
* the browser surfaces a "Continue as …" prompt with no popup, redirect, or
|
|
8579
8580
|
* typing. Requires a registered `clientId` in the SDK config and a browser
|
|
8580
8581
|
* with FedCM support — callers should feature-detect with
|
|
@@ -8599,7 +8600,10 @@ class IdentityModule {
|
|
|
8599
8600
|
});
|
|
8600
8601
|
}
|
|
8601
8602
|
const nonce = options.nonce ?? generateState();
|
|
8602
|
-
|
|
8603
|
+
// The FedCM IdP is the IDENTITY origin (where sign-in runs and the SSO hub
|
|
8604
|
+
// cookie lives) — not the auth.sv portal. The config, its endpoints, and
|
|
8605
|
+
// the credentialed accounts fetch must all be same-origin with that cookie.
|
|
8606
|
+
const configURL = `${this.config.identityBaseUrl}/${this.config.accountId}/fedcm/config.json`;
|
|
8603
8607
|
const request = {
|
|
8604
8608
|
identity: { providers: [{ configURL, clientId: this.config.clientId, nonce }] },
|
|
8605
8609
|
...(options.mediation ? { mediation: options.mediation } : {}),
|
|
@@ -12728,6 +12732,7 @@ class IngotsModule {
|
|
|
12728
12732
|
name: options.name,
|
|
12729
12733
|
content_type: options.contentType,
|
|
12730
12734
|
size_bytes: options.sizeBytes,
|
|
12735
|
+
contentHmac: options.contentHmac,
|
|
12731
12736
|
folder: options.folder,
|
|
12732
12737
|
folderId: options.folderId,
|
|
12733
12738
|
});
|
|
@@ -12762,6 +12767,7 @@ class IngotsModule {
|
|
|
12762
12767
|
name,
|
|
12763
12768
|
content_type: contentType,
|
|
12764
12769
|
size_bytes: options.file.size,
|
|
12770
|
+
contentHmac: options.contentHmac,
|
|
12765
12771
|
folder: options.folder,
|
|
12766
12772
|
folderId: options.folderId,
|
|
12767
12773
|
});
|
|
@@ -12778,7 +12784,12 @@ class IngotsModule {
|
|
|
12778
12784
|
const cleanId = normalizeIngotId(ingotId);
|
|
12779
12785
|
const name = options.name ?? getBlobName(options.file);
|
|
12780
12786
|
const contentType = options.contentType ?? options.file.type ?? 'application/octet-stream';
|
|
12781
|
-
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 } });
|
|
12782
12793
|
if (!response.data.forge_url) {
|
|
12783
12794
|
throw new ValidationError('Replace endpoint did not return a Forge upload URL');
|
|
12784
12795
|
}
|
|
@@ -12990,6 +13001,18 @@ class IngotsModule {
|
|
|
12990
13001
|
const cleanId = normalizeIngotId(ingotId);
|
|
12991
13002
|
await this.http.delete(`/v1/vaults/${vault.id}/ingots/${cleanId}/sharing/invite/${inviteId}`, { headers: { 'X-Vault-Access-Token': vault.vatToken } });
|
|
12992
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
|
+
}
|
|
12993
13016
|
/**
|
|
12994
13017
|
* Get an ingot's access logs.
|
|
12995
13018
|
*
|
|
@@ -13024,6 +13047,9 @@ class IngotsModule {
|
|
|
13024
13047
|
else if (body.folderId) {
|
|
13025
13048
|
payload.folder_id = body.folderId;
|
|
13026
13049
|
}
|
|
13050
|
+
if (body.contentHmac) {
|
|
13051
|
+
payload.content_hmac = body.contentHmac;
|
|
13052
|
+
}
|
|
13027
13053
|
const response = await this.http.post(`/v1/vaults/${vault.id}/ingots`, payload, { headers: { 'X-Vault-Access-Token': vault.vatToken } });
|
|
13028
13054
|
if (!response.data.forge_url) {
|
|
13029
13055
|
throw new ValidationError('Upload endpoint did not return a Forge upload URL');
|
|
@@ -13093,6 +13119,7 @@ function mapIngot(wire) {
|
|
|
13093
13119
|
status: wire.status ?? 'active',
|
|
13094
13120
|
createdAt: wire.created_at ?? 0,
|
|
13095
13121
|
folderId: wire.folder_id ?? null,
|
|
13122
|
+
contentHmac: wire.content_hmac ?? null,
|
|
13096
13123
|
};
|
|
13097
13124
|
}
|
|
13098
13125
|
function mapIngotPage(response) {
|