conformance: the identity presentation verifier enrolled (134 rules of 10 verifiers, 273 vectors); the reference verifier instruction names all five files beside verify-proof.mjs; module READMEs point to aere.network/tools

This commit is contained in:
Aere Network committed 2026-10-05 18:53:32 +03:00
1 parent c9798a0013
commit 5fb38c5d0b
88 files changed
+20246 -179

No files matched your search

+77 -57
View File
@@ -285,40 +285,59 @@ export function present({ credential, disclosures = [], reveal = [], presenter,
// (validFrom al credentialului si al listei de stare, notBefore al delegarii) si in sensul prudent pe revocari (o revocare cu momentul
// pana la clockSkewS in viitor se aplica deja); niciodata pe sfarsituri (validUntil, notAfter), unde ar prelungi o valabilitate.
export const CLOCK_SKEW_S = 60;
// 2026-10-05 (conformance suite): every refusal of verifyPresentation NAMES its rule. REGULI is the list of the rules it can name (the
// helper throws on any other); every check of a rule carries a PAZA marker with the rule id, read by the suite's derivation
// (declared == marked == mapped there). A row is { name, pass, detail, rule }; a row that was not judged is { name, pass: null, detail,
// unjudged: <cause> } with the cause from NEJUDECATE. The result carries `rules` (the sorted ids that refused) and `unjudged` (the
// sorted causes). OPRIRI are the rules after whose refusal other checks were NOT made (the verifier returned, or skipped a link).
export const REGULI = ['form', 'issuer-id', 'holder-id', 'credential-signature', 'issuer-trusted', 'credential-window', 'status-list', 'credential-revoked', 'sd-distinct',
'disclosure-readable', 'disclosure-signed', 'disclosure-once', 'disclosure-plain', 'claim-name', 'binding-credential', 'binding-disclosures', 'binding-delegations', 'presenter',
'presentation-signature', 'audience', 'nonce', 'freshness', 'chain-length', 'delegation-form', 'delegation-ids', 'delegation-from', 'delegation-parent', 'delegation-signature',
'delegation-scope', 'delegation-window', 'delegation-depth', 'delegation-narrows', 'delegation-credential', 'delegation-claims', 'delegation-audience', 'delegation-revoked', 'unreadable'];
export const NEJUDECATE = ['issuer-trust', 'status-none', 'status-unread', 'audience', 'nonce', 'revocation-ignored', 'revocations-none'];
export const OPRIRI = ['form', 'chain-length', 'delegation-form', 'unreadable'];
class Nedeclarata extends Error {}
export function verifyPresentation(p, { audience = null, nonce = null, now = new Date(), trustedIssuers = null, statusLists = [], revocations = [], maxAgeS = 300, clockSkewS = CLOCK_SKEW_S } = {}) {
const rows = [];
const ok = (name, pass, detail = '') => { rows.push({ name, pass: !!pass, detail: pass ? '' : detail }); return !!pass; };
const nejudecat = (name, detail) => rows.push({ name, pass: null, detail });
const ok = (rule, name, pass, detail = '') => { if (!REGULI.includes(rule)) throw new Nedeclarata('aere-identity: undeclared rule ' + rule); rows.push({ name, pass: !!pass, detail: pass ? '' : detail, rule }); return !!pass; };
const nejudecat = (cauza, name, detail) => { if (!NEJUDECATE.includes(cauza)) throw new Nedeclarata('aere-identity: undeclared cause ' + cauza); rows.push({ name, pass: null, detail, unjudged: cauza }); };
const acum = new Date(now).getTime();
if (!Number.isInteger(clockSkewS) || clockSkewS < 0 || clockSkewS > 600) throw new Error('verifyPresentation: clockSkewS is 0..600 seconds');
const sk = clockSkewS * 1000;
// 2026-09-30 (API-ul Identity din Cloud): o prezentare VALIDA spune si despre cine e (tip, credential, emitent, detinator, cine a
// prezentat), ca verificatorul care nu a dat trustedIssuers sa vada pe cine ar trebui sa creada; numai pe drumul care ajunge la capat
const gata = (claims = null, subject = null) => { const valid = rows.every((r) => r.pass !== false); return { valid, rows, notJudged: rows.filter((r) => r.pass === null).length, claims: valid ? claims : null, subject: valid ? subject : null }; };
const gata = (claims = null, subject = null) => { const valid = rows.every((r) => r.pass !== false); return { valid, rows, notJudged: rows.filter((r) => r.pass === null).length,
rules: [...new Set(rows.filter((r) => r.pass === false).map((r) => r.rule))].sort(), unjudged: [...new Set(rows.filter((r) => r.pass === null).map((r) => r.unjudged))].sort(),
claims: valid ? claims : null, subject: valid ? subject : null }; };
// configuratia verificatorului se valideaza inainte (o cheie de incredere stricata e o greseala a lui, nu o prezentare invalida)
if (trustedIssuers != null && !Array.isArray(trustedIssuers)) throw new Error('verifyPresentation: trustedIssuers is a list of ids or public keys');
const idsIncredere = trustedIssuers == null ? null : trustedIssuers.map((x) => (typeof x === 'string' && ID.test(x) ? x : idOf(x)));
if (!Array.isArray(statusLists) || !Array.isArray(revocations)) throw new Error('verifyPresentation: statusLists and revocations are lists');
try {
if (!p || p.kind !== 'aere-presentation' || p.v !== VERSION || !p.credential || !p.binding || !Array.isArray(p.disclosures) || !Array.isArray(p.delegations)) {
ok('presentation: well formed', false, 'not an aere-presentation'); return gata();
if (!((!!p && p.kind === 'aere-presentation' && p.v === VERSION && !!p.credential && !!p.binding && Array.isArray(p.disclosures) && Array.isArray(p.delegations)) /*PAZA:form*/)) {
ok('form', 'presentation: well formed', false, 'not an aere-presentation'); return gata();
}
const c = p.credential, S = c.statement, B = p.binding;
if (!S || S.kind !== 'aere-credential' || S.v !== VERSION || !S.issuer || !S.holder || !Array.isArray(S.sd) || !S.claims || typeof S.claims !== 'object' || Array.isArray(S.claims)) {
ok('credential: well formed', false, 'not an aere-credential'); return gata();
if (!((!!S && S.kind === 'aere-credential' && S.v === VERSION && !!S.issuer && !!S.holder && Array.isArray(S.sd) && !!S.claims && typeof S.claims === 'object' && !Array.isArray(S.claims)) /*PAZA:form*/)) {
ok('form', 'credential: well formed', false, 'not an aere-credential'); return gata();
}
// 1. emitentul si detinatorul, legati de chei
let idE = null, idH = null; try { idE = idOf(S.issuer.keys); idH = idOf(S.holder.keys); } catch (e) { /* randurile de mai jos spun */ }
ok('credential: the issuer id is the id of its keys', idE && idE === S.issuer.id, `issuer id ${S.issuer.id} is not derived from the keys in the credential`);
ok('credential: the holder id is the id of its keys', idH && idH === S.holder.id, `holder id ${S.holder.id} is not derived from the keys in the credential`);
ok(`credential: signed by ${String(S.issuer.id)} (Ed25519 and ML-DSA-65, both)`, verifyText('credential', canonical(S), c.signature, S.issuer.keys), 'the hybrid signature does not verify with the issuer\'s keys');
if (trustedIssuers == null) nejudecat('credential: issuer trusted', 'not judged: anyone can issue a credential with their own keys; pass trustedIssuers (ids or public keys) to require who issued');
// 2026-10-05: each id in its own try. In one try, issuer keys that could not be read left the holder id underived too, and the
// verdict named the holder (holder-id) for a fault of the issuer's keys.
let idE = null, idH = null; try { idE = idOf(S.issuer.keys); } catch (e) { /* randul de mai jos spune */ }
try { idH = idOf(S.holder.keys); } catch (e) { /* randul de mai jos spune */ }
ok('issuer-id', 'credential: the issuer id is the id of its keys', idE && idE === S.issuer.id /*PAZA:issuer-id*/, `issuer id ${S.issuer.id} is not derived from the keys in the credential`);
ok('holder-id', 'credential: the holder id is the id of its keys', idH && idH === S.holder.id /*PAZA:holder-id*/, `holder id ${S.holder.id} is not derived from the keys in the credential`);
ok('credential-signature', `credential: signed by ${String(S.issuer.id)} (Ed25519 and ML-DSA-65, both)`, verifyText('credential', canonical(S), c.signature, S.issuer.keys) /*PAZA:credential-signature*/, 'the hybrid signature does not verify with the issuer\'s keys');
if (trustedIssuers == null) nejudecat('issuer-trust', 'credential: issuer trusted', 'not judged: anyone can issue a credential with their own keys; pass trustedIssuers (ids or public keys) to require who issued');
else {
ok('credential: issuer trusted', idsIncredere.includes(S.issuer.id), `${S.issuer.id} is not among the ${idsIncredere.length} trusted issuer(s)`);
ok('issuer-trusted', 'credential: issuer trusted', idsIncredere.includes(S.issuer.id) /*PAZA:issuer-trusted*/, `${S.issuer.id} is not among the ${idsIncredere.length} trusted issuer(s)`);
}
// 2. fereastra, pe ceasul verificatorului
const vf = data(S.validFrom, 'validFrom'), vu = data(S.validUntil, 'validUntil');
ok(`credential: valid at ${iso(acum)}`, vf - sk <= acum && acum <= vu, `valid from ${S.validFrom} until ${S.validUntil}`);
ok('credential-window', `credential: valid at ${iso(acum)}`, vf - sk <= acum && acum <= vu /*PAZA:credential-window*/, `valid from ${S.validFrom} until ${S.validUntil}`);
// 3. starea (revocarea) credentialului
if (!S.status) nejudecat('credential: status', 'the credential names no status list, so its issuer cannot revoke it');
if (!S.status) nejudecat('status-none', 'credential: status', 'the credential names no status list, so its issuer cannot revoke it');
else {
const liste = statusLists.filter((l) => l && l.statement && l.statement.id === S.status.list);
// o lista stricata (adusa de pe retea, de pilda) nu acuza credentialul: e ignorata, ca una a altui emitent
@@ -326,89 +345,90 @@ export function verifyPresentation(p, { audience = null, nonce = null, now = new
&& canonical(l.statement.issuer.keys) === canonical(S.issuer.keys) && verifyText('status-list', canonical(l.statement), l.signature, S.issuer.keys); } catch { return false; } });
// numai listele emitentului valabile ACUM; cu mai multe, un bit pus in oricare inseamna revocat (revocarea nu se ridica)
const curente = aEmitentului.filter((l) => { try { return data(l.statement.validFrom, 'status validFrom') - sk <= acum && acum <= data(l.statement.validUntil, 'status validUntil'); } catch { return false; } });
if (!aEmitentului.length) nejudecat(`credential: status in ${S.status.list}`, liste.length ? 'the status list(s) given with this id are not signed by the issuer: ignored' : 'the status list was not handed to the verifier; a revocation it was not handed cannot be seen');
else if (!curente.length) nejudecat(`credential: status in ${S.status.list}`, `the issuer's status list(s) given are not valid at ${iso(acum)}: fetch a current one`);
if (!aEmitentului.length) nejudecat('status-unread', `credential: status in ${S.status.list}`, liste.length ? 'the status list(s) given with this id are not signed by the issuer: ignored' : 'the status list was not handed to the verifier; a revocation it was not handed cannot be seen');
else if (!curente.length) nejudecat('status-unread', `credential: status in ${S.status.list}`, `the issuer's status list(s) given are not valid at ${iso(acum)}: fetch a current one`);
else {
let rev = false, citite = 0;
for (const L of curente) { try { rev = statusBit(L, S.status.index) || rev; citite++; } catch (e) { ok(`credential: status in ${S.status.list}`, false, String(e.message)); } }
if (citite) ok(`credential: not revoked (status list ${S.status.list}, index ${S.status.index})`, !rev, 'the issuer revoked this credential');
for (const L of curente) { try { rev = statusBit(L, S.status.index) || rev; citite++; } catch (e) { if (!(false /*PAZA:status-list*/)) ok('status-list', `credential: status in ${S.status.list}`, false, String(e.message)); } }
if (citite) ok('credential-revoked', `credential: not revoked (status list ${S.status.list}, index ${S.status.index})`, !rev /*PAZA:credential-revoked*/, 'the issuer revoked this credential');
}
}
// 4. dezvaluirile: fiecare semnata (digestul in sd), o singura data, fara sa acopere o afirmatie in clar
const sd = new Set(S.sd);
ok('credential: the digests it signs are distinct', sd.size === S.sd.length, 'a digest appears twice in sd');
ok('sd-distinct', 'credential: the digests it signs are distinct', sd.size === S.sd.length /*PAZA:sd-distinct*/, 'a digest appears twice in sd');
const dezvaluite = []; const vazuteD = new Set(), vazuteN = new Set(); let bune = true;
for (const enc of p.disclosures) {
let d; try { d = decodeDisclosure(enc); } catch (e) { bune = ok('disclosure: readable', false, e.message); continue; }
let d; try { d = decodeDisclosure(enc); } catch (e) { if (!(false /*PAZA:disclosure-readable*/)) bune = ok('disclosure-readable', 'disclosure: readable', false, e.message); continue; }
const dg = digestOf(enc);
if (!sd.has(dg)) { bune = ok(`disclosure ${d.name}: signed by the issuer`, false, 'its digest is not in the credential'); continue; }
if (vazuteD.has(dg) || vazuteN.has(d.name)) { bune = ok(`disclosure ${d.name}: shown once`, false, 'the same claim is disclosed twice'); continue; }
if (Object.hasOwn(S.claims, d.name)) { bune = ok(`disclosure ${d.name}: does not cover a plain claim`, false, 'the credential has this claim in the clear too'); continue; }
if (!(sd.has(dg) /*PAZA:disclosure-signed*/)) { bune = ok('disclosure-signed', `disclosure ${d.name}: signed by the issuer`, false, 'its digest is not in the credential'); continue; }
if (!(!(vazuteD.has(dg) || vazuteN.has(d.name)) /*PAZA:disclosure-once*/)) { bune = ok('disclosure-once', `disclosure ${d.name}: shown once`, false, 'the same claim is disclosed twice'); continue; }
if (!(!Object.hasOwn(S.claims, d.name) /*PAZA:disclosure-plain*/)) { bune = ok('disclosure-plain', `disclosure ${d.name}: does not cover a plain claim`, false, 'the credential has this claim in the clear too'); continue; }
vazuteD.add(dg); vazuteN.add(d.name); dezvaluite.push(d);
}
if (bune) ok(`disclosures: ${dezvaluite.length} shown, each signed by the issuer, once`, true);
for (const n of Object.keys(S.claims)) if (!numeValid(n)) ok(`credential: claim name ${n}`, false, 'a claim name that is not allowed');
if (bune) ok('disclosure-signed', `disclosures: ${dezvaluite.length} shown, each signed by the issuer, once`, true);
for (const n of Object.keys(S.claims)) if (!(numeValid(n) /*PAZA:claim-name*/)) ok('claim-name', `credential: claim name ${n}`, false, 'a claim name that is not allowed');
// 5. legatura prezentarii: ce credential, ce dezvaluiri, ce lant, cine prezinta
if (!B || B.kind !== 'aere-presentation-binding' || B.v !== VERSION || !B.presenter) { ok('presentation: binding well formed', false, 'not an aere-presentation-binding'); return gata(); }
ok('presentation: names this credential', B.credentialHash === credentialHash(c), 'the binding names another credential');
ok('presentation: names exactly these disclosures', B.disclosuresHash === hashOf(p.disclosures), 'disclosures added, removed or changed after signing');
ok('presentation: names exactly this delegation chain', Array.isArray(B.delegations) && canonical(B.delegations) === canonical(p.delegations.map(delegationHash)), 'the delegation chain is not the one signed');
if (!((!!B && B.kind === 'aere-presentation-binding' && B.v === VERSION && !!B.presenter) /*PAZA:form*/)) { ok('form', 'presentation: binding well formed', false, 'not an aere-presentation-binding'); return gata(); }
ok('binding-credential', 'presentation: names this credential', B.credentialHash === credentialHash(c) /*PAZA:binding-credential*/, 'the binding names another credential');
ok('binding-disclosures', 'presentation: names exactly these disclosures', B.disclosuresHash === hashOf(p.disclosures) /*PAZA:binding-disclosures*/, 'disclosures added, removed or changed after signing');
ok('binding-delegations', 'presentation: names exactly this delegation chain', Array.isArray(B.delegations) && canonical(B.delegations) === canonical(p.delegations.map(delegationHash)) /*PAZA:binding-delegations*/, 'the delegation chain is not the one signed');
const lant = p.delegations;
const asteptat = lant.length ? lant[lant.length - 1].statement && lant[lant.length - 1].statement.to : S.holder;
const cine = lant.length ? 'the last delegate' : 'the holder';
ok(`presentation: presented by ${cine}`, asteptat && B.presenter.id === asteptat.id && canonical(B.presenter.keys) === canonical(asteptat.keys), `presented by ${B.presenter.id}, expected ${asteptat && asteptat.id}`);
ok('presentation: signed by the presenter (Ed25519 and ML-DSA-65, both)', verifyText('presentation', canonical(B), p.signature, B.presenter.keys), 'the hybrid signature does not verify with the presenter\'s keys');
ok('presenter', `presentation: presented by ${cine}`, asteptat && B.presenter.id === asteptat.id && canonical(B.presenter.keys) === canonical(asteptat.keys) /*PAZA:presenter*/, `presented by ${B.presenter.id}, expected ${asteptat && asteptat.id}`);
ok('presentation-signature', 'presentation: signed by the presenter (Ed25519 and ML-DSA-65, both)', verifyText('presentation', canonical(B), p.signature, B.presenter.keys) /*PAZA:presentation-signature*/, 'the hybrid signature does not verify with the presenter\'s keys');
// 6. publicul, nonce-ul, prospetimea
if (audience == null) nejudecat('presentation: audience', 'not judged: without the verifier\'s own audience a presentation made for another verifier is accepted');
else ok(`presentation: made for ${audience}`, B.audience === audience, `made for ${B.audience}`);
if (nonce == null) nejudecat('presentation: nonce', 'not judged: without the verifier\'s nonce an old presentation can be replayed');
else ok('presentation: carries the verifier\'s nonce', B.nonce === nonce, 'another nonce');
if (audience == null) nejudecat('audience', 'presentation: audience', 'not judged: without the verifier\'s own audience a presentation made for another verifier is accepted');
else ok('audience', `presentation: made for ${audience}`, B.audience === audience /*PAZA:audience*/, `made for ${B.audience}`);
if (nonce == null) nejudecat('nonce', 'presentation: nonce', 'not judged: without the verifier\'s nonce an old presentation can be replayed');
else ok('nonce', 'presentation: carries the verifier\'s nonce', B.nonce === nonce /*PAZA:nonce*/, 'another nonce');
const t = data(B.createdAt, 'createdAt');
ok(`presentation: made within ${maxAgeS} s of the verifier's clock`, Math.abs(acum - t) <= maxAgeS * 1000, `made at ${B.createdAt}`);
ok('freshness', `presentation: made within ${maxAgeS} s of the verifier's clock`, Math.abs(acum - t) <= maxAgeS * 1000 /*PAZA:freshness*/, `made at ${B.createdAt}`);
// 7. lantul de delegare
if (lant.length > MAX_CHAIN) { ok('delegation: chain length', false, `${lant.length} links, at most ${MAX_CHAIN}`); return gata(); }
if (!(lant.length <= MAX_CHAIN /*PAZA:chain-length*/)) { ok('chain-length', 'delegation: chain length', false, `${lant.length} links, at most ${MAX_CHAIN}`); return gata(); }
for (let i = 0; i < lant.length; i++) {
const D = lant[i] && lant[i].statement, et = `delegation ${i + 1}/${lant.length}`;
if (!D || D.kind !== 'aere-delegation' || D.v !== VERSION || !D.from || !D.to || !D.scope) { ok(`${et}: well formed`, false, 'not an aere-delegation'); continue; }
if (!((!!D && D.kind === 'aere-delegation' && D.v === VERSION && !!D.from && !!D.to && !!D.scope) /*PAZA:delegation-form*/)) { ok('delegation-form', `${et}: well formed`, false, 'not an aere-delegation'); continue; }
const dela = i === 0 ? S.holder : lant[i - 1].statement.to;
let idF = null, idT = null; try { idF = idOf(D.from.keys); idT = idOf(D.to.keys); } catch { /* spus mai jos */ }
ok(`${et}: from and to are the ids of their keys`, idF === D.from.id && idT === D.to.id, 'an id not derived from its keys');
ok(`${et}: given by ${i === 0 ? 'the holder' : 'the previous delegate'}`, dela && D.from.id === dela.id && canonical(D.from.keys) === canonical(dela.keys), `given by ${D.from.id}`);
ok(`${et}: names its parent link`, D.parent === (i === 0 ? null : delegationHash(lant[i - 1])), 'the parent hash is not the previous link');
ok(`${et}: signed by who gave it (Ed25519 and ML-DSA-65, both)`, verifyText('delegation', canonical(D), lant[i].signature, D.from.keys), 'the hybrid signature does not verify');
let sc = null; try { sc = scopNormal(D.scope); } catch (e) { ok(`${et}: scope`, false, e.message); }
if (sc && canonical(sc) !== canonical(D.scope)) ok(`${et}: scope in normal form`, false, 'the scope is not sorted or has duplicates');
ok('delegation-ids', `${et}: from and to are the ids of their keys`, idF === D.from.id && idT === D.to.id /*PAZA:delegation-ids*/, 'an id not derived from its keys');
ok('delegation-from', `${et}: given by ${i === 0 ? 'the holder' : 'the previous delegate'}`, dela && D.from.id === dela.id && canonical(D.from.keys) === canonical(dela.keys) /*PAZA:delegation-from*/, `given by ${D.from.id}`);
ok('delegation-parent', `${et}: names its parent link`, D.parent === (i === 0 ? null : delegationHash(lant[i - 1])) /*PAZA:delegation-parent*/, 'the parent hash is not the previous link');
ok('delegation-signature', `${et}: signed by who gave it (Ed25519 and ML-DSA-65, both)`, verifyText('delegation', canonical(D), lant[i].signature, D.from.keys) /*PAZA:delegation-signature*/, 'the hybrid signature does not verify');
let sc = null; try { sc = scopNormal(D.scope); } catch (e) { if (!(false /*PAZA:delegation-scope*/)) ok('delegation-scope', `${et}: scope`, false, e.message); }
if (sc && !(canonical(sc) === canonical(D.scope) /*PAZA:delegation-scope*/)) ok('delegation-scope', `${et}: scope in normal form`, false, 'the scope is not sorted or has duplicates');
const nb = data(D.notBefore, 'notBefore'), na = data(D.notAfter, 'notAfter');
ok(`${et}: valid at ${iso(acum)} and when the presentation was made`, nb - sk <= acum && acum <= na && nb - sk <= t && t <= na, `valid from ${D.notBefore} until ${D.notAfter}`);
ok(`${et}: allows the links after it`, Number.isInteger(D.maxDepth) && D.maxDepth >= lant.length - 1 - i, `maxDepth ${D.maxDepth}, ${lant.length - 1 - i} link(s) after it`);
ok('delegation-window', `${et}: valid at ${iso(acum)} and when the presentation was made`, nb - sk <= acum && acum <= na && nb - sk <= t && t <= na /*PAZA:delegation-window*/, `valid from ${D.notBefore} until ${D.notAfter}`);
ok('delegation-depth', `${et}: allows the links after it`, Number.isInteger(D.maxDepth) && D.maxDepth >= lant.length - 1 - i /*PAZA:delegation-depth*/, `maxDepth ${D.maxDepth}, ${lant.length - 1 - i} link(s) after it`);
if (i > 0 && sc) {
const P = lant[i - 1].statement;
const ingust = ['credentials', 'claims', 'audiences'].every((k) => inclus(sc[k], P.scope[k]));
ok(`${et}: only narrows the previous link`, ingust && nb >= data(P.notBefore, 'notBefore') && na <= data(P.notAfter, 'notAfter') && D.maxDepth <= P.maxDepth - 1, 'a wider scope, a wider window or a deeper delegation than the link it comes from');
ok('delegation-narrows', `${et}: only narrows the previous link`, ingust && nb >= data(P.notBefore, 'notBefore') && na <= data(P.notAfter, 'notAfter') && D.maxDepth <= P.maxDepth - 1 /*PAZA:delegation-narrows*/, 'a wider scope, a wider window or a deeper delegation than the link it comes from');
}
if (sc) {
ok(`${et}: covers this credential`, permite(sc.credentials, S.id), `${S.id} is outside its scope`);
ok('delegation-credential', `${et}: covers this credential`, permite(sc.credentials, S.id) /*PAZA:delegation-credential*/, `${S.id} is outside its scope`);
const afara = dezvaluite.map((d) => d.name).filter((n) => !permite(sc.claims, n));
ok(`${et}: covers the disclosed claims`, !afara.length, 'outside its scope: ' + afara.join(', '));
ok(`${et}: covers the audience`, permite(sc.audiences, B.audience), `${B.audience} is outside its scope`);
ok('delegation-claims', `${et}: covers the disclosed claims`, !afara.length /*PAZA:delegation-claims*/, 'outside its scope: ' + afara.join(', '));
ok('delegation-audience', `${et}: covers the audience`, permite(sc.audiences, B.audience) /*PAZA:delegation-audience*/, `${B.audience} is outside its scope`);
}
// revocarile: semnate de cel care a dat veriga sau de detinator, pe ceasul verificatorului
const h = delegationHash(lant[i]);
for (const r of revocations) {
const R = r && r.statement; if (!R || R.kind !== 'aere-revocation' || R.target !== h) continue;
try { canonical(R); } catch { nejudecat(`${et}: a revocation`, 'ignored: not readable'); continue; }
try { canonical(R); } catch { nejudecat('revocation-ignored', `${et}: a revocation`, 'ignored: not readable'); continue; }
const autor = R.by && (R.by.id === D.from.id || R.by.id === S.holder.id);
let idR = null; try { idR = idOf(R.by.keys); } catch { /* ignorata */ }
if (!autor || idR !== R.by.id || !verifyText('revocation', canonical(R), r.signature, R.by.keys)) { nejudecat(`${et}: a revocation`, `ignored: not signed by who gave the link or by the holder (${R.by && R.by.id})`); continue; }
let at = null; try { at = data(R.at, 'revocation at'); } catch { nejudecat(`${et}: a revocation`, 'ignored: its time is not an RFC 3339 UTC time'); continue; }
ok(`${et}: not revoked`, at > acum + sk, `revoked by ${R.by.id} at ${R.at}`);
if (!autor || idR !== R.by.id || !verifyText('revocation', canonical(R), r.signature, R.by.keys)) { nejudecat('revocation-ignored', `${et}: a revocation`, `ignored: not signed by who gave the link or by the holder (${R.by && R.by.id})`); continue; }
let at = null; try { at = data(R.at, 'revocation at'); } catch { nejudecat('revocation-ignored', `${et}: a revocation`, 'ignored: its time is not an RFC 3339 UTC time'); continue; }
ok('delegation-revoked', `${et}: not revoked`, at > acum + sk /*PAZA:delegation-revoked*/, `revoked by ${R.by.id} at ${R.at}`);
}
}
if (lant.length && !revocations.length) nejudecat('delegation: revocations', 'none given; a revocation the verifier was not handed cannot be seen');
if (lant.length && !revocations.length) nejudecat('revocations-none', 'delegation: revocations', 'none given; a revocation the verifier was not handed cannot be seen');
const claims = Object.fromEntries([...Object.entries(S.claims), ...dezvaluite.map((d) => [d.name, d.value])].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)));
return gata(claims, { type: S.type, credential: S.id, issuer: S.issuer.id, holder: S.holder.id, presenter: B.presenter.id, delegations: lant.length });
} catch (e) {
ok('presentation: readable', false, String(e && e.message || e).slice(0, 200));
if (e instanceof Nedeclarata) throw e;
if (!(false /*PAZA:unreadable*/)) ok('unreadable', 'presentation: readable', false, String(e && e.message || e).slice(0, 200));
return gata();
}
}