@digitalbazaar/vc 6.0.1 → 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.
- package/README.md +1 -1
- package/lib/index.js +10 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Verifiable Credentials JS Library _(@digitalbazaar/vc)_
|
|
2
2
|
|
|
3
|
-
[](https://github.com/digitalbazaar/vc/actions/workflow/main.yml)
|
|
4
4
|
[](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
|
}
|
|
@@ -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
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
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.
|
|
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"
|