import fs from 'fs'; import * as readline from 'node:readline'; import log from './log.js'; export const isInWhiteList = async (filename, email) => { if (!email) { log.warn("isInWhiteList: empty email."); return false; } if (filename) { const fileStream = fs.createReadStream(filename); const rl = readline.createInterface({ input: fileStream, crlfDelay: Infinity }); // Note: we use the crlfDelay option to recognize all instances of CR LF // ('\r\n') in input as a single line break. for await (const line of rl) { if (email.trim() === line) { return true; } else { return false; } } return false; } else { log.debug('isInWhiteList: no whitelist file defined.') return true; } }