@tinycloud/cli 0.9.1-beta.2 → 0.9.1-beta.3
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 +12 -22
- package/dist/index.js.map +1 -1
- package/dist/legacy-entry.js +4 -11
- package/dist/legacy-entry.js.map +1 -1
- package/package.json +5 -5
package/dist/legacy-entry.js
CHANGED
|
@@ -18036,9 +18036,9 @@ function verifyCompactUcanAuthorization(authorization, expectedCid) {
|
|
|
18036
18036
|
const segments = authorization.split(".");
|
|
18037
18037
|
if (segments.length !== 3 || segments.some((segment) => segment.length === 0)) throw new TypeError("compact Authorization must contain three segments");
|
|
18038
18038
|
const [headerSegment, payloadSegment, signatureSegment] = segments;
|
|
18039
|
-
const headerBytes =
|
|
18040
|
-
const payloadBytes =
|
|
18041
|
-
const signature =
|
|
18039
|
+
const headerBytes = fromBase64Url(headerSegment);
|
|
18040
|
+
const payloadBytes = fromBase64Url(payloadSegment);
|
|
18041
|
+
const signature = fromBase64Url(signatureSegment);
|
|
18042
18042
|
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
18043
18043
|
const header = JSON.parse(decoder.decode(headerBytes));
|
|
18044
18044
|
const payload = JSON.parse(decoder.decode(payloadBytes));
|
|
@@ -18051,7 +18051,7 @@ function verifyCompactUcanAuthorization(authorization, expectedCid) {
|
|
|
18051
18051
|
if (typeof payload.iss !== "string" || typeof payload.aud !== "string" || typeof payload.nnc !== "string" || !Number.isInteger(payload.nbf) || !Number.isInteger(payload.exp) || payload.nbf >= payload.exp || !Array.isArray(payload.prf) || payload.prf.some((proof) => typeof proof !== "string") || !Array.isArray(payload.fct) || payload.fct.length !== 1) throw new TypeError("compact Authorization payload is invalid");
|
|
18052
18052
|
const principal = payload.iss.split("#", 1)[0];
|
|
18053
18053
|
const publicKey = ed25519PublicKeyFromDidKey(principal);
|
|
18054
|
-
if (!equal(publicKey,
|
|
18054
|
+
if (!equal(publicKey, fromBase64Url(jwk.x))) throw new TypeError("compact Authorization JWK does not bind issuer");
|
|
18055
18055
|
if (!ed25519.verify(signature, new TextEncoder().encode(`${headerSegment}.${payloadSegment}`), publicKey, { zip215: false })) throw new TypeError("compact Authorization signature is invalid");
|
|
18056
18056
|
const cid2 = CID.createV1(85, create(30, blake3(new TextEncoder().encode(authorization)))).toString();
|
|
18057
18057
|
if (expectedCid !== void 0 && cid2 !== expectedCid) throw new TypeError("compact Authorization CID mismatch");
|
|
@@ -18064,13 +18064,6 @@ function object(value, label) {
|
|
|
18064
18064
|
function assertExactKeys(value, keys, label) {
|
|
18065
18065
|
if (Object.keys(value).length !== keys.length || Object.keys(value).some((key) => !keys.includes(key))) throw new TypeError(`${label} has unknown or missing fields`);
|
|
18066
18066
|
}
|
|
18067
|
-
function decodeBase64Url(value) {
|
|
18068
|
-
if (!/^[A-Za-z0-9_-]+$/.test(value) || value.length % 4 === 1) throw new TypeError("compact Authorization segment is not base64url");
|
|
18069
|
-
const bytes3 = typeof Buffer !== "undefined" ? new Uint8Array(Buffer.from(value, "base64url")) : Uint8Array.from(atob(value.replace(/-/g, "+").replace(/_/g, "/").padEnd(Math.ceil(value.length / 4) * 4, "=")), (character) => character.charCodeAt(0));
|
|
18070
|
-
const encoded = typeof Buffer !== "undefined" ? Buffer.from(bytes3).toString("base64url") : btoa(String.fromCharCode(...bytes3)).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
18071
|
-
if (encoded !== value) throw new TypeError("compact Authorization segment is not canonical");
|
|
18072
|
-
return bytes3;
|
|
18073
|
-
}
|
|
18074
18067
|
function equal(left, right) {
|
|
18075
18068
|
return left.length === right.length && left.every((byte, index) => byte === right[index]);
|
|
18076
18069
|
}
|