@haex-space/vault-sdk 2.5.50 → 2.5.54

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.
@@ -1,6 +1,6 @@
1
1
  import * as nuxt_app from 'nuxt/app';
2
2
  import { ShallowRef } from 'vue';
3
- import { H as HaexVaultSdk } from '../client-BDxVgihp.mjs';
3
+ import { H as HaexVaultSdk } from '../client-Y3QEhTe2.mjs';
4
4
  import { A as ApplicationContext } from '../types-DiXJ5SF6.mjs';
5
5
  import 'drizzle-orm/sqlite-proxy';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import * as nuxt_app from 'nuxt/app';
2
2
  import { ShallowRef } from 'vue';
3
- import { H as HaexVaultSdk } from '../client-Bgu2k1yJ.js';
3
+ import { H as HaexVaultSdk } from '../client-Dv3ysOWr.js';
4
4
  import { A as ApplicationContext } from '../types-DiXJ5SF6.js';
5
5
  import 'drizzle-orm/sqlite-proxy';
6
6
 
@@ -232,6 +232,33 @@ var DatabaseAPI = class {
232
232
  }
233
233
  };
234
234
 
235
+ // src/crypto/vaultKey.ts
236
+ function arrayBufferToBase64(buffer) {
237
+ const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
238
+ if (typeof Buffer !== "undefined") {
239
+ return Buffer.from(bytes).toString("base64");
240
+ }
241
+ let binary = "";
242
+ for (let i = 0; i < bytes.length; i++) {
243
+ const byte = bytes[i];
244
+ if (byte !== void 0) {
245
+ binary += String.fromCharCode(byte);
246
+ }
247
+ }
248
+ return btoa(binary);
249
+ }
250
+ function base64ToArrayBuffer(base64) {
251
+ if (typeof Buffer !== "undefined") {
252
+ return new Uint8Array(Buffer.from(base64, "base64"));
253
+ }
254
+ const binary = atob(base64);
255
+ const bytes = new Uint8Array(binary.length);
256
+ for (let i = 0; i < binary.length; i++) {
257
+ bytes[i] = binary.charCodeAt(i);
258
+ }
259
+ return bytes;
260
+ }
261
+
235
262
  // src/api/filesystem.ts
236
263
  var FilesystemAPI = class {
237
264
  constructor(client) {
@@ -303,12 +330,7 @@ var FilesystemAPI = class {
303
330
  HAEXTENSION_METHODS.filesystem.readFile,
304
331
  { path }
305
332
  );
306
- const binary = atob(base64);
307
- const bytes = new Uint8Array(binary.length);
308
- for (let i = 0; i < binary.length; i++) {
309
- bytes[i] = binary.charCodeAt(i);
310
- }
311
- return bytes;
333
+ return base64ToArrayBuffer(base64);
312
334
  }
313
335
  /**
314
336
  * Write file contents
@@ -316,7 +338,7 @@ var FilesystemAPI = class {
316
338
  * @param data File contents as Uint8Array
317
339
  */
318
340
  async writeFile(path, data) {
319
- const base64 = btoa(String.fromCharCode(...data));
341
+ const base64 = arrayBufferToBase64(data);
320
342
  await this.client.request(
321
343
  HAEXTENSION_METHODS.filesystem.writeFile,
322
344
  { path, data: base64 }
@@ -602,7 +624,7 @@ var RemoteStorageAPI = class {
602
624
  * @param data - Data to upload
603
625
  */
604
626
  async upload(backendId, key, data) {
605
- const base64 = btoa(String.fromCharCode(...data));
627
+ const base64 = arrayBufferToBase64(data);
606
628
  await this.client.request(HAEXTENSION_METHODS.remoteStorage.upload, {
607
629
  backendId,
608
630
  key,
@@ -620,12 +642,7 @@ var RemoteStorageAPI = class {
620
642
  HAEXTENSION_METHODS.remoteStorage.download,
621
643
  { backendId, key }
622
644
  );
623
- const binary = atob(base64);
624
- const bytes = new Uint8Array(binary.length);
625
- for (let i = 0; i < binary.length; i++) {
626
- bytes[i] = binary.charCodeAt(i);
627
- }
628
- return bytes;
645
+ return base64ToArrayBuffer(base64);
629
646
  }
630
647
  /**
631
648
  * Delete an object from a storage backend