mask-card

Masks PAN/card numbers with Luhn validation and type detection.

8|Updated Feb 3, 2026
One-click install
npx skills add https://github.com/ekaone/mask-card --skill mask-card
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mask-card
Source: https://github.com/ekaone/mask-card/tree/main/.cursor/skills/mask-card
Command: npx skills add https://github.com/ekaone/mask-card --skill mask-card

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Maintains the @ekaone/mask-card TypeScript library for masking PAN/credit card numbers to protect sensitive information in displays and logs, aligning with PCI display guidance (first 6 + last 4) and supporting docs, examples, tests, and builds.

Core Features & Use Cases

  • Masking and formatting with maskCard, maskCardAuto, and maskCardBatch for display-safe PAN handling.
  • Card-type detection (detectCardType) and grouping (getCardTypeGrouping) to drive formatting logic.
  • Luhn validation (isValidCardLuhn, isValidCard) and helper utilities (getCardLast, getCardFirst, getCardLast4, getCardFirst6).
  • Workflows for development, testing (Vitest), documentation, and npm publishing workflows.
  • Security-focused defaults (last-4 visible by default) and configurable masking behavior.

Quick Start

Install the library and call maskCard with a card number to see a masked result.

Frequently Asked Questions about mask-card

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I mask credit card numbers for display in a TypeScript application?

To mask credit card numbers for display, call the maskCard function with a card number string, which returns a display-safe result showing the last four digits by default while hiding the rest.

What is the PCI-DSS compliant way to display masked PAN data?

PCI-DSS compliant masked PAN display follows the first six and last four digits format, which this library supports through configurable masking behavior and security-focused defaults.

Does this credit card masking library validate numbers with the Luhn algorithm?

Yes, the library includes Luhn validation through the isValidCardLuhn and isValidCard functions to verify credit card number integrity before or after masking operations.

Can I detect credit card type and apply formatting groups in TypeScript?

Card-type detection uses the detectCardType function, and getCardTypeGrouping returns formatting groups to drive display logic for different card brands.

How do I batch mask multiple credit card numbers for analytics or logging?

Use the maskCardBatch function to process multiple credit card numbers simultaneously, returning display-safe masked results suitable for analytics and logging workflows.

Do I need external dependencies to use this TypeScript credit card masking library?

No, this is a zero-dependency TypeScript library, so you can install and use it directly without adding any external packages to your project.