Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await Promise.all(config.SERVICES.map(async (service) => {
const credentials = await this.getCredentialsForService(service);
if (credentials === null) {
console.error(`"npm run setup" must be ran before running bot (failed on service ${service.niceName}`);
process.exit();
}
const options = Object.assign({ companyId: service.companyId }, config.ADDITIONAL_OPTIONS);
const scraper = israeliBankScrapers.createScraper(options);
const scrapeResult = await scraper.scrape(credentials);
if (scrapeResult.success) {
scrapeResult.accounts.forEach(this.handleAccount.bind(this, service));
} else {
console.error(`scraping failed for the following reason: ${scrapeResult.errorType}`);
}
}));
} catch (e) {
console.error('Please fix configuration and try again');
return;
}
const serviceResult = await inquirer.prompt([{
type: 'list',
name: 'service',
message: 'Which service would you like to save credentials for?',
choices: CONFIG.SERVICES.map((service) => {
return {
name: service.niceName,
value: service,
};
}),
}]);
const { loginFields } = israeliBankScrapers.SCRAPERS[serviceResult.service.companyId];
const questions = loginFields.map((field) => {
return {
type: field === CONSTS.SCRAPER_PASSWORD_FIELD_NAME ? CONSTS.SCRAPER_PASSWORD_FIELD_NAME : 'input',
name: field,
message: `Enter value for ${field}:`,
validate: input => validateNonEmpty(field, input),
};
});
const credentialsResult = await inquirer.prompt(questions);
setKeytarCredentials(serviceResult.service, credentialsResult);
}