@bedrock/kms-http 22.0.0 → 22.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.
- package/lib/middleware.js +2 -39
- package/package.json +2 -2
package/lib/middleware.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Copyright (c) 2019-
|
|
2
|
+
* Copyright (c) 2019-2025 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';
|
|
@@ -20,6 +20,7 @@ import {defaultModuleManager as moduleManager} from '@bedrock/kms';
|
|
|
20
20
|
import {reportOperationUsage} from './metering.js';
|
|
21
21
|
|
|
22
22
|
const {config, util: {BedrockError}} = bedrock;
|
|
23
|
+
const {helpers: {inspectCapabilityChain}} = brZCapStorage;
|
|
23
24
|
|
|
24
25
|
const FIVE_MINUTES = 1000 * 60 * 5;
|
|
25
26
|
|
|
@@ -200,44 +201,6 @@ async function getVerifier({keyId, documentLoader}) {
|
|
|
200
201
|
return {verifier, verificationMethod};
|
|
201
202
|
}
|
|
202
203
|
|
|
203
|
-
async function inspectCapabilityChain({
|
|
204
|
-
capabilityChain, capabilityChainMeta
|
|
205
|
-
}) {
|
|
206
|
-
// if capability chain has only root, there's nothing to check as root
|
|
207
|
-
// zcaps cannot be revoked
|
|
208
|
-
if(capabilityChain.length === 1) {
|
|
209
|
-
return {valid: true};
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// collect capability IDs and delegators for all delegated capabilities in
|
|
213
|
-
// chain (skip root) so they can be checked for revocation
|
|
214
|
-
const capabilities = [];
|
|
215
|
-
for(const [i, capability] of capabilityChain.entries()) {
|
|
216
|
-
// skip root zcap, it cannot be revoked
|
|
217
|
-
if(i === 0) {
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
const [{purposeResult}] = capabilityChainMeta[i].verifyResult.results;
|
|
221
|
-
if(purposeResult && purposeResult.delegator) {
|
|
222
|
-
capabilities.push({
|
|
223
|
-
capabilityId: capability.id,
|
|
224
|
-
delegator: purposeResult.delegator.id,
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
const revoked = await brZCapStorage.revocations.isRevoked({capabilities});
|
|
230
|
-
if(revoked) {
|
|
231
|
-
return {
|
|
232
|
-
valid: false,
|
|
233
|
-
error: new Error(
|
|
234
|
-
'One or more capabilities in the chain have been revoked.')
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
return {valid: true};
|
|
239
|
-
}
|
|
240
|
-
|
|
241
204
|
function onError({error}) {
|
|
242
205
|
if(!(error instanceof BedrockError)) {
|
|
243
206
|
// always expose cause message and name; expose cause details as
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bedrock/kms-http",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Bedrock KMS HTTP API",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@bedrock/security-context": "^9.0.0",
|
|
50
50
|
"@bedrock/validation": "^7.1.1",
|
|
51
51
|
"@bedrock/veres-one-context": "^16.0.0",
|
|
52
|
-
"@bedrock/zcap-storage": "^9.
|
|
52
|
+
"@bedrock/zcap-storage": "^9.3.0"
|
|
53
53
|
},
|
|
54
54
|
"directories": {
|
|
55
55
|
"lib": "./lib"
|