@digitalbazaar/vc 6.0.0 → 6.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/lib/index.js +14 -12
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Verifiable Credentials JS Library _(@digitalbazaar/vc)_
2
2
 
3
- [![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)
3
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/digitalbazaar/vc/main.yml)](https://github.com/digitalbazaar/vc/actions/workflow/main.yml)
4
4
  [![NPM Version](https://img.shields.io/npm/v/@digitalbazaar/vc.svg)](https://npm.im/@digitalbazaar/vc)
5
5
 
6
6
  > A Javascript library for issuing and verifying Verifiable Credentials.
package/lib/index.js CHANGED
@@ -139,7 +139,7 @@ export async function issue({
139
139
  }
140
140
 
141
141
  // run common credential checks
142
- _checkCredential({credential, now});
142
+ _checkCredential({credential, now, mode: 'issue'});
143
143
 
144
144
  return jsigs.sign(credential, {purpose, documentLoader, suite});
145
145
  }
@@ -290,7 +290,7 @@ async function _verifyCredential(options = {}) {
290
290
  });
291
291
 
292
292
  const result = await jsigs.verify(
293
- credential, {purpose, documentLoader, ...options});
293
+ credential, {...options, purpose, documentLoader});
294
294
 
295
295
  // if verification has already failed, skip status check
296
296
  if(!result.verified) {
@@ -382,7 +382,7 @@ export async function signPresentation(options = {}) {
382
382
 
383
383
  const documentLoader = options.documentLoader || defaultDocumentLoader;
384
384
 
385
- return jsigs.sign(presentation, {purpose, documentLoader, ...options});
385
+ return jsigs.sign(presentation, {...options, purpose, documentLoader});
386
386
  }
387
387
 
388
388
  /**
@@ -441,7 +441,7 @@ async function _verifyPresentation(options = {}) {
441
441
  if(credentials.length > 0) {
442
442
  // verify every credential in `verifiableCredential`
443
443
  credentialResults = await Promise.all(credentials.map(credential => {
444
- return verifyCredential({credential, documentLoader, ...options});
444
+ return verifyCredential({...options, credential, documentLoader});
445
445
  }));
446
446
 
447
447
  for(const [i, credentialResult] of credentialResults.entries()) {
@@ -469,7 +469,7 @@ async function _verifyPresentation(options = {}) {
469
469
  new AuthenticationProofPurpose({controller, domain, challenge});
470
470
 
471
471
  const presentationResult = await jsigs.verify(
472
- presentation, {purpose, documentLoader, ...options});
472
+ presentation, {...options, purpose, documentLoader});
473
473
 
474
474
  return {
475
475
  presentationResult,
@@ -536,7 +536,7 @@ export function _checkPresentation(presentation) {
536
536
  * @throws {Error}
537
537
  * @private
538
538
  */
539
- export function _checkCredential({credential, now = new Date()}) {
539
+ export function _checkCredential({credential, now = new Date(), mode = 'verify'}) {
540
540
  if(typeof now === 'string') {
541
541
  now = new Date(now);
542
542
  }
@@ -586,12 +586,14 @@ export function _checkCredential({credential, now = new Date()}) {
586
586
  if(!dateRegex.test(issuanceDate)) {
587
587
  throw new Error(`"issuanceDate" must be a valid date: ${issuanceDate}`);
588
588
  }
589
- // check if `now` is before `issuanceDate`
590
- issuanceDate = new Date(issuanceDate);
591
- if(now < issuanceDate) {
592
- throw new Error(
593
- `The current date time (${now.toISOString()}) is before the ` +
594
- `"issuanceDate" (${issuanceDate.toISOString()}).`);
589
+ // check if `now` is before `issuanceDate` on verification
590
+ if(mode === 'verify') {
591
+ issuanceDate = new Date(issuanceDate);
592
+ if(now < issuanceDate) {
593
+ throw new Error(
594
+ `The current date time (${now.toISOString()}) is before the ` +
595
+ `"issuanceDate" (${issuanceDate.toISOString()}).`);
596
+ }
595
597
  }
596
598
  }
597
599
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalbazaar/vc",
3
- "version": "6.0.0",
3
+ "version": "6.0.2",
4
4
  "description": "Verifiable Credentials JavaScript library.",
5
5
  "homepage": "https://github.com/digitalbazaar/vc",
6
6
  "author": {
@@ -82,7 +82,7 @@
82
82
  "test": "npm run test-node",
83
83
  "test-node": "cross-env NODE_ENV=test mocha --preserve-symlinks -t 10000 test/*.spec.js",
84
84
  "test-karma": "karma start karma.conf.cjs",
85
- "lint": "eslint .",
85
+ "lint": "eslint 'lib/**/*.js' 'test/**/*.js'",
86
86
  "coverage": "cross-env NODE_ENV=test c8 npm run test-node",
87
87
  "coverage-ci": "cross-env NODE_ENV=test c8 --reporter=lcovonly --reporter=text-summary --reporter=text npm run test-node",
88
88
  "coverage-report": "c8 report"