@arcjet/bun 1.10.0-rc.1 → 1.10.0
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.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -5
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -88,6 +88,8 @@ interface ArcjetBun<Props extends PlainObject> {
|
|
|
88
88
|
*/
|
|
89
89
|
protect(request: Request, ...properties: MaybeProperties<Props & {
|
|
90
90
|
correlationId?: string;
|
|
91
|
+
/** Application-provided client IP address, used instead of automatic detection. */
|
|
92
|
+
ipSrc?: string;
|
|
91
93
|
metadata?: ArcjetMetadata;
|
|
92
94
|
}>): Promise<ArcjetDecision>;
|
|
93
95
|
/**
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { env } from "bun";
|
|
|
10
10
|
export * from "arcjet";
|
|
11
11
|
//#region src/index.ts
|
|
12
12
|
/** SDK version. Updated by the release process. */
|
|
13
|
-
const VERSION = "1.10.0
|
|
13
|
+
const VERSION = "1.10.0";
|
|
14
14
|
let warnedForAutomaticBodyRead = false;
|
|
15
15
|
/**
|
|
16
16
|
* Create a remote client.
|
|
@@ -49,11 +49,12 @@ function arcjet(options) {
|
|
|
49
49
|
const log = options.log ? options.log : new Logger({ level: logLevel(env) });
|
|
50
50
|
const proxies = Array.isArray(options.proxies) ? parseProxies(options.proxies) : void 0;
|
|
51
51
|
if (isDevelopment(env)) log.warn("Arcjet will use 127.0.0.1 when missing public IP address in development mode");
|
|
52
|
-
function toArcjetRequest(request, props) {
|
|
52
|
+
function toArcjetRequest(request, props, ipSrc) {
|
|
53
53
|
const cookies = request.headers.get("cookie") ?? "";
|
|
54
54
|
const headers = new ArcjetHeaders(request.headers);
|
|
55
55
|
const url = new URL(request.url);
|
|
56
|
-
|
|
56
|
+
const xArcjetIp = isDevelopment(env) ? headers.get("x-arcjet-ip") : void 0;
|
|
57
|
+
let ip = ipSrc || xArcjetIp || findIp({
|
|
57
58
|
ip: ipCache.get(request),
|
|
58
59
|
headers
|
|
59
60
|
}, {
|
|
@@ -80,8 +81,8 @@ function arcjet(options) {
|
|
|
80
81
|
return withClient(aj.withRule(rule));
|
|
81
82
|
},
|
|
82
83
|
async protect(request, props) {
|
|
83
|
-
const { correlationId, metadata, ...properties } = props ?? {};
|
|
84
|
-
const req = toArcjetRequest(request, properties || {});
|
|
84
|
+
const { correlationId, ipSrc, metadata, ...properties } = props ?? {};
|
|
85
|
+
const req = toArcjetRequest(request, properties || {}, ipSrc);
|
|
85
86
|
const getBody = async () => {
|
|
86
87
|
if (request.bodyUsed) throw new Error("Cannot read body: already read");
|
|
87
88
|
const clonedRequest = request.clone();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcjet/bun",
|
|
3
|
-
"version": "1.10.0
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Arcjet runtime security SDK for Bun — bot protection, rate limiting, prompt injection detection, PII blocking, and WAF",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -59,14 +59,14 @@
|
|
|
59
59
|
"test": "npm run build"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@arcjet/body": "1.10.0
|
|
63
|
-
"@arcjet/env": "1.10.0
|
|
64
|
-
"@arcjet/headers": "1.10.0
|
|
65
|
-
"@arcjet/ip": "1.10.0
|
|
66
|
-
"@arcjet/logger": "1.10.0
|
|
67
|
-
"@arcjet/protocol": "1.10.0
|
|
68
|
-
"@arcjet/transport": "1.10.0
|
|
69
|
-
"arcjet": "1.10.0
|
|
62
|
+
"@arcjet/body": "1.10.0",
|
|
63
|
+
"@arcjet/env": "1.10.0",
|
|
64
|
+
"@arcjet/headers": "1.10.0",
|
|
65
|
+
"@arcjet/ip": "1.10.0",
|
|
66
|
+
"@arcjet/logger": "1.10.0",
|
|
67
|
+
"@arcjet/protocol": "1.10.0",
|
|
68
|
+
"@arcjet/transport": "1.10.0",
|
|
69
|
+
"arcjet": "1.10.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"bun-types": "1.3.14",
|