express-rate-limit 6.3.0 → 6.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 +19 -0
- package/dist/index.cjs +14 -19
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +6 -6
- package/package.json +21 -21
package/changelog.md
CHANGED
|
@@ -6,6 +6,25 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
6
6
|
and this project adheres to
|
|
7
7
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
8
|
|
|
9
|
+
## [6.4.0](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.3.0)
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Adds Express 5 (`5.0.0-beta.1`) as a supported peer dependency (#304)
|
|
14
|
+
|
|
15
|
+
## Changed
|
|
16
|
+
|
|
17
|
+
- Tests are now run on Node 12, 14, 16 and 18 on CI (#305)
|
|
18
|
+
- Updated all development dependencies (#306)
|
|
19
|
+
|
|
20
|
+
## [6.3.0](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.3.0)
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- Changes the build target to es2019 so that ESBuild outputs code that can run
|
|
25
|
+
with Node 12.
|
|
26
|
+
- Changes the minimum required Node version to 12.9.0.
|
|
27
|
+
|
|
9
28
|
## [6.2.1](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.2.1)
|
|
10
29
|
|
|
11
30
|
### Fixed
|
package/dist/index.cjs
CHANGED
|
@@ -2,24 +2,19 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
5
|
var __export = (target, all) => {
|
|
7
6
|
for (var name in all)
|
|
8
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
8
|
};
|
|
10
|
-
var
|
|
11
|
-
if (
|
|
12
|
-
for (let key of __getOwnPropNames(
|
|
13
|
-
if (!__hasOwnProp.call(
|
|
14
|
-
__defProp(
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
14
|
}
|
|
16
|
-
return
|
|
15
|
+
return to;
|
|
17
16
|
};
|
|
18
|
-
var __toCommonJS =
|
|
19
|
-
return (module2, temp) => {
|
|
20
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
21
|
-
};
|
|
22
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
18
|
|
|
24
19
|
// source/index.ts
|
|
25
20
|
var source_exports = {};
|
|
@@ -28,6 +23,7 @@ __export(source_exports, {
|
|
|
28
23
|
default: () => lib_default,
|
|
29
24
|
rateLimit: () => lib_default
|
|
30
25
|
});
|
|
26
|
+
module.exports = __toCommonJS(source_exports);
|
|
31
27
|
|
|
32
28
|
// source/memory-store.ts
|
|
33
29
|
var calculateNextResetTime = (windowMs) => {
|
|
@@ -89,14 +85,14 @@ var promisifyStore = (passedStore) => {
|
|
|
89
85
|
});
|
|
90
86
|
}
|
|
91
87
|
async decrement(key) {
|
|
92
|
-
return
|
|
88
|
+
return legacyStore.decrement(key);
|
|
93
89
|
}
|
|
94
90
|
async resetKey(key) {
|
|
95
|
-
return
|
|
91
|
+
return legacyStore.resetKey(key);
|
|
96
92
|
}
|
|
97
93
|
async resetAll() {
|
|
98
94
|
if (typeof legacyStore.resetAll === "function")
|
|
99
|
-
return
|
|
95
|
+
return legacyStore.resetAll();
|
|
100
96
|
}
|
|
101
97
|
}
|
|
102
98
|
return new PromisifiedStore();
|
|
@@ -116,16 +112,16 @@ var parseOptions = (passedOptions) => {
|
|
|
116
112
|
skipSuccessfulRequests: false,
|
|
117
113
|
requestWasSuccessful: (_request, response) => response.statusCode < 400,
|
|
118
114
|
skip: (_request, _response) => false,
|
|
119
|
-
keyGenerator
|
|
115
|
+
keyGenerator(request, _response) {
|
|
120
116
|
if (!request.ip) {
|
|
121
117
|
console.error("WARN | `express-rate-limit` | `request.ip` is undefined. You can avoid this by providing a custom `keyGenerator` function, but it may be indicative of a larger issue.");
|
|
122
118
|
}
|
|
123
119
|
return request.ip;
|
|
124
120
|
},
|
|
125
|
-
handler
|
|
121
|
+
handler(_request, response, _next, _optionsUsed) {
|
|
126
122
|
response.status(config.statusCode).send(config.message);
|
|
127
123
|
},
|
|
128
|
-
onLimitReached
|
|
124
|
+
onLimitReached(_request, _response, _optionsUsed) {
|
|
129
125
|
},
|
|
130
126
|
...notUndefinedOptions,
|
|
131
127
|
store: promisifyStore((_c = notUndefinedOptions.store) != null ? _c : new MemoryStore())
|
|
@@ -233,5 +229,4 @@ var omitUndefinedOptions = (passedOptions) => {
|
|
|
233
229
|
return omittedOptions;
|
|
234
230
|
};
|
|
235
231
|
var lib_default = rateLimit;
|
|
236
|
-
module.exports = __toCommonJS(source_exports);
|
|
237
232
|
module.exports = rateLimit; module.exports.default = rateLimit; module.exports.rateLimit = rateLimit; module.exports.MemoryStore = MemoryStore;
|
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -58,14 +58,14 @@ var promisifyStore = (passedStore) => {
|
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
async decrement(key) {
|
|
61
|
-
return
|
|
61
|
+
return legacyStore.decrement(key);
|
|
62
62
|
}
|
|
63
63
|
async resetKey(key) {
|
|
64
|
-
return
|
|
64
|
+
return legacyStore.resetKey(key);
|
|
65
65
|
}
|
|
66
66
|
async resetAll() {
|
|
67
67
|
if (typeof legacyStore.resetAll === "function")
|
|
68
|
-
return
|
|
68
|
+
return legacyStore.resetAll();
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
return new PromisifiedStore();
|
|
@@ -85,16 +85,16 @@ var parseOptions = (passedOptions) => {
|
|
|
85
85
|
skipSuccessfulRequests: false,
|
|
86
86
|
requestWasSuccessful: (_request, response) => response.statusCode < 400,
|
|
87
87
|
skip: (_request, _response) => false,
|
|
88
|
-
keyGenerator
|
|
88
|
+
keyGenerator(request, _response) {
|
|
89
89
|
if (!request.ip) {
|
|
90
90
|
console.error("WARN | `express-rate-limit` | `request.ip` is undefined. You can avoid this by providing a custom `keyGenerator` function, but it may be indicative of a larger issue.");
|
|
91
91
|
}
|
|
92
92
|
return request.ip;
|
|
93
93
|
},
|
|
94
|
-
handler
|
|
94
|
+
handler(_request, response, _next, _optionsUsed) {
|
|
95
95
|
response.status(config.statusCode).send(config.message);
|
|
96
96
|
},
|
|
97
|
-
onLimitReached
|
|
97
|
+
onLimitReached(_request, _response, _optionsUsed) {
|
|
98
98
|
},
|
|
99
99
|
...notUndefinedOptions,
|
|
100
100
|
store: promisifyStore((_c = notUndefinedOptions.store) != null ? _c : new MemoryStore())
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-rate-limit",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.0",
|
|
4
4
|
"description": "Basic IP rate-limiting middleware for Express. Use to limit repeated requests to public APIs and/or endpoints such as password reset.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Nathan Friedly",
|
|
@@ -67,28 +67,28 @@
|
|
|
67
67
|
"prepare": "run-s compile && husky install config/husky"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"express": "^4"
|
|
70
|
+
"express": "^4 || ^5"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@jest/globals": "
|
|
74
|
-
"@types/express": "
|
|
75
|
-
"@types/jest": "
|
|
76
|
-
"@types/node": "
|
|
77
|
-
"@types/supertest": "
|
|
78
|
-
"cross-env": "
|
|
79
|
-
"del-cli": "
|
|
80
|
-
"dts-bundle-generator": "
|
|
81
|
-
"esbuild": "
|
|
82
|
-
"express": "
|
|
83
|
-
"husky": "
|
|
84
|
-
"jest": "
|
|
85
|
-
"lint-staged": "
|
|
86
|
-
"npm-run-all": "
|
|
87
|
-
"supertest": "
|
|
88
|
-
"ts-jest": "
|
|
89
|
-
"ts-node": "
|
|
90
|
-
"typescript": "
|
|
91
|
-
"xo": "
|
|
73
|
+
"@jest/globals": "27.4.6",
|
|
74
|
+
"@types/express": "4.17.13",
|
|
75
|
+
"@types/jest": "27.4.1",
|
|
76
|
+
"@types/node": "16.11.27",
|
|
77
|
+
"@types/supertest": "2.0.12",
|
|
78
|
+
"cross-env": "7.0.3",
|
|
79
|
+
"del-cli": "4.0.1",
|
|
80
|
+
"dts-bundle-generator": "6.8.0",
|
|
81
|
+
"esbuild": "0.14.38",
|
|
82
|
+
"express": "4.17.3",
|
|
83
|
+
"husky": "7.0.4",
|
|
84
|
+
"jest": "27.5.1",
|
|
85
|
+
"lint-staged": "12.4.0",
|
|
86
|
+
"npm-run-all": "4.1.5",
|
|
87
|
+
"supertest": "6.2.2",
|
|
88
|
+
"ts-jest": "27.1.4",
|
|
89
|
+
"ts-node": "10.7.0",
|
|
90
|
+
"typescript": "4.6.3",
|
|
91
|
+
"xo": "0.48.0"
|
|
92
92
|
},
|
|
93
93
|
"xo": {
|
|
94
94
|
"prettier": true,
|