express-rate-limit 6.11.0 → 6.11.1
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 +8 -0
- package/dist/index.cjs +4 -2
- package/dist/index.d.cts +6 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +4 -2
- package/package.json +1 -1
package/changelog.md
CHANGED
|
@@ -6,6 +6,14 @@ 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.1](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v6.11.1)
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- Check for prefixed keys when validating that the stores have single counted
|
|
14
|
+
keys (See
|
|
15
|
+
[#395](https://github.com/express-rate-limit/express-rate-limit/issues/395)).
|
|
16
|
+
|
|
9
17
|
## [6.11.0](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v6.11.0)
|
|
10
18
|
|
|
11
19
|
### 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
|
@@ -154,6 +154,12 @@ export type Store = {
|
|
|
154
154
|
* Used to help detect double-counting misconfigurations.
|
|
155
155
|
*/
|
|
156
156
|
localKeys?: boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Optional value that the store prepends to keys
|
|
159
|
+
*
|
|
160
|
+
* Used by the double-count check to avoid false-positives when a key is counted twice, but with different prefixes
|
|
161
|
+
*/
|
|
162
|
+
prefix?: string;
|
|
157
163
|
};
|
|
158
164
|
export type DraftHeadersVersion = "draft-6" | "draft-7";
|
|
159
165
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -154,6 +154,12 @@ export type Store = {
|
|
|
154
154
|
* Used to help detect double-counting misconfigurations.
|
|
155
155
|
*/
|
|
156
156
|
localKeys?: boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Optional value that the store prepends to keys
|
|
159
|
+
*
|
|
160
|
+
* Used by the double-count check to avoid false-positives when a key is counted twice, but with different prefixes
|
|
161
|
+
*/
|
|
162
|
+
prefix?: string;
|
|
157
163
|
};
|
|
158
164
|
export type DraftHeadersVersion = "draft-6" | "draft-7";
|
|
159
165
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -154,6 +154,12 @@ export type Store = {
|
|
|
154
154
|
* Used to help detect double-counting misconfigurations.
|
|
155
155
|
*/
|
|
156
156
|
localKeys?: boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Optional value that the store prepends to keys
|
|
159
|
+
*
|
|
160
|
+
* Used by the double-count check to avoid false-positives when a key is counted twice, but with different prefixes
|
|
161
|
+
*/
|
|
162
|
+
prefix?: string;
|
|
157
163
|
};
|
|
158
164
|
export type DraftHeadersVersion = "draft-6" | "draft-7";
|
|
159
165
|
/**
|
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.1",
|
|
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",
|