@unicitylabs/sphere-sdk 0.1.6 → 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.
@@ -348,10 +348,18 @@ var FileTokenStorageProvider = class {
348
348
  const files = fs2.readdirSync(this.tokensDir).filter((f) => f.endsWith(".json") && f !== "_meta.json");
349
349
  for (const file of files) {
350
350
  try {
351
+ const basename2 = path2.basename(file, ".json");
352
+ if (basename2.startsWith("token-") || basename2.startsWith("nametag-")) {
353
+ continue;
354
+ }
351
355
  const content = fs2.readFileSync(path2.join(this.tokensDir, file), "utf-8");
352
356
  const token = JSON.parse(content);
353
- const key = `_${path2.basename(file, ".json")}`;
354
- data[key] = token;
357
+ if (basename2.startsWith("archived-")) {
358
+ data[basename2] = token;
359
+ } else {
360
+ const key = `_${basename2}`;
361
+ data[key] = token;
362
+ }
355
363
  } catch {
356
364
  }
357
365
  }
@@ -376,13 +384,20 @@ var FileTokenStorageProvider = class {
376
384
  path2.join(this.tokensDir, "_meta.json"),
377
385
  JSON.stringify(data._meta, null, 2)
378
386
  );
387
+ const reservedKeys = ["_meta", "_tombstones", "_outbox", "_sent", "_invalid"];
379
388
  for (const [key, value] of Object.entries(data)) {
380
- if (key.startsWith("_") && key !== "_meta" && key !== "_tombstones" && key !== "_outbox" && key !== "_sent" && key !== "_invalid") {
389
+ if (reservedKeys.includes(key)) continue;
390
+ if (key.startsWith("_")) {
381
391
  const tokenId = key.slice(1);
382
392
  fs2.writeFileSync(
383
393
  path2.join(this.tokensDir, `${tokenId}.json`),
384
394
  JSON.stringify(value, null, 2)
385
395
  );
396
+ } else if (key.startsWith("archived-")) {
397
+ fs2.writeFileSync(
398
+ path2.join(this.tokensDir, `${key}.json`),
399
+ JSON.stringify(value, null, 2)
400
+ );
386
401
  }
387
402
  }
388
403
  if (data._tombstones) {