|
12 | 12 | without it will fail (unless you specify a <code>baseUrl</code> to a proxy that inserts |
13 | 13 | a valid API key on your behalf).</p> |
14 | 14 | </dd> |
| 15 | +<dt><a href="#breachedDomain">breachedDomain(domain, [options])</a> ⇒ <code><a href="#breach--objectedDomainsByEmailAlias">Promise.<BreachedDomainsByEmailAlias></a></code> | <code>Promise.<null></code></dt> |
| 16 | +<dd><p>Fetches all breached email addresses for a domain.</p> |
| 17 | +<p>The result maps email aliases (the local-part before the '@') to an array of |
| 18 | +breach names. For example, querying <code>example.com</code> could return an object like |
| 19 | +<code>{ "john": ["Adobe"], "jane": ["Adobe", "Gawker"] }</code>, corresponding to |
| 20 | +<code>john@example.com</code> and <code>jane@example.com</code>.</p> |
| 21 | +<p>🔑 <code>haveibeenpwned.com</code> requires an API key from |
| 22 | +<a href="https://haveibeenpwned.com/API/Key">https://haveibeenpwned.com/API/Key</a> for the <code>breacheddomain</code> endpoint. The |
| 23 | +<code>apiKey</code> option here is not explicitly required, but direct requests made |
| 24 | +without it will fail (unless you specify a <code>baseUrl</code> to a proxy that inserts |
| 25 | +a valid API key on your behalf).</p> |
| 26 | +</dd> |
15 | 27 | <dt><a href="#breaches">breaches([options])</a> ⇒ <code><a href="#breach--object">Promise.<Array.<Breach>></a></code></dt> |
16 | 28 | <dd><p>Fetches all breach events in the system.</p> |
17 | 29 | </dd> |
@@ -73,6 +85,10 @@ a valid API key on your behalf).</p> |
73 | 85 | <dt><a href="#breach--object">Breach</a> : <code>object</code></dt> |
74 | 86 | <dd><p>An object representing a breach.</p> |
75 | 87 | </dd> |
| 88 | +<dt><a href="#breach--objectedDomainsByEmailAlias">BreachedDomainsByEmailAlias</a> : <code>Object.<string, Array.<string>></code></dt> |
| 89 | +<dd><p>An object mapping an email alias (local-part before the '@') to the list of |
| 90 | +breach names that alias has appeared in for the specified domain.</p> |
| 91 | +</dd> |
76 | 92 | <dt><a href="#Paste">Paste</a> : <code>object</code></dt> |
77 | 93 | <dd><p>An object representing a paste.</p> |
78 | 94 | </dd> |
@@ -194,6 +210,49 @@ try { |
194 | 210 | // ... |
195 | 211 | } |
196 | 212 | ``` |
| 213 | +<a name="breachedDomain"></a> |
| 214 | + |
| 215 | +## breachedDomain(domain, [options]) ⇒ [<code>Promise.<BreachedDomainsByEmailAlias></code>](#breach--objectedDomainsByEmailAlias) \| <code>Promise.<null></code> |
| 216 | +Fetches all breached email addresses for a domain. |
| 217 | + |
| 218 | +The result maps email aliases (the local-part before the '@') to an array of |
| 219 | +breach names. For example, querying `example.com` could return an object like |
| 220 | +`{ "john": ["Adobe"], "jane": ["Adobe", "Gawker"] }`, corresponding to |
| 221 | +`john@example.com` and `jane@example.com`. |
| 222 | + |
| 223 | +🔑 `haveibeenpwned.com` requires an API key from |
| 224 | +https://haveibeenpwned.com/API/Key for the `breacheddomain` endpoint. The |
| 225 | +`apiKey` option here is not explicitly required, but direct requests made |
| 226 | +without it will fail (unless you specify a `baseUrl` to a proxy that inserts |
| 227 | +a valid API key on your behalf). |
| 228 | + |
| 229 | +**Kind**: global function |
| 230 | +**Returns**: [<code>Promise.<BreachedDomainsByEmailAlias></code>](#breach--objectedDomainsByEmailAlias) \| <code>Promise.<null></code> - a Promise which |
| 231 | +resolves to an object mapping aliases to breach name arrays (or null if no |
| 232 | +results were found), or rejects with an Error |
| 233 | + |
| 234 | +| Param | Type | Description | |
| 235 | +| --- | --- | --- | |
| 236 | +| domain | <code>string</code> | the domain to query (e.g., "example.com") | |
| 237 | +| [options] | <code>object</code> | a configuration object | |
| 238 | +| [options.apiKey] | <code>string</code> | an API key from https://haveibeenpwned.com/API/Key (default: undefined) | |
| 239 | +| [options.baseUrl] | <code>string</code> | a custom base URL for the haveibeenpwned.com API endpoints (default: `https://haveibeenpwned.com/api/v3`) | |
| 240 | +| [options.timeoutMs] | <code>number</code> | timeout for the request in milliseconds (default: none) | |
| 241 | +| [options.userAgent] | <code>string</code> | a custom string to send as the User-Agent field in the request headers (default: `hibp <version>`) | |
| 242 | + |
| 243 | +**Example** |
| 244 | +```js |
| 245 | +try { |
| 246 | + const data = await breachedDomain("example.com", { apiKey: "my-api-key" }); |
| 247 | + if (data) { |
| 248 | + // { "john": ["Adobe"], "jane": ["Adobe", "Gawker"] } |
| 249 | + } else { |
| 250 | + // no results |
| 251 | + } |
| 252 | +} catch (err) { |
| 253 | + // ... |
| 254 | +} |
| 255 | +``` |
197 | 256 | <a name="breaches"></a> |
198 | 257 |
|
199 | 258 | ## breaches([options]) ⇒ <code><a href="#breach--object">Promise.<Array.<Breach>></a></code> |
@@ -573,6 +632,13 @@ An object representing a breach. |
573 | 632 | | IsSubscriptionFree | <code>boolean</code> | |
574 | 633 | | LogoPath | <code>string</code> | |
575 | 634 |
|
| 635 | +<a name="BreachedDomainsByEmailAlias"></a> |
| 636 | + |
| 637 | +## BreachedDomainsByEmailAlias : <code>Object.<string, Array.<string>></code> |
| 638 | +An object mapping an email alias (local-part before the '@') to the list of |
| 639 | +breach names that alias has appeared in for the specified domain. |
| 640 | + |
| 641 | +**Kind**: global typedef |
576 | 642 | <a name="Paste"></a> |
577 | 643 |
|
578 | 644 | ## Paste : <code>object</code> |
|
0 commit comments