@arcjet/astro 1.6.0 → 1.7.0-rc.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.
@@ -1,38 +1,38 @@
1
- import type { BotOptions, DetectPromptInjectionOptions, EmailOptions, FilterOptions, FixedWindowRateLimitOptions, ProtectSignupOptions, SensitiveInfoOptions, ShieldOptions, SlidingWindowRateLimitOptions, TokenBucketRateLimitOptions } from "arcjet";
2
- import type { ProxyService } from "@arcjet/ip";
3
- import type { AstroIntegration } from "astro";
4
- export { cloudflare } from "@arcjet/ip";
5
- export type { ProxyService } from "@arcjet/ip";
1
+ import { ProxyService, ProxyService as ProxyService$1, cloudflare } from "@arcjet/ip";
2
+ import { BotOptions, DetectPromptInjectionOptions, EmailOptions, FilterOptions, FixedWindowRateLimitOptions, ProtectSignupOptions, SensitiveInfoOptions, ShieldOptions, SlidingWindowRateLimitOptions, TokenBucketRateLimitOptions } from "arcjet";
3
+ import { AstroIntegration } from "astro";
4
+
5
+ //#region src/index.d.ts
6
6
  type IntegrationRule<Characteristics extends readonly string[]> = {
7
- type: "shield";
8
- options: ShieldOptions;
7
+ type: "shield";
8
+ options: ShieldOptions;
9
9
  } | {
10
- type: "bot";
11
- options: BotOptions;
10
+ type: "bot";
11
+ options: BotOptions;
12
12
  } | {
13
- type: "email";
14
- options: EmailOptions;
13
+ type: "email";
14
+ options: EmailOptions;
15
15
  } | {
16
- type: "filter";
17
- options: FilterOptions;
16
+ type: "filter";
17
+ options: FilterOptions;
18
18
  } | {
19
- type: "sensitiveInfo";
20
- options: SensitiveInfoOptions<undefined>;
19
+ type: "sensitiveInfo";
20
+ options: SensitiveInfoOptions<undefined>;
21
21
  } | {
22
- type: "fixedWindow";
23
- options: FixedWindowRateLimitOptions<Characteristics>;
22
+ type: "fixedWindow";
23
+ options: FixedWindowRateLimitOptions<Characteristics>;
24
24
  } | {
25
- type: "slidingWindow";
26
- options: SlidingWindowRateLimitOptions<Characteristics>;
25
+ type: "slidingWindow";
26
+ options: SlidingWindowRateLimitOptions<Characteristics>;
27
27
  } | {
28
- type: "tokenBucket";
29
- options: TokenBucketRateLimitOptions<Characteristics>;
28
+ type: "tokenBucket";
29
+ options: TokenBucketRateLimitOptions<Characteristics>;
30
30
  } | {
31
- type: "protectSignup";
32
- options: ProtectSignupOptions<Characteristics>;
31
+ type: "protectSignup";
32
+ options: ProtectSignupOptions<Characteristics>;
33
33
  } | {
34
- type: "detectPromptInjection";
35
- options: DetectPromptInjectionOptions;
34
+ type: "detectPromptInjection";
35
+ options: DetectPromptInjectionOptions;
36
36
  };
37
37
  /**
38
38
  * Configuration for the Astro integration of Arcjet.
@@ -40,33 +40,33 @@ type IntegrationRule<Characteristics extends readonly string[]> = {
40
40
  * @template Characteristics
41
41
  * Characteristics to track a user by.
42
42
  */
43
- export type ArcjetOptions<Characteristics extends readonly string[]> = {
44
- /**
45
- * Integration rules to apply when protecting a request (required).
46
- *
47
- * These rules are *different* from those exposed from `arcjet` core.
48
- * You have to import them from this integration (`@arcjet/astro`) instead.
49
- */
50
- rules: IntegrationRule<Characteristics>[];
51
- /**
52
- * Characteristics to track a user by (default: `["ip.src"]`).
53
- *
54
- * Can also be passed to rules.
55
- */
56
- characteristics?: Characteristics;
57
- /**
58
- * Configuration for the default client (optional).
59
- */
60
- client?: RemoteClientOptions;
61
- /**
62
- * IP addresses and CIDR ranges of trusted load balancers and proxies
63
- * (optional, example: `["100.100.100.100", "100.100.100.0/24"]`).
64
- *
65
- * Proxy services such as {@linkcode cloudflare} can also be included to read
66
- * the real client IP from a service-specific header when the request comes
67
- * from that service.
68
- */
69
- proxies?: Array<string | ProxyService>;
43
+ type ArcjetOptions<Characteristics extends readonly string[]> = {
44
+ /**
45
+ * Integration rules to apply when protecting a request (required).
46
+ *
47
+ * These rules are *different* from those exposed from `arcjet` core.
48
+ * You have to import them from this integration (`@arcjet/astro`) instead.
49
+ */
50
+ rules: IntegrationRule<Characteristics>[];
51
+ /**
52
+ * Characteristics to track a user by (default: `["ip.src"]`).
53
+ *
54
+ * Can also be passed to rules.
55
+ */
56
+ characteristics?: Characteristics;
57
+ /**
58
+ * Configuration for the default client (optional).
59
+ */
60
+ client?: RemoteClientOptions;
61
+ /**
62
+ * IP addresses and CIDR ranges of trusted load balancers and proxies
63
+ * (optional, example: `["100.100.100.100", "100.100.100.0/24"]`).
64
+ *
65
+ * Proxy services such as {@linkcode cloudflare} can also be included to read
66
+ * the real client IP from a service-specific header when the request comes
67
+ * from that service.
68
+ */
69
+ proxies?: Array<string | ProxyService$1>;
70
70
  };
71
71
  /**
72
72
  * Arcjet Shield WAF rule.
@@ -84,9 +84,9 @@ export type ArcjetOptions<Characteristics extends readonly string[]> = {
84
84
  * @returns
85
85
  * Astro integration Shield rule to provide to the SDK in the `rules` field.
86
86
  */
87
- export declare function shield(options: ShieldOptions): {
88
- readonly type: "shield";
89
- readonly options: ShieldOptions;
87
+ declare function shield(options: ShieldOptions): {
88
+ readonly type: "shield";
89
+ readonly options: ShieldOptions;
90
90
  };
91
91
  /**
92
92
  * Arcjet bot detection rule.
@@ -108,9 +108,9 @@ export declare function shield(options: ShieldOptions): {
108
108
  * @returns
109
109
  * Astro integration Bot rule to provide to the SDK in the `rules` field.
110
110
  */
111
- export declare function detectBot(options: BotOptions): {
112
- readonly type: "bot";
113
- readonly options: BotOptions;
111
+ declare function detectBot(options: BotOptions): {
112
+ readonly type: "bot";
113
+ readonly options: BotOptions;
114
114
  };
115
115
  /**
116
116
  * Arcjet email validation rule.
@@ -129,9 +129,9 @@ export declare function detectBot(options: BotOptions): {
129
129
  * @returns
130
130
  * Astro integration Email rule to provide to the SDK in the `rules` field.
131
131
  */
132
- export declare function validateEmail(options: EmailOptions): {
133
- readonly type: "email";
134
- readonly options: EmailOptions;
132
+ declare function validateEmail(options: EmailOptions): {
133
+ readonly type: "email";
134
+ readonly options: EmailOptions;
135
135
  };
136
136
  /**
137
137
  * Arcjet filter rule.
@@ -165,9 +165,9 @@ export declare function validateEmail(options: EmailOptions): {
165
165
  *
166
166
  * @link https://docs.arcjet.com/filters/reference
167
167
  */
168
- export declare function filter(options: FilterOptions): {
169
- readonly type: "filter";
170
- readonly options: FilterOptions;
168
+ declare function filter(options: FilterOptions): {
169
+ readonly type: "filter";
170
+ readonly options: FilterOptions;
171
171
  };
172
172
  /**
173
173
  * Arcjet sensitive information detection rule.
@@ -187,9 +187,9 @@ export declare function filter(options: FilterOptions): {
187
187
  * @returns
188
188
  * Astro integration Sensitive information rule to provide to the SDK in the `rules` field.
189
189
  */
190
- export declare function sensitiveInfo(options: SensitiveInfoOptions<never>): {
191
- readonly type: "sensitiveInfo";
192
- readonly options: SensitiveInfoOptions<never>;
190
+ declare function sensitiveInfo(options: SensitiveInfoOptions<never>): {
191
+ readonly type: "sensitiveInfo";
192
+ readonly options: SensitiveInfoOptions<never>;
193
193
  };
194
194
  /**
195
195
  * Arcjet fixed window rate limiting rule.
@@ -217,9 +217,9 @@ export declare function sensitiveInfo(options: SensitiveInfoOptions<never>): {
217
217
  * @returns
218
218
  * Astro integration Fixed window rule to provide to the SDK in the `rules` field.
219
219
  */
220
- export declare function fixedWindow<Characteristics extends readonly string[]>(options: FixedWindowRateLimitOptions<Characteristics>): {
221
- readonly type: "fixedWindow";
222
- readonly options: FixedWindowRateLimitOptions<Characteristics>;
220
+ declare function fixedWindow<Characteristics extends readonly string[]>(options: FixedWindowRateLimitOptions<Characteristics>): {
221
+ readonly type: "fixedWindow";
222
+ readonly options: FixedWindowRateLimitOptions<Characteristics>;
223
223
  };
224
224
  /**
225
225
  * Arcjet sliding window rate limiting rule.
@@ -240,9 +240,9 @@ export declare function fixedWindow<Characteristics extends readonly string[]>(o
240
240
  * @returns
241
241
  * Astro integration Sliding window rule to provide to the SDK in the `rules` field.
242
242
  */
243
- export declare function slidingWindow<Characteristics extends readonly string[]>(options: SlidingWindowRateLimitOptions<Characteristics>): {
244
- readonly type: "slidingWindow";
245
- readonly options: SlidingWindowRateLimitOptions<Characteristics>;
243
+ declare function slidingWindow<Characteristics extends readonly string[]>(options: SlidingWindowRateLimitOptions<Characteristics>): {
244
+ readonly type: "slidingWindow";
245
+ readonly options: SlidingWindowRateLimitOptions<Characteristics>;
246
246
  };
247
247
  /**
248
248
  * Arcjet token bucket rate limiting rule.
@@ -264,9 +264,9 @@ export declare function slidingWindow<Characteristics extends readonly string[]>
264
264
  * @returns
265
265
  * Astro integration Token bucket rule to provide to the SDK in the `rules` field.
266
266
  */
267
- export declare function tokenBucket<Characteristics extends readonly string[]>(options: TokenBucketRateLimitOptions<Characteristics>): {
268
- readonly type: "tokenBucket";
269
- readonly options: TokenBucketRateLimitOptions<Characteristics>;
267
+ declare function tokenBucket<Characteristics extends readonly string[]>(options: TokenBucketRateLimitOptions<Characteristics>): {
268
+ readonly type: "tokenBucket";
269
+ readonly options: TokenBucketRateLimitOptions<Characteristics>;
270
270
  };
271
271
  /**
272
272
  * Arcjet signup form protection rule.
@@ -292,9 +292,9 @@ export declare function tokenBucket<Characteristics extends readonly string[]>(o
292
292
  * @returns
293
293
  * Astro integration Signup form protection rule to provide to the SDK in the `rules` field.
294
294
  */
295
- export declare function protectSignup<Characteristics extends readonly string[]>(options: ProtectSignupOptions<Characteristics>): {
296
- readonly type: "protectSignup";
297
- readonly options: ProtectSignupOptions<Characteristics>;
295
+ declare function protectSignup<Characteristics extends readonly string[]>(options: ProtectSignupOptions<Characteristics>): {
296
+ readonly type: "protectSignup";
297
+ readonly options: ProtectSignupOptions<Characteristics>;
298
298
  };
299
299
  /**
300
300
  * Arcjet prompt injection detection rule.
@@ -310,9 +310,9 @@ export declare function protectSignup<Characteristics extends readonly string[]>
310
310
  * @returns
311
311
  * Astro integration Prompt injection detection rule to provide to the SDK in the `rules` field.
312
312
  */
313
- export declare function detectPromptInjection(options?: DetectPromptInjectionOptions): {
314
- readonly type: "detectPromptInjection";
315
- readonly options: DetectPromptInjectionOptions;
313
+ declare function detectPromptInjection(options?: DetectPromptInjectionOptions): {
314
+ readonly type: "detectPromptInjection";
315
+ readonly options: DetectPromptInjectionOptions;
316
316
  };
317
317
  /**
318
318
  * Arcjet prompt injection detection rule.
@@ -320,24 +320,24 @@ export declare function detectPromptInjection(options?: DetectPromptInjectionOpt
320
320
  * @deprecated
321
321
  * Use `detectPromptInjection` instead.
322
322
  */
323
- export declare const experimental_detectPromptInjection: typeof detectPromptInjection;
323
+ declare const experimental_detectPromptInjection: typeof detectPromptInjection;
324
324
  /**
325
325
  * Configuration for {@linkcode createRemoteClient}.
326
326
  */
327
- export type RemoteClientOptions = {
328
- /**
329
- * Base URI for HTTP requests to Decide API (optional).
330
- *
331
- * Defaults to the environment variable `ARCJET_BASE_URL` (if that value
332
- * is known and allowed) and the standard production API otherwise.
333
- */
334
- baseUrl?: string | undefined;
335
- /**
336
- * Timeout in milliseconds for the Decide API (optional).
337
- *
338
- * Defaults to `500` in production and `1000` in development.
339
- */
340
- timeout?: number | undefined;
327
+ type RemoteClientOptions = {
328
+ /**
329
+ * Base URI for HTTP requests to Decide API (optional).
330
+ *
331
+ * Defaults to the environment variable `ARCJET_BASE_URL` (if that value
332
+ * is known and allowed) and the standard production API otherwise.
333
+ */
334
+ baseUrl?: string | undefined;
335
+ /**
336
+ * Timeout in milliseconds for the Decide API (optional).
337
+ *
338
+ * Defaults to `500` in production and `1000` in development.
339
+ */
340
+ timeout?: number | undefined;
341
341
  };
342
342
  /**
343
343
  * Create a remote client.
@@ -347,9 +347,9 @@ export type RemoteClientOptions = {
347
347
  * @returns
348
348
  * Client.
349
349
  */
350
- export declare function createRemoteClient(options?: RemoteClientOptions | undefined): {
351
- readonly baseUrl: string | undefined;
352
- readonly timeout: number | undefined;
350
+ declare function createRemoteClient(options?: RemoteClientOptions | undefined): {
351
+ readonly baseUrl: string | undefined;
352
+ readonly timeout: number | undefined;
353
353
  };
354
354
  /**
355
355
  * Create a new Astro integration of Arcjet.
@@ -361,4 +361,6 @@ export declare function createRemoteClient(options?: RemoteClientOptions | undef
361
361
  * @returns
362
362
  * Astro integration of Arcjet.
363
363
  */
364
- export default function arcjet<Characteristics extends readonly string[]>(options?: ArcjetOptions<Characteristics>): AstroIntegration;
364
+ declare function arcjet<Characteristics extends readonly string[]>(options?: ArcjetOptions<Characteristics>): AstroIntegration;
365
+ //#endregion
366
+ export { ArcjetOptions, type ProxyService, RemoteClientOptions, cloudflare, createRemoteClient, arcjet as default, detectBot, detectPromptInjection, experimental_detectPromptInjection, filter, fixedWindow, protectSignup, sensitiveInfo, shield, slidingWindow, tokenBucket, validateEmail };