@bedrock/kms 10.3.0 → 11.0.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/keystores.js CHANGED
@@ -4,10 +4,8 @@
4
4
  import * as bedrock from '@bedrock/core';
5
5
  import * as database from '@bedrock/mongodb';
6
6
  import assert from 'assert-plus';
7
+ import {LruCache} from '@digitalbazaar/lru-memoize';
7
8
  import pAll from 'p-all';
8
- import {createRequire} from 'node:module';
9
- const require = createRequire(import.meta.url);
10
- const {LruCache} = require('@digitalbazaar/lru-memoize');
11
9
 
12
10
  const {util: {BedrockError}} = bedrock;
13
11
 
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@bedrock/kms",
3
- "version": "10.3.0",
3
+ "version": "11.0.0",
4
4
  "type": "module",
5
5
  "description": "Key management for Bedrock applications",
6
6
  "main": "./lib/index.js",
7
+ "files": [
8
+ "lib/**/*.js"
9
+ ],
7
10
  "scripts": {
8
11
  "lint": "eslint ."
9
12
  },
@@ -23,30 +26,31 @@
23
26
  "url": "https://github.com/digitalbazaar/bedrock-kms/issues"
24
27
  },
25
28
  "engines": {
26
- "node": ">=14"
29
+ "node": ">=16"
27
30
  },
28
31
  "homepage": "https://github.com/digitalbazaar/bedrock-kms",
29
32
  "dependencies": {
30
- "@digitalbazaar/lru-memoize": "^2.0.0",
33
+ "@digitalbazaar/lru-memoize": "^3.0.0",
31
34
  "p-all": "^4.0.0"
32
35
  },
33
36
  "peerDependencies": {
34
- "@bedrock/core": "^6.0.0",
37
+ "@bedrock/core": "^6.0.1",
35
38
  "@bedrock/did-context": "^4.0.0",
36
- "@bedrock/did-io": "^8.0.0",
39
+ "@bedrock/did-io": "^9.0.1",
37
40
  "@bedrock/jsonld-document-loader": "^3.0.0",
38
41
  "@bedrock/mongodb": "^10.0.0",
39
42
  "@bedrock/package-manager": "^3.0.0",
40
43
  "@bedrock/security-context": "^7.0.0",
41
- "@bedrock/veres-one-context": "^14.0.0"
44
+ "@bedrock/veres-one-context": "^14.0.1"
42
45
  },
43
46
  "directories": {
44
47
  "lib": "./lib"
45
48
  },
46
49
  "devDependencies": {
47
- "eslint": "^7.32.0",
48
- "eslint-config-digitalbazaar": "^2.8.0",
49
- "eslint-plugin-jsdoc": "^37.9.7",
50
+ "eslint": "^8.18.0",
51
+ "eslint-config-digitalbazaar": "^4.0.1",
52
+ "eslint-plugin-jsdoc": "^39.3.3",
53
+ "eslint-plugin-unicorn": "^43.0.0",
50
54
  "jsdoc-to-markdown": "^7.1.1"
51
55
  }
52
56
  }
package/.eslintrc.cjs DELETED
@@ -1,12 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- parserOptions: {
4
- // this is required for dynamic import()
5
- ecmaVersion: 2020
6
- },
7
- env: {
8
- node: true
9
- },
10
- extends: ['digitalbazaar', 'digitalbazaar/jsdoc'],
11
- ignorePatterns: ['node_modules/']
12
- };
@@ -1,77 +0,0 @@
1
- name: Bedrock Node.js CI
2
-
3
- on: [push]
4
-
5
- jobs:
6
- lint:
7
- runs-on: ubuntu-latest
8
- timeout-minutes: 10
9
- strategy:
10
- matrix:
11
- node-version: [16.x]
12
- steps:
13
- - uses: actions/checkout@v2
14
- - name: Use Node.js ${{ matrix.node-version }}
15
- uses: actions/setup-node@v1
16
- with:
17
- node-version: ${{ matrix.node-version }}
18
- - run: npm install
19
- - name: Run eslint
20
- run: npm run lint
21
- test-node:
22
- needs: [lint]
23
- runs-on: ubuntu-latest
24
- timeout-minutes: 10
25
- services:
26
- mongodb:
27
- image: mongo:4.4
28
- ports:
29
- - 27017:27017
30
- strategy:
31
- matrix:
32
- node-version: [14.x, 16.x]
33
- steps:
34
- - uses: actions/checkout@v2
35
- - name: Use Node.js ${{ matrix.node-version }}
36
- uses: actions/setup-node@v1
37
- with:
38
- node-version: ${{ matrix.node-version }}
39
- - run: |
40
- npm install
41
- cd test
42
- npm install
43
- - name: Run test with Node.js ${{ matrix.node-version }}
44
- run: |
45
- cd test
46
- npm test
47
- coverage:
48
- needs: [test-node]
49
- runs-on: ubuntu-latest
50
- timeout-minutes: 10
51
- services:
52
- mongodb:
53
- image: mongo:4.4
54
- ports:
55
- - 27017:27017
56
- strategy:
57
- matrix:
58
- node-version: [16.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: Generate coverage report
70
- run: |
71
- cd test
72
- npm run coverage-ci
73
- - name: Upload coverage to Codecov
74
- uses: codecov/codecov-action@v2
75
- with:
76
- file: ./test/coverage/lcov.info
77
- fail_ci_if_error: true
package/CHANGELOG.md DELETED
@@ -1,249 +0,0 @@
1
- # bedrock-kms ChangeLog
2
-
3
- ## 10.3.0 - 2022-06-19
4
-
5
- ### Added
6
- - Cache KMS module APIs as imported.
7
-
8
- ## 10.2.0 - 2022-05-13
9
-
10
- ### Added
11
- - Expose `_disableClearCacheOnUpdate` for testing cache busting only; do not use in
12
- production.
13
-
14
- ## 10.1.0 - 2022-05-13
15
-
16
- ### Added
17
- - Add `fresh` option to `keystores.get()` API to allow for retrieving a fresh
18
- (not previously cached) keystore config record.
19
-
20
- ## 10.0.0 - 2022-04-29
21
-
22
- ### Changed
23
- - **BREAKING**: Update peer deps:
24
- - `@bedrock/core@6`.
25
- - `@bedrock/did-context@4`
26
- - `@bedrock/did-io@8`
27
- - `@bedrock/jsonld-document-loader@3`
28
- - `@bedrock/mongodb@10`
29
- - `@bedrock/package-manager@3`
30
- - `@bedrock/security-context@7`
31
- - `@bedrock/veres-one-context@14`.
32
-
33
- ## 9.0.0 - 2022-04-05
34
-
35
- ### Changed
36
- - **BREAKING**: Rename package to `@bedrock/kms`.
37
- - **BREAKING**: Convert to module (ESM).
38
- - **BREAKING**: Remove default export.
39
- - **BREAKING**: Require node 14.x.
40
-
41
- ## 8.3.1 - 2022-03-29
42
-
43
- ### Fixed
44
- - Use updated `bedrock-security-context` peer dependency.
45
-
46
- ## 8.3.0 - 2022-03-29
47
-
48
- ### Changed
49
- - Update peer deps:
50
- - `bedrock@4.5`
51
- - `bedrock-mongodb@8.5`.
52
- - `bedrock-did-context@2.1`
53
- - `bedrock-package-manager@1.2`
54
- - `bedrock-jsonld-document-loader@1.3`
55
- - `bedrock-veres-one-context@12.1`.
56
- - Update internals to use esm style and use `esm.js` to
57
- transpile to CommonJS.
58
-
59
- ## 8.2.0 - 2022-02-10
60
-
61
- ### Changed
62
- - Use `bedrock-did-io@6`.
63
-
64
- ## 8.1.0 - 2022-02-08
65
-
66
- ### Changed
67
- - Update peer dependency `bedrock-veres-one-context@12`.
68
-
69
- ## 8.0.0 - 2022-01-11
70
-
71
- ### Changed
72
- - **BREAKING**: Require bedrock-did-io@5. This change effectively pulls in
73
- the latest did-veres-one driver which ultimately uses zcap@7.
74
-
75
- ## 7.4.0 - 2021-12-17
76
-
77
- ### Changed
78
- - Replace `p-limit` with `p-all`.
79
-
80
- ## 7.3.0 - 2021-12-16
81
-
82
- ### Changed
83
- - Changed `getStorageUsage` to use `p-limit` for handling max concurrency.
84
-
85
- ## 7.2.0 - 2021-11-22
86
-
87
- ### Added
88
- - Add `aggregate` function option for `getStorageUsage` to allow custom
89
- aggregation of additional usage information. This is used, for example,
90
- by `bedrock-kms-http` to store zcap revocation storage usage.
91
-
92
- ### Fixed
93
- - Fixed bugs with `keystores.getStorageUsage()`.
94
-
95
- ## 7.1.0 - 2021-11-15
96
-
97
- ### Added
98
- - Added optional `explain` param to get more details about database performance.
99
- - Added database tests in order to check database performance.
100
-
101
- ### Changed
102
- - Exposed helper functions in order to properly test database calls.
103
-
104
- ## 7.0.1 - 2021-09-01
105
-
106
- ### Fixed
107
- - Fix typo in controller+referenceId index.
108
-
109
- ## 7.0.0 - 2021-07-22
110
-
111
- ### Added
112
- - Add `getStorageUsage` API. This function can be called with a meter ID,
113
- WebKMS module manager API and an optional abort signal. It will return the
114
- current storage usage for all keystores that use the identified meter.
115
-
116
- ### Changed
117
- - **BREAKING**: Database keystore collection now named `kms-keystore` to match
118
- modern naming convention. There is no expectation that old systems will
119
- be able to upgrade in place to this new version, rather existing systems
120
- that relied on bedrock-kms (typically via bedrock-kms-http) must transition
121
- to new systems running the new version.
122
-
123
- ### Removed
124
- - **BREAKING**: Removed deprecated `fields` option from `keystores.find` API.
125
- Use `options.projection` option instead.
126
-
127
- ## 6.0.0 - 2021-05-20
128
-
129
- ### Changed
130
- - **BREAKING**: Drop support for node 10.
131
- - **BREAKING**: Use `ed25519-signature-2020` signature suite. Operations must
132
- now be signed using the `Ed25519Signature2020` suite.
133
- - Remove unused `did-veres-one`.
134
- - Remove use of `jsonld-signatures`.
135
- - Remove `@digitalbazaar/did-io` and use `bedrock-did-io@2.0`.
136
- - Remove `did-method-key`.
137
- - Update dependencies to latest:
138
- - [bedrock-did-io@2.0](https://github.com/digitalbazaar/bedrock-did-io/blob/main/CHANGELOG.md),
139
- - [webkms-switch@5.0](https://github.com/digitalbazaar/webkms-switch/blob/main/CHANGELOG.md).
140
-
141
- ## 5.0.0 - 2021-03-11
142
-
143
- ### Fixed
144
- - **BREAKING**: Fix incorrectly configured MongoDB index on the `kmsKeystore`
145
- collection. If this software needs to be deployed along with an existing
146
- database, the index named `controller_1_config.referenceId_1` will need to
147
- be dropped manually. The index will be recreated automatically on Bedrock
148
- application startup.
149
-
150
- ## 4.0.1 - 2021-03-09
151
-
152
- ### Fixed
153
- - Remove obsolete `allowedHost` config.
154
-
155
- ## 4.0.0 - 2021-03-09
156
-
157
- ### Added
158
- - Keystore configurations may now include an optional `ipAllowList` array. If
159
- specified, the KMS system will only execute requests originating from IPs
160
- listed in `ipAllowList`. This applies to key operations for all keys in the
161
- keystore as well as modification of the configuration itself.
162
-
163
- ### Changed
164
- - **BREAKING**: Change data model and validation of keystore configs. Configs
165
- no longer include `invoker` or `delegator` properties.
166
-
167
- ## 3.1.0 - 2020-09-25
168
-
169
- ## Added
170
- - Add cache for public key records.
171
-
172
- ## 3.0.2 - 2020-07-09
173
-
174
- ## Fixed
175
- - Fix usage of MongoDB projection API.
176
-
177
- ## 3.0.1 - 2020-06-09
178
-
179
- ## Added
180
- - Add `delegator` and `invoker` as valid kms config properties.
181
-
182
- ## 3.0.0 - 2020-06-09
183
-
184
- ### Changed
185
- - **BREAKING**: Upgraded to `bedrock-mongodb` ^7.0.0.
186
- - Mongodb `update` is now `updateOne`.
187
- - Mongodb `find` no longer accepts fields.
188
-
189
- ### Added
190
- - `find` now throws in both options.projection and fields are set.
191
-
192
- ## 2.1.0 - 2020-05-15
193
-
194
- ### Changed
195
- - Add support for `did:v1` resolution.
196
- - Add dependency for `did-io`.
197
- - Add dependency for `did-veres-one`.
198
-
199
- ## 2.0.1 - 2020-05-06
200
-
201
- ### Fixed
202
- - Fix error handling in `keystore.update` API.
203
-
204
- ## 2.0.0 - 2020-04-02
205
-
206
- ### Changed
207
- - **BREAKING**: Use webkms-switch@2.
208
- - Remove unused peer deps.
209
-
210
- ## 1.4.0 - 2020-02-25
211
-
212
- ### Changed
213
- - Add dependency for `did-key-method`.
214
- - Add peer dependency for `bedrock-did-context`.
215
- - Add peer dependency for `bedrock-jsonld-document-loader`.
216
-
217
- ## 1.3.0 - 2020-02-14
218
-
219
- ### Changed
220
- - Use jsonld-signatures@5.
221
-
222
- ## 1.2.0 - 2020-02-07
223
-
224
- ### Added
225
- - Add support for `inspectCapabilityChain` handler in `validateOperation`. This
226
- handler can be used to check for revocations in a capability chain.
227
- - Handle reading DID key URLs (with `#`) in document loader.
228
-
229
- ## 1.1.0 - 2020-01-22
230
-
231
- ### Changed
232
- - Specify peer dep bedrock-security-context@3.
233
-
234
- ## 1.0.2 - 2020-01-22
235
-
236
- ### Fixed
237
- - Add missing jsonld-sigatures dep.
238
-
239
- ## 1.0.1 - 2019-12-20
240
-
241
- ### Fixed
242
- - Fixed typo in module import.
243
-
244
- ## 1.0.0 - 2019-12-20
245
-
246
- ### Added
247
- - Add core files.
248
-
249
- - See git history for changes previous to this release.
@@ -1,9 +0,0 @@
1
- {
2
- "env": {
3
- "mocha": true
4
- },
5
- "globals": {
6
- "assertNoError": true,
7
- "should": true
8
- }
9
- }
@@ -1,275 +0,0 @@
1
- /*!
2
- * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
3
- */
4
- import {keystores} from '@bedrock/kms';
5
-
6
- describe('keystores APIs', () => {
7
- describe('insert API', () => {
8
- it('throws error on missing config', async () => {
9
- let err;
10
- let result;
11
- try {
12
- result = await keystores.insert();
13
- } catch(e) {
14
- err = e;
15
- }
16
- should.not.exist(result);
17
- should.exist(err);
18
- err.message.should.contain('config (object) is required');
19
- });
20
- it('throws error on missing config.id', async () => {
21
- let err;
22
- let result;
23
- const config = {};
24
- try {
25
- result = await keystores.insert({config});
26
- } catch(e) {
27
- err = e;
28
- }
29
- should.not.exist(result);
30
- should.exist(err);
31
- err.message.should.contain('config.id (string) is required');
32
- });
33
- it('throws error on missing config.controller', async () => {
34
- let err;
35
- let result;
36
- const config = {
37
- id: 'https://example.com/keystores/foo',
38
- };
39
- try {
40
- result = await keystores.insert({config});
41
- } catch(e) {
42
- err = e;
43
- }
44
- should.not.exist(result);
45
- should.exist(err);
46
- err.message.should.contain('config.controller (string) is required');
47
- });
48
- it('throws error on missing config.kmsModule', async () => {
49
- let err;
50
- let result;
51
- const config = {
52
- id: 'https://example.com/keystores/foo',
53
- controller: 'bar',
54
- };
55
- try {
56
- result = await keystores.insert({config});
57
- } catch(e) {
58
- err = e;
59
- }
60
- should.not.exist(result);
61
- should.exist(err);
62
- err.message.should.contain('config.kmsModule (string) is required');
63
- });
64
- it('throws error on missing config.sequence', async () => {
65
- let err;
66
- let result;
67
- const config = {
68
- id: 'https://example.com/keystores/foo',
69
- controller: 'bar',
70
- kmsModule: 'ssm-v1'
71
- };
72
- try {
73
- result = await keystores.insert({config});
74
- } catch(e) {
75
- err = e;
76
- }
77
- should.not.exist(result);
78
- should.exist(err);
79
- err.message.should.contain('Keystore config sequence must be "0".');
80
- });
81
- it('throws error on negative config.sequence', async () => {
82
- let err;
83
- let result;
84
- const config = {
85
- id: 'https://example.com/keystores/foo',
86
- controller: 'bar',
87
- kmsModule: 'ssm-v1',
88
- sequence: -1,
89
- };
90
- try {
91
- result = await keystores.insert({config});
92
- } catch(e) {
93
- err = e;
94
- }
95
- should.not.exist(result);
96
- should.exist(err);
97
- err.message.should.contain('Keystore config sequence must be "0".');
98
- });
99
- it('throws error on float config.sequence', async () => {
100
- let err;
101
- let result;
102
- const config = {
103
- id: 'https://example.com/keystores/foo',
104
- controller: 'bar',
105
- kmsModule: 'ssm-v1',
106
- sequence: 1.1,
107
- };
108
- try {
109
- result = await keystores.insert({config});
110
- } catch(e) {
111
- err = e;
112
- }
113
- should.not.exist(result);
114
- should.exist(err);
115
- err.message.should.contain('Keystore config sequence must be "0".');
116
- });
117
- it('throws error on non-zero config.sequence', async () => {
118
- let err;
119
- let result;
120
- const config = {
121
- id: 'https://example.com/keystores/foo',
122
- controller: 'bar',
123
- kmsModule: 'ssm-v1',
124
- sequence: 1,
125
- };
126
- try {
127
- result = await keystores.insert({config});
128
- } catch(e) {
129
- err = e;
130
- }
131
- should.not.exist(result);
132
- should.exist(err);
133
- err.message.should.contain('Keystore config sequence must be "0".');
134
- });
135
- it('throws error on string config.sequence', async () => {
136
- let err;
137
- let result;
138
- const config = {
139
- id: 'https://example.com/keystores/foo',
140
- controller: 'bar',
141
- kmsModule: 'ssm-v1',
142
- sequence: '0',
143
- };
144
- try {
145
- result = await keystores.insert({config});
146
- } catch(e) {
147
- err = e;
148
- }
149
- should.not.exist(result);
150
- should.exist(err);
151
- err.message.should.contain('Keystore config sequence must be "0".');
152
- });
153
- it('throws error on non-string config.id', async () => {
154
- let err;
155
- let result;
156
- const config = {
157
- id: 1,
158
- controller: 'bar',
159
- kmsModule: 'ssm-v1',
160
- sequence: '0',
161
- };
162
- try {
163
- result = await keystores.insert({config});
164
- } catch(e) {
165
- err = e;
166
- }
167
- should.not.exist(result);
168
- should.exist(err);
169
- err.message.should.contain('config.id (string) is required');
170
- });
171
- it('throws error on non-string config.controller', async () => {
172
- let err;
173
- let result;
174
- const config = {
175
- id: 'https://example.com/keystores/foo',
176
- controller: 1,
177
- kmsModule: 'ssm-v1',
178
- sequence: '0',
179
- };
180
- try {
181
- result = await keystores.insert({config});
182
- } catch(e) {
183
- err = e;
184
- }
185
- should.not.exist(result);
186
- should.exist(err);
187
- err.message.should.contain('config.controller (string) is required');
188
- });
189
- it('successfully creates a keystore', async () => {
190
- let err;
191
- let result;
192
- const config = {
193
- id: 'https://example.com/keystores/foo',
194
- controller: 'bar',
195
- kmsModule: 'ssm-v1',
196
- sequence: 0,
197
- };
198
- try {
199
- result = await keystores.insert({config});
200
- } catch(e) {
201
- err = e;
202
- }
203
- assertNoError(err);
204
- should.exist(result);
205
- result.should.be.an('object');
206
- result.should.have.property('config');
207
- result.config.should.eql(config);
208
- });
209
- it('throws DuplicateError on duplicate keystore config', async () => {
210
- let err;
211
- let result;
212
- const config = {
213
- id:
214
- 'https://example.com/keystores/fbea027c-ecc4-4562-b3dc-392db7b7c7c6',
215
- controller: 'bar',
216
- kmsModule: 'ssm-v1',
217
- sequence: 0,
218
- };
219
- try {
220
- result = await keystores.insert({config});
221
- } catch(e) {
222
- err = e;
223
- }
224
- assertNoError(err);
225
- should.exist(result);
226
- result = undefined;
227
- err = undefined;
228
- try {
229
- result = await keystores.insert({config});
230
- } catch(e) {
231
- err = e;
232
- }
233
- should.exist(err);
234
- err.name.should.equal('DuplicateError');
235
- });
236
- it('throws DuplicateError on config with same controller and referenceId',
237
- async () => {
238
- // configs have unique IDs, but the same controller and referenceId
239
- let err;
240
- let result;
241
- const keystoreConfig1 = {
242
- id: 'https://example.com/keystores/fbea027c',
243
- controller: 'bar',
244
- kmsModule: 'ssm-v1',
245
- referenceId: 'urn:uuid:72b89236-7bb7-4d00-8930-9c74c4a7a4a8',
246
- sequence: 0,
247
- };
248
- try {
249
- result = await keystores.insert({config: keystoreConfig1});
250
- } catch(e) {
251
- err = e;
252
- }
253
- assertNoError(err);
254
- should.exist(result);
255
-
256
- const keystoreConfig2 = {
257
- id: 'https://example.com/keystores/4f398f8f',
258
- controller: 'bar',
259
- kmsModule: 'ssm-v1',
260
- referenceId: 'urn:uuid:72b89236-7bb7-4d00-8930-9c74c4a7a4a8',
261
- sequence: 0,
262
- };
263
-
264
- result = undefined;
265
- err = undefined;
266
- try {
267
- result = await keystores.insert({config: keystoreConfig2});
268
- } catch(e) {
269
- err = e;
270
- }
271
- should.exist(err);
272
- err.name.should.equal('DuplicateError');
273
- });
274
- }); // end insert API
275
- }); // end keystore APIs