@bedrock/kms-http 19.0.0 → 20.1.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.
@@ -0,0 +1,28 @@
1
+ /*!
2
+ * Copyright (c) 2019-2024 Digital Bazaar, Inc. All rights reserved.
3
+ */
4
+ import {didIo} from '@bedrock/did-io';
5
+ import {documentLoader} from '@bedrock/jsonld-document-loader';
6
+ import '@bedrock/did-context';
7
+ import '@bedrock/security-context';
8
+ import '@bedrock/veres-one-context';
9
+
10
+ // load config defaults
11
+ import './config.js';
12
+
13
+ async function defaultDocumentLoader(url) {
14
+ let document;
15
+ if(url.startsWith('did:')) {
16
+ document = await didIo.get({did: url});
17
+ return {
18
+ contextUrl: null,
19
+ documentUrl: url,
20
+ document
21
+ };
22
+ }
23
+
24
+ // finally, try the bedrock document loader
25
+ return documentLoader(url);
26
+ }
27
+
28
+ export {defaultDocumentLoader as documentLoader};
package/lib/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  /*!
2
- * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2019-2024 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
4
  import '@bedrock/express';
5
5
 
6
+ import './documentLoader.js';
6
7
  import './http.js';
7
8
 
8
9
  // load config defaults
package/lib/middleware.js CHANGED
@@ -1,27 +1,22 @@
1
1
  /*!
2
- * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2019-2024 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
4
  import * as bedrock from '@bedrock/core';
5
5
  import * as brZCapStorage from '@bedrock/zcap-storage';
6
+ import * as Ed25519Multikey from '@digitalbazaar/ed25519-multikey';
6
7
  import * as helpers from './helpers.js';
7
8
  import {
8
9
  authorizeZcapInvocation as _authorizeZcapInvocation,
9
10
  authorizeZcapRevocation as _authorizeZcapRevocation
10
11
  } from '@digitalbazaar/ezcap-express';
11
- import {
12
- defaultDocumentLoader as documentLoader,
13
- defaultModuleManager as moduleManager
14
- } from '@bedrock/kms';
15
12
  import {default as _cors} from 'cors';
16
13
  import {asyncHandler} from '@bedrock/express';
17
14
  import {BedrockKeystoreConfigStorage} from './BedrockKeystoreConfigStorage.js';
18
15
  import {createOperationMiddleware} from '@digitalbazaar/webkms-switch';
19
- import {CryptoLD} from 'crypto-ld';
16
+ import {documentLoader} from './documentLoader.js';
20
17
  import {Ed25519Signature2020} from '@digitalbazaar/ed25519-signature-2020';
21
- import {
22
- Ed25519VerificationKey2020
23
- } from '@digitalbazaar/ed25519-verification-key-2020';
24
18
  import {logger} from './logger.js';
19
+ import {defaultModuleManager as moduleManager} from '@bedrock/kms';
25
20
  import {reportOperationUsage} from './metering.js';
26
21
 
27
22
  const {config, util: {BedrockError}} = bedrock;
@@ -30,10 +25,6 @@ const FIVE_MINUTES = 1000 * 60 * 5;
30
25
 
31
26
  const storage = new BedrockKeystoreConfigStorage();
32
27
 
33
- // create `getVerifier` hook for verifying zcap invocation HTTP signatures
34
- const cryptoLd = new CryptoLD();
35
- cryptoLd.use(Ed25519VerificationKey2020);
36
-
37
28
  // creates middleware to get the keystore config for the current request and
38
29
  // caches it in `req.webkms.keystore`
39
30
  export function createGetKeystoreConfig({routes}) {
@@ -201,7 +192,8 @@ async function getKeystoreController({req}) {
201
192
 
202
193
  // hook used to verify zcap invocation HTTP signatures
203
194
  async function getVerifier({keyId, documentLoader}) {
204
- const key = await cryptoLd.fromKeyId({id: keyId, documentLoader});
195
+ const {document} = await documentLoader(keyId);
196
+ const key = await Ed25519Multikey.from(document);
205
197
  const verificationMethod = await key.export(
206
198
  {publicKey: true, includeContext: true});
207
199
  const verifier = key.verifier();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrock/kms-http",
3
- "version": "19.0.0",
3
+ "version": "20.1.0",
4
4
  "type": "module",
5
5
  "description": "Bedrock KMS HTTP API",
6
6
  "main": "./lib/index.js",
@@ -28,23 +28,27 @@
28
28
  },
29
29
  "homepage": "https://github.com/digitalbazaar/bedrock-kms-http",
30
30
  "dependencies": {
31
+ "@digitalbazaar/ed25519-multikey": "^1.1.0",
31
32
  "@digitalbazaar/ed25519-signature-2020": "^5.0.0",
32
- "@digitalbazaar/ed25519-verification-key-2020": "^4.0.0",
33
33
  "@digitalbazaar/ezcap-express": "^7.0.0",
34
34
  "@digitalbazaar/webkms-switch": "^12.0.0",
35
35
  "cidr-regex": "^4.0.0",
36
36
  "cors": "^2.8.5",
37
- "crypto-ld": "^7.0.0",
38
37
  "forwarded": "^0.2.0",
39
38
  "ipaddr.js": "^2.0.1"
40
39
  },
41
40
  "peerDependencies": {
42
41
  "@bedrock/app-identity": "^4.0.0",
43
42
  "@bedrock/core": "^6.0.1",
43
+ "@bedrock/did-context": "^5.0.0",
44
+ "@bedrock/did-io": "^10.1.0",
44
45
  "@bedrock/express": "^8.0.0",
45
- "@bedrock/kms": "^14.0.0",
46
+ "@bedrock/jsonld-document-loader": "^4.0.0",
47
+ "@bedrock/kms": "^15.0.0",
46
48
  "@bedrock/meter-usage-reporter": "^9.0.0",
49
+ "@bedrock/security-context": "^8.0.0",
47
50
  "@bedrock/validation": "^7.0.0",
51
+ "@bedrock/veres-one-context": "^15.0.0",
48
52
  "@bedrock/zcap-storage": "^8.0.0"
49
53
  },
50
54
  "directories": {
@@ -54,7 +58,7 @@
54
58
  "eslint": "^8.18.0",
55
59
  "eslint-config-digitalbazaar": "^5.0.1",
56
60
  "eslint-plugin-jsdoc": "^48.0.2",
57
- "eslint-plugin-unicorn": "^50.0.1",
61
+ "eslint-plugin-unicorn": "^52.0.0",
58
62
  "jsdoc-to-markdown": "^8.0.0"
59
63
  },
60
64
  "engines": {