Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const hibp = require('hibp');
hibp
.breach('Adobe')
.then(data => {
if (data) {
// Breach data found
console.log(data);
} else {
console.log('No breach data found by that name.');
}
})
.catch(err => {
// Something went wrong.
console.log(err.message);
});
export const handler = async ({
name,
raw,
}: BreachHandlerOptions): Promise => {
if (!raw) {
spinner.start();
}
try {
const breachData = await breach(name, { userAgent });
if (breachData && raw) {
logger.log(JSON.stringify(breachData));
} else if (breachData) {
spinner.stop();
logger.log(prettyjson.render(breachData));
} else if (!breachData && !raw) {
spinner.succeed('No breach found by that name.');
}
} catch (err) {
if (!raw) {
spinner.fail(err.message);
} else {
logger.error(err.message);
}
}
};
export default (name, raw) => {
if (!raw && process.stdout.isTTY) {
spinner.start();
}
return Promise.resolve(breach(name))
.then((breachData) => {
if (!raw && process.stdout.isTTY) {
spinner.stop(true);
}
if (breachData && raw) {
logger.log(JSON.stringify(breachData));
} else if (breachData) {
logger.log(prettyjson.render(breachData));
} else if (!breachData && !raw) {
logger.log('No breach found by that name.');
}
})
.catch((err) => {
if (!raw && process.stdout.isTTY) {
spinner.stop(true);
}