@bedrock/kms 9.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 +12 -0
- package/.github/workflows/main.yml +77 -0
- package/CHANGELOG.md +219 -0
- package/LICENSE.md +115 -0
- package/README.md +2 -0
- package/lib/BedrockKmsModuleManager.js +16 -0
- package/lib/config.js +16 -0
- package/lib/index.js +34 -0
- package/lib/keystores.js +330 -0
- package/package.json +52 -0
- package/test/mocha/.eslintrc +9 -0
- package/test/mocha/10-keystores-insert-api.js +275 -0
- package/test/mocha/11-keystores-get-api.js +79 -0
- package/test/mocha/12-keystores-find-api.js +127 -0
- package/test/mocha/13-keystores-update-api.js +163 -0
- package/test/mocha/14-keystores-getStorageUsage-api.js +119 -0
- package/test/mocha/20-key-operations.js +241 -0
- package/test/mocha/30-bulk-operations.js +111 -0
- package/test/mocha/40-database.js +95 -0
- package/test/mocha/50-document-loader.js +40 -0
- package/test/mocha/cryptoLd.js +22 -0
- package/test/mocha/helpers.js +46 -0
- package/test/mocha/mock.data.js +62 -0
- package/test/package.json +49 -0
- package/test/test.config.js +17 -0
- package/test/test.js +9 -0
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
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 test
|
|
47
|
+
coverage:
|
|
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: 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
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# bedrock-kms ChangeLog
|
|
2
|
+
|
|
3
|
+
## 9.0.0 - 2022-04-05
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
- **BREAKING**: Rename package to `@bedrock/kms`.
|
|
7
|
+
- **BREAKING**: Convert to module (ESM).
|
|
8
|
+
- **BREAKING**: Remove default export.
|
|
9
|
+
- **BREAKING**: Require node 14.x.
|
|
10
|
+
|
|
11
|
+
## 8.3.1 - 2022-03-29
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- Use updated `bedrock-security-context` peer dependency.
|
|
15
|
+
|
|
16
|
+
## 8.3.0 - 2022-03-29
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- Update peer deps:
|
|
20
|
+
- `bedrock@4.5`
|
|
21
|
+
- `bedrock-mongodb@8.5`.
|
|
22
|
+
- `bedrock-did-context@2.1`
|
|
23
|
+
- `bedrock-package-manager@1.2`
|
|
24
|
+
- `bedrock-jsonld-document-loader@1.3`
|
|
25
|
+
- `bedrock-veres-one-context@12.1`.
|
|
26
|
+
- Update internals to use esm style and use `esm.js` to
|
|
27
|
+
transpile to CommonJS.
|
|
28
|
+
|
|
29
|
+
## 8.2.0 - 2022-02-10
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
- Use `bedrock-did-io@6`.
|
|
33
|
+
|
|
34
|
+
## 8.1.0 - 2022-02-08
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
- Update peer dependency `bedrock-veres-one-context@12`.
|
|
38
|
+
|
|
39
|
+
## 8.0.0 - 2022-01-11
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
- **BREAKING**: Require bedrock-did-io@5. This change effectively pulls in
|
|
43
|
+
the latest did-veres-one driver which ultimately uses zcap@7.
|
|
44
|
+
|
|
45
|
+
## 7.4.0 - 2021-12-17
|
|
46
|
+
|
|
47
|
+
### Changed
|
|
48
|
+
- Replace `p-limit` with `p-all`.
|
|
49
|
+
|
|
50
|
+
## 7.3.0 - 2021-12-16
|
|
51
|
+
|
|
52
|
+
### Changed
|
|
53
|
+
- Changed `getStorageUsage` to use `p-limit` for handling max concurrency.
|
|
54
|
+
|
|
55
|
+
## 7.2.0 - 2021-11-22
|
|
56
|
+
|
|
57
|
+
### Added
|
|
58
|
+
- Add `aggregate` function option for `getStorageUsage` to allow custom
|
|
59
|
+
aggregation of additional usage information. This is used, for example,
|
|
60
|
+
by `bedrock-kms-http` to store zcap revocation storage usage.
|
|
61
|
+
|
|
62
|
+
### Fixed
|
|
63
|
+
- Fixed bugs with `keystores.getStorageUsage()`.
|
|
64
|
+
|
|
65
|
+
## 7.1.0 - 2021-11-15
|
|
66
|
+
|
|
67
|
+
### Added
|
|
68
|
+
- Added optional `explain` param to get more details about database performance.
|
|
69
|
+
- Added database tests in order to check database performance.
|
|
70
|
+
|
|
71
|
+
### Changed
|
|
72
|
+
- Exposed helper functions in order to properly test database calls.
|
|
73
|
+
|
|
74
|
+
## 7.0.1 - 2021-09-01
|
|
75
|
+
|
|
76
|
+
### Fixed
|
|
77
|
+
- Fix typo in controller+referenceId index.
|
|
78
|
+
|
|
79
|
+
## 7.0.0 - 2021-07-22
|
|
80
|
+
|
|
81
|
+
### Added
|
|
82
|
+
- Add `getStorageUsage` API. This function can be called with a meter ID,
|
|
83
|
+
WebKMS module manager API and an optional abort signal. It will return the
|
|
84
|
+
current storage usage for all keystores that use the identified meter.
|
|
85
|
+
|
|
86
|
+
### Changed
|
|
87
|
+
- **BREAKING**: Database keystore collection now named `kms-keystore` to match
|
|
88
|
+
modern naming convention. There is no expectation that old systems will
|
|
89
|
+
be able to upgrade in place to this new version, rather existing systems
|
|
90
|
+
that relied on bedrock-kms (typically via bedrock-kms-http) must transition
|
|
91
|
+
to new systems running the new version.
|
|
92
|
+
|
|
93
|
+
### Removed
|
|
94
|
+
- **BREAKING**: Removed deprecated `fields` option from `keystores.find` API.
|
|
95
|
+
Use `options.projection` option instead.
|
|
96
|
+
|
|
97
|
+
## 6.0.0 - 2021-05-20
|
|
98
|
+
|
|
99
|
+
### Changed
|
|
100
|
+
- **BREAKING**: Drop support for node 10.
|
|
101
|
+
- **BREAKING**: Use `ed25519-signature-2020` signature suite. Operations must
|
|
102
|
+
now be signed using the `Ed25519Signature2020` suite.
|
|
103
|
+
- Remove unused `did-veres-one`.
|
|
104
|
+
- Remove use of `jsonld-signatures`.
|
|
105
|
+
- Remove `@digitalbazaar/did-io` and use `bedrock-did-io@2.0`.
|
|
106
|
+
- Remove `did-method-key`.
|
|
107
|
+
- Update dependencies to latest:
|
|
108
|
+
- [bedrock-did-io@2.0](https://github.com/digitalbazaar/bedrock-did-io/blob/main/CHANGELOG.md),
|
|
109
|
+
- [webkms-switch@5.0](https://github.com/digitalbazaar/webkms-switch/blob/main/CHANGELOG.md).
|
|
110
|
+
|
|
111
|
+
## 5.0.0 - 2021-03-11
|
|
112
|
+
|
|
113
|
+
### Fixed
|
|
114
|
+
- **BREAKING**: Fix incorrectly configured MongoDB index on the `kmsKeystore`
|
|
115
|
+
collection. If this software needs to be deployed along with an existing
|
|
116
|
+
database, the index named `controller_1_config.referenceId_1` will need to
|
|
117
|
+
be dropped manually. The index will be recreated automatically on Bedrock
|
|
118
|
+
application startup.
|
|
119
|
+
|
|
120
|
+
## 4.0.1 - 2021-03-09
|
|
121
|
+
|
|
122
|
+
### Fixed
|
|
123
|
+
- Remove obsolete `allowedHost` config.
|
|
124
|
+
|
|
125
|
+
## 4.0.0 - 2021-03-09
|
|
126
|
+
|
|
127
|
+
### Added
|
|
128
|
+
- Keystore configurations may now include an optional `ipAllowList` array. If
|
|
129
|
+
specified, the KMS system will only execute requests originating from IPs
|
|
130
|
+
listed in `ipAllowList`. This applies to key operations for all keys in the
|
|
131
|
+
keystore as well as modification of the configuration itself.
|
|
132
|
+
|
|
133
|
+
### Changed
|
|
134
|
+
- **BREAKING**: Change data model and validation of keystore configs. Configs
|
|
135
|
+
no longer include `invoker` or `delegator` properties.
|
|
136
|
+
|
|
137
|
+
## 3.1.0 - 2020-09-25
|
|
138
|
+
|
|
139
|
+
## Added
|
|
140
|
+
- Add cache for public key records.
|
|
141
|
+
|
|
142
|
+
## 3.0.2 - 2020-07-09
|
|
143
|
+
|
|
144
|
+
## Fixed
|
|
145
|
+
- Fix usage of MongoDB projection API.
|
|
146
|
+
|
|
147
|
+
## 3.0.1 - 2020-06-09
|
|
148
|
+
|
|
149
|
+
## Added
|
|
150
|
+
- Add `delegator` and `invoker` as valid kms config properties.
|
|
151
|
+
|
|
152
|
+
## 3.0.0 - 2020-06-09
|
|
153
|
+
|
|
154
|
+
### Changed
|
|
155
|
+
- **BREAKING**: Upgraded to `bedrock-mongodb` ^7.0.0.
|
|
156
|
+
- Mongodb `update` is now `updateOne`.
|
|
157
|
+
- Mongodb `find` no longer accepts fields.
|
|
158
|
+
|
|
159
|
+
### Added
|
|
160
|
+
- `find` now throws in both options.projection and fields are set.
|
|
161
|
+
|
|
162
|
+
## 2.1.0 - 2020-05-15
|
|
163
|
+
|
|
164
|
+
### Changed
|
|
165
|
+
- Add support for `did:v1` resolution.
|
|
166
|
+
- Add dependency for `did-io`.
|
|
167
|
+
- Add dependency for `did-veres-one`.
|
|
168
|
+
|
|
169
|
+
## 2.0.1 - 2020-05-06
|
|
170
|
+
|
|
171
|
+
### Fixed
|
|
172
|
+
- Fix error handling in `keystore.update` API.
|
|
173
|
+
|
|
174
|
+
## 2.0.0 - 2020-04-02
|
|
175
|
+
|
|
176
|
+
### Changed
|
|
177
|
+
- **BREAKING**: Use webkms-switch@2.
|
|
178
|
+
- Remove unused peer deps.
|
|
179
|
+
|
|
180
|
+
## 1.4.0 - 2020-02-25
|
|
181
|
+
|
|
182
|
+
### Changed
|
|
183
|
+
- Add dependency for `did-key-method`.
|
|
184
|
+
- Add peer dependency for `bedrock-did-context`.
|
|
185
|
+
- Add peer dependency for `bedrock-jsonld-document-loader`.
|
|
186
|
+
|
|
187
|
+
## 1.3.0 - 2020-02-14
|
|
188
|
+
|
|
189
|
+
### Changed
|
|
190
|
+
- Use jsonld-signatures@5.
|
|
191
|
+
|
|
192
|
+
## 1.2.0 - 2020-02-07
|
|
193
|
+
|
|
194
|
+
### Added
|
|
195
|
+
- Add support for `inspectCapabilityChain` handler in `validateOperation`. This
|
|
196
|
+
handler can be used to check for revocations in a capability chain.
|
|
197
|
+
- Handle reading DID key URLs (with `#`) in document loader.
|
|
198
|
+
|
|
199
|
+
## 1.1.0 - 2020-01-22
|
|
200
|
+
|
|
201
|
+
### Changed
|
|
202
|
+
- Specify peer dep bedrock-security-context@3.
|
|
203
|
+
|
|
204
|
+
## 1.0.2 - 2020-01-22
|
|
205
|
+
|
|
206
|
+
### Fixed
|
|
207
|
+
- Add missing jsonld-sigatures dep.
|
|
208
|
+
|
|
209
|
+
## 1.0.1 - 2019-12-20
|
|
210
|
+
|
|
211
|
+
### Fixed
|
|
212
|
+
- Fixed typo in module import.
|
|
213
|
+
|
|
214
|
+
## 1.0.0 - 2019-12-20
|
|
215
|
+
|
|
216
|
+
### Added
|
|
217
|
+
- Add core files.
|
|
218
|
+
|
|
219
|
+
- See git history for changes previous to this release.
|
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>
|
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import * as brPackageManager from '@bedrock/package-manager';
|
|
5
|
+
|
|
6
|
+
// load config defaults
|
|
7
|
+
import './config.js';
|
|
8
|
+
|
|
9
|
+
export class BedrockKmsModuleManager {
|
|
10
|
+
async get({id}) {
|
|
11
|
+
const {packageName} = brPackageManager.get(
|
|
12
|
+
{alias: id, type: 'webkms-module'});
|
|
13
|
+
const api = await import(packageName);
|
|
14
|
+
return api.default || api;
|
|
15
|
+
}
|
|
16
|
+
}
|
package/lib/config.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import {config} from '@bedrock/core';
|
|
5
|
+
|
|
6
|
+
const cfg = config.kms = {};
|
|
7
|
+
cfg.keystoreConfigCache = {
|
|
8
|
+
maxSize: 1000,
|
|
9
|
+
maxAge: 5 * 60 * 1000
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// storage size to report to meter service
|
|
13
|
+
cfg.storageCost = {
|
|
14
|
+
keystore: 1,
|
|
15
|
+
key: 1
|
|
16
|
+
};
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import * as keystores from './keystores.js';
|
|
5
|
+
import {BedrockKmsModuleManager} from './BedrockKmsModuleManager.js';
|
|
6
|
+
import {didIo} from '@bedrock/did-io';
|
|
7
|
+
import {documentLoader} from '@bedrock/jsonld-document-loader';
|
|
8
|
+
import '@bedrock/did-context';
|
|
9
|
+
import '@bedrock/security-context';
|
|
10
|
+
import '@bedrock/veres-one-context';
|
|
11
|
+
|
|
12
|
+
// load config defaults
|
|
13
|
+
import './config.js';
|
|
14
|
+
|
|
15
|
+
async function defaultDocumentLoader(url) {
|
|
16
|
+
let document;
|
|
17
|
+
if(url.startsWith('did:')) {
|
|
18
|
+
document = await didIo.get({did: url});
|
|
19
|
+
return {
|
|
20
|
+
contextUrl: null,
|
|
21
|
+
documentUrl: url,
|
|
22
|
+
document
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// finally, try the bedrock document loader
|
|
27
|
+
return documentLoader(url);
|
|
28
|
+
}
|
|
29
|
+
const defaultModuleManager = new BedrockKmsModuleManager();
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
BedrockKmsModuleManager, keystores,
|
|
33
|
+
defaultDocumentLoader, defaultModuleManager
|
|
34
|
+
};
|