Skip to content

Arcjet Redact quick start

The Arcjet Redaction library makes it easy to redact sensitive information locally.

What are Arcjet utilities?

Arcjet utilities are independent libraries that do not require the use of the main Arcjet SDK—they can be used with or without other Arcjet rules.

We take the pain out of implementing security tasks through these utilities to provide a security as code approach to developer-first security.

SDK installation

Follow these steps to get started:

1. Install Arcjet Redact

In your project root, run the following command to install the Arcjet redact library:

Terminal window
npm i @arcjet/redact

2. Redact some text

Now all you have to do to Redact text is to call the redact function. It can be configured to redact a number of built-in entity types, or else you can provide a custom detect function to redact your own types. The types that we support by default are: email, phone-number, ip-address, credit-card.

import { redact } from "@arcjet/redact";
const text = "my email address is test@example.com";
const [redacted] = await redact(text, {
entities: ["email"],
});
console.log(redacted);
// my email address is <Redacted email #1>

3. Unredact a response

If you want to un-redact some text that contains the replacements from the redact function just call unredact, it is passed as the value in the return array.

import { redact } from "@arcjet/redact";
const text = "My email address is test@example.com";
const [redacted, unredact] = await redact(text, {
entities: ["email"],
});
console.log(redacted);
// My email address is <Redacted email #1>
const unredacted = unredact("Your email address is <Redacted email #1>");
console.log(unredacted);
// Your email address is test@example.com

Get help

Need help with anything? Email us or join our Discord to get support from our engineering team.

Discussion