diff --git a/.gitignore b/.gitignore index 7ece4b56..26ab9964 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,3 @@ npm-debug.log package-lock.json .nyc_output dist -.idea diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a5cad13..24bbc088 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,50 @@ # @digitalcredentials/vc ChangeLog -## 8.0.0 - 2024-08-03 +## 8.0.0 - 2024-xx-xx + +### Added +- Add support for VC 2.0 Verifiable Credentials issuance and verification. +- Add support for VC 2.0 Verifiable Presentations issuance and verification. +- Add support for VC 2.0 `validFrom` and `validUntil`. +- Add Test vectors for VC 2.0 VCs & VPs. +- Allow `credentialStatus` arrays in credential status check. +- Add `derive()` API for deriving new verifiable credentials from + existing ones, for the purpose of selective disclosure or + unlinkable presentation. +- Add optional param `now` to `verifyCredential()`, `createPresentation()`, + `verify()`, and `issue()`. + ### Changed - - **BREAKING**: Switch dependencies to: - - `@digitalcredentials/jsonld` - - `@digitalcredentials/jsonld-signatures` - - `@digitalcredentials/http-client` +- **BREAKING**: Switch dependencies to: + - `@digitalcredentials/jsonld` + - `@digitalcredentials/jsonld-signatures` + - `@digitalcredentials/http-client` +- **BREAKING**: Default issuance now uses VC 2.0 context. +- **BREAKING**: DateTime validator is now an xml schema DateTime validator. +- Change `engines.node` to `>=18` to support newer keys & suites. +- Update dependencies. + - **BREAKING**: Remove support for `expansionMap`. (Removed in dependencies.) +- **BREAKING**: Use `jsonld-signatures@11` and `jsonld@8` to get new `safe` + mode (and on by default when using `canonize`) feature. +- **BREAKING**: Check if credential has expired when `expirationDate` property + exists. +- **BREAKING**: Convert to module (ESM). +- **BREAKING**: Require Node.js >=14. +- Update dependencies. + - **BREAKING**: `did-veres-one@15.0.0` used in tests. +- Lint module. + +### Fixed +- Ensure that `issuanceDate` is only checked on verification, + not issuance. +- Fix bug with option overrides for verifying presentations. + +### Removed +- **BREAKING**: Remove ODRL and VC examples contexts from `./lib/contexts/` and + from the default document loader. The contexts are now available in + [`@digitalbazaar/odrl-context`](https://github.com/digitalbazaar/odrl-context) + and + [`@digitalbazaar/credentials-examples-context`](https://github.com/digitalbazaar/credentials-examples-context). ## 7.0.0 - 2024-02-07 ### Changed @@ -62,85 +101,7 @@ Version skipped to match upstream. -## 7.0.0 - - -### Added -- Add support for VC 2.0 Verifiable Credentials issuance and verification. -- Add support for VC 2.0 Verifiable Presentations issuance and verification. -- Add support for VC 2.0 `validFrom` and `validUntil`. -- Add Test vectors for VC 2.0 VCs & VPs. - -### Changed -- **BREAKING**: Default issuance now uses VC 2.0 context. -- **BREAKING**: DateTime validator is now an xml schema DateTime validator. - -## 6.3.0 - 2023-xx-xx - -### Changed -- Change `engines.node` to `>=18` to support newer keys & suites. - -## 6.2.0 - 2023-11-14 - -### Added -- Allow `credentialStatus` arrays in credential status check. - -## 6.1.0 - 2023-11-13 - -### Added -- Add `derive()` API for deriving new verifiable credentials from - existing ones, for the purpose of selective disclosure or - unlinkable presentation. - -## 6.0.2 - 2023-08-04 - -### Fixed -- Ensure that `issuanceDate` is only checked on verification, - not issuance. - -## 6.0.1 - 2023-03-17 - -### Fixed -- Fix bug with option overrides for verifying presentations. - -## 6.0.0 - 2023-01-17 - -### Removed -- **BREAKING**: Remove ODRL and VC examples contexts from `./lib/contexts/` and - from the default document loader. The contexts are now available in - [`@digitalbazaar/odrl-context`](https://github.com/digitalbazaar/odrl-context) - and - [`@digitalbazaar/credentials-examples-context`](https://github.com/digitalbazaar/credentials-examples-context). - -### Changed -- Update dependencies. - - **BREAKING**: Remove support for `expansionMap`. (Removed in dependencies.) - -## 5.0.0 - 2022-08-24 - -### Changed -- **BREAKING**: Use `jsonld-signatures@11` and `jsonld@8` to get new `safe` - mode (and on by default when using `canonize`) feature. - -## 4.0.0 - 2022-06-23 - -### Changed -- **BREAKING**: Check if credential has expired when `expirationDate` property - exists. - -### Added -- Add optional param `now` to `verifyCredential()`, `createPresentation()`, - `verify()`, and `issue()`. - -## 3.0.0 - 2022-06-15 - -### Changed -- **BREAKING**: Convert to module (ESM). -- **BREAKING**: Require Node.js >=14. -- Update dependencies. - - **BREAKING**: `did-veres-one@15.0.0` used in tests. -- Lint module. - -## 2.1.0 - 2021-12-20 +## 2.1.0 - 2021-xx-xx ### Changed - Sync VC example context from vc-data-model spec source. diff --git a/README.md b/README.md index ce897b6a..195d7e1d 100644 --- a/README.md +++ b/README.md @@ -61,8 +61,8 @@ npm install @digitalbazaar/vc To install locally (for development): ``` -git clone https://github.com/digitalcredentials/vc-js.git -cd vc-js +git clone https://github.com/digitalcredentials/vc.git +cd vc npm install ``` diff --git a/karma.conf.cjs b/karma.conf.cjs index 6e69cfb4..d6622a44 100644 --- a/karma.conf.cjs +++ b/karma.conf.cjs @@ -27,7 +27,14 @@ module.exports = function(config) { webpack: { mode: 'development', - devtool: 'inline-source-map' + devtool: 'inline-source-map', + resolve: { + fallback: { + crypto: false, + url: false, + util: false + } + } }, // test results reporter to use diff --git a/lib/CredentialIssuancePurpose.js b/lib/CredentialIssuancePurpose.js index 9bde5572..288f380f 100644 --- a/lib/CredentialIssuancePurpose.js +++ b/lib/CredentialIssuancePurpose.js @@ -1,10 +1,10 @@ /*! * Copyright (c) 2019-2023 Digital Bazaar, Inc. All rights reserved. */ -'use strict'; -const jsonld = require('@digitalcredentials/jsonld'); -const {AssertionProofPurpose} = - require('@digitalcredentials/jsonld-signatures').purposes; +import jsigs from '@digitalcredentials/jsonld-signatures'; +import jsonld from '@digitalcredentials/jsonld'; + +const {purposes: {AssertionProofPurpose}} = jsigs; /** * Creates a proof purpose that will validate whether the verification diff --git a/package.json b/package.json index 7ab7b0f2..8398047c 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,6 @@ "@digitalcredentials/ed25519-signature-2020": "^5.0.0", "@digitalcredentials/security-document-loader": "digitalcredentials/security-document-loader#add-vc-2.0-context", "@npmcli/package-json": "^5.0.0", - "c8": "^8.0.1", "chai": "^4.3.7", "cross-env": "^7.0.3", "did-context": "^3.1.1", @@ -65,19 +64,27 @@ "klona": "^2.0.6", "mocha": "^10.2.0", "mocha-lcov-reporter": "^1.3.0", + "nyc": "^15.1.0", "rimraf": "^5.0.5", "rollup": "^2.77.2", "uuid": "^9.0.0", "veres-one-context": "^12.0.0", "webpack": "^5.75.0" }, - "c8": { + "nyc": { + "exclude": [ + "test" + ], "reporter": [ - "lcov", - "text-summary", - "text" + "html", + "text-summary" ] }, + "browser": { + "Buffer": false, + "crypto": false, + "util": false + }, "engines": { "node": ">=18" }, @@ -99,9 +106,9 @@ "pretest": "node pre-test.js", "rebuild": "npm run clear && npm run build", "test": "npm run test-node", - "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", + "test-node": "cross-env NODE_ENV=test mocha --preserve-symlinks -t 10000 test/*.spec.js", + "test-karma": "karma start karma.conf.cjs", + "lint": "eslint '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 npm run test-node", "coverage-report": "nyc report" diff --git a/test/20-checkStatus.spec.js b/test/20-checkStatus.spec.js deleted file mode 100644 index 1cf606f3..00000000 --- a/test/20-checkStatus.spec.js +++ /dev/null @@ -1,67 +0,0 @@ -/* eslint-disable */ -const {checkStatus} = require('fix-esm').require('@digitalcredentials/vc-status-list'); -const {Ed25519Signature2020} = require('@digitalcredentials/ed25519-signature-2020'); -const {securityLoader} = require('@digitalcredentials/security-document-loader'); -const vc = require('..'); - -const mockCredential = { - '@context': [ - 'https://www.w3.org/2018/credentials/v1', - 'https://w3id.org/security/suites/ed25519-2020/v1', - 'https://w3id.org/dcc/v1', - 'https://w3id.org/vc/status-list/2021/v1' - ], - type: [ - 'VerifiableCredential', - 'Assertion' - ], - issuer: { - id: 'did:key:z6MkhVTX9BF3NGYX6cc7jWpbNnR7cAjH8LUffabZP8Qu4ysC', - name: 'Example University', - url: 'https://cs.example.edu', - image: 'https://user-images.githubusercontent.com/947005/133544904-29d6139d-2e7b-4fe2-b6e9-7d1022bb6a45.png' - }, - issuanceDate: '2020-08-16T12:00:00.000+00:00', - credentialSubject: { - id: 'did:key:z6MkhVTX9BF3NGYX6cc7jWpbNnR7cAjH8LUffabZP8Qu4ysC', - name: 'Kayode Ezike', - hasCredential: { - type: [ - 'EducationalOccupationalCredential' - ], - name: 'GT Guide', - description: 'The holder of this credential is qualified to lead new student orientations.' - } - }, - expirationDate: '2025-08-16T12:00:00.000+00:00', - credentialStatus: { - id: 'https://digitalcredentials.github.io/credential-status-playground/JWZM3H8WKU#3', - type: 'StatusList2021Entry', - statusPurpose: 'revocation', - statusListIndex: 3, - statusListCredential: 'https://digitalcredentials.github.io/credential-status-playground/JWZM3H8WKU' - }, - proof: { - type: 'Ed25519Signature2020', - created: '2022-08-19T06:58:29Z', - verificationMethod: 'did:key:z6MkhVTX9BF3NGYX6cc7jWpbNnR7cAjH8LUffabZP8Qu4ysC#z6MkhVTX9BF3NGYX6cc7jWpbNnR7cAjH8LUffabZP8Qu4ysC', - proofPurpose: 'assertionMethod', - proofValue: 'z33Wy3kvx8UEoPHdQWYHVCXAjW19AZpA88NnikwfJqcH9oNmHyqSkt6wiVS31ewytAX7m2vneVEm8Awo4xzqKHYUp' - } -}; - -const documentLoader = securityLoader().build(); - -describe('checkStatus', () => { - it.skip('should verify', async () => { - const suite = new Ed25519Signature2020(); - const result = await vc.verifyCredential({ - credential: mockCredential, - suite, - documentLoader, - checkStatus - }); - - console.log(JSON.stringify(result, null, 2)); - }); -});