UNPKG

hibp

Version:

An unofficial TypeScript SDK for the 'Have I been pwned?' service.

32 lines 1.13 kB
import { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js'; /** * Fetches the most recently added breach. * * @param {object} [options] a configuration object * @param {string} [options.baseUrl] a custom base URL for the * haveibeenpwned.com API endpoints (default: * `https://haveibeenpwned.com/api/v3`) * @param {number} [options.timeoutMs] timeout for the request in milliseconds * (default: none) * @param {AbortSignal} [options.signal] an AbortSignal to cancel the request (default: none) * @param {string} [options.userAgent] a custom string to send as the User-Agent * field in the request headers (default: `hibp <version>`) * @returns {(Promise<Breach>|Promise<null>)} a Promise which resolves to an * object representing a breach (or null if no breach was found), or rejects * with an Error * @example * try { * const data = await latestBreach(); * if (data) { * // ... * } else { * // ... * } * } catch (err) { * // ... * } */ export function latestBreach(options = {}) { return fetchFromApi('/latestbreach', options); } //# sourceMappingURL=latest-breach.js.map