import { fetchListTrustSource, verifyJws } from "@tamga-network/trust";
import { BranchRegistry, BranchSet, createPresentationRequest, dcqlFromPolicy } from "@tamga-network/verifier";
// 1. Ynam sanawlaryny ýükle (kök barmak yzy: tamga.network/trust-anchor)
const { source: trust } = await fetchListTrustSource("https://trust.tamga.network", http, {
rootFingerprints: [ROOT_FINGERPRINT],
verifyJws,
});
// 2. Görkezişi aç, QR hökmünde görkez (umumy haýyş obýekti ýok)
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-niň her çekilişi täze şaha: täze state, nonce we açar
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);
});