@gramota/presentation-exchange
v0.1.3
Published
DIF Presentation Exchange v2 — match credentials against a verifier's presentation_definition.
Maintainers
Readme
@gramota/presentation-exchange
DIF Presentation Exchange v2 — select credentials that satisfy a verifier's
presentation_definitionand build the matchingpresentation_submission. Use this for OID4VP requests that don't use DCQL (newer wallets prefer@gramota/dcql).
Part of Gramota — the TypeScript SDK for the EU Digital Identity Wallet (EUDIW).
Install
pnpm add @gramota/presentation-exchange
# or: npm install @gramota/presentation-exchange
# or: yarn add @gramota/presentation-exchangeQuick example
import {
selectForDefinition,
buildPresentationSubmission,
SdJwtVcMatcher,
} from "@gramota/presentation-exchange";
const definition = {
id: "pid-request",
input_descriptors: [
{
id: "pid",
format: { "vc+sd-jwt": { alg: ["ES256"] } },
constraints: {
fields: [{ path: ["$.given_name"] }, { path: ["$.family_name"] }],
},
},
],
};
const selection = selectForDefinition({
definition,
credentials: walletCredentials,
matchers: [new SdJwtVcMatcher()],
});
if (selection.satisfiable) {
const submission = buildPresentationSubmission(definition, selection);
// submission.descriptor_map[i].path → vp_token entry index
}What's inside
selectForDefinition— top-level matcher; returns aSelectionbuildPresentationSubmission— produce the DIFpresentation_submissionmappingSdJwtVcMatcher— matcher forvc+sd-jwtcredentials with JSONPath constraintsevaluateJsonPath,parseJsonPath,leafClaimName— JSONPath primitivesCredentialMatcherinterface — write your own for mDoc / W3C-VC formats- Constants:
SD_JWT_VC_FORMAT
For the OID4VP transport that carries the definition, see
@gramota/oid4vp.
