@xapp/arachne-utils
Version:
69 lines • 3.21 kB
JavaScript
;
/*! Copyright (c) 2024, XAPP AI */
Object.defineProperty(exports, "__esModule", { value: true });
exports.isHallucinatedPhoneNumber = isHallucinatedPhoneNumber;
exports.isHallucinatedEmail = isHallucinatedEmail;
/**
* Looks for common hallucinated phone numbers.
*
* @param number
* @returns
*/
function isHallucinatedPhoneNumber(number) {
// Remove non-digit characters from the input
const digits = number.replace(/\D/g, '');
// Check for hallucinated numbers
const hallucinatedPatterns = [
/^555\d{7}$/, // 10 digits starting with '555'
/^1?555\d{7}$/, // 10 or 11 digits with optional '1', starting with '555'
/1?\d{3}555\d{4}$/,
/555\d{4}$/,
/^(0123456789|1234567890|9876543210)$/, // 10 digits sequential
/(01234567|1234567|7654321|9876543|3214567)/, // 7 digits sequential
/(0{10}|1{10}|2{10}|3{10}|4{10}|5{10}|6{10}|7{10}|8{10}|9{10})/, // 10 digits repeated
/(0{7}|1{7}|2{7}|3{7}|4{7}|5{7}|6{7}|7{7}|8{7}|9{7})/, // 7 digits repeated
/^(\d)\1{2}\1{3}\1{4}$/, // '5555555555' pattern
/^1?(\d)\1{2}\1{2}\1{3}$/, // '15555555555' pattern
/^(\d)\1{2}\1{3}$/, // '5555555' pattern
/^1\d{2}555\d{4}$/, // '12125550183' pattern
/^8675309$/, // '8675309' pattern, the song pattern
];
return hallucinatedPatterns.some(pattern => pattern.test(digits));
}
/**
* Looks for common hallucinated (or made up fake) email addresses.
*
* @param email
* @returns
*/
function isHallucinatedEmail(email) {
// Common fake or placeholder email patterns
const hallucinatedPatterns = [
/^your@email\.com$/i, // Generic 'your email'
/^example@example\.com$/i, // Generic 'example'
/^example@email\.com$/i, // Generic 'example'
/^abc@xyz\.com$/i, // Generic 'user at domain'
/^user@domain\.com$/i, // Generic 'user at domain'
/^johndoe@email\.com$/i, // Generic 'johndoe'
/^janedoe@email\.com$/i, // Generic 'janedoe'
/^support@email\.com$/i, // Generic 'support'
// any john doe at any domain, either johndoe or john.doe
/^(john|john\.doe)@[a-z]+\.[a-z]{2,}$/i,
/^example@domain\.com$/i, // 'example at domain'
/^[a-z]*@example\.com$/i, // Any user at example.com
/^[a-z]*@test\.com$/i, // Placeholder test emails
/^no-reply@.*$/i, // No-reply emails
/^donotreply@.*$/i, // Alternate no-reply pattern
/^[a-z]*@localhost$/i, // Local testing addresses
/^admin@domain\.com$/i, // Generic admin emails
/^info@domain\.com$/i, // Generic info email
/^support@domain\.com$/i, // Support emails
/^[a-z]+@[a-z]+\.(test|invalid)$/i, // Invalid/test TLDs
/^[a-z]{2,4}@example\.(com|net|org)$/i, // Short names at example domains
/^fake@[a-z]+\.[a-z]{2,}$/i, // Fake@something patterns
/^(test|fake|your|email|admin)[\.\+a-z0-9_-]*@[a-z]+\.[a-z]{2,}$/i, // Placeholder email starting keywords
/^[a-z]*@mailservice\.com$/i, // any mailservice.com emails
];
return hallucinatedPatterns.some(pattern => pattern.test(email));
}
//# sourceMappingURL=hallucinationDetector.js.map