@sparkvault/sdk-js 8.11.3 → 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 +6 -3
- package/dist/sparkvault.cjs.js +39 -6
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +39 -6
- package/dist/sparkvault.esm.js.map +1 -1
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/dist/utils/base64url.d.ts +11 -0
- package/dist/vaults/index.d.ts +6 -3
- package/package.json +1 -1
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
|
|
972
|
-
* `X-Confirm-Name` header
|
|
973
|
-
* (
|
|
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');
|
package/dist/sparkvault.cjs.js
CHANGED
|
@@ -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
|
|
12457
|
-
* `X-Confirm-Name` header
|
|
12458
|
-
* (
|
|
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
|
-
|
|
12469
|
-
|
|
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.
|