@bedrock/vc-verifier 12.1.0 → 12.3.0

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/lib/config.js CHANGED
@@ -23,7 +23,11 @@ cfg.documentLoader = {
23
23
  https: true
24
24
  };
25
25
 
26
- cfg.supportedSuites = ['Ed25519Signature2018', 'Ed25519Signature2020'];
26
+ cfg.supportedSuites = [
27
+ 'Ed25519Signature2018',
28
+ 'Ed25519Signature2020',
29
+ 'eddsa-2022',
30
+ ];
27
31
 
28
32
  cfg.routes = {
29
33
  challenges: '/challenges',
@@ -10,8 +10,10 @@ import {
10
10
  import {createContextDocumentLoader} from '@bedrock/service-context-store';
11
11
  import {didIo} from '@bedrock/did-io';
12
12
  import '@bedrock/credentials-context';
13
+ import '@bedrock/data-integrity-context';
13
14
  import '@bedrock/did-context';
14
15
  import '@bedrock/did-io';
16
+ import '@bedrock/multikey-context';
15
17
  import '@bedrock/security-context';
16
18
  import '@bedrock/vc-revocation-list-context';
17
19
  import '@bedrock/vc-status-list-context';
package/lib/http.js CHANGED
@@ -15,20 +15,24 @@ import bodyParser from 'body-parser';
15
15
  import {checkStatus} from './status.js';
16
16
  import cors from 'cors';
17
17
  import {createDocumentLoader} from './documentLoader.js';
18
- import {Ed25519Signature2018} from '@digitalbazaar/ed25519-signature-2018';
19
- import {Ed25519Signature2020} from '@digitalbazaar/ed25519-signature-2020';
18
+ import {createSuites} from './suites.js';
20
19
  import {createValidateMiddleware as validate} from '@bedrock/validation';
21
20
 
22
21
  const {util: {BedrockError}} = bedrock;
23
22
 
24
23
  // FIXME: remove and apply at top-level application
25
24
  bedrock.events.on('bedrock-express.configure.bodyParser', app => {
26
- app.use(bodyParser.json({limit: '10MB', type: ['json', '+json']}));
25
+ app.use(bodyParser.json({
26
+ // allow json that is not just arrays or objects
27
+ strict: false,
28
+ limit: '10MB',
29
+ type: ['json', '+json']
30
+ }));
27
31
  });
28
32
 
29
33
  export async function addRoutes({app, service} = {}) {
30
34
  const {routePrefix} = service;
31
-
35
+ const suite = createSuites();
32
36
  const cfg = bedrock.config['vc-verifier'];
33
37
  const baseUrl = `${routePrefix}/:localId`;
34
38
  const routes = {
@@ -37,15 +41,6 @@ export async function addRoutes({app, service} = {}) {
37
41
  presentationsVerify: `${baseUrl}${cfg.routes.presentationsVerify}`
38
42
  };
39
43
 
40
- const {supportedSuites} = cfg;
41
- const suite = [];
42
- if(supportedSuites.includes('Ed25519Signature2018')) {
43
- suite.push(new Ed25519Signature2018());
44
- }
45
- if(supportedSuites.includes('Ed25519Signature2020')) {
46
- suite.push(new Ed25519Signature2020());
47
- }
48
-
49
44
  const getConfigMiddleware = middleware.createGetConfigMiddleware({service});
50
45
 
51
46
  /* Note: CORS is used on all endpoints. This is safe because authorization
package/lib/suites.js ADDED
@@ -0,0 +1,37 @@
1
+ /*!
2
+ * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
3
+ */
4
+ import * as bedrock from '@bedrock/core';
5
+ import {DataIntegrityProof} from '@digitalbazaar/data-integrity';
6
+ import {Ed25519Signature2018} from '@digitalbazaar/ed25519-signature-2018';
7
+ import {Ed25519Signature2020} from '@digitalbazaar/ed25519-signature-2020';
8
+ import {
9
+ cryptosuite as eddsa2022CryptoSuite
10
+ } from '@digitalbazaar/eddsa-2022-cryptosuite';
11
+
12
+ // DataIntegrityProof should work for multiple cryptosuites
13
+ const SUPPORTED_CRYPTOSUITES = new Map([
14
+ ['eddsa-2022', eddsa2022CryptoSuite]
15
+ ]);
16
+
17
+ const SUPPORTED_LEGACY_SUITES = new Map([
18
+ ['Ed25519Signature2018', Ed25519Signature2018],
19
+ ['Ed25519Signature2020', Ed25519Signature2020]
20
+ ]);
21
+
22
+ export function createSuites() {
23
+ const cfg = bedrock.config['vc-verifier'];
24
+ const {supportedSuites} = cfg;
25
+ const suite = supportedSuites.map(supportedSuite => {
26
+ const LegacySuite = SUPPORTED_LEGACY_SUITES.get(supportedSuite);
27
+ if(LegacySuite) {
28
+ return new LegacySuite();
29
+ }
30
+ const cryptosuite = SUPPORTED_CRYPTOSUITES.get(supportedSuite);
31
+ if(cryptosuite) {
32
+ return new DataIntegrityProof({cryptosuite});
33
+ }
34
+ throw new Error(`Unsupported suite ${supportedSuite}`);
35
+ });
36
+ return suite;
37
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrock/vc-verifier",
3
- "version": "12.1.0",
3
+ "version": "12.3.0",
4
4
  "type": "module",
5
5
  "description": "Bedrock VC Verifier",
6
6
  "main": "./lib/index.js",
@@ -25,9 +25,11 @@
25
25
  },
26
26
  "homepage": "https://github.com/digitalbazaar/bedrock-vc-verifier",
27
27
  "dependencies": {
28
+ "@digitalbazaar/data-integrity": "^1.0.0",
28
29
  "@digitalbazaar/ed25519-signature-2018": "^3.0.0",
29
30
  "@digitalbazaar/ed25519-signature-2020": "^4.0.1",
30
- "@digitalbazaar/vc": "^4.0.0",
31
+ "@digitalbazaar/eddsa-2022-cryptosuite": "^1.0.0",
32
+ "@digitalbazaar/vc": "^5.0.0",
31
33
  "@digitalbazaar/vc-revocation-list": "^4.0.0",
32
34
  "@digitalbazaar/vc-status-list": "^5.0.0",
33
35
  "assert-plus": "^1.0.0",
@@ -38,12 +40,14 @@
38
40
  "peerDependencies": {
39
41
  "@bedrock/core": "^6.0.1",
40
42
  "@bedrock/credentials-context": "^3.0.0",
43
+ "@bedrock/data-integrity-context": "^1.0.0",
41
44
  "@bedrock/did-context": "^4.0.0",
42
45
  "@bedrock/did-io": "^9.0.1",
43
46
  "@bedrock/express": "^8.0.0",
44
47
  "@bedrock/https-agent": "^4.0.0",
45
48
  "@bedrock/jsonld-document-loader": "^3.0.0",
46
49
  "@bedrock/mongodb": "^10.0.0",
50
+ "@bedrock/multikey-context": "^1.0.0",
47
51
  "@bedrock/security-context": "^7.0.0",
48
52
  "@bedrock/service-agent": "^6.0.0",
49
53
  "@bedrock/service-context-store": "^8.1.0",