<T>(
value: T,
options?: { readonly label?: string | undefined }
): Redacted<T>Creates a Redacted wrapper for a sensitive value.
When to use
Use to wrap a sensitive value so normal string, JSON, and inspection output is redacted.
Details
The wrapper redacts string, JSON, and inspection output to reduce accidental
disclosure. The original value remains retrievable with Redacted.value
until the wrapper is wiped or becomes unreachable.
Example (Creating a redacted value)
import { Redacted } from "effect"
const API_KEY = Redacted.make("1234567890")export const const make: <T>(
value: T,
options?: {
readonly label?: string | undefined
}
) => Redacted<T>
Creates a Redacted wrapper for a sensitive value.
When to use
Use to wrap a sensitive value so normal string, JSON, and inspection output
is redacted.
Details
The wrapper redacts string, JSON, and inspection output to reduce accidental
disclosure. The original value remains retrievable with Redacted.value
until the wrapper is wiped or becomes unreachable.
Example (Creating a redacted value)
import { Redacted } from "effect"
const API_KEY = Redacted.make("1234567890")
make = <function (type parameter) T in <T>(value: T, options?: {
readonly label?: string | undefined;
}): Redacted<T>
T>(value: Tvalue: function (type parameter) T in <T>(value: T, options?: {
readonly label?: string | undefined;
}): Redacted<T>
T, options: | {
readonly label?: string | undefined
}
| undefined
options?: {
readonly label?: string | undefinedlabel?: string | undefined
}): interface Redacted<out A = string>A wrapper for sensitive values whose string, JSON, and inspection output is
redacted.
When to use
Use to carry sensitive values while reducing accidental exposure in string,
JSON, and inspection output.
Gotchas
The underlying value is still stored in memory and can be recovered with
Redacted.value until the wrapper is wiped or becomes unreachable. Use
Redacted to reduce accidental disclosure in logs and diagnostics, not as a
cryptographic protection mechanism.
Example (Creating redacted values)
import { Redacted } from "effect"
// Create a redacted value to protect sensitive information
const apiKey = Redacted.make("secret-key")
const userPassword = Redacted.make("user-password")
// TypeScript will infer the types as Redacted<string>
Namespace containing type-level members associated with Redacted values.
When to use
Use to access type-level helpers associated with Redacted.
Example (Using namespace utilities)
import { Redacted } from "effect"
// Use the Redacted namespace for type-level operations
const secret = Redacted.make("my-secret")
// The namespace contains utilities for working with Redacted values
const isRedacted = Redacted.isRedacted(secret) // true
Redacted<function (type parameter) T in <T>(value: T, options?: {
readonly label?: string | undefined;
}): Redacted<T>
T> => {
const const self: anyself = var Object: ObjectConstructorProvides functionality common to all JavaScript objects.
Object.ObjectConstructor.create(o: object | null): any (+1 overload)Creates an object that has the specified prototype or that has null prototype.
create(const Proto: {
toJSON(): string
toString(): string
"~effect/interfaces/Hash"<T>(
this: Redacted<T>
): number
"~effect/interfaces/Equal"<T>(
this: Redacted<T>,
that: unknown
): boolean
pipe(): unknown
[NodeInspectSymbol](): any
"~effect/data/Redacted": {
_A: (_: never) => never
}
label: undefined
}
Proto)
if (options: | {
readonly label?: string | undefined
}
| undefined
options?.label?: string | undefinedlabel) {
const self: anyself.label = options: {
readonly label?: string | undefined
}
options.label?: stringlabel
}
import redactedredacted.const redactedRegistry: WeakMap<
Redacted<any>,
any
>
redactedRegistry.WeakMap<Redacted<any>, any>.set(key: Redacted<any>, value: any): WeakMap<Redacted<any>, any>Adds a new element with a specified key and value.
set(const self: anyself, value: Tvalue)
return const self: anyself
}