@bedrock/vc-verifier 12.0.0 → 12.2.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,8 +15,7 @@ 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;
@@ -28,7 +27,7 @@ bedrock.events.on('bedrock-express.configure.bodyParser', app => {
28
27
 
29
28
  export async function addRoutes({app, service} = {}) {
30
29
  const {routePrefix} = service;
31
-
30
+ const suite = createSuites();
32
31
  const cfg = bedrock.config['vc-verifier'];
33
32
  const baseUrl = `${routePrefix}/:localId`;
34
33
  const routes = {
@@ -37,15 +36,6 @@ export async function addRoutes({app, service} = {}) {
37
36
  presentationsVerify: `${baseUrl}${cfg.routes.presentationsVerify}`
38
37
  };
39
38
 
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
39
  const getConfigMiddleware = middleware.createGetConfigMiddleware({service});
50
40
 
51
41
  /* Note: CORS is used on all endpoints. This is safe because authorization
@@ -59,8 +49,7 @@ export async function addRoutes({app, service} = {}) {
59
49
  cors(),
60
50
  validate({bodySchema: createChallengeBody}),
61
51
  getConfigMiddleware,
62
- // FIXME: add middleware to switch between oauth2 / zcap based on headers
63
- middleware.authorizeConfigZcapInvocation(),
52
+ middleware.authorizeServiceObjectRequest(),
64
53
  asyncHandler(async (req, res) => {
65
54
  const {config} = req.serviceObject;
66
55
  const challenge = await createChallenge({verifierId: config.id});
@@ -77,8 +66,7 @@ export async function addRoutes({app, service} = {}) {
77
66
  cors(),
78
67
  validate({bodySchema: verifyCredentialBody}),
79
68
  getConfigMiddleware,
80
- // FIXME: add middleware to switch between oauth2 / zcap based on headers
81
- middleware.authorizeConfigZcapInvocation(),
69
+ middleware.authorizeServiceObjectRequest(),
82
70
  asyncHandler(async (req, res) => {
83
71
  const {config} = req.serviceObject;
84
72
  const documentLoader = await createDocumentLoader({config});
@@ -135,8 +123,7 @@ export async function addRoutes({app, service} = {}) {
135
123
  cors(),
136
124
  validate({bodySchema: verifyPresentationBody}),
137
125
  getConfigMiddleware,
138
- // FIXME: add middleware to switch between oauth2 / zcap based on headers
139
- middleware.authorizeConfigZcapInvocation(),
126
+ middleware.authorizeServiceObjectRequest(),
140
127
  asyncHandler(async (req, res) => {
141
128
  const {config} = req.serviceObject;
142
129
  const documentLoader = await createDocumentLoader({config});
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.0.0",
3
+ "version": "12.2.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,16 +40,18 @@
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
- "@bedrock/service-context-store": "^8.0.0",
50
- "@bedrock/service-core": "^6.0.0",
53
+ "@bedrock/service-context-store": "^8.1.0",
54
+ "@bedrock/service-core": "^6.1.2",
51
55
  "@bedrock/validation": "^7.0.0",
52
56
  "@bedrock/vc-revocation-list-context": "^3.1.0",
53
57
  "@bedrock/vc-status-list-context": "^4.1.0",