@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.
@@ -299,10 +299,18 @@ var FileTokenStorageProvider = class {
299
299
  const files = fs2.readdirSync(this.tokensDir).filter((f) => f.endsWith(".json") && f !== "_meta.json");
300
300
  for (const file of files) {
301
301
  try {
302
+ const basename2 = path2.basename(file, ".json");
303
+ if (basename2.startsWith("token-") || basename2.startsWith("nametag-")) {
304
+ continue;
305
+ }
302
306
  const content = fs2.readFileSync(path2.join(this.tokensDir, file), "utf-8");
303
307
  const token = JSON.parse(content);
304
- const key = `_${path2.basename(file, ".json")}`;
305
- data[key] = token;
308
+ if (basename2.startsWith("archived-")) {
309
+ data[basename2] = token;
310
+ } else {
311
+ const key = `_${basename2}`;
312
+ data[key] = token;
313
+ }
306
314
  } catch {
307
315
  }
308
316
  }
@@ -327,13 +335,20 @@ var FileTokenStorageProvider = class {
327
335
  path2.join(this.tokensDir, "_meta.json"),
328
336
  JSON.stringify(data._meta, null, 2)
329
337
  );
338
+ const reservedKeys = ["_meta", "_tombstones", "_outbox", "_sent", "_invalid"];
330
339
  for (const [key, value] of Object.entries(data)) {
331
- if (key.startsWith("_") && key !== "_meta" && key !== "_tombstones" && key !== "_outbox" && key !== "_sent" && key !== "_invalid") {
340
+ if (reservedKeys.includes(key)) continue;
341
+ if (key.startsWith("_")) {
332
342
  const tokenId = key.slice(1);
333
343
  fs2.writeFileSync(
334
344
  path2.join(this.tokensDir, `${tokenId}.json`),
335
345
  JSON.stringify(value, null, 2)
336
346
  );
347
+ } else if (key.startsWith("archived-")) {
348
+ fs2.writeFileSync(
349
+ path2.join(this.tokensDir, `${key}.json`),
350
+ JSON.stringify(value, null, 2)
351
+ );
337
352
  }
338
353
  }
339
354
  if (data._tombstones) {