hibp 0.0.0-dev.9896b89a → 0.0.0-dev.debac06f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +275 -198
- package/CHANGELOG.md +70 -0
- package/README.md +20 -22
- package/dist/browser/hibp.module.js +1 -1
- package/dist/browser/hibp.module.js.map +1 -1
- package/dist/browser/hibp.umd.js +1 -1
- package/dist/browser/hibp.umd.js.map +1 -1
- package/dist/cjs/api/fetch-polyfill.cjs +28 -0
- package/dist/cjs/api/fetch-polyfill.cjs.map +1 -0
- package/dist/cjs/api/haveibeenpwned/{fetchFromApi.js → fetch-from-api.cjs} +43 -38
- package/dist/cjs/api/haveibeenpwned/fetch-from-api.cjs.map +1 -0
- package/dist/cjs/api/haveibeenpwned/{responses.js → responses.cjs} +1 -7
- package/dist/cjs/api/haveibeenpwned/responses.cjs.map +1 -0
- package/dist/cjs/api/haveibeenpwned/types.cjs +2 -0
- package/dist/cjs/api/haveibeenpwned/types.cjs.map +1 -0
- package/dist/cjs/api/pwnedpasswords/fetch-from-api.cjs +53 -0
- package/dist/cjs/api/pwnedpasswords/fetch-from-api.cjs.map +1 -0
- package/dist/cjs/api/pwnedpasswords/{responses.js → responses.cjs} +1 -6
- package/dist/cjs/api/pwnedpasswords/responses.cjs.map +1 -0
- package/dist/cjs/{breach.js → breach.cjs} +14 -13
- package/dist/cjs/breach.cjs.map +1 -0
- package/dist/cjs/{breachedAccount.js → breached-account.cjs} +56 -56
- package/dist/cjs/breached-account.cjs.map +1 -0
- package/dist/cjs/{breaches.js → breaches.cjs} +29 -26
- package/dist/cjs/breaches.cjs.map +1 -0
- package/dist/cjs/{dataClasses.js → data-classes.cjs} +11 -12
- package/dist/cjs/data-classes.cjs.map +1 -0
- package/dist/cjs/hibp.cjs +23 -0
- package/dist/cjs/hibp.cjs.map +1 -0
- package/dist/cjs/hibp.d.cts +663 -0
- package/dist/cjs/{package.json.js → package.json.cjs} +2 -2
- package/dist/cjs/package.json.cjs.map +1 -0
- package/dist/cjs/{pasteAccount.js → paste-account.cjs} +28 -22
- package/dist/cjs/paste-account.cjs.map +1 -0
- package/dist/cjs/{pwnedPasswordRange.js → pwned-password-range.cjs} +44 -25
- package/dist/cjs/pwned-password-range.cjs.map +1 -0
- package/dist/cjs/{pwnedPassword.js → pwned-password.cjs} +20 -15
- package/dist/cjs/pwned-password.cjs.map +1 -0
- package/dist/cjs/{search.js → search.cjs} +51 -49
- package/dist/cjs/search.cjs.map +1 -0
- package/dist/cjs/subscription-status.cjs +56 -0
- package/dist/cjs/subscription-status.cjs.map +1 -0
- package/dist/esm/api/fetch-polyfill.js +26 -0
- package/dist/esm/api/fetch-polyfill.js.map +1 -0
- package/dist/esm/api/haveibeenpwned/{fetchFromApi.mjs → fetch-from-api.js} +43 -38
- package/dist/esm/api/haveibeenpwned/fetch-from-api.js.map +1 -0
- package/dist/esm/api/haveibeenpwned/{responses.mjs → responses.js} +2 -7
- package/dist/esm/api/haveibeenpwned/responses.js.map +1 -0
- package/dist/esm/api/haveibeenpwned/types.js +2 -0
- package/dist/esm/api/haveibeenpwned/types.js.map +1 -0
- package/dist/esm/api/pwnedpasswords/fetch-from-api.js +51 -0
- package/dist/esm/api/pwnedpasswords/fetch-from-api.js.map +1 -0
- package/dist/esm/api/pwnedpasswords/{responses.mjs → responses.js} +2 -6
- package/dist/esm/api/pwnedpasswords/responses.js.map +1 -0
- package/dist/esm/{breach.mjs → breach.js} +14 -13
- package/dist/esm/breach.js.map +1 -0
- package/dist/esm/{breachedAccount.mjs → breached-account.js} +56 -56
- package/dist/esm/breached-account.js.map +1 -0
- package/dist/esm/{breaches.mjs → breaches.js} +29 -26
- package/dist/esm/breaches.js.map +1 -0
- package/dist/esm/{dataClasses.mjs → data-classes.js} +11 -12
- package/dist/esm/data-classes.js.map +1 -0
- package/dist/esm/hibp.d.ts +663 -0
- package/dist/esm/hibp.js +11 -0
- package/dist/{cjs → esm}/hibp.js.map +1 -1
- package/dist/esm/package.json.js +4 -0
- package/dist/{cjs → esm}/package.json.js.map +1 -1
- package/dist/esm/{pasteAccount.mjs → paste-account.js} +28 -22
- package/dist/esm/paste-account.js.map +1 -0
- package/dist/esm/{pwnedPasswordRange.mjs → pwned-password-range.js} +44 -25
- package/dist/esm/pwned-password-range.js.map +1 -0
- package/dist/esm/{pwnedPassword.mjs → pwned-password.js} +20 -15
- package/dist/esm/pwned-password.js.map +1 -0
- package/dist/esm/{search.mjs → search.js} +51 -49
- package/dist/esm/search.js.map +1 -0
- package/dist/esm/subscription-status.js +54 -0
- package/dist/esm/subscription-status.js.map +1 -0
- package/example/runkit.js +13 -14
- package/package.json +57 -64
- package/dist/cjs/api/haveibeenpwned/fetchFromApi.js.map +0 -1
- package/dist/cjs/api/haveibeenpwned/index.js +0 -6
- package/dist/cjs/api/haveibeenpwned/index.js.map +0 -1
- package/dist/cjs/api/haveibeenpwned/responses.js.map +0 -1
- package/dist/cjs/api/pwnedpasswords/fetchFromApi.js +0 -44
- package/dist/cjs/api/pwnedpasswords/fetchFromApi.js.map +0 -1
- package/dist/cjs/api/pwnedpasswords/index.js +0 -5
- package/dist/cjs/api/pwnedpasswords/index.js.map +0 -1
- package/dist/cjs/api/pwnedpasswords/responses.js.map +0 -1
- package/dist/cjs/breach.js.map +0 -1
- package/dist/cjs/breachedAccount.js.map +0 -1
- package/dist/cjs/breaches.js.map +0 -1
- package/dist/cjs/dataClasses.js.map +0 -1
- package/dist/cjs/hibp.js +0 -21
- package/dist/cjs/pasteAccount.js.map +0 -1
- package/dist/cjs/pwnedPassword.js.map +0 -1
- package/dist/cjs/pwnedPasswordRange.js.map +0 -1
- package/dist/cjs/search.js.map +0 -1
- package/dist/esm/api/haveibeenpwned/fetchFromApi.mjs.map +0 -1
- package/dist/esm/api/haveibeenpwned/index.mjs +0 -2
- package/dist/esm/api/haveibeenpwned/index.mjs.map +0 -1
- package/dist/esm/api/haveibeenpwned/responses.mjs.map +0 -1
- package/dist/esm/api/pwnedpasswords/fetchFromApi.mjs +0 -42
- package/dist/esm/api/pwnedpasswords/fetchFromApi.mjs.map +0 -1
- package/dist/esm/api/pwnedpasswords/index.mjs +0 -2
- package/dist/esm/api/pwnedpasswords/index.mjs.map +0 -1
- package/dist/esm/api/pwnedpasswords/responses.mjs.map +0 -1
- package/dist/esm/breach.mjs.map +0 -1
- package/dist/esm/breachedAccount.mjs.map +0 -1
- package/dist/esm/breaches.mjs.map +0 -1
- package/dist/esm/dataClasses.mjs.map +0 -1
- package/dist/esm/hibp.mjs +0 -10
- package/dist/esm/hibp.mjs.map +0 -1
- package/dist/esm/package.json.mjs +0 -4
- package/dist/esm/package.json.mjs.map +0 -1
- package/dist/esm/pasteAccount.mjs.map +0 -1
- package/dist/esm/pwnedPassword.mjs.map +0 -1
- package/dist/esm/pwnedPasswordRange.mjs.map +0 -1
- package/dist/esm/search.mjs.map +0 -1
- package/dist/hibp.d.ts +0 -502
package/API.md
CHANGED
|
@@ -6,12 +6,11 @@
|
|
|
6
6
|
</dd>
|
|
7
7
|
<dt><a href="#breachedAccount">breachedAccount(account, [options])</a> ⇒ <code><a href="#breach--object">Promise.<Array.<Breach>></a></code> | <code>Promise.<null></code></dt>
|
|
8
8
|
<dd><p>Fetches breach data for a specific account.</p>
|
|
9
|
-
<p
|
|
10
|
-
<p><code>haveibeenpwned.com</code> now requires an API key from
|
|
9
|
+
<p>🔑 <code>haveibeenpwned.com</code> requires an API key from
|
|
11
10
|
<a href="https://haveibeenpwned.com/API/Key">https://haveibeenpwned.com/API/Key</a> for the <code>breachedaccount</code> endpoint. The
|
|
12
11
|
<code>apiKey</code> option here is not explicitly required, but direct requests made
|
|
13
|
-
without it (
|
|
14
|
-
valid API key on your behalf)
|
|
12
|
+
without it will fail (unless you specify a <code>baseUrl</code> to a proxy that inserts
|
|
13
|
+
a valid API key on your behalf).</p>
|
|
15
14
|
</dd>
|
|
16
15
|
<dt><a href="#breaches">breaches([options])</a> ⇒ <code><a href="#breach--object">Promise.<Array.<Breach>></a></code></dt>
|
|
17
16
|
<dd><p>Fetches all breach events in the system.</p>
|
|
@@ -21,27 +20,27 @@ valid API key on your behalf) will fail.</p>
|
|
|
21
20
|
</dd>
|
|
22
21
|
<dt><a href="#pasteAccount">pasteAccount(email, [options])</a> ⇒ <code><a href="#paste--object">Promise.<Array.<Paste>></a></code> | <code>Promise.<null></code></dt>
|
|
23
22
|
<dd><p>Fetches paste data for a specific account (email address).</p>
|
|
24
|
-
<p
|
|
25
|
-
<p><code>haveibeenpwned.com</code> now requires an API key from
|
|
23
|
+
<p>🔑 <code>haveibeenpwned.com</code> requires an API key from
|
|
26
24
|
<a href="https://haveibeenpwned.com/API/Key">https://haveibeenpwned.com/API/Key</a> for the <code>pasteaccount</code> endpoint. The
|
|
27
25
|
<code>apiKey</code> option here is not explicitly required, but direct requests made
|
|
28
|
-
without it (
|
|
29
|
-
valid API key on your behalf)
|
|
30
|
-
</dd>
|
|
31
|
-
<dt><a href="#pwnedPassword">pwnedPassword(password, [options])</a> ⇒ <code>Promise.<number></code></dt>
|
|
32
|
-
<dd><p>Fetches the number of times the the given password has been exposed in a
|
|
33
|
-
breach (0 indicating no exposure). The password is given in plain text, but
|
|
34
|
-
only the first 5 characters of its SHA-1 hash will be submitted to the API.</p>
|
|
26
|
+
without it will fail (unless you specify a <code>baseUrl</code> to a proxy that inserts
|
|
27
|
+
a valid API key on your behalf).</p>
|
|
35
28
|
</dd>
|
|
36
29
|
<dt><a href="#pwnedPasswordRange">pwnedPasswordRange(prefix, [options])</a> ⇒ <code><a href="#PwnedPasswordSuffixes">Promise.<PwnedPasswordSuffixes></a></code></dt>
|
|
37
|
-
<dd><p>Fetches the SHA-1 hash suffixes for the given 5-character
|
|
30
|
+
<dd><p>Fetches the SHA-1 or NTLM hash suffixes for the given 5-character hash
|
|
31
|
+
prefix.</p>
|
|
38
32
|
<p>When a password hash with the same first 5 characters is found in the Pwned
|
|
39
33
|
Passwords repository, the API will respond with an HTTP 200 and include the
|
|
40
34
|
suffix of every hash beginning with the specified prefix, followed by a count
|
|
41
35
|
of how many times it appears in the data set. This function parses the
|
|
42
36
|
response and returns a more structured format.</p>
|
|
43
37
|
</dd>
|
|
44
|
-
<dt><a href="#
|
|
38
|
+
<dt><a href="#pwnedPassword">pwnedPassword(password, [options])</a> ⇒ <code>Promise.<number></code></dt>
|
|
39
|
+
<dd><p>Fetches the number of times the the given password has been exposed in a
|
|
40
|
+
breach (0 indicating no exposure). The password is given in plain text, but
|
|
41
|
+
only the first 5 characters of its SHA-1 hash will be submitted to the API.</p>
|
|
42
|
+
</dd>
|
|
43
|
+
<dt><a href="#search">search(account, [options])</a> ⇒ <code><a href="#SearchResults">Promise.<SearchResults></a></code></dt>
|
|
45
44
|
<dd><p>Fetches all breaches and all pastes associated with the provided account
|
|
46
45
|
(email address or username). Note that the remote API does not support
|
|
47
46
|
querying pastes by username (only email addresses), so in the event the
|
|
@@ -49,12 +48,19 @@ provided account is not a valid email address, only breach data is queried
|
|
|
49
48
|
and the "pastes" field of the resulting object will always be null. This is
|
|
50
49
|
exactly how searching via the current web interface behaves, which this
|
|
51
50
|
convenience method is designed to mimic.</p>
|
|
52
|
-
<p
|
|
53
|
-
<p><code>haveibeenpwned.com</code> now requires an API key from
|
|
51
|
+
<p>🔑 <code>haveibeenpwned.com</code> requires an API key from
|
|
54
52
|
<a href="https://haveibeenpwned.com/API/Key">https://haveibeenpwned.com/API/Key</a> for the <code>breachedaccount</code> and
|
|
55
|
-
<code>pasteaccount</code> endpoints. The
|
|
56
|
-
required, but direct requests made without it (
|
|
57
|
-
<code>baseUrl</code> to a proxy that inserts a valid API key on your behalf)
|
|
53
|
+
<code>pasteaccount</code> endpoints. The <code>apiKey</code> option here is not explicitly
|
|
54
|
+
required, but direct requests made without it will fail (unless you specify a
|
|
55
|
+
<code>baseUrl</code> to a proxy that inserts a valid API key on your behalf).</p>
|
|
56
|
+
</dd>
|
|
57
|
+
<dt><a href="#subscriptionStatus">subscriptionStatus([options])</a> ⇒ <code><a href="#subscriptionstatus--object">Promise.<SubscriptionStatus></a></code></dt>
|
|
58
|
+
<dd><p>Fetches the current status of your HIBP subscription (API key).</p>
|
|
59
|
+
<p>🔑 <code>haveibeenpwned.com</code> requires an API key from
|
|
60
|
+
<a href="https://haveibeenpwned.com/API/Key">https://haveibeenpwned.com/API/Key</a> for the <code>subscription/status</code> endpoint.
|
|
61
|
+
The <code>apiKey</code> option here is not explicitly required, but direct requests made
|
|
62
|
+
without it will fail (unless you specify a <code>baseUrl</code> to a proxy that inserts
|
|
63
|
+
a valid API key on your behalf).</p>
|
|
58
64
|
</dd>
|
|
59
65
|
</dl>
|
|
60
66
|
|
|
@@ -74,6 +80,9 @@ hash prefix) to how many times it occurred in the Pwned Passwords repository.</p
|
|
|
74
80
|
<dt><a href="#SearchResults">SearchResults</a> : <code>object</code></dt>
|
|
75
81
|
<dd><p>An object representing search results.</p>
|
|
76
82
|
</dd>
|
|
83
|
+
<dt><a href="#subscriptionstatus--object">SubscriptionStatus</a> : <code>object</code></dt>
|
|
84
|
+
<dd><p>An object representing the status of your HIBP subscription.</p>
|
|
85
|
+
</dd>
|
|
77
86
|
</dl>
|
|
78
87
|
|
|
79
88
|
<a name="breach"></a>
|
|
@@ -95,30 +104,27 @@ with an Error
|
|
|
95
104
|
|
|
96
105
|
**Example**
|
|
97
106
|
```js
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
// ...
|
|
102
|
-
} else {
|
|
103
|
-
// ...
|
|
104
|
-
}
|
|
105
|
-
})
|
|
106
|
-
.catch(err => {
|
|
107
|
+
try {
|
|
108
|
+
const data = await breach("Adobe");
|
|
109
|
+
if (data) {
|
|
107
110
|
// ...
|
|
108
|
-
}
|
|
111
|
+
} else {
|
|
112
|
+
// ...
|
|
113
|
+
}
|
|
114
|
+
} catch (err) {
|
|
115
|
+
// ...
|
|
116
|
+
}
|
|
109
117
|
```
|
|
110
118
|
<a name="breachedAccount"></a>
|
|
111
119
|
|
|
112
120
|
## breachedAccount(account, [options]) ⇒ <code><a href="#breach--object">Promise.<Array.<Breach>></a></code> \| <code>Promise.<null></code>
|
|
113
121
|
Fetches breach data for a specific account.
|
|
114
122
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
`haveibeenpwned.com` now requires an API key from
|
|
123
|
+
🔑 `haveibeenpwned.com` requires an API key from
|
|
118
124
|
https://haveibeenpwned.com/API/Key for the `breachedaccount` endpoint. The
|
|
119
125
|
`apiKey` option here is not explicitly required, but direct requests made
|
|
120
|
-
without it (
|
|
121
|
-
valid API key on your behalf)
|
|
126
|
+
without it will fail (unless you specify a `baseUrl` to a proxy that inserts
|
|
127
|
+
a valid API key on your behalf).
|
|
122
128
|
|
|
123
129
|
**Kind**: global function
|
|
124
130
|
**Returns**: <code><a href="#breach--object">Promise.<Array.<Breach>></a></code> \| <code>Promise.<null></code> - a Promise which resolves to an
|
|
@@ -138,53 +144,50 @@ an Error
|
|
|
138
144
|
|
|
139
145
|
**Example**
|
|
140
146
|
```js
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
// ...
|
|
145
|
-
} else {
|
|
146
|
-
// ...
|
|
147
|
-
}
|
|
148
|
-
})
|
|
149
|
-
.catch(err => {
|
|
147
|
+
try {
|
|
148
|
+
const data = await breachedAccount("foo", { apiKey: "my-api-key" });
|
|
149
|
+
if (data) {
|
|
150
150
|
// ...
|
|
151
|
-
}
|
|
151
|
+
} else {
|
|
152
|
+
// ...
|
|
153
|
+
}
|
|
154
|
+
} catch (err) {
|
|
155
|
+
// ...
|
|
156
|
+
}
|
|
152
157
|
```
|
|
153
158
|
**Example**
|
|
154
159
|
```js
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
.then(data => {
|
|
160
|
-
if (data) {
|
|
161
|
-
// ...
|
|
162
|
-
} else {
|
|
163
|
-
// ...
|
|
164
|
-
}
|
|
165
|
-
})
|
|
166
|
-
.catch(err => {
|
|
167
|
-
// ...
|
|
160
|
+
try {
|
|
161
|
+
const data = await breachedAccount("bar", {
|
|
162
|
+
includeUnverified: false,
|
|
163
|
+
baseUrl: "https://my-hibp-proxy:8080",
|
|
168
164
|
});
|
|
165
|
+
if (data) {
|
|
166
|
+
// ...
|
|
167
|
+
} else {
|
|
168
|
+
// ...
|
|
169
|
+
}
|
|
170
|
+
} catch (err) {
|
|
171
|
+
// ...
|
|
172
|
+
}
|
|
169
173
|
```
|
|
170
174
|
**Example**
|
|
171
175
|
```js
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
.then(data => {
|
|
179
|
-
if (data) {
|
|
180
|
-
// ...
|
|
181
|
-
} else {
|
|
182
|
-
// ...
|
|
183
|
-
}
|
|
184
|
-
})
|
|
185
|
-
.catch(err => {
|
|
186
|
-
// ...
|
|
176
|
+
try {
|
|
177
|
+
const data = await breachedAccount("baz", {
|
|
178
|
+
apiKey: "my-api-key",
|
|
179
|
+
domain: "adobe.com",
|
|
180
|
+
truncate: false,
|
|
181
|
+
userAgent: "my-app 1.0",
|
|
187
182
|
});
|
|
183
|
+
if (data) {
|
|
184
|
+
// ...
|
|
185
|
+
} else {
|
|
186
|
+
// ...
|
|
187
|
+
}
|
|
188
|
+
} catch (err) {
|
|
189
|
+
// ...
|
|
190
|
+
}
|
|
188
191
|
```
|
|
189
192
|
<a name="breaches"></a>
|
|
190
193
|
|
|
@@ -204,31 +207,29 @@ objects (an empty array if no breaches were found), or rejects with an Error
|
|
|
204
207
|
|
|
205
208
|
**Example**
|
|
206
209
|
```js
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
// ...
|
|
211
|
-
} else {
|
|
212
|
-
// ...
|
|
213
|
-
}
|
|
214
|
-
})
|
|
215
|
-
.catch(err => {
|
|
210
|
+
try {
|
|
211
|
+
const data = await breaches();
|
|
212
|
+
if (data) {
|
|
216
213
|
// ...
|
|
217
|
-
}
|
|
214
|
+
} else {
|
|
215
|
+
// ...
|
|
216
|
+
}
|
|
217
|
+
} catch (err) {
|
|
218
|
+
// ...
|
|
219
|
+
}
|
|
218
220
|
```
|
|
219
221
|
**Example**
|
|
220
222
|
```js
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
// ...
|
|
225
|
-
} else {
|
|
226
|
-
// ...
|
|
227
|
-
}
|
|
228
|
-
})
|
|
229
|
-
.catch(err => {
|
|
223
|
+
try {
|
|
224
|
+
const data = await breaches({ domain: "adobe.com" });
|
|
225
|
+
if (data) {
|
|
230
226
|
// ...
|
|
231
|
-
}
|
|
227
|
+
} else {
|
|
228
|
+
// ...
|
|
229
|
+
}
|
|
230
|
+
} catch (err) {
|
|
231
|
+
// ...
|
|
232
|
+
}
|
|
232
233
|
```
|
|
233
234
|
<a name="dataClasses"></a>
|
|
234
235
|
|
|
@@ -248,30 +249,27 @@ Error
|
|
|
248
249
|
|
|
249
250
|
**Example**
|
|
250
251
|
```js
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
// ...
|
|
255
|
-
} else {
|
|
256
|
-
// ...
|
|
257
|
-
}
|
|
258
|
-
})
|
|
259
|
-
.catch(err => {
|
|
252
|
+
try {
|
|
253
|
+
const data = await dataClasses();
|
|
254
|
+
if (data) {
|
|
260
255
|
// ...
|
|
261
|
-
}
|
|
256
|
+
} else {
|
|
257
|
+
// ...
|
|
258
|
+
}
|
|
259
|
+
} catch (err) {
|
|
260
|
+
// ...
|
|
261
|
+
}
|
|
262
262
|
```
|
|
263
263
|
<a name="pasteAccount"></a>
|
|
264
264
|
|
|
265
265
|
## pasteAccount(email, [options]) ⇒ <code><a href="#paste--object">Promise.<Array.<Paste>></a></code> \| <code>Promise.<null></code>
|
|
266
266
|
Fetches paste data for a specific account (email address).
|
|
267
267
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
`haveibeenpwned.com` now requires an API key from
|
|
268
|
+
🔑 `haveibeenpwned.com` requires an API key from
|
|
271
269
|
https://haveibeenpwned.com/API/Key for the `pasteaccount` endpoint. The
|
|
272
270
|
`apiKey` option here is not explicitly required, but direct requests made
|
|
273
|
-
without it (
|
|
274
|
-
valid API key on your behalf)
|
|
271
|
+
without it will fail (unless you specify a `baseUrl` to a proxy that inserts
|
|
272
|
+
a valid API key on your behalf).
|
|
275
273
|
|
|
276
274
|
**Kind**: global function
|
|
277
275
|
**Returns**: <code><a href="#paste--object">Promise.<Array.<Paste>></a></code> \| <code>Promise.<null></code> - a Promise which resolves to an
|
|
@@ -282,62 +280,43 @@ Error
|
|
|
282
280
|
| --- | --- | --- |
|
|
283
281
|
| email | <code>string</code> | the email address to query |
|
|
284
282
|
| [options] | <code>object</code> | a configuration object |
|
|
285
|
-
| [options.apiKey] | <code>string</code> | an API key from https://haveibeenpwned.com/API/Key |
|
|
283
|
+
| [options.apiKey] | <code>string</code> | an API key from https://haveibeenpwned.com/API/Key (default: undefined) |
|
|
286
284
|
| [options.baseUrl] | <code>string</code> | a custom base URL for the haveibeenpwned.com API endpoints (default: `https://haveibeenpwned.com/api/v3`) |
|
|
287
285
|
| [options.userAgent] | <code>string</code> | a custom string to send as the User-Agent field in the request headers (default: `hibp <version>`) |
|
|
288
286
|
|
|
289
287
|
**Example**
|
|
290
288
|
```js
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
// ...
|
|
295
|
-
} else {
|
|
296
|
-
// ...
|
|
297
|
-
}
|
|
298
|
-
})
|
|
299
|
-
.catch(err => {
|
|
289
|
+
try {
|
|
290
|
+
const data = await pasteAccount("foo@bar.com", { apiKey: "my-api-key" });
|
|
291
|
+
if (data) {
|
|
300
292
|
// ...
|
|
301
|
-
}
|
|
293
|
+
} else {
|
|
294
|
+
// ...
|
|
295
|
+
}
|
|
296
|
+
} catch (err) {
|
|
297
|
+
// ...
|
|
298
|
+
}
|
|
302
299
|
```
|
|
303
|
-
<a name="pwnedPassword"></a>
|
|
304
|
-
|
|
305
|
-
## pwnedPassword(password, [options]) ⇒ <code>Promise.<number></code>
|
|
306
|
-
Fetches the number of times the the given password has been exposed in a
|
|
307
|
-
breach (0 indicating no exposure). The password is given in plain text, but
|
|
308
|
-
only the first 5 characters of its SHA-1 hash will be submitted to the API.
|
|
309
|
-
|
|
310
|
-
**Kind**: global function
|
|
311
|
-
**Returns**: <code>Promise.<number></code> - a Promise which resolves to the number of times
|
|
312
|
-
the password has been exposed in a breach, or rejects with an Error
|
|
313
|
-
**See**: https://haveibeenpwned.com/api/v3#PwnedPasswords
|
|
314
|
-
|
|
315
|
-
| Param | Type | Description |
|
|
316
|
-
| --- | --- | --- |
|
|
317
|
-
| password | <code>string</code> | a password in plain text |
|
|
318
|
-
| [options] | <code>object</code> | a configuration object |
|
|
319
|
-
| [options.baseUrl] | <code>string</code> | a custom base URL for the pwnedpasswords.com API endpoints (default: `https://api.pwnedpasswords.com`) |
|
|
320
|
-
| [options.userAgent] | <code>string</code> | a custom string to send as the User-Agent field in the request headers (default: `hibp <version>`) |
|
|
321
|
-
|
|
322
300
|
**Example**
|
|
323
301
|
```js
|
|
324
|
-
|
|
325
|
-
.
|
|
326
|
-
|
|
327
|
-
if (numPwns) {
|
|
328
|
-
// ...
|
|
329
|
-
} else {
|
|
330
|
-
// ...
|
|
331
|
-
}
|
|
332
|
-
})
|
|
333
|
-
.catch(err => {
|
|
334
|
-
// ...
|
|
302
|
+
try {
|
|
303
|
+
const data = await pasteAccount("foo@bar.com", {
|
|
304
|
+
baseUrl: "https://my-hibp-proxy:8080",
|
|
335
305
|
});
|
|
306
|
+
if (data) {
|
|
307
|
+
// ...
|
|
308
|
+
} else {
|
|
309
|
+
// ...
|
|
310
|
+
}
|
|
311
|
+
} catch (err) {
|
|
312
|
+
// ...
|
|
313
|
+
}
|
|
336
314
|
```
|
|
337
315
|
<a name="pwnedPasswordRange"></a>
|
|
338
316
|
|
|
339
317
|
## pwnedPasswordRange(prefix, [options]) ⇒ [<code>Promise.<PwnedPasswordSuffixes></code>](#PwnedPasswordSuffixes)
|
|
340
|
-
Fetches the SHA-1 hash suffixes for the given 5-character
|
|
318
|
+
Fetches the SHA-1 or NTLM hash suffixes for the given 5-character hash
|
|
319
|
+
prefix.
|
|
341
320
|
|
|
342
321
|
When a password hash with the same first 5 characters is found in the Pwned
|
|
343
322
|
Passwords repository, the API will respond with an HTTP 200 and include the
|
|
@@ -354,35 +333,74 @@ password data set, or rejects with an Error
|
|
|
354
333
|
|
|
355
334
|
| Param | Type | Description |
|
|
356
335
|
| --- | --- | --- |
|
|
357
|
-
| prefix | <code>string</code> | the first 5 characters of a
|
|
336
|
+
| prefix | <code>string</code> | the first 5 characters of a password hash (case insensitive) |
|
|
358
337
|
| [options] | <code>object</code> | a configuration object |
|
|
338
|
+
| [options.addPadding] | <code>boolean</code> | ask the remote API to add padding to the response to obscure the password prefix (default: `false`) |
|
|
339
|
+
| [options.mode] | <code>'sha1'</code> \| <code>'ntlm'</code> | return SHA-1 or NTLM hashes (default: `sha1`) |
|
|
359
340
|
| [options.baseUrl] | <code>string</code> | a custom base URL for the pwnedpasswords.com API endpoints (default: `https://api.pwnedpasswords.com`) |
|
|
360
341
|
| [options.userAgent] | <code>string</code> | a custom string to send as the User-Agent field in the request headers (default: `hibp <version>`) |
|
|
361
342
|
|
|
362
343
|
**Example**
|
|
363
344
|
```js
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
345
|
+
try {
|
|
346
|
+
const results = await pwnedPasswordRange("5BAA6");
|
|
347
|
+
// results will have the following shape:
|
|
348
|
+
// {
|
|
349
|
+
// "003D68EB55068C33ACE09247EE4C639306B": 3,
|
|
350
|
+
// "012C192B2F16F82EA0EB9EF18D9D539B0DD": 1,
|
|
351
|
+
// ...
|
|
352
|
+
// }
|
|
353
|
+
} catch (err) {
|
|
354
|
+
// ...
|
|
355
|
+
}
|
|
373
356
|
```
|
|
374
357
|
**Example**
|
|
375
358
|
```js
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
359
|
+
try {
|
|
360
|
+
const suffix = "1E4C9B93F3F0682250B6CF8331B7EE68FD8";
|
|
361
|
+
const results = await pwnedPasswordRange("5BAA6");
|
|
362
|
+
const numPwns = results[suffix] || 0;
|
|
363
|
+
} catch (err) {
|
|
364
|
+
// ...
|
|
365
|
+
}
|
|
366
|
+
```
|
|
367
|
+
<a name="pwnedPassword"></a>
|
|
368
|
+
|
|
369
|
+
## pwnedPassword(password, [options]) ⇒ <code>Promise.<number></code>
|
|
370
|
+
Fetches the number of times the the given password has been exposed in a
|
|
371
|
+
breach (0 indicating no exposure). The password is given in plain text, but
|
|
372
|
+
only the first 5 characters of its SHA-1 hash will be submitted to the API.
|
|
373
|
+
|
|
374
|
+
**Kind**: global function
|
|
375
|
+
**Returns**: <code>Promise.<number></code> - a Promise which resolves to the number of times
|
|
376
|
+
the password has been exposed in a breach, or rejects with an Error
|
|
377
|
+
**See**: https://haveibeenpwned.com/api/v3#PwnedPasswords
|
|
378
|
+
|
|
379
|
+
| Param | Type | Description |
|
|
380
|
+
| --- | --- | --- |
|
|
381
|
+
| password | <code>string</code> | a password in plain text |
|
|
382
|
+
| [options] | <code>object</code> | a configuration object |
|
|
383
|
+
| [options.addPadding] | <code>boolean</code> | ask the remote API to add padding to the response to obscure the password prefix (default: `false`) |
|
|
384
|
+
| [options.baseUrl] | <code>string</code> | a custom base URL for the pwnedpasswords.com API endpoints (default: `https://api.pwnedpasswords.com`) |
|
|
385
|
+
| [options.userAgent] | <code>string</code> | a custom string to send as the User-Agent field in the request headers (default: `hibp <version>`) |
|
|
386
|
+
|
|
387
|
+
**Example**
|
|
388
|
+
```js
|
|
389
|
+
try {
|
|
390
|
+
const numPwns = await pwnedPassword("f00b4r");
|
|
391
|
+
// truthy check or numeric condition
|
|
392
|
+
if (numPwns) {
|
|
380
393
|
// ...
|
|
381
|
-
}
|
|
394
|
+
} else {
|
|
395
|
+
// ...
|
|
396
|
+
}
|
|
397
|
+
} catch (err) {
|
|
398
|
+
// ...
|
|
399
|
+
}
|
|
382
400
|
```
|
|
383
401
|
<a name="search"></a>
|
|
384
402
|
|
|
385
|
-
## search(account, [
|
|
403
|
+
## search(account, [options]) ⇒ [<code>Promise.<SearchResults></code>](#SearchResults)
|
|
386
404
|
Fetches all breaches and all pastes associated with the provided account
|
|
387
405
|
(email address or username). Note that the remote API does not support
|
|
388
406
|
querying pastes by username (only email addresses), so in the event the
|
|
@@ -391,13 +409,11 @@ and the "pastes" field of the resulting object will always be null. This is
|
|
|
391
409
|
exactly how searching via the current web interface behaves, which this
|
|
392
410
|
convenience method is designed to mimic.
|
|
393
411
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
`haveibeenpwned.com` now requires an API key from
|
|
412
|
+
🔑 `haveibeenpwned.com` requires an API key from
|
|
397
413
|
https://haveibeenpwned.com/API/Key for the `breachedaccount` and
|
|
398
|
-
`pasteaccount` endpoints. The
|
|
399
|
-
required, but direct requests made without it (
|
|
400
|
-
`baseUrl` to a proxy that inserts a valid API key on your behalf)
|
|
414
|
+
`pasteaccount` endpoints. The `apiKey` option here is not explicitly
|
|
415
|
+
required, but direct requests made without it will fail (unless you specify a
|
|
416
|
+
`baseUrl` to a proxy that inserts a valid API key on your behalf).
|
|
401
417
|
|
|
402
418
|
**Kind**: global function
|
|
403
419
|
**Returns**: [<code>Promise.<SearchResults></code>](#SearchResults) - a Promise which resolves to an object
|
|
@@ -409,40 +425,83 @@ rejects with an Error
|
|
|
409
425
|
| Param | Type | Description |
|
|
410
426
|
| --- | --- | --- |
|
|
411
427
|
| account | <code>string</code> | an email address or username |
|
|
412
|
-
| [
|
|
413
|
-
| [
|
|
414
|
-
| [
|
|
415
|
-
| [
|
|
416
|
-
| [
|
|
417
|
-
| [
|
|
428
|
+
| [options] | <code>object</code> | a configuration object |
|
|
429
|
+
| [options.apiKey] | <code>string</code> | an API key from https://haveibeenpwned.com/API/Key (default: undefined) |
|
|
430
|
+
| [options.domain] | <code>string</code> | a domain by which to filter the breach results (default: all domains) |
|
|
431
|
+
| [options.truncate] | <code>boolean</code> | truncate the breach results to only include the name of each breach (default: true) |
|
|
432
|
+
| [options.baseUrl] | <code>string</code> | a custom base URL for the haveibeenpwned.com API endpoints (default: `https://haveibeenpwned.com/api/v3`) |
|
|
433
|
+
| [options.userAgent] | <code>string</code> | a custom string to send as the User-Agent field in the request headers (default: `hibp <version>`) |
|
|
418
434
|
|
|
419
435
|
**Example**
|
|
420
436
|
```js
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
// ...
|
|
425
|
-
} else {
|
|
426
|
-
// ...
|
|
427
|
-
}
|
|
428
|
-
})
|
|
429
|
-
.catch(err => {
|
|
437
|
+
try {
|
|
438
|
+
const data = await search("foo", { apiKey: "my-api-key" });
|
|
439
|
+
if (data.breaches || data.pastes) {
|
|
430
440
|
// ...
|
|
431
|
-
}
|
|
441
|
+
} else {
|
|
442
|
+
// ...
|
|
443
|
+
}
|
|
444
|
+
} catch (err) {
|
|
445
|
+
// ...
|
|
446
|
+
}
|
|
432
447
|
```
|
|
433
448
|
**Example**
|
|
434
449
|
```js
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
}
|
|
443
|
-
.catch(err => {
|
|
450
|
+
try {
|
|
451
|
+
const data = await search("nobody@nowhere.com", {
|
|
452
|
+
baseUrl: "https://my-hibp-proxy:8080",
|
|
453
|
+
truncate: false,
|
|
454
|
+
});
|
|
455
|
+
if (data.breaches || data.pastes) {
|
|
456
|
+
// ...
|
|
457
|
+
} else {
|
|
444
458
|
// ...
|
|
459
|
+
}
|
|
460
|
+
} catch (err) {
|
|
461
|
+
// ...
|
|
462
|
+
}
|
|
463
|
+
```
|
|
464
|
+
<a name="subscriptionStatus"></a>
|
|
465
|
+
|
|
466
|
+
## subscriptionStatus([options]) ⇒ [<code>Promise.<SubscriptionStatus></code>](#subscriptionstatus--object)
|
|
467
|
+
Fetches the current status of your HIBP subscription (API key).
|
|
468
|
+
|
|
469
|
+
🔑 `haveibeenpwned.com` requires an API key from
|
|
470
|
+
https://haveibeenpwned.com/API/Key for the `subscription/status` endpoint.
|
|
471
|
+
The `apiKey` option here is not explicitly required, but direct requests made
|
|
472
|
+
without it will fail (unless you specify a `baseUrl` to a proxy that inserts
|
|
473
|
+
a valid API key on your behalf).
|
|
474
|
+
|
|
475
|
+
**Kind**: global function
|
|
476
|
+
**Returns**: [<code>Promise.<SubscriptionStatus></code>](#subscriptionstatus--object) - a Promise which resolves to a
|
|
477
|
+
subscription status object, or rejects with an Error
|
|
478
|
+
|
|
479
|
+
| Param | Type | Description |
|
|
480
|
+
| --- | --- | --- |
|
|
481
|
+
| [options] | <code>object</code> | a configuration object |
|
|
482
|
+
| [options.apiKey] | <code>string</code> | an API key from https://haveibeenpwned.com/API/Key (default: undefined) |
|
|
483
|
+
| [options.baseUrl] | <code>string</code> | a custom base URL for the haveibeenpwned.com API endpoints (default: `https://haveibeenpwned.com/api/v3`) |
|
|
484
|
+
| [options.userAgent] | <code>string</code> | a custom string to send as the User-Agent field in the request headers (default: `hibp <version>`) |
|
|
485
|
+
|
|
486
|
+
**Example**
|
|
487
|
+
```js
|
|
488
|
+
try {
|
|
489
|
+
const data = await subscriptionStatus({ apiKey: "my-api-key" });
|
|
490
|
+
// ...
|
|
491
|
+
} catch (err) {
|
|
492
|
+
// ...
|
|
493
|
+
}
|
|
494
|
+
```
|
|
495
|
+
**Example**
|
|
496
|
+
```js
|
|
497
|
+
try {
|
|
498
|
+
const data = await subscriptionStatus({
|
|
499
|
+
baseUrl: "https://my-hibp-proxy:8080",
|
|
445
500
|
});
|
|
501
|
+
// ...
|
|
502
|
+
} catch (err) {
|
|
503
|
+
// ...
|
|
504
|
+
}
|
|
446
505
|
```
|
|
447
506
|
<a name="Breach"></a>
|
|
448
507
|
|
|
@@ -462,13 +521,15 @@ An object representing a breach.
|
|
|
462
521
|
| ModifiedDate | <code>string</code> |
|
|
463
522
|
| PwnCount | <code>number</code> |
|
|
464
523
|
| Description | <code>string</code> |
|
|
465
|
-
| LogoPath | <code>string</code> |
|
|
466
524
|
| DataClasses | <code>Array.<string></code> |
|
|
467
525
|
| IsVerified | <code>boolean</code> |
|
|
468
526
|
| IsFabricated | <code>boolean</code> |
|
|
469
527
|
| IsSensitive | <code>boolean</code> |
|
|
470
528
|
| IsRetired | <code>boolean</code> |
|
|
471
529
|
| IsSpamList | <code>boolean</code> |
|
|
530
|
+
| IsMalware | <code>boolean</code> |
|
|
531
|
+
| IsSubscriptionFree | <code>boolean</code> |
|
|
532
|
+
| LogoPath | <code>string</code> |
|
|
472
533
|
|
|
473
534
|
<a name="Paste"></a>
|
|
474
535
|
|
|
@@ -506,3 +567,19 @@ An object representing search results.
|
|
|
506
567
|
| breaches | [<code>Array.<Breach></code>](#breach--object) \| <code>null</code> |
|
|
507
568
|
| pastes | [<code>Array.<Paste></code>](#Paste) \| <code>null</code> |
|
|
508
569
|
|
|
570
|
+
<a name="SubscriptionStatus"></a>
|
|
571
|
+
|
|
572
|
+
## SubscriptionStatus : <code>object</code>
|
|
573
|
+
An object representing the status of your HIBP subscription.
|
|
574
|
+
|
|
575
|
+
**Kind**: global typedef
|
|
576
|
+
**Properties**
|
|
577
|
+
|
|
578
|
+
| Name | Type |
|
|
579
|
+
| --- | --- |
|
|
580
|
+
| SubscriptionName | <code>string</code> |
|
|
581
|
+
| Description | <code>string</code> |
|
|
582
|
+
| SubscribedUntil | <code>string</code> |
|
|
583
|
+
| Rpm | <code>number</code> |
|
|
584
|
+
| DomainSearchMaxBreachedAccounts | <code>number</code> |
|
|
585
|
+
|