@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.cjs
CHANGED
|
@@ -24468,6 +24468,14 @@ function signedAuthorityFromCompactUcan(authorization) {
|
|
|
24468
24468
|
if (typeof payload.aud !== "string" || payload.aud.length === 0) {
|
|
24469
24469
|
throw new Error("Validated runtime delegation is missing a signed audience.");
|
|
24470
24470
|
}
|
|
24471
|
+
if (typeof payload.iss !== "string" || payload.iss.length === 0) {
|
|
24472
|
+
throw new Error("Validated runtime delegation is missing a signed issuer.");
|
|
24473
|
+
}
|
|
24474
|
+
if (!Array.isArray(payload.prf) || payload.prf.some(
|
|
24475
|
+
(proof) => typeof proof !== "string" || proof.length === 0
|
|
24476
|
+
)) {
|
|
24477
|
+
throw new Error("Validated runtime delegation has malformed signed proofs.");
|
|
24478
|
+
}
|
|
24471
24479
|
if (typeof payload.exp !== "number" || !Number.isFinite(payload.exp)) {
|
|
24472
24480
|
throw new Error("Validated runtime delegation is missing a signed expiry.");
|
|
24473
24481
|
}
|
|
@@ -24478,6 +24486,11 @@ function signedAuthorityFromCompactUcan(authorization) {
|
|
|
24478
24486
|
if (payload.att === null || typeof payload.att !== "object" || Array.isArray(payload.att)) {
|
|
24479
24487
|
throw new Error("Validated runtime delegation is missing a signed attenuation.");
|
|
24480
24488
|
}
|
|
24489
|
+
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;
|
|
24490
|
+
const remainingRedelegationDepth = fact?.remainingRedelegationDepth;
|
|
24491
|
+
if (remainingRedelegationDepth !== void 0 && (!Number.isInteger(remainingRedelegationDepth) || remainingRedelegationDepth < 0 || remainingRedelegationDepth > 8)) {
|
|
24492
|
+
throw new Error("Validated runtime delegation has invalid signed redelegation depth.");
|
|
24493
|
+
}
|
|
24481
24494
|
const permissions = [];
|
|
24482
24495
|
for (const [resource, abilities] of Object.entries(payload.att)) {
|
|
24483
24496
|
if (abilities === null || typeof abilities !== "object" || Array.isArray(abilities)) {
|
|
@@ -24528,8 +24541,11 @@ function signedAuthorityFromCompactUcan(authorization) {
|
|
|
24528
24541
|
...permission.caveats === void 0 ? {} : { caveats: permission.caveats }
|
|
24529
24542
|
}));
|
|
24530
24543
|
return {
|
|
24544
|
+
issuer: payload.iss,
|
|
24531
24545
|
audience: payload.aud,
|
|
24532
24546
|
expiry,
|
|
24547
|
+
proofs: [...payload.prf],
|
|
24548
|
+
...remainingRedelegationDepth === void 0 ? {} : { remainingRedelegationDepth },
|
|
24533
24549
|
permissions: canonicalPermissions,
|
|
24534
24550
|
resources: canonicalResources
|
|
24535
24551
|
};
|
|
@@ -24620,6 +24636,13 @@ async function activateValidatedRuntimeDelegation(node, delegation, options) {
|
|
|
24620
24636
|
delegationHeader: { Authorization: authorization },
|
|
24621
24637
|
ownerAddress: delegation.ownerAddress,
|
|
24622
24638
|
chainId: delegation.chainId,
|
|
24639
|
+
delegatorDID: signed2.issuer,
|
|
24640
|
+
...signed2.proofs.length === 1 ? { parentCid: signed2.proofs[0] } : {},
|
|
24641
|
+
...signed2.remainingRedelegationDepth === void 0 ? {} : {
|
|
24642
|
+
allowSubDelegation: signed2.remainingRedelegationDepth > 0,
|
|
24643
|
+
disableSubDelegation: signed2.remainingRedelegationDepth === 0
|
|
24644
|
+
},
|
|
24645
|
+
authHeader: authorization,
|
|
24623
24646
|
spaceId: signedSpace ?? delegation.spaceId,
|
|
24624
24647
|
path: primary.path,
|
|
24625
24648
|
actions: [...primary.actions],
|