Skip to content
WebMCP Agents
Esc
↑↓navigate↵open⌘Jpreview
On this page

mask

Masks one value already known to be secret, with no traversal and no detection.

Masks one value that is already known to be secret, with no traversal and no detection. The redactor uses it for every value it replaces. Call it for a single value of your own, such as the last digits of a card in your own UI.

Import

import { mask } from "@webmcp-agents/core/redact";

Example

import { mask } from "@webmcp-agents/core/redact";

mask("4242424242424242", "partial"); // "42••••42"
mask("1234567", "partial"); // "[REDACTED]": too short to keep both ends
mask("hunter2"); // "[REDACTED]"
mask("hunter2", "full", "••••"); // "••••"

Options

mask(value, style?, token?).

Name Type Default Description
value string required The secret. Anything else is read as text.
style "full" | "partial" | "indexed" "full" "partial" keeps the first and last two characters of a value of 12 characters or more, and fully masks a shorter one. "indexed" needs a redactor’s scope, so here it is written as token.
token string "[REDACTED]" What replaces the value.

Returns

The masked string.

See also

Was this page helpful?