
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@arcjet/ip
Advanced tools
@arcjet/ip
Arcjet utilities for finding the originating IP of a request.
npm install -S @arcjet/ip
import ip from "@arcjet/ip";
// Some Request-like object, such as node's `http.IncomingMessage` or next.js'
// `NextRequest`
const request = new NextRequest();
// A `Headers` object, which is passed separately for cases where it needs to be
// constructed or sanitized
const headers = new Headers();
// Returns the first non-private IP address detected
const globalIp = ip(request, headers);
console.log(globalIp);
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.
The implementation of this library is based on the Parser, global ipv4 comparisons, and global ipv6 comparisons in the Rust stdlib and the header lookups in the request-ip package. Both licensed MIT with licenses included in our source code.
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.
Licensed under the Apache License, Version 2.0.
1.0.0-alpha.6 (2023-12-18)
?
if querystring is empty (#71) (16ca958)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 2 open source maintainers collaborating on the project.
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.