@arcjet/astro 1.0.0-beta.15 → 1.0.0-beta.17
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/index.d.ts +3 -3
- package/index.js +15 -0
- package/internal.js +15 -25
- package/package.json +16 -15
package/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ type IntegrationRule<Characteristics extends readonly string[]> = {
|
|
|
14
14
|
options: FilterOptions;
|
|
15
15
|
} | {
|
|
16
16
|
type: "sensitiveInfo";
|
|
17
|
-
options: SensitiveInfoOptions<
|
|
17
|
+
options: SensitiveInfoOptions<undefined>;
|
|
18
18
|
} | {
|
|
19
19
|
type: "fixedWindow";
|
|
20
20
|
options: FixedWindowRateLimitOptions<Characteristics>;
|
|
@@ -34,7 +34,7 @@ type IntegrationRule<Characteristics extends readonly string[]> = {
|
|
|
34
34
|
* @template Characteristics
|
|
35
35
|
* Characteristics to track a user by.
|
|
36
36
|
*/
|
|
37
|
-
type
|
|
37
|
+
export type ArcjetOptions<Characteristics extends readonly string[]> = {
|
|
38
38
|
/**
|
|
39
39
|
* Integration rules to apply when protecting a request (required).
|
|
40
40
|
*
|
|
@@ -326,5 +326,5 @@ export declare function createRemoteClient(options?: RemoteClientOptions | undef
|
|
|
326
326
|
* @returns
|
|
327
327
|
* Astro integration of Arcjet.
|
|
328
328
|
*/
|
|
329
|
-
export default function arcjet<Characteristics extends readonly string[]>(options?:
|
|
329
|
+
export default function arcjet<Characteristics extends readonly string[]>(options?: ArcjetOptions<Characteristics>): AstroIntegration;
|
|
330
330
|
export {};
|
package/index.js
CHANGED
|
@@ -514,6 +514,21 @@ function arcjet(options = { rules: [] }) {
|
|
|
514
514
|
access: "public",
|
|
515
515
|
optional: true,
|
|
516
516
|
},
|
|
517
|
+
FIREBASE_CONFIG: {
|
|
518
|
+
access: "public",
|
|
519
|
+
context: "server",
|
|
520
|
+
optional: true,
|
|
521
|
+
type: "string",
|
|
522
|
+
},
|
|
523
|
+
// No `MODE`, that is a vite value on `import.meta.env.MODE`,
|
|
524
|
+
// it is inferred in `internal.ts` directly.
|
|
525
|
+
// No `NODE_ENV`.
|
|
526
|
+
RENDER: {
|
|
527
|
+
access: "public",
|
|
528
|
+
context: "server",
|
|
529
|
+
optional: true,
|
|
530
|
+
type: "string",
|
|
531
|
+
},
|
|
517
532
|
},
|
|
518
533
|
},
|
|
519
534
|
vite: {
|
package/internal.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import core__default from 'arcjet';
|
|
2
2
|
export * from 'arcjet';
|
|
3
|
+
import { readBodyWeb } from '@arcjet/body';
|
|
3
4
|
import findIp, { parseProxy } from '@arcjet/ip';
|
|
4
5
|
import { ArcjetHeaders } from '@arcjet/headers';
|
|
5
6
|
import { baseUrl, isDevelopment, logLevel, platform } from '@arcjet/env';
|
|
6
7
|
import { Logger } from '@arcjet/logger';
|
|
7
8
|
import { createClient } from '@arcjet/protocol/client.js';
|
|
8
9
|
import { createTransport } from '@arcjet/transport';
|
|
9
|
-
import { VERCEL, FLY_APP_NAME, ARCJET_LOG_LEVEL, ARCJET_KEY, ARCJET_ENV, ARCJET_BASE_URL } from 'astro:env/server';
|
|
10
|
+
import { VERCEL, RENDER, FLY_APP_NAME, FIREBASE_CONFIG, ARCJET_LOG_LEVEL, ARCJET_KEY, ARCJET_ENV, ARCJET_BASE_URL } from 'astro:env/server';
|
|
10
11
|
|
|
11
12
|
// We use a middleware to store the IP address on a `Request` with this symbol.
|
|
12
13
|
// This is due to Astro inconsistently using `Symbol.for("astro.clientAddress")`
|
|
@@ -17,25 +18,13 @@ const env = {
|
|
|
17
18
|
ARCJET_ENV,
|
|
18
19
|
ARCJET_KEY,
|
|
19
20
|
ARCJET_LOG_LEVEL,
|
|
21
|
+
FIREBASE_CONFIG,
|
|
20
22
|
FLY_APP_NAME,
|
|
21
|
-
VERCEL,
|
|
22
23
|
// `MODE` is only set on `import.meta.env`.
|
|
23
24
|
MODE: import.meta.env.MODE,
|
|
25
|
+
RENDER,
|
|
26
|
+
VERCEL,
|
|
24
27
|
};
|
|
25
|
-
// TODO: Deduplicate with other packages
|
|
26
|
-
function errorMessage(err) {
|
|
27
|
-
if (err) {
|
|
28
|
-
if (typeof err === "string") {
|
|
29
|
-
return err;
|
|
30
|
-
}
|
|
31
|
-
if (typeof err === "object" &&
|
|
32
|
-
"message" in err &&
|
|
33
|
-
typeof err.message === "string") {
|
|
34
|
-
return err.message;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return "Unknown problem";
|
|
38
|
-
}
|
|
39
28
|
/**
|
|
40
29
|
* Create a remote client.
|
|
41
30
|
*
|
|
@@ -50,7 +39,7 @@ function createRemoteClient(options) {
|
|
|
50
39
|
// Transport is the HTTP client that the client uses to make requests.
|
|
51
40
|
const transport = createTransport(url);
|
|
52
41
|
const sdkStack = "ASTRO";
|
|
53
|
-
const sdkVersion = "1.0.0-beta.
|
|
42
|
+
const sdkVersion = "1.0.0-beta.17";
|
|
54
43
|
return createClient({
|
|
55
44
|
transport,
|
|
56
45
|
baseUrl: url,
|
|
@@ -132,16 +121,17 @@ function createArcjetClient(options) {
|
|
|
132
121
|
// the definition of `props` in the signature but it's hard to track down
|
|
133
122
|
const req = toArcjetRequest(request, props ?? {});
|
|
134
123
|
const getBody = async () => {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
124
|
+
const clonedRequest = request.clone();
|
|
125
|
+
let expectedLength;
|
|
126
|
+
const expectedLengthString = request.headers.get("content-length");
|
|
127
|
+
if (typeof expectedLengthString === "string") {
|
|
128
|
+
expectedLength = parseInt(expectedLengthString, 10);
|
|
140
129
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
130
|
+
// HEAD and GET requests do not have a body.
|
|
131
|
+
if (!clonedRequest.body) {
|
|
132
|
+
throw new Error("Cannot read body: body is missing");
|
|
144
133
|
}
|
|
134
|
+
return readBodyWeb(clonedRequest.body, { expectedLength });
|
|
145
135
|
};
|
|
146
136
|
return aj.protect({ getBody }, req);
|
|
147
137
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcjet/astro",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.17",
|
|
4
4
|
"description": "Arcjet helps developers protect their Astro sites in just a few lines of code. Bot detection. Rate limiting. Email validation. Attack protection. Data redaction. A developer-first approach to security.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"analyze",
|
|
@@ -47,28 +47,29 @@
|
|
|
47
47
|
"build": "rollup --config rollup.config.js",
|
|
48
48
|
"lint": "eslint .",
|
|
49
49
|
"prepublishOnly": "npm run build",
|
|
50
|
-
"test-api": "node --test",
|
|
51
|
-
"test-coverage": "node --experimental-test-coverage --test",
|
|
50
|
+
"test-api": "node --test -- test/*.test.js",
|
|
51
|
+
"test-coverage": "node --experimental-test-coverage --test -- test/*.test.js",
|
|
52
52
|
"test": "npm run build && npm run lint && npm run test-coverage"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@arcjet/
|
|
56
|
-
"@arcjet/
|
|
57
|
-
"@arcjet/
|
|
58
|
-
"@arcjet/
|
|
59
|
-
"@arcjet/
|
|
60
|
-
"@arcjet/
|
|
61
|
-
"arcjet": "1.0.0-beta.
|
|
55
|
+
"@arcjet/body": "1.0.0-beta.17",
|
|
56
|
+
"@arcjet/env": "1.0.0-beta.17",
|
|
57
|
+
"@arcjet/headers": "1.0.0-beta.17",
|
|
58
|
+
"@arcjet/ip": "1.0.0-beta.17",
|
|
59
|
+
"@arcjet/logger": "1.0.0-beta.17",
|
|
60
|
+
"@arcjet/protocol": "1.0.0-beta.17",
|
|
61
|
+
"@arcjet/transport": "1.0.0-beta.17",
|
|
62
|
+
"arcjet": "1.0.0-beta.17"
|
|
62
63
|
},
|
|
63
64
|
"peerDependencies": {
|
|
64
65
|
"astro": "^5.9.3"
|
|
65
66
|
},
|
|
66
67
|
"devDependencies": {
|
|
67
|
-
"@arcjet/eslint-config": "1.0.0-beta.
|
|
68
|
-
"@arcjet/rollup-config": "1.0.0-beta.
|
|
69
|
-
"@rollup/wasm-node": "4.
|
|
70
|
-
"astro": "5.
|
|
71
|
-
"eslint": "9.
|
|
68
|
+
"@arcjet/eslint-config": "1.0.0-beta.17",
|
|
69
|
+
"@arcjet/rollup-config": "1.0.0-beta.17",
|
|
70
|
+
"@rollup/wasm-node": "4.55.1",
|
|
71
|
+
"astro": "5.16.6",
|
|
72
|
+
"eslint": "9.39.2",
|
|
72
73
|
"typescript": "5.9.3"
|
|
73
74
|
},
|
|
74
75
|
"publishConfig": {
|