@t2000/sdk 5.20.0 → 5.20.1

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 CHANGED
@@ -2133,7 +2133,15 @@ async function verifyTdxQuote(base, model, receiptWorkloadId) {
2133
2133
  };
2134
2134
  }
2135
2135
  try {
2136
- const { getCollateralAndVerify } = await import('@phala/dcap-qvl');
2136
+ const dcap = await import('@phala/dcap-qvl');
2137
+ const getCollateralAndVerify = dcap.getCollateralAndVerify ?? dcap.default?.getCollateralAndVerify;
2138
+ if (typeof getCollateralAndVerify !== "function") {
2139
+ return {
2140
+ status: "fail",
2141
+ forged: false,
2142
+ detail: "DCAP verifier unavailable in this build"
2143
+ };
2144
+ }
2137
2145
  const quoteBytes = hexToBytes(quoteHex.replace(/^0x/, ""));
2138
2146
  const vr = await getCollateralAndVerify(quoteBytes);
2139
2147
  const td = vr.report.asTd10() ?? vr.report.asTd15()?.base ?? null;
@@ -2259,7 +2267,6 @@ async function verifyReceipt(receiptId, opts = {}) {
2259
2267
  });
2260
2268
  }
2261
2269
  }
2262
- let signatureForged = false;
2263
2270
  let sigStatus = "skip";
2264
2271
  let sigDetail = "no signature on receipt";
2265
2272
  if (receipt.signature?.value) {
@@ -2276,7 +2283,6 @@ async function verifyReceipt(receiptId, opts = {}) {
2276
2283
  } else {
2277
2284
  const ok = verifyReceiptSignature(receipt, att.signingKey);
2278
2285
  sigStatus = ok ? "pass" : "fail";
2279
- signatureForged = !ok;
2280
2286
  sigDetail = ok ? `signed by the attested receipt key (${receipt.signature.key_id ?? "key"})` : "signature does NOT recover the attested receipt key \u2014 forged/altered";
2281
2287
  }
2282
2288
  } catch {
@@ -2289,7 +2295,6 @@ async function verifyReceipt(receiptId, opts = {}) {
2289
2295
  detail: sigDetail,
2290
2296
  trust: sigStatus === "skip" ? "roadmap" : "trustless"
2291
2297
  });
2292
- let quoteForged = false;
2293
2298
  if (opts.skipQuote) {
2294
2299
  checks.push({
2295
2300
  name: "TDX quote (DCAP)",
@@ -2303,7 +2308,6 @@ async function verifyReceipt(receiptId, opts = {}) {
2303
2308
  opts.model ?? "phala/glm-5.2",
2304
2309
  workloadId ?? ""
2305
2310
  );
2306
- quoteForged = q.forged;
2307
2311
  checks.push({
2308
2312
  name: "TDX quote (DCAP)",
2309
2313
  status: q.status,
@@ -2311,9 +2315,12 @@ async function verifyReceipt(receiptId, opts = {}) {
2311
2315
  trust: "trustless"
2312
2316
  });
2313
2317
  }
2318
+ const trustlessFailed = checks.some(
2319
+ (c) => c.trust === "trustless" && c.status === "fail"
2320
+ );
2314
2321
  return {
2315
2322
  receiptId,
2316
- verified: Boolean(wireHash && workloadId) && anchorVerified && !signatureForged && !quoteForged,
2323
+ verified: Boolean(wireHash && workloadId) && !trustlessFailed,
2317
2324
  anchorVerified,
2318
2325
  checks,
2319
2326
  wireHash,