@bedrock/kms-http 13.0.0 → 14.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/.github/workflows/main.yml +7 -33
- package/CHANGELOG.md +25 -0
- package/lib/BedrockKeystoreConfigStorage.js +6 -5
- package/lib/http.js +1 -1
- package/lib/middleware.js +87 -19
- package/package.json +10 -10
- package/test/mocha/10-keystore.js +4 -4
- package/test/mocha/11-keystore-kms-client.js +2 -2
- package/test/mocha/20-revocation.js +1 -1
- package/test/mocha/21-revocation-ip-allow-list.js +1 -1
- package/test/mocha/30-operations-generate-key.js +2 -2
- package/test/mocha/31-operations-hmac.js +2 -4
- package/test/mocha/helpers.js +2 -2
- package/test/mocha/mock.data.js +1 -1
- package/test/package.json +23 -23
- package/test/test.config.js +2 -2
|
@@ -8,7 +8,7 @@ jobs:
|
|
|
8
8
|
timeout-minutes: 10
|
|
9
9
|
strategy:
|
|
10
10
|
matrix:
|
|
11
|
-
node-version: [
|
|
11
|
+
node-version: [16.x]
|
|
12
12
|
steps:
|
|
13
13
|
- uses: actions/checkout@v2
|
|
14
14
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
@@ -24,12 +24,12 @@ jobs:
|
|
|
24
24
|
timeout-minutes: 10
|
|
25
25
|
services:
|
|
26
26
|
mongodb:
|
|
27
|
-
image: mongo:4.
|
|
27
|
+
image: mongo:4.4
|
|
28
28
|
ports:
|
|
29
29
|
- 27017:27017
|
|
30
30
|
strategy:
|
|
31
31
|
matrix:
|
|
32
|
-
node-version: [14.x]
|
|
32
|
+
node-version: [14.x, 16.x]
|
|
33
33
|
steps:
|
|
34
34
|
- uses: actions/checkout@v2
|
|
35
35
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
@@ -43,45 +43,19 @@ jobs:
|
|
|
43
43
|
- name: Run test with Node.js ${{ matrix.node-version }}
|
|
44
44
|
run: |
|
|
45
45
|
cd test
|
|
46
|
-
npm
|
|
47
|
-
test-karma:
|
|
48
|
-
needs: [test-node]
|
|
49
|
-
runs-on: ubuntu-latest
|
|
50
|
-
timeout-minutes: 10
|
|
51
|
-
services:
|
|
52
|
-
mongodb:
|
|
53
|
-
image: mongo:4.2
|
|
54
|
-
ports:
|
|
55
|
-
- 27017:27017
|
|
56
|
-
strategy:
|
|
57
|
-
matrix:
|
|
58
|
-
node-version: [14.x]
|
|
59
|
-
steps:
|
|
60
|
-
- uses: actions/checkout@v2
|
|
61
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
62
|
-
uses: actions/setup-node@v1
|
|
63
|
-
with:
|
|
64
|
-
node-version: ${{ matrix.node-version }}
|
|
65
|
-
- run: |
|
|
66
|
-
npm install
|
|
67
|
-
cd test
|
|
68
|
-
npm install
|
|
69
|
-
- name: Run test with Node.js ${{ matrix.node-version }}
|
|
70
|
-
run: |
|
|
71
|
-
cd test
|
|
72
|
-
npm run test-karma
|
|
46
|
+
npm test
|
|
73
47
|
coverage:
|
|
74
|
-
needs: [test-
|
|
48
|
+
needs: [test-node]
|
|
75
49
|
runs-on: ubuntu-latest
|
|
76
50
|
timeout-minutes: 10
|
|
77
51
|
services:
|
|
78
52
|
mongodb:
|
|
79
|
-
image: mongo:4.
|
|
53
|
+
image: mongo:4.4
|
|
80
54
|
ports:
|
|
81
55
|
- 27017:27017
|
|
82
56
|
strategy:
|
|
83
57
|
matrix:
|
|
84
|
-
node-version: [
|
|
58
|
+
node-version: [16.x]
|
|
85
59
|
steps:
|
|
86
60
|
- uses: actions/checkout@v2
|
|
87
61
|
- name: Use Node.js ${{ matrix.node-version }}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# bedrock-kms-http ChangeLog
|
|
2
2
|
|
|
3
|
+
## 14.2.0 - 2022-05-13
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
- Be more resilient to keystore config controller changes. When a keystore
|
|
7
|
+
is new and KMS operations are performed on it that could cause false-positive
|
|
8
|
+
fail authz errors, fetch a fresh version of the config to ensure that the
|
|
9
|
+
controller has not changed.
|
|
10
|
+
|
|
11
|
+
## 14.1.0 - 2022-05-12
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
- Include full error as non-public `cause` in `onError` handler.
|
|
15
|
+
|
|
16
|
+
## 14.0.0 - 2022-04-29
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- **BREAKING**: Update peer deps:
|
|
20
|
+
- `@bedrock/core@6`
|
|
21
|
+
- `@bedrock/app-identity@3`
|
|
22
|
+
- `@bedrock/express@8`
|
|
23
|
+
- `@bedrock/kms@10`
|
|
24
|
+
- `@bedrock/meter-usage-reporter@7`
|
|
25
|
+
- `@bedrock/validation@7`
|
|
26
|
+
- `@bedrock/zcap-storage@7`.
|
|
27
|
+
|
|
3
28
|
## 13.0.0 - 2022-04-05
|
|
4
29
|
|
|
5
30
|
### Changed
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as bedrock from '@bedrock/core';
|
|
5
5
|
import * as helpers from './helpers.js';
|
|
6
|
-
import {createRequire} from 'module';
|
|
6
|
+
import {createRequire} from 'node:module';
|
|
7
7
|
import {keystores} from '@bedrock/kms';
|
|
8
8
|
const require = createRequire(import.meta.url);
|
|
9
9
|
const {KeystoreConfigStorage} = require('@digitalbazaar/webkms-switch');
|
|
@@ -14,12 +14,13 @@ const {util: {BedrockError}} = bedrock;
|
|
|
14
14
|
import './config.js';
|
|
15
15
|
|
|
16
16
|
export class BedrockKeystoreConfigStorage extends KeystoreConfigStorage {
|
|
17
|
-
async get({id, req} = {}) {
|
|
18
|
-
const
|
|
17
|
+
async get({id, req, returnRecord = false, fresh = false} = {}) {
|
|
18
|
+
const record = await keystores.get({id, fresh});
|
|
19
|
+
const {config: keystoreConfig} = record;
|
|
19
20
|
|
|
20
21
|
// skip request checks if specifically requested
|
|
21
22
|
if(req === false) {
|
|
22
|
-
return keystoreConfig;
|
|
23
|
+
return returnRecord ? record : keystoreConfig;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
// verify that request is from an IP that is allowed to access the config
|
|
@@ -32,6 +33,6 @@ export class BedrockKeystoreConfigStorage extends KeystoreConfigStorage {
|
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
return keystoreConfig;
|
|
36
|
+
return returnRecord ? record : keystoreConfig;
|
|
36
37
|
}
|
|
37
38
|
}
|
package/lib/http.js
CHANGED
|
@@ -7,7 +7,7 @@ import * as helpers from './helpers.js';
|
|
|
7
7
|
import * as middleware from './middleware.js';
|
|
8
8
|
import {asyncHandler} from '@bedrock/express';
|
|
9
9
|
import cors from 'cors';
|
|
10
|
-
import {createRequire} from 'module';
|
|
10
|
+
import {createRequire} from 'node:module';
|
|
11
11
|
import {createValidateMiddleware as validate} from '@bedrock/validation';
|
|
12
12
|
import {
|
|
13
13
|
defaultModuleManager as moduleManager,
|
package/lib/middleware.js
CHANGED
|
@@ -6,7 +6,7 @@ import * as brZCapStorage from '@bedrock/zcap-storage';
|
|
|
6
6
|
import * as helpers from './helpers.js';
|
|
7
7
|
import {asyncHandler} from '@bedrock/express';
|
|
8
8
|
import {BedrockKeystoreConfigStorage} from './BedrockKeystoreConfigStorage.js';
|
|
9
|
-
import {createRequire} from 'module';
|
|
9
|
+
import {createRequire} from 'node:module';
|
|
10
10
|
import {
|
|
11
11
|
defaultDocumentLoader as documentLoader,
|
|
12
12
|
defaultModuleManager as moduleManager
|
|
@@ -26,6 +26,8 @@ const {Ed25519VerificationKey2020} =
|
|
|
26
26
|
|
|
27
27
|
const {config, util: {BedrockError}} = bedrock;
|
|
28
28
|
|
|
29
|
+
const FIVE_MINUTES = 1000 * 60 * 5;
|
|
30
|
+
|
|
29
31
|
const storage = new BedrockKeystoreConfigStorage();
|
|
30
32
|
|
|
31
33
|
// create `getVerifier` hook for verifying zcap invocation HTTP signatures
|
|
@@ -39,8 +41,11 @@ export function createGetKeystoreConfig({routes}) {
|
|
|
39
41
|
if(!req.webkms) {
|
|
40
42
|
const keystoreId = helpers.getKeystoreId(
|
|
41
43
|
{req, localId: req.params.keystoreId, routes});
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
+
const configRecord = await storage.get({
|
|
45
|
+
id: keystoreId, req, returnRecord: true
|
|
46
|
+
});
|
|
47
|
+
const {config: keystore} = configRecord;
|
|
48
|
+
req.webkms = {keystore, configRecord};
|
|
44
49
|
}
|
|
45
50
|
next();
|
|
46
51
|
});
|
|
@@ -81,10 +86,7 @@ export function authorizeKeystoreZcapInvocation() {
|
|
|
81
86
|
rootInvocationTarget: req.webkms.keystore.id
|
|
82
87
|
};
|
|
83
88
|
},
|
|
84
|
-
|
|
85
|
-
// this will always be present based on where this middleware is used
|
|
86
|
-
return req.webkms.keystore.controller;
|
|
87
|
-
}
|
|
89
|
+
getRootController: getKeystoreController,
|
|
88
90
|
});
|
|
89
91
|
}
|
|
90
92
|
|
|
@@ -93,10 +95,7 @@ export function authorizeZcapRevocation() {
|
|
|
93
95
|
return _authorizeZcapRevocation({
|
|
94
96
|
documentLoader,
|
|
95
97
|
expectedHost: config.server.host,
|
|
96
|
-
|
|
97
|
-
// this will always be present based on where this middleware is used
|
|
98
|
-
return req.webkms.keystore.controller;
|
|
99
|
-
},
|
|
98
|
+
getRootController: getKeystoreController,
|
|
100
99
|
getVerifier,
|
|
101
100
|
inspectCapabilityChain,
|
|
102
101
|
onError,
|
|
@@ -104,6 +103,77 @@ export function authorizeZcapRevocation() {
|
|
|
104
103
|
});
|
|
105
104
|
}
|
|
106
105
|
|
|
106
|
+
async function getKeystoreController({req}) {
|
|
107
|
+
/* The following code is to prevent false-negative authz errors that are the
|
|
108
|
+
result of stale cached keystore configs.
|
|
109
|
+
|
|
110
|
+
It is a common pattern for keystore configs to have their root controllers
|
|
111
|
+
updated immediately after creation based on the value of a key that is in the
|
|
112
|
+
keystore itself. When this happens, decentralized caches may hold a stale
|
|
113
|
+
config with the old controller value. A client that uses a zcap that is
|
|
114
|
+
delegated / controlled by the root controller would see a false negative
|
|
115
|
+
authz error if the authz check used the cached value.
|
|
116
|
+
|
|
117
|
+
Therefore, this code will check whether keystore configs are reasonably new
|
|
118
|
+
and whether a failure is likely to occur on account of a mismatched root
|
|
119
|
+
controller. If this seems likely, a fresh copy of the keystore config record
|
|
120
|
+
is retrieved.
|
|
121
|
+
|
|
122
|
+
Algorithm: If the keystore config is less than five minutes old, then inspect
|
|
123
|
+
`req.ezcap.invocationParameters.capability` to ensure that either:
|
|
124
|
+
|
|
125
|
+
1. The `capability` is the root zcap and the verification method ID or
|
|
126
|
+
controller match the keystore controller.
|
|
127
|
+
2. The `capability` is delegated and the controller of the first delegated
|
|
128
|
+
zcap in the chain is the keystore controller.
|
|
129
|
+
|
|
130
|
+
If neither condition is true, fetch a fresh version of the keystore config
|
|
131
|
+
record and update `req.webkms`. */
|
|
132
|
+
const now = Date.now();
|
|
133
|
+
if((now - req.webkms.configRecord.meta.created) > FIVE_MINUTES ||
|
|
134
|
+
(req.ezcap.capabilityToRevoke && req.ezcap.invocationParameters)) {
|
|
135
|
+
// config is either older than five minutes or we've already been through
|
|
136
|
+
// this code path for the current request to run the checks against a
|
|
137
|
+
// zcap that is to be revoked (in which case we must not update again to
|
|
138
|
+
// ensure the keystore config used is consistent)
|
|
139
|
+
return req.webkms.keystore.controller;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// check for a zcap from the invocation params or for one to be revoked; the
|
|
143
|
+
// same rules above will be used to check if we need a fresh config record
|
|
144
|
+
const capability = req.ezcap?.invocationParameters?.capability ||
|
|
145
|
+
req.ezcap.capabilityToRevoke;
|
|
146
|
+
|
|
147
|
+
let getFreshConfigRecord = false;
|
|
148
|
+
|
|
149
|
+
// capability is root if it is a string; and it must be invoked because you
|
|
150
|
+
// can't revoke a root zcap
|
|
151
|
+
const isRoot = typeof capability === 'string';
|
|
152
|
+
if(isRoot && req.ezcap.invocationParameters) {
|
|
153
|
+
// fetch verification method early to compare against keystore controller
|
|
154
|
+
const {signature: {params: {keyId}}} = req.ezcap;
|
|
155
|
+
const {verificationMethod} = await getVerifier({keyId, documentLoader});
|
|
156
|
+
getFreshConfigRecord =
|
|
157
|
+
!(verificationMethod.controller === req.webkms.keystore.controller ||
|
|
158
|
+
verificationMethod.id === req.webkms.keystore.controller);
|
|
159
|
+
} else {
|
|
160
|
+
const second = capability?.proof?.capabilityChain[1];
|
|
161
|
+
if(second && second.controller !== req.webkms.keystore.controller) {
|
|
162
|
+
getFreshConfigRecord = true;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if(getFreshConfigRecord) {
|
|
167
|
+
const configRecord = await storage.get({
|
|
168
|
+
id: req.webkms.keystore.id, req, returnRecord: true, fresh: true
|
|
169
|
+
});
|
|
170
|
+
const {config: keystore} = configRecord;
|
|
171
|
+
req.webkms = {keystore, configRecord};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return req.webkms.keystore.controller;
|
|
175
|
+
}
|
|
176
|
+
|
|
107
177
|
// hook used to verify zcap invocation HTTP signatures
|
|
108
178
|
async function getVerifier({keyId, documentLoader}) {
|
|
109
179
|
const key = await cryptoLd.fromKeyId({id: keyId, documentLoader});
|
|
@@ -152,27 +222,25 @@ async function inspectCapabilityChain({
|
|
|
152
222
|
}
|
|
153
223
|
|
|
154
224
|
function onError({error}) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
cause = error;
|
|
159
|
-
} else {
|
|
225
|
+
if(!(error instanceof BedrockError)) {
|
|
226
|
+
// always expose cause message and name; expose cause details as
|
|
227
|
+
// BedrockError if error is marked public
|
|
160
228
|
let details = {};
|
|
161
229
|
if(error.details && error.details.public) {
|
|
162
230
|
details = error.details;
|
|
163
231
|
}
|
|
164
|
-
|
|
232
|
+
error = new BedrockError(
|
|
165
233
|
error.message,
|
|
166
234
|
error.name || 'NotAllowedError', {
|
|
167
235
|
...details,
|
|
168
236
|
public: true,
|
|
169
|
-
});
|
|
237
|
+
}, error);
|
|
170
238
|
}
|
|
171
239
|
throw new BedrockError(
|
|
172
240
|
'Authorization error.', 'NotAllowedError', {
|
|
173
241
|
httpStatusCode: 403,
|
|
174
242
|
public: true,
|
|
175
|
-
},
|
|
243
|
+
}, error);
|
|
176
244
|
}
|
|
177
245
|
|
|
178
246
|
// hook used to create suites for verifying zcap delegation chains
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bedrock/kms-http",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Bedrock KMS HTTP API",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@digitalbazaar/ed25519-signature-2020": "^3.0.0",
|
|
28
28
|
"@digitalbazaar/ed25519-verification-key-2020": "^3.2.0",
|
|
29
|
-
"@digitalbazaar/ezcap-express": "^6.
|
|
29
|
+
"@digitalbazaar/ezcap-express": "^6.2.0",
|
|
30
30
|
"@digitalbazaar/webkms-switch": "^10.0.0",
|
|
31
31
|
"cidr-regex": "^3.1.1",
|
|
32
32
|
"cors": "^2.8.5",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"netmask": "^2.0.2"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@bedrock/
|
|
39
|
-
"@bedrock/
|
|
40
|
-
"@bedrock/express": "^
|
|
41
|
-
"@bedrock/kms": "^
|
|
42
|
-
"@bedrock/meter-usage-reporter": "^
|
|
43
|
-
"@bedrock/validation": "^
|
|
44
|
-
"@bedrock/zcap-storage": "^
|
|
38
|
+
"@bedrock/app-identity": "^3.0.0",
|
|
39
|
+
"@bedrock/core": "^6.0.0",
|
|
40
|
+
"@bedrock/express": "^8.0.0",
|
|
41
|
+
"@bedrock/kms": "^10.1.0",
|
|
42
|
+
"@bedrock/meter-usage-reporter": "^7.0.0",
|
|
43
|
+
"@bedrock/validation": "^7.0.0",
|
|
44
|
+
"@bedrock/zcap-storage": "^7.0.0"
|
|
45
45
|
},
|
|
46
46
|
"directories": {
|
|
47
47
|
"lib": "./lib"
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"eslint": "^7.32.0",
|
|
51
51
|
"eslint-config-digitalbazaar": "^2.8.0",
|
|
52
|
-
"eslint-plugin-jsdoc": "^
|
|
52
|
+
"eslint-plugin-jsdoc": "^39.2.9",
|
|
53
53
|
"jsdoc-to-markdown": "^7.1.1"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
import * as bedrock from '@bedrock/core';
|
|
5
5
|
import * as helpers from './helpers.js';
|
|
6
6
|
import {agent} from '@bedrock/https-agent';
|
|
7
|
-
import {createRequire} from 'module';
|
|
7
|
+
import {createRequire} from 'node:module';
|
|
8
|
+
import {httpClient, DEFAULT_HEADERS} from '@digitalbazaar/http-client';
|
|
8
9
|
import {mockData} from './mock.data.js';
|
|
9
10
|
const require = createRequire(import.meta.url);
|
|
10
11
|
const {CapabilityAgent} = require('@digitalbazaar/webkms-client');
|
|
11
|
-
const {httpClient, DEFAULT_HEADERS} = require('@digitalbazaar/http-client');
|
|
12
12
|
const {signCapabilityInvocation} = require(
|
|
13
13
|
'@digitalbazaar/http-signature-zcap-invoke');
|
|
14
14
|
const {ZcapClient} = require('@digitalbazaar/ezcap');
|
|
@@ -334,7 +334,7 @@ describe('bedrock-kms-http API', () => {
|
|
|
334
334
|
should.exist(result);
|
|
335
335
|
result.should.eql(expectedConfig);
|
|
336
336
|
});
|
|
337
|
-
it('throw
|
|
337
|
+
it('throw operation error when attempting to update "meterId"',
|
|
338
338
|
async () => {
|
|
339
339
|
// TODO: Remove or update this test when the following is fixed
|
|
340
340
|
// eslint-disable-next-line max-len
|
|
@@ -385,7 +385,7 @@ describe('bedrock-kms-http API', () => {
|
|
|
385
385
|
should.not.exist(result);
|
|
386
386
|
should.exist(err);
|
|
387
387
|
err.status.should.equal(500);
|
|
388
|
-
err.data.type.should.equal('
|
|
388
|
+
err.data.type.should.equal('OperationError');
|
|
389
389
|
});
|
|
390
390
|
it('rejects config update for an invalid zcap', async () => {
|
|
391
391
|
const secret = 'd852a72d-013f-4dd6-8ba2-588aaf601b66';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as helpers from './helpers.js';
|
|
5
5
|
import {httpsAgent} from '@bedrock/https-agent';
|
|
6
|
-
import {createRequire} from 'module';
|
|
6
|
+
import {createRequire} from 'node:module';
|
|
7
7
|
const require = createRequire(import.meta.url);
|
|
8
8
|
const {CapabilityAgent, KmsClient, KeystoreAgent} =
|
|
9
9
|
require('@digitalbazaar/webkms-client');
|
|
@@ -55,7 +55,7 @@ describe('keystore API interactions using webkms-client', () => {
|
|
|
55
55
|
should.not.exist(result);
|
|
56
56
|
should.exist(err);
|
|
57
57
|
err.status.should.equal(400);
|
|
58
|
-
err.data.should.
|
|
58
|
+
err.data.should.include.keys('message', 'name', 'type', 'details', 'cause');
|
|
59
59
|
err.data.type.should.equal('URLMismatchError');
|
|
60
60
|
err.data.details.should.have.keys(
|
|
61
61
|
['expected', 'httpStatusCode', 'actual', 'configId', 'requestUrl']);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as helpers from './helpers.js';
|
|
5
5
|
import {httpsAgent} from '@bedrock/https-agent';
|
|
6
|
-
import {createRequire} from 'module';
|
|
6
|
+
import {createRequire} from 'node:module';
|
|
7
7
|
const require = createRequire(import.meta.url);
|
|
8
8
|
const {CapabilityAgent, KmsClient, KeystoreAgent} =
|
|
9
9
|
require('@digitalbazaar/webkms-client');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as helpers from './helpers.js';
|
|
5
5
|
import {httpsAgent} from '@bedrock/https-agent';
|
|
6
|
-
import {createRequire} from 'module';
|
|
6
|
+
import {createRequire} from 'node:module';
|
|
7
7
|
const require = createRequire(import.meta.url);
|
|
8
8
|
const {CapabilityAgent, KmsClient, KeystoreAgent} =
|
|
9
9
|
require('@digitalbazaar/webkms-client');
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
import * as helpers from './helpers.js';
|
|
5
|
+
import {httpClient, DEFAULT_HEADERS} from '@digitalbazaar/http-client';
|
|
5
6
|
import {httpsAgent} from '@bedrock/https-agent';
|
|
6
|
-
import {createRequire} from 'module';
|
|
7
|
+
import {createRequire} from 'node:module';
|
|
7
8
|
const require = createRequire(import.meta.url);
|
|
8
9
|
const {CapabilityAgent, KmsClient, KeystoreAgent} =
|
|
9
10
|
require('@digitalbazaar/webkms-client');
|
|
10
|
-
const {httpClient, DEFAULT_HEADERS} = require('@digitalbazaar/http-client');
|
|
11
11
|
const {signCapabilityInvocation} = require(
|
|
12
12
|
'@digitalbazaar/http-signature-zcap-invoke');
|
|
13
13
|
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
import * as bedrock from '@bedrock/core';
|
|
5
4
|
import * as helpers from './helpers.js';
|
|
6
5
|
import {httpsAgent} from '@bedrock/https-agent';
|
|
7
|
-
import {createRequire} from 'module';
|
|
6
|
+
import {createRequire} from 'node:module';
|
|
8
7
|
import pMap from 'p-map';
|
|
8
|
+
import uuid from 'uuid-random';
|
|
9
9
|
const require = createRequire(import.meta.url);
|
|
10
10
|
const {CapabilityAgent, Hmac, KmsClient} = require(
|
|
11
11
|
'@digitalbazaar/webkms-client');
|
|
12
12
|
|
|
13
|
-
const {util: {uuid}} = bedrock;
|
|
14
|
-
|
|
15
13
|
const ZCAP_ROOT_PREFIX = 'urn:zcap:root:';
|
|
16
14
|
|
|
17
15
|
describe('bedrock-kms-http HMAC operations', () => {
|
package/test/mocha/helpers.js
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
import * as bedrock from '@bedrock/core';
|
|
5
|
-
import {createRequire} from 'module';
|
|
5
|
+
import {createRequire} from 'node:module';
|
|
6
6
|
import {documentLoader} from '@bedrock/jsonld-document-loader';
|
|
7
7
|
import {getAppIdentity} from '@bedrock/app-identity';
|
|
8
8
|
import {httpsAgent} from '@bedrock/https-agent';
|
|
9
9
|
import jsigs from 'jsonld-signatures';
|
|
10
|
+
import uuid from 'uuid-random';
|
|
10
11
|
const require = createRequire(import.meta.url);
|
|
11
12
|
const {AsymmetricKey, CapabilityAgent, KeystoreAgent, KmsClient} =
|
|
12
13
|
require('@digitalbazaar/webkms-client');
|
|
@@ -18,7 +19,6 @@ const {Ed25519Signature2020} = require('@digitalbazaar/ed25519-signature-2020');
|
|
|
18
19
|
const {ZcapClient} = require('@digitalbazaar/ezcap');
|
|
19
20
|
|
|
20
21
|
const {purposes: {AssertionProofPurpose}} = jsigs;
|
|
21
|
-
const {util: {uuid}} = bedrock;
|
|
22
22
|
const {ZCAP_CONTEXT_URL} = zcapConstants;
|
|
23
23
|
|
|
24
24
|
export async function createMeter({capabilityAgent} = {}) {
|
package/test/mocha/mock.data.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
import {createRequire} from 'module';
|
|
4
|
+
import {createRequire} from 'node:module';
|
|
5
5
|
const require = createRequire(import.meta.url);
|
|
6
6
|
const {constants: zcapConstants} = require('@digitalbazaar/zcap');
|
|
7
7
|
|
package/test/package.json
CHANGED
|
@@ -14,33 +14,33 @@
|
|
|
14
14
|
"coverage-report": "c8 report"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@bedrock/app-identity": "^
|
|
18
|
-
"@bedrock/core": "^
|
|
19
|
-
"@bedrock/did-context": "^
|
|
20
|
-
"@bedrock/did-io": "^
|
|
21
|
-
"@bedrock/express": "^
|
|
22
|
-
"@bedrock/https-agent": "^
|
|
23
|
-
"@bedrock/jsonld-document-loader": "^
|
|
24
|
-
"@bedrock/karma": "^
|
|
25
|
-
"@bedrock/kms": "^
|
|
17
|
+
"@bedrock/app-identity": "^3.0.0",
|
|
18
|
+
"@bedrock/core": "^6.0.0",
|
|
19
|
+
"@bedrock/did-context": "^4.0.0",
|
|
20
|
+
"@bedrock/did-io": "^8.0.0",
|
|
21
|
+
"@bedrock/express": "^8.0.0",
|
|
22
|
+
"@bedrock/https-agent": "^4.0.0",
|
|
23
|
+
"@bedrock/jsonld-document-loader": "^3.0.0",
|
|
24
|
+
"@bedrock/karma": "^4.0.0",
|
|
25
|
+
"@bedrock/kms": "^10.0.0",
|
|
26
26
|
"@bedrock/kms-http": "file:..",
|
|
27
|
-
"@bedrock/ledger-context": "^
|
|
28
|
-
"@bedrock/meter": "^
|
|
29
|
-
"@bedrock/meter-http": "^
|
|
30
|
-
"@bedrock/meter-usage-reporter": "^
|
|
31
|
-
"@bedrock/mongodb": "^
|
|
32
|
-
"@bedrock/package-manager": "^
|
|
33
|
-
"@bedrock/security-context": "^
|
|
34
|
-
"@bedrock/server": "^
|
|
35
|
-
"@bedrock/ssm-mongodb": "^
|
|
36
|
-
"@bedrock/test": "^
|
|
37
|
-
"@bedrock/validation": "^
|
|
38
|
-
"@bedrock/veres-one-context": "^
|
|
39
|
-
"@bedrock/zcap-storage": "^
|
|
27
|
+
"@bedrock/ledger-context": "^23.0.0",
|
|
28
|
+
"@bedrock/meter": "^3.0.0",
|
|
29
|
+
"@bedrock/meter-http": "^8.0.0",
|
|
30
|
+
"@bedrock/meter-usage-reporter": "^7.0.0",
|
|
31
|
+
"@bedrock/mongodb": "^10.0.0",
|
|
32
|
+
"@bedrock/package-manager": "^3.0.0",
|
|
33
|
+
"@bedrock/security-context": "^7.0.0",
|
|
34
|
+
"@bedrock/server": "^5.0.0",
|
|
35
|
+
"@bedrock/ssm-mongodb": "^9.0.0",
|
|
36
|
+
"@bedrock/test": "^8.0.0",
|
|
37
|
+
"@bedrock/validation": "^7.0.0",
|
|
38
|
+
"@bedrock/veres-one-context": "^14.0.0",
|
|
39
|
+
"@bedrock/zcap-storage": "^7.0.0",
|
|
40
40
|
"@digitalbazaar/did-method-key": "^2.0.0",
|
|
41
41
|
"@digitalbazaar/ed25519-signature-2020": "^3.0.0",
|
|
42
42
|
"@digitalbazaar/ezcap": "^2.0.0",
|
|
43
|
-
"@digitalbazaar/http-client": "^
|
|
43
|
+
"@digitalbazaar/http-client": "^3.0.1",
|
|
44
44
|
"@digitalbazaar/http-signature-zcap-invoke": "^5.0.1",
|
|
45
45
|
"@digitalbazaar/webkms-client": "^10.0.0",
|
|
46
46
|
"@digitalbazaar/zcap": "^7.0.0",
|
package/test/test.config.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
import {config} from '@bedrock/core';
|
|
5
|
-
import {fileURLToPath} from 'url';
|
|
6
|
-
import path from 'path';
|
|
5
|
+
import {fileURLToPath} from 'node:url';
|
|
6
|
+
import path from 'node:path';
|
|
7
7
|
import '@bedrock/https-agent';
|
|
8
8
|
import '@bedrock/kms-http';
|
|
9
9
|
import '@bedrock/mongodb';
|