- 이름,이메일,계좌번호 등 마스킹정책 적용
- 권한 체크 오 기입 수정 - 다국어 누락 부분 수정
This commit is contained in:
66
src/shared/lib/masking-utils.ts
Normal file
66
src/shared/lib/masking-utils.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* 마스킹 유틸리티 함수
|
||||
* 개인정보 보호를 위한 데이터 마스킹 처리
|
||||
*/
|
||||
|
||||
/**
|
||||
* 이름 마스킹
|
||||
* - 1글자: 그대로 표시
|
||||
* - 2글자: 첫 글자 + * (홍*, j*)
|
||||
* - 3글자: 첫 글자 + * + 마지막 글자 (홍*동, j*n)
|
||||
* - 4글자 이상: 첫 글자 + *** + 마지막 글자 (선**녀, j***n)
|
||||
*/
|
||||
export const getMaskedName = (name?: string): string => {
|
||||
if (!name) return '';
|
||||
const length = name.length;
|
||||
if (length <= 1) return name;
|
||||
if (length === 2) return name[0] + '*';
|
||||
if (length === 3) return name[0] + '*' + name[2];
|
||||
const firstChar = name[0];
|
||||
const lastChar = name[length - 1];
|
||||
const maskedLength = length - 2;
|
||||
const masked = '*'.repeat(maskedLength);
|
||||
return firstChar + masked + lastChar;
|
||||
};
|
||||
|
||||
/**
|
||||
* 전화번호 마스킹
|
||||
* - 마지막 4자리 마스킹
|
||||
* - 예: 0101234****
|
||||
*/
|
||||
export const getMaskedPhoneNumber = (phone?: string): string => {
|
||||
if (!phone) return '';
|
||||
if (phone.length <= 7) return phone;
|
||||
const visiblePart = phone.slice(0, -4);
|
||||
return visiblePart + '****';
|
||||
};
|
||||
|
||||
/**
|
||||
* 이메일 마스킹
|
||||
* - 앞 2자리만 표시, @ 이전 부분 마스킹
|
||||
* - 예: te**@nicepay.co.kr
|
||||
*/
|
||||
export const getMaskedEmail = (email?: string): string => {
|
||||
if (!email) return '';
|
||||
const atIndex = email.indexOf('@');
|
||||
if (atIndex === -1 || atIndex <= 2) return email;
|
||||
const visiblePart = email.slice(0, 2);
|
||||
const domainPart = email.slice(atIndex);
|
||||
const maskedLength = atIndex - 2;
|
||||
const masked = '*'.repeat(maskedLength);
|
||||
return visiblePart + masked + domainPart;
|
||||
};
|
||||
|
||||
/**
|
||||
* 계좌번호 마스킹
|
||||
* - 마지막 5자리만 표시
|
||||
* - 예: *********74018
|
||||
*/
|
||||
export const getMaskedAccountNumber = (accountNo?: string): string => {
|
||||
if (!accountNo) return '';
|
||||
if (accountNo.length <= 5) return accountNo;
|
||||
const visiblePart = accountNo.slice(-5);
|
||||
const maskedLength = accountNo.length - 5;
|
||||
const masked = '*'.repeat(maskedLength);
|
||||
return masked + visiblePart;
|
||||
};
|
||||
Reference in New Issue
Block a user