redact-pii
Version:
Remove personally identifiable information from text.
162 lines (151 loc) • 5.69 kB
JavaScript
process.env.GOOGLE_APPLICATION_CREDENTIALS = require('path').resolve(
// __dirname + '/../node-mordor/credentials/node-mordor-prod-key.json'
__dirname + '/../node-mordor/credentials/node-mordor-dev-key.json'
);
// const Redactor = require('redact-pii');
const Redactor = require('./lib/index.js');
// const redactor = Redactor({
// enableGoogleCloudDLP: true,
// googleCloudDLPOptions: {
// // clientOptions: {
// //
// // },
// disableFallbackRedaction: true,
// inspectOverrides: {
// inspectConfig: {
// // infoTypes: [
// // { name: 'PHONE_NUMBER' },
// // { name: 'EMAIL_ADDRESS' }
// // ],
// // customInfoTypes: [{
// // infoType: {
// // name: 'F**'
// // },
// // regex: {
// // pattern: '\\bfoo\\b'
// // }
// // }],
// ruleSet: [
// {
// infoTypes: [{ name: 'PHONE_NUMBER' }],
// rules: [
// {
// exclusionRule: {
// matchingType: 'MATCHING_TYPE_FULL_MATCH',
// regex: {
// pattern: '\\d{6}-\\d{6}'
// }
// }
// }
// ]
// },
// // {
// // infoTypes: [
// // {
// // name: 'EMAIL_ADDRESS'
// // }
// // ],
// // rules: [
// // {
// // exclusionRule: {
// // dictionary: {
// // wordList: {
// // words: [
// // 'exclude@example.com'
// // ]
// // }
// // },
// // matchingType: 'MATCHING_TYPE_FULL_MATCH'
// // }
// // }
// // ]
// // }
// ]
// },
// // includeInfoTypes: ['SWEDEN_PASSPORT'],
// // excludeInfoTypes: ['IP_ADDRESS'],
// }
// },
// zipcode: false,
// digits: false,
// url: false,
// emailAddress: false,
// phoneNumber: false,
// ipAddress: false
// });
// payoneer
// const redactor = new Redactor(
// {
// enableGoogleCloudDLP: true
// "phoneNumber": false,
// "digits": false,
// "googleCloudDLPOptions": {
// "inspectConfig": {
// "ruleSet": [
// {
// "infoTypes": [
// {
// "name": "PHONE_NUMBER"
// }
// ],
// "rules": [
// {
// "exclusionRule": {
// "matchingType": "MATCHING_TYPE_FULL_MATCH",
// "regex": {
// "pattern": "\\d{6}-\\d{6}"
// }
// }
// }
// ]
// }
// ]
// }
// }
// }
// );
// // Tastyworks
// const redactor = new Redactor(
// {
// "TASTYWORKS_ACCOUNT_NUMBER": new RegExp("\\d\\d?[a-zA-Z]{2}\\d{5}"),
// }
// );
// Tastyworks
const redactor = new Redactor(
{
enableGoogleCloudDLP: true,
// "googleCloudDLPOptions": {
// "inspectOverrides": {
// "excludeInfoTypes": ["ETHNIC_GROUP", "GENDER"]
// }
// }
}
);
(async function () {
const input = `
Go foo foo foo FTW!
Phone
Phone
Ref
Ref
Email
Email
Swedish passport number: 27386473
IP address: 127.0.0.1
Name: John Smith
Address: 123 Park Ave, New York City, NY 10002
Url: http://example.com/index.html
`;
// const input = '(foo\n/(hiHighland Ave\n/foo bar(age/ New York';
// const input = "Hi Jared also known as PERSON_NAME,\r\n\r\nThank you for trying HelloFresh. I'm sorry for the confusion with your discount offer. I see you applied the code \"8R300W234\". The code gives you a $25 discount on the first and second order and free shipping on the first delivery. I see you created a subscription for a Classic Plan (2 meals for 2 people). The regular price of the box is $39.96 + $7.99 shipping. I see that for the first delivery you were charged $14.96. Don't worry, you're not being charged for shipping.\r\n\r\nIf you need any further assistance, feel free to check out URL or contact us! Just call (646) 846-FOOD (3663) or reply here so I can help you directly. \r\n\r\nPERSON_NAME,\r\nPERSON_NAME";
// const input = "Just call (646) 846-FOOD or (646) 846-3663.";
// console.log('REDACTED: ', await redactor.redact(input));
// console.log('REDACTED: ', await redactor.redact('example@example.com'));
// console.log('REDACTED: ', await redactor.redact('Hi my name is John.'));
// console.log('REDACTED: ', await redactor.redact('My phone is 111-222-3333 and my ref is 181211-008247'));
// console.log('REDACTED: ', await redactor.redact('how do I reset my password?\nMy account number is 5WT52295'));
// console.log('REDACTED: ', await redactor.redact('how do I reset my password?\nMy account number is 15AB52295'));
// console.log('REDACTED: ', await redactor.redact('I deleted three items (brownies, black bean zucchini, banana bread oats) but it only allowed me to add one (chick pea cookies).'));
console.log('REDACTED: ', await redactor.redact('Why are the black beans so yummy in my little rumbly tummy? My home state is California.'));
// console.log('REDACTED: ', await redactor.redact('My phone number is (415) 555-0890. My main email is example@example.com and my backup is foo@example.com.'));
})();