@sparkvault/sdk-js 8.11.2 → 8.11.4

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 CHANGED
@@ -968,9 +968,12 @@ declare class VaultsModule {
968
968
  /**
969
969
  * Delete a vault and all its ingots. This action is irreversible!
970
970
  *
971
- * Requires the vault's exact name as confirmation. It is sent as the
972
- * `X-Confirm-Name` header and must match the vault name exactly
973
- * (case-sensitive).
971
+ * Requires the vault's exact name as confirmation, matched case-sensitively.
972
+ * The name is sent base64(UTF-8) as the `X-Confirm-Name-B64` header so a vault
973
+ * named with any Unicode (emoji, CJK, the U+202F in macOS-style names) is
974
+ * deletable — an HTTP header value cannot carry non-latin1 characters. The
975
+ * legacy raw `X-Confirm-Name` header is included only for latin1 names, so
976
+ * older API servers keep working.
974
977
  *
975
978
  * @example
976
979
  * await sv.vaults.delete('vlt_abc', 'My Vault');
@@ -1214,6 +1217,8 @@ interface SearchIngotsOptions {
1214
1217
  q?: string;
1215
1218
  /** File type filter */
1216
1219
  fileType?: string;
1220
+ /** Scope the search to one folder (whole vault when omitted) */
1221
+ folderId?: string;
1217
1222
  /** Minimum size in bytes */
1218
1223
  minSize?: number;
1219
1224
  /** Maximum size in bytes */
@@ -148,6 +148,8 @@ export interface SearchIngotsOptions {
148
148
  q?: string;
149
149
  /** File type filter */
150
150
  fileType?: string;
151
+ /** Scope the search to one folder (whole vault when omitted) */
152
+ folderId?: string;
151
153
  /** Minimum size in bytes */
152
154
  minSize?: number;
153
155
  /** Maximum size in bytes */
@@ -718,6 +718,24 @@ function base64urlEncode(data) {
718
718
  function arrayBufferToBase64url(buffer) {
719
719
  return base64urlEncode(new Uint8Array(buffer));
720
720
  }
721
+ /**
722
+ * Encode a string as STANDARD base64 (with padding) of its UTF-8 bytes.
723
+ *
724
+ * Unlike base64urlEncode this keeps `+`/`/` and padding, so it round-trips
725
+ * through a server-side standard-base64 decoder. Used to carry arbitrary
726
+ * Unicode through an HTTP header value (which is limited to latin1 bytes).
727
+ *
728
+ * @param value - String to encode
729
+ * @returns Standard base64 string
730
+ */
731
+ function base64EncodeUtf8(value) {
732
+ const bytes = new TextEncoder().encode(value);
733
+ let binary = '';
734
+ for (let i = 0; i < bytes.length; i++) {
735
+ binary += String.fromCharCode(bytes[i]);
736
+ }
737
+ return btoa(binary);
738
+ }
721
739
  /**
722
740
  * Decode base64url string to Uint8Array
723
741
  *
@@ -12312,6 +12330,14 @@ class VaultUploadModule {
12312
12330
  * operations live in their own modules; this module owns the vault record,
12313
12331
  * its sharing/upload configuration, and the browser upload widget.
12314
12332
  */
12333
+ /** A string every char of which fits in a single header byte (latin1). */
12334
+ function isLatin1(value) {
12335
+ for (let i = 0; i < value.length; i++) {
12336
+ if (value.charCodeAt(i) > 0xff)
12337
+ return false;
12338
+ }
12339
+ return true;
12340
+ }
12315
12341
  class VaultsModule {
12316
12342
  constructor(config, http) {
12317
12343
  this.http = http;
@@ -12453,9 +12479,12 @@ class VaultsModule {
12453
12479
  /**
12454
12480
  * Delete a vault and all its ingots. This action is irreversible!
12455
12481
  *
12456
- * Requires the vault's exact name as confirmation. It is sent as the
12457
- * `X-Confirm-Name` header and must match the vault name exactly
12458
- * (case-sensitive).
12482
+ * Requires the vault's exact name as confirmation, matched case-sensitively.
12483
+ * The name is sent base64(UTF-8) as the `X-Confirm-Name-B64` header so a vault
12484
+ * named with any Unicode (emoji, CJK, the U+202F in macOS-style names) is
12485
+ * deletable — an HTTP header value cannot carry non-latin1 characters. The
12486
+ * legacy raw `X-Confirm-Name` header is included only for latin1 names, so
12487
+ * older API servers keep working.
12459
12488
  *
12460
12489
  * @example
12461
12490
  * await sv.vaults.delete('vlt_abc', 'My Vault');
@@ -12465,9 +12494,13 @@ class VaultsModule {
12465
12494
  if (!name) {
12466
12495
  throw new ValidationError('Vault name is required to confirm deletion');
12467
12496
  }
12468
- await this.http.delete(`/v1/vaults/${cleanId}`, {
12469
- headers: { 'X-Confirm-Name': name },
12470
- });
12497
+ const headers = {
12498
+ 'X-Confirm-Name-B64': base64EncodeUtf8(name),
12499
+ };
12500
+ if (isLatin1(name)) {
12501
+ headers['X-Confirm-Name'] = name;
12502
+ }
12503
+ await this.http.delete(`/v1/vaults/${cleanId}`, { headers });
12471
12504
  }
12472
12505
  /**
12473
12506
  * Get a vault's public-sharing configuration.
@@ -12865,6 +12898,7 @@ class IngotsModule {
12865
12898
  const query = buildQuery$1({
12866
12899
  q: options.q,
12867
12900
  file_type: options.fileType,
12901
+ folder_id: options.folderId,
12868
12902
  min_size: options.minSize,
12869
12903
  max_size: options.maxSize,
12870
12904
  limit: options.limit,