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.
dev: Bump bun-types from 1.1.12 to 1.1.13 (#947) (bbf996d)
example: Bump braces from 3.0.2 to 3.0.3 in /examples/nextjs-14-app-dir-rl (#962) (3ef130f)
example: Bump braces from 3.0.2 to 3.0.3 in /examples/nextjs-14-app-dir-validate-email (#961) (05c8aed)
example: Bump braces from 3.0.2 to 3.0.3 in /examples/nextjs-14-authjs-5 (#959) (9af5c16)
example: Bump braces from 3.0.2 to 3.0.3 in /examples/nextjs-14-clerk-rl (#949) (2a3a919)
example: Bump braces from 3.0.2 to 3.0.3 in /examples/nextjs-14-clerk-shield (#957) (18c5068)
example: Bump braces from 3.0.2 to 3.0.3 in /examples/nextjs-14-decorate (#952) (3077d96)
example: Bump braces from 3.0.2 to 3.0.3 in /examples/nextjs-14-ip-details (#956) (466c6d6)
example: Bump braces from 3.0.2 to 3.0.3 in /examples/nextjs-14-nextauth-4 (#951) (c6270dd)
example: Bump braces from 3.0.2 to 3.0.3 in /examples/nextjs-14-openai (#955) (cc46877)
example: Bump braces from 3.0.2 to 3.0.3 in /examples/nextjs-14-pages-wrap (#953) (6449d0d)
example: Bump braces from 3.0.2 to 3.0.3 in /examples/nextjs-14-react-hook-form (#958) (3cc0ae7)
example: Bump hono from 4.4.4 to 4.4.5 in /examples/nodejs-hono-rl in the dependencies group (#923) (8458fe8)
example: Bump next from 14.2.3 to 14.2.4 in /examples/nextjs-14-authjs-5 in the dependencies group (#940) (4a1e3c1)
example: Bump prettier from 3.3.1 to 3.3.2 in /examples/sveltekit in the dependencies group (#926) (30e03ad)
example: Bump the dependencies group across 1 directory with 3 updates (#943) (8e84ab6)
example: Bump the dependencies group across 1 directory with 3 updates (#960) (12c541c)
example: Bump the dependencies group across 1 directory with 3 updates (#963) (37f387c)
example: Bump the dependencies group across 1 directory with 4 updates (#946) (71fcc86)
example: Bump the dependencies group in /examples/nextjs-14-app-dir-rl with 2 updates (#937) (9384f4e)
example: Bump the dependencies group in /examples/nextjs-14-app-dir-validate-email with 2 updates (#944) (6b6fe28)
example: Bump the dependencies group in /examples/nextjs-14-decorate with 2 updates (#938) (8c31888)
example: Bump the dependencies group in /examples/nextjs-14-ip-details with 2 updates (#936) (0cb5ed7)
example: Bump the dependencies group in /examples/nextjs-14-nextauth-4 with 2 updates (#942) (00d32d1)
example: Bump the dependencies group in /examples/nextjs-14-pages-wrap with 2 updates (#935) (78f1a31)
🧹 Miscellaneous Chores
deps-dev: Bump braces from 3.0.2 to 3.0.3 in /examples/nodejs-nestjs (#950) (eb4efc1)
Fix typo in the release-please config (#966) (4e67890)
Freeze the ArcjetContext before using it (#934) (6720504)
Link the versions of our new packages (#965) (6d20dfc)
Move client into protocol and rename builders in adapters (#932) (ea1c2b2)
Remove logger dependency from core (#929) (8c15961)
Remove rateLimit alias for fixedWindow rule (#964) (320d67c)
rollup-config: Allow more builtins to avoid warnings (#933) (2d6f4a0)
FAQs
Arcjet utilities for finding the originating IP of a request
The npm package @arcjet/ip receives a total of 1,681 weekly downloads. As such, @arcjet/ip popularity was classified as popular.
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 2 open source maintainers collaborating on the project.
Package last updated on 12 Jun 2024
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.
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.