Skip to content

textfilters/phone

@textfilters/phone

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.

Installation

Add the GitHub Packages registry for the @textfilters scope:

@textfilters:registry=https://npm.pkg.github.com

Install with GitHub npm authentication configured. GitHub Packages requires authentication for npm installs, including public packages.

npm install @textfilters/core @textfilters/phone

Use Cases

  • 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.

Usage

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".

Behavior

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.

Architecture

See docs/architecture.md for the parser flow, module map, and change guide.

Related Textfilters Packages

  • @textfilters/core for shared pipeline, normalization, and range masking primitives.
  • @textfilters/url for URL detection, obfuscated links, and safe link censoring.
  • @textfilters/email for email detection and contact redaction.
  • @textfilters/profanity for Russian profanity filtering and taxonomy-backed moderation.
  • @textfilters/spam for actor-based anti-spam guard checks.

Release

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.

License

MIT

Packages

 
 
 

Contributors