From e8551d687b7bc1f6c1a2330a49de8eb8b89fa0b9 Mon Sep 17 00:00:00 2001 From: Dmitri Zagidulin Date: Sun, 9 Aug 2020 22:59:08 -0400 Subject: [PATCH 01/32] Update to latest crypto-ld and jsigs api. --- bin/vc-js | 2 +- package.json | 9 ++++++--- tests/10-verify.spec.js | 12 ++++++------ webpack.config.js | 3 --- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/bin/vc-js b/bin/vc-js index 3cd9d2c7..bb72b619 100755 --- a/bin/vc-js +++ b/bin/vc-js @@ -5,7 +5,7 @@ const getStdin = require('get-stdin'); const program = require('commander'); const vc = require('../lib/'); const jsigs = require('jsonld-signatures'); -const {Ed25519KeyPair} = require('crypto-ld'); +const {Ed25519VerificationKey2018} = require('@digitalbazaar/ed25519-verification-key-2018'); /* eslint-disable no-unused-vars */ diff --git a/package.json b/package.json index 11295c5d..495bad13 100644 --- a/package.json +++ b/package.json @@ -40,11 +40,12 @@ "fs-extra": "^8.1.0", "get-stdin": "^7.0.0", "jsonld": "^2.0.2", - "jsonld-signatures": "^5.0.0", + "jsonld-signatures": "digitalbazaar/jsonld-signatures#v6.x", "supports-color": "^7.1.0" }, "browser": { "bs58": false, + "Buffer": false, "crypto": false, "sodium-native": false, "util": false @@ -60,12 +61,14 @@ "@babel/preset-env": "^7.8.3", "@babel/register": "^7.8.3", "@babel/runtime": "^7.8.3", + "@digitalbazaar/ed25519-signature-2018": "digitalbazaar/ed25519-signature-2018#initial", + "@digitalbazaar/ed25519-verification-key-2018": "^1.0.2", "babel-loader": "^8.0.5", "browserify": "^16.2.3", "chai": "^4.1.2", "core-js": "^3.6.4", "cross-env": "^7.0.0", - "crypto-ld": "^3.7.0", + "crypto-ld": "^4.0.2", "did-context": "^2.0.0", "did-veres-one": "^10.0.1", "eslint": "^6.8.0", @@ -90,7 +93,7 @@ "webpack-merge": "^4.2.2" }, "engines": { - "node": ">=8" + "node": ">=12" }, "keywords": [ "JSON", diff --git a/tests/10-verify.spec.js b/tests/10-verify.spec.js index 17626b1d..af749fdc 100644 --- a/tests/10-verify.spec.js +++ b/tests/10-verify.spec.js @@ -1,10 +1,10 @@ const chai = require('chai'); const should = chai.should(); -const {Ed25519KeyPair} = require('crypto-ld'); +const {Ed25519VerificationKey2018} = require('@digitalbazaar/ed25519-verification-key-2018'); const jsigs = require('jsonld-signatures'); const jsonld = require('jsonld'); -const {Ed25519Signature2018} = jsigs.suites; +const {Ed25519Signature2018} = require('@digitalbazaar/ed25519-signature-2018'); const CredentialIssuancePurpose = require('../lib/CredentialIssuancePurpose'); const mockData = require('./mocks/mock.data'); @@ -51,7 +51,7 @@ const documentLoader = testLoader.documentLoader.bind(testLoader); before(async () => { // Set up the key that will be signing and verifying - keyPair = await Ed25519KeyPair.generate({ + keyPair = await Ed25519VerificationKey2018.generate({ id: 'https://example.edu/issuers/keys/1', controller: 'https://example.edu/issuers/565049' }); @@ -67,7 +67,7 @@ before(async () => { contexts['https://example.edu/issuers/keys/1'] = keyPair.publicNode(); // Set up the signature suite, using the generated key - suite = new jsigs.suites.Ed25519Signature2018({ + suite = new Ed25519Signature2018({ verificationMethod: 'https://example.edu/issuers/keys/1', key: keyPair }); @@ -86,9 +86,9 @@ describe('vc.issue()', () => { }); it('should throw an error on missing verificationMethod', async () => { - const suite = new jsigs.suites.Ed25519Signature2018({ + const suite = new Ed25519Signature2018({ // Note no key id or verificationMethod passed to suite - key: await Ed25519KeyPair.generate() + key: await Ed25519VerificationKey2018.generate() }); let error; try { diff --git a/webpack.config.js b/webpack.config.js index 6d5305ee..f5688925 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,9 +2,6 @@ module.exports = { entry: { 'vc-js': './lib/index.js' }, - externals: { - 'bitcore-message': '\'bitcore-message\'' - }, mode: 'production', output: { filename: '[name].min.js', From 9b5776611b4ffd9b153ce9feb194214d1c09b20e Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Sun, 23 Aug 2020 02:24:51 -0400 Subject: [PATCH 02/32] Update workflow. - Remove CI env. - Add timeouts. - Add and use Node.js 14.x. --- .github/workflows/main.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 03b8e63e..9a5d4c86 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,9 +5,10 @@ on: [push] jobs: test-node: runs-on: ubuntu-latest + timeout-minutes: 10 strategy: matrix: - node-version: [10.x, 12.x] + node-version: [10.x, 12.x, 14.x] steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} @@ -17,13 +18,12 @@ jobs: - run: npm install - name: Run test with Node.js ${{ matrix.node-version }} run: npm run test-node - env: - CI: true test-karma: runs-on: ubuntu-latest + timeout-minutes: 10 strategy: matrix: - node-version: [12.x] + node-version: [14.x] steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} @@ -33,13 +33,12 @@ jobs: - run: npm install - name: Run karma tests run: npm run test-karma - env: - CI: true lint: runs-on: ubuntu-latest + timeout-minutes: 10 strategy: matrix: - node-version: [12.x] + node-version: [14.x] steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} @@ -52,9 +51,10 @@ jobs: coverage: needs: [test-node, test-karma] runs-on: ubuntu-latest + timeout-minutes: 10 strategy: matrix: - node-version: [12.x] + node-version: [14.x] steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} @@ -64,8 +64,6 @@ jobs: - run: npm install - name: Generate coverage report run: npm run coverage-ci - env: - CI: true - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 with: From b8ff01995c6a106822540f9a016f6fc7f2fe0a8a Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Sun, 23 Aug 2020 02:26:37 -0400 Subject: [PATCH 03/32] Fix coverage output. --- .github/workflows/main.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9a5d4c86..7e999948 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,5 +67,5 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 with: - file: ./coverage.lcov + file: ./coverage/lcov.info fail_ci_if_error: true diff --git a/package.json b/package.json index 495bad13..2da2f935 100644 --- a/package.json +++ b/package.json @@ -115,7 +115,7 @@ "test-karma": "karma start karma.conf.js", "lint": "eslint '*.js' 'lib/**.js' 'tests/**.js' bin/vc-js", "coverage": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text-summary npm run test-node", - "coverage-ci": "cross-env NODE_ENV=test nyc --reporter=text-lcov npm run test-node > coverage.lcov", + "coverage-ci": "cross-env NODE_ENV=test nyc --reporter=lcovonly run test-node", "coverage-report": "nyc report" } } From e91e7b8406a6cb24a20330d1fe8692829269257d Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Sun, 23 Aug 2020 02:39:59 -0400 Subject: [PATCH 04/32] Update dependencies. --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 2da2f935..6c898a94 100644 --- a/package.json +++ b/package.json @@ -71,9 +71,9 @@ "crypto-ld": "^4.0.2", "did-context": "^2.0.0", "did-veres-one": "^10.0.1", - "eslint": "^6.8.0", + "eslint": "^7.7.0", "eslint-config-digitalbazaar": "^2.0.0", - "eslint-plugin-jsdoc": "^20.3.1", + "eslint-plugin-jsdoc": "^30.2.4", "karma": "^4.4.1", "karma-babel-preprocessor": "^8.0.0", "karma-chai": "^0.1.0", @@ -82,7 +82,7 @@ "karma-mocha-reporter": "^2.2.5", "karma-sourcemap-loader": "^0.3.7", "karma-webpack": "^4.0.2", - "mocha": "^7.0.0", + "mocha": "^7.2.0", "nyc": "^15.0.0", "regenerator-runtime": "^0.13.1", "typescript": "^4.0.3", From 1008b995f8cde4fb1d8d082d0db0d997edb40ffc Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Sun, 23 Aug 2020 02:40:50 -0400 Subject: [PATCH 05/32] Fix lint issues. --- bin/vc-js | 3 ++- tests/10-verify.spec.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/vc-js b/bin/vc-js index bb72b619..04a4f1ec 100755 --- a/bin/vc-js +++ b/bin/vc-js @@ -5,7 +5,8 @@ const getStdin = require('get-stdin'); const program = require('commander'); const vc = require('../lib/'); const jsigs = require('jsonld-signatures'); -const {Ed25519VerificationKey2018} = require('@digitalbazaar/ed25519-verification-key-2018'); +const {Ed25519VerificationKey2018} = + require('@digitalbazaar/ed25519-verification-key-2018'); /* eslint-disable no-unused-vars */ diff --git a/tests/10-verify.spec.js b/tests/10-verify.spec.js index af749fdc..da1d6845 100644 --- a/tests/10-verify.spec.js +++ b/tests/10-verify.spec.js @@ -1,7 +1,8 @@ const chai = require('chai'); const should = chai.should(); -const {Ed25519VerificationKey2018} = require('@digitalbazaar/ed25519-verification-key-2018'); +const {Ed25519VerificationKey2018} = + require('@digitalbazaar/ed25519-verification-key-2018'); const jsigs = require('jsonld-signatures'); const jsonld = require('jsonld'); const {Ed25519Signature2018} = require('@digitalbazaar/ed25519-signature-2018'); From 7de89b517722bddeb455acb574881237f765a9ef Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Sun, 23 Aug 2020 02:41:14 -0400 Subject: [PATCH 06/32] Update API usage. --- bin/vc-js | 5 +++-- tests/10-verify.spec.js | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/vc-js b/bin/vc-js index 04a4f1ec..54e387bb 100755 --- a/bin/vc-js +++ b/bin/vc-js @@ -109,7 +109,7 @@ const testKey = { '53KBp86VkzDKthrZdQCKv4UaAWd74DWCqgbmYmXuLytg' + 'bU7pFghAWs23Tdd9iacMLZtkvwdo5vCvDQ8vj24HdJYv' }; -const testKeyPair = new Ed25519KeyPair(testKey); +const testKeyPair = new Ed25519VerificationKey2018(testKey); const controller = { '@context': 'https://w3id.org/security/v2', @@ -119,7 +119,8 @@ const controller = { const testContext = require('../lib/contexts'); testContext['https://example.edu/issuers/14'] = controller; -testContext['https://example.edu/issuers/keys/1'] = testKeyPair.publicNode(); +testContext['https://example.edu/issuers/keys/1'] = + testKeyPair.export({publicKey: true}); testContext['https://example.org/examples/degree.json'] = {}; async function testDocumentLoader(url) { diff --git a/tests/10-verify.spec.js b/tests/10-verify.spec.js index da1d6845..4f2c9d02 100644 --- a/tests/10-verify.spec.js +++ b/tests/10-verify.spec.js @@ -65,7 +65,8 @@ before(async () => { // Register the controller document and the key document with documentLoader contexts['https://example.edu/issuers/565049'] = assertionController; // FIXME this might require a security context. - contexts['https://example.edu/issuers/keys/1'] = keyPair.publicNode(); + contexts['https://example.edu/issuers/keys/1'] = + keyPair.export({publicKey: true}); // Set up the signature suite, using the generated key suite = new Ed25519Signature2018({ From e3d86d768db28f91e46f26f90a4ae875e6015e18 Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Sun, 23 Aug 2020 02:43:32 -0400 Subject: [PATCH 07/32] Remove testing on Node.js 10.x. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7e999948..dd7665a3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: timeout-minutes: 10 strategy: matrix: - node-version: [10.x, 12.x, 14.x] + node-version: [12.x, 14.x] steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} From dcfff1f27d6a30f3a7db07ab1801b1e383370b68 Mon Sep 17 00:00:00 2001 From: Dmitri Zagidulin Date: Sun, 7 Mar 2021 22:03:34 -0500 Subject: [PATCH 08/32] Remove bin/, rename test/ dir, update copyright. --- .github/workflows/main.yml | 2 +- LICENSE | 2 +- README.md | 2 +- bin/vc-js | 238 ------------------- bin/vc-js-issuer | 3 - bin/vc-js-verifier | 3 - bin/vc-test | 8 - karma.conf.js | 8 +- lib/CredentialIssuancePurpose.js | 2 +- lib/contexts/index.js | 2 +- lib/contexts/odrl.js | 2 +- lib/contexts/vc-examples-v1.js | 2 +- lib/documentLoader.js | 2 +- lib/index.js | 2 +- lib/vc.js | 2 +- package.json | 34 ++- {tests => test}/.eslintrc | 0 {tests => test}/10-verify.spec.js | 4 +- {tests => test}/MultiLoader.js | 0 {tests => test}/constants.js | 0 {tests => test}/contexts/index.js | 0 {tests => test}/contexts/invalid_id.json | 0 {tests => test}/contexts/null_id.json | 0 {tests => test}/contexts/null_type.json | 0 {tests => test}/contexts/null_version.json | 0 {tests => test}/mocha.opts | 0 {tests => test}/mocks/assertionController.js | 0 {tests => test}/mocks/credential.js | 0 {tests => test}/mocks/didDocument.js | 0 {tests => test}/mocks/didKeys.js | 0 {tests => test}/mocks/mock.data.js | 0 31 files changed, 30 insertions(+), 288 deletions(-) delete mode 100755 bin/vc-js delete mode 100755 bin/vc-js-issuer delete mode 100755 bin/vc-js-verifier delete mode 100755 bin/vc-test rename {tests => test}/.eslintrc (100%) rename {tests => test}/10-verify.spec.js (99%) rename {tests => test}/MultiLoader.js (100%) rename {tests => test}/constants.js (100%) rename {tests => test}/contexts/index.js (100%) rename {tests => test}/contexts/invalid_id.json (100%) rename {tests => test}/contexts/null_id.json (100%) rename {tests => test}/contexts/null_type.json (100%) rename {tests => test}/contexts/null_version.json (100%) rename {tests => test}/mocha.opts (100%) rename {tests => test}/mocks/assertionController.js (100%) rename {tests => test}/mocks/credential.js (100%) rename {tests => test}/mocks/didDocument.js (100%) rename {tests => test}/mocks/didKeys.js (100%) rename {tests => test}/mocks/mock.data.js (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dd7665a3..aaa12334 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,7 +31,7 @@ jobs: with: node-version: ${{ matrix.node-version }} - run: npm install - - name: Run karma tests + - name: Run karma test run: npm run test-karma lint: runs-on: ubuntu-latest diff --git a/LICENSE b/LICENSE index 4e51ef53..c362d5e3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ BSD 3-Clause License -Copyright (c) 2017-2020, Digital Bazaar, Inc. +Copyright (c) 2017-2021, Digital Bazaar, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.md b/README.md index 26497e77..4a5ba3bc 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Build Status](https://travis-ci.org/digitalbazaar/vc-js.png?branch=master)](https://travis-ci.org/digitalbazaar/vc-js) [![NPM Version](https://img.shields.io/npm/v/vc-js.svg?style=flat-square)](https://npm.im/vc-js) -> A Javascript library for issuing and verifying Verifiable Credentials +> A Javascript library for issuing and verifying Verifiable Credentials. ## Table of Contents diff --git a/bin/vc-js b/bin/vc-js deleted file mode 100755 index 54e387bb..00000000 --- a/bin/vc-js +++ /dev/null @@ -1,238 +0,0 @@ -#!/usr/bin/env node - -const fs = require('fs-extra'); -const getStdin = require('get-stdin'); -const program = require('commander'); -const vc = require('../lib/'); -const jsigs = require('jsonld-signatures'); -const {Ed25519VerificationKey2018} = - require('@digitalbazaar/ed25519-verification-key-2018'); - -/* eslint-disable no-unused-vars */ - -// debuggers -const loaderDebug = require('debug')('vc:loader'); - -function inc(value, total) { - return total + 1; -} - -if(process.env.JSONLD_LOADER_MAP) { - const map = {}; - const cache = {}; - const oldLoader = vc.documentLoader; - process.env.JSONLD_LOADER_MAP - .split(',') - .map(v => v.split('=')) - .forEach(v => map[v[0]] = v[1]); - loaderDebug('map: %O', map); - vc.documentLoader = async url => { - if(url in cache) { - // already loaded - loaderDebug('from cache: %s', url); - } else if(url in map) { - // load from file - loaderDebug('from file: %s', url); - cache[url] = { - contextUrl: null, - documentUrl: url, - document: JSON.parse(await fs.readFile(map[url])) - }; - } else { - // load with default loader - loaderDebug('default: %s', url); - cache[url] = await oldLoader(url); - } - return cache[url]; - }; -} - -// program -// .version(require('../package.json').version) -// .option('-v, --verbose', 'Increase verbosity', inc, 0); - -program - .command('issue') - .alias('i') - .description('issue a credential') - .option('-i, --issuer ', 'URL for the issuer public key.') - .option('-r, --private-key ', 'Private key PEM file.') - .option('-d, --date ', 'Signature date [now].', new Date()) - .option('-D, --domain ', 'Signature domain [none].') - .option('-a, --algorithm ', - 'Signature algorithm [Ed25519Signature2018].') - .action(async function(cmd) { - try { - if(arguments.length > 1) { - throw new Error('Too many arguments.'); - } - if(!cmd.issuer) { - throw new Error('issuer required'); - } - //if(!cmd.publicKey) { - // throw new Error('public key required'); - //} - //if(!cmd.owner) { - // throw new Error('owner required'); - //} - if(!cmd.privateKey) { - throw new Error('private key required'); - } - - const result = await vc.issue({ - credential: JSON.parse(await getStdin()), - issuer: cmd.issuer, - //publicKey: cmd.publicKey, - //owner: cmd.owner, - privateKeyPem: String(await fs.readFile(cmd.privateKey)) - }); - console.log(JSON.stringify(result, null, 2)); - } catch(e) { - console.error('Error:', JSON.stringify(e, null, 2), e); - process.exit(1); - } - }) - .on('--help', () => { - console.log(); - console.log(' Examples: '); - console.log(); - console.log(' $ vc-js issue ... < cred.jsonld'); - console.log(); - }); - -const testKey = { - id: 'https://example.edu/issuers/keys/1', - type: 'Ed25519VerificationKey2018', - controller: 'https://example.edu/issuers/14', - publicKeyBase58: 'AoncetDEamr1hreoMiLocvQvCLEu5i5FuQ232zdqie7g', - privateKeyBase58: - '53KBp86VkzDKthrZdQCKv4UaAWd74DWCqgbmYmXuLytg' + - 'bU7pFghAWs23Tdd9iacMLZtkvwdo5vCvDQ8vj24HdJYv' -}; -const testKeyPair = new Ed25519VerificationKey2018(testKey); - -const controller = { - '@context': 'https://w3id.org/security/v2', - id: 'https://example.edu/issuers/14', - assertionMethod: [ testKey.id ] -}; - -const testContext = require('../lib/contexts'); -testContext['https://example.edu/issuers/14'] = controller; -testContext['https://example.edu/issuers/keys/1'] = - testKeyPair.export({publicKey: true}); -testContext['https://example.org/examples/degree.json'] = {}; - -async function testDocumentLoader(url) { - const context = testContext[url]; - if(context) { - return { - contextUrl: null, - documentUrl: url, - document: context - }; - } - throw new Error(`${url} is not an authorized supported context url.`); -} - -const testSuite = new jsigs.suites.Ed25519Signature2018({ - verificationMethod: testKey.id, - key: testKeyPair -}); - -program - .command('test-issue') - .alias('ti') - .description('issue a verifiable credential with test key') - .action(async cmd => { - try { - const input = await getStdin(); - const credential = JSON.parse(input); - - const result = await vc.issue({ - credential, - suite: testSuite, - documentLoader: testDocumentLoader - }); - console.log(JSON.stringify(result, null, 2)); - } catch(e) { - console.error('Error:', JSON.stringify(e, null, 2), e); - process.exit(1); - } - }) - .on('--help', () => { - console.log(); - console.log('Used for test suites. Examples: '); - console.log(); - console.log(' $ vc-js test-issue < cred.jsonld'); - console.log(); - }); - -program - .command('test-presentation') - .alias('tp') - .description('issue a verifiable presentation with test key') - .action(async cmd => { - try { - const input = await getStdin(); - const presentation = JSON.parse(input); - - const result = await vc.createPresentation({ - presentation, - type: 'CredentialManagerPresentation', - suite: testSuite, - documentLoader: testDocumentLoader - }); - console.log(JSON.stringify(result, null, 2)); - } catch(e) { - console.error('Error:', JSON.stringify(e, null, 2), e); - process.exit(1); - } - }) - .on('--help', () => { - console.log(); - console.log('Used for test suites. Examples: '); - console.log(); - console.log(' $ vc-js test-presentation < cred.jsonld'); - console.log(); - }); - -program - .command('verify') - .alias('v') - .description('verify a credential') - .option('-i, --issuer ', 'The URL for the issuer public key.') - .option('-p, --public-key ', 'The public key PEM file.') - //.option('-o, --owner ', 'The key owner URL.') - //.option('-r, --private-key ', 'The private key file.') - .action(async function(cmd, options) { - try { - const result = await vc.verify({ - credential: JSON.parse(await getStdin()), - issuer: cmd.issuer, - //publicKey: cmd.publicKey, - //owner: cmd.owner, - publicKeyPem: String(await fs.readFile(cmd.publicKey)) - }); - if(result.verified === false) { - // result can include raw Error - //console.log(JSON.stringify(result, null, 2)); - console.log(result); - process.exit(1); - } - } catch(e) { - console.error('Error:', JSON.stringify(e, null, 2), e); - process.exit(1); - } - //console.error('Error: verify not implemented'); - //process.exit(1); - }) - .on('--help', () => { - console.log(); - console.log(' Examples: '); - console.log(); - console.log(' $ vc-js verify ... < signed-cred.jsonld'); - console.log(); - }); - -program.parse(process.argv); diff --git a/bin/vc-js-issuer b/bin/vc-js-issuer deleted file mode 100755 index c1f9f8ee..00000000 --- a/bin/vc-js-issuer +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -$(dirname $0)/vc-js issue $@ diff --git a/bin/vc-js-verifier b/bin/vc-js-verifier deleted file mode 100755 index b51e9e5f..00000000 --- a/bin/vc-js-verifier +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -$(dirname $0)/vc-js verify $@ diff --git a/bin/vc-test b/bin/vc-test deleted file mode 100755 index 99116820..00000000 --- a/bin/vc-test +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -ROOT_DIR=$(dirname $0)/.. -if [ -e $ROOT_DIR/test-suites/vc-test-suite ]; then - TEST_SUITE_DIR=$ROOT_DIR/test-suites/vc-test-suite -else - TEST_SUITE_DIR=$ROOT_DIR/../vc-test-suite -fi -$TEST_SUITE_DIR/bin/vc-driver -i $ROOT_DIR/bin/vc-js-issuer -v $ROOT_DIR/bin/vc-js-verifier $@ diff --git a/karma.conf.js b/karma.conf.js index 2da17fe3..4af3484b 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Digital Bazaar, Inc. All rights reserved. + * Copyright (c) 2019-2021 Digital Bazaar, Inc. All rights reserved. */ module.exports = function(config) { @@ -13,7 +13,7 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ - 'tests/*.spec.js' + 'test/*.spec.js' ], // list of files to exclude @@ -75,7 +75,7 @@ module.exports = function(config) { // config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG logLevel: config.LOG_INFO, - // enable / disable watching file and executing tests whenever any + // enable / disable watching file and executing test whenever any // file changes autoWatch: false, @@ -96,7 +96,7 @@ module.exports = function(config) { }, // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits + // if true, Karma captures browsers, runs the test and exits singleRun: true, }); diff --git a/lib/CredentialIssuancePurpose.js b/lib/CredentialIssuancePurpose.js index 59715a74..ddc27114 100644 --- a/lib/CredentialIssuancePurpose.js +++ b/lib/CredentialIssuancePurpose.js @@ -1,5 +1,5 @@ /*! - * Copyright (c) 2019-2020 Digital Bazaar, Inc. All rights reserved. + * Copyright (c) 2019-2021 Digital Bazaar, Inc. All rights reserved. */ 'use strict'; const jsonld = require('jsonld'); diff --git a/lib/contexts/index.js b/lib/contexts/index.js index 62a20d67..c0a54fb8 100644 --- a/lib/contexts/index.js +++ b/lib/contexts/index.js @@ -1,5 +1,5 @@ /*! - * Copyright (c) 2019-2020 Digital Bazaar, Inc. All rights reserved. + * Copyright (c) 2019-2021 Digital Bazaar, Inc. All rights reserved. */ 'use strict'; diff --git a/lib/contexts/odrl.js b/lib/contexts/odrl.js index b9020aea..2ebff783 100644 --- a/lib/contexts/odrl.js +++ b/lib/contexts/odrl.js @@ -1,5 +1,5 @@ /*! - * Copyright (c) 2019-2020 Digital Bazaar, Inc. All rights reserved. + * Copyright (c) 2019-2021 Digital Bazaar, Inc. All rights reserved. */ 'use strict'; diff --git a/lib/contexts/vc-examples-v1.js b/lib/contexts/vc-examples-v1.js index 063312be..8467379f 100644 --- a/lib/contexts/vc-examples-v1.js +++ b/lib/contexts/vc-examples-v1.js @@ -1,5 +1,5 @@ /*! - * Copyright (c) 2019-2020 Digital Bazaar, Inc. All rights reserved. + * Copyright (c) 2019-2021 Digital Bazaar, Inc. All rights reserved. */ /* eslint-disable quote-props */ diff --git a/lib/documentLoader.js b/lib/documentLoader.js index 284636fd..fcadcb49 100644 --- a/lib/documentLoader.js +++ b/lib/documentLoader.js @@ -1,5 +1,5 @@ /*! - * Copyright (c) 2019-2020 Digital Bazaar, Inc. All rights reserved. + * Copyright (c) 2019-2021 Digital Bazaar, Inc. All rights reserved. */ 'use strict'; diff --git a/lib/index.js b/lib/index.js index a425d21a..268d8777 100644 --- a/lib/index.js +++ b/lib/index.js @@ -3,6 +3,6 @@ * * @author David I. Lehn * - * Copyright 2017-2020 Digital Bazaar, Inc. + * Copyright 2017-2021 Digital Bazaar, Inc. */ module.exports = require('./vc.js'); diff --git a/lib/vc.js b/lib/vc.js index 378d1344..8ccd5d54 100644 --- a/lib/vc.js +++ b/lib/vc.js @@ -5,7 +5,7 @@ * @author David I. Lehn * * @license BSD 3-Clause License - * Copyright (c) 2017-2020 Digital Bazaar, Inc. + * Copyright (c) 2017-2021 Digital Bazaar, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/package.json b/package.json index 6c898a94..fb83ff99 100644 --- a/package.json +++ b/package.json @@ -34,21 +34,10 @@ "lib/contexts" ], "dependencies": { - "commander": "^2.20.3", "credentials-context": "^1.0.0", - "debug": "^4.1.1", - "fs-extra": "^8.1.0", - "get-stdin": "^7.0.0", - "jsonld": "^2.0.2", - "jsonld-signatures": "digitalbazaar/jsonld-signatures#v6.x", - "supports-color": "^7.1.0" - }, - "browser": { - "bs58": false, - "Buffer": false, - "crypto": false, - "sodium-native": false, - "util": false + "esm": "^3.2.25", + "jsonld": "^4.0.1", + "jsonld-signatures": "digitalbazaar/jsonld-signatures#v8.x" }, "devDependencies": { "@babel/cli": "^7.8.3", @@ -62,7 +51,9 @@ "@babel/register": "^7.8.3", "@babel/runtime": "^7.8.3", "@digitalbazaar/ed25519-signature-2018": "digitalbazaar/ed25519-signature-2018#initial", - "@digitalbazaar/ed25519-verification-key-2018": "^1.0.2", + "@digitalbazaar/ed25519-signature-2020": "digitalbazaar/ed25519-signature-2020#initial", + "@digitalbazaar/ed25519-verification-key-2018": "^2.0.0", + "@digitalbazaar/ed25519-verification-key-2020": "^1.0.0", "babel-loader": "^8.0.5", "browserify": "^16.2.3", "chai": "^4.1.2", @@ -92,6 +83,11 @@ "webpack-cli": "^3.3.10", "webpack-merge": "^4.2.2" }, + "browser": { + "Buffer": false, + "crypto": false, + "util": false + }, "engines": { "node": ">=12" }, @@ -108,12 +104,10 @@ "ts:defs": "npx tsc --declaration --outDir dist --emitDeclarationOnly", "prepublish": "npm run build && npm run ts:defs", "build": "webpack", - "fetch-test-suites": "npm run fetch-vc-test-suite", - "fetch-vc-test-suite": "if [ ! -e test-suites/vc-test-suite ]; then git clone --depth 1 https://github.com/digitalbazaar/vc-test-suite.git test-suites/vc-test-suite; fi", - "test": "bin/vc-test", - "test-node": "mocha ./tests/*.spec.js --opts ./tests/mocha.opts --require @babel/polyfill --require @babel/register", + "test": "npm run lint && npm run test-node && npm run test-karma", + "test-node": "mocha ./test/*.spec.js --opts ./test/mocha.opts --require @babel/polyfill --require @babel/register", "test-karma": "karma start karma.conf.js", - "lint": "eslint '*.js' 'lib/**.js' 'tests/**.js' bin/vc-js", + "lint": "eslint '*.js' 'lib/**.js' 'test/**.js'", "coverage": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text-summary npm run test-node", "coverage-ci": "cross-env NODE_ENV=test nyc --reporter=lcovonly run test-node", "coverage-report": "nyc report" diff --git a/tests/.eslintrc b/test/.eslintrc similarity index 100% rename from tests/.eslintrc rename to test/.eslintrc diff --git a/tests/10-verify.spec.js b/test/10-verify.spec.js similarity index 99% rename from tests/10-verify.spec.js rename to test/10-verify.spec.js index 4f2c9d02..62b5084a 100644 --- a/tests/10-verify.spec.js +++ b/test/10-verify.spec.js @@ -210,7 +210,7 @@ describe('verify API (credentials)', () => { result.verified.should.be.true; }); - describe('negative tests', async () => { + describe('negative test', async () => { it('fails to verify if a context is null', async () => { const {credential, suite} = await _generateCredential(); credential['@context'].push(invalidContexts.nullDoc.url); @@ -351,7 +351,7 @@ describe('verify API (presentations)', () => { }); }); -describe('tests for multiple credentials', async () => { +describe('test for multiple credentials', async () => { const credentialsCount = [5, 25, 50, 100]; diff --git a/tests/MultiLoader.js b/test/MultiLoader.js similarity index 100% rename from tests/MultiLoader.js rename to test/MultiLoader.js diff --git a/tests/constants.js b/test/constants.js similarity index 100% rename from tests/constants.js rename to test/constants.js diff --git a/tests/contexts/index.js b/test/contexts/index.js similarity index 100% rename from tests/contexts/index.js rename to test/contexts/index.js diff --git a/tests/contexts/invalid_id.json b/test/contexts/invalid_id.json similarity index 100% rename from tests/contexts/invalid_id.json rename to test/contexts/invalid_id.json diff --git a/tests/contexts/null_id.json b/test/contexts/null_id.json similarity index 100% rename from tests/contexts/null_id.json rename to test/contexts/null_id.json diff --git a/tests/contexts/null_type.json b/test/contexts/null_type.json similarity index 100% rename from tests/contexts/null_type.json rename to test/contexts/null_type.json diff --git a/tests/contexts/null_version.json b/test/contexts/null_version.json similarity index 100% rename from tests/contexts/null_version.json rename to test/contexts/null_version.json diff --git a/tests/mocha.opts b/test/mocha.opts similarity index 100% rename from tests/mocha.opts rename to test/mocha.opts diff --git a/tests/mocks/assertionController.js b/test/mocks/assertionController.js similarity index 100% rename from tests/mocks/assertionController.js rename to test/mocks/assertionController.js diff --git a/tests/mocks/credential.js b/test/mocks/credential.js similarity index 100% rename from tests/mocks/credential.js rename to test/mocks/credential.js diff --git a/tests/mocks/didDocument.js b/test/mocks/didDocument.js similarity index 100% rename from tests/mocks/didDocument.js rename to test/mocks/didDocument.js diff --git a/tests/mocks/didKeys.js b/test/mocks/didKeys.js similarity index 100% rename from tests/mocks/didKeys.js rename to test/mocks/didKeys.js diff --git a/tests/mocks/mock.data.js b/test/mocks/mock.data.js similarity index 100% rename from tests/mocks/mock.data.js rename to test/mocks/mock.data.js From 35c4e670809a5a8ee9539659913b87441eb5db35 Mon Sep 17 00:00:00 2001 From: Dmitri Zagidulin Date: Sun, 7 Mar 2021 22:23:06 -0500 Subject: [PATCH 09/32] Remove unused mocha.opts. --- package.json | 5 +---- test/mocha.opts | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) delete mode 100644 test/mocha.opts diff --git a/package.json b/package.json index fb83ff99..810752f7 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,6 @@ }, "license": "BSD-3-Clause", "main": "lib/index.js", - "bin": { - "vc-js": "bin/vc-js" - }, "files": [ "bin/vc-js", "dist/*.js", @@ -105,7 +102,7 @@ "prepublish": "npm run build && npm run ts:defs", "build": "webpack", "test": "npm run lint && npm run test-node && npm run test-karma", - "test-node": "mocha ./test/*.spec.js --opts ./test/mocha.opts --require @babel/polyfill --require @babel/register", + "test-node": "mocha ./test/*.spec.js --require @babel/polyfill --require @babel/register", "test-karma": "karma start karma.conf.js", "lint": "eslint '*.js' 'lib/**.js' 'test/**.js'", "coverage": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text-summary npm run test-node", diff --git a/test/mocha.opts b/test/mocha.opts deleted file mode 100644 index 8b137891..00000000 --- a/test/mocha.opts +++ /dev/null @@ -1 +0,0 @@ - From 594a995a48718284d3cf98707edb1c031fe3edbc Mon Sep 17 00:00:00 2001 From: Dmitri Zagidulin Date: Wed, 17 Mar 2021 22:34:28 -0400 Subject: [PATCH 10/32] Update to latest packages. --- lib/vc.js | 4 +-- package.json | 61 ++++++++++++++++++------------------------ test/10-verify.spec.js | 2 +- 3 files changed, 29 insertions(+), 38 deletions(-) diff --git a/lib/vc.js b/lib/vc.js index 8ccd5d54..358fbb27 100644 --- a/lib/vc.js +++ b/lib/vc.js @@ -366,8 +366,8 @@ async function signPresentation(options = {}) { * @param {object} [options={}] * @param {VerifiablePresentation} options.presentation * - * @param {LinkedDataSignature|LinkedDataSignature[]} suite - See the definition - * in the `verify()` docstring, for this param. + * @param {LinkedDataSignature|LinkedDataSignature[]} options.suite - See the + * definition in the `verify()` docstring, for this param. * * @param {boolean} [options.unsignedPresentation=false] - By default, this * function assumes that a presentation is signed (and will return an error if diff --git a/package.json b/package.json index 810752f7..f55ee038 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,6 @@ "license": "BSD-3-Clause", "main": "lib/index.js", "files": [ - "bin/vc-js", "dist/*.js", "dist/*.js.map", "lib/*.js", @@ -37,48 +36,40 @@ "jsonld-signatures": "digitalbazaar/jsonld-signatures#v8.x" }, "devDependencies": { - "@babel/cli": "^7.8.3", - "@babel/core": "^7.8.3", - "@babel/node": "^7.8.3", - "@babel/plugin-proposal-object-rest-spread": "^7.8.3", - "@babel/plugin-transform-modules-commonjs": "^7.8.3", - "@babel/plugin-transform-runtime": "^7.8.3", - "@babel/polyfill": "^7.8.3", - "@babel/preset-env": "^7.8.3", - "@babel/register": "^7.8.3", - "@babel/runtime": "^7.8.3", + "@babel/core": "^7.13.8", + "@babel/plugin-transform-modules-commonjs": "^7.13.8", + "@babel/plugin-transform-runtime": "^7.13.9", + "@babel/preset-env": "^7.13.9", + "@babel/runtime": "^7.13.9", "@digitalbazaar/ed25519-signature-2018": "digitalbazaar/ed25519-signature-2018#initial", "@digitalbazaar/ed25519-signature-2020": "digitalbazaar/ed25519-signature-2020#initial", - "@digitalbazaar/ed25519-verification-key-2018": "^2.0.0", - "@digitalbazaar/ed25519-verification-key-2020": "^1.0.0", - "babel-loader": "^8.0.5", - "browserify": "^16.2.3", - "chai": "^4.1.2", - "core-js": "^3.6.4", - "cross-env": "^7.0.0", - "crypto-ld": "^4.0.2", + "@digitalbazaar/ed25519-verification-key-2018": "^3.0.0", + "@digitalbazaar/ed25519-verification-key-2020": "^2.0.0", + "babel-loader": "^8.2.2", + "chai": "^4.3.3", + "cross-env": "^7.0.3", + "crypto-ld": "^5.0.0", "did-context": "^2.0.0", - "did-veres-one": "^10.0.1", - "eslint": "^7.7.0", - "eslint-config-digitalbazaar": "^2.0.0", - "eslint-plugin-jsdoc": "^30.2.4", - "karma": "^4.4.1", - "karma-babel-preprocessor": "^8.0.0", + "did-veres-one": "^13.0.0", + "eslint": "^7.21.0", + "eslint-config-digitalbazaar": "^2.6.1", + "eslint-plugin-jsdoc": "^32.2.0", + "karma": "^6.1.1", + "karma-babel-preprocessor": "^8.0.1", "karma-chai": "^0.1.0", "karma-chrome-launcher": "^3.1.0", - "karma-mocha": "^1.3.0", + "karma-mocha": "^2.0.1", "karma-mocha-reporter": "^2.2.5", - "karma-sourcemap-loader": "^0.3.7", - "karma-webpack": "^4.0.2", - "mocha": "^7.2.0", - "nyc": "^15.0.0", - "regenerator-runtime": "^0.13.1", + "karma-sourcemap-loader": "^0.3.8", + "karma-webpack": "^5.0.0", + "mocha": "^8.3.1", + "mocha-lcov-reporter": "^1.3.0", + "nyc": "^15.1.0", "typescript": "^4.0.3", - "uuid": "^3.4.0", + "uuid": "^8.3.2", "veres-one-context": "^11.0.0", - "webpack": "^4.41.5", - "webpack-cli": "^3.3.10", - "webpack-merge": "^4.2.2" + "webpack": "^5.24.3", + "webpack-cli": "^4.5.0" }, "browser": { "Buffer": false, diff --git a/test/10-verify.spec.js b/test/10-verify.spec.js index 62b5084a..08fac2af 100644 --- a/test/10-verify.spec.js +++ b/test/10-verify.spec.js @@ -9,7 +9,7 @@ const {Ed25519Signature2018} = require('@digitalbazaar/ed25519-signature-2018'); const CredentialIssuancePurpose = require('../lib/CredentialIssuancePurpose'); const mockData = require('./mocks/mock.data'); -const uuid = require('uuid/v4'); +const {v4: uuid} = require('uuid'); const vc = require('..'); const MultiLoader = require('./MultiLoader'); const realContexts = require('../lib/contexts'); From e54badb5ed6dc99c7b79c8dd90feebc376ee6709 Mon Sep 17 00:00:00 2001 From: Dmitri Zagidulin Date: Wed, 17 Mar 2021 22:39:03 -0400 Subject: [PATCH 11/32] Set up lint, fix mocha script. --- .eslintrc.js | 21 ++++++++++++++++----- package.json | 4 ++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 03fc43e1..f8f8c9ce 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,11 +1,22 @@ +/*! + * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved. + */ module.exports = { root: true, + extends: [ + 'eslint-config-digitalbazaar', + // 'eslint-config-digitalbazaar/jsdoc' + ], env: { node: true }, - extends: [ - 'digitalbazaar', - 'digitalbazaar/jsdoc' - ], - ignorePatterns: ['dist/'] + parserOptions: { + // this is required for dynamic import() + ecmaVersion: 2020 + }, + ignorePatterns: ['node_modules', 'dist'], + rules: { + 'jsdoc/check-examples': 0, + 'jsdoc/require-description-complete-sentence': 0 + } }; diff --git a/package.json b/package.json index f55ee038..4cf70762 100644 --- a/package.json +++ b/package.json @@ -93,9 +93,9 @@ "prepublish": "npm run build && npm run ts:defs", "build": "webpack", "test": "npm run lint && npm run test-node && npm run test-karma", - "test-node": "mocha ./test/*.spec.js --require @babel/polyfill --require @babel/register", + "test-node": "cross-env NODE_ENV=test mocha --preserve-symlinks -t 10000 test/*.spec.js", "test-karma": "karma start karma.conf.js", - "lint": "eslint '*.js' 'lib/**.js' 'test/**.js'", + "lint": "eslint lib test/*.spec.js", "coverage": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text-summary npm run test-node", "coverage-ci": "cross-env NODE_ENV=test nyc --reporter=lcovonly run test-node", "coverage-report": "nyc report" From 14da26bff04fb72b687b53416eecf920f9848dd7 Mon Sep 17 00:00:00 2001 From: Dmitri Zagidulin Date: Wed, 17 Mar 2021 23:12:58 -0400 Subject: [PATCH 12/32] Update karma config. --- karma.conf.js | 69 ++++++++++++++++----------------------------------- 1 file changed, 22 insertions(+), 47 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 4af3484b..ce6f71dc 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,8 +1,8 @@ /* - * Copyright (c) 2019-2021 Digital Bazaar, Inc. All rights reserved. + * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved. */ - module.exports = function(config) { + config.set({ // base path that will be used to resolve all patterns (eg. files, exclude) basePath: '', @@ -17,47 +17,20 @@ module.exports = function(config) { ], // list of files to exclude - exclude: ['bin/*'], + exclude: [], + + // preprocess matching files before serving them to the browser + // preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { - 'tests/*.js': ['webpack', 'sourcemap'] + 'test/*.js': ['webpack', 'sourcemap'] }, webpack: { //mode: 'production', mode: 'development', - devtool: 'inline-source-map', - module: { - rules: [ - { - test: /\.js$/, - exclude: [ - /bin/, - /node_modules\/(?!jsonld|crypto-ld)/ - ], - use: { - loader: 'babel-loader', - options: { - presets: ['@babel/preset-env'], - plugins: [ - '@babel/plugin-transform-modules-commonjs', - '@babel/plugin-transform-runtime', - '@babel/plugin-proposal-object-rest-spread' - ] - } - } - } - ] - }, - node: { - Buffer: false, - process: false, - crypto: false, - setImmediate: false - }, - externals: { - 'bitcore-message': '\'bitcore-message\'' - } + devtool: 'inline-source-map' }, + // test results reporter to use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter @@ -84,20 +57,22 @@ module.exports = function(config) { //browsers: ['ChromeHeadless', 'Chrome', 'Firefox', 'Safari'], browsers: ['ChromeHeadless'], - customLaunchers: { - IE9: { - base: 'IE', - 'x-ua-compatible': 'IE=EmulateIE9' - }, - IE8: { - base: 'IE', - 'x-ua-compatible': 'IE=EmulateIE8' - } - }, - // Continuous Integration mode // if true, Karma captures browsers, runs the test and exits singleRun: true, + // Concurrency level + // how many browser should be started simultaneous + concurrency: Infinity, + + // Mocha + client: { + mocha: { + // increase from default 2s + timeout: 10000, + reporter: 'html' + //delay: true + } + } }); }; From ebcf94b1f38714f0b253135d52716319b710effe Mon Sep 17 00:00:00 2001 From: Dmitri Zagidulin Date: Wed, 17 Mar 2021 23:49:22 -0400 Subject: [PATCH 13/32] Extract dateRegex tests to separate file. --- package.json | 3 +-- test/10-verify.spec.js | 35 ++++++++--------------------------- test/dateRegex.spec.js | 27 +++++++++++++++++++++++++++ test/mocks/didDocument.js | 1 + test/mocks/didKeys.js | 1 + test/mocks/mock.data.js | 1 + 6 files changed, 39 insertions(+), 29 deletions(-) create mode 100644 test/dateRegex.spec.js diff --git a/package.json b/package.json index 4cf70762..331f13cb 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,6 @@ "babel-loader": "^8.2.2", "chai": "^4.3.3", "cross-env": "^7.0.3", - "crypto-ld": "^5.0.0", "did-context": "^2.0.0", "did-veres-one": "^13.0.0", "eslint": "^7.21.0", @@ -93,7 +92,7 @@ "prepublish": "npm run build && npm run ts:defs", "build": "webpack", "test": "npm run lint && npm run test-node && npm run test-karma", - "test-node": "cross-env NODE_ENV=test mocha --preserve-symlinks -t 10000 test/*.spec.js", + "test-node": "cross-env NODE_ENV=test mocha -b --preserve-symlinks -t 10000 test/*.spec.js", "test-karma": "karma start karma.conf.js", "lint": "eslint lib test/*.spec.js", "coverage": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text-summary npm run test-node", diff --git a/test/10-verify.spec.js b/test/10-verify.spec.js index 08fac2af..cfbbdee7 100644 --- a/test/10-verify.spec.js +++ b/test/10-verify.spec.js @@ -1,3 +1,6 @@ +/*! + * Copyright (c) 2019-2021 Digital Bazaar, Inc. All rights reserved. + */ const chai = require('chai'); const should = chai.should(); @@ -151,27 +154,6 @@ describe('vc.signPresentation()', () => { }); }); -describe('verifies RFC3339 Dates', function() { - it('verify a valid date', function() { - const latest = new Date().toISOString(); - vc.dateRegex.test(latest).should.be.true; - }); - it('verify a valid date with lowercase t', function() { - const latest = new Date().toISOString().toLowerCase(); - vc.dateRegex.test(latest).should.be.true; - }); - - it('should not verify an invalid date', function() { - const invalid = '2017/09/27'; - vc.dateRegex.test(invalid).should.be.false; - }); - it('should not verify 2 digit years', function() { - const invalid = '17-09-27T22:07:22.563z'; - vc.dateRegex.test(invalid).should.be.false; - }); - -}); - describe('verify API (credentials)', () => { it('should verify a vc', async () => { verifiableCredential = await vc.issue({ @@ -310,7 +292,7 @@ describe('verify API (credentials)', () => { }); describe('verify API (presentations)', () => { - it('verifies a valid signed presentation', async () => { + it.only('verifies a valid signed presentation', async () => { const challenge = uuid(); const {presentation, suite, documentLoader} = @@ -323,6 +305,8 @@ describe('verify API (presentations)', () => { presentation }); + console.log(result) + if(result.error) { const firstError = [].concat(result.error)[0]; throw firstError; @@ -352,12 +336,10 @@ describe('verify API (presentations)', () => { }); describe('test for multiple credentials', async () => { - const credentialsCount = [5, 25, 50, 100]; for(const count of credentialsCount) { - it('cause error when credentials are tampered', async function() { - this.timeout(10000); + it('cause error when credentials are tampered', async () => { const challenge = uuid(); const {presentation, suite: vcSuite, documentLoader} = await _generatePresentation({challenge, credentialsCount: count}); @@ -401,8 +383,7 @@ describe('test for multiple credentials', async () => { firstErrorMsg.should.contain('Invalid signature.'); }); - it('should not cause error when credentials are correct', async function() { - this.timeout(10000); + it('should not cause error when credentials are correct', async () => { const challenge = uuid(); const {presentation, suite: vcSuite, documentLoader} = await _generatePresentation({challenge, credentialsCount: count}); diff --git a/test/dateRegex.spec.js b/test/dateRegex.spec.js new file mode 100644 index 00000000..a1b9b0e5 --- /dev/null +++ b/test/dateRegex.spec.js @@ -0,0 +1,27 @@ +/*! + * Copyright (c) 2019-2021 Digital Bazaar, Inc. All rights reserved. + */ +const chai = require('chai'); +chai.should(); + +const vc = require('..'); + +describe('verifies RFC3339 Dates', function() { + it('verify a valid date', function() { + const latest = new Date().toISOString(); + vc.dateRegex.test(latest).should.be.true; + }); + it('verify a valid date with lowercase t', function() { + const latest = new Date().toISOString().toLowerCase(); + vc.dateRegex.test(latest).should.be.true; + }); + + it('should not verify an invalid date', function() { + const invalid = '2017/09/27'; + vc.dateRegex.test(invalid).should.be.false; + }); + it('should not verify 2 digit years', function() { + const invalid = '17-09-27T22:07:22.563z'; + vc.dateRegex.test(invalid).should.be.false; + }); +}); diff --git a/test/mocks/didDocument.js b/test/mocks/didDocument.js index 21225872..1aed5edb 100644 --- a/test/mocks/didDocument.js +++ b/test/mocks/didDocument.js @@ -1,3 +1,4 @@ +/* eslint-disable */ module.exports = { "@context": [ "https://w3id.org/did/v0.11", diff --git a/test/mocks/didKeys.js b/test/mocks/didKeys.js index bc40867c..ad50e278 100644 --- a/test/mocks/didKeys.js +++ b/test/mocks/didKeys.js @@ -1,3 +1,4 @@ +/* eslint-disable */ /** * Private key store for the test DID Document. * Note that this is for unit testing purposes only, please do not commit diff --git a/test/mocks/mock.data.js b/test/mocks/mock.data.js index ac29ec34..febe460f 100644 --- a/test/mocks/mock.data.js +++ b/test/mocks/mock.data.js @@ -1,3 +1,4 @@ +/* eslint-disable */ const constants = require('../constants'); const mock = {}; From f6b516c12a7779d69a13164919f7efbd709dacda Mon Sep 17 00:00:00 2001 From: Dmitri Zagidulin Date: Thu, 18 Mar 2021 22:38:35 -0400 Subject: [PATCH 14/32] Update to latest published packages. --- package.json | 8 ++++---- test/10-verify.spec.js | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 331f13cb..48111bf2 100644 --- a/package.json +++ b/package.json @@ -32,8 +32,8 @@ "dependencies": { "credentials-context": "^1.0.0", "esm": "^3.2.25", - "jsonld": "^4.0.1", - "jsonld-signatures": "digitalbazaar/jsonld-signatures#v8.x" + "jsonld": "^5.0.0", + "jsonld-signatures": "^8.0.1" }, "devDependencies": { "@babel/core": "^7.13.8", @@ -41,7 +41,7 @@ "@babel/plugin-transform-runtime": "^7.13.9", "@babel/preset-env": "^7.13.9", "@babel/runtime": "^7.13.9", - "@digitalbazaar/ed25519-signature-2018": "digitalbazaar/ed25519-signature-2018#initial", + "@digitalbazaar/ed25519-signature-2018": "^1.0.0", "@digitalbazaar/ed25519-signature-2020": "digitalbazaar/ed25519-signature-2020#initial", "@digitalbazaar/ed25519-verification-key-2018": "^3.0.0", "@digitalbazaar/ed25519-verification-key-2020": "^2.0.0", @@ -92,7 +92,7 @@ "prepublish": "npm run build && npm run ts:defs", "build": "webpack", "test": "npm run lint && npm run test-node && npm run test-karma", - "test-node": "cross-env NODE_ENV=test mocha -b --preserve-symlinks -t 10000 test/*.spec.js", + "test-node": "cross-env NODE_ENV=test mocha --preserve-symlinks -t 10000 test/*.spec.js", "test-karma": "karma start karma.conf.js", "lint": "eslint lib test/*.spec.js", "coverage": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text-summary npm run test-node", diff --git a/test/10-verify.spec.js b/test/10-verify.spec.js index cfbbdee7..aade7bb0 100644 --- a/test/10-verify.spec.js +++ b/test/10-verify.spec.js @@ -305,8 +305,6 @@ describe('verify API (presentations)', () => { presentation }); - console.log(result) - if(result.error) { const firstError = [].concat(result.error)[0]; throw firstError; From df985460e5a8d11ecf459e2707fc4f0e403bd945 Mon Sep 17 00:00:00 2001 From: Dmitri Zagidulin Date: Wed, 24 Mar 2021 21:29:38 -0400 Subject: [PATCH 15/32] Update checking for issuer and controller in validate. --- README.md | 23 ++++++++++++++++++++--- lib/CredentialIssuancePurpose.js | 7 ++++--- package.json | 4 ++-- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4a5ba3bc..440a0c24 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,7 @@ the following: ## Install -- Node.js 8.3+ required. -- Node.js 10.12.0+ is highly recommended due to RSA key generation speed. +- Node.js 12+ required. To install locally (for development): @@ -61,6 +60,24 @@ npm install ## Usage +### Setting up a signature suite + +For signing, when setting up a signature suite, you will need to pass in +a key pair containing a private key. + +```js +import vc from '@digitalbazaar/vc-js'; + +// Required to set up a suite instance with private key +import {Ed25519VerificationKey2020} from + '@digitalbazaar/ed25519-verification-key-2020'; +import {Ed25519Signature2020} from '@digitalbazaar/ed25519-signature-2020'; + +const keyPair = await Ed25519VerificationKey2020.generate(); + +const suite = new Ed25519Signature2020({key: keyPair}); +``` + ### Issuing a Verifiable Credential Pre-requisites: @@ -103,7 +120,7 @@ Pre-requisites: * (Recommended) You have a strategy for where to publish your Controller Documents and Public Keys -#### Creating an Unsigned Presentation +#### Creating an unsigned presentation To create a presentation out of one or more verifiable credentials, you can use the `createPresentation()` convenience function. Alternatively, you can diff --git a/lib/CredentialIssuancePurpose.js b/lib/CredentialIssuancePurpose.js index ddc27114..a2d32ca5 100644 --- a/lib/CredentialIssuancePurpose.js +++ b/lib/CredentialIssuancePurpose.js @@ -58,14 +58,15 @@ class CredentialIssuancePurpose extends AssertionProofPurpose { throw result.error; } - const issuer = jsonld.getValues(document, - 'https://www.w3.org/2018/credentials#issuer'); + const issuer = jsonld.getValues(document, 'issuer'); if(!issuer || issuer.length === 0) { throw new Error('Credential issuer is required.'); } - if(result.controller.id !== issuer[0].id) { + const issuerId = typeof issuer[0] === 'string' ? issuer[0] : issuer[0].id; + + if(result.controller.id !== issuerId) { throw new Error( 'Credential issuer must match the verification method controller.'); } diff --git a/package.json b/package.json index 48111bf2..271a2be2 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "credentials-context": "^1.0.0", "esm": "^3.2.25", "jsonld": "^5.0.0", - "jsonld-signatures": "^8.0.1" + "jsonld-signatures": "^8.0.2" }, "devDependencies": { "@babel/core": "^7.13.8", @@ -42,7 +42,7 @@ "@babel/preset-env": "^7.13.9", "@babel/runtime": "^7.13.9", "@digitalbazaar/ed25519-signature-2018": "^1.0.0", - "@digitalbazaar/ed25519-signature-2020": "digitalbazaar/ed25519-signature-2020#initial", + "@digitalbazaar/ed25519-signature-2020": "^1.0.0", "@digitalbazaar/ed25519-verification-key-2018": "^3.0.0", "@digitalbazaar/ed25519-verification-key-2020": "^2.0.0", "babel-loader": "^8.2.2", From 9d631fd3b066547b15e2b0faee0ea58844f63718 Mon Sep 17 00:00:00 2001 From: Dave Longley Date: Wed, 21 Apr 2021 09:32:09 -0400 Subject: [PATCH 16/32] Update jsonld* deps. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 271a2be2..e7c8ea25 100644 --- a/package.json +++ b/package.json @@ -32,8 +32,8 @@ "dependencies": { "credentials-context": "^1.0.0", "esm": "^3.2.25", - "jsonld": "^5.0.0", - "jsonld-signatures": "^8.0.2" + "jsonld": "^5.2.0", + "jsonld-signatures": "^9.0.2" }, "devDependencies": { "@babel/core": "^7.13.8", From 279ec76a894aa402d1066e9915d00d70b861cc35 Mon Sep 17 00:00:00 2001 From: Dave Longley Date: Wed, 21 Apr 2021 14:25:05 -0400 Subject: [PATCH 17/32] Re-enable tests. --- test/10-verify.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/10-verify.spec.js b/test/10-verify.spec.js index aade7bb0..ae04c742 100644 --- a/test/10-verify.spec.js +++ b/test/10-verify.spec.js @@ -292,7 +292,7 @@ describe('verify API (credentials)', () => { }); describe('verify API (presentations)', () => { - it.only('verifies a valid signed presentation', async () => { + it('verifies a valid signed presentation', async () => { const challenge = uuid(); const {presentation, suite, documentLoader} = From b6afc94dd794a15225ef2f062f6514bd09e4ab36 Mon Sep 17 00:00:00 2001 From: Dave Longley Date: Wed, 21 Apr 2021 14:28:19 -0400 Subject: [PATCH 18/32] Fix linting errors. --- lib/vc.js | 8 ++++---- test/10-verify.spec.js | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/vc.js b/lib/vc.js index 358fbb27..b6335ac4 100644 --- a/lib/vc.js +++ b/lib/vc.js @@ -502,7 +502,7 @@ function _checkCredential(credential) { } // check type presence and cardinality - if(!credential['type']) { + if(!credential.type) { throw new Error('"type" property is required.'); } @@ -510,11 +510,11 @@ function _checkCredential(credential) { throw new Error('"type" must include `VerifiableCredential`.'); } - if(!credential['credentialSubject']) { + if(!credential.credentialSubject) { throw new Error('"credentialSubject" property is required.'); } - if(!credential['issuer']) { + if(!credential.issuer) { throw new Error('"issuer" property is required.'); } @@ -524,7 +524,7 @@ function _checkCredential(credential) { } // check issued is a date - if(!credential['issuanceDate']) { + if(!credential.issuanceDate) { throw new Error('"issuanceDate" property is required.'); } diff --git a/test/10-verify.spec.js b/test/10-verify.spec.js index ae04c742..b5626e5a 100644 --- a/test/10-verify.spec.js +++ b/test/10-verify.spec.js @@ -50,7 +50,9 @@ const testLoader = new MultiLoader({ ] }); -let suite, keyPair, verifiableCredential; +let suite; +let keyPair; +let verifiableCredential; const documentLoader = testLoader.documentLoader.bind(testLoader); before(async () => { From 6bf79ec5ebab7975514da63fca5fd0e1cda1e0e8 Mon Sep 17 00:00:00 2001 From: Dmitri Zagidulin Date: Wed, 21 Apr 2021 14:34:14 -0400 Subject: [PATCH 19/32] Update to latest suite packages. --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index e7c8ea25..54b92751 100644 --- a/package.json +++ b/package.json @@ -41,14 +41,14 @@ "@babel/plugin-transform-runtime": "^7.13.9", "@babel/preset-env": "^7.13.9", "@babel/runtime": "^7.13.9", - "@digitalbazaar/ed25519-signature-2018": "^1.0.0", - "@digitalbazaar/ed25519-signature-2020": "^1.0.0", + "@digitalbazaar/ed25519-signature-2018": "^2.0.1", + "@digitalbazaar/ed25519-signature-2020": "^2.1.0", "@digitalbazaar/ed25519-verification-key-2018": "^3.0.0", "@digitalbazaar/ed25519-verification-key-2020": "^2.0.0", "babel-loader": "^8.2.2", "chai": "^4.3.3", "cross-env": "^7.0.3", - "did-context": "^2.0.0", + "did-context": "^3.0.1", "did-veres-one": "^13.0.0", "eslint": "^7.21.0", "eslint-config-digitalbazaar": "^2.6.1", From bf3499648c75259589f4713cfc9007e726797f27 Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Wed, 21 Apr 2021 14:58:44 -0400 Subject: [PATCH 20/32] Setup nyc options. --- package.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/package.json b/package.json index 54b92751..4a47aacc 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,15 @@ "webpack": "^5.24.3", "webpack-cli": "^4.5.0" }, + "nyc": { + "exclude": [ + "test" + ], + "reporter": [ + "html", + "text-summary" + ] + }, "browser": { "Buffer": false, "crypto": false, From b0a14ac429ed977647076fdc2969a738dd9974c2 Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Wed, 21 Apr 2021 15:02:00 -0400 Subject: [PATCH 21/32] Fix karma testing. - Add null fallbacks for unneeded libraries. --- karma.conf.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/karma.conf.js b/karma.conf.js index ce6f71dc..b45f9685 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -28,7 +28,14 @@ module.exports = function(config) { webpack: { //mode: 'production', mode: 'development', - devtool: 'inline-source-map' + devtool: 'inline-source-map', + resolve: { + fallback: { + crypto: false, + url: false, + util: false + } + } }, // test results reporter to use From 1b6af76bac8936724ed90bc84841d3f52580fcbb Mon Sep 17 00:00:00 2001 From: Dave Longley Date: Wed, 21 Apr 2021 15:05:27 -0400 Subject: [PATCH 22/32] Update DID doc context URL. --- test/constants.js | 2 +- test/mocks/didDocument.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/constants.js b/test/constants.js index 34ec217d..a3ca2689 100644 --- a/test/constants.js +++ b/test/constants.js @@ -1,5 +1,5 @@ module.exports = { CREDENTIALS_CONTEXT_URL: 'https://www.w3.org/2018/credentials/v1', - DID_CONTEXT_URL: 'https://w3id.org/did/v0.11', + DID_CONTEXT_URL: 'https://www.w3.org/ns/did/v1', VERES_ONE_CONTEXT_URL: 'https://w3id.org/veres-one/v1' }; diff --git a/test/mocks/didDocument.js b/test/mocks/didDocument.js index 1aed5edb..1aaec946 100644 --- a/test/mocks/didDocument.js +++ b/test/mocks/didDocument.js @@ -1,7 +1,7 @@ /* eslint-disable */ module.exports = { "@context": [ - "https://w3id.org/did/v0.11", + "https://www.w3.org/ns/did/v1", "https://w3id.org/veres-one/v1" ], "id": "did:v1:test:nym:z6MknshWwzBaWsZ7jph8pUeJWg8rhoub7dK6upUK3WMJqd6m", From 3cbae0bc3a63ed8cd0d34037ea1e02e085c56c5e Mon Sep 17 00:00:00 2001 From: Dave Longley Date: Wed, 21 Apr 2021 15:24:04 -0400 Subject: [PATCH 23/32] Ensure mock DID Doc loader only loads the DID Doc/keys in it. --- test/10-verify.spec.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/test/10-verify.spec.js b/test/10-verify.spec.js index b5626e5a..29632345 100644 --- a/test/10-verify.spec.js +++ b/test/10-verify.spec.js @@ -195,7 +195,7 @@ describe('verify API (credentials)', () => { }); describe('negative test', async () => { - it('fails to verify if a context is null', async () => { + it('fails to verify if a context resolves to null', async () => { const {credential, suite} = await _generateCredential(); credential['@context'].push(invalidContexts.nullDoc.url); const results = await vc.verifyCredential({ @@ -470,15 +470,16 @@ async function _loadDid() { const didDocument = new VeresOneDidDoc({doc: mockDidDoc}); await didDocument.importKeys(mockDidKeys.keys); const documentLoader = url => { + let document; if(url.includes('#')) { - return { - contextUrl: null, document: didDocument.keys[url], documentUrl: url - }; - } else { - return { - contextUrl: null, document: didDocument.doc, documentUrl: url - }; + document = didDocument.keys[url]; + } else if(url === didDocument.doc.id) { + document = didDocument.doc; } + if(document) { + return {contextUrl: null, document, documentUrl: url}; + } + throw new Error(`"${url}" not authorized to be resolved.`); }; return { didDocument, documentLoader From a5c7ce489032a4b2209083d44283e8bd78b78481 Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Wed, 21 Apr 2021 15:38:58 -0400 Subject: [PATCH 24/32] Update dist files. - Include .ts files. - Use globstar patterns. --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 4a47aacc..30a39a0a 100644 --- a/package.json +++ b/package.json @@ -24,10 +24,10 @@ "license": "BSD-3-Clause", "main": "lib/index.js", "files": [ - "dist/*.js", - "dist/*.js.map", - "lib/*.js", - "lib/contexts" + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.ts", + "lib/**/*.js" ], "dependencies": { "credentials-context": "^1.0.0", From e442571b5d8155823eeb0cb2c32d368bbe1dc0ed Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Wed, 21 Apr 2021 16:07:07 -0400 Subject: [PATCH 25/32] Remove typescript def generation support. --- CHANGELOG.md | 5 +++++ package.json | 5 +---- tsconfig.json | 10 ---------- 3 files changed, 6 insertions(+), 14 deletions(-) delete mode 100644 tsconfig.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 34c547d1..1fbf74f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # vc-js ChangeLog +## 1.0.0 - 2021-xx-xx + +### Removed +- **BREAKING**: Remove typescript def generation support. + ## 0.6.4 - 2020-05-22 ### Added diff --git a/package.json b/package.json index 30a39a0a..7afeef11 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ "files": [ "dist/**/*.js", "dist/**/*.js.map", - "dist/**/*.ts", "lib/**/*.js" ], "dependencies": { @@ -64,7 +63,6 @@ "mocha": "^8.3.1", "mocha-lcov-reporter": "^1.3.0", "nyc": "^15.1.0", - "typescript": "^4.0.3", "uuid": "^8.3.2", "veres-one-context": "^11.0.0", "webpack": "^5.24.3", @@ -97,8 +95,7 @@ "Credential" ], "scripts": { - "ts:defs": "npx tsc --declaration --outDir dist --emitDeclarationOnly", - "prepublish": "npm run build && npm run ts:defs", + "prepublish": "npm run build", "build": "webpack", "test": "npm run lint && npm run test-node && npm run test-karma", "test-node": "cross-env NODE_ENV=test mocha --preserve-symlinks -t 10000 test/*.spec.js", diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index bcf1147f..00000000 --- a/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compilerOptions": { - "allowJs": true, - "declaration": true, - "emitDeclarationOnly": true, - "outDir": "./dist" - }, - "include": ["lib/**/*"], - "exclude": ["node_modules", "tests"] -} \ No newline at end of file From 34de7057cb0159eb4770ecb0d9b31fffb9e55e60 Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Wed, 21 Apr 2021 16:07:55 -0400 Subject: [PATCH 26/32] No longer ship browser bundles. --- CHANGELOG.md | 1 + package.json | 7 +------ webpack.config.js | 11 ----------- 3 files changed, 2 insertions(+), 17 deletions(-) delete mode 100644 webpack.config.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fbf74f2..282d6fd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Removed - **BREAKING**: Remove typescript def generation support. +- **BREAKING**: No longer shipping browser bundles. ## 0.6.4 - 2020-05-22 diff --git a/package.json b/package.json index 7afeef11..5d22f34f 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,6 @@ "license": "BSD-3-Clause", "main": "lib/index.js", "files": [ - "dist/**/*.js", - "dist/**/*.js.map", "lib/**/*.js" ], "dependencies": { @@ -65,8 +63,7 @@ "nyc": "^15.1.0", "uuid": "^8.3.2", "veres-one-context": "^11.0.0", - "webpack": "^5.24.3", - "webpack-cli": "^4.5.0" + "webpack": "^5.24.3" }, "nyc": { "exclude": [ @@ -95,8 +92,6 @@ "Credential" ], "scripts": { - "prepublish": "npm run build", - "build": "webpack", "test": "npm run lint && npm run test-node && npm run test-karma", "test-node": "cross-env NODE_ENV=test mocha --preserve-symlinks -t 10000 test/*.spec.js", "test-karma": "karma start karma.conf.js", diff --git a/webpack.config.js b/webpack.config.js deleted file mode 100644 index f5688925..00000000 --- a/webpack.config.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - entry: { - 'vc-js': './lib/index.js' - }, - mode: 'production', - output: { - filename: '[name].min.js', - library: 'VC', - libraryTarget: 'umd' - } -}; From 6f7d1ca28734cf078aea043cd05e723560560c29 Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Wed, 21 Apr 2021 16:10:31 -0400 Subject: [PATCH 27/32] Remove unused 'esm' dependency. --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 5d22f34f..50f345ec 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,6 @@ ], "dependencies": { "credentials-context": "^1.0.0", - "esm": "^3.2.25", "jsonld": "^5.2.0", "jsonld-signatures": "^9.0.2" }, From c3485ac210f1300d558cd234609b098c742052ff Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Wed, 21 Apr 2021 16:32:53 -0400 Subject: [PATCH 28/32] Rename package to `@digitalbazaar/vc`. - Rename uses of `vc-js` to `@digitalbazaar/vc`. - Update changelog. - Update README. - Update badges. --- BACKGROUND.md | 2 +- CHANGELOG.md | 7 ++++++- README.md | 14 +++++++------- lib/index.js | 2 +- package.json | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/BACKGROUND.md b/BACKGROUND.md index ef623480..5d9a1fe3 100644 --- a/BACKGROUND.md +++ b/BACKGROUND.md @@ -1,4 +1,4 @@ -## `vc-js` Background Documentation +## `@digitalbazaar/vc` Background Documentation See also (related specs): diff --git a/CHANGELOG.md b/CHANGELOG.md index 282d6fd1..11d2669f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,15 @@ -# vc-js ChangeLog +# @digitalbazaar/vc ChangeLog ## 1.0.0 - 2021-xx-xx +### Changed +- **BREAKING**: Rename library to `@digitalbazaar/vc`. +- Update dependencies. + ### Removed - **BREAKING**: Remove typescript def generation support. - **BREAKING**: No longer shipping browser bundles. +- **BREAKING**: Move `vc-js` binary to `@digitalbazaar/vc-js-cli`. ## 0.6.4 - 2020-05-22 diff --git a/README.md b/README.md index 440a0c24..5cb943c7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# Verifiable Credentials JS Library _(vc-js)_ +# Verifiable Credentials JS Library _(@digitalbazaar/vc)_ -[![Build Status](https://travis-ci.org/digitalbazaar/vc-js.png?branch=master)](https://travis-ci.org/digitalbazaar/vc-js) -[![NPM Version](https://img.shields.io/npm/v/vc-js.svg?style=flat-square)](https://npm.im/vc-js) +[![Build Status](https://img.shields.io/github/workflow/status/digitalbazaar/vc/Node.js%20CI)](https://github.com/digitalbazaar/vc/actions?query=workflow%3A%22Node.js+CI%22) +[![NPM Version](https://img.shields.io/npm/v/digitalbazaar/vc.svg)](https://npm.im/@digitalbazaar/vc) > A Javascript library for issuing and verifying Verifiable Credentials. @@ -66,7 +66,7 @@ For signing, when setting up a signature suite, you will need to pass in a key pair containing a private key. ```js -import vc from '@digitalbazaar/vc-js'; +import vc from '@digitalbazaar/vc'; // Required to set up a suite instance with private key import {Ed25519VerificationKey2020} from @@ -88,7 +88,7 @@ Pre-requisites: Document and Public Key ```js -const vc = require('vc-js'); +const vc = require('@digitalbazaar/vc'); // Sample unsigned credential const credential = { @@ -199,8 +199,8 @@ Pre-requisites: // contexts are loaded from jsonld-signatures // and not an insecure source. const {extendContextLoader} = require('jsonld-signatures'); -const vc = require('vc-js'); -// vc-js exports its own secure documentLoader. +const vc = require('@digitalbazaar/vc'); +// @digitalbazaar/vc exports its own secure documentLoader. const {defaultDocumentLoader} = vc; // a valid json-ld @context. const myCustomContext = require('./myCustomContext'); diff --git a/lib/index.js b/lib/index.js index 268d8777..b9e1b467 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,5 +1,5 @@ /** - * A library for working with verifiable credentials - vc-js library. + * A library for working with verifiable credentials - vc library. * * @author David I. Lehn * diff --git a/package.json b/package.json index 50f345ec..8654f2c2 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "vc-js", + "name": "@digitalbazaar/vc", "version": "0.6.5-0", "description": "Verifiable Credentials JavaScript library.", "homepage": "https://github.com/digitalbazaar/vc-js", From f0a70c37e5de1933fddaedc4c62ff7a496810dc3 Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Wed, 21 Apr 2021 16:41:51 -0400 Subject: [PATCH 29/32] Fix typo. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8654f2c2..5a6f81b3 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,7 @@ "test-karma": "karma start karma.conf.js", "lint": "eslint lib test/*.spec.js", "coverage": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text-summary npm run test-node", - "coverage-ci": "cross-env NODE_ENV=test nyc --reporter=lcovonly run test-node", + "coverage-ci": "cross-env NODE_ENV=test nyc --reporter=lcovonly npm run test-node", "coverage-report": "nyc report" } } From 186111251289d65d951c5ac0289cd08f5e840597 Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Wed, 21 Apr 2021 16:47:12 -0400 Subject: [PATCH 30/32] Fix typo. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5cb943c7..ec4c0958 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Verifiable Credentials JS Library _(@digitalbazaar/vc)_ [![Build Status](https://img.shields.io/github/workflow/status/digitalbazaar/vc/Node.js%20CI)](https://github.com/digitalbazaar/vc/actions?query=workflow%3A%22Node.js+CI%22) -[![NPM Version](https://img.shields.io/npm/v/digitalbazaar/vc.svg)](https://npm.im/@digitalbazaar/vc) +[![NPM Version](https://img.shields.io/npm/v/@digitalbazaar/vc.svg)](https://npm.im/@digitalbazaar/vc) > A Javascript library for issuing and verifying Verifiable Credentials. From 07eff2b98a06eea58c29bd70661fffe724ff137c Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Wed, 21 Apr 2021 17:39:32 -0400 Subject: [PATCH 31/32] Fix badge links. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ec4c0958..389d0ed8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Verifiable Credentials JS Library _(@digitalbazaar/vc)_ -[![Build Status](https://img.shields.io/github/workflow/status/digitalbazaar/vc/Node.js%20CI)](https://github.com/digitalbazaar/vc/actions?query=workflow%3A%22Node.js+CI%22) +[![Build Status](https://img.shields.io/github/workflow/status/digitalbazaar/vc-js/Node.js%20CI)](https://github.com/digitalbazaar/vc-js/actions?query=workflow%3A%22Node.js+CI%22) [![NPM Version](https://img.shields.io/npm/v/@digitalbazaar/vc.svg)](https://npm.im/@digitalbazaar/vc) > A Javascript library for issuing and verifying Verifiable Credentials. From f3ec4eb6b2f59da66f3adf837a01eb145653a29e Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Wed, 21 Apr 2021 17:41:11 -0400 Subject: [PATCH 32/32] Update changelog. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11d2669f..473167f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ ### Removed - **BREAKING**: Remove typescript def generation support. - **BREAKING**: No longer shipping browser bundles. -- **BREAKING**: Move `vc-js` binary to `@digitalbazaar/vc-js-cli`. +- **BREAKING**: Move binaries from `bin/` to `@digitalbazaar/vc-js-cli`. ## 0.6.4 - 2020-05-22