@bedrock/kms-http 14.3.1 → 14.4.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/CHANGELOG.md +6 -0
- package/lib/http.js +1 -1
- package/lib/middleware.js +6 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/lib/http.js
CHANGED
|
@@ -6,7 +6,6 @@ import * as brZCapStorage from '@bedrock/zcap-storage';
|
|
|
6
6
|
import * as helpers from './helpers.js';
|
|
7
7
|
import * as middleware from './middleware.js';
|
|
8
8
|
import {asyncHandler} from '@bedrock/express';
|
|
9
|
-
import cors from 'cors';
|
|
10
9
|
import {createRequire} from 'node:module';
|
|
11
10
|
import {createValidateMiddleware as validate} from '@bedrock/validation';
|
|
12
11
|
import {
|
|
@@ -24,6 +23,7 @@ const require = createRequire(import.meta.url);
|
|
|
24
23
|
const {generateRandom} = require('@digitalbazaar/webkms-switch');
|
|
25
24
|
|
|
26
25
|
const {config, util: {BedrockError}} = bedrock;
|
|
26
|
+
const {cors} = middleware;
|
|
27
27
|
|
|
28
28
|
bedrock.events.on('bedrock-express.configure.routes', app => {
|
|
29
29
|
const cfg = config['kms-http'];
|
package/lib/middleware.js
CHANGED
|
@@ -7,6 +7,7 @@ import * as helpers from './helpers.js';
|
|
|
7
7
|
import {asyncHandler} from '@bedrock/express';
|
|
8
8
|
import {BedrockKeystoreConfigStorage} from './BedrockKeystoreConfigStorage.js';
|
|
9
9
|
import {createRequire} from 'node:module';
|
|
10
|
+
import {default as _cors} from 'cors';
|
|
10
11
|
import {
|
|
11
12
|
defaultDocumentLoader as documentLoader,
|
|
12
13
|
defaultModuleManager as moduleManager
|
|
@@ -107,6 +108,11 @@ export function authorizeZcapRevocation() {
|
|
|
107
108
|
});
|
|
108
109
|
}
|
|
109
110
|
|
|
111
|
+
export function cors() {
|
|
112
|
+
// `86400` is the max acceptable cache age for modern browsers
|
|
113
|
+
return _cors({maxAge: 86400});
|
|
114
|
+
}
|
|
115
|
+
|
|
110
116
|
async function getKeystoreController({req}) {
|
|
111
117
|
/* The following code is to prevent false-negative authz errors that are the
|
|
112
118
|
result of stale cached keystore configs.
|