@unicitylabs/sphere-sdk 0.1.5 → 0.1.7

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,3 +1,6 @@
1
+ // impl/browser/index.ts
2
+ import { Buffer as Buffer3 } from "buffer";
3
+
1
4
  // constants.ts
2
5
  var STORAGE_KEYS_GLOBAL = {
3
6
  /** Encrypted BIP39 mnemonic */
@@ -367,8 +370,15 @@ var IndexedDBTokenStorageProvider = class {
367
370
  }
368
371
  const tokens = await this.getAllFromStore(STORE_TOKENS);
369
372
  for (const token of tokens) {
370
- const key = `_${token.id}`;
371
- data[key] = token.data;
373
+ if (token.id.startsWith("token-") || token.id.startsWith("nametag-")) {
374
+ continue;
375
+ }
376
+ if (token.id.startsWith("archived-")) {
377
+ data[token.id] = token.data;
378
+ } else {
379
+ const key = `_${token.id}`;
380
+ data[key] = token.data;
381
+ }
372
382
  }
373
383
  const tombstones = await this.getFromStore(STORE_META, "tombstones");
374
384
  if (tombstones) {
@@ -423,10 +433,14 @@ var IndexedDBTokenStorageProvider = class {
423
433
  if (data._invalid) {
424
434
  await this.putToStore(STORE_META, "invalid", data._invalid);
425
435
  }
436
+ const reservedKeys = ["_meta", "_tombstones", "_outbox", "_sent", "_invalid"];
426
437
  for (const [key, value] of Object.entries(data)) {
427
- if (key.startsWith("_") && key !== "_meta" && key !== "_tombstones" && key !== "_outbox" && key !== "_sent" && key !== "_invalid") {
438
+ if (reservedKeys.includes(key)) continue;
439
+ if (key.startsWith("_")) {
428
440
  const tokenId = key.slice(1);
429
441
  await this.putToStore(STORE_TOKENS, tokenId, { id: tokenId, data: value });
442
+ } else if (key.startsWith("archived-")) {
443
+ await this.putToStore(STORE_TOKENS, key, { id: key, data: value });
430
444
  }
431
445
  }
432
446
  if (data._tombstones) {
@@ -2822,6 +2836,9 @@ function resolveArrayConfig(defaults, replace, additional) {
2822
2836
  }
2823
2837
 
2824
2838
  // impl/browser/index.ts
2839
+ if (typeof globalThis.Buffer === "undefined") {
2840
+ globalThis.Buffer = Buffer3;
2841
+ }
2825
2842
  function resolveIpfsSyncConfig(network, config) {
2826
2843
  if (!config) return void 0;
2827
2844
  const networkConfig = getNetworkConfig(network);