hibp 15.2.1 → 16.0.0
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 +433 -126
- package/CHANGELOG.md +44 -0
- package/MIGRATION.md +7 -5
- package/README.md +53 -27
- package/dist/browser/hibp.module.js +2 -2
- package/dist/esm/api/base-fetch.d.ts +3 -1
- package/dist/esm/api/base-fetch.js +20 -7
- package/dist/esm/api/base-fetch.js.map +1 -1
- package/dist/esm/api/haveibeenpwned/fetch-from-api.d.ts +1 -1
- package/dist/esm/api/haveibeenpwned/fetch-from-api.js +71 -24
- package/dist/esm/api/haveibeenpwned/fetch-from-api.js.map +1 -1
- package/dist/esm/api/haveibeenpwned/package-info.d.ts +1 -1
- package/dist/esm/api/haveibeenpwned/package-info.js +1 -1
- package/dist/esm/api/haveibeenpwned/post-to-api.d.ts +1 -0
- package/dist/esm/api/haveibeenpwned/post-to-api.js +31 -0
- package/dist/esm/api/haveibeenpwned/post-to-api.js.map +1 -0
- package/dist/esm/api/haveibeenpwned/responses.js +8 -7
- package/dist/esm/api/haveibeenpwned/responses.js.map +1 -1
- package/dist/esm/api/haveibeenpwned/types.d.ts +22 -2
- package/dist/esm/api/pwnedpasswords/fetch-from-api.js +4 -4
- package/dist/esm/api/pwnedpasswords/fetch-from-api.js.map +1 -1
- package/dist/esm/api/pwnedpasswords/responses.js +1 -1
- package/dist/esm/breach.d.ts +8 -1
- package/dist/esm/breach.js +8 -1
- package/dist/esm/breach.js.map +1 -1
- package/dist/esm/breached-account-range.d.ts +73 -0
- package/dist/esm/breached-account-range.js +60 -0
- package/dist/esm/breached-account-range.js.map +1 -0
- package/dist/esm/breached-account.d.ts +56 -45
- package/dist/esm/breached-account.js +4 -76
- package/dist/esm/breached-account.js.map +1 -1
- package/dist/esm/breached-domain.d.ts +2 -3
- package/dist/esm/breached-domain.js +2 -3
- package/dist/esm/breached-domain.js.map +1 -1
- package/dist/esm/breaches.d.ts +9 -2
- package/dist/esm/breaches.js +10 -5
- package/dist/esm/breaches.js.map +1 -1
- package/dist/esm/data-class-descriptions.d.ts +55 -0
- package/dist/esm/data-class-descriptions.js +39 -0
- package/dist/esm/data-class-descriptions.js.map +1 -0
- package/dist/esm/data-classes.js +2 -2
- package/dist/esm/data-classes.js.map +1 -1
- package/dist/esm/generate-dns-token.d.ts +67 -0
- package/dist/esm/generate-dns-token.js +48 -0
- package/dist/esm/generate-dns-token.js.map +1 -0
- package/dist/esm/hibp.d.ts +28 -18
- package/dist/esm/hibp.js +23 -18
- package/dist/esm/hibp.js.map +1 -1
- package/dist/esm/latest-breach.d.ts +1 -1
- package/dist/esm/latest-breach.js +2 -2
- package/dist/esm/latest-breach.js.map +1 -1
- package/dist/esm/paste-account.d.ts +8 -8
- package/dist/esm/paste-account.js +8 -8
- package/dist/esm/paste-account.js.map +1 -1
- package/dist/esm/pwned-password-range.d.ts +1 -1
- package/dist/esm/pwned-password-range.js +4 -4
- package/dist/esm/pwned-password-range.js.map +1 -1
- package/dist/esm/pwned-password.js +6 -6
- package/dist/esm/pwned-password.js.map +1 -1
- package/dist/esm/search.d.ts +57 -40
- package/dist/esm/search.js +3 -72
- package/dist/esm/search.js.map +1 -1
- package/dist/esm/send-email.d.ts +69 -0
- package/dist/esm/send-email.js +49 -0
- package/dist/esm/send-email.js.map +1 -0
- package/dist/esm/stealer-logs-by-email-domain.d.ts +8 -9
- package/dist/esm/stealer-logs-by-email-domain.js +8 -9
- package/dist/esm/stealer-logs-by-email-domain.js.map +1 -1
- package/dist/esm/stealer-logs-by-email.d.ts +4 -5
- package/dist/esm/stealer-logs-by-email.js +5 -6
- package/dist/esm/stealer-logs-by-email.js.map +1 -1
- package/dist/esm/stealer-logs-by-website-domain.d.ts +4 -5
- package/dist/esm/stealer-logs-by-website-domain.js +5 -6
- package/dist/esm/stealer-logs-by-website-domain.js.map +1 -1
- package/dist/esm/subscribed-domains.d.ts +2 -3
- package/dist/esm/subscribed-domains.js +3 -4
- package/dist/esm/subscribed-domains.js.map +1 -1
- package/dist/esm/subscription-status.d.ts +11 -6
- package/dist/esm/subscription-status.js +12 -7
- package/dist/esm/subscription-status.js.map +1 -1
- package/dist/esm/verify-dns-token.d.ts +60 -0
- package/dist/esm/verify-dns-token.js +41 -0
- package/dist/esm/verify-dns-token.js.map +1 -0
- package/package.json +55 -56
package/dist/esm/breaches.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { fetchFromApi } from
|
|
1
|
+
import { fetchFromApi } from "./api/haveibeenpwned/fetch-from-api.js";
|
|
2
2
|
/**
|
|
3
3
|
* Fetches all breach events in the system.
|
|
4
4
|
*
|
|
5
5
|
* @param {object} [options] a configuration object
|
|
6
6
|
* @param {string} [options.domain] a domain by which to filter the results
|
|
7
7
|
* (default: all domains)
|
|
8
|
+
* @param {boolean} [options.isSpamList] true for only spam-list breaches, false
|
|
9
|
+
* for only non-spam-list breaches (default: no spam-list filter)
|
|
8
10
|
* @param {string} [options.baseUrl] a custom base URL for the
|
|
9
11
|
* haveibeenpwned.com API endpoints (default:
|
|
10
12
|
* `https://haveibeenpwned.com/api/v3`)
|
|
@@ -28,7 +30,7 @@ import { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';
|
|
|
28
30
|
* }
|
|
29
31
|
* @example
|
|
30
32
|
* try {
|
|
31
|
-
* const data = await breaches({ domain: "adobe.com" });
|
|
33
|
+
* const data = await breaches({ domain: "adobe.com", isSpamList: false });
|
|
32
34
|
* if (data) {
|
|
33
35
|
* // ...
|
|
34
36
|
* } else {
|
|
@@ -39,13 +41,16 @@ import { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';
|
|
|
39
41
|
* }
|
|
40
42
|
*/
|
|
41
43
|
export function breaches(options = {}) {
|
|
42
|
-
const { domain, baseUrl, timeoutMs, signal, userAgent } = options;
|
|
43
|
-
const endpoint =
|
|
44
|
+
const { domain, isSpamList, baseUrl, timeoutMs, signal, userAgent } = options;
|
|
45
|
+
const endpoint = "/breaches?";
|
|
44
46
|
const params = [];
|
|
45
47
|
if (domain) {
|
|
46
48
|
params.push(`domain=${encodeURIComponent(domain)}`);
|
|
47
49
|
}
|
|
48
|
-
|
|
50
|
+
if (isSpamList !== undefined) {
|
|
51
|
+
params.push(`isSpamList=${isSpamList}`);
|
|
52
|
+
}
|
|
53
|
+
return fetchFromApi(`${endpoint}${params.join("&")}`, {
|
|
49
54
|
baseUrl,
|
|
50
55
|
timeoutMs,
|
|
51
56
|
signal,
|
package/dist/esm/breaches.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"breaches.js","sourceRoot":"","sources":["../../src/breaches.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE
|
|
1
|
+
{"version":3,"file":"breaches.js","sourceRoot":"","sources":["../../src/breaches.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,UAAU,QAAQ,CACtB,OAAO,GA4BH,EAAE;IAEN,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9E,MAAM,QAAQ,GAAG,YAAY,CAAC;IAC9B,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,CAAC,IAAI,CAAC,UAAU,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,cAAc,UAAU,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,YAAY,CAAC,GAAG,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;QACpD,OAAO;QACP,SAAS;QACT,MAAM;QACN,SAAS;KACV,CAAsB,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { DataClassDescription } from "./api/haveibeenpwned/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* A data class name and its description.
|
|
4
|
+
*
|
|
5
|
+
* @typedef {object} DataClassDescription
|
|
6
|
+
* @property {string} name - the data class name
|
|
7
|
+
* @property {string} description - a description of the compromised data
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Fetches all data class names and descriptions.
|
|
11
|
+
*
|
|
12
|
+
* @param {object} [options] a configuration object
|
|
13
|
+
* @param {string} [options.baseUrl] a custom base URL for the
|
|
14
|
+
* haveibeenpwned.com API endpoints (default:
|
|
15
|
+
* `https://haveibeenpwned.com/api/v3`)
|
|
16
|
+
* @param {number} [options.timeoutMs] timeout for the request in milliseconds
|
|
17
|
+
* (default: none)
|
|
18
|
+
* @param {AbortSignal} [options.signal] an AbortSignal to cancel the request (default: none)
|
|
19
|
+
* @param {string} [options.userAgent] a custom string to send as the User-Agent
|
|
20
|
+
* field in the request headers (default: `hibp <version>`)
|
|
21
|
+
* @returns {(Promise<DataClassDescription[]> | Promise<null>)} a Promise which
|
|
22
|
+
* resolves to an array of data class objects (or null if no data classes were
|
|
23
|
+
* found), or rejects with an Error
|
|
24
|
+
* @example
|
|
25
|
+
* try {
|
|
26
|
+
* const data = await dataClassDescriptions();
|
|
27
|
+
* if (data) {
|
|
28
|
+
* // ...
|
|
29
|
+
* } else {
|
|
30
|
+
* // ...
|
|
31
|
+
* }
|
|
32
|
+
* } catch (err) {
|
|
33
|
+
* // ...
|
|
34
|
+
* }
|
|
35
|
+
*/
|
|
36
|
+
export declare function dataClassDescriptions(options?: {
|
|
37
|
+
/**
|
|
38
|
+
* a custom base URL for the haveibeenpwned.com API endpoints (default:
|
|
39
|
+
* `https://haveibeenpwned.com/api/v3`)
|
|
40
|
+
*/
|
|
41
|
+
baseUrl?: string;
|
|
42
|
+
/**
|
|
43
|
+
* timeout for the request in milliseconds (default: none)
|
|
44
|
+
*/
|
|
45
|
+
timeoutMs?: number;
|
|
46
|
+
/**
|
|
47
|
+
* an AbortSignal to cancel the request (default: none)
|
|
48
|
+
*/
|
|
49
|
+
signal?: AbortSignal;
|
|
50
|
+
/**
|
|
51
|
+
* a custom string to send as the User-Agent field in the request headers
|
|
52
|
+
* (default: `hibp <version>`)
|
|
53
|
+
*/
|
|
54
|
+
userAgent?: string;
|
|
55
|
+
}): Promise<DataClassDescription[] | null>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { fetchFromApi } from "./api/haveibeenpwned/fetch-from-api.js";
|
|
2
|
+
/**
|
|
3
|
+
* A data class name and its description.
|
|
4
|
+
*
|
|
5
|
+
* @typedef {object} DataClassDescription
|
|
6
|
+
* @property {string} name - the data class name
|
|
7
|
+
* @property {string} description - a description of the compromised data
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Fetches all data class names and descriptions.
|
|
11
|
+
*
|
|
12
|
+
* @param {object} [options] a configuration object
|
|
13
|
+
* @param {string} [options.baseUrl] a custom base URL for the
|
|
14
|
+
* haveibeenpwned.com API endpoints (default:
|
|
15
|
+
* `https://haveibeenpwned.com/api/v3`)
|
|
16
|
+
* @param {number} [options.timeoutMs] timeout for the request in milliseconds
|
|
17
|
+
* (default: none)
|
|
18
|
+
* @param {AbortSignal} [options.signal] an AbortSignal to cancel the request (default: none)
|
|
19
|
+
* @param {string} [options.userAgent] a custom string to send as the User-Agent
|
|
20
|
+
* field in the request headers (default: `hibp <version>`)
|
|
21
|
+
* @returns {(Promise<DataClassDescription[]> | Promise<null>)} a Promise which
|
|
22
|
+
* resolves to an array of data class objects (or null if no data classes were
|
|
23
|
+
* found), or rejects with an Error
|
|
24
|
+
* @example
|
|
25
|
+
* try {
|
|
26
|
+
* const data = await dataClassDescriptions();
|
|
27
|
+
* if (data) {
|
|
28
|
+
* // ...
|
|
29
|
+
* } else {
|
|
30
|
+
* // ...
|
|
31
|
+
* }
|
|
32
|
+
* } catch (err) {
|
|
33
|
+
* // ...
|
|
34
|
+
* }
|
|
35
|
+
*/
|
|
36
|
+
export function dataClassDescriptions(options = {}) {
|
|
37
|
+
return fetchFromApi("/dataclasses/descriptions", options);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=data-class-descriptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-class-descriptions.js","sourceRoot":"","sources":["../../src/data-class-descriptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAO,GAmBH,EAAE;IAEN,OAAO,YAAY,CAAC,2BAA2B,EAAE,OAAO,CAEvD,CAAC;AACJ,CAAC"}
|
package/dist/esm/data-classes.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fetchFromApi } from
|
|
1
|
+
import { fetchFromApi } from "./api/haveibeenpwned/fetch-from-api.js";
|
|
2
2
|
/**
|
|
3
3
|
* Fetches all data classes in the system.
|
|
4
4
|
*
|
|
@@ -27,6 +27,6 @@ import { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';
|
|
|
27
27
|
* }
|
|
28
28
|
*/
|
|
29
29
|
export function dataClasses(options = {}) {
|
|
30
|
-
return fetchFromApi(
|
|
30
|
+
return fetchFromApi("/dataclasses", options);
|
|
31
31
|
}
|
|
32
32
|
//# sourceMappingURL=data-classes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-classes.js","sourceRoot":"","sources":["../../src/data-classes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,WAAW,CACzB,
|
|
1
|
+
{"version":3,"file":"data-classes.js","sourceRoot":"","sources":["../../src/data-classes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,WAAW,CACzB,OAAO,GAmBH,EAAE;IAEN,OAAO,YAAY,CAAC,cAAc,EAAE,OAAO,CAA6B,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { DnsToken } from "./api/haveibeenpwned/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The TXT record value to publish at your DNS provider.
|
|
4
|
+
*
|
|
5
|
+
* @typedef {object} DnsToken
|
|
6
|
+
* @property {string} txtRecordValue - the complete TXT record value
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Generates a domain-specific DNS verification token.
|
|
10
|
+
*
|
|
11
|
+
* Publish `txtRecordValue` as a TXT record on the domain, then call
|
|
12
|
+
* `verifyDnsToken` after DNS propagation.
|
|
13
|
+
*
|
|
14
|
+
* Requires a Pro API key from https://haveibeenpwned.com/API/Key. The `apiKey`
|
|
15
|
+
* option here is not explicitly required, but direct requests made without it
|
|
16
|
+
* will fail (unless you specify a `baseUrl` to a proxy that inserts a valid API
|
|
17
|
+
* key on your behalf).
|
|
18
|
+
*
|
|
19
|
+
* @see https://haveibeenpwned.com/API/v3#VerifyDomainViaDns
|
|
20
|
+
* @param {string} domain the domain to verify (e.g., "example.com")
|
|
21
|
+
* @param {object} [options] a configuration object
|
|
22
|
+
* @param {string} [options.apiKey] an API key from
|
|
23
|
+
* https://haveibeenpwned.com/API/Key (default: undefined)
|
|
24
|
+
* @param {string} [options.baseUrl] a custom base URL for the
|
|
25
|
+
* haveibeenpwned.com API endpoints (default:
|
|
26
|
+
* `https://haveibeenpwned.com/api/v3`)
|
|
27
|
+
* @param {number} [options.timeoutMs] timeout for the request in milliseconds
|
|
28
|
+
* (default: none)
|
|
29
|
+
* @param {AbortSignal} [options.signal] an AbortSignal to cancel the request (default: none)
|
|
30
|
+
* @param {string} [options.userAgent] a custom string to send as the User-Agent
|
|
31
|
+
* field in the request headers (default: `hibp <version>`)
|
|
32
|
+
* @returns {Promise<DnsToken>} a Promise which resolves to the TXT record
|
|
33
|
+
* value, or rejects with an Error containing the upstream failure reason
|
|
34
|
+
* @example
|
|
35
|
+
* try {
|
|
36
|
+
* const { txtRecordValue } = await generateDnsToken("example.com", {
|
|
37
|
+
* apiKey: "my-api-key",
|
|
38
|
+
* });
|
|
39
|
+
* // Publish txtRecordValue as a TXT record on example.com.
|
|
40
|
+
* } catch (err) {
|
|
41
|
+
* // ...
|
|
42
|
+
* }
|
|
43
|
+
*/
|
|
44
|
+
export declare function generateDnsToken(domain: string, options?: {
|
|
45
|
+
/**
|
|
46
|
+
* an API key from https://haveibeenpwned.com/API/Key (default: undefined)
|
|
47
|
+
*/
|
|
48
|
+
apiKey?: string;
|
|
49
|
+
/**
|
|
50
|
+
* a custom base URL for the haveibeenpwned.com API endpoints (default:
|
|
51
|
+
* `https://haveibeenpwned.com/api/v3`)
|
|
52
|
+
*/
|
|
53
|
+
baseUrl?: string;
|
|
54
|
+
/**
|
|
55
|
+
* timeout for the request in milliseconds (default: none)
|
|
56
|
+
*/
|
|
57
|
+
timeoutMs?: number;
|
|
58
|
+
/**
|
|
59
|
+
* an AbortSignal to cancel the request (default: none)
|
|
60
|
+
*/
|
|
61
|
+
signal?: AbortSignal;
|
|
62
|
+
/**
|
|
63
|
+
* a custom string to send as the User-Agent field in the request headers
|
|
64
|
+
* (default: `hibp <version>`)
|
|
65
|
+
*/
|
|
66
|
+
userAgent?: string;
|
|
67
|
+
}): Promise<DnsToken>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { postToApi } from "./api/haveibeenpwned/post-to-api.js";
|
|
2
|
+
/**
|
|
3
|
+
* The TXT record value to publish at your DNS provider.
|
|
4
|
+
*
|
|
5
|
+
* @typedef {object} DnsToken
|
|
6
|
+
* @property {string} txtRecordValue - the complete TXT record value
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Generates a domain-specific DNS verification token.
|
|
10
|
+
*
|
|
11
|
+
* Publish `txtRecordValue` as a TXT record on the domain, then call
|
|
12
|
+
* `verifyDnsToken` after DNS propagation.
|
|
13
|
+
*
|
|
14
|
+
* Requires a Pro API key from https://haveibeenpwned.com/API/Key. The `apiKey`
|
|
15
|
+
* option here is not explicitly required, but direct requests made without it
|
|
16
|
+
* will fail (unless you specify a `baseUrl` to a proxy that inserts a valid API
|
|
17
|
+
* key on your behalf).
|
|
18
|
+
*
|
|
19
|
+
* @see https://haveibeenpwned.com/API/v3#VerifyDomainViaDns
|
|
20
|
+
* @param {string} domain the domain to verify (e.g., "example.com")
|
|
21
|
+
* @param {object} [options] a configuration object
|
|
22
|
+
* @param {string} [options.apiKey] an API key from
|
|
23
|
+
* https://haveibeenpwned.com/API/Key (default: undefined)
|
|
24
|
+
* @param {string} [options.baseUrl] a custom base URL for the
|
|
25
|
+
* haveibeenpwned.com API endpoints (default:
|
|
26
|
+
* `https://haveibeenpwned.com/api/v3`)
|
|
27
|
+
* @param {number} [options.timeoutMs] timeout for the request in milliseconds
|
|
28
|
+
* (default: none)
|
|
29
|
+
* @param {AbortSignal} [options.signal] an AbortSignal to cancel the request (default: none)
|
|
30
|
+
* @param {string} [options.userAgent] a custom string to send as the User-Agent
|
|
31
|
+
* field in the request headers (default: `hibp <version>`)
|
|
32
|
+
* @returns {Promise<DnsToken>} a Promise which resolves to the TXT record
|
|
33
|
+
* value, or rejects with an Error containing the upstream failure reason
|
|
34
|
+
* @example
|
|
35
|
+
* try {
|
|
36
|
+
* const { txtRecordValue } = await generateDnsToken("example.com", {
|
|
37
|
+
* apiKey: "my-api-key",
|
|
38
|
+
* });
|
|
39
|
+
* // Publish txtRecordValue as a TXT record on example.com.
|
|
40
|
+
* } catch (err) {
|
|
41
|
+
* // ...
|
|
42
|
+
* }
|
|
43
|
+
*/
|
|
44
|
+
export async function generateDnsToken(domain, options = {}) {
|
|
45
|
+
const response = await postToApi("/domainVerification/generateDnsToken", { DomainName: domain }, options);
|
|
46
|
+
return response.json();
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=generate-dns-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-dns-token.js","sourceRoot":"","sources":["../../src/generate-dns-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAGhE;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAc,EACd,OAAO,GAuBH,EAAE;IAEN,MAAM,QAAQ,GAAG,MAAM,SAAS,CAC9B,sCAAsC,EACtC,EAAE,UAAU,EAAE,MAAM,EAAE,EACtB,OAAO,CACR,CAAC;IACF,OAAO,QAAQ,CAAC,IAAI,EAAuB,CAAC;AAC9C,CAAC"}
|
package/dist/esm/hibp.d.ts
CHANGED
|
@@ -1,36 +1,46 @@
|
|
|
1
|
-
import { RateLimitError } from
|
|
2
|
-
import { breach } from
|
|
3
|
-
import { breachedAccount } from
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { RateLimitError } from "./api/haveibeenpwned/fetch-from-api.js";
|
|
2
|
+
import { breach } from "./breach.js";
|
|
3
|
+
import { breachedAccount } from "./breached-account.js";
|
|
4
|
+
import { breachedAccountRange } from "./breached-account-range.js";
|
|
5
|
+
import { breachedDomain } from "./breached-domain.js";
|
|
6
|
+
import { breaches } from "./breaches.js";
|
|
7
|
+
import { dataClasses } from "./data-classes.js";
|
|
8
|
+
import { dataClassDescriptions } from "./data-class-descriptions.js";
|
|
9
|
+
import { generateDnsToken } from "./generate-dns-token.js";
|
|
10
|
+
import { latestBreach } from "./latest-breach.js";
|
|
11
|
+
import { pasteAccount } from "./paste-account.js";
|
|
12
|
+
import { pwnedPassword } from "./pwned-password.js";
|
|
13
|
+
import { pwnedPasswordRange } from "./pwned-password-range.js";
|
|
14
|
+
import { search } from "./search.js";
|
|
15
|
+
import { sendEmail } from "./send-email.js";
|
|
16
|
+
import { stealerLogsByEmail } from "./stealer-logs-by-email.js";
|
|
17
|
+
import { stealerLogsByEmailDomain } from "./stealer-logs-by-email-domain.js";
|
|
18
|
+
import { stealerLogsByWebsiteDomain } from "./stealer-logs-by-website-domain.js";
|
|
19
|
+
import { subscribedDomains } from "./subscribed-domains.js";
|
|
20
|
+
import { subscriptionStatus } from "./subscription-status.js";
|
|
21
|
+
import { verifyDnsToken } from "./verify-dns-token.js";
|
|
22
|
+
export type * from "./api/haveibeenpwned/types.js";
|
|
23
|
+
export { breach, breachedAccount, breachedAccountRange, breachedDomain, breaches, dataClasses, dataClassDescriptions, generateDnsToken, latestBreach, pasteAccount, pwnedPassword, pwnedPasswordRange, search, sendEmail, stealerLogsByEmail, stealerLogsByEmailDomain, stealerLogsByWebsiteDomain, subscribedDomains, subscriptionStatus, verifyDnsToken, RateLimitError, };
|
|
19
24
|
export interface HIBP {
|
|
20
25
|
breach: typeof breach;
|
|
21
26
|
breachedAccount: typeof breachedAccount;
|
|
27
|
+
breachedAccountRange: typeof breachedAccountRange;
|
|
22
28
|
breachedDomain: typeof breachedDomain;
|
|
23
29
|
breaches: typeof breaches;
|
|
24
30
|
dataClasses: typeof dataClasses;
|
|
31
|
+
dataClassDescriptions: typeof dataClassDescriptions;
|
|
32
|
+
generateDnsToken: typeof generateDnsToken;
|
|
25
33
|
latestBreach: typeof latestBreach;
|
|
26
34
|
pasteAccount: typeof pasteAccount;
|
|
27
35
|
pwnedPassword: typeof pwnedPassword;
|
|
28
36
|
pwnedPasswordRange: typeof pwnedPasswordRange;
|
|
29
37
|
search: typeof search;
|
|
38
|
+
sendEmail: typeof sendEmail;
|
|
30
39
|
stealerLogsByEmail: typeof stealerLogsByEmail;
|
|
31
40
|
stealerLogsByEmailDomain: typeof stealerLogsByEmailDomain;
|
|
32
41
|
stealerLogsByWebsiteDomain: typeof stealerLogsByWebsiteDomain;
|
|
33
42
|
subscribedDomains: typeof subscribedDomains;
|
|
34
43
|
subscriptionStatus: typeof subscriptionStatus;
|
|
44
|
+
verifyDnsToken: typeof verifyDnsToken;
|
|
35
45
|
RateLimitError: typeof RateLimitError;
|
|
36
46
|
}
|
package/dist/esm/hibp.js
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import { RateLimitError } from
|
|
2
|
-
import { breach } from
|
|
3
|
-
import { breachedAccount } from
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
1
|
+
import { RateLimitError } from "./api/haveibeenpwned/fetch-from-api.js";
|
|
2
|
+
import { breach } from "./breach.js";
|
|
3
|
+
import { breachedAccount } from "./breached-account.js";
|
|
4
|
+
import { breachedAccountRange } from "./breached-account-range.js";
|
|
5
|
+
import { breachedDomain } from "./breached-domain.js";
|
|
6
|
+
import { breaches } from "./breaches.js";
|
|
7
|
+
import { dataClasses } from "./data-classes.js";
|
|
8
|
+
import { dataClassDescriptions } from "./data-class-descriptions.js";
|
|
9
|
+
import { generateDnsToken } from "./generate-dns-token.js";
|
|
10
|
+
import { latestBreach } from "./latest-breach.js";
|
|
11
|
+
import { pasteAccount } from "./paste-account.js";
|
|
12
|
+
import { pwnedPassword } from "./pwned-password.js";
|
|
13
|
+
import { pwnedPasswordRange } from "./pwned-password-range.js";
|
|
14
|
+
import { search } from "./search.js";
|
|
15
|
+
import { sendEmail } from "./send-email.js";
|
|
16
|
+
import { stealerLogsByEmail } from "./stealer-logs-by-email.js";
|
|
17
|
+
import { stealerLogsByEmailDomain } from "./stealer-logs-by-email-domain.js";
|
|
18
|
+
import { stealerLogsByWebsiteDomain } from "./stealer-logs-by-website-domain.js";
|
|
19
|
+
import { subscribedDomains } from "./subscribed-domains.js";
|
|
20
|
+
import { subscriptionStatus } from "./subscription-status.js";
|
|
21
|
+
import { verifyDnsToken } from "./verify-dns-token.js";
|
|
17
22
|
/*
|
|
18
23
|
* Export individual named functions to allow the following:
|
|
19
24
|
*
|
|
@@ -22,8 +27,8 @@ import { subscriptionStatus } from './subscription-status.js';
|
|
|
22
27
|
* const { search } = require('hibp'); // CommonJS
|
|
23
28
|
* const hibp = require('hibp'); // CommonJS
|
|
24
29
|
*/
|
|
25
|
-
export { breach, breachedAccount, breachedDomain, breaches, dataClasses, latestBreach, pasteAccount, pwnedPassword, pwnedPasswordRange, search, stealerLogsByEmail, stealerLogsByEmailDomain, stealerLogsByWebsiteDomain, subscribedDomains, subscriptionStatus, RateLimitError, };
|
|
30
|
+
export { breach, breachedAccount, breachedAccountRange, breachedDomain, breaches, dataClasses, dataClassDescriptions, generateDnsToken, latestBreach, pasteAccount, pwnedPassword, pwnedPasswordRange, search, sendEmail, stealerLogsByEmail, stealerLogsByEmailDomain, stealerLogsByWebsiteDomain, subscribedDomains, subscriptionStatus, verifyDnsToken, RateLimitError, };
|
|
26
31
|
// https://github.com/jsdoc2md/jsdoc-to-markdown/wiki/How-to-document-TypeScript#jsdoc-comments-disappear
|
|
27
|
-
//
|
|
32
|
+
// oxlint-disable-next-line eslint/no-unused-vars -- Required for jsdoc-to-markdown.
|
|
28
33
|
const JSDOC2MARKDOWN_STUB = undefined;
|
|
29
34
|
//# sourceMappingURL=hibp.js.map
|
package/dist/esm/hibp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hibp.js","sourceRoot":"","sources":["../../src/hibp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"hibp.js","sourceRoot":"","sources":["../../src/hibp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAIvD;;;;;;;GAOG;AAEH,OAAO,EACL,MAAM,EACN,eAAe,EACf,oBAAoB,EACpB,cAAc,EACd,QAAQ,EACR,WAAW,EACX,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,MAAM,EACN,SAAS,EACT,kBAAkB,EAClB,wBAAwB,EACxB,0BAA0B,EAC1B,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,cAAc,GACf,CAAC;AA2BF,yGAAyG;AACzG,oFAAoF;AACpF,MAAM,mBAAmB,GAAG,SAAS,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fetchFromApi } from
|
|
1
|
+
import { fetchFromApi } from "./api/haveibeenpwned/fetch-from-api.js";
|
|
2
2
|
/**
|
|
3
3
|
* Fetches the most recently added breach.
|
|
4
4
|
*
|
|
@@ -27,6 +27,6 @@ import { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';
|
|
|
27
27
|
* }
|
|
28
28
|
*/
|
|
29
29
|
export function latestBreach(options = {}) {
|
|
30
|
-
return fetchFromApi(
|
|
30
|
+
return fetchFromApi("/latestbreach", options);
|
|
31
31
|
}
|
|
32
32
|
//# sourceMappingURL=latest-breach.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latest-breach.js","sourceRoot":"","sources":["../../src/latest-breach.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,YAAY,CAC1B,
|
|
1
|
+
{"version":3,"file":"latest-breach.js","sourceRoot":"","sources":["../../src/latest-breach.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,YAAY,CAC1B,OAAO,GAmBH,EAAE;IAEN,OAAO,YAAY,CAAC,eAAe,EAAE,OAAO,CAA2B,CAAC;AAC1E,CAAC"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import type { Paste } from
|
|
1
|
+
import type { Paste } from "./api/haveibeenpwned/types.js";
|
|
2
2
|
/**
|
|
3
3
|
* An object representing a paste.
|
|
4
4
|
*
|
|
5
5
|
* @typedef {object} Paste
|
|
6
6
|
* @property {string} Id
|
|
7
7
|
* @property {string} Source
|
|
8
|
-
* @property {string} Title
|
|
9
|
-
* @property {string} Date
|
|
8
|
+
* @property {string} [Title] omitted when the source has no title
|
|
9
|
+
* @property {(string | null)} Date null when the source has no posting date
|
|
10
10
|
* @property {number} EmailCount
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
13
|
* Fetches paste data for a specific account (email address).
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
* https://haveibeenpwned.com/API/Key
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
15
|
+
* Requires a Core, Pro, or High RPM API key from
|
|
16
|
+
* https://haveibeenpwned.com/API/Key. The `apiKey` option here is not
|
|
17
|
+
* explicitly required, but direct requests made without it will fail (unless
|
|
18
|
+
* you specify a `baseUrl` to a proxy that inserts a valid API key on your
|
|
19
|
+
* behalf).
|
|
20
20
|
*
|
|
21
21
|
* @param {string} email the email address to query
|
|
22
22
|
* @param {object} [options] a configuration object
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { fetchFromApi } from
|
|
1
|
+
import { fetchFromApi } from "./api/haveibeenpwned/fetch-from-api.js";
|
|
2
2
|
/**
|
|
3
3
|
* An object representing a paste.
|
|
4
4
|
*
|
|
5
5
|
* @typedef {object} Paste
|
|
6
6
|
* @property {string} Id
|
|
7
7
|
* @property {string} Source
|
|
8
|
-
* @property {string} Title
|
|
9
|
-
* @property {string} Date
|
|
8
|
+
* @property {string} [Title] omitted when the source has no title
|
|
9
|
+
* @property {(string | null)} Date null when the source has no posting date
|
|
10
10
|
* @property {number} EmailCount
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
13
|
* Fetches paste data for a specific account (email address).
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
* https://haveibeenpwned.com/API/Key
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
15
|
+
* Requires a Core, Pro, or High RPM API key from
|
|
16
|
+
* https://haveibeenpwned.com/API/Key. The `apiKey` option here is not
|
|
17
|
+
* explicitly required, but direct requests made without it will fail (unless
|
|
18
|
+
* you specify a `baseUrl` to a proxy that inserts a valid API key on your
|
|
19
|
+
* behalf).
|
|
20
20
|
*
|
|
21
21
|
* @param {string} email the email address to query
|
|
22
22
|
* @param {object} [options] a configuration object
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paste-account.js","sourceRoot":"","sources":["../../src/paste-account.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE;;;;;;;;;GASG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAa,EACb,
|
|
1
|
+
{"version":3,"file":"paste-account.js","sourceRoot":"","sources":["../../src/paste-account.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE;;;;;;;;;GASG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAa,EACb,OAAO,GAuBH,EAAE;IAEN,OAAO,YAAY,CACjB,iBAAiB,kBAAkB,CAAC,KAAK,CAAC,EAAE,EAC5C,OAAO,CACmB,CAAC;AAC/B,CAAC"}
|
|
@@ -65,7 +65,7 @@ export declare function pwnedPasswordRange(prefix: string, options?: {
|
|
|
65
65
|
/**
|
|
66
66
|
* return SHA-1 or NTLM hashes (default: `sha1`)
|
|
67
67
|
*/
|
|
68
|
-
mode?:
|
|
68
|
+
mode?: "sha1" | "ntlm";
|
|
69
69
|
/**
|
|
70
70
|
* a custom base URL for the haveibeenpwned.com API endpoints (default:
|
|
71
71
|
* `https://haveibeenpwned.com/api/v3`)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fetchFromApi } from
|
|
1
|
+
import { fetchFromApi } from "./api/pwnedpasswords/fetch-from-api.js";
|
|
2
2
|
/**
|
|
3
3
|
* An object mapping an exposed password hash suffix (corresponding to a given
|
|
4
4
|
* hash prefix) to how many times it occurred in the Pwned Passwords repository.
|
|
@@ -57,7 +57,7 @@ import { fetchFromApi } from './api/pwnedpasswords/fetch-from-api.js';
|
|
|
57
57
|
* @see https://haveibeenpwned.com/api/v3#SearchingPwnedPasswordsByRange
|
|
58
58
|
*/
|
|
59
59
|
export async function pwnedPasswordRange(prefix, options = {}) {
|
|
60
|
-
const { baseUrl, timeoutMs, signal, userAgent, addPadding = false, mode =
|
|
60
|
+
const { baseUrl, timeoutMs, signal, userAgent, addPadding = false, mode = "sha1", } = options;
|
|
61
61
|
const data = await fetchFromApi(`/range/${encodeURIComponent(prefix)}`, {
|
|
62
62
|
baseUrl,
|
|
63
63
|
timeoutMs,
|
|
@@ -67,10 +67,10 @@ export async function pwnedPasswordRange(prefix, options = {}) {
|
|
|
67
67
|
mode,
|
|
68
68
|
});
|
|
69
69
|
// create array from lines of text in response body
|
|
70
|
-
const results = data.split(
|
|
70
|
+
const results = data.split("\n").filter(Boolean);
|
|
71
71
|
// convert into an object mapping suffix to count for each line
|
|
72
72
|
return results.reduce((acc, row) => {
|
|
73
|
-
const [suffix, countString] = row.split(
|
|
73
|
+
const [suffix, countString] = row.split(":");
|
|
74
74
|
acc[suffix] = Number.parseInt(countString, 10);
|
|
75
75
|
return acc;
|
|
76
76
|
}, {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pwned-password-range.js","sourceRoot":"","sources":["../../src/pwned-password-range.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAItE;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAc,EACd,
|
|
1
|
+
{"version":3,"file":"pwned-password-range.js","sourceRoot":"","sources":["../../src/pwned-password-range.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAItE;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAc,EACd,OAAO,GA4BH,EAAE;IAEN,MAAM,EACJ,OAAO,EACP,SAAS,EACT,MAAM,EACN,SAAS,EACT,UAAU,GAAG,KAAK,EAClB,IAAI,GAAG,MAAM,GACd,GAAG,OAAO,CAAC;IAEZ,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,UAAU,kBAAkB,CAAC,MAAM,CAAC,EAAE,EAAE;QACtE,OAAO;QACP,SAAS;QACT,MAAM;QACN,SAAS;QACT,UAAU;QACV,IAAI;KACL,CAAC,CAAC;IAEH,mDAAmD;IACnD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAEjD,+DAA+D;IAC/D,OAAO,OAAO,CAAC,MAAM,CAAwB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACxD,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7C,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAC/C,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pwnedPasswordRange } from
|
|
1
|
+
import { pwnedPasswordRange } from "./pwned-password-range.js";
|
|
2
2
|
/**
|
|
3
3
|
* Fetches the number of times the the given password has been exposed in a
|
|
4
4
|
* breach (0 indicating no exposure). The password is given in plain text, but
|
|
@@ -37,16 +37,16 @@ export async function pwnedPassword(password, options = {}) {
|
|
|
37
37
|
return range[suffix] || 0;
|
|
38
38
|
}
|
|
39
39
|
async function getPasswordHashParts(password) {
|
|
40
|
-
if (typeof crypto ===
|
|
40
|
+
if (typeof crypto === "object" && crypto.subtle) {
|
|
41
41
|
const msgUint8 = new TextEncoder().encode(password);
|
|
42
|
-
const hashBuffer = await crypto.subtle.digest(
|
|
42
|
+
const hashBuffer = await crypto.subtle.digest("SHA-1", msgUint8);
|
|
43
43
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
44
44
|
const hashHex = hashArray
|
|
45
|
-
.map((byte) => byte.toString(16).padStart(2,
|
|
46
|
-
.join(
|
|
45
|
+
.map((byte) => byte.toString(16).padStart(2, "0"))
|
|
46
|
+
.join("")
|
|
47
47
|
.toUpperCase();
|
|
48
48
|
return [hashHex.slice(0, 5), hashHex.slice(5)];
|
|
49
49
|
}
|
|
50
|
-
throw new Error(
|
|
50
|
+
throw new Error("The Web Crypto API is not available in this environment.");
|
|
51
51
|
}
|
|
52
52
|
//# sourceMappingURL=pwned-password.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pwned-password.js","sourceRoot":"","sources":["../../src/pwned-password.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,QAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"pwned-password.js","sourceRoot":"","sources":["../../src/pwned-password.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,QAAgB,EAChB,OAAO,GAwBH,EAAE;IAEN,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAC9D,MAAM,KAAK,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxD,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED,KAAK,UAAU,oBAAoB,CAAC,QAAgB;IAClD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAChD,MAAM,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACpD,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACjE,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,SAAS;aACtB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;aACjD,IAAI,CAAC,EAAE,CAAC;aACR,WAAW,EAAE,CAAC;QAEjB,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAU,CAAC;IAC1D,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;AAC9E,CAAC"}
|