Skip to content
JavaScript implementation of W3C Verifiable Credentials standard
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Remove challenge from issue(). May 24, 2019
lib Use common conditional style. May 24, 2019
tests Add better assertions for failing verifiable credential test. May 24, 2019
.babelrc Update babel deps, provide documentLoader, embed vc contexts. Apr 23, 2019
.editorconfig
.eslintrc.js Add eslint to project. May 3, 2019
.gitignore Implement test for verify API. Apr 23, 2019
.travis.yml Add travis yml file. May 7, 2019
CHANGELOG.md Add CHANGELOG. Apr 23, 2019
LICENSE
README.md Standardize capitalization. May 24, 2019
karma.conf.js
package.json Add better assertions for failing verifiable credential test. May 24, 2019
webpack.config.js Add initial files. Apr 23, 2019

README.md

Verifiable Credentials JS Library (vc-js)

Build Status

A Javascript library for issuing and verifying Verifiable Credentials

Table of Contents

Security

TBD

Background

TBD

See also (related specs):

Install

  • Node.js 8.3+ required.
  • Node.js 10.12.0+ is highly recommended due to RSA key generation speed.

To install locally (for development):

git clone https://github.com/digitalbazaar/vc-js.git
cd vc-js
npm install

Usage

Use on the command line, or see the API section below.

Issuing Credentials

To issue a verifiable credential, you need the following:

  • A URL for the public key
  • A local PEM encoded private key file
  • The input credential (cred.json in the example)
./bin/vc-js issue --issuer "https://example.com/keys/1" --private-key example.pem < cred.json

Verifying Credentials

API

Issuing a Verifiable Credential - issue()

const vc = require('vc-js');

// generate a publicKey / privateKeyBase58 (not shown here)

const suite = new Ed25519Signature2018({
  verificationMethod: publicKey.id,
  key: new Ed25519KeyPair({privateKeyBase58})
});

vc.issue({credential, suite})
  .then(issuedVc => console.log)
  .catch(console.error);

Creating a Verifiable Presentation - createPresentation()

To create a verifiable presentation out of one or more verifiable credentials:

const verifiableCredential = [vc1, vc2];

const suite = new Ed25519Signature2018({
  verificationMethod: publicKey.id,
  key: new Ed25519KeyPair({privateKeyBase58})
});

vc.createPresentation({verifiableCredential, suite})
  .then(vp => console.log)
  .catch(console.error);

Verifying - verify()

To verify a verifiable credential:

vc.verify({credential, suite})
  .then(result => console.log)
  .catch(console.error);

To verify a verifiable presentation:

vc.verify({presentation, suite})
  .then(result => console.log)
  .catch(console.error);

Testing

To run Mocha tests:

npm run mocha

To run the VC Test Suite:

npm run fetch-vc-test-suite
npm test

Contribute

See the contribute file!

PRs accepted.

Small 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: support@digitalbazaar.com

License

New BSD License (3-clause) © Digital Bazaar

You can’t perform that action at this time.