hibp 0.0.0-dev.9896b89a → 0.0.0-dev.d74e2ad2

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.
Files changed (119) hide show
  1. package/API.md +275 -198
  2. package/CHANGELOG.md +70 -0
  3. package/README.md +20 -22
  4. package/dist/browser/hibp.module.js +1 -1
  5. package/dist/browser/hibp.module.js.map +1 -1
  6. package/dist/browser/hibp.umd.js +1 -1
  7. package/dist/browser/hibp.umd.js.map +1 -1
  8. package/dist/cjs/api/fetch-polyfill.cjs +27 -0
  9. package/dist/cjs/api/fetch-polyfill.cjs.map +1 -0
  10. package/dist/cjs/api/haveibeenpwned/{fetchFromApi.js → fetch-from-api.cjs} +43 -38
  11. package/dist/cjs/api/haveibeenpwned/fetch-from-api.cjs.map +1 -0
  12. package/dist/cjs/api/haveibeenpwned/{responses.js → responses.cjs} +1 -7
  13. package/dist/cjs/api/haveibeenpwned/responses.cjs.map +1 -0
  14. package/dist/cjs/api/haveibeenpwned/types.cjs +2 -0
  15. package/dist/cjs/api/haveibeenpwned/types.cjs.map +1 -0
  16. package/dist/cjs/api/pwnedpasswords/fetch-from-api.cjs +53 -0
  17. package/dist/cjs/api/pwnedpasswords/fetch-from-api.cjs.map +1 -0
  18. package/dist/cjs/api/pwnedpasswords/{responses.js → responses.cjs} +1 -6
  19. package/dist/cjs/api/pwnedpasswords/responses.cjs.map +1 -0
  20. package/dist/cjs/{breach.js → breach.cjs} +14 -13
  21. package/dist/cjs/breach.cjs.map +1 -0
  22. package/dist/cjs/{breachedAccount.js → breached-account.cjs} +56 -56
  23. package/dist/cjs/breached-account.cjs.map +1 -0
  24. package/dist/cjs/{breaches.js → breaches.cjs} +29 -26
  25. package/dist/cjs/breaches.cjs.map +1 -0
  26. package/dist/cjs/{dataClasses.js → data-classes.cjs} +11 -12
  27. package/dist/cjs/data-classes.cjs.map +1 -0
  28. package/dist/cjs/hibp.cjs +23 -0
  29. package/dist/cjs/hibp.cjs.map +1 -0
  30. package/dist/cjs/hibp.d.cts +663 -0
  31. package/dist/cjs/{package.json.js → package.json.cjs} +2 -2
  32. package/dist/cjs/package.json.cjs.map +1 -0
  33. package/dist/cjs/{pasteAccount.js → paste-account.cjs} +28 -22
  34. package/dist/cjs/paste-account.cjs.map +1 -0
  35. package/dist/cjs/{pwnedPasswordRange.js → pwned-password-range.cjs} +44 -25
  36. package/dist/cjs/pwned-password-range.cjs.map +1 -0
  37. package/dist/cjs/{pwnedPassword.js → pwned-password.cjs} +20 -15
  38. package/dist/cjs/pwned-password.cjs.map +1 -0
  39. package/dist/cjs/{search.js → search.cjs} +51 -49
  40. package/dist/cjs/search.cjs.map +1 -0
  41. package/dist/cjs/subscription-status.cjs +56 -0
  42. package/dist/cjs/subscription-status.cjs.map +1 -0
  43. package/dist/esm/api/fetch-polyfill.js +25 -0
  44. package/dist/esm/api/fetch-polyfill.js.map +1 -0
  45. package/dist/esm/api/haveibeenpwned/{fetchFromApi.mjs → fetch-from-api.js} +43 -38
  46. package/dist/esm/api/haveibeenpwned/fetch-from-api.js.map +1 -0
  47. package/dist/esm/api/haveibeenpwned/{responses.mjs → responses.js} +2 -7
  48. package/dist/esm/api/haveibeenpwned/responses.js.map +1 -0
  49. package/dist/esm/api/haveibeenpwned/types.js +2 -0
  50. package/dist/esm/api/haveibeenpwned/types.js.map +1 -0
  51. package/dist/esm/api/pwnedpasswords/fetch-from-api.js +51 -0
  52. package/dist/esm/api/pwnedpasswords/fetch-from-api.js.map +1 -0
  53. package/dist/esm/api/pwnedpasswords/{responses.mjs → responses.js} +2 -6
  54. package/dist/esm/api/pwnedpasswords/responses.js.map +1 -0
  55. package/dist/esm/{breach.mjs → breach.js} +14 -13
  56. package/dist/esm/breach.js.map +1 -0
  57. package/dist/esm/{breachedAccount.mjs → breached-account.js} +56 -56
  58. package/dist/esm/breached-account.js.map +1 -0
  59. package/dist/esm/{breaches.mjs → breaches.js} +29 -26
  60. package/dist/esm/breaches.js.map +1 -0
  61. package/dist/esm/{dataClasses.mjs → data-classes.js} +11 -12
  62. package/dist/esm/data-classes.js.map +1 -0
  63. package/dist/esm/hibp.d.ts +663 -0
  64. package/dist/esm/hibp.js +11 -0
  65. package/dist/{cjs → esm}/hibp.js.map +1 -1
  66. package/dist/esm/package.json.js +4 -0
  67. package/dist/{cjs → esm}/package.json.js.map +1 -1
  68. package/dist/esm/{pasteAccount.mjs → paste-account.js} +28 -22
  69. package/dist/esm/paste-account.js.map +1 -0
  70. package/dist/esm/{pwnedPasswordRange.mjs → pwned-password-range.js} +44 -25
  71. package/dist/esm/pwned-password-range.js.map +1 -0
  72. package/dist/esm/{pwnedPassword.mjs → pwned-password.js} +20 -15
  73. package/dist/esm/pwned-password.js.map +1 -0
  74. package/dist/esm/{search.mjs → search.js} +51 -49
  75. package/dist/esm/search.js.map +1 -0
  76. package/dist/esm/subscription-status.js +54 -0
  77. package/dist/esm/subscription-status.js.map +1 -0
  78. package/example/runkit.js +13 -14
  79. package/package.json +57 -64
  80. package/dist/cjs/api/haveibeenpwned/fetchFromApi.js.map +0 -1
  81. package/dist/cjs/api/haveibeenpwned/index.js +0 -6
  82. package/dist/cjs/api/haveibeenpwned/index.js.map +0 -1
  83. package/dist/cjs/api/haveibeenpwned/responses.js.map +0 -1
  84. package/dist/cjs/api/pwnedpasswords/fetchFromApi.js +0 -44
  85. package/dist/cjs/api/pwnedpasswords/fetchFromApi.js.map +0 -1
  86. package/dist/cjs/api/pwnedpasswords/index.js +0 -5
  87. package/dist/cjs/api/pwnedpasswords/index.js.map +0 -1
  88. package/dist/cjs/api/pwnedpasswords/responses.js.map +0 -1
  89. package/dist/cjs/breach.js.map +0 -1
  90. package/dist/cjs/breachedAccount.js.map +0 -1
  91. package/dist/cjs/breaches.js.map +0 -1
  92. package/dist/cjs/dataClasses.js.map +0 -1
  93. package/dist/cjs/hibp.js +0 -21
  94. package/dist/cjs/pasteAccount.js.map +0 -1
  95. package/dist/cjs/pwnedPassword.js.map +0 -1
  96. package/dist/cjs/pwnedPasswordRange.js.map +0 -1
  97. package/dist/cjs/search.js.map +0 -1
  98. package/dist/esm/api/haveibeenpwned/fetchFromApi.mjs.map +0 -1
  99. package/dist/esm/api/haveibeenpwned/index.mjs +0 -2
  100. package/dist/esm/api/haveibeenpwned/index.mjs.map +0 -1
  101. package/dist/esm/api/haveibeenpwned/responses.mjs.map +0 -1
  102. package/dist/esm/api/pwnedpasswords/fetchFromApi.mjs +0 -42
  103. package/dist/esm/api/pwnedpasswords/fetchFromApi.mjs.map +0 -1
  104. package/dist/esm/api/pwnedpasswords/index.mjs +0 -2
  105. package/dist/esm/api/pwnedpasswords/index.mjs.map +0 -1
  106. package/dist/esm/api/pwnedpasswords/responses.mjs.map +0 -1
  107. package/dist/esm/breach.mjs.map +0 -1
  108. package/dist/esm/breachedAccount.mjs.map +0 -1
  109. package/dist/esm/breaches.mjs.map +0 -1
  110. package/dist/esm/dataClasses.mjs.map +0 -1
  111. package/dist/esm/hibp.mjs +0 -10
  112. package/dist/esm/hibp.mjs.map +0 -1
  113. package/dist/esm/package.json.mjs +0 -4
  114. package/dist/esm/package.json.mjs.map +0 -1
  115. package/dist/esm/pasteAccount.mjs.map +0 -1
  116. package/dist/esm/pwnedPassword.mjs.map +0 -1
  117. package/dist/esm/pwnedPasswordRange.mjs.map +0 -1
  118. package/dist/esm/search.mjs.map +0 -1
  119. package/dist/hibp.d.ts +0 -502
@@ -0,0 +1,663 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ /**
4
+ * Custom error thrown when the haveibeenpwned.com API responds with 429 Too
5
+ * Many Requests. See the `retryAfterSeconds` property for the number of seconds
6
+ * to wait before attempting the request again.
7
+ *
8
+ * @see https://haveibeenpwned.com/API/v3#RateLimiting
9
+ */
10
+ export declare class RateLimitError extends Error {
11
+ /**
12
+ * The number of seconds to wait before attempting the request again. May be
13
+ * `undefined` if the API does not provide a `retry-after` header, but this
14
+ * should never happen.
15
+ */
16
+ retryAfterSeconds: number | undefined;
17
+ constructor(retryAfter: ReturnType<Headers["get"]>, message: string | undefined, options?: ErrorOptions);
18
+ }
19
+ export interface Breach {
20
+ Name: string;
21
+ Title: string;
22
+ Domain: string;
23
+ BreachDate: string;
24
+ AddedDate: string;
25
+ ModifiedDate: string;
26
+ PwnCount: number;
27
+ Description: string;
28
+ DataClasses: string[];
29
+ IsVerified: boolean;
30
+ IsFabricated: boolean;
31
+ IsSensitive: boolean;
32
+ IsRetired: boolean;
33
+ IsSpamList: boolean;
34
+ IsMalware: boolean;
35
+ IsSubscriptionFree: boolean;
36
+ LogoPath: string;
37
+ }
38
+ export interface Paste {
39
+ Id: string;
40
+ Source: string;
41
+ Title: string;
42
+ Date: string;
43
+ EmailCount: number;
44
+ }
45
+ export interface SubscriptionStatus {
46
+ SubscriptionName: string;
47
+ Description: string;
48
+ SubscribedUntil: string;
49
+ Rpm: number;
50
+ DomainSearchMaxBreachedAccounts: number;
51
+ }
52
+ /**
53
+ * An object representing a breach.
54
+ *
55
+ * @typedef {object} Breach
56
+ * @property {string} Name
57
+ * @property {string} Title
58
+ * @property {string} Domain
59
+ * @property {string} BreachDate
60
+ * @property {string} AddedDate
61
+ * @property {string} ModifiedDate
62
+ * @property {number} PwnCount
63
+ * @property {string} Description
64
+ * @property {string[]} DataClasses
65
+ * @property {boolean} IsVerified
66
+ * @property {boolean} IsFabricated
67
+ * @property {boolean} IsSensitive
68
+ * @property {boolean} IsRetired
69
+ * @property {boolean} IsSpamList
70
+ * @property {boolean} IsMalware
71
+ * @property {boolean} IsSubscriptionFree
72
+ * @property {string} LogoPath
73
+ */
74
+ /**
75
+ * Fetches data for a specific breach event.
76
+ *
77
+ * @param {string} breachName the name of a breach in the system
78
+ * @param {object} [options] a configuration object
79
+ * @param {string} [options.baseUrl] a custom base URL for the
80
+ * haveibeenpwned.com API endpoints (default:
81
+ * `https://haveibeenpwned.com/api/v3`)
82
+ * @param {string} [options.userAgent] a custom string to send as the User-Agent
83
+ * field in the request headers (default: `hibp <version>`)
84
+ * @returns {(Promise<Breach>|Promise<null>)} a Promise which resolves to an
85
+ * object representing a breach (or null if no breach was found), or rejects
86
+ * with an Error
87
+ * @example
88
+ * try {
89
+ * const data = await breach("Adobe");
90
+ * if (data) {
91
+ * // ...
92
+ * } else {
93
+ * // ...
94
+ * }
95
+ * } catch (err) {
96
+ * // ...
97
+ * }
98
+ */
99
+ export declare function breach(breachName: string, options?: {
100
+ /**
101
+ * a custom base URL for the haveibeenpwned.com API endpoints (default:
102
+ * `https://haveibeenpwned.com/api/v3`)
103
+ */
104
+ baseUrl?: string;
105
+ /**
106
+ * a custom string to send as the User-Agent field in the request headers
107
+ * (default: `hibp <version>`)
108
+ */
109
+ userAgent?: string;
110
+ }): Promise<Breach | null>;
111
+ /**
112
+ * Fetches breach data for a specific account.
113
+ *
114
+ * 🔑 `haveibeenpwned.com` requires an API key from
115
+ * https://haveibeenpwned.com/API/Key for the `breachedaccount` endpoint. The
116
+ * `apiKey` option here is not explicitly required, but direct requests made
117
+ * without it will fail (unless you specify a `baseUrl` to a proxy that inserts
118
+ * a valid API key on your behalf).
119
+ *
120
+ * @param {string} account a username or email address
121
+ * @param {object} [options] a configuration object
122
+ * @param {string} [options.apiKey] an API key from
123
+ * https://haveibeenpwned.com/API/Key (default: undefined)
124
+ * @param {string} [options.domain] a domain by which to filter the results
125
+ * (default: all domains)
126
+ * @param {boolean} [options.includeUnverified] include "unverified" breaches in
127
+ * the results (default: true)
128
+ * @param {boolean} [options.truncate] truncate the results to only include
129
+ * the name of each breach (default: true)
130
+ * @param {string} [options.baseUrl] a custom base URL for the
131
+ * haveibeenpwned.com API endpoints (default:
132
+ * `https://haveibeenpwned.com/api/v3`)
133
+ * @param {string} [options.userAgent] a custom string to send as the User-Agent
134
+ * field in the request headers (default: `hibp <version>`)
135
+ * @returns {(Promise<Breach[]> | Promise<null>)} a Promise which resolves to an
136
+ * array of breach objects (or null if no breaches were found), or rejects with
137
+ * an Error
138
+ * @example
139
+ * try {
140
+ * const data = await breachedAccount("foo", { apiKey: "my-api-key" });
141
+ * if (data) {
142
+ * // ...
143
+ * } else {
144
+ * // ...
145
+ * }
146
+ * } catch (err) {
147
+ * // ...
148
+ * }
149
+ * @example
150
+ * try {
151
+ * const data = await breachedAccount("bar", {
152
+ * includeUnverified: false,
153
+ * baseUrl: "https://my-hibp-proxy:8080",
154
+ * });
155
+ * if (data) {
156
+ * // ...
157
+ * } else {
158
+ * // ...
159
+ * }
160
+ * } catch (err) {
161
+ * // ...
162
+ * }
163
+ * @example
164
+ * try {
165
+ * const data = await breachedAccount("baz", {
166
+ * apiKey: "my-api-key",
167
+ * domain: "adobe.com",
168
+ * truncate: false,
169
+ * userAgent: "my-app 1.0",
170
+ * });
171
+ * if (data) {
172
+ * // ...
173
+ * } else {
174
+ * // ...
175
+ * }
176
+ * } catch (err) {
177
+ * // ...
178
+ * }
179
+ */
180
+ export declare function breachedAccount(account: string, options?: {
181
+ /**
182
+ * an API key from https://haveibeenpwned.com/API/Key (default: undefined)
183
+ */
184
+ apiKey?: string;
185
+ /**
186
+ * a domain by which to filter the results (default: all domains)
187
+ */
188
+ domain?: string;
189
+ /**
190
+ * include "unverified" breaches in the results (default: true)
191
+ */
192
+ includeUnverified?: boolean;
193
+ /**
194
+ * truncate the results to only include the name of each breach (default:
195
+ * true)
196
+ */
197
+ truncate?: boolean;
198
+ /**
199
+ * a custom base URL for the haveibeenpwned.com API endpoints (default:
200
+ * `https://haveibeenpwned.com/api/v3`)
201
+ */
202
+ baseUrl?: string;
203
+ /**
204
+ * a custom string to send as the User-Agent field in the request headers
205
+ * (default: `hibp <version>`)
206
+ */
207
+ userAgent?: string;
208
+ }): Promise<Breach[] | null>;
209
+ /**
210
+ * Fetches all breach events in the system.
211
+ *
212
+ * @param {object} [options] a configuration object
213
+ * @param {string} [options.domain] a domain by which to filter the results
214
+ * (default: all domains)
215
+ * @param {string} [options.baseUrl] a custom base URL for the
216
+ * haveibeenpwned.com API endpoints (default:
217
+ * `https://haveibeenpwned.com/api/v3`)
218
+ * @param {string} [options.userAgent] a custom string to send as the User-Agent
219
+ * field in the request headers (default: `hibp <version>`)
220
+ * @returns {Promise<Breach[]>} a Promise which resolves to an array of breach
221
+ * objects (an empty array if no breaches were found), or rejects with an Error
222
+ * @example
223
+ * try {
224
+ * const data = await breaches();
225
+ * if (data) {
226
+ * // ...
227
+ * } else {
228
+ * // ...
229
+ * }
230
+ * } catch (err) {
231
+ * // ...
232
+ * }
233
+ * @example
234
+ * try {
235
+ * const data = await breaches({ domain: "adobe.com" });
236
+ * if (data) {
237
+ * // ...
238
+ * } else {
239
+ * // ...
240
+ * }
241
+ * } catch (err) {
242
+ * // ...
243
+ * }
244
+ */
245
+ export declare function breaches(options?: {
246
+ /**
247
+ * a domain by which to filter the results (default: all domains)
248
+ */
249
+ domain?: string;
250
+ /**
251
+ * a custom base URL for the haveibeenpwned.com API endpoints (default:
252
+ * `https://haveibeenpwned.com/api/v3`)
253
+ */
254
+ baseUrl?: string;
255
+ /**
256
+ * a custom string to send as the User-Agent field in the request headers
257
+ * (default: `hibp <version>`)
258
+ */
259
+ userAgent?: string;
260
+ }): Promise<Breach[]>;
261
+ /**
262
+ * Fetches all data classes in the system.
263
+ *
264
+ * @param {object} [options] a configuration object
265
+ * @param {string} [options.baseUrl] a custom base URL for the
266
+ * haveibeenpwned.com API endpoints (default:
267
+ * `https://haveibeenpwned.com/api/v3`)
268
+ * @param {string} [options.userAgent] a custom string to send as the User-Agent
269
+ * field in the request headers (default: `hibp <version>`)
270
+ * @returns {(Promise<string[]> | Promise<null>)} a Promise which resolves to an
271
+ * array of strings (or null if no data classes were found), or rejects with an
272
+ * Error
273
+ * @example
274
+ * try {
275
+ * const data = await dataClasses();
276
+ * if (data) {
277
+ * // ...
278
+ * } else {
279
+ * // ...
280
+ * }
281
+ * } catch (err) {
282
+ * // ...
283
+ * }
284
+ */
285
+ export declare function dataClasses(options?: {
286
+ /**
287
+ * a custom base URL for the haveibeenpwned.com API endpoints (default:
288
+ * `https://haveibeenpwned.com/api/v3`)
289
+ */
290
+ baseUrl?: string;
291
+ /**
292
+ * a custom string to send as the User-Agent field in the request headers
293
+ * (default: `hibp <version>`)
294
+ */
295
+ userAgent?: string;
296
+ }): Promise<string[] | null>;
297
+ /**
298
+ * An object representing a paste.
299
+ *
300
+ * @typedef {object} Paste
301
+ * @property {string} Id
302
+ * @property {string} Source
303
+ * @property {string} Title
304
+ * @property {string} Date
305
+ * @property {number} EmailCount
306
+ */
307
+ /**
308
+ * Fetches paste data for a specific account (email address).
309
+ *
310
+ * 🔑 `haveibeenpwned.com` requires an API key from
311
+ * https://haveibeenpwned.com/API/Key for the `pasteaccount` endpoint. The
312
+ * `apiKey` option here is not explicitly required, but direct requests made
313
+ * without it will fail (unless you specify a `baseUrl` to a proxy that inserts
314
+ * a valid API key on your behalf).
315
+ *
316
+ * @param {string} email the email address to query
317
+ * @param {object} [options] a configuration object
318
+ * @param {string} [options.apiKey] an API key from
319
+ * https://haveibeenpwned.com/API/Key (default: undefined)
320
+ * @param {string} [options.baseUrl] a custom base URL for the
321
+ * haveibeenpwned.com API endpoints (default:
322
+ * `https://haveibeenpwned.com/api/v3`)
323
+ * @param {string} [options.userAgent] a custom string to send as the User-Agent
324
+ * field in the request headers (default: `hibp <version>`)
325
+ * @returns {(Promise<Paste[]> | Promise<null>)} a Promise which resolves to an
326
+ * array of paste objects (or null if no pastes were found), or rejects with an
327
+ * Error
328
+ * @example
329
+ * try {
330
+ * const data = await pasteAccount("foo@bar.com", { apiKey: "my-api-key" });
331
+ * if (data) {
332
+ * // ...
333
+ * } else {
334
+ * // ...
335
+ * }
336
+ * } catch (err) {
337
+ * // ...
338
+ * }
339
+ * @example
340
+ * try {
341
+ * const data = await pasteAccount("foo@bar.com", {
342
+ * baseUrl: "https://my-hibp-proxy:8080",
343
+ * });
344
+ * if (data) {
345
+ * // ...
346
+ * } else {
347
+ * // ...
348
+ * }
349
+ * } catch (err) {
350
+ * // ...
351
+ * }
352
+ */
353
+ export declare function pasteAccount(email: string, options?: {
354
+ /**
355
+ * an API key from https://haveibeenpwned.com/API/Key (default: undefined)
356
+ */
357
+ apiKey?: string;
358
+ /**
359
+ * a custom base URL for the haveibeenpwned.com API endpoints (default:
360
+ * `https://haveibeenpwned.com/api/v3`)
361
+ */
362
+ baseUrl?: string;
363
+ /**
364
+ * a custom string to send as the User-Agent field in the request headers
365
+ * (default: `hibp <version>`)
366
+ */
367
+ userAgent?: string;
368
+ }): Promise<Paste[] | null>;
369
+ /**
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
+ * @param {string} password a password in plain text
375
+ * @param {object} [options] a configuration object
376
+ * @param {boolean} [options.addPadding] ask the remote API to add padding to
377
+ * the response to obscure the password prefix (default: `false`)
378
+ * @param {string} [options.baseUrl] a custom base URL for the
379
+ * pwnedpasswords.com API endpoints (default: `https://api.pwnedpasswords.com`)
380
+ * @param {string} [options.userAgent] a custom string to send as the User-Agent
381
+ * field in the request headers (default: `hibp <version>`)
382
+ * @returns {Promise<number>} a Promise which resolves to the number of times
383
+ * the password has been exposed in a breach, or rejects with an Error
384
+ * @example
385
+ * try {
386
+ * const numPwns = await pwnedPassword("f00b4r");
387
+ * // truthy check or numeric condition
388
+ * if (numPwns) {
389
+ * // ...
390
+ * } else {
391
+ * // ...
392
+ * }
393
+ * } catch (err) {
394
+ * // ...
395
+ * }
396
+ * @see https://haveibeenpwned.com/api/v3#PwnedPasswords
397
+ */
398
+ export declare function pwnedPassword(password: string, options?: {
399
+ /**
400
+ * ask the remote API to add padding to the response to obscure the password
401
+ * prefix (default: `false`)
402
+ */
403
+ addPadding?: boolean;
404
+ /**
405
+ * a custom base URL for the haveibeenpwned.com API endpoints (default:
406
+ * `https://haveibeenpwned.com/api/v3`)
407
+ */
408
+ baseUrl?: string;
409
+ /**
410
+ * a custom string to send as the User-Agent field in the request headers
411
+ * (default: `hibp <version>`)
412
+ */
413
+ userAgent?: string;
414
+ }): Promise<number>;
415
+ export type PwnedPasswordSuffixes = Record<string, number>;
416
+ /**
417
+ * An object mapping an exposed password hash suffix (corresponding to a given
418
+ * hash prefix) to how many times it occurred in the Pwned Passwords repository.
419
+ *
420
+ * @typedef {Object.<string, number>} PwnedPasswordSuffixes
421
+ */
422
+ /**
423
+ * Fetches the SHA-1 or NTLM hash suffixes for the given 5-character hash
424
+ * prefix.
425
+ *
426
+ * When a password hash with the same first 5 characters is found in the Pwned
427
+ * Passwords repository, the API will respond with an HTTP 200 and include the
428
+ * suffix of every hash beginning with the specified prefix, followed by a count
429
+ * of how many times it appears in the data set. This function parses the
430
+ * response and returns a more structured format.
431
+ *
432
+ * @param {string} prefix the first 5 characters of a password hash (case
433
+ * insensitive)
434
+ * @param {object} [options] a configuration object
435
+ * @param {boolean} [options.addPadding] ask the remote API to add padding to
436
+ * the response to obscure the password prefix (default: `false`)
437
+ * @param {'sha1' | 'ntlm'} [options.mode] return SHA-1 or NTLM hashes
438
+ * (default: `sha1`)
439
+ * @param {string} [options.baseUrl] a custom base URL for the
440
+ * pwnedpasswords.com API endpoints (default: `https://api.pwnedpasswords.com`)
441
+ * @param {string} [options.userAgent] a custom string to send as the User-Agent
442
+ * field in the request headers (default: `hibp <version>`)
443
+ * @returns {Promise<PwnedPasswordSuffixes>} a Promise which resolves to an
444
+ * object mapping the `suffix` that when matched with the prefix composes the
445
+ * complete hash, to the `count` of how many times it appears in the breached
446
+ * password data set, or rejects with an Error
447
+ *
448
+ * @example
449
+ * try {
450
+ * const results = await pwnedPasswordRange("5BAA6");
451
+ * // results will have the following shape:
452
+ * // {
453
+ * // "003D68EB55068C33ACE09247EE4C639306B": 3,
454
+ * // "012C192B2F16F82EA0EB9EF18D9D539B0DD": 1,
455
+ * // ...
456
+ * // }
457
+ * } catch (err) {
458
+ * // ...
459
+ * }
460
+ * @example
461
+ * try {
462
+ * const suffix = "1E4C9B93F3F0682250B6CF8331B7EE68FD8";
463
+ * const results = await pwnedPasswordRange("5BAA6");
464
+ * const numPwns = results[suffix] || 0;
465
+ * } catch (err) {
466
+ * // ...
467
+ * }
468
+ * @see https://haveibeenpwned.com/api/v3#SearchingPwnedPasswordsByRange
469
+ */
470
+ export declare function pwnedPasswordRange(prefix: string, options?: {
471
+ /**
472
+ * ask the remote API to add padding to the response to obscure the password
473
+ * prefix (default: `false`)
474
+ */
475
+ addPadding?: boolean;
476
+ /**
477
+ * return SHA-1 or NTLM hashes (default: `sha1`)
478
+ */
479
+ mode?: "sha1" | "ntlm";
480
+ /**
481
+ * a custom base URL for the haveibeenpwned.com API endpoints (default:
482
+ * `https://haveibeenpwned.com/api/v3`)
483
+ */
484
+ baseUrl?: string;
485
+ /**
486
+ * a custom string to send as the User-Agent field in the request headers
487
+ * (default: `hibp <version>`)
488
+ */
489
+ userAgent?: string;
490
+ }): Promise<PwnedPasswordSuffixes>;
491
+ export interface SearchResults {
492
+ breaches: Breach[] | null;
493
+ pastes: Paste[] | null;
494
+ }
495
+ /**
496
+ * An object representing search results.
497
+ *
498
+ * @typedef {object} SearchResults
499
+ * @property {(Breach[] | null)} breaches
500
+ * @property {(Paste[] | null)} pastes
501
+ */
502
+ /**
503
+ * Fetches all breaches and all pastes associated with the provided account
504
+ * (email address or username). Note that the remote API does not support
505
+ * querying pastes by username (only email addresses), so in the event the
506
+ * provided account is not a valid email address, only breach data is queried
507
+ * and the "pastes" field of the resulting object will always be null. This is
508
+ * exactly how searching via the current web interface behaves, which this
509
+ * convenience method is designed to mimic.
510
+ *
511
+ * 🔑 `haveibeenpwned.com` requires an API key from
512
+ * https://haveibeenpwned.com/API/Key for the `breachedaccount` and
513
+ * `pasteaccount` endpoints. The `apiKey` option here is not explicitly
514
+ * required, but direct requests made without it will fail (unless you specify a
515
+ * `baseUrl` to a proxy that inserts a valid API key on your behalf).
516
+ *
517
+ * @param {string} account an email address or username
518
+ * @param {object} [options] a configuration object
519
+ * @param {string} [options.apiKey] an API key from
520
+ * https://haveibeenpwned.com/API/Key (default: undefined)
521
+ * @param {string} [options.domain] a domain by which to filter the breach
522
+ * results (default: all domains)
523
+ * @param {boolean} [options.truncate] truncate the breach results to only
524
+ * include the name of each breach (default: true)
525
+ * @param {string} [options.baseUrl] a custom base URL for the
526
+ * haveibeenpwned.com API endpoints (default:
527
+ * `https://haveibeenpwned.com/api/v3`)
528
+ * @param {string} [options.userAgent] a custom string to send as the
529
+ * User-Agent field in the request headers (default: `hibp <version>`)
530
+ * @returns {Promise<SearchResults>} a Promise which resolves to an object
531
+ * containing a "breaches" key (which can be null or an array of breach objects)
532
+ * and a "pastes" key (which can be null or an array of paste objects), or
533
+ * rejects with an Error
534
+ * @example
535
+ * try {
536
+ * const data = await search("foo", { apiKey: "my-api-key" });
537
+ * if (data.breaches || data.pastes) {
538
+ * // ...
539
+ * } else {
540
+ * // ...
541
+ * }
542
+ * } catch (err) {
543
+ * // ...
544
+ * }
545
+ * @example
546
+ * try {
547
+ * const data = await search("nobody@nowhere.com", {
548
+ * baseUrl: "https://my-hibp-proxy:8080",
549
+ * truncate: false,
550
+ * });
551
+ * if (data.breaches || data.pastes) {
552
+ * // ...
553
+ * } else {
554
+ * // ...
555
+ * }
556
+ * } catch (err) {
557
+ * // ...
558
+ * }
559
+ * @see https://haveibeenpwned.com/
560
+ */
561
+ export declare function search(account: string, options?: {
562
+ /**
563
+ * an API key from https://haveibeenpwned.com/API/Key (default: undefined)
564
+ */
565
+ apiKey?: string;
566
+ /**
567
+ * a domain by which to filter the results (default: all domains)
568
+ */
569
+ domain?: string;
570
+ /**
571
+ * truncate the results to only include the name of each breach (default:
572
+ * true)
573
+ */
574
+ truncate?: boolean;
575
+ /**
576
+ * a custom base URL for the haveibeenpwned.com API endpoints (default:
577
+ * `https://haveibeenpwned.com/api/v3`)
578
+ */
579
+ baseUrl?: string;
580
+ /**
581
+ * a custom string to send as the User-Agent field in the request headers
582
+ * (default: `hibp <version>`)
583
+ */
584
+ userAgent?: string;
585
+ }): Promise<SearchResults>;
586
+ /**
587
+ * An object representing the status of your HIBP subscription.
588
+ *
589
+ * @typedef {object} SubscriptionStatus
590
+ * @property {string} SubscriptionName
591
+ * @property {string} Description
592
+ * @property {string} SubscribedUntil
593
+ * @property {number} Rpm
594
+ * @property {number} DomainSearchMaxBreachedAccounts
595
+ */
596
+ /**
597
+ * Fetches the current status of your HIBP subscription (API key).
598
+ *
599
+ * 🔑 `haveibeenpwned.com` requires an API key from
600
+ * https://haveibeenpwned.com/API/Key for the `subscription/status` endpoint.
601
+ * The `apiKey` option here is not explicitly required, but direct requests made
602
+ * without it will fail (unless you specify a `baseUrl` to a proxy that inserts
603
+ * a valid API key on your behalf).
604
+ *
605
+ * @param {object} [options] a configuration object
606
+ * @param {string} [options.apiKey] an API key from
607
+ * https://haveibeenpwned.com/API/Key (default: undefined)
608
+ * @param {string} [options.baseUrl] a custom base URL for the
609
+ * haveibeenpwned.com API endpoints (default:
610
+ * `https://haveibeenpwned.com/api/v3`)
611
+ * @param {string} [options.userAgent] a custom string to send as the User-Agent
612
+ * field in the request headers (default: `hibp <version>`)
613
+ * @returns {Promise<SubscriptionStatus>} a Promise which resolves to a
614
+ * subscription status object, or rejects with an Error
615
+ * @example
616
+ * try {
617
+ * const data = await subscriptionStatus({ apiKey: "my-api-key" });
618
+ * // ...
619
+ * } catch (err) {
620
+ * // ...
621
+ * }
622
+ * @example
623
+ * try {
624
+ * const data = await subscriptionStatus({
625
+ * baseUrl: "https://my-hibp-proxy:8080",
626
+ * });
627
+ * // ...
628
+ * } catch (err) {
629
+ * // ...
630
+ * }
631
+ */
632
+ export declare function subscriptionStatus(options?: {
633
+ /**
634
+ * an API key from https://haveibeenpwned.com/API/Key (default: undefined)
635
+ */
636
+ apiKey?: string;
637
+ /**
638
+ * a custom base URL for the haveibeenpwned.com API endpoints (default:
639
+ * `https://haveibeenpwned.com/api/v3`)
640
+ */
641
+ baseUrl?: string;
642
+ /**
643
+ * a custom string to send as the User-Agent field in the request headers
644
+ * (default: `hibp <version>`)
645
+ */
646
+ userAgent?: string;
647
+ }): Promise<SubscriptionStatus>;
648
+ export interface HIBP {
649
+ breach: typeof breach;
650
+ breachedAccount: typeof breachedAccount;
651
+ breaches: typeof breaches;
652
+ dataClasses: typeof dataClasses;
653
+ pasteAccount: typeof pasteAccount;
654
+ pwnedPassword: typeof pwnedPassword;
655
+ pwnedPasswordRange: typeof pwnedPasswordRange;
656
+ search: typeof search;
657
+ subscriptionStatus: typeof subscriptionStatus;
658
+ RateLimitError: typeof RateLimitError;
659
+ }
660
+
661
+ export as namespace hibp;
662
+
663
+ export {};
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const name = "hibp";
4
- const version = "0.0.0-dev.9896b89a";
4
+ const version = "0.0.0-dev.d74e2ad2";
5
5
  exports.name = name;
6
6
  exports.version = version;
7
- //# sourceMappingURL=package.json.js.map
7
+ //# sourceMappingURL=package.json.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.json.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}