nestjs-ip-filter 0.1.0 → 0.1.3

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.
Files changed (3) hide show
  1. package/README.md +11 -6
  2. package/package.json +30 -30
  3. package/renovate.json +10 -0
package/README.md CHANGED
@@ -4,6 +4,8 @@ Now we can filter the incoming requests by setting the whitelist and the blackli
4
4
 
5
5
  It will work using the built-in feature in NestJS, **Guard**, so it works like a charm as it should be and as much as it should do.
6
6
 
7
+ The Guard recognizes the requester's IP address using [@supercharge/request-ip](https://www.npmjs.com/package/request-ip) package.
8
+
7
9
  ## How to install
8
10
 
9
11
  Simply, install using NPM by the following command.
@@ -16,7 +18,10 @@ npm install nestjs-ip-filter
16
18
 
17
19
  ### Use Regex for the IP list
18
20
 
19
- You can use Regex format string for the IP ranges.
21
+ > In Express-based framework, the incoming IP address will have prefix `::ffff:` characters. So if you have put `(^192.168.)` into the whitelist, it won't work because that regex describes it must have number `1` as a first character.
22
+ > So for now, you should put that prefix for your regex string like `(^::ffff:192.168.)`. Will patch the source codes in the near future.
23
+
24
+ You can use the Regex format string for the IP ranges.
20
25
 
21
26
  For a simple example, if you want to allow the private network hosts in `192.168.0.1/16`, you can write the Regex string like the below.
22
27
 
@@ -38,13 +43,13 @@ Check the other use cases.
38
43
  (^11[0-9].*)
39
44
  ```
40
45
 
41
- And, writing in this way also works on this pacakge.
46
+ And, writing in this way also works on this package.
42
47
 
43
48
  But be aware of that you should write the Regex string very carefully to avoid allowing unwanted incoming IP addresses.
44
49
 
45
- ### Baisc usage for Whitelist
50
+ ### Basic usage for Whitelist
46
51
 
47
- You can initialize the dedicated Guard using non-async or async mode, as like the other NestJS packages support.
52
+ You can initialize the dedicated Guard using non-async or async mode, as the other NestJS packages support.
48
53
 
49
54
  Use `forRoot` for the static IP address list.
50
55
 
@@ -81,7 +86,7 @@ After setting up the `IpFilter` module with the `forRoot*` method, this will acc
81
86
 
82
87
  You can deny the requests that are from the blacklist IPs.
83
88
 
84
- Use `blacklist` option to let the Guart know the list.
89
+ Use `blacklist` option to let the Guard know the list.
85
90
 
86
91
  ```typescript
87
92
  // If it would like to get the whitelist IPs from a config file,
@@ -128,7 +133,7 @@ When the Guard throws an exception, it will also carry some informative data lik
128
133
 
129
134
  ### Inject IpFilterService
130
135
 
131
- If you want, you can inject `IpFilterService` into your code and can see current options you put when you initilize it. And, you can set the whitelist and the blacklist too.
136
+ If you want, you can inject `IpFilterService` into your code and can see current options you put when you initialize it. And, you can set the whitelist and the blacklist too.
132
137
 
133
138
  Inject the service using the `IPFILTER_TOKEN` module.
134
139
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nestjs-ip-filter",
3
- "version": "0.1.0",
3
+ "version": "0.1.3",
4
4
  "description": "A NestJS Guard for filtering IP addresses",
5
5
  "author": "Deokgyu Yang <secugyu@gmail.com>",
6
6
  "keywords": [
@@ -34,37 +34,37 @@
34
34
  "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand"
35
35
  },
36
36
  "dependencies": {
37
- "@nestjs/common": "^8.1.1",
38
- "@nestjs/core": "^8.1.1",
39
- "@nestjs/platform-express": "^8.1.1",
40
- "@supercharge/request-ip": "^1.2.0",
41
- "reflect-metadata": "^0.1.13",
42
- "rimraf": "^3.0.2",
43
- "rxjs": "^7.4.0"
37
+ "@nestjs/common": "8.4.7",
38
+ "@nestjs/core": "8.4.7",
39
+ "@nestjs/platform-express": "8.4.7",
40
+ "@supercharge/request-ip": "1.2.0",
41
+ "reflect-metadata": "0.1.13",
42
+ "rimraf": "3.0.2",
43
+ "rxjs": "7.5.5"
44
44
  },
45
45
  "devDependencies": {
46
- "@nestjs/cli": "^8.1.3",
47
- "@nestjs/schematics": "^8.0.4",
48
- "@nestjs/testing": "^8.1.1",
49
- "@types/express": "^4.17.13",
50
- "@types/jest": "^27.0.2",
51
- "@types/node": "^16.11.1",
52
- "@types/supertest": "^2.0.11",
53
- "@typescript-eslint/eslint-plugin": "^5.28.0",
54
- "@typescript-eslint/parser": "^5.28.0",
55
- "eslint": "^8.17.0",
56
- "eslint-config-google": "^0.14.0",
57
- "eslint-config-prettier": "^8.3.0",
58
- "eslint-plugin-prettier": "^3.4.1",
59
- "jest": "^27.3.0",
60
- "prettier": "^2.4.1",
61
- "source-map-support": "^0.5.20",
62
- "supertest": "^6.1.6",
63
- "ts-jest": "^27.0.7",
64
- "ts-loader": "^9.2.6",
65
- "ts-node": "^10.3.0",
66
- "tsconfig-paths": "^3.11.0",
67
- "typescript": "^4.4.4"
46
+ "@nestjs/cli": "8.2.6",
47
+ "@nestjs/schematics": "8.0.11",
48
+ "@nestjs/testing": "8.4.7",
49
+ "@types/express": "4.17.13",
50
+ "@types/jest": "28.1.3",
51
+ "@types/node": "16.11.41",
52
+ "@types/supertest": "2.0.12",
53
+ "@typescript-eslint/eslint-plugin": "5.29.0",
54
+ "@typescript-eslint/parser": "5.29.0",
55
+ "eslint": "8.18.0",
56
+ "eslint-config-google": "0.14.0",
57
+ "eslint-config-prettier": "8.5.0",
58
+ "eslint-plugin-prettier": "4.0.0",
59
+ "jest": "28.1.1",
60
+ "prettier": "2.7.1",
61
+ "source-map-support": "0.5.21",
62
+ "supertest": "6.2.3",
63
+ "ts-jest": "28.0.5",
64
+ "ts-loader": "9.3.1",
65
+ "ts-node": "10.8.1",
66
+ "tsconfig-paths": "4.0.0",
67
+ "typescript": "4.7.4"
68
68
  },
69
69
  "jest": {
70
70
  "moduleFileExtensions": [
package/renovate.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "packageRules": [{
3
+ "depTypeList": ["devDependencies"],
4
+ "automerge": true,
5
+ "ignoreTests": true
6
+ }],
7
+ "extends": [
8
+ "config:base"
9
+ ]
10
+ }