express-rate-limit 8.1.0 → 8.2.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/dist/index.cjs CHANGED
@@ -521,12 +521,54 @@ 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
+ // from express-slow-down - https://github.com/express-rate-limit/express-slow-down/blob/main/source/types.ts#L65
552
+ "delayAfter",
553
+ "delayMs",
554
+ "maxDelayMs"
555
+ );
556
+ for (const key of Object.keys(passedOptions)) {
557
+ if (!validOptions.includes(key)) {
558
+ throw new ValidationError(
559
+ "ERR_ERL_UNKNOWN_OPTION",
560
+ `Unexpected configuration option: ${key}`
561
+ // todo: suggest a valid option with a short levenstein distance?
562
+ );
563
+ }
564
+ }
565
+ },
524
566
  /**
525
567
  * Checks the options.validate setting to ensure that only recognized
526
568
  * validations are enabled or disabled.
527
569
  *
528
570
  * If any unrecognized values are found, an error is logged that
529
- * includes the list of supported vaidations.
571
+ * includes the list of supported validations.
530
572
  */
531
573
  validationsConfig() {
532
574
  const supportedValidations = Object.keys(this).filter(
@@ -696,6 +738,7 @@ var parseOptions = (passedOptions) => {
696
738
  const notUndefinedOptions = omitUndefinedProperties(passedOptions);
697
739
  const validations2 = getValidations(notUndefinedOptions?.validate ?? true);
698
740
  validations2.validationsConfig();
741
+ validations2.knownOptions(passedOptions);
699
742
  validations2.draftPolliHeaders(
700
743
  // @ts-expect-error see the note above.
701
744
  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 vaidations.
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 vaidations.
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 vaidations.
141
+ * includes the list of supported validations.
141
142
  */
142
143
  validationsConfig(): void;
143
144
  /**
package/dist/index.mjs CHANGED
@@ -492,12 +492,54 @@ 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
+ // from express-slow-down - https://github.com/express-rate-limit/express-slow-down/blob/main/source/types.ts#L65
523
+ "delayAfter",
524
+ "delayMs",
525
+ "maxDelayMs"
526
+ );
527
+ for (const key of Object.keys(passedOptions)) {
528
+ if (!validOptions.includes(key)) {
529
+ throw new ValidationError(
530
+ "ERR_ERL_UNKNOWN_OPTION",
531
+ `Unexpected configuration option: ${key}`
532
+ // todo: suggest a valid option with a short levenstein distance?
533
+ );
534
+ }
535
+ }
536
+ },
495
537
  /**
496
538
  * Checks the options.validate setting to ensure that only recognized
497
539
  * validations are enabled or disabled.
498
540
  *
499
541
  * If any unrecognized values are found, an error is logged that
500
- * includes the list of supported vaidations.
542
+ * includes the list of supported validations.
501
543
  */
502
544
  validationsConfig() {
503
545
  const supportedValidations = Object.keys(this).filter(
@@ -667,6 +709,7 @@ var parseOptions = (passedOptions) => {
667
709
  const notUndefinedOptions = omitUndefinedProperties(passedOptions);
668
710
  const validations2 = getValidations(notUndefinedOptions?.validate ?? true);
669
711
  validations2.validationsConfig();
712
+ validations2.knownOptions(passedOptions);
670
713
  validations2.draftPolliHeaders(
671
714
  // @ts-expect-error see the note above.
672
715
  notUndefinedOptions.draft_polli_ratelimit_headers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-rate-limit",
3
- "version": "8.1.0",
3
+ "version": "8.2.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",
@@ -77,29 +77,29 @@
77
77
  "express": ">= 4.11"
78
78
  },
79
79
  "devDependencies": {
80
- "@biomejs/biome": "2.2.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.1.2",
84
- "@types/express": "5.0.3",
83
+ "@jest/globals": "30.2.0",
84
+ "@types/express": "5.0.4",
85
85
  "@types/jest": "30.0.0",
86
- "@types/node": "24.3.0",
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.9",
90
+ "esbuild": "0.25.11",
91
91
  "express": "5.1.0",
92
92
  "husky": "9.1.7",
93
- "jest": "30.1.2",
94
- "lint-staged": "16.1.6",
95
- "mintlify": "4.2.94",
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.1",
100
+ "ts-jest": "29.4.5",
101
101
  "ts-node": "10.9.2",
102
- "typescript": "5.9.2"
102
+ "typescript": "5.9.3"
103
103
  },
104
104
  "prettier": "@express-rate-limit/prettier",
105
105
  "lint-staged": {