@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.
@@ -12728,6 +12728,7 @@ class IngotsModule {
12728
12728
  name: options.name,
12729
12729
  content_type: options.contentType,
12730
12730
  size_bytes: options.sizeBytes,
12731
+ contentHmac: options.contentHmac,
12731
12732
  folder: options.folder,
12732
12733
  folderId: options.folderId,
12733
12734
  });
@@ -12762,6 +12763,7 @@ class IngotsModule {
12762
12763
  name,
12763
12764
  content_type: contentType,
12764
12765
  size_bytes: options.file.size,
12766
+ contentHmac: options.contentHmac,
12765
12767
  folder: options.folder,
12766
12768
  folderId: options.folderId,
12767
12769
  });
@@ -12778,7 +12780,12 @@ class IngotsModule {
12778
12780
  const cleanId = normalizeIngotId(ingotId);
12779
12781
  const name = options.name ?? getBlobName(options.file);
12780
12782
  const contentType = options.contentType ?? options.file.type ?? 'application/octet-stream';
12781
- const response = await this.http.put(`/v1/vaults/${vault.id}/ingots/${cleanId}`, { name, content_type: contentType, size_bytes: options.file.size }, { headers: { 'X-Vault-Access-Token': vault.vatToken } });
12783
+ const response = await this.http.put(`/v1/vaults/${vault.id}/ingots/${cleanId}`, {
12784
+ name,
12785
+ content_type: contentType,
12786
+ size_bytes: options.file.size,
12787
+ ...(options.contentHmac && { content_hmac: options.contentHmac }),
12788
+ }, { headers: { 'X-Vault-Access-Token': vault.vatToken } });
12782
12789
  if (!response.data.forge_url) {
12783
12790
  throw new ValidationError('Replace endpoint did not return a Forge upload URL');
12784
12791
  }
@@ -12990,6 +12997,18 @@ class IngotsModule {
12990
12997
  const cleanId = normalizeIngotId(ingotId);
12991
12998
  await this.http.delete(`/v1/vaults/${vault.id}/ingots/${cleanId}/sharing/invite/${inviteId}`, { headers: { 'X-Vault-Access-Token': vault.vatToken } });
12992
12999
  }
13000
+ /**
13001
+ * Batch content-HMAC existence check — the pre-upload dedup handshake.
13002
+ * Returns which of the supplied vault-keyed HMACs already exist on active
13003
+ * ingots in the vault, so callers can skip transferring those bytes.
13004
+ *
13005
+ * @example
13006
+ * const { found } = await sv.ingots.checkContentHmacs(unsealed, [hmac1, hmac2]);
13007
+ */
13008
+ async checkContentHmacs(vault, hashes) {
13009
+ const response = await this.http.post(`/v1/vaults/${vault.id}/ingots/hash-check`, { hashes }, { headers: { 'X-Vault-Access-Token': vault.vatToken } });
13010
+ return response.data;
13011
+ }
12993
13012
  /**
12994
13013
  * Get an ingot's access logs.
12995
13014
  *
@@ -13024,6 +13043,9 @@ class IngotsModule {
13024
13043
  else if (body.folderId) {
13025
13044
  payload.folder_id = body.folderId;
13026
13045
  }
13046
+ if (body.contentHmac) {
13047
+ payload.content_hmac = body.contentHmac;
13048
+ }
13027
13049
  const response = await this.http.post(`/v1/vaults/${vault.id}/ingots`, payload, { headers: { 'X-Vault-Access-Token': vault.vatToken } });
13028
13050
  if (!response.data.forge_url) {
13029
13051
  throw new ValidationError('Upload endpoint did not return a Forge upload URL');
@@ -13093,6 +13115,7 @@ function mapIngot(wire) {
13093
13115
  status: wire.status ?? 'active',
13094
13116
  createdAt: wire.created_at ?? 0,
13095
13117
  folderId: wire.folder_id ?? null,
13118
+ contentHmac: wire.content_hmac ?? null,
13096
13119
  };
13097
13120
  }
13098
13121
  function mapIngotPage(response) {