Arcjet utilities for finding the originating IP of a request.
Installation
npm install -S @arcjet/ip
Example
import ip from"@arcjet/ip";
// Some Request-like object, such as node's `http.IncomingMessage` or next.js'// `NextRequest`const request = newNextRequest();
// A `Headers` object, which is passed separately for cases where it needs to be// constructed or sanitizedconst headers = newHeaders();
// Returns the first non-private IP address detectedconst globalIp = ip(request, headers);
console.log(globalIp);
Considerations
The IP should not be trusted as it can be spoofed in most cases, especially when
loaded via the Headers object.
In non-production environments (NODE_ENV !== "production"), we allow
private/internal addresses so that the SDKs work correctly locally.
We've chosen the approach of porting Rust's IP Parser because capturing RegExps
can be the source of ReDoS attacks, which we need to avoid. We also wanted to
keep our implementation as close to Rust as possible because we will be relying
on the Rust stdlib implementation in the future, with a fallback to this
implementation. As such, we'll need to track changes in Rust's implementation,
even though it seems to change infrequently.
bump @typescript-eslint/eslint-plugin from 7.16.1 to 7.17.0 (#1164) (06344e7)
bump @typescript-eslint/parser from 7.16.1 to 7.17.0 (#1165) (40adc5b)
bump eslint-config-turbo from 2.0.6 to 2.0.9 (#1159) (1e7a59f)
dev: bump @rollup/wasm-node from 4.18.1 to 4.19.0 (#1160) (7062ca0)
dev: bump typescript from 5.5.3 to 5.5.4 (#1166) (644e3a6)
example: bump @clerk/nextjs from 5.2.5 to 5.2.6 in /examples/nextjs-14-permit in the dependencies group (#1173) (2dd29a7)
example: bump hono from 4.4.13 to 4.5.1 in /examples/nodejs-hono-rl in the dependencies group across 1 directory (#1158) (797d8b8)
example: bump postcss from 8.4.39 to 8.4.40 in /examples/nextjs-14-app-dir-validate-email in the dependencies group (#1177) (926f84e)
example: bump postcss from 8.4.39 to 8.4.40 in /examples/nextjs-14-clerk-rl in the dependencies group across 1 directory (#1180) (47b6e7d)
example: bump tailwindcss from 3.4.4 to 3.4.6 in /examples/nextjs-14-app-dir-validate-email in the dependencies group across 1 directory (#1139) (ee1938b)
example: bump tailwindcss from 3.4.5 to 3.4.6 in /examples/nextjs-14-app-dir-rl in the dependencies group (#1152) (282448a)
example: bump tailwindcss from 3.4.5 to 3.4.6 in /examples/nextjs-14-decorate in the dependencies group (#1148) (1149de9)
example: bump tailwindcss from 3.4.5 to 3.4.6 in /examples/nextjs-14-ip-details in the dependencies group (#1147) (c77aa6b)
example: bump tailwindcss from 3.4.5 to 3.4.6 in /examples/nextjs-14-nextauth-4 in the dependencies group (#1145) (a97525b)
example: bump tailwindcss from 3.4.5 to 3.4.6 in /examples/nextjs-14-pages-wrap in the dependencies group (#1151) (d9291c6)
example: bump the dependencies group across 1 directory with 2 updates (#1171) (e2bfd35)
example: bump the dependencies group across 1 directory with 2 updates (#1179) (1240621)
example: bump the dependencies group across 1 directory with 3 updates (#1163) (213a7c8)
example: bump the dependencies group across 1 directory with 3 updates (#1178) (9bc5f1e)
example: bump the dependencies group across 1 directory with 3 updates (#1181) (f01ec2c)
example: bump the dependencies group across 1 directory with 5 updates (#1167) (f3c8ca7)
example: bump the dependencies group across 1 directory with 6 updates (#1169) (a02a74c)
🧹 Miscellaneous Chores
examples: Add Next.js app with Permit.io for dynamic Arcjet rules (#1067) (6939878)
FAQs
Arcjet utilities for finding the originating IP of a request
We found that @arcjet/ip demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 0 open source maintainers collaborating on the project.
Package last updated on 07 Dec 2023
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.