express-rate-limit 6.11.0 → 6.11.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.
- package/changelog.md +15 -0
- package/dist/index.cjs +4 -2
- package/dist/index.d.cts +9 -2
- package/dist/index.d.mts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.mjs +4 -2
- package/package.json +1 -1
package/changelog.md
CHANGED
|
@@ -6,6 +6,21 @@ 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.11.2](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v6.11.2)
|
|
10
|
+
|
|
11
|
+
Fixed:
|
|
12
|
+
|
|
13
|
+
- Restored `IncrementResponse ` TypeScript type (See
|
|
14
|
+
[#397](https://github.com/express-rate-limit/express-rate-limit/pull/397))
|
|
15
|
+
|
|
16
|
+
## [6.11.1](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v6.11.1)
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Check for prefixed keys when validating that the stores have single counted
|
|
21
|
+
keys (See
|
|
22
|
+
[#395](https://github.com/express-rate-limit/express-rate-limit/issues/395)).
|
|
23
|
+
|
|
9
24
|
## [6.11.0](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v6.11.0)
|
|
10
25
|
|
|
11
26
|
### Added
|
package/dist/index.cjs
CHANGED
|
@@ -211,6 +211,7 @@ var _Validations = class _Validations {
|
|
|
211
211
|
*/
|
|
212
212
|
singleCount(request, store, key) {
|
|
213
213
|
this.wrap(() => {
|
|
214
|
+
var _a;
|
|
214
215
|
let storeKeys = _Validations.singleCountKeys.get(request);
|
|
215
216
|
if (!storeKeys) {
|
|
216
217
|
storeKeys = /* @__PURE__ */ new Map();
|
|
@@ -222,13 +223,14 @@ var _Validations = class _Validations {
|
|
|
222
223
|
keys = [];
|
|
223
224
|
storeKeys.set(storeKey, keys);
|
|
224
225
|
}
|
|
225
|
-
|
|
226
|
+
const prefixedKey = `${(_a = store.prefix) != null ? _a : ""}${key}`;
|
|
227
|
+
if (keys.includes(prefixedKey)) {
|
|
226
228
|
throw new ValidationError(
|
|
227
229
|
"ERR_ERL_DOUBLE_COUNT",
|
|
228
230
|
`The hit count for ${key} was incremented more than once for a single request.`
|
|
229
231
|
);
|
|
230
232
|
}
|
|
231
|
-
keys.push(
|
|
233
|
+
keys.push(prefixedKey);
|
|
232
234
|
});
|
|
233
235
|
}
|
|
234
236
|
/**
|
package/dist/index.d.cts
CHANGED
|
@@ -50,6 +50,7 @@ export type ClientRateLimitInfo = {
|
|
|
50
50
|
totalHits: number;
|
|
51
51
|
resetTime: Date | undefined;
|
|
52
52
|
};
|
|
53
|
+
export type IncrementResponse = ClientRateLimitInfo;
|
|
53
54
|
/**
|
|
54
55
|
* A modified Express request handler with the rate limit functions.
|
|
55
56
|
*/
|
|
@@ -123,9 +124,9 @@ export type Store = {
|
|
|
123
124
|
*
|
|
124
125
|
* @param key {string} - The identifier for a client.
|
|
125
126
|
*
|
|
126
|
-
* @returns {
|
|
127
|
+
* @returns {IncrementResponse | undefined} - The number of hits and reset time for that client.
|
|
127
128
|
*/
|
|
128
|
-
increment: (key: string) => Promise<
|
|
129
|
+
increment: (key: string) => Promise<IncrementResponse> | IncrementResponse;
|
|
129
130
|
/**
|
|
130
131
|
* Method to decrement a client's hit counter.
|
|
131
132
|
*
|
|
@@ -154,6 +155,12 @@ export type Store = {
|
|
|
154
155
|
* Used to help detect double-counting misconfigurations.
|
|
155
156
|
*/
|
|
156
157
|
localKeys?: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Optional value that the store prepends to keys
|
|
160
|
+
*
|
|
161
|
+
* Used by the double-count check to avoid false-positives when a key is counted twice, but with different prefixes
|
|
162
|
+
*/
|
|
163
|
+
prefix?: string;
|
|
157
164
|
};
|
|
158
165
|
export type DraftHeadersVersion = "draft-6" | "draft-7";
|
|
159
166
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -50,6 +50,7 @@ export type ClientRateLimitInfo = {
|
|
|
50
50
|
totalHits: number;
|
|
51
51
|
resetTime: Date | undefined;
|
|
52
52
|
};
|
|
53
|
+
export type IncrementResponse = ClientRateLimitInfo;
|
|
53
54
|
/**
|
|
54
55
|
* A modified Express request handler with the rate limit functions.
|
|
55
56
|
*/
|
|
@@ -123,9 +124,9 @@ export type Store = {
|
|
|
123
124
|
*
|
|
124
125
|
* @param key {string} - The identifier for a client.
|
|
125
126
|
*
|
|
126
|
-
* @returns {
|
|
127
|
+
* @returns {IncrementResponse | undefined} - The number of hits and reset time for that client.
|
|
127
128
|
*/
|
|
128
|
-
increment: (key: string) => Promise<
|
|
129
|
+
increment: (key: string) => Promise<IncrementResponse> | IncrementResponse;
|
|
129
130
|
/**
|
|
130
131
|
* Method to decrement a client's hit counter.
|
|
131
132
|
*
|
|
@@ -154,6 +155,12 @@ export type Store = {
|
|
|
154
155
|
* Used to help detect double-counting misconfigurations.
|
|
155
156
|
*/
|
|
156
157
|
localKeys?: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Optional value that the store prepends to keys
|
|
160
|
+
*
|
|
161
|
+
* Used by the double-count check to avoid false-positives when a key is counted twice, but with different prefixes
|
|
162
|
+
*/
|
|
163
|
+
prefix?: string;
|
|
157
164
|
};
|
|
158
165
|
export type DraftHeadersVersion = "draft-6" | "draft-7";
|
|
159
166
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ export type ClientRateLimitInfo = {
|
|
|
50
50
|
totalHits: number;
|
|
51
51
|
resetTime: Date | undefined;
|
|
52
52
|
};
|
|
53
|
+
export type IncrementResponse = ClientRateLimitInfo;
|
|
53
54
|
/**
|
|
54
55
|
* A modified Express request handler with the rate limit functions.
|
|
55
56
|
*/
|
|
@@ -123,9 +124,9 @@ export type Store = {
|
|
|
123
124
|
*
|
|
124
125
|
* @param key {string} - The identifier for a client.
|
|
125
126
|
*
|
|
126
|
-
* @returns {
|
|
127
|
+
* @returns {IncrementResponse | undefined} - The number of hits and reset time for that client.
|
|
127
128
|
*/
|
|
128
|
-
increment: (key: string) => Promise<
|
|
129
|
+
increment: (key: string) => Promise<IncrementResponse> | IncrementResponse;
|
|
129
130
|
/**
|
|
130
131
|
* Method to decrement a client's hit counter.
|
|
131
132
|
*
|
|
@@ -154,6 +155,12 @@ export type Store = {
|
|
|
154
155
|
* Used to help detect double-counting misconfigurations.
|
|
155
156
|
*/
|
|
156
157
|
localKeys?: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Optional value that the store prepends to keys
|
|
160
|
+
*
|
|
161
|
+
* Used by the double-count check to avoid false-positives when a key is counted twice, but with different prefixes
|
|
162
|
+
*/
|
|
163
|
+
prefix?: string;
|
|
157
164
|
};
|
|
158
165
|
export type DraftHeadersVersion = "draft-6" | "draft-7";
|
|
159
166
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -185,6 +185,7 @@ var _Validations = class _Validations {
|
|
|
185
185
|
*/
|
|
186
186
|
singleCount(request, store, key) {
|
|
187
187
|
this.wrap(() => {
|
|
188
|
+
var _a;
|
|
188
189
|
let storeKeys = _Validations.singleCountKeys.get(request);
|
|
189
190
|
if (!storeKeys) {
|
|
190
191
|
storeKeys = /* @__PURE__ */ new Map();
|
|
@@ -196,13 +197,14 @@ var _Validations = class _Validations {
|
|
|
196
197
|
keys = [];
|
|
197
198
|
storeKeys.set(storeKey, keys);
|
|
198
199
|
}
|
|
199
|
-
|
|
200
|
+
const prefixedKey = `${(_a = store.prefix) != null ? _a : ""}${key}`;
|
|
201
|
+
if (keys.includes(prefixedKey)) {
|
|
200
202
|
throw new ValidationError(
|
|
201
203
|
"ERR_ERL_DOUBLE_COUNT",
|
|
202
204
|
`The hit count for ${key} was incremented more than once for a single request.`
|
|
203
205
|
);
|
|
204
206
|
}
|
|
205
|
-
keys.push(
|
|
207
|
+
keys.push(prefixedKey);
|
|
206
208
|
});
|
|
207
209
|
}
|
|
208
210
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-rate-limit",
|
|
3
|
-
"version": "6.11.
|
|
3
|
+
"version": "6.11.2",
|
|
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",
|