express-rate-limit 8.0.1 → 8.0.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/dist/index.cjs CHANGED
@@ -31,8 +31,13 @@ module.exports = __toCommonJS(index_exports);
31
31
  var import_node_net = require("node:net");
32
32
  var import_ip_address = require("ip-address");
33
33
  function ipKeyGenerator(ip, ipv6Subnet = 56) {
34
- if (ipv6Subnet && (0, import_node_net.isIPv6)(ip)) {
35
- return `${new import_ip_address.Address6(`${ip}/${ipv6Subnet}`).startAddress().correctForm()}/${ipv6Subnet}`;
34
+ if ((0, import_node_net.isIPv6)(ip)) {
35
+ const address = new import_ip_address.Address6(ip);
36
+ if (address.is4()) return address.to4().correctForm();
37
+ if (ipv6Subnet) {
38
+ const subnet = new import_ip_address.Address6(`${ip}/${ipv6Subnet}`);
39
+ return `${subnet.startAddress().correctForm()}/${ipv6Subnet}`;
40
+ }
36
41
  }
37
42
  return ip;
38
43
  }
package/dist/index.mjs CHANGED
@@ -2,8 +2,13 @@
2
2
  import { isIPv6 } from "node:net";
3
3
  import { Address6 } from "ip-address";
4
4
  function ipKeyGenerator(ip, ipv6Subnet = 56) {
5
- if (ipv6Subnet && isIPv6(ip)) {
6
- return `${new Address6(`${ip}/${ipv6Subnet}`).startAddress().correctForm()}/${ipv6Subnet}`;
5
+ if (isIPv6(ip)) {
6
+ const address = new Address6(ip);
7
+ if (address.is4()) return address.to4().correctForm();
8
+ if (ipv6Subnet) {
9
+ const subnet = new Address6(`${ip}/${ipv6Subnet}`);
10
+ return `${subnet.startAddress().correctForm()}/${ipv6Subnet}`;
11
+ }
7
12
  }
8
13
  return ip;
9
14
  }
package/package.json CHANGED
@@ -1,112 +1,111 @@
1
1
  {
2
- "name": "express-rate-limit",
3
- "version": "8.0.1",
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
- "author": {
6
- "name": "Nathan Friedly",
7
- "url": "http://nfriedly.com/"
8
- },
9
- "license": "MIT",
10
- "homepage": "https://github.com/express-rate-limit/express-rate-limit",
11
- "repository": {
12
- "type": "git",
13
- "url": "git+https://github.com/express-rate-limit/express-rate-limit.git"
14
- },
15
- "funding": "https://github.com/sponsors/express-rate-limit",
16
- "keywords": [
17
- "express-rate-limit",
18
- "express",
19
- "rate",
20
- "limit",
21
- "ratelimit",
22
- "rate-limit",
23
- "middleware",
24
- "ip",
25
- "auth",
26
- "authorization",
27
- "security",
28
- "brute",
29
- "force",
30
- "bruteforce",
31
- "brute-force",
32
- "attack"
33
- ],
34
- "type": "module",
35
- "exports": {
36
- ".": {
37
- "import": {
38
- "types": "./dist/index.d.mts",
39
- "default": "./dist/index.mjs"
40
- },
41
- "require": {
42
- "types": "./dist/index.d.cts",
43
- "default": "./dist/index.cjs"
44
- }
45
- }
46
- },
47
- "main": "./dist/index.cjs",
48
- "module": "./dist/index.mjs",
49
- "types": "./dist/index.d.ts",
50
- "files": [
51
- "dist/",
52
- "tsconfig.json"
53
- ],
54
- "engines": {
55
- "node": ">= 16"
56
- },
57
- "scripts": {
58
- "clean": "del-cli dist/ coverage/ *.log *.tmp *.bak *.tgz",
59
- "build:cjs": "esbuild --packages=external --platform=node --bundle --target=es2022 --format=cjs --outfile=dist/index.cjs --footer:js=\"module.exports = Object.assign(rateLimit, module.exports);\" source/index.ts",
60
- "build:esm": "esbuild --packages=external --platform=node --bundle --target=es2022 --format=esm --outfile=dist/index.mjs source/index.ts",
61
- "build:types": "dts-bundle-generator --out-file=dist/index.d.ts source/index.ts && cp dist/index.d.ts dist/index.d.cts && cp dist/index.d.ts dist/index.d.mts",
62
- "compile": "run-s clean build:*",
63
- "docs": "cd docs && mintlify dev",
64
- "lint:code": "biome check",
65
- "lint:docs": "prettier --check docs/ *.md",
66
- "lint": "run-s lint:*",
67
- "format:code": "biome check --write",
68
- "format:docs": "prettier --write docs/ *.md",
69
- "format": "run-s format:*",
70
- "test:lib": "jest",
71
- "test:ext": "cd test/external/ && bash run-all-tests",
72
- "test": "run-s lint test:lib",
73
- "pre-commit": "lint-staged",
74
- "prepare": "run-s compile && husky"
75
- },
76
- "peerDependencies": {
77
- "express": ">= 4.11"
78
- },
79
- "devDependencies": {
80
- "@biomejs/biome": "2.1.1",
81
- "@express-rate-limit/prettier": "1.1.1",
82
- "@express-rate-limit/tsconfig": "1.0.2",
83
- "@jest/globals": "30.0.4",
84
- "@types/express": "5.0.3",
85
- "@types/jest": "30.0.0",
86
- "@types/node": "24.0.14",
87
- "@types/supertest": "6.0.3",
88
- "del-cli": "6.0.0",
89
- "dts-bundle-generator": "8.0.1",
90
- "esbuild": "0.25.6",
91
- "express": "5.1.0",
92
- "husky": "9.1.7",
93
- "jest": "30.0.4",
94
- "lint-staged": "16.1.2",
95
- "mintlify": "4.2.15",
96
- "npm-run-all": "4.1.5",
97
- "prettier": "3.6.2",
98
- "ratelimit-header-parser": "0.1.0",
99
- "supertest": "7.1.3",
100
- "ts-jest": "29.4.0",
101
- "ts-node": "10.9.2",
102
- "typescript": "5.8.3"
103
- },
104
- "prettier": "@express-rate-limit/prettier",
105
- "lint-staged": {
106
- "*.{js,ts,json}": "biome check --write",
107
- "*.{md,yaml}": "prettier --write"
108
- },
109
- "dependencies": {
110
- "ip-address": "10.0.1"
111
- }
112
- }
2
+ "name": "express-rate-limit",
3
+ "version": "8.0.2",
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
+ "author": {
6
+ "name": "Nathan Friedly",
7
+ "url": "http://nfriedly.com/"
8
+ },
9
+ "license": "MIT",
10
+ "homepage": "https://github.com/express-rate-limit/express-rate-limit",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/express-rate-limit/express-rate-limit.git"
14
+ },
15
+ "funding": "https://github.com/sponsors/express-rate-limit",
16
+ "keywords": [
17
+ "express-rate-limit",
18
+ "express",
19
+ "rate",
20
+ "limit",
21
+ "ratelimit",
22
+ "rate-limit",
23
+ "middleware",
24
+ "ip",
25
+ "auth",
26
+ "authorization",
27
+ "security",
28
+ "brute",
29
+ "force",
30
+ "bruteforce",
31
+ "brute-force",
32
+ "attack"
33
+ ],
34
+ "type": "module",
35
+ "exports": {
36
+ ".": {
37
+ "import": {
38
+ "types": "./dist/index.d.mts",
39
+ "default": "./dist/index.mjs"
40
+ },
41
+ "require": {
42
+ "types": "./dist/index.d.cts",
43
+ "default": "./dist/index.cjs"
44
+ }
45
+ }
46
+ },
47
+ "main": "./dist/index.cjs",
48
+ "module": "./dist/index.mjs",
49
+ "types": "./dist/index.d.ts",
50
+ "files": [
51
+ "dist/",
52
+ "tsconfig.json"
53
+ ],
54
+ "engines": {
55
+ "node": ">= 16"
56
+ },
57
+ "dependencies": {
58
+ "ip-address": "10.1.0"
59
+ },
60
+ "peerDependencies": {
61
+ "express": ">= 4.11"
62
+ },
63
+ "devDependencies": {
64
+ "@biomejs/biome": "2.1.1",
65
+ "@express-rate-limit/prettier": "1.1.1",
66
+ "@express-rate-limit/tsconfig": "1.0.2",
67
+ "@jest/globals": "30.0.4",
68
+ "@types/express": "5.0.3",
69
+ "@types/jest": "30.0.0",
70
+ "@types/node": "24.0.14",
71
+ "@types/supertest": "6.0.3",
72
+ "del-cli": "6.0.0",
73
+ "dts-bundle-generator": "8.0.1",
74
+ "esbuild": "0.25.6",
75
+ "express": "5.1.0",
76
+ "husky": "9.1.7",
77
+ "jest": "30.0.4",
78
+ "lint-staged": "16.1.2",
79
+ "mintlify": "4.2.15",
80
+ "npm-run-all": "4.1.5",
81
+ "prettier": "3.6.2",
82
+ "ratelimit-header-parser": "0.1.0",
83
+ "supertest": "7.1.3",
84
+ "ts-jest": "29.4.0",
85
+ "ts-node": "10.9.2",
86
+ "typescript": "5.8.3"
87
+ },
88
+ "prettier": "@express-rate-limit/prettier",
89
+ "lint-staged": {
90
+ "*.{js,ts,json}": "biome check --write",
91
+ "*.{md,yaml}": "prettier --write"
92
+ },
93
+ "scripts": {
94
+ "clean": "del-cli dist/ coverage/ *.log *.tmp *.bak *.tgz",
95
+ "build:cjs": "esbuild --packages=external --platform=node --bundle --target=es2022 --format=cjs --outfile=dist/index.cjs --footer:js=\"module.exports = Object.assign(rateLimit, module.exports);\" source/index.ts",
96
+ "build:esm": "esbuild --packages=external --platform=node --bundle --target=es2022 --format=esm --outfile=dist/index.mjs source/index.ts",
97
+ "build:types": "dts-bundle-generator --out-file=dist/index.d.ts source/index.ts && cp dist/index.d.ts dist/index.d.cts && cp dist/index.d.ts dist/index.d.mts",
98
+ "compile": "run-s clean build:*",
99
+ "docs": "cd docs && mintlify dev",
100
+ "lint:code": "biome check",
101
+ "lint:docs": "prettier --check docs/ *.md",
102
+ "lint": "run-s lint:*",
103
+ "format:code": "biome check --write",
104
+ "format:docs": "prettier --write docs/ *.md",
105
+ "format": "run-s format:*",
106
+ "test:lib": "jest",
107
+ "test:ext": "cd test/external/ && bash run-all-tests",
108
+ "test": "run-s lint test:lib",
109
+ "pre-commit": "lint-staged"
110
+ }
111
+ }