@bedrock/kms-http 22.1.0 → 23.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/helpers.js +5 -6
- package/lib/http.js +1 -1
- package/lib/middleware.js +1 -1
- package/package.json +1 -1
package/lib/helpers.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Copyright (c) 2019-
|
|
2
|
+
* Copyright (c) 2019-2025 Digital Bazaar, Inc. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
+
import * as bedrock from '@bedrock/core';
|
|
4
5
|
import forwarded from 'forwarded';
|
|
5
6
|
import ipaddr from 'ipaddr.js';
|
|
6
7
|
|
|
7
|
-
export function getKeystoreId({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
return `https://${host}${routes.keystores}/${localId}`;
|
|
8
|
+
export function getKeystoreId({localId, routes}) {
|
|
9
|
+
const {baseUri} = bedrock.config.server;
|
|
10
|
+
return `${baseUri}${routes.keystores}/${localId}`;
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
export function verifyRequestIp({keystoreConfig, req}) {
|
package/lib/http.js
CHANGED
|
@@ -110,7 +110,7 @@ bedrock.events.on('bedrock-express.configure.routes', app => {
|
|
|
110
110
|
|
|
111
111
|
// create a keystore for the controller
|
|
112
112
|
const random = await generateRandom();
|
|
113
|
-
const id = helpers.getKeystoreId({
|
|
113
|
+
const id = helpers.getKeystoreId({localId: random, routes});
|
|
114
114
|
const config = {id, meterId, ...req.body};
|
|
115
115
|
const record = await keystores.insert({config});
|
|
116
116
|
res.status(201).location(id).json(record.config);
|
package/lib/middleware.js
CHANGED
|
@@ -32,7 +32,7 @@ export function createGetKeystoreConfig({routes}) {
|
|
|
32
32
|
return asyncHandler(async function _getKeystoreConfig(req, res, next) {
|
|
33
33
|
if(!req.webkms) {
|
|
34
34
|
const keystoreId = helpers.getKeystoreId(
|
|
35
|
-
{
|
|
35
|
+
{localId: req.params.keystoreId, routes});
|
|
36
36
|
const configRecord = await storage.get({
|
|
37
37
|
id: keystoreId, req, returnRecord: true
|
|
38
38
|
});
|