{"id":16325508,"url":"https://github.com/auth0-lab/mdl","last_synced_at":"2025-04-04T11:07:39.653Z","repository":{"id":224102302,"uuid":"669143153","full_name":"auth0-lab/mdl","owner":"auth0-lab","description":"Parse and validate MDOC CBOR encoded binaries according to ISO 18013-5.","archived":false,"fork":false,"pushed_at":"2025-03-26T14:46:34.000Z","size":501,"stargazers_count":85,"open_issues_count":10,"forks_count":6,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-28T10:01:43.434Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/auth0-lab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-21T12:55:03.000Z","updated_at":"2025-03-26T14:45:51.000Z","dependencies_parsed_at":"2024-02-23T19:43:27.959Z","dependency_job_id":"980d3b72-30cd-464b-9e9e-860bd949df8b","html_url":"https://github.com/auth0-lab/mdl","commit_stats":{"total_commits":112,"total_committers":6,"mean_commits":"18.666666666666668","dds":0.3214285714285714,"last_synced_commit":"33c849ae25c226697955cb03dd4eacba926e1690"},"previous_names":["auth0-lab/mdl"],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0-lab%2Fmdl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0-lab%2Fmdl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0-lab%2Fmdl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0-lab%2Fmdl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/auth0-lab","download_url":"https://codeload.github.com/auth0-lab/mdl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247159964,"owners_count":20893726,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T23:05:12.066Z","updated_at":"2025-04-04T11:07:39.628Z","avatar_url":"https://github.com/auth0-lab.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/@auth0%2Fmdl.svg)](https://badge.fury.io/js/@auth0%2Fmdl)\n\n# mDL\n\n[ISO 18013-5](https://www.iso.org/standard/69084.html) defines mDL (mobile Driver Licenses): an ISO standard for digital driver licenses.\n\nThis is a Node.js library to issue and verify mDL [CBOR encoded](https://cbor.io/) documents in accordance with **ISO 18013-7 (draft's date: 2023-08-02)**.\n\n## Installation\n\n```bash\nnpm i @auth0/mdl\n```\n\n## Verifying a credential\n\n```javascript\nimport { Verifier } from \"@auth0/mdl\";\nimport { inspect } from \"node:util\";\nimport fs from \"node:fs\";\n\n(async () =\u003e {\n  const encodedDeviceResponse = Buffer.from(encodedDeviceResponseHex, 'hex');\n  const encodedSessionTranscript = Buffer.from(encodedSessionTranscriptHex, 'hex');\n  const ephemeralReaderKey = Buffer.from(ephemeralReaderKeyHex, 'hex');\n\n  const trustedCerts = [fs.readFileSync('./caCert1.pem')/*, ... */];\n  const verifier = new Verifier(trustedCerts);\n  const mdoc = await verifier.verify(encodedDeviceResponse, {\n    ephemeralReaderKey,\n    encodedSessionTranscript,\n  });\n\n  //at this point the issuer and device signature are valids.\n  inspect(mdoc);\n})();\n```\n\n## Getting diagnostic information\n\n```javascript\nimport { Verifier } from \"@auth0/mdl\";\nimport { inspect } from \"node:util\";\nimport fs from \"node:fs\";\n\n(async () =\u003e {\n  const encodedDeviceResponse = Buffer.from(encodedDeviceResponseHex, 'hex');\n  const encodedSessionTranscript = Buffer.from(encodedSessionTranscriptHex, 'hex');\n  const ephemeralReaderKey = Buffer.from(ephemeralReaderKeyHex, 'hex');\n\n  const trustedCerts = [fs.readFileSync('./caCert1.pem')/*, ... */];\n  const verifier = new Verifier(trustedCerts);\n\n  const diagnosticInfo = await verifier.getDiagnosticInformation(encodedDeviceResponse, {\n    ephemeralReaderKey,\n    encodedSessionTranscript,\n  });\n\n  inspect(diagnosticInfo);\n})();\n```\n\n## Issuing a credential\n\n```js\nimport { MDoc, Document } from \"@auth0/mdl\";\nimport { inspect } from \"node:util\";\n\n(async () =\u003e {\n  const document = await new Document('org.iso.18013.5.1.mDL')\n    .addIssuerNameSpace('org.iso.18013.5.1', {\n      family_name: 'Jones',\n      given_name: 'Ava',\n      birth_date: '2007-03-25',\n    })\n    .useDigestAlgorithm('SHA-256')\n    .addValidityInfo({\n      signed: new Date(),\n    })\n    .addDeviceKeyInfo({ deviceKey: publicKeyJWK })\n    .sign({\n      issuerPrivateKey,\n      issuerCertificate,\n    });\n\n  const mdoc = new MDoc([document]).encode();\n\n  inspect(encoded);\n})();\n```\n\n## Generating a device response\n\n```js\nimport { DeviceResponse, MDoc } from '@auth0/mdl';\n\n(async () =\u003e {\n  let issuerMDoc;\n  let deviceResponseMDoc;\n\n  /**\n   * This is what the MDL issuer does to generate a credential:\n   */\n  {\n    let issuerPrivateKey;\n    let issuerCertificate;\n    let devicePublicKey; // the public key for the device, as a JWK\n\n    const document = await new Document('org.iso.18013.5.1.mDL')\n      .addIssuerNameSpace('org.iso.18013.5.1', {\n        family_name: 'Jones',\n        given_name: 'Ava',\n        birth_date: '2007-03-25',\n      })\n      .useDigestAlgorithm('SHA-256')\n      .addValidityInfo({\n        signed: new Date(),\n      })\n      .addDeviceKeyInfo({ deviceKey: devicePublicKey })\n      .sign({\n        issuerPrivateKey,\n        issuerCertificate,\n        alg: 'ES256',\n      });\n\n    issuerMDoc = new MDoc([document]).encode();\n  }\n\n  /**\n   * This is what the DEVICE does to generate a response...\n   */\n  {\n    let devicePrivateKey; // the private key for the device, as a JWK\n\n    // Parameters coming from the OID4VP transaction\n    let mdocGeneratedNonce, clientId, responseUri, verifierGeneratedNonce;\n    let presentationDefinition = {\n      id: 'family_name_only',\n      input_descriptors: [\n        {\n          id: 'org.iso.18013.5.1.mDL',\n          format: { mso_mdoc: { alg: ['EdDSA', 'ES256'] } },\n          constraints: {\n            limit_disclosure: 'required',\n            fields: [{\n                path: [\"$['org.iso.18013.5.1']['family_name']\"],\n                intent_to_retain: false,\n              }],\n          },\n        },\n      ],\n    };\n\n    deviceResponseMDoc = await DeviceResponse.from(issuerMDoc)\n      .usingPresentationDefinition(presentationDefinition)\n      .usingSessionTranscriptForOID4VP(mdocGeneratedNonce, clientId, responseUri, verifierGeneratedNonce)\n      .authenticateWithSignature(devicePrivateKey, 'ES256')\n      .sign();\n  }\n})();\n```\n\n## License\n\nApache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauth0-lab%2Fmdl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fauth0-lab%2Fmdl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauth0-lab%2Fmdl/lists"}