@arcjet/astro 1.1.0 → 1.3.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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { BotOptions, EmailOptions, FilterOptions, FixedWindowRateLimitOptions, ProtectSignupOptions, SensitiveInfoOptions, ShieldOptions, SlidingWindowRateLimitOptions, TokenBucketRateLimitOptions } from "arcjet";
1
+ import type { BotOptions, DetectPromptInjectionOptions, EmailOptions, FilterOptions, FixedWindowRateLimitOptions, ProtectSignupOptions, SensitiveInfoOptions, ShieldOptions, SlidingWindowRateLimitOptions, TokenBucketRateLimitOptions } from "arcjet";
2
2
  import type { AstroIntegration } from "astro";
3
3
  type IntegrationRule<Characteristics extends readonly string[]> = {
4
4
  type: "shield";
@@ -27,6 +27,9 @@ type IntegrationRule<Characteristics extends readonly string[]> = {
27
27
  } | {
28
28
  type: "protectSignup";
29
29
  options: ProtectSignupOptions<Characteristics>;
30
+ } | {
31
+ type: "detectPromptInjection";
32
+ options: DetectPromptInjectionOptions;
30
33
  };
31
34
  /**
32
35
  * Configuration for the Astro integration of Arcjet.
@@ -286,6 +289,31 @@ export declare function protectSignup<Characteristics extends readonly string[]>
286
289
  readonly type: "protectSignup";
287
290
  readonly options: ProtectSignupOptions<Characteristics>;
288
291
  };
292
+ /**
293
+ * Arcjet prompt injection detection rule.
294
+ *
295
+ * Analyzes LLM prompts to detect prompt injection attempts.
296
+ *
297
+ * The Arcjet prompt injection detection rule analyzes prompts sent to LLM
298
+ * applications to detect jailbreak and injection attempts.
299
+ * The analysis is performed through Arcjet's Cloud API.
300
+ *
301
+ * @param options
302
+ * Configuration for the prompt injection detection rule.
303
+ * @returns
304
+ * Astro integration Prompt injection detection rule to provide to the SDK in the `rules` field.
305
+ */
306
+ export declare function detectPromptInjection(options?: DetectPromptInjectionOptions): {
307
+ readonly type: "detectPromptInjection";
308
+ readonly options: DetectPromptInjectionOptions;
309
+ };
310
+ /**
311
+ * Arcjet prompt injection detection rule.
312
+ *
313
+ * @deprecated
314
+ * Use `detectPromptInjection` instead.
315
+ */
316
+ export declare const experimental_detectPromptInjection: typeof detectPromptInjection;
289
317
  /**
290
318
  * Configuration for {@linkcode createRemoteClient}.
291
319
  */
package/index.js CHANGED
@@ -113,6 +113,12 @@ const validateProtectSignupOptions = z
113
113
  email: validateEmailOptions,
114
114
  })
115
115
  .strict();
116
+ const validateDetectPromptInjectionOptions = z
117
+ .object({
118
+ mode: validateMode.optional(),
119
+ threshold: z.number().optional(),
120
+ })
121
+ .strict();
116
122
  function validateAndSerialize(schema, value) {
117
123
  const v = schema.parse(value);
118
124
  return v ? JSON.stringify(v) : "";
@@ -182,6 +188,13 @@ function integrationRuleToClientRule(rule) {
182
188
  code: `protectSignup(${serializedOpts})`,
183
189
  };
184
190
  }
191
+ case "detectPromptInjection": {
192
+ const serializedOpts = validateAndSerialize(validateDetectPromptInjectionOptions, rule.options);
193
+ return {
194
+ importName: `detectPromptInjection`,
195
+ code: `detectPromptInjection(${serializedOpts})`,
196
+ };
197
+ }
185
198
  default: {
186
199
  throw new Error("Cannot convert rule via integration");
187
200
  }
@@ -428,6 +441,34 @@ function protectSignup(options) {
428
441
  options,
429
442
  };
430
443
  }
444
+ // Note: please keep JSDocs in sync with `arcjet` core.
445
+ /**
446
+ * Arcjet prompt injection detection rule.
447
+ *
448
+ * Analyzes LLM prompts to detect prompt injection attempts.
449
+ *
450
+ * The Arcjet prompt injection detection rule analyzes prompts sent to LLM
451
+ * applications to detect jailbreak and injection attempts.
452
+ * The analysis is performed through Arcjet's Cloud API.
453
+ *
454
+ * @param options
455
+ * Configuration for the prompt injection detection rule.
456
+ * @returns
457
+ * Astro integration Prompt injection detection rule to provide to the SDK in the `rules` field.
458
+ */
459
+ function detectPromptInjection(options = {}) {
460
+ return {
461
+ type: "detectPromptInjection",
462
+ options,
463
+ };
464
+ }
465
+ /**
466
+ * Arcjet prompt injection detection rule.
467
+ *
468
+ * @deprecated
469
+ * Use `detectPromptInjection` instead.
470
+ */
471
+ const experimental_detectPromptInjection = detectPromptInjection;
431
472
  /**
432
473
  * Create a remote client.
433
474
  *
@@ -626,4 +667,4 @@ function arcjet(options = { rules: [] }) {
626
667
  };
627
668
  }
628
669
 
629
- export { createRemoteClient, arcjet as default, detectBot, filter, fixedWindow, protectSignup, sensitiveInfo, shield, slidingWindow, tokenBucket, validateEmail };
670
+ export { createRemoteClient, arcjet as default, detectBot, detectPromptInjection, experimental_detectPromptInjection, filter, fixedWindow, protectSignup, sensitiveInfo, shield, slidingWindow, tokenBucket, validateEmail };
package/internal.js CHANGED
@@ -40,7 +40,7 @@ function createRemoteClient(options) {
40
40
  // Transport is the HTTP client that the client uses to make requests.
41
41
  const transport = createTransport(url);
42
42
  const sdkStack = "ASTRO";
43
- const sdkVersion = "1.1.0";
43
+ const sdkVersion = "1.3.0";
44
44
  return createClient({
45
45
  transport,
46
46
  baseUrl: url,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcjet/astro",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
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",
@@ -51,23 +51,23 @@
51
51
  "test": "npm run build && npm run lint && npm run test-coverage"
52
52
  },
53
53
  "dependencies": {
54
- "@arcjet/body": "1.1.0",
55
- "@arcjet/env": "1.1.0",
56
- "@arcjet/headers": "1.1.0",
57
- "@arcjet/ip": "1.1.0",
58
- "@arcjet/logger": "1.1.0",
59
- "@arcjet/protocol": "1.1.0",
60
- "@arcjet/transport": "1.1.0",
61
- "arcjet": "1.1.0"
54
+ "@arcjet/body": "1.3.0",
55
+ "@arcjet/env": "1.3.0",
56
+ "@arcjet/headers": "1.3.0",
57
+ "@arcjet/ip": "1.3.0",
58
+ "@arcjet/logger": "1.3.0",
59
+ "@arcjet/protocol": "1.3.0",
60
+ "@arcjet/transport": "1.3.0",
61
+ "arcjet": "1.3.0"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "astro": "^5.9.3"
65
65
  },
66
66
  "devDependencies": {
67
- "@arcjet/eslint-config": "1.1.0",
68
- "@arcjet/rollup-config": "1.1.0",
69
- "@rollup/wasm-node": "4.57.0",
70
- "astro": "5.16.16",
67
+ "@arcjet/eslint-config": "1.3.0",
68
+ "@arcjet/rollup-config": "1.3.0",
69
+ "@rollup/wasm-node": "4.57.1",
70
+ "astro": "5.17.1",
71
71
  "eslint": "9.39.2",
72
72
  "typescript": "5.9.3"
73
73
  },