@arcjet/bun 1.0.0-beta.14 → 1.0.0-beta.16
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/README.md +9 -0
- package/index.js +14 -9
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -95,6 +95,15 @@ export default {
|
|
|
95
95
|
For more on how to configure Arcjet with Bun and how to protect Bun,
|
|
96
96
|
see the [Arcjet Bun SDK reference][arcjet-reference-bun] on our website.
|
|
97
97
|
|
|
98
|
+
## Test
|
|
99
|
+
|
|
100
|
+
This monorepo is tested with Node.js but this package targets Bun.
|
|
101
|
+
Run the tests from this package folder with:
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
bun test
|
|
105
|
+
```
|
|
106
|
+
|
|
98
107
|
## License
|
|
99
108
|
|
|
100
109
|
[Apache License, Version 2.0][apache-license] © [Arcjet Labs, Inc.][arcjet]
|
package/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as core from 'arcjet';
|
|
1
2
|
import core__default from 'arcjet';
|
|
2
3
|
export * from 'arcjet';
|
|
3
4
|
import findIp, { parseProxy } from '@arcjet/ip';
|
|
@@ -37,7 +38,7 @@ function createRemoteClient(options) {
|
|
|
37
38
|
// Transport is the HTTP client that the client uses to make requests.
|
|
38
39
|
const transport = createTransport(url);
|
|
39
40
|
const sdkStack = "BUN";
|
|
40
|
-
const sdkVersion = "1.0.0-beta.
|
|
41
|
+
const sdkVersion = "1.0.0-beta.16";
|
|
41
42
|
return createClient({
|
|
42
43
|
transport,
|
|
43
44
|
baseUrl: url,
|
|
@@ -72,7 +73,7 @@ function arcjet(options) {
|
|
|
72
73
|
const proxies = Array.isArray(options.proxies)
|
|
73
74
|
? options.proxies.map(parseProxy)
|
|
74
75
|
: undefined;
|
|
75
|
-
if (isDevelopment(
|
|
76
|
+
if (isDevelopment(env)) {
|
|
76
77
|
log.warn("Arcjet will use 127.0.0.1 when missing public IP address in development mode");
|
|
77
78
|
}
|
|
78
79
|
function toArcjetRequest(request, props) {
|
|
@@ -80,13 +81,17 @@ function arcjet(options) {
|
|
|
80
81
|
// We construct an ArcjetHeaders to normalize over Headers
|
|
81
82
|
const headers = new ArcjetHeaders(request.headers);
|
|
82
83
|
const url = new URL(request.url);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
const xArcjetIp = isDevelopment(env)
|
|
85
|
+
? headers.get("x-arcjet-ip")
|
|
86
|
+
: undefined;
|
|
87
|
+
let ip = xArcjetIp ||
|
|
88
|
+
findIp({
|
|
89
|
+
// This attempts to lookup the IP in the `ipCache`. This is primarily a
|
|
90
|
+
// workaround to the API design in Bun that requires access to the
|
|
91
|
+
// `Server` to lookup an IP.
|
|
92
|
+
ip: ipCache.get(request),
|
|
93
|
+
headers,
|
|
94
|
+
}, { platform: platform(env), proxies });
|
|
90
95
|
if (ip === "") {
|
|
91
96
|
// If the `ip` is empty but we're in development mode, we default the IP
|
|
92
97
|
// so the request doesn't fail.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcjet/bun",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.16",
|
|
4
4
|
"description": "Arcjet SDK for Bun",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"analyze",
|
|
@@ -45,20 +45,20 @@
|
|
|
45
45
|
"test": "npm run build && npm run lint"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@arcjet/env": "1.0.0-beta.
|
|
49
|
-
"@arcjet/headers": "1.0.0-beta.
|
|
50
|
-
"@arcjet/ip": "1.0.0-beta.
|
|
51
|
-
"@arcjet/logger": "1.0.0-beta.
|
|
52
|
-
"@arcjet/protocol": "1.0.0-beta.
|
|
53
|
-
"@arcjet/transport": "1.0.0-beta.
|
|
54
|
-
"arcjet": "1.0.0-beta.
|
|
48
|
+
"@arcjet/env": "1.0.0-beta.16",
|
|
49
|
+
"@arcjet/headers": "1.0.0-beta.16",
|
|
50
|
+
"@arcjet/ip": "1.0.0-beta.16",
|
|
51
|
+
"@arcjet/logger": "1.0.0-beta.16",
|
|
52
|
+
"@arcjet/protocol": "1.0.0-beta.16",
|
|
53
|
+
"@arcjet/transport": "1.0.0-beta.16",
|
|
54
|
+
"arcjet": "1.0.0-beta.16"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@arcjet/eslint-config": "1.0.0-beta.
|
|
58
|
-
"@arcjet/rollup-config": "1.0.0-beta.
|
|
59
|
-
"@rollup/wasm-node": "4.
|
|
60
|
-
"bun-types": "1.3.
|
|
61
|
-
"eslint": "9.
|
|
57
|
+
"@arcjet/eslint-config": "1.0.0-beta.16",
|
|
58
|
+
"@arcjet/rollup-config": "1.0.0-beta.16",
|
|
59
|
+
"@rollup/wasm-node": "4.54.0",
|
|
60
|
+
"bun-types": "1.3.5",
|
|
61
|
+
"eslint": "9.39.2",
|
|
62
62
|
"typescript": "5.9.3",
|
|
63
63
|
"undici-types": "7.15.0"
|
|
64
64
|
},
|