@digitalcredentials/issuer-core
v0.1.0
Published
VC API Issuer library.
Downloads
2
Readme
Issuer (@digitalcredentials/issuer-core)
VC API Issuer library.
Table of Contents
Background
Security
Install
- Node.js 16+ is recommended.
NPM
To install via NPM:
npm install @digitalcredentials/issuer-core
Development
To install locally (for development):
git clone https://github.com/digitalcredentials/issuer-core.git
cd issuer-core
npm install
Usage
You can use issuer-core
to help build a standalone VC-API issuer service.
For example:
import { IssuerInstance } from '@digitalcredentials/issuer-core'
import { securityLoader } from '@digitalcredentials/security-document-loader'
import { Ed25519Signature2020 } from '@digitalcredentials/ed25519-signature-2020'
import fastify from 'fastify'
import * as didKey from '@digitalcredentials/did-method-key'
const documentLoader = securityLoader({ fetchRemoteContexts: true }).build()
// load secret key seed from config file, to generate issuer DID
const didKeyDriver = didKey.driver()
const {methodFor} = await didKeyDriver.generate({ seed })
const signingKeyPair = methodFor({ purpose: 'assertionMethod' })
const signingSuite = new Ed25519Signature2020({ key: signingKeyPair })
const issuerInstance = new IssuerInstance({ documentLoader, signingSuite })
const server = fastify(serverOptions)
server.post('/credentials/issue', async (req, res) => {
// parse the incoming body according to VC-API specs, validate via JSON Schema ...
const {credential, options} = parseBody(req)
const signedCredential = await issuerInstance.issueCredential({ credential, options })
// return it in the response etc
})
Contribute
PRs accepted.
If editing the Readme, please conform to the standard-readme specification.
License
MIT License © 2023 Digital Credentials Consortium.