This version is support with Node 10 and upper version.
Version changes in version 1.0.1, Have 4 parameters (start, end, specialChar, data).
Version changes in version 1.1.1, Have 5 parameters (data, type, start, end, specialChar) and mapping by type from Json file about start, end and specialChar.
MaskingJs is Javascript libraries and tranform data to masking pattern
Option | Default value | Description |
---|---|---|
data | '' | (Required) Original text for mask. |
type | '' | Type of mask data e.g. ACCOUNT, PHONE etc. |
start | null | First position of mask. |
end | null | Last position of mask. |
specialChar | '' | Point of split original text for mask with logic by type. |
type | Description |
---|---|
NAME | Mask text From the 2(start) position to last position. e.g. TEST mark to TExxxxx |
CITIZEN_ID | Mask text From the 10(start) position to 12(end) position. e.g. 1234567890123 mark to 123456789xxx3 |
PASSPORT | Mask text From the 5(start) position to 7(end) position. e.g. 12345678 mark to 1234xxx8 |
PHONE | Mask text From the last 4 position. e.g. 1234567890 mark to 123456xxxx |
Mask text From the last 4 position after keyword @. e.g. testtest@test.com mark to testxxxx@test.com | |
ACCOUNT_NO | Mask text From the 0(start) position to 6(end) position. e.g. 1234567890 mark to xxxxxxx7890 |
CARD_NUMBER | Mask text From the 7(start) position to 12(end) position. e.g. 1234567890123456 mark to 123456xxxxxx3456 |
RELIGION | Return empty text. |
NATIONALITY | Return empty text. |
CRIMINAL_HIST | Return empty text. |
HEALTH | Return empty text. |
ADDRESS | Return original text after keyword ['แขวง', 'ตำบล', 'Subdistrict', 'ต.', 'แขวง/ตำบล']. e.g. test Subdistrict test to Subdistrict test |
return string data masking
To install this library, run:
$ npm install masking-js --save
// Import the library
import * as MaskingJS from 'masking-js';
export class MarkingClass {
mask : string = '';
mask2 : string = '';
constructor() {
this.mask = MaskingJS('1234567890123', 'CITIZEN_ID');
this.mask2 = MaskingJS('1234567890123', '', 10, 12,'');
}
}
<p>{{mask}}</p>
<p>{{mask2}}</p>
// Import the library
const MaskingJS = require('masking-js')
export default function Home() {
return (<>
<div>{MaskingJS('Testdata' , 'NAME')}</div>
<div>{MaskingJS('Testdata' , '', 2, null,'')}</div>
</>
);
}
ISC © Sirintra Wannakheaw