@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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # bedrock-kms-http ChangeLog
2
2
 
3
+ ## 14.4.0 - 2022-05-19
4
+
5
+ ### Added
6
+ - Add max age header for CORS, defaulting to the max acceptable time for
7
+ modern browsers of 86400 seconds (24 hours).
8
+
3
9
  ## 14.3.1 - 2022-05-16
4
10
 
5
11
  ### Fixed
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrock/kms-http",
3
- "version": "14.3.1",
3
+ "version": "14.4.0",
4
4
  "type": "module",
5
5
  "description": "Bedrock KMS HTTP API",
6
6
  "main": "./lib/index.js",