@gramota/sd-jwt
v0.2.0
Published
SD-JWT-VC parser and verifier for the EU Digital Identity Wallet.
Maintainers
Readme
@gramota/sd-jwt
IETF SD-JWT-VC primitives — parse, issue, hash-binding verify, key-binding (KB-JWT) build / verify. Tight low-level layer; most consumers should reach for
@gramota/issuer,@gramota/holder, or@gramota/verifierinstead.
Part of Gramota — the TypeScript SDK for the EU Digital Identity Wallet (EUDIW).
Install
pnpm add @gramota/sd-jwt
# or: npm install @gramota/sd-jwt
# or: yarn add @gramota/sd-jwtQuick example — parse + hash-binding verify
import { parseSdJwt, verifyHashBinding } from "@gramota/sd-jwt";
const parsed = parseSdJwt(presentationToken);
const verified = verifyHashBinding(parsed);
console.log(verified.disclosed); // user claims
console.log(verified.unmatchedDisclosures); // expected []Quick example — KB-JWT (holder presentation binding)
import { buildKeyBindingJwt, computeSdHash } from "@gramota/sd-jwt";
const sdHash = computeSdHash(presentationPrefix); // <issuer-jws>~<d1>~...~<dN>~
const kbJwt = await buildKeyBindingJwt({
signer, // holder's @gramota/jose Signer
aud: "https://verifier.example",
nonce: "n-from-verifier",
sdHash,
});
const fullPresentation = `${presentationPrefix}${kbJwt}`;What's inside
parseSdJwt— split<issuer-jws>~<d1>~...~<dN>~<kb-jwt?>and decode partsissueSdJwt— produce a fresh SD-JWT from claims + a list of selectively-disclosable pathsverifyHashBinding— match disclosures to_sddigests; reject forgeriesbuildKeyBindingJwt/verifyKeyBinding— IETF SD-JWT §4.3 holder bindingcomputeSdHash— RFC-alignedsd_hashclaim used in KB-JWT- One error class —
SdJwtError— with codes namespaced by operation (sd_jwt.parse.*,sd_jwt.verify.*,sd_jwt.kb.*,sd_jwt.issue.*)
For the high-level Verifier / Issuer / Holder API, see the main repo.
