@middy/http-cors 7.3.2 → 7.3.4
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/index.js +7 -4
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
import { normalizeHttpResponse, validateOptions } from "@middy/util";
|
|
4
4
|
|
|
5
|
+
const name = "http-cors";
|
|
6
|
+
const pkg = `@middy/${name}`;
|
|
7
|
+
|
|
5
8
|
const optionSchema = {
|
|
6
9
|
type: "object",
|
|
7
10
|
properties: {
|
|
@@ -11,7 +14,7 @@ const optionSchema = {
|
|
|
11
14
|
headers: { type: "string" },
|
|
12
15
|
methods: {
|
|
13
16
|
type: "string",
|
|
14
|
-
pattern:
|
|
17
|
+
pattern: /^\s*(\*|[A-Z]+)(\s*,\s*(\*|[A-Z]+))*\s*$/,
|
|
15
18
|
examples: ["*", "GET", "GET,POST"],
|
|
16
19
|
},
|
|
17
20
|
origin: { type: "string" },
|
|
@@ -35,7 +38,7 @@ const optionSchema = {
|
|
|
35
38
|
};
|
|
36
39
|
|
|
37
40
|
export const httpCorsValidateOptions = (options) =>
|
|
38
|
-
validateOptions(
|
|
41
|
+
validateOptions(pkg, optionSchema, options);
|
|
39
42
|
|
|
40
43
|
const hostnameToPunycode = (hostname) => {
|
|
41
44
|
const placeholder = "-_ANY_-";
|
|
@@ -117,7 +120,7 @@ const httpCorsMiddleware = (opts = {}) => {
|
|
|
117
120
|
!Array.isArray(options.requestHeaders)
|
|
118
121
|
) {
|
|
119
122
|
throw new Error("requestHeaders must be an array", {
|
|
120
|
-
cause: { package:
|
|
123
|
+
cause: { package: pkg },
|
|
121
124
|
});
|
|
122
125
|
}
|
|
123
126
|
if (
|
|
@@ -125,7 +128,7 @@ const httpCorsMiddleware = (opts = {}) => {
|
|
|
125
128
|
!Array.isArray(options.requestMethods)
|
|
126
129
|
) {
|
|
127
130
|
throw new Error("requestMethods must be an array", {
|
|
128
|
-
cause: { package:
|
|
131
|
+
cause: { package: pkg },
|
|
129
132
|
});
|
|
130
133
|
}
|
|
131
134
|
options.requestHeaders = options.requestHeaders?.map((v) => v.toLowerCase());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/http-cors",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.4",
|
|
4
4
|
"description": "CORS (Cross-Origin Resource Sharing) middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"url": "https://github.com/sponsors/willfarrell"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@middy/util": "7.3.
|
|
64
|
+
"@middy/util": "7.3.4"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@middy/core": "7.3.
|
|
67
|
+
"@middy/core": "7.3.4",
|
|
68
68
|
"@types/aws-lambda": "^8.0.0",
|
|
69
69
|
"@types/node": "^22.0.0"
|
|
70
70
|
}
|