Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# bedrock-kms-http ChangeLog

## 22.2.0 - 2025-10-dd

### Changed
- `helpers.getKeystoreId` will use `config.server.baseUri` rather than
`req.host` to align with other Bedrock service behavior.

## 22.1.0 - 2025-09-28

### Changed
Expand Down
11 changes: 5 additions & 6 deletions lib/helpers.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/*!
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
* Copyright (c) 2019-2025 Digital Bazaar, Inc. All rights reserved.
*/
import * as bedrock from '@bedrock/core';
import forwarded from 'forwarded';
import ipaddr from 'ipaddr.js';

export function getKeystoreId({host, req, localId, routes}) {
if(!host) {
host = req.get('host');
}
return `https://${host}${routes.keystores}/${localId}`;
export function getKeystoreId({localId, routes}) {
const {baseUri} = bedrock.config.server;
return `${baseUri}${routes.keystores}/${localId}`;
}

export function verifyRequestIp({keystoreConfig, req}) {
Expand Down
2 changes: 1 addition & 1 deletion lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ bedrock.events.on('bedrock-express.configure.routes', app => {

// create a keystore for the controller
const random = await generateRandom();
const id = helpers.getKeystoreId({req, localId: random, routes});
const id = helpers.getKeystoreId({localId: random, routes});
const config = {id, meterId, ...req.body};
const record = await keystores.insert({config});
res.status(201).location(id).json(record.config);
Expand Down
2 changes: 1 addition & 1 deletion lib/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function createGetKeystoreConfig({routes}) {
return asyncHandler(async function _getKeystoreConfig(req, res, next) {
if(!req.webkms) {
const keystoreId = helpers.getKeystoreId(
{req, localId: req.params.keystoreId, routes});
{localId: req.params.keystoreId, routes});
const configRecord = await storage.get({
id: keystoreId, req, returnRecord: true
});
Expand Down