@gramota/dcql
v0.1.3
Published
Digital Credentials Query Language (OID4VP 2.0) — match credentials against a verifier's dcql_query.
Maintainers
Readme
@gramota/dcql
Digital Credentials Query Language (OID4VP Final 1.0) — select credentials from a holder's wallet that satisfy a verifier's
dcql_query.
Part of Gramota — the TypeScript SDK for the EU Digital Identity Wallet (EUDIW).
Install
pnpm add @gramota/dcql
# or: npm install @gramota/dcql
# or: yarn add @gramota/dcqlQuick example — match a verifier's request
import { selectForDcql, DcqlSdJwtVcMatcher } from "@gramota/dcql";
const query = {
credentials: [
{
id: "pid",
format: "dc+sd-jwt",
meta: { vct_values: ["urn:eudi:pid:1"] },
claims: [
{ path: ["given_name"] },
{ path: ["family_name"] },
{ path: ["birth_date"] },
],
},
],
};
const selection = selectForDcql({
query,
credentials: walletCredentials, // [{ id, view: { vct, claims } }, ...]
matchers: [new DcqlSdJwtVcMatcher()],
});
if (selection.satisfiable) {
for (const match of selection.matches) {
console.log(match.credentialId, match.queryId, match.disclosablePaths);
}
}What's inside
selectForDcql— top-level matcher; returns aDcqlSelection(satisfiable + per-query matches, or unsatisfiable + reason)DcqlSdJwtVcMatcher— matcher forformat: "dc+sd-jwt"credentialsDcqlMatcherinterface — write your own for mDoc / W3C-VC formatsevaluateDcqlPath,validateDcqlPath— JSON-pointer-style path traversal used by matchers- Constants:
SD_JWT_VC_FORMAT,DC_SD_JWT_VC_FORMAT
For the OID4VP transport that carries the query, see
@gramota/oid4vp.
