import { fetchListTrustSource, verifyJws } from "@tamga-network/trust";
import { BranchRegistry, BranchSet, createPresentationRequest, dcqlFromPolicy } from "@tamga-network/verifier";
// 1. Load the trust lists (root fingerprint: tamga.network/trust-anchor)
const { source: trust } = await fetchListTrustSource("https://trust.tamga.network", http, {
rootFingerprints: [ROOT_FINGERPRINT],
verifyJws,
});
// 2. Open the presentation, show it as a QR code (no shared request object)
const registry = new BranchRegistry();
const content = { signer, dcql: dcqlFromPolicy(AGE_OVER_18_POLICY), responseUri };
const req = await createPresentationRequest({ ...content, requestUriBase });
const branches = new BranchSet({ registry, presentationId: req.presentationId, expiresAt: req.expiresAt, content });
show(req.qrPayload);
// 3. Every fetch of request_uri is a new branch: fresh state, nonce and key
app.get("/vp/req/:id", async (_, res) => {
const f = await branches.fetch();
if (f.ok) res.type("application/oauth-authz-req+jwt").send(f.requestJwt);
});