@arcjet/astro 1.14.0 → 1.15.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.
Files changed (3) hide show
  1. package/README.md +48 -27
  2. package/dist/internal.js +1 -1
  3. package/package.json +11 -11
package/README.md CHANGED
@@ -344,39 +344,60 @@ if (decision.isDenied() && decision.reason.isRateLimit()) {
344
344
 
345
345
  ## Sensitive information detection
346
346
 
347
- Detect and block PII in request content. Pass the content to scan via
348
- `sensitiveInfoValue` on each `protect()` call. Built-in entity types:
349
- `CREDIT_CARD_NUMBER`, `EMAIL`, `PHONE_NUMBER`, `IP_ADDRESS`. You can also
350
- provide a custom `detect` callback for additional patterns.
351
-
352
- ```js
353
- import arcjet, { sensitiveInfo } from "@arcjet/astro";
354
-
355
- // In astro.config.mjs:
356
- arcjet({
357
- rules: [
358
- sensitiveInfo({
359
- mode: "LIVE", // Blocks requests. Use "DRY_RUN" to log only
360
- deny: ["CREDIT_CARD_NUMBER", "EMAIL", "PHONE_NUMBER"],
361
- }),
362
- ],
363
- });
347
+ Detect and block PII in request content on-device with
348
+ [`@arcjet/sensitive-info-rampart`](https://www.npmjs.com/package/@arcjet/sensitive-info-rampart),
349
+ which runs the Rampart named-entity-recognition model locally, so no data
350
+ leaves your environment. Pass the content to scan via `sensitiveInfoValue` on
351
+ each `protect()` call. Rampart detects names, addresses, government and
352
+ financial identifiers, email addresses, phone numbers, IP addresses, and card
353
+ numbers. Add a recognizer to detect custom patterns.
354
+
355
+ The backend is a runtime object, so add the rule in your route with
356
+ `withRule()` rather than in `astro.config.mjs`. Import the rule from the
357
+ `arcjet` core package, which `@arcjet/astro` already depends on:
358
+
359
+ ```sh
360
+ npm install arcjet @arcjet/sensitive-info-rampart
364
361
  ```
365
362
 
366
363
  ```ts
367
- // In your API route:
368
- const decision = await aj.protect(request, {
369
- sensitiveInfoValue: userMessage, // The text content to scan
370
- });
364
+ // src/pages/api/chat.ts
365
+ import { rampart } from "@arcjet/sensitive-info-rampart";
366
+ import type { APIRoute } from "astro";
367
+ // The client generated by the Astro integration
368
+ import aj from "arcjet:client";
369
+ // The core package, for rules that take a runtime backend
370
+ import { sensitiveInfo } from "arcjet";
371
+
372
+ const routeAj = aj.withRule(
373
+ sensitiveInfo({
374
+ mode: "LIVE", // Blocks requests. Use "DRY_RUN" to log only
375
+ deny: ["CREDIT_CARD_NUMBER", "EMAIL", "PHONE_NUMBER"],
376
+ backend: rampart(),
377
+ }),
378
+ );
371
379
 
372
- if (decision.isDenied() && decision.reason.isSensitiveInfo()) {
373
- return Response.json(
374
- { error: "Sensitive information detected" },
375
- { status: 400 },
376
- );
377
- }
380
+ export const POST: APIRoute = async ({ request }) => {
381
+ const { message } = await request.json();
382
+ const decision = await routeAj.protect(request, {
383
+ sensitiveInfoValue: message, // The text content to scan
384
+ });
385
+
386
+ if (decision.isDenied() && decision.reason.isSensitiveInfo()) {
387
+ return Response.json(
388
+ { error: "Sensitive information detected" },
389
+ { status: 400 },
390
+ );
391
+ }
392
+
393
+ return Response.json({ ok: true });
394
+ };
378
395
  ```
379
396
 
397
+ Rampart runs on Node.js, Bun, and Deno, and loads its model from
398
+ `node_modules` at runtime, so keep it out of your server bundle. See
399
+ [Bundlers and frameworks](https://github.com/arcjet/arcjet-js/tree/main/sensitive-info-rampart#bundlers-and-frameworks).
400
+
380
401
  ## Shield WAF
381
402
 
382
403
  Protect your application against common web attacks, including the OWASP
package/dist/internal.js CHANGED
@@ -10,7 +10,7 @@ import { ARCJET_BASE_URL, ARCJET_ENV, ARCJET_KEY, ARCJET_LOG_LEVEL, FIREBASE_CON
10
10
  export * from "arcjet";
11
11
  //#region src/internal.ts
12
12
  /** SDK version. Updated by the release process. */
13
- const VERSION = "1.14.0";
13
+ const VERSION = "1.15.0";
14
14
  let warnedForAutomaticBodyRead = false;
15
15
  const ipSymbol = Symbol.for("arcjet.ip");
16
16
  const env = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcjet/astro",
3
- "version": "1.14.0",
3
+ "version": "1.15.0",
4
4
  "description": "Arcjet runtime security SDK for Astro — bot protection, rate limiting, prompt injection detection, PII blocking, and WAF",
5
5
  "keywords": [
6
6
  "ai",
@@ -62,18 +62,18 @@
62
62
  "test": "npm run build && npm run test-coverage"
63
63
  },
64
64
  "dependencies": {
65
- "@arcjet/body": "1.14.0",
66
- "@arcjet/env": "1.14.0",
67
- "@arcjet/headers": "1.14.0",
68
- "@arcjet/ip": "1.14.0",
69
- "@arcjet/logger": "1.14.0",
70
- "@arcjet/protocol": "1.14.0",
71
- "@arcjet/transport": "1.14.0",
72
- "arcjet": "1.14.0"
65
+ "@arcjet/body": "1.15.0",
66
+ "@arcjet/env": "1.15.0",
67
+ "@arcjet/headers": "1.15.0",
68
+ "@arcjet/ip": "1.15.0",
69
+ "@arcjet/logger": "1.15.0",
70
+ "@arcjet/protocol": "1.15.0",
71
+ "@arcjet/transport": "1.15.0",
72
+ "arcjet": "1.15.0"
73
73
  },
74
74
  "devDependencies": {
75
- "astro": "7.3.2",
76
- "tsdown": "0.23.0",
75
+ "astro": "7.4.2",
76
+ "tsdown": "0.23.1",
77
77
  "typescript": "7.0.2"
78
78
  },
79
79
  "peerDependencies": {