@middy/http-cors 7.1.1 → 7.1.2

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.
Files changed (2) hide show
  1. package/index.js +16 -1
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -62,7 +62,6 @@ const httpCorsMiddleware = (opts = {}) => {
62
62
  if (originDynamic.some((regExp) => regExp.test(incomingOrigin))) {
63
63
  return incomingOrigin;
64
64
  }
65
- // TODO v8 deprecate `else`
66
65
  } else {
67
66
  if (incomingOrigin && options.credentials && options.origin === "*") {
68
67
  return incomingOrigin;
@@ -77,6 +76,22 @@ const httpCorsMiddleware = (opts = {}) => {
77
76
  ...opts,
78
77
  };
79
78
 
79
+ if (
80
+ options.requestHeaders !== undefined &&
81
+ !Array.isArray(options.requestHeaders)
82
+ ) {
83
+ throw new Error("requestHeaders must be an array", {
84
+ cause: { package: "@middy/http-cors" },
85
+ });
86
+ }
87
+ if (
88
+ options.requestMethods !== undefined &&
89
+ !Array.isArray(options.requestMethods)
90
+ ) {
91
+ throw new Error("requestMethods must be an array", {
92
+ cause: { package: "@middy/http-cors" },
93
+ });
94
+ }
80
95
  options.requestHeaders = options.requestHeaders?.map((v) => v.toLowerCase());
81
96
  options.requestMethods = options.requestMethods?.map((v) => v.toUpperCase());
82
97
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/http-cors",
3
- "version": "7.1.1",
3
+ "version": "7.1.2",
4
4
  "description": "CORS (Cross-Origin Resource Sharing) middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -65,10 +65,10 @@
65
65
  },
66
66
  "gitHead": "7a6c0fbb8ab71d6a2171e678697de9f237568431",
67
67
  "dependencies": {
68
- "@middy/util": "7.1.1"
68
+ "@middy/util": "7.1.2"
69
69
  },
70
70
  "devDependencies": {
71
- "@middy/core": "7.1.1",
71
+ "@middy/core": "7.1.2",
72
72
  "@types/aws-lambda": "^8.0.0"
73
73
  }
74
74
  }