express-rate-limit 7.0.2 → 7.1.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 +7 -0
- package/dist/index.cjs +4 -7
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +4 -7
- package/package.json +1 -1
- package/readme.md +4 -0
package/changelog.md
CHANGED
|
@@ -6,6 +6,13 @@ 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
|
+
## [7.1.0](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v7.1.0)
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- The `getKey` method is now always defined. If the store does not have the
|
|
14
|
+
required `get` method, `getKey` will throw an error explaining this.
|
|
15
|
+
|
|
9
16
|
## [7.0.2](https://github.com/express-rate-limit/express-rate-limit/releases/tag/v7.0.2)
|
|
10
17
|
|
|
11
18
|
### Added
|
package/dist/index.cjs
CHANGED
|
@@ -506,10 +506,6 @@ var promisifyStore = (passedStore) => {
|
|
|
506
506
|
}
|
|
507
507
|
const legacyStore = passedStore;
|
|
508
508
|
class PromisifiedStore {
|
|
509
|
-
/* istanbul ignore next */
|
|
510
|
-
async get(key) {
|
|
511
|
-
return void 0;
|
|
512
|
-
}
|
|
513
509
|
async increment(key) {
|
|
514
510
|
return new Promise((resolve, reject) => {
|
|
515
511
|
legacyStore.incr(
|
|
@@ -699,10 +695,11 @@ var rateLimit = (passedOptions) => {
|
|
|
699
695
|
next();
|
|
700
696
|
}
|
|
701
697
|
);
|
|
698
|
+
const getThrowFn = () => {
|
|
699
|
+
throw new Error("The current store does not support the get/getKey method");
|
|
700
|
+
};
|
|
702
701
|
middleware.resetKey = config.store.resetKey.bind(config.store);
|
|
703
|
-
middleware.getKey = config.store.get
|
|
704
|
-
config.store
|
|
705
|
-
);
|
|
702
|
+
middleware.getKey = typeof config.store.get === "function" ? config.store.get.bind(config.store) : getThrowFn;
|
|
706
703
|
return middleware;
|
|
707
704
|
};
|
|
708
705
|
var lib_default = rateLimit;
|
package/dist/index.d.cts
CHANGED
|
@@ -165,7 +165,7 @@ export type RateLimitRequestHandler = RequestHandler & {
|
|
|
165
165
|
*
|
|
166
166
|
* @returns {ClientRateLimitInfo} - The number of hits and reset time for that client.
|
|
167
167
|
*/
|
|
168
|
-
getKey
|
|
168
|
+
getKey: (key: string) => Promise<ClientRateLimitInfo | undefined> | ClientRateLimitInfo | undefined;
|
|
169
169
|
};
|
|
170
170
|
/**
|
|
171
171
|
* An interface that all hit counter stores must implement.
|
package/dist/index.d.mts
CHANGED
|
@@ -165,7 +165,7 @@ export type RateLimitRequestHandler = RequestHandler & {
|
|
|
165
165
|
*
|
|
166
166
|
* @returns {ClientRateLimitInfo} - The number of hits and reset time for that client.
|
|
167
167
|
*/
|
|
168
|
-
getKey
|
|
168
|
+
getKey: (key: string) => Promise<ClientRateLimitInfo | undefined> | ClientRateLimitInfo | undefined;
|
|
169
169
|
};
|
|
170
170
|
/**
|
|
171
171
|
* An interface that all hit counter stores must implement.
|
package/dist/index.d.ts
CHANGED
|
@@ -165,7 +165,7 @@ export type RateLimitRequestHandler = RequestHandler & {
|
|
|
165
165
|
*
|
|
166
166
|
* @returns {ClientRateLimitInfo} - The number of hits and reset time for that client.
|
|
167
167
|
*/
|
|
168
|
-
getKey
|
|
168
|
+
getKey: (key: string) => Promise<ClientRateLimitInfo | undefined> | ClientRateLimitInfo | undefined;
|
|
169
169
|
};
|
|
170
170
|
/**
|
|
171
171
|
* An interface that all hit counter stores must implement.
|
package/dist/index.mjs
CHANGED
|
@@ -478,10 +478,6 @@ var promisifyStore = (passedStore) => {
|
|
|
478
478
|
}
|
|
479
479
|
const legacyStore = passedStore;
|
|
480
480
|
class PromisifiedStore {
|
|
481
|
-
/* istanbul ignore next */
|
|
482
|
-
async get(key) {
|
|
483
|
-
return void 0;
|
|
484
|
-
}
|
|
485
481
|
async increment(key) {
|
|
486
482
|
return new Promise((resolve, reject) => {
|
|
487
483
|
legacyStore.incr(
|
|
@@ -671,10 +667,11 @@ var rateLimit = (passedOptions) => {
|
|
|
671
667
|
next();
|
|
672
668
|
}
|
|
673
669
|
);
|
|
670
|
+
const getThrowFn = () => {
|
|
671
|
+
throw new Error("The current store does not support the get/getKey method");
|
|
672
|
+
};
|
|
674
673
|
middleware.resetKey = config.store.resetKey.bind(config.store);
|
|
675
|
-
middleware.getKey = config.store.get
|
|
676
|
-
config.store
|
|
677
|
-
);
|
|
674
|
+
middleware.getKey = typeof config.store.get === "function" ? config.store.get.bind(config.store) : getThrowFn;
|
|
678
675
|
return middleware;
|
|
679
676
|
};
|
|
680
677
|
var lib_default = rateLimit;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-rate-limit",
|
|
3
|
-
"version": "7.0
|
|
3
|
+
"version": "7.1.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",
|
package/readme.md
CHANGED
|
@@ -554,6 +554,10 @@ to complete a captcha to reset their rate limit, then call this function.
|
|
|
554
554
|
|
|
555
555
|
Retrieves the hit count and reset time from the store for a given key.
|
|
556
556
|
|
|
557
|
+
Note: `getKey` depends on store support. It works with the MemoryStore, but may
|
|
558
|
+
not work with other stores. Calling it will throw an error if the store does not
|
|
559
|
+
have a `get` method.
|
|
560
|
+
|
|
557
561
|
## Issues and Contributing
|
|
558
562
|
|
|
559
563
|
If you encounter a bug or want to see something added/changed, please go ahead
|