hibp 11.0.0 → 11.1.1
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/CHANGELOG.md +3 -352
- package/README.md +15 -9
- 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/haveibeenpwned/fetchFromApi.js +27 -35
- package/dist/cjs/api/haveibeenpwned/fetchFromApi.js.map +1 -1
- package/dist/cjs/api/haveibeenpwned/index.js +1 -5
- package/dist/cjs/api/haveibeenpwned/index.js.map +1 -1
- package/dist/cjs/api/haveibeenpwned/responses.js +1 -12
- package/dist/cjs/api/haveibeenpwned/responses.js.map +1 -1
- package/dist/cjs/api/pwnedpasswords/fetchFromApi.js +2 -21
- package/dist/cjs/api/pwnedpasswords/fetchFromApi.js.map +1 -1
- package/dist/cjs/api/pwnedpasswords/index.js +0 -5
- package/dist/cjs/api/pwnedpasswords/index.js.map +1 -1
- package/dist/cjs/api/pwnedpasswords/responses.js +0 -6
- package/dist/cjs/api/pwnedpasswords/responses.js.map +1 -1
- package/dist/cjs/breach.js +1 -8
- package/dist/cjs/breach.js.map +1 -1
- package/dist/cjs/breachedAccount.js +1 -11
- package/dist/cjs/breachedAccount.js.map +1 -1
- package/dist/cjs/breaches.js +1 -9
- package/dist/cjs/breaches.js.map +1 -1
- package/dist/cjs/dataClasses.js +1 -7
- package/dist/cjs/dataClasses.js.map +1 -1
- package/dist/cjs/hibp.js +2 -12
- package/dist/cjs/hibp.js.map +1 -1
- package/dist/cjs/package.json.js +1 -4
- package/dist/cjs/package.json.js.map +1 -1
- package/dist/cjs/pasteAccount.js +1 -8
- package/dist/cjs/pasteAccount.js.map +1 -1
- package/dist/cjs/pwnedPassword.js +1 -16
- package/dist/cjs/pwnedPassword.js.map +1 -1
- package/dist/cjs/pwnedPasswordRange.js +5 -10
- package/dist/cjs/pwnedPasswordRange.js.map +1 -1
- package/dist/cjs/search.js +5 -11
- package/dist/cjs/search.js.map +1 -1
- package/dist/esm/api/haveibeenpwned/fetchFromApi.mjs +28 -23
- package/dist/esm/api/haveibeenpwned/fetchFromApi.mjs.map +1 -1
- package/dist/esm/api/haveibeenpwned/index.mjs +1 -1
- package/dist/esm/api/haveibeenpwned/responses.mjs +1 -8
- package/dist/esm/api/haveibeenpwned/responses.mjs.map +1 -1
- package/dist/esm/api/pwnedpasswords/fetchFromApi.mjs +2 -7
- package/dist/esm/api/pwnedpasswords/fetchFromApi.mjs.map +1 -1
- package/dist/esm/api/pwnedpasswords/responses.mjs +0 -2
- package/dist/esm/api/pwnedpasswords/responses.mjs.map +1 -1
- package/dist/esm/breach.mjs +1 -3
- package/dist/esm/breach.mjs.map +1 -1
- package/dist/esm/breachedAccount.mjs +1 -6
- package/dist/esm/breachedAccount.mjs.map +1 -1
- package/dist/esm/breaches.mjs +1 -4
- package/dist/esm/breaches.mjs.map +1 -1
- package/dist/esm/dataClasses.mjs +1 -2
- package/dist/esm/dataClasses.mjs.map +1 -1
- package/dist/esm/hibp.mjs +1 -0
- package/dist/esm/hibp.mjs.map +1 -1
- package/dist/esm/package.json.mjs +4 -0
- package/dist/esm/package.json.mjs.map +1 -0
- package/dist/esm/pasteAccount.mjs +1 -3
- package/dist/esm/pasteAccount.mjs.map +1 -1
- package/dist/esm/pwnedPassword.mjs +1 -2
- package/dist/esm/pwnedPassword.mjs.map +1 -1
- package/dist/esm/pwnedPasswordRange.mjs +5 -5
- package/dist/esm/pwnedPasswordRange.mjs.map +1 -1
- package/dist/esm/search.mjs +5 -5
- package/dist/esm/search.mjs.map +1 -1
- package/dist/hibp.d.ts +25 -1
- package/package.json +63 -75
- package/dist/esm/package.mjs +0 -4
- package/dist/esm/package.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,356 +1,7 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[semantic-release](https://github.com/semantic-release/semantic-release). You
|
|
5
|
-
can see it on the [releases page](../../releases).
|
|
3
|
+
## 11.1.1
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
### Patch Changes
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
<summary>Historical Change Log</summary>
|
|
11
|
-
|
|
12
|
-
#### Version 7.5.1 _(2019-03-05)_
|
|
13
|
-
|
|
14
|
-
- Fixed an issue preventing the use of `hibp` in React Native development mode
|
|
15
|
-
([8e5b4de7][8e5b4de7])
|
|
16
|
-
|
|
17
|
-
#### Version 7.5.0 _(2019-01-27)_
|
|
18
|
-
|
|
19
|
-
- Added a `userAgent` option to all functions to facilitate specifying your own
|
|
20
|
-
`User-Agent` header value for requests made to the haveibeenpwned.com and
|
|
21
|
-
pwnedpasswords.com APIs ([#63][63])
|
|
22
|
-
- Added a `baseUrl` option to all functions to facilitate specifying your own
|
|
23
|
-
URL for requests that would normally be made to
|
|
24
|
-
`https://haveibeenpwned.com/api` and `https://api.pwnedpasswords.com` to
|
|
25
|
-
facilitate proxying the requests through your own server (which may be
|
|
26
|
-
necessary if you wish to use the `breachedAccount` and `search` functions
|
|
27
|
-
after January, 2019 as `haveibeenpwned.com` no longer accepts
|
|
28
|
-
`breachedaccount` endpoint requests originating from a browser)
|
|
29
|
-
|
|
30
|
-
See issue [#60][60] for more details and discussion.
|
|
31
|
-
|
|
32
|
-
#### Version 7.4.0 _(2019-01-19)_
|
|
33
|
-
|
|
34
|
-
- Added an `includeUnverified` option to the `breachedAccount` function to
|
|
35
|
-
include "unverified" breaches in the results ([be01ad12][be01ad12])
|
|
36
|
-
- Generalized the 403 Forbidden response message to simply "access denied" as
|
|
37
|
-
this type of response from `haveibeenpwned.com` is no longer limited to a
|
|
38
|
-
missing `User-Agent` header field ([15e02f97][15e02f97])
|
|
39
|
-
- Added a new error specific to 403 Forbidden responses that includes the Ray ID
|
|
40
|
-
from Cloudflare so users can contact `haveibeenpwned.com` when they are being
|
|
41
|
-
blocked ([cd74e40d][cd74e40d])
|
|
42
|
-
- Removed (and prevented future creation of) empty `remote-api` bundle in the
|
|
43
|
-
ESM build
|
|
44
|
-
- Defined and exported the `hibp` namespace for typing the UMD build
|
|
45
|
-
|
|
46
|
-
#### Version 7.3.0 _(2019-01-05)_
|
|
47
|
-
|
|
48
|
-
- Converted to TypeScript ([#56][56])
|
|
49
|
-
|
|
50
|
-
#### Version 7.2.3 _(2018-12-20)_
|
|
51
|
-
|
|
52
|
-
- Fixed build on Windows ([48d25282][48d25282])
|
|
53
|
-
- Moved CI from Travis to Circle ([#52][52])
|
|
54
|
-
- Moved coverage reports from Coveralls to Codecov ([#53][53])
|
|
55
|
-
|
|
56
|
-
#### Version 7.2.2 _(2018-11-26)_
|
|
57
|
-
|
|
58
|
-
- Updated a **development-only** dependency (`start-server-and-test`) to remove
|
|
59
|
-
a compromised transitive dependency (`flatmap-stream@0.1.1`). See
|
|
60
|
-
[dominictarr/event-stream#116][dominictarr/event-stream#116] for further
|
|
61
|
-
details.
|
|
62
|
-
- Removed redundant pre-publish build step
|
|
63
|
-
|
|
64
|
-
#### Version 7.2.1 _(2018-10-23)_
|
|
65
|
-
|
|
66
|
-
- Fixed the CommonJS build ([3f33becf][3f33becf])
|
|
67
|
-
|
|
68
|
-
#### Version 7.2.0 _(2018-10-16)_
|
|
69
|
-
|
|
70
|
-
- Added an ESM for browsers build ([#49][49])
|
|
71
|
-
|
|
72
|
-
#### Version 7.1.3 _(2018-06-26)_
|
|
73
|
-
|
|
74
|
-
- Fixed custom `User-Agent` request header implementation ([#40][40])
|
|
75
|
-
|
|
76
|
-
#### Version 7.1.2 _(2018-06-26)_
|
|
77
|
-
|
|
78
|
-
- Fixed `Forbidden` errors by adding a custom `User-Agent` request header when
|
|
79
|
-
running outside the browser ([#39][39])
|
|
80
|
-
|
|
81
|
-
#### Version 7.1.1 _(2018-04-04)_
|
|
82
|
-
|
|
83
|
-
- Fixed build scripts to prevent including test-only mocks in published output
|
|
84
|
-
|
|
85
|
-
#### Version 7.1.0 _(2018-04-04)_
|
|
86
|
-
|
|
87
|
-
- Added npm `prepare` script to facilitate installing from hosted git
|
|
88
|
-
- Replaced [js-sha1][js-sha1] with [jsSHA][jssha]
|
|
89
|
-
- Fixed a misleading comment in the `hibp` export documentation
|
|
90
|
-
- Integrated [Renovate][renovate] for automated dependency updates
|
|
91
|
-
- Changed mocking strategy and refactored tests
|
|
92
|
-
|
|
93
|
-
#### Version 7.0.0 _(2018-03-13)_
|
|
94
|
-
|
|
95
|
-
##### Breaking Changes (see [MIGRATION.md](MIGRATION.md) for details):
|
|
96
|
-
|
|
97
|
-
- Modified `pwnedPassword` to use the more secure hash range API
|
|
98
|
-
([@danieladams456][danieladams456] in [#23][23])
|
|
99
|
-
- Modified `pwnedPasswordRange` to resolve with array of objects
|
|
100
|
-
([@danieladams456][danieladams456] in [#24][24])
|
|
101
|
-
|
|
102
|
-
#### Version 6.0.0 _(2018-02-25)_
|
|
103
|
-
|
|
104
|
-
- Restored `puppeteer` to a development dependency
|
|
105
|
-
- Cleaned up some tests
|
|
106
|
-
|
|
107
|
-
##### Breaking Changes (see [MIGRATION.md](MIGRATION.md) for details):
|
|
108
|
-
|
|
109
|
-
- Dropped support for Node < 6
|
|
110
|
-
|
|
111
|
-
#### Version 5.3.0 _(2018-02-24)_
|
|
112
|
-
|
|
113
|
-
- Added `"sideEffects": false` to support Webpack 4 tree-shaking
|
|
114
|
-
- Added support for searching pwned passwords by range (#21)
|
|
115
|
-
- Switched API endpoint for `pwnedPassword` module to new `pwnedpasswords.com`
|
|
116
|
-
domain
|
|
117
|
-
|
|
118
|
-
#### Version 5.2.5 _(2017-12-07)_
|
|
119
|
-
|
|
120
|
-
- Removed `puppeteer` optional dependency as it was causing downstream consumers
|
|
121
|
-
to download Chromium (particularly, when running things with `npx`). The
|
|
122
|
-
`test:umd` script now requires you manually install `puppeteer` before running
|
|
123
|
-
it, which will be done automatically in CI.
|
|
124
|
-
|
|
125
|
-
#### Version 5.2.4 _(2017-12-07)_
|
|
126
|
-
|
|
127
|
-
- Reverted `puppeteer` to `0.12.0` ~~as `0.13.0` was causing downstream
|
|
128
|
-
consumers to download Chromium.~~
|
|
129
|
-
|
|
130
|
-
#### Version 5.2.3 _(2017-12-07)_
|
|
131
|
-
|
|
132
|
-
- Reformated some documentation files
|
|
133
|
-
- Updated dependencies
|
|
134
|
-
|
|
135
|
-
#### Version 5.2.2 _(2017-11-08)_
|
|
136
|
-
|
|
137
|
-
- Internal maintenance
|
|
138
|
-
|
|
139
|
-
#### Version 5.2.1 _(2017-11-07)_
|
|
140
|
-
|
|
141
|
-
- Internal maintenance
|
|
142
|
-
|
|
143
|
-
#### Version 5.2.0 _(2017-08-04)_
|
|
144
|
-
|
|
145
|
-
- Added [`pwnedPassword`][hibp-pwnedpassword] method to check a password to see
|
|
146
|
-
if it has been previously exposed in a data breach (#16)
|
|
147
|
-
|
|
148
|
-
#### Version 5.1.0 _(2017-07-10)_
|
|
149
|
-
|
|
150
|
-
- Replaced webpack with rollup for UMD bundling (#15)
|
|
151
|
-
- Updated dependencies
|
|
152
|
-
|
|
153
|
-
#### Version 5.0.0 _(2017-07-01)_
|
|
154
|
-
|
|
155
|
-
- Targeted browsers in CommonJS/ES Module builds (#11)
|
|
156
|
-
- Updated dependencies
|
|
157
|
-
|
|
158
|
-
##### Breaking Changes (see [MIGRATION.md](MIGRATION.md) for details):
|
|
159
|
-
|
|
160
|
-
- Removed `index.js`, the `source-map-support` entry point (#7)
|
|
161
|
-
- Replaced `browser` field in package.json with `unpkg` (#12)
|
|
162
|
-
- Removed the top-level `default` export (#14)
|
|
163
|
-
|
|
164
|
-
#### Version 4.4.0 _(2017-06-22)_
|
|
165
|
-
|
|
166
|
-
- Separated functions into individual modules (fixed tree-shaking)
|
|
167
|
-
- Provided safer UMD script tag instructions
|
|
168
|
-
- Explicitly targeted browsers in UMD build (resulting in reduced file size)
|
|
169
|
-
- Updated dependencies
|
|
170
|
-
|
|
171
|
-
#### Version 4.3.0 _(2017-06-08)_
|
|
172
|
-
|
|
173
|
-
- Added [`search`][hibp-search] method for querying breaches and pastes
|
|
174
|
-
simultaneously (like the search form on the [website][haveibeenpwned])
|
|
175
|
-
- Set the AMD module name in the UMD build to `hibp` rather than anonymous
|
|
176
|
-
- Updated dependencies
|
|
177
|
-
|
|
178
|
-
#### Version 4.2.1 _(2017-05-27)_
|
|
179
|
-
|
|
180
|
-
- Fixed UMD build that broke in 4.2.0
|
|
181
|
-
|
|
182
|
-
#### Version 4.2.0 _(2017-05-25)_
|
|
183
|
-
|
|
184
|
-
- Fixed return type in `breachedAccount` documentation
|
|
185
|
-
- Added support for tree-shaking bundlers
|
|
186
|
-
- Optimized tests
|
|
187
|
-
- Updated dependencies
|
|
188
|
-
|
|
189
|
-
#### Version 4.1.1 _(2017-01-16)_
|
|
190
|
-
|
|
191
|
-
- Published `example` directory for RunKit support
|
|
192
|
-
- Removed `old` directory from package that slipped in by mistake
|
|
193
|
-
|
|
194
|
-
#### Version 4.1.0 _(2017-01-16)_
|
|
195
|
-
|
|
196
|
-
- Encoded user input used in API query string parameters
|
|
197
|
-
- Added RunKit information for live trial usage
|
|
198
|
-
|
|
199
|
-
#### Version 4.0.1 _(2017-01-04)_
|
|
200
|
-
|
|
201
|
-
- First release of 2017! :tada:
|
|
202
|
-
- Reduced size of UMD build by 75%
|
|
203
|
-
- Updated dependencies
|
|
204
|
-
|
|
205
|
-
#### Version 4.0.0 _(2016-12-10)_
|
|
206
|
-
|
|
207
|
-
- Tweaked toolchain configs
|
|
208
|
-
- Restructured test data
|
|
209
|
-
- Updated dependencies
|
|
210
|
-
|
|
211
|
-
##### Breaking Changes (see [MIGRATION.md](MIGRATION.md) for details):
|
|
212
|
-
|
|
213
|
-
- Dropped support for Node < 4
|
|
214
|
-
|
|
215
|
-
#### Version 3.0.0 _(2016-10-23)_
|
|
216
|
-
|
|
217
|
-
- Added `yarn.lock` for experimental [yarn][yarn] support
|
|
218
|
-
- Removed expect.js dependency from the test environment
|
|
219
|
-
- Expanded usage documentation
|
|
220
|
-
- Updated dependencies
|
|
221
|
-
|
|
222
|
-
##### Breaking Changes (see [MIGRATION.md](MIGRATION.md) for details):
|
|
223
|
-
|
|
224
|
-
- The browser (UMD) version has moved from the `lib` directory to the `dist`
|
|
225
|
-
directory.
|
|
226
|
-
|
|
227
|
-
#### Version 2.2.0 _(2016-10-03)_
|
|
228
|
-
|
|
229
|
-
- Added fallback for unexpected HTTP responses (thanks @jellekralt)
|
|
230
|
-
- Added handling for new HTTP 429 (Too Many Requests) rate-limiting responses
|
|
231
|
-
- Improved tests
|
|
232
|
-
- Switched code style from SemiStandard to Airbnb
|
|
233
|
-
- Updated dependencies
|
|
234
|
-
|
|
235
|
-
#### Version 2.1.0 _(2016-09-04)_
|
|
236
|
-
|
|
237
|
-
- Replaced **npmcdn.com** with **unpkg.com** in the documentation as the service
|
|
238
|
-
is being renamed
|
|
239
|
-
- Inherited support for `http_proxy` and `https_proxy` environment variables
|
|
240
|
-
from Axios 0.14.0
|
|
241
|
-
- Simplified build scripts
|
|
242
|
-
- Refactored test environment
|
|
243
|
-
- Updated dependencies
|
|
244
|
-
|
|
245
|
-
#### Version 2.0.0 _(2016-08-07)_
|
|
246
|
-
|
|
247
|
-
##### New:
|
|
248
|
-
|
|
249
|
-
- Added browser support
|
|
250
|
-
|
|
251
|
-
##### Breaking Changes (see [MIGRATION.md](MIGRATION.md) for details):
|
|
252
|
-
|
|
253
|
-
- Changed API methods to resolve to null instead of undefined when no data was
|
|
254
|
-
found
|
|
255
|
-
- Changed API methods to take a configuration object rather than optional,
|
|
256
|
-
positional parameters
|
|
257
|
-
|
|
258
|
-
#### Version 1.0.8 _(2016-08-06)_
|
|
259
|
-
|
|
260
|
-
- Updated description and example usage
|
|
261
|
-
- Switched test coverage from istanbul to nyc
|
|
262
|
-
- Improved cross-platform compatibility for development
|
|
263
|
-
- Updated dependencies
|
|
264
|
-
|
|
265
|
-
#### Version 1.0.7 _(2016-07-21)_
|
|
266
|
-
|
|
267
|
-
- Minor performance increase
|
|
268
|
-
- Fixed API documentation for 'breaches' query
|
|
269
|
-
- Updated dependencies
|
|
270
|
-
|
|
271
|
-
#### Version 1.0.6 _(2016-06-28)_
|
|
272
|
-
|
|
273
|
-
- Increased visibility in npm search
|
|
274
|
-
- Minor improvements to development environment
|
|
275
|
-
|
|
276
|
-
#### Version 1.0.5 _(2016-04-22)_
|
|
277
|
-
|
|
278
|
-
- Removed temporary 'breach' hack as the API endpoint has been fixed
|
|
279
|
-
- Updated dependencies
|
|
280
|
-
|
|
281
|
-
#### Version 1.0.4 _(2016-04-12)_
|
|
282
|
-
|
|
283
|
-
- Changed temporary 'breach' hack to match author's intentions
|
|
284
|
-
|
|
285
|
-
_The API author (Troy Hunt) indicated there is no hard format restrictions on
|
|
286
|
-
a breach name, so the concept of an invalid breach name is not in play here.
|
|
287
|
-
The API will respond with HTTP status 404 (not found) once the fix has been
|
|
288
|
-
applied. This change mimics that behavior as opposed to responding with HTTP
|
|
289
|
-
status 400 (bad request), which was my initial interpretation._
|
|
290
|
-
|
|
291
|
-
#### Version 1.0.3 _(2016-04-10)_
|
|
292
|
-
|
|
293
|
-
- Updated documentation
|
|
294
|
-
|
|
295
|
-
#### Version 1.0.2 _(2016-04-10)_
|
|
296
|
-
|
|
297
|
-
- Shield clients from broken '[breach][singlebreach]' endpoint when querying for
|
|
298
|
-
an invalid breach name
|
|
299
|
-
|
|
300
|
-
_Currently, the endpoint responds with HTTP status 200 and "page not found"
|
|
301
|
-
HTML in the body if an invalid breach name is queried (e.g. 'adobe.com',
|
|
302
|
-
instead of the proper breach name, 'adobe'). Based on the response codes
|
|
303
|
-
described in the API documentation, I believe it should respond with HTTP
|
|
304
|
-
status 400 (bad request). Prior to this patch, it lead to a confusing one-off
|
|
305
|
-
scenario for clients consuming this module. This change should provide a
|
|
306
|
-
consistent experience by intercepting this specific case and throwing a "bad
|
|
307
|
-
request" error instead of a `SyntaxError` from trying to parse HTML. I brought
|
|
308
|
-
this API behavioral discrepancy to the API author's attention and he agreed it
|
|
309
|
-
was broken and noted that a fix is incoming._
|
|
310
|
-
|
|
311
|
-
- Updated tests
|
|
312
|
-
|
|
313
|
-
#### Version 1.0.1 _(2016-04-08)_
|
|
314
|
-
|
|
315
|
-
- Removed `preferGlobal` option from package.json
|
|
316
|
-
|
|
317
|
-
#### Version 1.0.0 _(2016-04-08)_
|
|
318
|
-
|
|
319
|
-
- Initial release
|
|
320
|
-
|
|
321
|
-
</details>
|
|
322
|
-
|
|
323
|
-
[hibp-pwnedpassword]: API.md#module_pwnedPassword
|
|
324
|
-
[hibp-search]: API.md#module_search
|
|
325
|
-
[haveibeenpwned]: https://haveibeenpwned.com
|
|
326
|
-
[singlebreach]: https://haveibeenpwned.com/API/v2#SingleBreach
|
|
327
|
-
[yarn]: https://yarnpkg.com
|
|
328
|
-
[danieladams456]: https://github.com/danieladams456
|
|
329
|
-
[23]: https://github.com/wKovacs64/hibp/pull/23
|
|
330
|
-
[24]: https://github.com/wKovacs64/hibp/pull/24
|
|
331
|
-
[renovate]: https://renovateapp.com/
|
|
332
|
-
[js-sha1]: https://github.com/emn178/js-sha1
|
|
333
|
-
[jssha]: https://github.com/Caligatio/jsSHA
|
|
334
|
-
[39]: https://github.com/wKovacs64/hibp/pull/39
|
|
335
|
-
[40]: https://github.com/wKovacs64/hibp/pull/40
|
|
336
|
-
[49]: https://github.com/wKovacs64/hibp/pull/49
|
|
337
|
-
[3f33becf]:
|
|
338
|
-
https://github.com/wKovacs64/hibp/commit/3f33becfa23b80abc45fbeaad6c8c9f85113d126
|
|
339
|
-
[dominictarr/event-stream#116]:
|
|
340
|
-
https://github.com/dominictarr/event-stream/issues/116
|
|
341
|
-
[48d25282]:
|
|
342
|
-
https://github.com/wKovacs64/hibp/commit/48d25282407d2b1d3cdfac51f311d018a6a16d25
|
|
343
|
-
[52]: https://github.com/wKovacs64/hibp/pull/52
|
|
344
|
-
[53]: https://github.com/wKovacs64/hibp/pull/53
|
|
345
|
-
[56]: https://github.com/wKovacs64/hibp/pull/56
|
|
346
|
-
[be01ad12]:
|
|
347
|
-
https://github.com/wKovacs64/hibp/commit/be01ad1253b7ceb3c7f844049451a4e8e9e3a858
|
|
348
|
-
[15e02f97]:
|
|
349
|
-
https://github.com/wKovacs64/hibp/commit/15e02f970286a410a275fe3457f559050632e5bd
|
|
350
|
-
[cd74e40d]:
|
|
351
|
-
https://github.com/wKovacs64/hibp/commit/cd74e40de95143252ab99f5c070a84e54b1365a6
|
|
352
|
-
[60]: https://github.com/wKovacs64/hibp/issues/60
|
|
353
|
-
[63]: https://github.com/wKovacs64/hibp/pull/63
|
|
354
|
-
[64]: https://github.com/wKovacs64/hibp/pull/64
|
|
355
|
-
[8e5b4de7]:
|
|
356
|
-
https://github.com/wKovacs64/hibp/commit/8e5b4de79d25d834e14b8917101b4e0209d52f14
|
|
7
|
+
- [#365](https://github.com/wKovacs64/hibp/pull/365) [`ec26254`](https://github.com/wKovacs64/hibp/commit/ec2625486c8500484befa4d4d203bb820a338967) Thanks [@wKovacs64](https://github.com/wKovacs64)! - Add `types` to the `exports` map in `package.json` to fix ESM consumers.
|
package/README.md
CHANGED
|
@@ -15,7 +15,6 @@ pwned?][haveibeenpwned] service._
|
|
|
15
15
|
|
|
16
16
|
[![npm Version][npm-image]][npm-url] [![Build Status][ci-image]][ci-url]
|
|
17
17
|
[![Code Coverage][coverage-image]][coverage-url]
|
|
18
|
-
[![semantic-release][semantic-release-image]][semantic-release-url]
|
|
19
18
|
[](#contributors-)
|
|
20
19
|
|
|
21
20
|
## Installation
|
|
@@ -106,6 +105,15 @@ search('someAccountOrEmail', { apiKey: 'my-api-key' })
|
|
|
106
105
|
});
|
|
107
106
|
```
|
|
108
107
|
|
|
108
|
+
#### Rate Limiting
|
|
109
|
+
|
|
110
|
+
The haveibeenpwned.com API [rate limits][haveibeenpwned-rate-limiting] requests
|
|
111
|
+
to prevent abuse. In the event you get rate limited, the module will throw a
|
|
112
|
+
custom `RateLimitError` which will include a `retryAfterSeconds` property so you
|
|
113
|
+
know when you can try the call again (as a `number`, unless the remote API did
|
|
114
|
+
not provide one, in which case it will be `undefined` - but that _should_ never
|
|
115
|
+
happen).
|
|
116
|
+
|
|
109
117
|
#### Using in the browser
|
|
110
118
|
|
|
111
119
|
**Prerequisite:** This module requires a Promise implementation to exist in the
|
|
@@ -190,18 +198,16 @@ This module is distributed under the [MIT License][license].
|
|
|
190
198
|
[npm-image]: https://img.shields.io/npm/v/hibp.svg?style=flat-square
|
|
191
199
|
[npm-url]: https://www.npmjs.com/package/hibp
|
|
192
200
|
[ci-image]:
|
|
193
|
-
https://img.shields.io/
|
|
194
|
-
[ci-url]: https://
|
|
201
|
+
https://img.shields.io/github/actions/workflow/status/wKovacs64/hibp/ci.yml?logo=github&style=flat-square
|
|
202
|
+
[ci-url]: https://github.com/wKovacs64/hibp/actions?query=workflow%3Aci
|
|
195
203
|
[coverage-image]:
|
|
196
|
-
https://img.shields.io/codecov/c/github/wKovacs64/hibp/
|
|
197
|
-
[coverage-url]: https://codecov.io/gh/wKovacs64/hibp/branch/
|
|
198
|
-
[semantic-release-image]:
|
|
199
|
-
https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square
|
|
200
|
-
[semantic-release-url]: https://github.com/semantic-release/semantic-release
|
|
204
|
+
https://img.shields.io/codecov/c/github/wKovacs64/hibp/main.svg?style=flat-square
|
|
205
|
+
[coverage-url]: https://codecov.io/gh/wKovacs64/hibp/branch/main
|
|
201
206
|
[deno]: https://deno.land/
|
|
202
207
|
[skypack]: https://www.skypack.dev/
|
|
203
208
|
[troy]: https://www.troyhunt.com
|
|
204
209
|
[haveibeenpwned]: https://haveibeenpwned.com
|
|
210
|
+
[haveibeenpwned-rate-limiting]: https://haveibeenpwned.com/API/v3#RateLimiting
|
|
205
211
|
[search-by-range]:
|
|
206
212
|
https://haveibeenpwned.com/API/v2#SearchingPwnedPasswordsByRange
|
|
207
213
|
[api-key-blog-post]:
|
|
@@ -217,7 +223,7 @@ This module is distributed under the [MIT License][license].
|
|
|
217
223
|
[pwned]: https://github.com/wKovacs64/pwned
|
|
218
224
|
[pulls]: https://github.com/wKovacs64/hibp/pulls
|
|
219
225
|
[pwl]: https://pwl.netlify.com/
|
|
220
|
-
[license]: https://github.com/wKovacs64/hibp/tree/
|
|
226
|
+
[license]: https://github.com/wKovacs64/hibp/tree/main/LICENSE.txt
|
|
221
227
|
|
|
222
228
|
## Contributors ✨
|
|
223
229
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function t(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})})),e}var e=t(Object.freeze({__proto__:null,default:function(t,e){return e=e||{},new Promise((function(n,r){var s=new XMLHttpRequest,o=[],i=[],u={},h=function(){return{ok:2==(s.status/100|0),statusText:s.statusText,status:s.status,url:s.responseURL,text:function(){return Promise.resolve(s.responseText)},json:function(){return Promise.resolve(s.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([s.response]))},clone:h,headers:{keys:function(){return o},entries:function(){return i},get:function(t){return u[t.toLowerCase()]},has:function(t){return t.toLowerCase()in u}}}};for(var a in s.open(e.method||"get",t,!0),s.onload=function(){s.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(t,e,n){o.push(e=e.toLowerCase()),i.push([e,n]),u[e]=u[e]?u[e]+","+n:n})),n(h())},s.onerror=r,s.withCredentials="include"==e.credentials,e.headers)s.setRequestHeader(a,e.headers[a]);s.send(e.body||null)}))}})),n=self.fetch||(self.fetch=e.default||e);new Map;const r=400,s="Bad request — the account does not comply with an acceptable format.",o=401,i=403,u="Forbidden - access denied.",h=404,a=429;function c(t,{apiKey:e,baseUrl:c="https://haveibeenpwned.com/api/v3",userAgent:f}={}){const l={};e&&(l["HIBP-API-Key"]=e),f&&(l["User-Agent"]=f),f||"undefined"!=typeof navigator||(l["User-Agent"]="hibp 11.0.0");const p={headers:l},d=`${c.replace(/\/$/g,"")}${t}`;return n(d,p).then(t=>{if(t.ok)return t.json();switch(t.status){case r:throw Error(s);case o:return t.json().then(t=>{throw Error(t.message)});case i:{const e=t.headers.get("cf-ray");if(e)throw Error(function(t){return`Request blocked, contact haveibeenpwned.com if this continues (Ray ID: ${t})`}(e));throw Error(u)}case h:return null;case a:return t.json().then(t=>{throw Error(t.message)});default:throw Error(t.statusText)}})}function f(t,e={}){return c("/breach/"+encodeURIComponent(t),e)}function l(t,e={includeUnverified:!0,truncate:!0}){const n=`/breachedaccount/${encodeURIComponent(t)}?`,r=[];return e.domain&&r.push("domain="+encodeURIComponent(e.domain)),!1===e.includeUnverified&&r.push("includeUnverified=false"),!1===e.truncate&&r.push("truncateResponse=false"),c(`${n}${r.join("&")}`,{apiKey:e.apiKey,baseUrl:e.baseUrl,userAgent:e.userAgent})}function p(t={}){const e=[];return t.domain&&e.push("domain="+encodeURIComponent(t.domain)),c("/breaches?"+e.join("&"),{baseUrl:t.baseUrl,userAgent:t.userAgent})}function d(t={}){return c("/dataclasses",t)}function g(t,e={}){return c("/pasteaccount/"+encodeURIComponent(t),{apiKey:e.apiKey,baseUrl:e.baseUrl,userAgent:e.userAgent})}const A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function U(t,e,n,r){let s,o,i;const u=e||[0],h=(n=n||0)>>>3,a=-1===r?3:0;for(s=0;t.length>s;s+=1)i=s+h,o=i>>>2,o>=u.length&&u.push(0),u[o]|=t[s]<<8*(a+r*(i%4));return{value:u,binLen:8*t.length+n}}function m(t,e,n){switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":return function(t,e,r){return function(t,e,n,r){let s,o,i,u;if(0!=t.length%2)throw Error("String of HEX type must be in byte increments");const h=e||[0],a=(n=n||0)>>>3,c=-1===r?3:0;for(s=0;t.length>s;s+=2){if(o=parseInt(t.substr(s,2),16),isNaN(o))throw Error("String of HEX type contains invalid characters");for(u=(s>>>1)+a,i=u>>>2;i>=h.length;)h.push(0);h[i]|=o<<8*(c+r*(u%4))}return{value:h,binLen:4*t.length+n}}(t,e,r,n)};case"TEXT":return function(t,r,s){return function(t,e,n,r,s){let o,i,u,h,a,c,f,l,p=0;const d=n||[0],g=(r=r||0)>>>3;if("UTF8"===e)for(f=-1===s?3:0,u=0;t.length>u;u+=1)for(o=t.charCodeAt(u),i=[],128>o?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||o>=57344?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(u+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(u)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),h=0;i.length>h;h+=1){for(c=p+g,a=c>>>2;a>=d.length;)d.push(0);d[a]|=i[h]<<8*(f+s*(c%4)),p+=1}else for(f=-1===s?2:0,l="UTF16LE"===e&&1!==s||"UTF16LE"!==e&&1===s,u=0;t.length>u;u+=1){for(o=t.charCodeAt(u),!0===l&&(h=255&o,o=h<<8|o>>>8),c=p+g,a=c>>>2;a>=d.length;)d.push(0);d[a]|=o<<8*(f+s*(c%4)),p+=2}return{value:d,binLen:8*p+r}}(t,e,r,s,n)};case"B64":return function(t,e,r){return function(t,e,n,r){let s,o,i,u,h,a,c,f=0;const l=e||[0],p=(n=n||0)>>>3,d=-1===r?3:0,g=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==g&&t.length>g)throw Error("Invalid '=' found in base-64 string");for(o=0;t.length>o;o+=4){for(h=t.substr(o,4),u=0,i=0;h.length>i;i+=1)s=A.indexOf(h.charAt(i)),u|=s<<18-6*i;for(i=0;h.length-1>i;i+=1){for(c=f+p,a=c>>>2;a>=l.length;)l.push(0);l[a]|=(u>>>16-8*i&255)<<8*(d+r*(c%4)),f+=1}}return{value:l,binLen:8*f+n}}(t,e,r,n)};case"BYTES":return function(t,e,r){return function(t,e,n,r){let s,o,i,u;const h=e||[0],a=(n=n||0)>>>3,c=-1===r?3:0;for(o=0;t.length>o;o+=1)s=t.charCodeAt(o),u=o+a,i=u>>>2,i>=h.length&&h.push(0),h[i]|=s<<8*(c+r*(u%4));return{value:h,binLen:8*t.length+n}}(t,e,r,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}return function(t,e,r){return function(t,e,n,r){return U(new Uint8Array(t),e,n,r)}(t,e,r,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw Error("UINT8ARRAY not supported by this environment")}return function(t,e,r){return U(t,e,r,n)};default:throw Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function b(t,e,n,r){switch(t){case"HEX":return function(t){return function(t,e,n,r){let s,o,i="";const u=e/8,h=-1===n?3:0;for(s=0;u>s;s+=1)o=t[s>>>2]>>>8*(h+n*(s%4)),i+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?i.toUpperCase():i}(t,e,n,r)};case"B64":return function(t){return function(t,e,n,r){let s,o,i,u,h,a="";const c=e/8,f=-1===n?3:0;for(s=0;c>s;s+=3)for(u=c>s+1?t[s+1>>>2]:0,h=c>s+2?t[s+2>>>2]:0,i=(t[s>>>2]>>>8*(f+n*(s%4))&255)<<16|(u>>>8*(f+n*((s+1)%4))&255)<<8|h>>>8*(f+n*((s+2)%4))&255,o=0;4>o;o+=1)a+=8*s+6*o>e?r.b64Pad:A.charAt(i>>>6*(3-o)&63);return a}(t,e,n,r)};case"BYTES":return function(t){return function(t,e,n){let r,s,o="";const i=e/8,u=-1===n?3:0;for(r=0;i>r;r+=1)s=t[r>>>2]>>>8*(u+n*(r%4))&255,o+=String.fromCharCode(s);return o}(t,e,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}return function(t){return function(t,e,n){let r;const s=e/8,o=new ArrayBuffer(s),i=new Uint8Array(o),u=-1===n?3:0;for(r=0;s>r;r+=1)i[r]=t[r>>>2]>>>8*(u+n*(r%4))&255;return o}(t,e,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw Error("UINT8ARRAY not supported by this environment")}return function(t){return function(t,e,n){let r;const s=e/8,o=-1===n?3:0,i=new Uint8Array(s);for(r=0;s>r;r+=1)i[r]=t[r>>>2]>>>8*(o+n*(r%4))&255;return i}(t,e,n)};default:throw Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function w(t){const e={outputUpper:!1,b64Pad:"=",outputLen:-1},n=t||{},r="Output length must be a multiple of 8";if(e.outputUpper=n.outputUpper||!1,n.b64Pad&&(e.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw Error(r);e.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw Error(r);e.outputLen=n.shakeLen}if("boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function E(t,e){return t<<e|t>>>32-e}function R(t,e,n){return t^e^n}function v(t,e,n){return t&e^t&n^e&n}function y(t,e){const n=(65535&t)+(65535&e);return(65535&(t>>>16)+(e>>>16)+(n>>>16))<<16|65535&n}function T(t,e,n,r,s){const o=(65535&t)+(65535&e)+(65535&n)+(65535&r)+(65535&s);return(65535&(t>>>16)+(e>>>16)+(n>>>16)+(r>>>16)+(s>>>16)+(o>>>16))<<16|65535&o}function C(t){return[1732584193,4023233417,2562383102,271733878,3285377520]}function F(t,e){let n,r,s,o,i,u,h;const a=[];for(n=e[0],r=e[1],s=e[2],o=e[3],i=e[4],h=0;80>h;h+=1)a[h]=16>h?t[h]:E(a[h-3]^a[h-8]^a[h-14]^a[h-16],1),u=20>h?T(E(n,5),(c=r)&s^~c&o,i,1518500249,a[h]):40>h?T(E(n,5),R(r,s,o),i,1859775393,a[h]):60>h?T(E(n,5),v(r,s,o),i,2400959708,a[h]):T(E(n,5),R(r,s,o),i,3395469782,a[h]),i=o,o=s,s=E(r,30),r=n,n=u;var c;return e[0]=y(n,e[0]),e[1]=y(r,e[1]),e[2]=y(s,e[2]),e[3]=y(o,e[3]),e[4]=y(i,e[4]),e}function L(t,e,n,r){let s;const o=15+(e+65>>>9<<4),i=e+n;for(;o>=t.length;)t.push(0);for(t[e>>>5]|=128<<24-e%32,t[o]=4294967295&i,t[o-1]=i/4294967296|0,s=0;t.length>s;s+=16)r=F(t.slice(s,s+16),r);return r}class H extends class{constructor(t,e,n){const r=n||{};if(this.t=e,this.i=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw Error("numRounds must a integer >= 1");this.s=t,this.o=[],this.h=0,this.u=!1,this.l=0,this.A=!1,this.p=[],this.R=[]}update(t){let e,n=0;const r=this.U>>>5,s=this.T(t,this.o,this.h),o=s.binLen,i=s.value,u=o>>>5;for(e=0;u>e;e+=r)o>=n+this.U&&(this.F=this.m(i.slice(e,e+r),this.F),n+=this.U);this.l+=n,this.o=i.slice(n>>>5),this.h=o%this.U,this.u=!0}getHash(t,e){let n,r,s=this.g;const o=w(e);if(this.B){if(-1===o.outputLen)throw Error("Output length must be specified in options");s=o.outputLen}const i=b(t,s,this.v,o);if(this.A&&this.Y)return i(this.Y(o));for(r=this.H(this.o.slice(),this.h,this.l,this.C(this.F),s),n=1;this.numRounds>n;n+=1)this.B&&s%32!=0&&(r[r.length-1]&=16777215>>>24-s%32),r=this.H(r,s,0,this.I(this.s),s);return i(r)}setHMACKey(t,e,n){if(!this.L)throw Error("Variant does not support HMAC");if(this.u)throw Error("Cannot set MAC key after calling update");const r=m(e,(n||{}).encoding||"UTF8",this.v);this.M(r(t))}M(t){const e=this.U>>>3,n=e/4-1;let r;if(1!==this.numRounds)throw Error("Cannot set numRounds with MAC");if(this.A)throw Error("MAC key already set");for(t.binLen/8>e&&(t.value=this.H(t.value,t.binLen,0,this.I(this.s),this.g));n>=t.value.length;)t.value.push(0);for(r=0;n>=r;r+=1)this.p[r]=909522486^t.value[r],this.R[r]=1549556828^t.value[r];this.F=this.m(this.p,this.F),this.l=this.U,this.A=!0}getHMAC(t,e){const n=w(e);return b(t,this.g,this.v,n)(this.N())}N(){let t;if(!this.A)throw Error("Cannot call getHMAC without first setting MAC key");const e=this.H(this.o.slice(),this.h,this.l,this.C(this.F),this.g);return t=this.m(this.R,this.I(this.s)),t=this.H(e,this.g,this.U,t,this.g),t}}{constructor(t,e,n){if("SHA-1"!==t)throw Error("Chosen SHA variant is not supported");super(t,e,n);const r=n||{};this.L=!0,this.Y=this.N,this.v=-1,this.T=m(this.t,this.i,this.v),this.m=F,this.C=function(t){return t.slice()},this.I=C,this.H=L,this.F=[1732584193,4023233417,2562383102,271733878,3285377520],this.U=512,this.g=160,this.B=!1,r.hmacKey&&this.M(function(t,e,n,r){const s="hmacKey must include a value and format";if(!e)throw Error(s);if(void 0===e.value||!e.format)throw Error(s);return m(e.format,e.encoding||"UTF8",n)(e.value)}(0,r.hmacKey,this.v))}}const I=400;function B(t,e={}){return function(t,{baseUrl:e="https://api.pwnedpasswords.com",userAgent:r}={}){const s=Object.assign({},r?{headers:{"User-Agent":r}}:{}),o=`${e.replace(/\/$/g,"")}${t}`;return n(o,s).then(t=>{if(t.ok)return t.text();if(t.status===I)return t.text().then(t=>{throw Error(t)});throw Error(t.statusText)})}("/range/"+encodeURIComponent(t),e).then(t=>t.split("\n")).then(t=>t.reduce((t,e)=>{const[n,r]=e.split(":");return t[n]=parseInt(r,10),t},{}))}function Y(t,e={}){const n=new H("SHA-1","TEXT");n.update(t);const r=n.getHash("HEX",{outputUpper:!0}),s=r.slice(0,5),o=r.slice(5);return B(s,e).then(t=>t[o]||0)}function P(t,e={truncate:!0}){const{apiKey:n,baseUrl:r,userAgent:s}=e;return Promise.all([l(t,e),/^.+@.+$/.test(t)?g(t,{apiKey:n,baseUrl:r,userAgent:s}):null]).then(t=>({breaches:t[0],pastes:t[1]}))}export{f as breach,l as breachedAccount,p as breaches,d as dataClasses,g as pasteAccount,Y as pwnedPassword,B as pwnedPasswordRange,P as search};
|
|
1
|
+
function t(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var n=function t(){if(this instanceof t){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(e,n);return new r}return e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})})),n}var e=Object.freeze({__proto__:null,default:function(t,e){return e=e||{},new Promise((function(n,r){var s=new XMLHttpRequest,o=[],i=[],u={},h=function(){return{ok:2==(s.status/100|0),statusText:s.statusText,status:s.status,url:s.responseURL,text:function(){return Promise.resolve(s.responseText)},json:function(){return Promise.resolve(s.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([s.response]))},clone:h,headers:{keys:function(){return o},entries:function(){return i},get:function(t){return u[t.toLowerCase()]},has:function(t){return t.toLowerCase()in u}}}};for(var a in s.open(e.method||"get",t,!0),s.onload=function(){s.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(t,e,n){o.push(e=e.toLowerCase()),i.push([e,n]),u[e]=u[e]?u[e]+","+n:n})),n(h())},s.onerror=r,s.withCredentials="include"==e.credentials,e.headers)s.setRequestHeader(a,e.headers[a]);s.send(e.body||null)}))}}),n=t(e),r=self.fetch||(self.fetch=n.default||n);new Map;const s=400,o="Bad request — the account does not comply with an acceptable format.",i=401,u=403,h="Forbidden - access denied.",a=404,c=(new Map([["retry-after","2"]]),429);class f extends Error{retryAfterSeconds;constructor(t,e,n){super(e,n),this.name=this.constructor.name,this.retryAfterSeconds="string"==typeof t?Number.parseInt(t,10):void 0}}function l(t,{apiKey:e,baseUrl:n="https://haveibeenpwned.com/api/v3",userAgent:l}={}){const p={};e&&(p["HIBP-API-Key"]=e),l&&(p["User-Agent"]=l),l||"undefined"!=typeof navigator||(p["User-Agent"]="hibp 11.1.1");const d={headers:p},g=`${n.replace(/\/$/g,"")}${t}`;return r(g,d).then((t=>{if(t.ok)return t.json();switch(t.status){case s:throw Error(o);case i:return t.json().then((t=>{throw Error(t.message)}));case u:{const e=t.headers.get("cf-ray");if(e)throw Error(function(t){return`Request blocked, contact haveibeenpwned.com if this continues (Ray ID: ${t})`}(e));throw Error(h)}case a:return null;case c:return t.json().then((e=>{const n=t.headers.get("retry-after");throw new f(n,e.message)}));default:throw Error(t.statusText)}}))}function p(t,e={}){return l("/breach/"+encodeURIComponent(t),e)}function d(t,e={includeUnverified:!0,truncate:!0}){const n=`/breachedaccount/${encodeURIComponent(t)}?`,r=[];return e.domain&&r.push("domain="+encodeURIComponent(e.domain)),!1===e.includeUnverified&&r.push("includeUnverified=false"),!1===e.truncate&&r.push("truncateResponse=false"),l(`${n}${r.join("&")}`,{apiKey:e.apiKey,baseUrl:e.baseUrl,userAgent:e.userAgent})}function g(t={}){const e=[];return t.domain&&e.push("domain="+encodeURIComponent(t.domain)),l("/breaches?"+e.join("&"),{baseUrl:t.baseUrl,userAgent:t.userAgent})}function A(t={}){return l("/dataclasses",t)}function m(t,e={}){return l("/pasteaccount/"+encodeURIComponent(t),{apiKey:e.apiKey,baseUrl:e.baseUrl,userAgent:e.userAgent})}const b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function w(t,e,n,r){let s,o,i;const u=e||[0],h=(n=n||0)>>>3,a=-1===r?3:0;for(s=0;t.length>s;s+=1)i=s+h,o=i>>>2,o>=u.length&&u.push(0),u[o]|=t[s]<<8*(a+r*(i%4));return{value:u,binLen:8*t.length+n}}function U(t,e,n){switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":return function(t,e,r){return function(t,e,n,r){let s,o,i,u;if(0!=t.length%2)throw Error("String of HEX type must be in byte increments");const h=e||[0],a=(n=n||0)>>>3,c=-1===r?3:0;for(s=0;t.length>s;s+=2){if(o=parseInt(t.substr(s,2),16),isNaN(o))throw Error("String of HEX type contains invalid characters");for(u=(s>>>1)+a,i=u>>>2;i>=h.length;)h.push(0);h[i]|=o<<8*(c+r*(u%4))}return{value:h,binLen:4*t.length+n}}(t,e,r,n)};case"TEXT":return function(t,r,s){return function(t,e,n,r,s){let o,i,u,h,a,c,f,l,p=0;const d=n||[0],g=(r=r||0)>>>3;if("UTF8"===e)for(f=-1===s?3:0,u=0;t.length>u;u+=1)for(o=t.charCodeAt(u),i=[],128>o?i.push(o):2048>o?(i.push(192|o>>>6),i.push(128|63&o)):55296>o||o>=57344?i.push(224|o>>>12,128|o>>>6&63,128|63&o):(u+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(u)),i.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),h=0;i.length>h;h+=1){for(c=p+g,a=c>>>2;a>=d.length;)d.push(0);d[a]|=i[h]<<8*(f+s*(c%4)),p+=1}else for(f=-1===s?2:0,l="UTF16LE"===e&&1!==s||"UTF16LE"!==e&&1===s,u=0;t.length>u;u+=1){for(o=t.charCodeAt(u),!0===l&&(h=255&o,o=h<<8|o>>>8),c=p+g,a=c>>>2;a>=d.length;)d.push(0);d[a]|=o<<8*(f+s*(c%4)),p+=2}return{value:d,binLen:8*p+r}}(t,e,r,s,n)};case"B64":return function(t,e,r){return function(t,e,n,r){let s,o,i,u,h,a,c,f=0;const l=e||[0],p=(n=n||0)>>>3,d=-1===r?3:0,g=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==g&&t.length>g)throw Error("Invalid '=' found in base-64 string");for(o=0;t.length>o;o+=4){for(h=t.substr(o,4),u=0,i=0;h.length>i;i+=1)s=b.indexOf(h.charAt(i)),u|=s<<18-6*i;for(i=0;h.length-1>i;i+=1){for(c=f+p,a=c>>>2;a>=l.length;)l.push(0);l[a]|=(u>>>16-8*i&255)<<8*(d+r*(c%4)),f+=1}}return{value:l,binLen:8*f+n}}(t,e,r,n)};case"BYTES":return function(t,e,r){return function(t,e,n,r){let s,o,i,u;const h=e||[0],a=(n=n||0)>>>3,c=-1===r?3:0;for(o=0;t.length>o;o+=1)s=t.charCodeAt(o),u=o+a,i=u>>>2,i>=h.length&&h.push(0),h[i]|=s<<8*(c+r*(u%4));return{value:h,binLen:8*t.length+n}}(t,e,r,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}return function(t,e,r){return function(t,e,n,r){return w(new Uint8Array(t),e,n,r)}(t,e,r,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw Error("UINT8ARRAY not supported by this environment")}return function(t,e,r){return w(t,e,r,n)};default:throw Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function E(t,e,n,r){switch(t){case"HEX":return function(t){return function(t,e,n,r){const s="0123456789abcdef";let o,i,u="";const h=e/8,a=-1===n?3:0;for(o=0;h>o;o+=1)i=t[o>>>2]>>>8*(a+n*(o%4)),u+=s.charAt(i>>>4&15)+s.charAt(15&i);return r.outputUpper?u.toUpperCase():u}(t,e,n,r)};case"B64":return function(t){return function(t,e,n,r){let s,o,i,u,h,a="";const c=e/8,f=-1===n?3:0;for(s=0;c>s;s+=3)for(u=c>s+1?t[s+1>>>2]:0,h=c>s+2?t[s+2>>>2]:0,i=(t[s>>>2]>>>8*(f+n*(s%4))&255)<<16|(u>>>8*(f+n*((s+1)%4))&255)<<8|h>>>8*(f+n*((s+2)%4))&255,o=0;4>o;o+=1)a+=8*s+6*o>e?r.b64Pad:b.charAt(i>>>6*(3-o)&63);return a}(t,e,n,r)};case"BYTES":return function(t){return function(t,e,n){let r,s,o="";const i=e/8,u=-1===n?3:0;for(r=0;i>r;r+=1)s=t[r>>>2]>>>8*(u+n*(r%4))&255,o+=String.fromCharCode(s);return o}(t,e,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw Error("ARRAYBUFFER not supported by this environment")}return function(t){return function(t,e,n){let r;const s=e/8,o=new ArrayBuffer(s),i=new Uint8Array(o),u=-1===n?3:0;for(r=0;s>r;r+=1)i[r]=t[r>>>2]>>>8*(u+n*(r%4))&255;return o}(t,e,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw Error("UINT8ARRAY not supported by this environment")}return function(t){return function(t,e,n){let r;const s=e/8,o=-1===n?3:0,i=new Uint8Array(s);for(r=0;s>r;r+=1)i[r]=t[r>>>2]>>>8*(o+n*(r%4))&255;return i}(t,e,n)};default:throw Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function y(t){const e={outputUpper:!1,b64Pad:"=",outputLen:-1},n=t||{},r="Output length must be a multiple of 8";if(e.outputUpper=n.outputUpper||!1,n.b64Pad&&(e.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw Error(r);e.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw Error(r);e.outputLen=n.shakeLen}if("boolean"!=typeof e.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw Error("Invalid b64Pad formatting option");return e}function R(t,e){return t<<e|t>>>32-e}function v(t,e,n){return t^e^n}function T(t,e,n){return t&e^t&n^e&n}function C(t,e){const n=(65535&t)+(65535&e);return(65535&(t>>>16)+(e>>>16)+(n>>>16))<<16|65535&n}function L(t,e,n,r,s){const o=(65535&t)+(65535&e)+(65535&n)+(65535&r)+(65535&s);return(65535&(t>>>16)+(e>>>16)+(n>>>16)+(r>>>16)+(s>>>16)+(o>>>16))<<16|65535&o}function B(t){return[1732584193,4023233417,2562383102,271733878,3285377520]}function F(t,e){let n,r,s,o,i,u,h;const a=[];for(n=e[0],r=e[1],s=e[2],o=e[3],i=e[4],h=0;80>h;h+=1)a[h]=16>h?t[h]:R(a[h-3]^a[h-8]^a[h-14]^a[h-16],1),u=20>h?L(R(n,5),(c=r)&s^~c&o,i,1518500249,a[h]):40>h?L(R(n,5),v(r,s,o),i,1859775393,a[h]):60>h?L(R(n,5),T(r,s,o),i,2400959708,a[h]):L(R(n,5),v(r,s,o),i,3395469782,a[h]),i=o,o=s,s=R(r,30),r=n,n=u;var c;return e[0]=C(n,e[0]),e[1]=C(r,e[1]),e[2]=C(s,e[2]),e[3]=C(o,e[3]),e[4]=C(i,e[4]),e}function I(t,e,n,r){let s;const o=15+(e+65>>>9<<4),i=e+n;for(;o>=t.length;)t.push(0);for(t[e>>>5]|=128<<24-e%32,t[o]=4294967295&i,t[o-1]=i/4294967296|0,s=0;t.length>s;s+=16)r=F(t.slice(s,s+16),r);return r}class H extends class{constructor(t,e,n){const r=n||{};if(this.t=e,this.i=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw Error("numRounds must a integer >= 1");this.o=t,this.h=[],this.u=0,this.l=!1,this.A=0,this.p=!1,this.R=[],this.U=[]}update(t){let e,n=0;const r=this.T>>>5,s=this.F(t,this.h,this.u),o=s.binLen,i=s.value,u=o>>>5;for(e=0;u>e;e+=r)o>=n+this.T&&(this.m=this.g(i.slice(e,e+r),this.m),n+=this.T);return this.A+=n,this.h=i.slice(n>>>5),this.u=o%this.T,this.l=!0,this}getHash(t,e){let n,r,s=this.B;const o=y(e);if(this.v){if(-1===o.outputLen)throw Error("Output length must be specified in options");s=o.outputLen}const i=E(t,s,this.Y,o);if(this.p&&this.H)return i(this.H(o));for(r=this.C(this.h.slice(),this.u,this.A,this.I(this.m),s),n=1;this.numRounds>n;n+=1)this.v&&s%32!=0&&(r[r.length-1]&=16777215>>>24-s%32),r=this.C(r,s,0,this.L(this.o),s);return i(r)}setHMACKey(t,e,n){if(!this.M)throw Error("Variant does not support HMAC");if(this.l)throw Error("Cannot set MAC key after calling update");const r=U(e,(n||{}).encoding||"UTF8",this.Y);this.N(r(t))}N(t){const e=this.T>>>3,n=e/4-1;let r;if(1!==this.numRounds)throw Error("Cannot set numRounds with MAC");if(this.p)throw Error("MAC key already set");for(t.binLen/8>e&&(t.value=this.C(t.value,t.binLen,0,this.L(this.o),this.B));n>=t.value.length;)t.value.push(0);for(r=0;n>=r;r+=1)this.R[r]=909522486^t.value[r],this.U[r]=1549556828^t.value[r];this.m=this.g(this.R,this.m),this.A=this.T,this.p=!0}getHMAC(t,e){const n=y(e);return E(t,this.B,this.Y,n)(this.S())}S(){let t;if(!this.p)throw Error("Cannot call getHMAC without first setting MAC key");const e=this.C(this.h.slice(),this.u,this.A,this.I(this.m),this.B);return t=this.g(this.U,this.L(this.o)),t=this.C(e,this.B,this.T,t,this.B),t}}{constructor(t,e,n){if("SHA-1"!==t)throw Error("Chosen SHA variant is not supported");super(t,e,n);const r=n||{};this.M=!0,this.H=this.S,this.Y=-1,this.F=U(this.t,this.i,this.Y),this.g=F,this.I=function(t){return t.slice()},this.L=B,this.C=I,this.m=[1732584193,4023233417,2562383102,271733878,3285377520],this.T=512,this.B=160,this.v=!1,r.hmacKey&&this.N(function(t,e,n,r){const s="hmacKey must include a value and format";if(!e)throw Error(s);if(void 0===e.value||!e.format)throw Error(s);return U(e.format,e.encoding||"UTF8",n)(e.value)}(0,r.hmacKey,this.Y))}}const Y=400;function S(t,e={}){return function(t,{baseUrl:e="https://api.pwnedpasswords.com",userAgent:n}={}){const s=Object.assign({},n?{headers:{"User-Agent":n}}:{}),o=`${e.replace(/\/$/g,"")}${t}`;return r(o,s).then((t=>{if(t.ok)return t.text();if(t.status===Y)return t.text().then((t=>{throw Error(t)}));throw Error(t.statusText)}))}("/range/"+encodeURIComponent(t),e).then((t=>t.split("\n").filter(Boolean))).then((t=>t.reduce(((t,e)=>{const[n,r]=e.split(":");return t[n]=parseInt(r,10),t}),{})))}function P(t,e={}){const n=new H("SHA-1","TEXT");n.update(t);const r=n.getHash("HEX",{outputUpper:!0}),s=r.slice(0,5),o=r.slice(5);return S(s,e).then((t=>t[o]||0))}function M(t,e={truncate:!0}){const{apiKey:n,baseUrl:r,userAgent:s}=e;return Promise.all([d(t,e),/^.+@.+$/.test(t)?m(t,{apiKey:n,baseUrl:r,userAgent:s}):null]).then((t=>({breaches:t[0],pastes:t[1]})))}export{f as RateLimitError,p as breach,d as breachedAccount,g as breaches,A as dataClasses,m as pasteAccount,P as pwnedPassword,S as pwnedPasswordRange,M as search};
|
|
2
2
|
//# sourceMappingURL=hibp.module.js.map
|