Skip to content

digitalbazaar/oid4-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OID4Client Library (@digitalbazaar/oid4-client)

NPM Version

A JavaScript library for working with the OpenID 4 Verifiable Credential Issuance (OID4VCI) protocol, offering functionality for requesting Verifiable Credentials.

Table of Contents

Background

This library is a JavaScript (Node.js and browser) implementation of the OID4VCI v11 Protocol.

It allows you to perform the following operations:

  1. Request a credential to be issued given a OID4VCI credential offer.
  2. Request multiple credentials to be issued given a OID4VCI credential offer.
  3. Authenticate using a DID if the offer requires it.

Install

npm install @digitalbazaar/oid4-client

Usage

Importing the Library

import { OID4Client } from "@digitalbazaar/oid4-client";

Creating a Client from a Credential Offer

const clientFromOffer = await OID4Client.fromCredentialOffer({
  offer: "YOUR_CREDENTIAL_OFFER",
});

Constructor

You can also instantiate the OID4Client directly using the following parameters:

  • accessToken (Optional)
  • issuerConfig
  • metadata
  • offer

Example:

const client = new OID4Client({
  accessToken: "YOUR_ACCESS_TOKEN",
  issuerConfig: "YOUR_ISSUER_CONFIG",
  metadata: "YOUR_METADATA",
  offer: "YOUR_OFFER",
});

Requesting a Credential

To request a single credential using the credential offer:

const credential = await client.requestCredential({
  did: "YOUR_DID",
  didProofSigner: "YOUR_DID_PROOF_SIGNER",
});

To request multiple credentials using the credential offer:

const credentials = await client.requestCredentials({
  did: "YOUR_DID",
  didProofSigner: "YOUR_DID_PROOF_SIGNER",
});

Requesting a Credential By Definition

To request a single credential using a specific credential definition:

const credential = await client.requestCredential({
  credentialDefinition: "YOUR_CREDENTIAL_DEFINITION",
  did: "YOUR_DID",
  didProofSigner: "YOUR_DID_PROOF_SIGNER",
});

To request multiple credentials using credential definition requests:

const credentials = await client.requestCredentials({
  requests: "YOUR_REQUESTS",
  did: "YOUR_DID",
  didProofSigner: "YOUR_DID_PROOF_SIGNER",
});

Testing

To run tests:

npm run test

Contribute

See the contribute file!

PRs accepted.

Note: If editing the Readme, please conform to the standard-readme specification.

Commercial Support

Commercial support for this library is available upon request from Digital Bazaar: [email protected]

License

New BSD License (3-clause) © Digital Bazaar