@tinycloud/node-sdk 3.0.0-beta.15 → 3.0.0-beta.17
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 +19 -2
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +19 -2
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +19 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/core.js
CHANGED
|
@@ -2289,6 +2289,22 @@ function cloneRecapCaveats(caveats) {
|
|
|
2289
2289
|
throw new Error("Verified persisted session ReCap contains invalid caveats.");
|
|
2290
2290
|
}
|
|
2291
2291
|
}
|
|
2292
|
+
function jsonFromVerifier(value) {
|
|
2293
|
+
if (value === void 0) return null;
|
|
2294
|
+
if (Array.isArray(value)) return value.map(jsonFromVerifier);
|
|
2295
|
+
if (value instanceof Map) {
|
|
2296
|
+
const entries = [...value.entries()];
|
|
2297
|
+
if (!entries.every(([key]) => typeof key === "string")) return value;
|
|
2298
|
+
return Object.fromEntries(entries.map(([key, nested]) => [key, jsonFromVerifier(nested)]));
|
|
2299
|
+
}
|
|
2300
|
+
if (value !== null && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) {
|
|
2301
|
+
return Object.fromEntries(Object.entries(value).map(([key, nested]) => [key, jsonFromVerifier(nested)]));
|
|
2302
|
+
}
|
|
2303
|
+
return value;
|
|
2304
|
+
}
|
|
2305
|
+
function verifierRecapEntries(entries) {
|
|
2306
|
+
return entries.map((entry) => Array.isArray(entry.caveats) ? { ...entry, caveats: entry.caveats.map((caveat) => jsonFromVerifier(caveat)) } : entry);
|
|
2307
|
+
}
|
|
2292
2308
|
var ServiceGraphLifetime = class {
|
|
2293
2309
|
constructor(invokeFn, invokeAnyFn, fetchFn) {
|
|
2294
2310
|
this.invokeFn = invokeFn;
|
|
@@ -3904,7 +3920,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3904
3920
|
throw new InvalidRestoredSessionError(error instanceof Error ? error.message : String(error));
|
|
3905
3921
|
}
|
|
3906
3922
|
})();
|
|
3907
|
-
const exactRecap = verified.verifiedRecap;
|
|
3923
|
+
const exactRecap = Array.isArray(verified.verifiedRecap) ? verifierRecapEntries(verified.verifiedRecap) : verified.verifiedRecap;
|
|
3908
3924
|
if (!Array.isArray(exactRecap) || !exactRecap.every(
|
|
3909
3925
|
(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(
|
|
3910
3926
|
(caveat) => caveat !== null && typeof caveat === "object" && !Array.isArray(caveat)
|
|
@@ -6912,7 +6928,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6912
6928
|
}
|
|
6913
6929
|
/** Prefer the v2 caveat-preserving parser while retaining old custom WASM. */
|
|
6914
6930
|
parseRecapWithCaveats(siwe) {
|
|
6915
|
-
|
|
6931
|
+
const verified = this.wasmBindings.parseVerifiedRecapFromSiwe?.(siwe);
|
|
6932
|
+
return verified == null ? this.wasmBindings.parseRecapFromSiwe(siwe) : verifierRecapEntries(verified);
|
|
6916
6933
|
}
|
|
6917
6934
|
isEncryptionNetworkOperation(service, path) {
|
|
6918
6935
|
return service === "encryption" && path.startsWith("urn:tinycloud:encryption:");
|