TypeScript phone number detection and phone-like sequence filtering for content moderation, chat moderation, UGC moderation, censoring, contact redaction, and PII redaction workflows.
Use @textfilters/phone to detect phone numbers and phone-like numeric
sequences while keeping false-positive guards around dates, times, coordinates,
IP-like text, and balance-like numbers.
Add the GitHub Packages registry for the @textfilters scope:
@textfilters:registry=https://npm.pkg.github.comInstall with GitHub npm authentication configured. GitHub Packages requires authentication for npm installs, including public packages.
npm install @textfilters/core @textfilters/phone- Redact phone numbers from chat messages, profiles, listings, and other UGC.
- Add contact redaction to a broader TypeScript text filtering library.
- Keep phone filtering separate from URL detection, email detection, profanity filtering, and spam checks.
- Apply false-positive guards for common numeric text that should stay visible.
import { filter } from "@textfilters/phone";
const safeText = filter.censor("call +1 555 010 9999");import { createPhoneFilter } from "@textfilters/phone";
const phoneFilter = createPhoneFilter({ maskChar: "#" });
const safeText = phoneFilter.censor("call 8 999 123 45 67");The default shared instance is exported as filter. It has stable name: "phone".
The package detects phone-like numeric sequences across common RU and international formats, including Unicode digit forms that normalize to ASCII digits for matching.
False-positive guards keep date-like, time-like, coordinate-like, IP/server-like, and balance-like numeric text outside the masked range.
censor() preserves the original JavaScript string length and is idempotent.
See docs/architecture.md for the parser flow, module map, and change guide.
@textfilters/corefor shared pipeline, normalization, and range masking primitives.@textfilters/urlfor URL detection, obfuscated links, and safe link censoring.@textfilters/emailfor email detection and contact redaction.@textfilters/profanityfor Russian profanity filtering and taxonomy-backed moderation.@textfilters/spamfor actor-based anti-spam guard checks.
Releases are managed by Release Please from Conventional Commit history on main. When a Release Please release is created, the workflow runs npm run check and publishes the package to GitHub Packages. Release tags keep the v* pattern.
The package is prepared for publication to GitHub Packages, not the public npm registry.
MIT