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.
transport: Reduce idle timeout for AWS Global Accelerator (#1479) (cd1df38)
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 02 Sep 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.