npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@cho_o/pii-masking-js

v1.0.5

Published

PII(개인식별정보) 마스킹을 위한 경량 라이브러리

Readme

@cho_o/pii-masking-js

개인식별정보(PII: Personally Identifiable Information) 마스킹을 위한 경량 JavaScript/TypeScript 라이브러리입니다.

특징

  • Zero Dependencies: 외부 의존성 없음
  • 🔒 Type-Safe: TypeScript로 작성되어 완전한 타입 지원
  • 📦 Dual Package: CommonJS와 ES Modules 모두 지원
  • 🚀 Node 16+: Node.js 16 이상 모든 버전 지원
  • 🎯 경량: 최소한의 코드로 구현

설치

npm install @cho_o/pii-masking-js
yarn add @cho_o/pii-masking-js
pnpm add @cho_o/pii-masking-js

마스킹 규칙

각 함수는 개인정보 보호를 위해 아래와 같은 규칙으로 데이터를 마스킹합니다. 마스킹 문자는 *를 사용합니다.

| 함수 | 규칙 | | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | maskEmail | - 이메일 아이디의 앞 2글자를 제외한 나머지를 마스킹합니다.- 아이디가 2글자 이하인 경우 전체를 마스킹합니다. | | maskRnn | - 13자리: 주민등록번호 뒤 7자리 중 첫째 자리를 제외한 6자리를 마스킹합니다.- 8자리: 생년월일(YYYYMMDD)의 앞 3자리를 제외하고 마스킹합니다.- 6자리: 생년월일(YYMMDD)의 앞 1자리를 제외하고 마스킹합니다. | | maskPhoneOrTel | - 전화번호의 종류와 길이에 따라 국번과 뒷번호 일부를 마스킹합니다.- (예: 010-1234-5678010-12**-56**) | | maskAddress | - 주소를 공백으로 분리하여, 앞 2개 파트(시/도, 시/군/구)를 제외한 나머지를 마스킹합니다. | | maskCardNumber | - 카드번호의 앞 4자리와 뒤 4자리를 제외한 중간 4~11자리를 마스킹합니다. | | maskAccountNumber | - 계좌번호의 뒤 4자리를 제외한 나머지를 모두 마스킹합니다. |

사용법

ES Modules

import {
  maskPhoneOrTel,
  maskEmail,
  maskRnn,
  maskAddress,
  maskCardNumber,
  maskAccountNumber,
} from '@cho_o/pii-masking-js';

console.log(maskPhoneOrTel('010-1234-5678')); // 010-12**-56**
console.log(maskEmail('[email protected]')); // us**@example.com
console.log(maskRnn('901231-1234567')); // 901231-1******
console.log(maskCardNumber('1234-5678-9012-3456')); // 1234-****-****-3456
console.log(maskCardNumber(1234567890123456)); // 1234-****-****-3456
console.log(maskAccountNumber('123-456-789012')); // ***-***-**9012
console.log(maskAddress('서울시 강남구 테헤란로 123')); // 서울시 강남구 *** ***

CommonJS

const { maskPhoneOrTel, maskEmail, maskRnn } = require('@cho_o/pii-masking-js');

console.log(maskPhoneOrTel('010-1234-5678')); // 010-12**-56**

TypeScript

import { maskPhoneOrTel, maskEmail } from '@cho_o/pii-masking-js';

const phone: string = maskPhoneOrTel('010-1234-5678');
const email: string = maskEmail('[email protected]');

API

maskPhoneOrTel(phone: string | number): string

전화번호를 마스킹합니다. number 타입으로 전달 시 0으로 시작하는 값은 유실될 수 있으므로 string 사용을 권장합니다. 휴대폰 번호는 가운데 2자리, 끝 2자리를 마스킹하고 일반 전화번호는 국번과 끝 2자리를 마스킹합니다.

maskPhoneOrTel('010-1234-5678'); // '010-12**-56**'
maskPhoneOrTel('02-123-4567'); // '02-1**-45**'
maskPhoneOrTel('031-1234-5678'); // '031-12**-56**'
maskPhoneOrTel(15881234); // '158812**'

maskEmail(email: string): string

이메일 주소를 마스킹합니다. @ 앞의 아이디 중 앞 2글자를 제외하고 마스킹합니다.

maskEmail('[email protected]'); // 'us**@example.com'
maskEmail('[email protected]'); // 've***********@example.com'
maskEmail('[email protected]'); // '**@example.com'
maskEmail('[email protected]'); // 'te**@example.com'

maskRnn(rnn: string | number): string

주민등록번호(RRN)를 마스킹합니다. 주민등록번호 뒤 7자리 중 성별을 나타내는 첫 자리를 제외하고 마스킹합니다.

maskRnn('901231-1234567'); // '901231-1******'
maskRnn('9012311234567'); // '9012311******'
maskRnn(9012311234567); // '9012311******'

maskAddress(address: string): string

주소를 마스킹합니다. 시/도와 시/군/구에 해당하는 앞 두 단어를 제외한 나머지 부분을 마스킹합니다.

maskAddress('서울특별시 강남구 테헤란로 123'); // '서울특별시 강남구 *** ***'
maskAddress('서울시 강남구 101동 202호'); // '서울시 강남구 *** ***'

maskCardNumber(cardNumber: string | number): string

카드번호를 마스킹합니다. 앞 4자리와 뒤 4자리만 남기고 가운데 번호를 마스킹합니다.

maskCardNumber('1234567890123456'); // '1234********3456'
maskCardNumber('1234-5678-9012-3456'); // '1234-****-****-3456'
maskCardNumber(1234567890123456); // '1234********3456'

maskAccountNumber(accountNumber: string | number): string

계좌번호를 마스킹합니다. 뒤 4자리를 제외한 나머지 숫자를 마스킹합니다.

maskAccountNumber('123-456-789012'); // '***-***-**9012'
maskAccountNumber('123456789012'); // '********9012'
maskAccountNumber(123456789012); // '********9012'

브라우저 지원

이 라이브러리는 Node.js 환경을 위해 설계되었습니다. 브라우저에서 사용하려면 번들러(Webpack, Rollup 등)를 사용하세요.

라이선스

MIT

기여

이슈와 Pull Request는 언제나 환영합니다!