Skip to content

Redacted

The Redacted module provides functionality for handling sensitive information securely within your application. By using the Redacted data type, you can ensure that sensitive values are not accidentally exposed in logs or error messages.

9 exports Added in v3.3.0 Source

Constructors

make

Added in v3.3.0 Source

This function creates a Redacted<A> instance from a given value A, securely hiding its content.

Signature

declare const make: <A>(value: A) => Redacted<A>;

Example

import { Redacted } from "effect"

const API_KEY = Redacted.make("1234567890")

Equivalence

Generates an equivalence relation for Redacted<A> values based on an equivalence relation for the underlying values A. This function is useful for comparing Redacted instances without exposing their contents.

Signature

declare function getEquivalence<A>(isEquivalent: Equivalence<A>): Equivalence<Redacted<A>>;

Getters

value

Added in v3.3.0 Source

Retrieves the original value from a Redacted instance. Use this function with caution, as it exposes the sensitive data.

Signature

declare const value: <A>(self: Redacted<A>) => A;

Example

import * as assert from "node:assert"
import { Redacted } from "effect"

const API_KEY = Redacted.make("1234567890")

assert.equal(Redacted.value(API_KEY), "1234567890")

Models

Redacted interface

Added in v3.3.0 Source

Signature

interface Redacted<out A = string> extends Variance<A>, Equal, Pipeable {}

Other

Redacted

Added in v3.3.0 Source

Refinements

isRedacted

Added in v3.3.0 Source

Signature

declare const isRedacted: (u: unknown) => u is Redacted<unknown>;

Symbols

Signature

declare const RedactedTypeId: unique symbol;

RedactedTypeId type

Added in v3.3.0 Source

Signature

type RedactedTypeId = typeof RedactedTypeId;

Unsafe

unsafeWipe

Added in v3.3.0 Source

Erases the underlying value of a Redacted instance, rendering it unusable. This function is intended to ensure that sensitive data does not remain in memory longer than necessary.

Signature

declare const unsafeWipe: <A>(self: Redacted<A>) => boolean;

Example

import * as assert from "node:assert"
import { Redacted } from "effect"

const API_KEY = Redacted.make("1234567890")

assert.equal(Redacted.value(API_KEY), "1234567890")

Redacted.unsafeWipe(API_KEY)

assert.throws(() => Redacted.value(API_KEY), new Error("Unable to get redacted value"))