hibp
Version:
An unofficial TypeScript SDK for the 'Have I been pwned?' service.
49 lines (48 loc) • 1.58 kB
TypeScript
import type { Breach } from './api/haveibeenpwned/types.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 declare function latestBreach(options?: {
/**
* a custom base URL for the haveibeenpwned.com API endpoints (default:
* `https://haveibeenpwned.com/api/v3`)
*/
baseUrl?: string;
/**
* timeout for the request in milliseconds (default: none)
*/
timeoutMs?: number;
/**
* an AbortSignal to cancel the request (default: none)
*/
signal?: AbortSignal;
/**
* a custom string to send as the User-Agent field in the request headers
* (default: `hibp <version>`)
*/
userAgent?: string;
}): Promise<Breach | null>;