@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.
- package/README.md +48 -27
- package/dist/internal.js +1 -1
- 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
|
|
348
|
-
`
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
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
|
-
//
|
|
368
|
-
|
|
369
|
-
|
|
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
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
66
|
-
"@arcjet/env": "1.
|
|
67
|
-
"@arcjet/headers": "1.
|
|
68
|
-
"@arcjet/ip": "1.
|
|
69
|
-
"@arcjet/logger": "1.
|
|
70
|
-
"@arcjet/protocol": "1.
|
|
71
|
-
"@arcjet/transport": "1.
|
|
72
|
-
"arcjet": "1.
|
|
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.
|
|
76
|
-
"tsdown": "0.23.
|
|
75
|
+
"astro": "7.4.2",
|
|
76
|
+
"tsdown": "0.23.1",
|
|
77
77
|
"typescript": "7.0.2"
|
|
78
78
|
},
|
|
79
79
|
"peerDependencies": {
|