express-rate-limit 8.1.0 → 8.2.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/dist/index.cjs +40 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +40 -1
- package/package.json +11 -11
package/dist/index.cjs
CHANGED
|
@@ -521,12 +521,50 @@ var validations = {
|
|
|
521
521
|
);
|
|
522
522
|
}
|
|
523
523
|
},
|
|
524
|
+
knownOptions(passedOptions) {
|
|
525
|
+
if (!passedOptions) return;
|
|
526
|
+
const optionsMap = {
|
|
527
|
+
windowMs: true,
|
|
528
|
+
limit: true,
|
|
529
|
+
message: true,
|
|
530
|
+
statusCode: true,
|
|
531
|
+
legacyHeaders: true,
|
|
532
|
+
standardHeaders: true,
|
|
533
|
+
identifier: true,
|
|
534
|
+
requestPropertyName: true,
|
|
535
|
+
skipFailedRequests: true,
|
|
536
|
+
skipSuccessfulRequests: true,
|
|
537
|
+
keyGenerator: true,
|
|
538
|
+
ipv6Subnet: true,
|
|
539
|
+
handler: true,
|
|
540
|
+
skip: true,
|
|
541
|
+
requestWasSuccessful: true,
|
|
542
|
+
store: true,
|
|
543
|
+
validate: true,
|
|
544
|
+
headers: true,
|
|
545
|
+
max: true,
|
|
546
|
+
passOnStoreError: true
|
|
547
|
+
};
|
|
548
|
+
const validOptions = Object.keys(optionsMap).concat(
|
|
549
|
+
"draft_polli_ratelimit_headers"
|
|
550
|
+
// not a valid option anymore, but we have a more specific check for this one, so don't warn for it here
|
|
551
|
+
);
|
|
552
|
+
for (const key of Object.keys(passedOptions)) {
|
|
553
|
+
if (!validOptions.includes(key)) {
|
|
554
|
+
throw new ValidationError(
|
|
555
|
+
"ERR_ERL_UNKNOWN_OPTION",
|
|
556
|
+
`Unexpected configuration option: ${key}`
|
|
557
|
+
// todo: suggest a valid option with a short levenstein distance?
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
},
|
|
524
562
|
/**
|
|
525
563
|
* Checks the options.validate setting to ensure that only recognized
|
|
526
564
|
* validations are enabled or disabled.
|
|
527
565
|
*
|
|
528
566
|
* If any unrecognized values are found, an error is logged that
|
|
529
|
-
* includes the list of supported
|
|
567
|
+
* includes the list of supported validations.
|
|
530
568
|
*/
|
|
531
569
|
validationsConfig() {
|
|
532
570
|
const supportedValidations = Object.keys(this).filter(
|
|
@@ -696,6 +734,7 @@ var parseOptions = (passedOptions) => {
|
|
|
696
734
|
const notUndefinedOptions = omitUndefinedProperties(passedOptions);
|
|
697
735
|
const validations2 = getValidations(notUndefinedOptions?.validate ?? true);
|
|
698
736
|
validations2.validationsConfig();
|
|
737
|
+
validations2.knownOptions(passedOptions);
|
|
699
738
|
validations2.draftPolliHeaders(
|
|
700
739
|
// @ts-expect-error see the note above.
|
|
701
740
|
notUndefinedOptions.draft_polli_ratelimit_headers
|
package/dist/index.d.cts
CHANGED
|
@@ -132,12 +132,13 @@ declare const validations: {
|
|
|
132
132
|
* @returns {void}
|
|
133
133
|
*/
|
|
134
134
|
headersResetTime(resetTime?: Date): void;
|
|
135
|
+
knownOptions(passedOptions?: Partial<Options>): void;
|
|
135
136
|
/**
|
|
136
137
|
* Checks the options.validate setting to ensure that only recognized
|
|
137
138
|
* validations are enabled or disabled.
|
|
138
139
|
*
|
|
139
140
|
* If any unrecognized values are found, an error is logged that
|
|
140
|
-
* includes the list of supported
|
|
141
|
+
* includes the list of supported validations.
|
|
141
142
|
*/
|
|
142
143
|
validationsConfig(): void;
|
|
143
144
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -132,12 +132,13 @@ declare const validations: {
|
|
|
132
132
|
* @returns {void}
|
|
133
133
|
*/
|
|
134
134
|
headersResetTime(resetTime?: Date): void;
|
|
135
|
+
knownOptions(passedOptions?: Partial<Options>): void;
|
|
135
136
|
/**
|
|
136
137
|
* Checks the options.validate setting to ensure that only recognized
|
|
137
138
|
* validations are enabled or disabled.
|
|
138
139
|
*
|
|
139
140
|
* If any unrecognized values are found, an error is logged that
|
|
140
|
-
* includes the list of supported
|
|
141
|
+
* includes the list of supported validations.
|
|
141
142
|
*/
|
|
142
143
|
validationsConfig(): void;
|
|
143
144
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -132,12 +132,13 @@ declare const validations: {
|
|
|
132
132
|
* @returns {void}
|
|
133
133
|
*/
|
|
134
134
|
headersResetTime(resetTime?: Date): void;
|
|
135
|
+
knownOptions(passedOptions?: Partial<Options>): void;
|
|
135
136
|
/**
|
|
136
137
|
* Checks the options.validate setting to ensure that only recognized
|
|
137
138
|
* validations are enabled or disabled.
|
|
138
139
|
*
|
|
139
140
|
* If any unrecognized values are found, an error is logged that
|
|
140
|
-
* includes the list of supported
|
|
141
|
+
* includes the list of supported validations.
|
|
141
142
|
*/
|
|
142
143
|
validationsConfig(): void;
|
|
143
144
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -492,12 +492,50 @@ var validations = {
|
|
|
492
492
|
);
|
|
493
493
|
}
|
|
494
494
|
},
|
|
495
|
+
knownOptions(passedOptions) {
|
|
496
|
+
if (!passedOptions) return;
|
|
497
|
+
const optionsMap = {
|
|
498
|
+
windowMs: true,
|
|
499
|
+
limit: true,
|
|
500
|
+
message: true,
|
|
501
|
+
statusCode: true,
|
|
502
|
+
legacyHeaders: true,
|
|
503
|
+
standardHeaders: true,
|
|
504
|
+
identifier: true,
|
|
505
|
+
requestPropertyName: true,
|
|
506
|
+
skipFailedRequests: true,
|
|
507
|
+
skipSuccessfulRequests: true,
|
|
508
|
+
keyGenerator: true,
|
|
509
|
+
ipv6Subnet: true,
|
|
510
|
+
handler: true,
|
|
511
|
+
skip: true,
|
|
512
|
+
requestWasSuccessful: true,
|
|
513
|
+
store: true,
|
|
514
|
+
validate: true,
|
|
515
|
+
headers: true,
|
|
516
|
+
max: true,
|
|
517
|
+
passOnStoreError: true
|
|
518
|
+
};
|
|
519
|
+
const validOptions = Object.keys(optionsMap).concat(
|
|
520
|
+
"draft_polli_ratelimit_headers"
|
|
521
|
+
// not a valid option anymore, but we have a more specific check for this one, so don't warn for it here
|
|
522
|
+
);
|
|
523
|
+
for (const key of Object.keys(passedOptions)) {
|
|
524
|
+
if (!validOptions.includes(key)) {
|
|
525
|
+
throw new ValidationError(
|
|
526
|
+
"ERR_ERL_UNKNOWN_OPTION",
|
|
527
|
+
`Unexpected configuration option: ${key}`
|
|
528
|
+
// todo: suggest a valid option with a short levenstein distance?
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
},
|
|
495
533
|
/**
|
|
496
534
|
* Checks the options.validate setting to ensure that only recognized
|
|
497
535
|
* validations are enabled or disabled.
|
|
498
536
|
*
|
|
499
537
|
* If any unrecognized values are found, an error is logged that
|
|
500
|
-
* includes the list of supported
|
|
538
|
+
* includes the list of supported validations.
|
|
501
539
|
*/
|
|
502
540
|
validationsConfig() {
|
|
503
541
|
const supportedValidations = Object.keys(this).filter(
|
|
@@ -667,6 +705,7 @@ var parseOptions = (passedOptions) => {
|
|
|
667
705
|
const notUndefinedOptions = omitUndefinedProperties(passedOptions);
|
|
668
706
|
const validations2 = getValidations(notUndefinedOptions?.validate ?? true);
|
|
669
707
|
validations2.validationsConfig();
|
|
708
|
+
validations2.knownOptions(passedOptions);
|
|
670
709
|
validations2.draftPolliHeaders(
|
|
671
710
|
// @ts-expect-error see the note above.
|
|
672
711
|
notUndefinedOptions.draft_polli_ratelimit_headers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-rate-limit",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.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",
|
|
@@ -77,29 +77,29 @@
|
|
|
77
77
|
"express": ">= 4.11"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@biomejs/biome": "2.
|
|
80
|
+
"@biomejs/biome": "2.3.1",
|
|
81
81
|
"@express-rate-limit/prettier": "1.1.1",
|
|
82
82
|
"@express-rate-limit/tsconfig": "1.0.2",
|
|
83
|
-
"@jest/globals": "30.
|
|
84
|
-
"@types/express": "5.0.
|
|
83
|
+
"@jest/globals": "30.2.0",
|
|
84
|
+
"@types/express": "5.0.4",
|
|
85
85
|
"@types/jest": "30.0.0",
|
|
86
|
-
"@types/node": "24.
|
|
86
|
+
"@types/node": "24.9.1",
|
|
87
87
|
"@types/supertest": "6.0.3",
|
|
88
88
|
"del-cli": "6.0.0",
|
|
89
89
|
"dts-bundle-generator": "8.1.2",
|
|
90
|
-
"esbuild": "0.25.
|
|
90
|
+
"esbuild": "0.25.11",
|
|
91
91
|
"express": "5.1.0",
|
|
92
92
|
"husky": "9.1.7",
|
|
93
|
-
"jest": "30.
|
|
94
|
-
"lint-staged": "16.
|
|
95
|
-
"mintlify": "4.2.
|
|
93
|
+
"jest": "30.2.0",
|
|
94
|
+
"lint-staged": "16.2.6",
|
|
95
|
+
"mintlify": "4.2.179",
|
|
96
96
|
"npm-run-all": "4.1.5",
|
|
97
97
|
"prettier": "3.6.2",
|
|
98
98
|
"ratelimit-header-parser": "0.1.0",
|
|
99
99
|
"supertest": "7.1.4",
|
|
100
|
-
"ts-jest": "29.4.
|
|
100
|
+
"ts-jest": "29.4.5",
|
|
101
101
|
"ts-node": "10.9.2",
|
|
102
|
-
"typescript": "5.9.
|
|
102
|
+
"typescript": "5.9.3"
|
|
103
103
|
},
|
|
104
104
|
"prettier": "@express-rate-limit/prettier",
|
|
105
105
|
"lint-staged": {
|