import { fetchListTrustSource, verifyJws } from "@tamga-network/trust";
import { BranchRegistry, BranchSet, createPresentationRequest, dcqlFromPolicy } from "@tamga-network/verifier";
// 1. Güven listelerini yükle (kök parmak izi: tamga.network/trust-anchor)
const { source: trust } = await fetchListTrustSource("https://trust.tamga.network", http, {
rootFingerprints: [ROOT_FINGERPRINT],
verifyJws,
});
// 2. Sunumu aç, QR olarak göster (paylaşılan istek nesnesi yok)
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. request_uri'nin her çekimi yeni bir dal: taze state, nonce ve anahtar
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);
});