@tinycloud/node-sdk 3.0.0-beta.15 → 3.0.0-beta.16

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/core.cjs CHANGED
@@ -2286,6 +2286,22 @@ function cloneRecapCaveats(caveats) {
2286
2286
  throw new Error("Verified persisted session ReCap contains invalid caveats.");
2287
2287
  }
2288
2288
  }
2289
+ function jsonFromVerifier(value) {
2290
+ if (value === void 0) return null;
2291
+ if (Array.isArray(value)) return value.map(jsonFromVerifier);
2292
+ if (value instanceof Map) {
2293
+ const entries = [...value.entries()];
2294
+ if (!entries.every(([key]) => typeof key === "string")) return value;
2295
+ return Object.fromEntries(entries.map(([key, nested]) => [key, jsonFromVerifier(nested)]));
2296
+ }
2297
+ if (value !== null && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) {
2298
+ return Object.fromEntries(Object.entries(value).map(([key, nested]) => [key, jsonFromVerifier(nested)]));
2299
+ }
2300
+ return value;
2301
+ }
2302
+ function verifierRecapEntries(entries) {
2303
+ return entries.map((entry) => Array.isArray(entry.caveats) ? { ...entry, caveats: entry.caveats.map((caveat) => jsonFromVerifier(caveat)) } : entry);
2304
+ }
2289
2305
  var ServiceGraphLifetime = class {
2290
2306
  constructor(invokeFn, invokeAnyFn, fetchFn) {
2291
2307
  this.invokeFn = invokeFn;
@@ -3901,7 +3917,7 @@ var _TinyCloudNode = class _TinyCloudNode {
3901
3917
  throw new InvalidRestoredSessionError(error instanceof Error ? error.message : String(error));
3902
3918
  }
3903
3919
  })();
3904
- const exactRecap = verified.verifiedRecap;
3920
+ const exactRecap = Array.isArray(verified.verifiedRecap) ? verifierRecapEntries(verified.verifiedRecap) : verified.verifiedRecap;
3905
3921
  if (!Array.isArray(exactRecap) || !exactRecap.every(
3906
3922
  (entry) => entry !== null && typeof entry === "object" && typeof entry.service === "string" && typeof entry.space === "string" && typeof entry.path === "string" && Array.isArray(entry.actions) && entry.actions.every((action) => typeof action === "string") && Array.isArray(entry.caveats) && entry.caveats.every(
3907
3923
  (caveat) => caveat !== null && typeof caveat === "object" && !Array.isArray(caveat)
@@ -6909,7 +6925,8 @@ var _TinyCloudNode = class _TinyCloudNode {
6909
6925
  }
6910
6926
  /** Prefer the v2 caveat-preserving parser while retaining old custom WASM. */
6911
6927
  parseRecapWithCaveats(siwe) {
6912
- return this.wasmBindings.parseVerifiedRecapFromSiwe?.(siwe) ?? this.wasmBindings.parseRecapFromSiwe(siwe);
6928
+ const verified = this.wasmBindings.parseVerifiedRecapFromSiwe?.(siwe);
6929
+ return verified == null ? this.wasmBindings.parseRecapFromSiwe(siwe) : verifierRecapEntries(verified);
6913
6930
  }
6914
6931
  isEncryptionNetworkOperation(service, path) {
6915
6932
  return service === "encryption" && path.startsWith("urn:tinycloud:encryption:");