import init, { QuoteVerifier } from "/pkg/web/dcap-qvl-web.js";
async function fetchFileAsUint8Array(url) {
const response = await fetch(url);
const data = await response.arrayBuffer();
return new Uint8Array(data);
}
const rawQuoteUrl = "/sample/tdx_quote";
async function getCollateral() {
try {
await init("/pkg/web/dcap-qvl-web_bg.wasm");
const rawQuote = await fetchFileAsUint8Array(rawQuoteUrl);
let pccs_url = "https://pccs.phala.network/tdx/certification/v4";
const result = await QuoteVerifier.get_collateral(pccs_url, rawQuote);
console.log("Collateral Result:", result);
} catch (error) {
console.error("Get collateral failed:", error);
}
}
getCollateral();