@tinycloud/cli 0.9.1-beta.0 → 0.9.1-beta.2
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/index.js +137 -23
- package/dist/index.js.map +1 -1
- package/dist/legacy-entry.js +20 -7
- package/dist/legacy-entry.js.map +1 -1
- package/package.json +5 -5
package/dist/legacy-entry.js
CHANGED
|
@@ -17687,7 +17687,7 @@ function validateV3Invariants(value, ctx) {
|
|
|
17687
17687
|
if (value.contentSource.encryptionNetwork !== value.encryptionNetwork) {
|
|
17688
17688
|
ctx.addIssue({ code: external_exports2.ZodIssueCode.custom, path: ["encryptionNetwork"], message: "encryption network is not bound to the source" });
|
|
17689
17689
|
}
|
|
17690
|
-
if (value.attestedEnforcerBinding.enforcerDid !== value.target.nodeAudience || value.attestedEnforcerBinding.
|
|
17690
|
+
if (value.attestedEnforcerBinding.enforcerDid !== value.target.nodeAudience || value.attestedEnforcerBinding.signature.signerDid !== value.attestedEnforcerBinding.nodeAudience || Date.parse(value.attestedEnforcerBinding.expiresAt) < Date.parse(value.expiry)) {
|
|
17691
17691
|
ctx.addIssue({ code: external_exports2.ZodIssueCode.custom, path: ["attestedEnforcerBinding"], message: "enforcer binding does not cover the target and share lifetime" });
|
|
17692
17692
|
}
|
|
17693
17693
|
if (value.policy.contentSource.shareId !== value.contentSource.shareId || value.policy.contentSource.kvResource !== value.contentSource.kvResource || value.policy.contentSource.selector !== value.contentSource.selector || value.policy.contentSource.encryptionNetwork !== value.encryptionNetwork || value.policy.contentSource.encryptedSymmetricKeyDigestHex !== value.contentSource.encryptedSymmetricKeyDigestHex || value.policy.contentSource.keyVersion !== value.contentSource.keyVersion || value.policy.contentSource.mode !== value.contentSource.mode || value.policy.contentSource.initialCiphertextDigestHex !== value.contentSource.initialCiphertextDigestHex) {
|
|
@@ -18190,10 +18190,10 @@ async function verifyEnvelopeV3(envelope, options) {
|
|
|
18190
18190
|
const binding = parsed.attestedEnforcerBinding;
|
|
18191
18191
|
const { signature: bindingSignature, ...unsignedBinding } = binding;
|
|
18192
18192
|
const expectedBindingDigestHex = hex(sha2562(new TextEncoder().encode(canonicalize2({ enforcerDid: binding.enforcerDid, nodeAudience: binding.nodeAudience }))));
|
|
18193
|
-
if (binding.enforcerDid !== parsed.target.nodeAudience || binding.
|
|
18193
|
+
if (binding.enforcerDid !== parsed.target.nodeAudience || binding.attestationBindingDigestHex !== expectedBindingDigestHex || bindingSignature.signerDid !== binding.nodeAudience || bindingSignature.suite !== "Ed25519" || Date.parse(binding.issuedAt) > Date.now() || Date.parse(binding.expiresAt) <= Date.now() || Date.parse(binding.expiresAt) < Date.parse(parsed.expiry)) return false;
|
|
18194
18194
|
try {
|
|
18195
18195
|
const digest4 = sha2562(new TextEncoder().encode(`${ATTESTED_ENFORCER_V2_DOMAIN}${canonicalize2(unsignedBinding)}`));
|
|
18196
|
-
if (!ed25519.verify(fromBase64Url(bindingSignature.value), digest4, ed25519PublicKeyFromDidKey(binding.
|
|
18196
|
+
if (!ed25519.verify(fromBase64Url(bindingSignature.value), digest4, ed25519PublicKeyFromDidKey(binding.nodeAudience), ED25519_VERIFY_OPTS2)) return false;
|
|
18197
18197
|
} catch {
|
|
18198
18198
|
return false;
|
|
18199
18199
|
}
|
|
@@ -18206,7 +18206,7 @@ async function verifyEnvelopeV3(envelope, options) {
|
|
|
18206
18206
|
const common = ["ownerDid", "policyId", "policyDigestHex", "policyCid", "contentSourceDigestHex", "capabilityCeilingHashHex", "nativeProjectionHashHex", "nodeAudience"];
|
|
18207
18207
|
const policyKeys = [...common, "role", "mode"];
|
|
18208
18208
|
const enforcementKeys = [...policyKeys, "enforcerDid"];
|
|
18209
|
-
if (Object.keys(policyFact).length !== policyKeys.length || policyKeys.some((key) => !(key in policyFact)) || Object.keys(enforcementFact).length !== enforcementKeys.length || enforcementKeys.some((key) => !(key in enforcementFact)) || policyRoot.payload.prf.length !== 0 || enforcementRoot.payload.prf.length !== 0 || policyRoot.payload.iss.split("#", 1)[0] !== policy.ownerDid || enforcementRoot.payload.iss.split("#", 1)[0] !== policy.ownerDid || policyRoot.payload.nbf !== enforcementRoot.payload.nbf || policyRoot.payload.exp !== enforcementRoot.payload.exp || canonicalize2(policyRoot.payload.att) !== canonicalize2(expectedAttenuation) || canonicalize2(enforcementRoot.payload.att) !== canonicalize2(expectedAttenuation) || policyFact.role !== "policy-authority" || policyFact.mode !== "policy-source" || "enforcerDid" in policyFact || enforcementFact.role !== "policy-enforcement" || enforcementFact.mode !== "conditional-mint" || policyRoot.payload.aud !== `did:tinycloud:policy:${hex(policyIdDigest)}` || enforcementRoot.payload.aud !==
|
|
18209
|
+
if (Object.keys(policyFact).length !== policyKeys.length || policyKeys.some((key) => !(key in policyFact)) || Object.keys(enforcementFact).length !== enforcementKeys.length || enforcementKeys.some((key) => !(key in enforcementFact)) || policyRoot.payload.prf.length !== 0 || enforcementRoot.payload.prf.length !== 0 || policyRoot.payload.iss.split("#", 1)[0] !== policy.ownerDid || enforcementRoot.payload.iss.split("#", 1)[0] !== policy.ownerDid || policyRoot.payload.nbf !== enforcementRoot.payload.nbf || policyRoot.payload.exp !== enforcementRoot.payload.exp || canonicalize2(policyRoot.payload.att) !== canonicalize2(expectedAttenuation) || canonicalize2(enforcementRoot.payload.att) !== canonicalize2(expectedAttenuation) || policyFact.role !== "policy-authority" || policyFact.mode !== "policy-source" || "enforcerDid" in policyFact || enforcementFact.role !== "policy-enforcement" || enforcementFact.mode !== "conditional-mint" || policyRoot.payload.aud !== `did:tinycloud:policy:${hex(policyIdDigest)}` || enforcementRoot.payload.aud !== binding.enforcerDid || enforcementFact.enforcerDid !== binding.enforcerDid || common.some((key) => policyFact[key] !== enforcementFact[key]) || policyFact.ownerDid !== policy.ownerDid || policyFact.policyId !== policy.policyId || policyFact.policyDigestHex !== hex(policyIdDigest) || policyFact.policyCid !== parsed.policyCid || policyFact.contentSourceDigestHex !== parsed.contentSourceDigestHex || policyFact.capabilityCeilingHashHex !== capabilityCeilingHashHex || policyFact.nativeProjectionHashHex !== nativeProjectionHashHex || policyFact.nodeAudience !== binding.nodeAudience || policyRoot.payload.exp * 1e3 < Date.parse(parsed.expiry)) return false;
|
|
18210
18210
|
} catch {
|
|
18211
18211
|
return false;
|
|
18212
18212
|
}
|
|
@@ -18388,8 +18388,12 @@ async function readResponseBytes(response, limit, tooLargeCode) {
|
|
|
18388
18388
|
function registryFetcher(options, limit, tooLargeCode = "max-bytes-exceeded", stage = "envelope") {
|
|
18389
18389
|
if (options.fetchBlob !== void 0) return async (input) => {
|
|
18390
18390
|
try {
|
|
18391
|
-
|
|
18391
|
+
options.signal?.throwIfAborted();
|
|
18392
|
+
const bytes3 = await options.fetchBlob({ ...input, ...options.signal === void 0 ? {} : { signal: options.signal } });
|
|
18393
|
+
options.signal?.throwIfAborted();
|
|
18394
|
+
return boundedBytes(bytes3, limit, tooLargeCode);
|
|
18392
18395
|
} catch (error) {
|
|
18396
|
+
if (options.signal?.aborted) throw options.signal.reason ?? error;
|
|
18393
18397
|
if (error instanceof ShareReceiveError) throw error;
|
|
18394
18398
|
throw new ShareReceiveError("fetch-failed", "registry unavailable", { stage });
|
|
18395
18399
|
}
|
|
@@ -18399,10 +18403,19 @@ function registryFetcher(options, limit, tooLargeCode = "max-bytes-exceeded", st
|
|
|
18399
18403
|
const base33 = options.registryBaseUrl.replace(/\/+$/, "");
|
|
18400
18404
|
return async ({ cid: cid2 }) => {
|
|
18401
18405
|
try {
|
|
18402
|
-
|
|
18406
|
+
options.signal?.throwIfAborted();
|
|
18407
|
+
const response = await fetchFn(`${base33}/ipfs/${cid2}?format=raw`, {
|
|
18408
|
+
headers: { accept: "application/vnd.ipld.raw" },
|
|
18409
|
+
redirect: "error",
|
|
18410
|
+
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
18411
|
+
});
|
|
18412
|
+
options.signal?.throwIfAborted();
|
|
18403
18413
|
if (!response.ok) throw new ShareReceiveError("fetch-failed", `registry returned ${response.status}`, { stage });
|
|
18404
|
-
|
|
18414
|
+
const bytes3 = await readResponseBytes(response, limit, tooLargeCode);
|
|
18415
|
+
options.signal?.throwIfAborted();
|
|
18416
|
+
return bytes3;
|
|
18405
18417
|
} catch (error) {
|
|
18418
|
+
if (options.signal?.aborted) throw options.signal.reason ?? error;
|
|
18406
18419
|
if (error instanceof ShareReceiveError) throw error;
|
|
18407
18420
|
throw new ShareReceiveError("fetch-failed", "registry unavailable", { stage });
|
|
18408
18421
|
}
|