Skip to content

feat: CEL credential maps for every credential type - #25

Draft
h4nz4 wants to merge 11 commits into
mainfrom
feat/cel-mapping-poc
Draft

h4nz4 wants to merge 11 commits into
mainfrom
feat/cel-mapping-poc

Conversation

@h4nz4

@h4nz4 h4nz4 commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

The short version

A credential map is a recipe. You give it the ingredients (the input fields) and it should bake a credential.

Until now, the recipes could only move an ingredient from one place to another. That is not enough to bake a real credential, so almost every recipe in this repo produced a broken one. This PR lets recipes do a little more (with CEL, a tiny, safe expression language) and fixes every recipe in the repo: mDL, all 10 Europass Digital Credential (EDC / ELM) types, the Open Badge microcredential, PID and age verification. A local playground lets you try it.

It also adds a v2 of eight types whose v1 EDCs looked fine as JSON but lost most of their data when Europass read them (see v2 below).

Spec: specifications/cel-mapping.md

How to review

It looks big (about 32,700 added lines), but about 22,000 are generated or copied in, so there is much less to read than the number suggests.

Skip these (generated by a script, or vendored from an official source):

Files Made by
.autogen/* the existing CI builders
credential-definitions/**/examples/*-example.json npm run apply-map -- --write-examples (CI fails if stale)
resources/vocabularies/*.json npm run build-vocabularies (ELM XSDs, EU SPARQL)
profiles/*/*/rulebook.json npm run build-rulebooks (EUDI rulebooks)
profiles/*/*/contexts/*, profiles/edc/w3c-vc/shacl/*.ttl copied from W3C, 1EdTech and the ELM repo, see profiles/README.md
package-lock.json, demo/package-lock.json npm

Read in this order:

  1. specifications/cel-mapping.md: the rules, in about two pages.
  2. .github/scripts/apply-credential-map.js: the runner (build, checks, examples). Its tests are in apply-credential-map.test.js.
  3. One profile end to end: profiles/edc/w3c-vc/base-map.json, then credential-definitions/microcredential/v1/edc/w3c-vc/input-fields-to-credential-map.json.
  4. One v2 type: credential-definitions/degree-certificate/v2/ (map and schema), and one EAA type: credential-definitions/visa/v2/eaa/sd-jwt-vc/.
  5. Skim the remaining maps: they follow the same pattern.
  6. demo/ last; it's optional and doesn't affect the maps or CI.

Commits, if you prefer reading by step: the first two are the original mDL proof of concept; d5d91a4 fixes the EDC schemas; 43361ff EDC and Open Badge; 53262b4 the v2 types; 7c9e6b4 caveat fixes; 2ab9389 PID and age verification; 8c6df20 generated examples; 57654b9 rulebook and Open Badge checks; 2090e1b the playground; 7ecca1e the mDL biometric fix and removal of the signed examples.

Check it yourself: npm ci && npm run apply-map && npm test builds and validates every credential and runs the tests.

Before and after

Before After
mDL 15 schema errors ✓ valid
10 EDC types 11 to 42 schema errors each ✓ valid JSON Schema and ✓ valid against the official ELM SHACL shapes
Open Badge (microcredential) empty map, nothing built ✓ valid
v2: 6 learning types as ELM EDC didn't exist ✓ valid, and nothing is dropped when Europass reads them
v2: visa and boarding pass as EAA SD-JWT VC didn't exist ✓ valid
PID (mdoc and SD-JWT VC) 7 to 8 schema errors each ✓ valid
Age verification (mdoc) no docType ✓ valid

Try it:

npm install
npm run apply-map -- credential-definitions/microcredential/v1/edc/w3c-vc --print
npm run apply-map   # everything
npm run apply-map -- --write-examples   # after changing a map
npm test

Playground

Want to see it instead of reading it? demo/ is a small local web page. Pick any credential, change the input or the recipe, and watch the credential rebuild and re-validate as you type. Once it's valid, the page also signs it with a pretend issuer and checks the signature, the way a wallet or verifier would:

Format Signed as Checked by
mdoc (mDL, PID, age verification) ISO 18013-5, presented like a wallet would @auth0/mdl and pymdoccbor
SD-JWT VC (PID, visa, boarding pass) dc+sd-jwt with a key-binding presentation @sd-jwt/sd-jwt-vc and the OpenWallet Foundation Python library
EDC JAdES, the same header Velocert's DSS writes jose (the full B-LTA check needs DSS)
Open Badge VC-JWT jose
npm ci && npm --prefix demo ci && npm --prefix demo start   # http://localhost:8090

The demo has its own package.json, so CI and the map tooling don't install any of these libraries. Details in demo/README.md.

What changed, explained simply

1. A recipe line is now a small formula. The key says where the value goes, the value says what it is:

"/credentialSubject/fullName": "input.fullName",
"/credentialSubject/placeOfBirth/address/countryCode": "vocab.country[input.placeOfBirth.en]",
"/credentialSubject/nationalID": "has(input.nationalId) ? optional.of({...}) : optional.none()"

input.?x and optional.none() mean "if there is nothing, leave it out".

2. Shared base recipes per profile. All 10 EDC types share the same envelope (@context, type, issuer, display parameters…). Instead of copying it 10 times, it lives once in profiles/edc/w3c-vc/base-map.json. Open Badge has its own in profiles/open-badge/w3c-vc/. A type's own recipe is applied on top and wins on conflicts.

3. Things a recipe can now read:

Name What it is Like…
input the input fields the ingredients
meta what the issuer knows at issuance: issuer and awarding body (already in EDC or Open Badge shape, from onboarding), language, recipient, validity dates the kitchen's own supplies
vocab lookup tables from the official EU vocabularies, e.g. "Slovenia" → http://publications.europa.eu/resource/authority/country/SVN a dictionary
translations the type's title in every language the label on the box
now, uuid() current time and a fresh id the date stamp and a serial number

In tests, now and uuid() are fixed, so every run produces exactly the same credential.

4. EDCs are checked the way Europass checks them. Passing a JSON Schema only means the shape looks right. An EDC is linked data, so the runner also turns it into RDF (with the official ELM JSON-LD context) and validates it against the official ELM SHACL shapes. Everything is vendored, so this runs offline in about 0.3 s.

5. CI. A new job runs npm ci, npm run apply-map and npm test. Every map in the repo is now a CEL map, so every one of them can fail the build.

6. Works the same in Go. Every map entry and rule (624 of them) was evaluated with cel-go v0.28 and gave exactly the same values as the JS runner, so a Go issuer can use these files as they are.

v2: credentials that Europass can actually read

The problem. Think of an EDC as a form with official boxes. Eight v1 types wrote their own data in the margins (studentNumber, degreeProgramme, flightInformation, visaNumber…). The JSON shows the scribbles, but Europass only reads the boxes, so to Europass a v1 degree certificate is little more than a name.

The fix. v2 of these types writes everything into official ELM boxes. The input fields are exactly the same as v1, so the same data still goes in. Only the recipe and the schema change. v1 is left untouched, because the repo's rule is that existing versions never change and something may still read the v1 JSON paths.

Type v2 is…
degree-certificate a LearningAchievement, specified by a Qualification (the programme)
certificate-of-advanced-study a LearningAchievement with the ECTS points as creditReceived
confirmation-of-enrolment a LearningEntitlement: the right to study in the programme
matriculation a LearningEntitlement valid from matriculation start to end
certificate-of-participation-in-summer-school a LearningActivity (an educational programme) with its workload
student-id a LearningEntitlement of type membership
visa, boarding-pass not EDC any more. They aren't learning credentials, and ELM has no boxes for flights or visas, so v2 issues them as EAA SD-JWT VC (eaa/sd-jwt-vc), with Type Metadata

Also:

  • student, card, library and identity numbers become ELM Identifiers on the person (with a scheme name such as "Student number")
  • things ELM has no box for, but that still make sense as a sentence (academic year, programme status, ECTS progress, student discount, roles), become additionalNotes like "Academic year: 2026"
  • personTitle (matriculation) has no ELM home and is not carried in the v2 EDC
  • the v2 schemas are strict: an unknown field is a schema error

Wrong labels are caught at the door

Some input fields need an exact label from a lookup table, like a dropdown. They are now marked, e.g. "x-vocabulary": "country", so:

  • a wrong value ("Slovenian") is an input error that names the table, before the map even runs
  • a form can build the dropdown straight from resources/vocabularies/country.json

Marked fields: placeOfBirth in the v2 learning types, nationality in visa v2, and the vocabulary fields of microcredential and certificate-of-attendance v1.

SD-JWT VC type metadata

A vct is the credential's type name. A wallet can look it up to learn what the credential is called and how to show each field. Visa and boarding-pass v2 now ship that lookup file, type-metadata.json (SD-JWT VC Type Metadata, draft 19). It holds a label for every claim, which claims are mandatory, and that the holder may choose to disclose each one (sd: allowed). The vct is the file's raw GitHub URL on main, so it can be fetched once this PR is merged. The runner checks that the map and the file agree.

New lookup tables: entitlementType, entitlementStatus, learningActivityType (from ELM) and countryCode ("Slovenia" → SVN, for SD-JWT VC, which has no linked data).

PID and age verification

These are now CEL maps too, so every map in the repo is a CEL map and the old "move this field there" format is gone.

  • PID (mdoc and SD-JWT VC) gets its type name (docType, vct) and the issuer's values from meta: expiry and issuance date, issuing authority, country and jurisdiction, document number and trust anchor.
  • Age verification gets its missing docType. It can carry any number of age checks (ageOver18, ageOver21, ageOver65…). Plain CEL can't invent field names on the fly, so a map line can be a small template: age_over_{{NN}} ← input.ageOver{{NN}} is repeated once for every ageOverNN field in the input.

Checked against the official rules, not just our own

Our schemas are written by us, so passing them only proves we agree with ourselves. Where an official, machine-readable rule exists, the runner now checks it too:

Credential Official rule How it's checked
EDC (ELM) ELM SHACL shapes already in this PR (JSON-LD + SHACL)
PID (mdoc and SD-JWT VC) EUDI PID Rulebook its attribute tables are turned into rulebook.json: allowed names, mandatory ones, encodings, docType/vct
Age verification EUDI Age Verification Profile, Annex A same; only age_over_18 / age_over_NN allowed
Open Badge 3.0 1EdTech JSON Schema and JSON-LD contexts the schema already was the official one; the credential is now also expanded with the official contexts
mDL ISO/IEC 18013-5 not possible: the EUDI mDL rulebook only points to the ISO standard, which isn't freely available

The PID check found a real bug: our PID mdoc used the SD-JWT VC address shape (address.formatted, …) and a vct element, but the rulebook's mdoc encoding uses flat resident_address, resident_country, … and has no vct. That is fixed, and the portrait is now raw bytes as the rulebook requires.

Fixes to existing files

The EDC JSON Schemas rejected real, valid EDCs (including the ones Velocert issues today), so they are fixed in a separate commit:

  • the recipient e-mail had to be exactly "mailto:" (no real address could pass). Now any mailto: address passes.

  • display parameters and languages may be lists, as ELM allows

  • organisations may have an eIDASIdentifier, which the ELM shapes require for the issuer

  • microcredential: label checks pointed at the wrong level and used labels that are not in the ELM vocabularies; an assessment's specifiedBy was typed Qualification instead of LearningAssessmentSpecification

  • PID mdoc: the schema's nationality key had a trailing space ("nationality "), so a correct nationality was always rejected

  • PID input: nationality was declared a single string, but the example and both PID formats use a list (["DE", "AT"])

  • mDL: biometric templates were written as the literal biometric_template_xx. ISO/IEC 18013-5 §7.2.6 names them after the biometric type (biometric_template_face, biometric_template_signature_sign), so the map now uses a {{XX}} word template, the word-based sibling of {{NN}}

  • Signed examples removed. The signed EDC examples contained a real person's email address in this public repo, and none of them matched the current maps. The address is still in git history; scrubbing it there is a decision for the maintainers. The playground shows every format signed and verified instead

Small input changes:

  • microcredential gets a nationalIdCountry field (ELM needs the country of a national ID). An x-cel-rule makes it required when nationalId is set.
  • example inputs now use vocabulary labels: microcredential type → written examination, visa nationality → Slovenia
  • the age-verification example uses a real ageOver21 field instead of the literal key "ageOver{{NN}}"

Compatibility

  • Nothing that reads this repo breaks. The only reader we found, the africa-demo verifier, still fetches _generated/…. That folder was renamed in af1948b, so it was already out of date before this PR. A search of the Velocert, wallet and demo repos found no other reader of these maps or of the v1 field paths.
  • v1 of the 8 lossy types is marked deprecated and points to v2. Under the repo's version rule it stays in place.
  • One heads-up: the MyNextID wallet recognises a boarding pass by credentialSubject.flightInformation (the ksia shape). The v2 SD-JWT boarding pass doesn't have that, so the wallet needs to learn the new vct before it shows v2 as a boarding pass.

Decisions

  • Example credentials are generated, not hand-written. Every format folder has an examples/<profile>-<initials>-example.json built from its map. CI fails if one is out of date, so examples can't drift again. Regenerate with npm run apply-map -- --write-examples. Signed examples were removed (see Fixes).
  • Bug fixes inside existing versions are allowed. CONTRIBUTING already says so ("unless fixing a confirmed bug"), and the other two specs now say the same. Every in-place change here fixes a file that could not produce a valid credential.
  • Deprecated v1 stays forever. Versions are never deleted.
  • PID SD-JWT VC now allows iss, iat, nbf, exp, cnf and status, so a signed PID passes its own schema.

Sources

h4nz4 and others added 4 commits October 5, 2026 06:33
Use CEL expressions in input-fields-to-credential-map.json (keyed by
output JSON pointer) and x-cel-rules in input-fields/schema.json.
Convert the mobile-driving-licence v1 mdoc map, which fixes the
driving_privileges key casing and the broken weight pointer, and add
apply-credential-map.js to build each credential from its example and
validate it against the format schema. Maps keyed by input field keep
working unchanged.
The EDC schemas disagree with the ELM SHACL shapes and with the EDCs
Velocert issues today:

- contactPoint emailAddress id was const "mailto:", so no real address
  could pass. It is now a ^mailto:.+ pattern.
- individualDisplay, displayDetail and language may be lists in ELM.
  They now accept an object or a non-empty array.
- The issuer needs an eIDASIdentifier (mandatory in EDC-generic-no-cv),
  which additionalProperties rejected. Organisation now allows it.
- microcredential: prefLabel enums were applied to the LangString
  object instead of its "en" value, and used labels that are not in
  the ELM vocabularies ("ECTS"). LearningAssessment.specifiedBy is a
  LearningAssessmentSpecification, not a Qualification.
Convert every edc/w3c-vc map and the microcredential open-badge map to
CEL, building on the mDL proof of concept.

- profiles/<profile>/<format>/base-map.json holds what every type of a
  profile shares (EDC envelope, issuer, awarding process, display
  parameter; OB envelope and achievement skeleton). The type map is
  applied on top.
- meta is fixed per profile: profile-shaped issuer and awardingBody
  nodes, primaryLanguage, recipient and validity. Defaults live in
  profiles/<profile>/<format>/examples/issuance-meta.json.
- New CEL inputs: vocab (controlled-vocabulary tables generated from
  the ELM XSDs into resources/vocabularies), translations (the type's
  credential title per language), now and uuid(). The runner fixes now
  and the uuid() sequence so output is reproducible.
- EDCs are also expanded as JSON-LD and validated against the vendored
  ELM SHACL shapes (EDC-generic-full), offline. Fields the ELM context
  does not define are reported as warnings.
- CI runs apply-map and the runner tests in a new job. Only CEL maps
  fail the build; legacy maps are reported.
- microcredential gets a nationalIdCountry input field, required by
  an x-cel-rule when nationalId is set, for the LegalIdentifier
  spatial.

All CEL map entries and rules give the same values in cel-go v0.28.
@h4nz4 h4nz4 changed the title feat: CEL mapping proof of concept (mDL) feat: CEL credential maps for mDL, EDC (ELM) and Open Badge Oct 8, 2026
The v1 EDC maps of eight types put their type-specific fields into
properties the ELM JSON-LD context does not define, so Europass and
other linked-data verifiers never see them. v1 stays as it is; v2 fixes
this with the same input fields:

- degree-certificate, certificate-of-advanced-study: LearningAchievement
  specified by a Qualification; ECTS as creditReceived
- confirmation-of-enrolment, matriculation: LearningEntitlement
  (learning opportunity, actual); matriculation start and end as its
  dateIssued and expiryDate
- certificate-of-participation-in-summer-school: LearningActivity
  (educational programme) with its workload
- student-id: LearningEntitlement of type membership
- student numbers and card, library and identity numbers are ELM
  Identifiers on the person; statements without an ELM property
  (academic year, programme status, discounts, roles) are
  additionalNotes; personTitle is not carried
- visa, boarding-pass: not learning credentials, so v2 drops EDC and
  adds eaa/sd-jwt-vc with snake_case claims and a placeholder vct

All six v2 EDCs pass their new JSON Schemas and the ELM SHACL shapes
with no dropped fields. New vocabulary tables: entitlementType,
entitlementStatus, learningActivityType and countryCode (ISO 3166-1
alpha-3). cel-go v0.28 matches cel-js on all 568 entries.
@h4nz4 h4nz4 changed the title feat: CEL credential maps for mDL, EDC (ELM) and Open Badge feat: CEL credential maps for mDL, EDC (ELM), Open Badge and EAA Oct 8, 2026
h4nz4 added 2 commits October 8, 2026 07:14
- Input fields that take a vocabulary label carry "x-vocabulary": the
  runner rejects any other value as an input error, and forms can offer
  the labels from resources/vocabularies. Added to the v2 inputs and to
  microcredential and certificate-of-attendance v1.
- visa and boarding-pass v2 get SD-JWT VC Type Metadata
  (type-metadata.json, draft 19): labels, mandatory and sd per claim,
  all claims sd "allowed". The vct is now the raw GitHub URL of that
  file instead of a urn placeholder. The runner checks that the map's
  vct matches and that every claim is described.
- v1 of the eight remodelled types is marked deprecated in favour of v2.
Every map in the repository is now a CEL map, so the runner drops the
reader for maps keyed by input field: a key that is not a JSON pointer
is now a map error and every map is enforced in CI.

- age-verification v1 (eudi.av mdoc): adds the missing docType. A key
  with {{NN}} is a template that repeats for every matching input field
  (ageOver21 -> age_over_21), since standard CEL cannot build a map with
  computed keys. The example input uses ageOver21 instead of the
  literal "ageOver{{NN}}" key.
- personal-id v2 (eudi.pid mdoc and sd-jwt-vc): add vct and docType,
  and the issuer values (expiry and issuance date, issuing authority,
  country and jurisdiction, document number, trust anchor) from meta.
- Fixes: the PID mdoc namespace schema had a "nationality " key with a
  trailing space, and the PID input schema declared nationality as a
  string while the example and both formats use a list of codes.

cel-go v0.28 matches cel-js on all 626 entries.
@h4nz4 h4nz4 changed the title feat: CEL credential maps for mDL, EDC (ELM), Open Badge and EAA feat: CEL credential maps for every credential type Oct 8, 2026
h4nz4 added 4 commits October 8, 2026 07:34
- The runner writes each format folder's unsigned example
  (examples/<profile>-<initials>-example.json) from the input example
  with --write-examples, and fails when a committed example is missing
  or out of date, so examples cannot drift from the maps again. The
  initials come from an existing example of the type, else from the
  words of its name. All 23 format folders now have one; the
  hand-written v1 examples are replaced.
- Signed examples are kept as they are and documented as historical.
- PID SD-JWT VC schema: allow iss, iat, nbf, exp, cnf and status, so a
  signed PID passes its own schema.
- The version rule in credential-type-structure and naming-conventions
  now names the bug-fix exception that CONTRIBUTING already allows.
- build-rulebooks.js parses the attribute tables of the EUDI PID
  Rulebook (ARF Annex 3.01) and the Age Verification Profile (Annex A),
  pinned to a commit, into profiles/<profile>/<format>/rulebook.json.
  The runner checks docType or vct, that every element or claim is in
  the rulebook, that mandatory ones are present, and their encoding.
  The mDL rulebook defers to ISO/IEC 18013-5, so mDL has none.
- The check found the PID mdoc used the SD-JWT VC address structure and
  a vct element, neither of which the rulebook's mdoc encoding has. It
  now writes the flat resident_* elements (street including the house
  number) and the portrait as bytes (base64), and all three PID schemas
  accept the rulebook's sex codes 0-6 and 9.
- Open Badge is expanded as JSON-LD with the vendored VC 2.0 and OB 3.0.3
  contexts, so undefined fields are reported as for EDC. shacl.json is
  renamed linked-data.json, with shapes optional.
- Maps may use the CEL strings extension (split, substring, indexOf);
  cel-go runs it with ext.Strings() and still matches on all entries.
A local page to edit input fields, meta, input rules and map
expressions and watch the credential and its validation update: format
JSON Schema, EUDI rulebook, and JSON-LD/SHACL. Once a claim set is
valid, it is signed with a mock PKI and verified, for every format:

- mdoc: ISO/IEC 18013-5 IssuerSigned, presented over OpenID4VP,
  verified by @auth0/mdl and pymdoccbor (Python)
- SD-JWT VC: dc+sd-jwt with disclosures per the Type Metadata,
  presented with a key-binding JWT, verified by @sd-jwt/sd-jwt-vc and
  the OpenWallet Foundation sd-jwt library (Python)
- EDC: JAdES baseline-B with the protected header Velocert's DSS
  produces, verified with jose (B-LTA needs DSS and is shown as skipped)
- Open Badge 3.0: VC-JWT per Open Badges 3.0 §8.2.4, verified with jose

The demo has its own package.json, so CI and the map tooling never
install its signing libraries. @sd-jwt/sd-jwt-vc is pinned to 0.21 and
its @owf/* dependencies to 0.4.0. @owf/cose and @auth0/mdl both
register global cbor-x handlers for tags 24 and 1004, so mdoc.js loads
@sd-jwt/sd-jwt-vc first and @auth0/mdl's handlers win.

Run: npm ci && npm --prefix demo ci && npm --prefix demo start
- mDL: ISO/IEC 18013-5 §7.2.6 names biometric templates
  biometric_template_<type>, the ISO/IEC 19785-3 biometric type in snake
  case (biometric_template_face, biometric_template_signature_sign).
  The map wrote the literal biometric_template_xx, the input pattern
  expected 5 characters and the mdoc schema 2. A {{XX}} key template now
  stands for a capitalised word, written in snake case in the pointer:
  biometricTemplateFace -> biometric_template_face. The validator
  accepts {{XX}} pattern keys as it does {{NN}}.
- Remove the signed examples. The EDC ones contained a real person's
  email address in this public repository, and none of them matched the
  current maps; the playground shows every format signed and verified.
  The address remains in git history.
@h4nz4
h4nz4 force-pushed the feat/cel-mapping-poc branch from aeabeef to 7ecca1e Compare October 8, 2026 07:10

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants