@calimero-network/mero-js 27.3.0 → 27.4.0
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/README.md +1 -1
- package/dist/cloud-v2/attestation.d.ts +20 -3
- package/dist/cloud-v2/attestation.js +33 -3
- package/dist/cloud-v2/index.d.ts +1 -1
- package/dist/cloud-v2/index.js +1 -1
- package/dist/index.browser.mjs +3 -3
- package/dist/index.browser.mjs.map +3 -3
- package/dist/index.cjs +32 -1
- package/dist/index.cjs.map +3 -3
- package/dist/index.mjs +32 -1
- package/dist/index.mjs.map +3 -3
- package/dist/sealed/index.d.ts +1 -1
- package/dist/sealed/index.js +1 -1
- package/dist/sealed/release.d.ts +6 -0
- package/dist/sealed/release.js +6 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -39,6 +39,7 @@ __export(index_exports, {
|
|
|
39
39
|
ConfirmCancelled: () => ConfirmCancelled,
|
|
40
40
|
ConfirmRequired: () => ConfirmRequired,
|
|
41
41
|
ConsentStale: () => ConsentStale,
|
|
42
|
+
DEFAULT_COLLATERAL_MIRROR: () => DEFAULT_COLLATERAL_MIRROR,
|
|
42
43
|
DEFAULT_ORG_CAPABILITIES: () => DEFAULT_ORG_CAPABILITIES,
|
|
43
44
|
DEFAULT_RELEASE_MIRROR: () => DEFAULT_RELEASE_MIRROR,
|
|
44
45
|
GITHUB_RELEASES: () => GITHUB_RELEASES,
|
|
@@ -79,6 +80,7 @@ __export(index_exports, {
|
|
|
79
80
|
fetchAttestedKey: () => fetchAttestedKey,
|
|
80
81
|
fetchGithubNodeRelease: () => fetchGithubNodeRelease,
|
|
81
82
|
fetchNodeRelease: () => fetchNodeRelease,
|
|
83
|
+
freshCollateral: () => freshCollateral,
|
|
82
84
|
fromB64url: () => fromB64url,
|
|
83
85
|
generateOwnerKey: () => generateOwnerKey,
|
|
84
86
|
orgCapabilities: () => orgCapabilities,
|
|
@@ -1107,6 +1109,7 @@ var NODE_RELEASE_SIGNER = Object.freeze({
|
|
|
1107
1109
|
});
|
|
1108
1110
|
var MEASUREMENTS = ["mrtd", "rtmr0", "rtmr1", "rtmr2", "rtmr3"];
|
|
1109
1111
|
var DEFAULT_RELEASE_MIRROR = "https://cloud.calimero.network";
|
|
1112
|
+
var DEFAULT_COLLATERAL_MIRROR = `${DEFAULT_RELEASE_MIRROR}/api/tee/pcs`;
|
|
1110
1113
|
async function verifySignedNodeRelease(publishedMrtds, bundle, options = {}) {
|
|
1111
1114
|
const body = typeof publishedMrtds === "string" ? new TextEncoder().encode(publishedMrtds) : publishedMrtds;
|
|
1112
1115
|
await verifyCosignBundle(
|
|
@@ -1271,6 +1274,34 @@ async function releaseFor(version, policy, fetchImpl) {
|
|
|
1271
1274
|
if (source === "github") return fetchGithubNodeRelease(version, { fetch: fetchImpl });
|
|
1272
1275
|
return fetchNodeRelease(cloudNodeReleaseUrl(source ?? DEFAULT_RELEASE_MIRROR, version), { fetch: fetchImpl });
|
|
1273
1276
|
}
|
|
1277
|
+
function defaultCollateral(policy) {
|
|
1278
|
+
const source = policy.collateralSource ?? DEFAULT_COLLATERAL_MIRROR;
|
|
1279
|
+
if (source === "intel") {
|
|
1280
|
+
return async (quote) => (await dcap("getCollateralFromPcs"))(quote);
|
|
1281
|
+
}
|
|
1282
|
+
return async (quote) => (await dcap("getCollateral"))(source, quote);
|
|
1283
|
+
}
|
|
1284
|
+
function freshCollateral(fetch2, policy) {
|
|
1285
|
+
const maxDays = policy.maxCollateralAgeDays;
|
|
1286
|
+
if (maxDays === void 0) return fetch2;
|
|
1287
|
+
return async (quote) => {
|
|
1288
|
+
const collateral = await fetch2(quote);
|
|
1289
|
+
let issued;
|
|
1290
|
+
try {
|
|
1291
|
+
issued = Date.parse(JSON.parse(collateral.tcb_info).issueDate ?? "");
|
|
1292
|
+
} catch {
|
|
1293
|
+
issued = Number.NaN;
|
|
1294
|
+
}
|
|
1295
|
+
if (!Number.isFinite(issued)) throw new Error("The quote's collateral names no TCB info issue date");
|
|
1296
|
+
const ageDays = ((policy.now ?? Date.now)() - issued) / 864e5;
|
|
1297
|
+
if (ageDays > maxDays) {
|
|
1298
|
+
throw new Error(
|
|
1299
|
+
`The quote's collateral was issued ${Math.floor(ageDays)} days ago, more than the ${maxDays} this client accepts`
|
|
1300
|
+
);
|
|
1301
|
+
}
|
|
1302
|
+
return collateral;
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1274
1305
|
async function verifyRelease(doc, args, policy, fetchImpl) {
|
|
1275
1306
|
const version = claimedRelease(doc, policy.minReleaseVersion);
|
|
1276
1307
|
const trusted = await trustSignedRelease({
|
|
@@ -1281,7 +1312,7 @@ async function verifyRelease(doc, args, policy, fetchImpl) {
|
|
|
1281
1312
|
identity: policy.identity,
|
|
1282
1313
|
issuer: policy.issuer
|
|
1283
1314
|
});
|
|
1284
|
-
const fetchCollateral = policy.fetchCollateral ?? (
|
|
1315
|
+
const fetchCollateral = freshCollateral(policy.fetchCollateral ?? defaultCollateral(policy), policy);
|
|
1285
1316
|
const verifier = createQuoteVerifier({
|
|
1286
1317
|
dcapVerify: policy.dcapVerify ?? await dcap("verify"),
|
|
1287
1318
|
fetchCollateral,
|