@thirtified/eudi-dev
v0.2.0
Published
Typed Node.js wrapper for the eudi-dev CLI (decode, validate, dcql, issue, trust, registrar)
Maintainers
Readme
@thirtified/eudi-dev
Typed Node.js wrapper for the eudi-dev CLI (Apache-2.0). It is built for integration tests that need to issue, decode and validate EUDI credentials (SD-JWT VC, JWT VC, mdoc) and work with the wallet's store, templates, catalogue, trusted lists and registrar.
The package does not bind to the Go code. It runs the CLI with --json, which upstream treats as a stable interface (ADR 0020): exactly one JSON document on stdout, messages on stderr, and within a major version fields are only added, never removed.
Scope: CLI commands that print one --json document. Nothing the wrapper runs opens a port: it doesn't start wallet serve, and it has no HTTP client for the wallet API. Commands it doesn't wrap yet are listed under Not wrapped.
Targets eudi-dev v3.10.1. Any v3.x binary is accepted. No runtime dependencies besides the platform package with the binary.
Install
pnpm add -D @thirtified/eudi-dev
# or: npm install --save-dev @thirtified/eudi-devWith TypeScript, also install the Node types: pnpm add -D @types/node. The package's type definitions use them and load them for you, so you don't need "types": ["node"] in your tsconfig, which TypeScript 6 and later would otherwise require.
The eudi-dev binary comes in one npm package per platform, listed as optionalDependencies with exact versions. The package manager installs only the one that matches your OS and CPU. Nothing is downloaded at install time or at runtime, and there is no install script.
| Platform | Package | Upstream asset |
|---|---|---|
| macOS arm64 | @thirtified/eudi-dev-darwin-arm64 | eudi-v3.10.1-darwin-arm64 |
| macOS x64 | @thirtified/eudi-dev-darwin-x64 | eudi-v3.10.1-darwin-amd64 |
| Linux x64 | @thirtified/eudi-dev-linux-x64 | eudi-v3.10.1-linux-amd64 |
| Linux arm64 | @thirtified/eudi-dev-linux-arm64 | eudi-v3.10.1-linux-arm64 |
Windows isn't supported yet. Upstream publishes eudi-v3.10.1-windows-amd64.exe, and you can point EUDI_DEV_BIN at it, but the wrapper is untested on Windows.
Each package contains the upstream release binary unchanged, checked against the release's checksums.txt (SHA-256) when it was built, plus upstream's Apache-2.0 LICENSE. Its README and the eudiDev field in its package.json record the release and the hash. A platform package has the upstream version without the v (3.10.1), with a suffix such as 3.10.1-1 if the same release had to be repackaged.
The binary is found in this order:
- the
binoption ofEudiDev.create() - the
EUDI_DEV_BINenvironment variable, for example a binary fromgo buildor Homebrew - the platform package
If the platform package is missing
EudiDev.create() throws an EudiDevBinaryError that names the package. The usual causes:
- Optional dependencies were left out (npm
--omit=optional, pnpm--no-optional, oromit=optionalin.npmrc). Install without leaving them out. package-lock.jsonwas created on another OS and has no entry for your platform's package (npm/cli#4828). Deletenode_modulesandpackage-lock.jsonand runnpm installagain. pnpm's lockfile lists every platform, so this doesn't happen with pnpm.node_moduleswas installed on another platform than the one it runs on, for example on a Mac and then mounted into a Linux container. With pnpm, list both platforms undersupportedArchitecturesinpnpm-workspace.yaml. With npm, install inside the container.- Your platform isn't one of the four above. Set
EUDI_DEV_BIN.
With Yarn PnP the packages are unplugged (preferUnplugged), so the binary is a real file on disk.
The macOS binaries are ad-hoc signed by the Go linker, not notarised. Files installed by npm or pnpm carry no quarantine attribute, so they run.
Usage
import { EudiDev } from '@thirtified/eudi-dev';
await using eudi = await EudiDev.create(); // own temp EUDI_DEV_HOME, removed on dispose
// Issue with an ephemeral key, then decode and validate
const { credential, publicJwk } = await eudi.issue.sdjwt({ pid: true, omit: ['sex'] });
const decoded = await eudi.decode(credential);
const result = await eudi.validate(credential, { key: publicJwk, haip: true });
result.valid; // false when a type/expiry/integrity/signature/status check fails
result.error; // "signature: ..." for the first failing check
result.report.checks; // every check, typed
result.report.haipFindings; // informational
// DCQL query for every claim of a credential
const query = await eudi.dcql(credential);
// mdoc and plain JWT VC
await eudi.issue.mdoc({ pid: true, docType: 'eu.europa.ec.eudi.pid.1' });
await eudi.issue.jwt({ claims: { name: 'Test', age: 30 } });A failing validate does not throw. It returns valid: false along with the report. Everything else throws EudiDevError when the command fails.
Inputs
Commands that read a credential take an Input:
string | Uint8Array: the content itself, sent on stdin, so there is no argv length limit{ path }: a file. It must exist, because upstream would read a missing path as raw input.{ url }: an http(s) URL that eudi-dev fetches
File-valued options (key, trustedList, cert, csr, dcql, claims, ca) take the content, { path }, or { url } where upstream accepts one. Content is written to a private temp file for the duration of the call. JSON options (claims, a JWK key, a DCQL dcql) also accept plain objects.
Wallet, trust and registrar (local state)
These commands work on the wallet in the instance's EUDI_DEV_HOME, which is created on first use. Pass home to keep state between instances.
The example continues the one above: it uses eudi and query from there. The access-certificate calls need a PEM certificate signing request for your verifier's key, here verifier.csr in the working directory:
openssl ecparam -name prime256v1 -genkey -noout -out verifier.key
openssl req -new -key verifier.key -subj "/CN=shop.example" -out verifier.csrimport { readFile } from 'node:fs/promises';
const issued = await eudi.issue.sdjwt({ pid: true, wallet: true }); // issued.id
const trustedList = await eudi.trust.show({ vct: 'urn:eudi:pid:1' }); // signed JWT
await eudi.validate(issued.credential, { trustedList, statusList: false });
const caPem = await eudi.trust.caCert();
const caJwks = await eudi.trust.caJwks();
// Register a verifier, then get its registration and access certificates
const rp = await eudi.registrar.verifiers.add({ name: 'Shop', purpose: 'Age check', dcql: query });
const id = rp.identifier[0]!.identifier;
const { registrationCertificate, verifierInfo } = await eudi.registrar.registrationCert({ identifier: id });
const { certificate, chain } = await eudi.registrar.accessCert({ identifier: id, csr: { path: 'verifier.csr' } });
await eudi.registrar.revoke({ identifier: id });
await eudi.registrar.issuers.add({ name: 'Diplomas Inc', attestations: ['dc+sd-jwt:urn:example:diploma:1'] });
// Register and get an access certificate in one step. The CSR can also be passed as content.
const csrPem = await readFile('verifier.csr', 'utf8');
await eudi.registrar.enrol({ relyingParty: { tradeName: 'Shop' }, access: { csr: csrPem } });A wallet-issued credential points to the wallet's own status list, which only wallet serve serves. Without a running server, validate it with statusList: false.
Wallet store, templates and catalogue
The wallet keeps credentials, templates and catalogue entries in files under the instance's home, so they last from one call to the next. These commands work offline. The example continues the first one: it imports its credential.
// Store a credential, list the wallet and inspect one credential
const stored = await eudi.wallet.import(credential); // also { path }
const { credentials } = await eudi.wallet.list(); // summaries: id, format, vct or doctype, validity, holder_binding
const full = await eudi.wallet.show(stored.id); // with claims and the raw credential
await eudi.wallet.remove(stored.id);
// Save a credential template, then issue from it
await eudi.templates.save('card', { format: 'sdjwt', vct: 'urn:example:card:1', claims: { given_name: 'Erika' } });
await eudi.issue.sdjwt({ template: 'card' });
// Add an attestation type to the catalogue, and remove it again
const entry = await eudi.catalog.add({ name: 'Membership', types: ['dc+sd-jwt:urn:example:membership:1'], claims: ['dc+sd-jwt:member_id'] });
await eudi.catalog.remove(entry.schema.id!);Also there: wallet.showDecoded(), removeAll(), info(), tlsCert(), tlsJwks(), logs() and clearLogs(); templates.list(), show(), import() and delete(); the transaction templates under templates.transactions; and catalog.list(). They take the wallet flags walletDir, storage and templatesDir, and the wallet and catalogue commands also mode and seed.
Not wrapped
These commands run through eudi.run() only:
- Talking to an issuer or a verifier:
wallet accept,wallet scan,wallet deferred,wallet refresh,wallet requests,wallet use. Wrapping them is planned. - Running a server:
wallet serve,decoder,proxyandproxy logs. They keep running, so they print no single--jsondocument. - For a person at a desktop:
wallet extension,wallet browser,wallet registerandwallet unregister(OS URL handlers),wallet psandwallet kill,completion.
Escape hatches
- Every wrapper takes
extraArgsfor flags it doesn't model, plustimeoutMsandsignal. eudi.run<T>(['wallet', 'deferred'])runs any command with--jsonand returns{ document, stdout, stderr }.new Runner({ bin, home })gives the bare runner without the version check.resolveBinary()returns the binary path the lookup above finds, andplatformPackage()the package for a platform.
Isolation
Each call runs with:
EUDI_DEV_HOMEset to the instance's homeNO_COLOR=1and--no-color- every inherited
EUDI_DEV_*variable removed, so a developer'sEUDI_DEV_STORAGEorEUDI_DEV_SEEDcannot change results. Opt out withinheritEudiEnv: true. Add variables withenv.
EudiDev.create() runs eudi version and refuses a major version other than 3 unless you pass allowAnyVersion: true. dev builds are accepted.
Errors
EudiDevError has message (the last stderr line, which is the error cobra printed), stderr, stdout, exitCode (eudi-dev uses only 0 and 1), signal, timedOut, args, and document (the JSON document, if one was printed before the failure). EudiDevBinaryError covers a missing or non-executable binary and an unsupported major version.
Types
The --json document types (ValidateReport, DecodedSdJwt, DecodedMdoc, Check, StatusResult, RelyingParty, TrustOverview, WalletCredential, CredentialTemplate, CatalogAttestation, …) are written by hand from the Go structs at v3.10.1. Upstream publishes no schema for them. Every object type also accepts unknown keys, so fields added in later v3 releases still type-check. decode of OpenID4VCI offers, OpenID4VP requests and trusted lists returns a plain JsonObject.
Contributing
Bug reports and pull requests are welcome. CONTRIBUTING.md covers setup, tests and releases.
Security
See SECURITY.md. Report vulnerabilities privately, not as public issues.
License
Apache-2.0 © Julian Dreissig.
The platform packages contain the unmodified eudi-dev release binaries, © Dominik Schlosser, also under Apache-2.0. Each package carries upstream's LICENSE.
This project isn't affiliated with or endorsed by the eudi-dev project or the European Commission. "EUDI" refers to the EU Digital Identity Wallet framework.
