@tinycloud/node-sdk 2.11.0-beta.11 → 2.11.0-beta.12
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.map +1 -1
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +23 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -24502,6 +24502,14 @@ function signedAuthorityFromCompactUcan(authorization) {
|
|
|
24502
24502
|
if (typeof payload.aud !== "string" || payload.aud.length === 0) {
|
|
24503
24503
|
throw new Error("Validated runtime delegation is missing a signed audience.");
|
|
24504
24504
|
}
|
|
24505
|
+
if (typeof payload.iss !== "string" || payload.iss.length === 0) {
|
|
24506
|
+
throw new Error("Validated runtime delegation is missing a signed issuer.");
|
|
24507
|
+
}
|
|
24508
|
+
if (!Array.isArray(payload.prf) || payload.prf.some(
|
|
24509
|
+
(proof) => typeof proof !== "string" || proof.length === 0
|
|
24510
|
+
)) {
|
|
24511
|
+
throw new Error("Validated runtime delegation has malformed signed proofs.");
|
|
24512
|
+
}
|
|
24505
24513
|
if (typeof payload.exp !== "number" || !Number.isFinite(payload.exp)) {
|
|
24506
24514
|
throw new Error("Validated runtime delegation is missing a signed expiry.");
|
|
24507
24515
|
}
|
|
@@ -24512,6 +24520,11 @@ function signedAuthorityFromCompactUcan(authorization) {
|
|
|
24512
24520
|
if (payload.att === null || typeof payload.att !== "object" || Array.isArray(payload.att)) {
|
|
24513
24521
|
throw new Error("Validated runtime delegation is missing a signed attenuation.");
|
|
24514
24522
|
}
|
|
24523
|
+
const fact = Array.isArray(payload.fct) && payload.fct.length > 0 && payload.fct[0] !== null && typeof payload.fct[0] === "object" && !Array.isArray(payload.fct[0]) ? payload.fct[0] : void 0;
|
|
24524
|
+
const remainingRedelegationDepth = fact?.remainingRedelegationDepth;
|
|
24525
|
+
if (remainingRedelegationDepth !== void 0 && (!Number.isInteger(remainingRedelegationDepth) || remainingRedelegationDepth < 0 || remainingRedelegationDepth > 8)) {
|
|
24526
|
+
throw new Error("Validated runtime delegation has invalid signed redelegation depth.");
|
|
24527
|
+
}
|
|
24515
24528
|
const permissions = [];
|
|
24516
24529
|
for (const [resource, abilities] of Object.entries(payload.att)) {
|
|
24517
24530
|
if (abilities === null || typeof abilities !== "object" || Array.isArray(abilities)) {
|
|
@@ -24562,8 +24575,11 @@ function signedAuthorityFromCompactUcan(authorization) {
|
|
|
24562
24575
|
...permission.caveats === void 0 ? {} : { caveats: permission.caveats }
|
|
24563
24576
|
}));
|
|
24564
24577
|
return {
|
|
24578
|
+
issuer: payload.iss,
|
|
24565
24579
|
audience: payload.aud,
|
|
24566
24580
|
expiry,
|
|
24581
|
+
proofs: [...payload.prf],
|
|
24582
|
+
...remainingRedelegationDepth === void 0 ? {} : { remainingRedelegationDepth },
|
|
24567
24583
|
permissions: canonicalPermissions,
|
|
24568
24584
|
resources: canonicalResources
|
|
24569
24585
|
};
|
|
@@ -24654,6 +24670,13 @@ async function activateValidatedRuntimeDelegation(node, delegation, options) {
|
|
|
24654
24670
|
delegationHeader: { Authorization: authorization },
|
|
24655
24671
|
ownerAddress: delegation.ownerAddress,
|
|
24656
24672
|
chainId: delegation.chainId,
|
|
24673
|
+
delegatorDID: signed2.issuer,
|
|
24674
|
+
...signed2.proofs.length === 1 ? { parentCid: signed2.proofs[0] } : {},
|
|
24675
|
+
...signed2.remainingRedelegationDepth === void 0 ? {} : {
|
|
24676
|
+
allowSubDelegation: signed2.remainingRedelegationDepth > 0,
|
|
24677
|
+
disableSubDelegation: signed2.remainingRedelegationDepth === 0
|
|
24678
|
+
},
|
|
24679
|
+
authHeader: authorization,
|
|
24657
24680
|
spaceId: signedSpace ?? delegation.spaceId,
|
|
24658
24681
|
path: primary.path,
|
|
24659
24682
|
actions: [...primary.actions],
|