@bedrock/kms-http 13.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/.eslintrc.cjs ADDED
@@ -0,0 +1,12 @@
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
+ };
@@ -0,0 +1,103 @@
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: [14.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.2
28
+ ports:
29
+ - 27017:27017
30
+ strategy:
31
+ matrix:
32
+ node-version: [14.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 run test-node
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
73
+ coverage:
74
+ needs: [test-karma]
75
+ runs-on: ubuntu-latest
76
+ timeout-minutes: 10
77
+ services:
78
+ mongodb:
79
+ image: mongo:4.2
80
+ ports:
81
+ - 27017:27017
82
+ strategy:
83
+ matrix:
84
+ node-version: [14.x]
85
+ steps:
86
+ - uses: actions/checkout@v2
87
+ - name: Use Node.js ${{ matrix.node-version }}
88
+ uses: actions/setup-node@v1
89
+ with:
90
+ node-version: ${{ matrix.node-version }}
91
+ - run: |
92
+ npm install
93
+ cd test
94
+ npm install
95
+ - name: Generate coverage report
96
+ run: |
97
+ cd test
98
+ npm run coverage-ci
99
+ - name: Upload coverage to Codecov
100
+ uses: codecov/codecov-action@v2
101
+ with:
102
+ file: ./test/coverage/lcov.info
103
+ fail_ci_if_error: true
package/CHANGELOG.md ADDED
@@ -0,0 +1,332 @@
1
+ # bedrock-kms-http ChangeLog
2
+
3
+ ## 13.0.0 - 2022-04-05
4
+
5
+ ### Changed
6
+ - **BREAKING**: Rename package to `@bedrock/kms-http`.
7
+ - **BREAKING**: Convert to module (ESM).
8
+ - **BREAKING**: Remove default export.
9
+ - **BREAKING**: Require node 14.x.
10
+
11
+ ## 12.1.0 - 2022-03-29
12
+
13
+ ### Changed
14
+ - Update peer deps:
15
+ - `bedrock@4.5`
16
+ - `bedrock-express@6.4.1`
17
+ - `bedrock-kms@8.3.0`
18
+ - `bedrock-validation@5.6.3`
19
+ - `bedrock-zcap-storage@5.2`.
20
+ - Update internals to use esm style and use `esm.js` to
21
+ transpile to CommonJS.
22
+
23
+ ### Removed
24
+ - Remove unused peer deps:
25
+ - `bedrock-server`
26
+ - `bedrock-jsonld-document-loader`
27
+ - `bedrock-mongodb`.
28
+
29
+ ## 12.0.1 - 2022-03-03
30
+
31
+ ### Fixed
32
+ - Use `@digitalbazaar/webkms-switch@10` to be consistent with
33
+ `@digitalbazaar/ezcap-express@6` and other breaking changes
34
+ in this major version.
35
+
36
+ ## 12.0.0 - 2022-03-01
37
+
38
+ ### Changed
39
+ - **BREAKING**: Move zcap revocations to `/zcaps/revocations` to better
40
+ future proof.
41
+ - **BREAKING**: Use `@digitalbazaar/ezcap-express@6`.
42
+ - **BREAKING**: This version is compatible with
43
+ `@digitalbazaar/webkms-client@10`.
44
+
45
+ ## 11.3.1 - 2022-02-12
46
+
47
+ ### Changed
48
+ - Improve internal implementation of JSON schema validators.
49
+
50
+ ## 11.3.0 - 2022-02-10
51
+
52
+ ### Changed
53
+ - Use `bedrock-validation@5.4` with better schema compilation.
54
+
55
+ ## 11.2.0 - 2022-02-08
56
+
57
+ ### Added
58
+ - Allow KMS operations to be configured via config system and
59
+ set defaults to allow long-lived zcaps.
60
+
61
+ ## 11.1.1 - 2022-01-20
62
+
63
+ ### Fixed
64
+ - Do not expose details from errors that aren't marked public.
65
+
66
+ ## 11.1.0 - 2022-01-14
67
+
68
+ ### Added
69
+ - Use webkms-switch@9.1 to enable passing `zcapInvocation` to KMS
70
+ modules. This enables KMS modules to disallow key operations based
71
+ on zcap invocation information, if desired.
72
+
73
+ ## 11.0.0 - 2022-01-11
74
+
75
+ ### Changed
76
+ - **BREAKING**: Use ezcap-express@5 and webkms-switch@9. These changes
77
+ include major breaking simplifications to ZCAP (zcap@7).
78
+
79
+ ## 10.2.0 - 2021-12-11
80
+
81
+ ### Added
82
+ - Add tests and update `README.md`.
83
+
84
+ ### Changed
85
+ - Require ezcap-express 4.3.x.
86
+
87
+ ## 10.1.3 - 2021-12-10
88
+
89
+ ### Fixed
90
+ - Combined duplicate error code paths to simplify; the relevant code ensures
91
+ that when a client sends a keystore config with an ID that does not match
92
+ the config ID in the request URL, an exception will be thrown.
93
+
94
+ ## 10.1.2 - 2021-12-09
95
+
96
+ ### Fixed
97
+ - Load keystore config for a particular request only once to create more
98
+ consistent behavior. Multiple retrievals of the same keystore config during
99
+ the lifetime of a request may result in loading different configs without
100
+ this patch. This patch makes behavior more consistent by reusing the same
101
+ loaded keystore config for the entire request. Note that there is a change
102
+ to an assertion in a test on a returned error, however, that error was
103
+ not going to be consistent in previous versions regardless. This fix makes
104
+ it more consistent.
105
+
106
+ ## 10.1.1 - 2021-11-24
107
+
108
+ ### Fixed
109
+ - Fix bug in meter usage aggregation.
110
+
111
+ ## 10.1.0 - 2021-11-23
112
+
113
+ ### Added
114
+ - Do not allow zcap revocations to be stored if the meter associated with
115
+ a keystore has been disabled. Storage of zcap revocations is permitted if
116
+ there is no available storage to prevent potential security issues, however,
117
+ the meter MUST not be disabled to make use of this feature. Very robust
118
+ rate limiting MUST be applied to the revocation submission endpoint in
119
+ a deployment to avoid significant storage overflow.
120
+
121
+ ## 10.0.0 - 2021-10-07
122
+
123
+ ### Changed
124
+ - **BREAKING**: Use `webkms-switch@8` which changes the way key IDs are
125
+ generated. See the [changelog](https://github.com/digitalbazaar/webkms-switch/blob/main/CHANGELOG.md).
126
+
127
+ ## 9.0.0 - 2021-09-02
128
+
129
+ ### Changed
130
+ - **BREAKING**: Use bedrock-meter-usage-reporter@4. This new version now
131
+ requires bedrock-app-identity to configure the identity for webkms
132
+ applications.
133
+
134
+ ## 8.0.1 - 2021-09-01
135
+
136
+ ### Fixed
137
+ - Do not allow meter ID to be changed when updating keystore config as
138
+ the keystore controller has insufficient authority to do so. This
139
+ may be enabled in the future by requiring the root zcap controller
140
+ to be the meter controller when changing the meter ID.
141
+
142
+ ## 8.0.0 - 2021-08-31
143
+
144
+ ### Changed
145
+ - **BREAKING**: Use bedrock-meter-usage-reporter@3. This new version simplifies
146
+ meter usage zcap management by eliminating the need for a delegated zcap
147
+ to allow reporting meter usage. Instead, the KMS service is the root
148
+ controller for the meter usage endpoint for any meter that is specifically
149
+ created and coupled to it.
150
+ - **BREAKING**: Creating a keystore now requires sending only the full URL
151
+ `meterId` for a meter, not a meter capability. The meter will be presumed
152
+ to be coupled to the KMS service -- and this will be confirmed via a call
153
+ to retrieve the meter information.
154
+
155
+ ## 7.1.0 - 2021-08-26
156
+
157
+ ### Changed
158
+ - Use ezcap-express@4.2 to provide zcap revocation authorization implementation.
159
+ Remove dependencies that are no longer needed because of this upgrade.
160
+
161
+ ## 7.0.1 - 2021-08-18
162
+
163
+ ### Fixed
164
+ - Ensure promise settles before returning key description.
165
+
166
+ ## 7.0.0 - 2021-08-17
167
+
168
+ ### Changed
169
+ - **BREAKING**: Updated to work with bedrock-meter-usage-reporter 2.x. This
170
+ new version enables applications to bundle the webkms service with other
171
+ services instead of requiring a microservices deployment architecture.
172
+
173
+ ## 6.1.0 - 2021-07-23
174
+
175
+ ### Changed
176
+ - Update peer dependencies; use bedrock-did-io@4.
177
+
178
+ ## 6.0.0 - 2021-07-22
179
+
180
+ ### Added
181
+ - **BREAKING** - Add storage and operation metering support. A meter capability
182
+ must be provided to create a new keystore. This capability will be used to
183
+ report keystore storage and operation usage to the associated meter.
184
+
185
+ ### Changed
186
+ - **BREAKING**: Require `expires` to be set on delegated zcaps.
187
+ - **BREAKING**: Use updated bedrock-kms.
188
+ - **BREAKING**: Simplify zcap revocation model. Now any party that has been delegated a zcap can
189
+ send it to a revocation address: `<keystoreId>/revocations/<zcap ID>` without needing to have an
190
+ additional zcap delegated to that party. The party must invoke the root zcap for that endpoint,
191
+ which will be dynamically generated and use the delegator of the zcap as the controller, i.e., the
192
+ delegator must invoke this root zcap to revoke the zcap they delegated.
193
+
194
+ ### Removed
195
+ - **BREAKING**: Remove `did-io`, `did-method-key`, and
196
+ `did-veres-one` from deps and use `bedrock-did-io`.
197
+ - **BREAKING**: Remove query endpoint. It was unused and a new design would need to
198
+ be introduced in the future that properly handles authz.
199
+
200
+ ## 5.0.0 - 2021-05-20
201
+
202
+ ### Changed
203
+ - **BREAKING**: Remove `ed25519-signature-2018` signature suite and use
204
+ `ed25519-signature-2020`.
205
+ - Remove `did-io`, `did-method-key`, and `did-veres-one` from deps and use
206
+ `bedrock-did-io`.
207
+ - Update peerDeps and deps
208
+ - [@digitalbazaar/ed25519-signature-2020@2.1.0](https://github.com/digitalbazaar/ed25519-signature-2020/blob/main/CHANGELOG.md)
209
+ - [@digitalbazaar/ezcap-express@3.0.1](https://github.com/digitalbazaar/ezcap-express/blob/main/CHANGELOG.md)
210
+ - [@digitalbazaar/zcapld@4.0.0](https://github.com/digitalbazaar/zcapld/blob/main/CHANGELOG.md)
211
+ - [http-signature-zcap-verify@7.1.0](https://github.com/digitalbazaar/http-signature-zcap-verify/blob/main/CHANGELOG.md)
212
+ - [jsonld-signatures@9.0.2](https://github.com/digitalbazaar/jsonld-signatures/blob/master/CHANGELOG.md)
213
+ - [webkms-switch@5.0.0](https://github.com/digitalbazaar/webkms-switch/blob/main/CHANGELOG.md)
214
+ - [bedrock-kms@6.0.0](https://github.com/digitalbazaar/bedrock-kms/blob/master/CHANGELOG.md)
215
+ - [bedrock-did-io@2.0.0](https://github.com/digitalbazaar/bedrock-did-io/blob/main/CHANGELOG.md)
216
+ - Update test deps
217
+
218
+ ### Added
219
+ - Keystore configurations may now include an optional `ipAllowList` array. If
220
+ specified, the KMS system will only execute requests originating from IPs
221
+ listed in `ipAllowList`. This applies to key operations for all keys in the
222
+ keystore as well as modification of the configuration itself.
223
+
224
+ ## 4.0.0 - 2021-03-02
225
+
226
+ ### Added
227
+ - **BREAKING**: Implement ZCAP authz on the keystore config update API.
228
+
229
+ ### Changed
230
+ - **BREAKING**: Drop Node 10.x support.
231
+ - **BREAKING**: Change data model and validation of keystore configs. Configs
232
+ no longer include `invoker` or `delegator` properties.
233
+
234
+ ## 3.2.0 - 2021-02-10
235
+
236
+ ### Added
237
+ - Added validators to `keystore`, `keystores`, `authorizations`, and
238
+ `zcaps` endpoints.
239
+ - Improve test coverage.
240
+
241
+ ## 3.1.0 - 2021-01-12
242
+
243
+ ### Changed
244
+ - Update bedrock-account@5.0
245
+
246
+ ## 3.0.0 - 2020-09-22
247
+
248
+ ### Changed
249
+ - **BREAKING**: Do not look up zcaps in authorizations collection;
250
+ full zcap chain must be submitted. A future feature may involve
251
+ ensuring that zcaps for certain keys are present in the
252
+ authorizations collection as an added security measure, but
253
+ those zcaps would still need to be submitted at invocation.
254
+
255
+ ## 2.3.0 - 2020-06-30
256
+
257
+ ### Changed
258
+ - Update peerDependencies to include bedrock-account@4.
259
+ - Update test deps.
260
+ - Update CI workflow.
261
+
262
+ ## 2.2.0 - 2020-06-19
263
+
264
+ ### Added
265
+ - Improve test coverage.
266
+
267
+ ### Changed
268
+ - Update peer deps.
269
+ - Improve error handling in `_verifyHost` helper.
270
+
271
+ ## 2.1.0 - 2020-05-15
272
+
273
+ ### Added
274
+ - Add CORS support for key ops.
275
+
276
+ ### Changed
277
+ - Use bedrock-kms@2.1.0.
278
+
279
+ ## 2.0.0 - 2020-04-02
280
+
281
+ ### Added
282
+ - Create expectedRootCapability for revocations.
283
+
284
+ ### Changed
285
+ - **BREAKING**: Use webkms-switch@2.
286
+ - **BREAKING**: Use http-signature-zcap-verify@3.
287
+
288
+ ## 1.2.1 - 2020-02-27
289
+
290
+ ### Fixed
291
+ - Fix syntax error/typo.
292
+
293
+ ## 1.2.0 - 2020-02-26
294
+
295
+ ### Added
296
+ - Revocations API.
297
+
298
+ ### Changed
299
+ - Use jsonld-signatures@5.
300
+
301
+ ## 1.1.3 - 2020-01-22
302
+
303
+ ### Fixed
304
+ - Add missing jsonld-sigatures dep.
305
+
306
+ ## 1.1.2 - 2020-01-12
307
+
308
+ ### Fixed
309
+ - Ensure local zcap storage is checked for invoked zcaps.
310
+
311
+ ## 1.1.1 - 2020-01-12
312
+
313
+ ### Fixed
314
+ - Ensure local zcap storage is checked for parent zcaps.
315
+
316
+ ## 1.1.0 - 2020-01-11
317
+
318
+ ### Added
319
+ - Support delegation by non-root controllers provided that `delegator`
320
+ is set in the zcap.
321
+
322
+ ## 1.0.1 - 2019-12-20
323
+
324
+ ### Fixed
325
+ - Fixed typo in module import.
326
+
327
+ ## 1.0.0 - 2019-12-20
328
+
329
+ ### Added
330
+ - Added core files.
331
+
332
+ - See git history for changes.
package/LICENSE.md ADDED
@@ -0,0 +1,115 @@
1
+ Bedrock Non-Commercial License v1.0
2
+ ===================================
3
+
4
+ Copyright (c) 2011-2021 Digital Bazaar, Inc.
5
+ All rights reserved.
6
+
7
+ Summary
8
+ =======
9
+
10
+ This license allows the licensee to use Bedrock and its software modules
11
+ for non-commercial purposes such as self-study, research, personal
12
+ projects, or for evaluation purposes. If the licensee uses Bedrock
13
+ directly or indirectly to generate revenue, or to provide products or
14
+ services to more than 500 people (users), the licensee must immediately
15
+ obtain a non-profit or commercial license.
16
+
17
+ Examples
18
+ ========
19
+
20
+ These are examples of cases that are allowed by this license:
21
+
22
+ * The licensee is an individual that creates Bedrock-dependent software for
23
+ personal use only.
24
+ * The licensee is an individual or group of students/researchers that uses
25
+ Bedrock to experiment with an idea for a non-commercial project.
26
+ * The licensee is a startup company that prototypes a Bedrock-dependent
27
+ product before they have cash flow and will be testing the prototype
28
+ software with less than 500 users. The service will not generate revenue
29
+ of any kind.
30
+ * The licensee is a for-profit organization that creates a product or
31
+ service that is used by less than 500 users and is built with or
32
+ integrates with Bedrock. The service must be exclusively provided for free
33
+ and no parent, subsidiary, agent, or affiliate organization may profit
34
+ from its use.
35
+
36
+ These cases require a non-profit or commercial license:
37
+
38
+ * The licensee is a non-profit that receives funding to create and/or run a
39
+ Bedrock-dependent service.
40
+ * The licensee is a startup company with Bedrock-dependent software that is
41
+ funded by another organization.
42
+ * The licensee is a startup company that is going into production with
43
+ Bedrock-dependent software.
44
+ * The licensee has more than 500 users using a Bedrock-dependent service
45
+ either directly or indirectly.
46
+ * The licensee is a medium to large organization that builds or integrates a
47
+ commercial product or service with Bedrock.
48
+
49
+ THE LICENSE
50
+ ===========
51
+
52
+ This section and all subsequent sections of this document constitute the
53
+ agreement between the licensee and Digital Bazaar, Inc.
54
+
55
+ DEFINITIONS
56
+ ===========
57
+
58
+ * Product - The Bedrock software and any modules associated with Bedrock
59
+ where Digital Bazaar, Inc. owns the copyright.
60
+
61
+ CONDITIONS
62
+ ==========
63
+
64
+ Redistribution and use in source and binary forms, with or without
65
+ modification, are permitted for NON-COMMERCIAL PURPOSES as long as the
66
+ following conditions are met:
67
+
68
+ 1. Any use of the Product must not generate revenue for the licensee or
69
+ any parent, subsidiary, agent, or affiliate of the licensee. Use of
70
+ Product includes, but is not limited to, interacting with any of the
71
+ licensee's Product-dependent products or services over a network.
72
+
73
+ 2. The aggregate number of individual people (users) of the licensee's
74
+ products or services that use Product must be less than 500.
75
+
76
+ 3. Redistributions of source code must retain the above copyright notice
77
+ intact, this list of conditions and the following disclaimer.
78
+
79
+ 4. Redistributions in binary form must reproduce the above copyright
80
+ notice, this license and the following disclaimer in the documentation and
81
+ on a web page available via interactive use and/or other materials
82
+ provided with the distribution.
83
+
84
+ 5. Neither the name of the copyright holder, the names of its
85
+ contributors, nor any trademarks held by the copyright holder may be used
86
+ to endorse or promote products or services built using the Product without
87
+ specific prior written permission.
88
+
89
+ 6. Any modifications are clearly outlined in release documentation and are
90
+ specifically mentioned as not being a part of an official Product release.
91
+ No additional restrictions to this license may be made when distributing
92
+ modifications.
93
+
94
+ 7. For the avoidance of doubt, this license prohibits sublicensing of the
95
+ Product.
96
+
97
+ 8. Any breach of this license by licensee must be resolved within 30 days.
98
+ Failure to do so results in the termination of this license.
99
+
100
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
101
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
102
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
103
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
104
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
105
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
106
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
107
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
108
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
109
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
110
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
111
+
112
+ To obtain a non-profit or commercial license for Product, please contact
113
+ Digital Bazaar, Inc. at the following email address:
114
+
115
+ Digital Bazaar <support@digitalbazaar.com>