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.
- package/API.md +275 -198
- package/CHANGELOG.md +70 -0
- package/README.md +20 -22
- package/dist/browser/hibp.module.js +1 -1
- package/dist/browser/hibp.module.js.map +1 -1
- package/dist/browser/hibp.umd.js +1 -1
- package/dist/browser/hibp.umd.js.map +1 -1
- package/dist/cjs/api/fetch-polyfill.cjs +27 -0
- package/dist/cjs/api/fetch-polyfill.cjs.map +1 -0
- package/dist/cjs/api/haveibeenpwned/{fetchFromApi.js → fetch-from-api.cjs} +43 -38
- package/dist/cjs/api/haveibeenpwned/fetch-from-api.cjs.map +1 -0
- package/dist/cjs/api/haveibeenpwned/{responses.js → responses.cjs} +1 -7
- package/dist/cjs/api/haveibeenpwned/responses.cjs.map +1 -0
- package/dist/cjs/api/haveibeenpwned/types.cjs +2 -0
- package/dist/cjs/api/haveibeenpwned/types.cjs.map +1 -0
- package/dist/cjs/api/pwnedpasswords/fetch-from-api.cjs +53 -0
- package/dist/cjs/api/pwnedpasswords/fetch-from-api.cjs.map +1 -0
- package/dist/cjs/api/pwnedpasswords/{responses.js → responses.cjs} +1 -6
- package/dist/cjs/api/pwnedpasswords/responses.cjs.map +1 -0
- package/dist/cjs/{breach.js → breach.cjs} +14 -13
- package/dist/cjs/breach.cjs.map +1 -0
- package/dist/cjs/{breachedAccount.js → breached-account.cjs} +56 -56
- package/dist/cjs/breached-account.cjs.map +1 -0
- package/dist/cjs/{breaches.js → breaches.cjs} +29 -26
- package/dist/cjs/breaches.cjs.map +1 -0
- package/dist/cjs/{dataClasses.js → data-classes.cjs} +11 -12
- package/dist/cjs/data-classes.cjs.map +1 -0
- package/dist/cjs/hibp.cjs +23 -0
- package/dist/cjs/hibp.cjs.map +1 -0
- package/dist/cjs/hibp.d.cts +663 -0
- package/dist/cjs/{package.json.js → package.json.cjs} +2 -2
- package/dist/cjs/package.json.cjs.map +1 -0
- package/dist/cjs/{pasteAccount.js → paste-account.cjs} +28 -22
- package/dist/cjs/paste-account.cjs.map +1 -0
- package/dist/cjs/{pwnedPasswordRange.js → pwned-password-range.cjs} +44 -25
- package/dist/cjs/pwned-password-range.cjs.map +1 -0
- package/dist/cjs/{pwnedPassword.js → pwned-password.cjs} +20 -15
- package/dist/cjs/pwned-password.cjs.map +1 -0
- package/dist/cjs/{search.js → search.cjs} +51 -49
- package/dist/cjs/search.cjs.map +1 -0
- package/dist/cjs/subscription-status.cjs +56 -0
- package/dist/cjs/subscription-status.cjs.map +1 -0
- package/dist/esm/api/fetch-polyfill.js +25 -0
- package/dist/esm/api/fetch-polyfill.js.map +1 -0
- package/dist/esm/api/haveibeenpwned/{fetchFromApi.mjs → fetch-from-api.js} +43 -38
- package/dist/esm/api/haveibeenpwned/fetch-from-api.js.map +1 -0
- package/dist/esm/api/haveibeenpwned/{responses.mjs → responses.js} +2 -7
- package/dist/esm/api/haveibeenpwned/responses.js.map +1 -0
- package/dist/esm/api/haveibeenpwned/types.js +2 -0
- package/dist/esm/api/haveibeenpwned/types.js.map +1 -0
- package/dist/esm/api/pwnedpasswords/fetch-from-api.js +51 -0
- package/dist/esm/api/pwnedpasswords/fetch-from-api.js.map +1 -0
- package/dist/esm/api/pwnedpasswords/{responses.mjs → responses.js} +2 -6
- package/dist/esm/api/pwnedpasswords/responses.js.map +1 -0
- package/dist/esm/{breach.mjs → breach.js} +14 -13
- package/dist/esm/breach.js.map +1 -0
- package/dist/esm/{breachedAccount.mjs → breached-account.js} +56 -56
- package/dist/esm/breached-account.js.map +1 -0
- package/dist/esm/{breaches.mjs → breaches.js} +29 -26
- package/dist/esm/breaches.js.map +1 -0
- package/dist/esm/{dataClasses.mjs → data-classes.js} +11 -12
- package/dist/esm/data-classes.js.map +1 -0
- package/dist/esm/hibp.d.ts +663 -0
- package/dist/esm/hibp.js +11 -0
- package/dist/{cjs → esm}/hibp.js.map +1 -1
- package/dist/esm/package.json.js +4 -0
- package/dist/{cjs → esm}/package.json.js.map +1 -1
- package/dist/esm/{pasteAccount.mjs → paste-account.js} +28 -22
- package/dist/esm/paste-account.js.map +1 -0
- package/dist/esm/{pwnedPasswordRange.mjs → pwned-password-range.js} +44 -25
- package/dist/esm/pwned-password-range.js.map +1 -0
- package/dist/esm/{pwnedPassword.mjs → pwned-password.js} +20 -15
- package/dist/esm/pwned-password.js.map +1 -0
- package/dist/esm/{search.mjs → search.js} +51 -49
- package/dist/esm/search.js.map +1 -0
- package/dist/esm/subscription-status.js +54 -0
- package/dist/esm/subscription-status.js.map +1 -0
- package/example/runkit.js +13 -14
- package/package.json +57 -64
- package/dist/cjs/api/haveibeenpwned/fetchFromApi.js.map +0 -1
- package/dist/cjs/api/haveibeenpwned/index.js +0 -6
- package/dist/cjs/api/haveibeenpwned/index.js.map +0 -1
- package/dist/cjs/api/haveibeenpwned/responses.js.map +0 -1
- package/dist/cjs/api/pwnedpasswords/fetchFromApi.js +0 -44
- package/dist/cjs/api/pwnedpasswords/fetchFromApi.js.map +0 -1
- package/dist/cjs/api/pwnedpasswords/index.js +0 -5
- package/dist/cjs/api/pwnedpasswords/index.js.map +0 -1
- package/dist/cjs/api/pwnedpasswords/responses.js.map +0 -1
- package/dist/cjs/breach.js.map +0 -1
- package/dist/cjs/breachedAccount.js.map +0 -1
- package/dist/cjs/breaches.js.map +0 -1
- package/dist/cjs/dataClasses.js.map +0 -1
- package/dist/cjs/hibp.js +0 -21
- package/dist/cjs/pasteAccount.js.map +0 -1
- package/dist/cjs/pwnedPassword.js.map +0 -1
- package/dist/cjs/pwnedPasswordRange.js.map +0 -1
- package/dist/cjs/search.js.map +0 -1
- package/dist/esm/api/haveibeenpwned/fetchFromApi.mjs.map +0 -1
- package/dist/esm/api/haveibeenpwned/index.mjs +0 -2
- package/dist/esm/api/haveibeenpwned/index.mjs.map +0 -1
- package/dist/esm/api/haveibeenpwned/responses.mjs.map +0 -1
- package/dist/esm/api/pwnedpasswords/fetchFromApi.mjs +0 -42
- package/dist/esm/api/pwnedpasswords/fetchFromApi.mjs.map +0 -1
- package/dist/esm/api/pwnedpasswords/index.mjs +0 -2
- package/dist/esm/api/pwnedpasswords/index.mjs.map +0 -1
- package/dist/esm/api/pwnedpasswords/responses.mjs.map +0 -1
- package/dist/esm/breach.mjs.map +0 -1
- package/dist/esm/breachedAccount.mjs.map +0 -1
- package/dist/esm/breaches.mjs.map +0 -1
- package/dist/esm/dataClasses.mjs.map +0 -1
- package/dist/esm/hibp.mjs +0 -10
- package/dist/esm/hibp.mjs.map +0 -1
- package/dist/esm/package.json.mjs +0 -4
- package/dist/esm/package.json.mjs.map +0 -1
- package/dist/esm/pasteAccount.mjs.map +0 -1
- package/dist/esm/pwnedPassword.mjs.map +0 -1
- package/dist/esm/pwnedPasswordRange.mjs.map +0 -1
- package/dist/esm/search.mjs.map +0 -1
- package/dist/hibp.d.ts +0 -502
|
@@ -13,11 +13,6 @@
|
|
|
13
13
|
*/
|
|
14
14
|
const emptyHeaders = /*#__PURE__*/new Map();
|
|
15
15
|
/** @internal */
|
|
16
|
-
const OK = {
|
|
17
|
-
headers: emptyHeaders,
|
|
18
|
-
status: 200
|
|
19
|
-
};
|
|
20
|
-
/** @internal */
|
|
21
16
|
const BAD_REQUEST = {
|
|
22
17
|
headers: emptyHeaders,
|
|
23
18
|
status: 400,
|
|
@@ -73,7 +68,6 @@ exports.BAD_REQUEST = BAD_REQUEST;
|
|
|
73
68
|
exports.BLOCKED = BLOCKED;
|
|
74
69
|
exports.FORBIDDEN = FORBIDDEN;
|
|
75
70
|
exports.NOT_FOUND = NOT_FOUND;
|
|
76
|
-
exports.OK = OK;
|
|
77
71
|
exports.TOO_MANY_REQUESTS = TOO_MANY_REQUESTS;
|
|
78
72
|
exports.UNAUTHORIZED = UNAUTHORIZED;
|
|
79
|
-
//# sourceMappingURL=responses.
|
|
73
|
+
//# sourceMappingURL=responses.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responses.cjs","sources":["../../../../src/api/haveibeenpwned/responses.ts"],"sourcesContent":["/**\n * Known potential responses from the remote API.\n *\n * Unfortunately, the API does not send a decent human-readable message back\n * with each response, but they are documented on the website:\n * https://haveibeenpwned.com/api/v3#ResponseCodes\n *\n * These objects simply provide a mapping between the HTTP response status code\n * and the corresponding human-readable message so we can throw a more\n * descriptive error for the consumer. (They are also leveraged in our tests.)\n */\n\nimport type { ResponseBody } from './types.js';\n\n/** @internal */\nexport interface HaveIBeenPwnedApiResponse {\n headers: Map<string, string>;\n status: number;\n statusText?: string;\n body?: ResponseBody;\n}\n\nconst emptyHeaders = new Map<string, string>();\n\n/** @internal */\nexport const BAD_REQUEST: HaveIBeenPwnedApiResponse = {\n headers: emptyHeaders,\n status: 400,\n statusText:\n 'Bad request — the account does not comply with an acceptable format.',\n};\n\n/**\n * This response has unique behavior. For some reason, the API includes an\n * object in the response body for this one, containing a human-readable\n * message. Manually populating the message here purely for use in tests.\n *\n * @internal\n */\nexport const UNAUTHORIZED: HaveIBeenPwnedApiResponse = {\n headers: emptyHeaders,\n status: 401,\n body: {\n statusCode: 401,\n message: 'Access denied due to missing hibp-api-key.',\n },\n};\n\n/** @internal */\nexport const FORBIDDEN: HaveIBeenPwnedApiResponse = {\n headers: emptyHeaders,\n status: 403,\n statusText: 'Forbidden - access denied.',\n};\n\n/** @internal */\nexport const BLOCKED: HaveIBeenPwnedApiResponse = {\n headers: new Map([['cf-ray', 'someRayId']]),\n status: 403,\n};\n\n/** @internal */\nexport const NOT_FOUND: HaveIBeenPwnedApiResponse = {\n headers: emptyHeaders,\n status: 404,\n};\n\n/**\n * This response has unique behavior. For some reason, the API includes an\n * object in the response body for this one, containing a human-readable\n * message. Manually populating the message here purely for use in tests.\n *\n * @internal\n */\nexport const TOO_MANY_REQUESTS: HaveIBeenPwnedApiResponse = {\n headers: new Map([['retry-after', '2']]),\n status: 429,\n body: {\n statusCode: 429,\n message: 'Rate limit is exceeded. Try again in 2 seconds.',\n },\n};\n"],"names":["emptyHeaders","Map","BAD_REQUEST","headers","status","statusText","UNAUTHORIZED","body","statusCode","message","FORBIDDEN","BLOCKED","NOT_FOUND","TOO_MANY_REQUESTS"],"mappings":";;AAAA;;;;;;;;;;AAUG;AAYH,MAAMA,YAAY,gBAAG,IAAIC,GAAG,EAAkB;AAE9C;AACa,MAAAC,WAAW,GAA8B;EACpDC,OAAO,EAAEH,YAAY;EACrBI,MAAM,EAAE,GAAG;EACXC,UAAU,EACR;CACF;AAEF;;;;;;AAMG;AACU,MAAAC,YAAY,GAA8B;EACrDH,OAAO,EAAEH,YAAY;EACrBI,MAAM,EAAE,GAAG;EACXG,IAAI,EAAE;IACJC,UAAU,EAAE,GAAG;IACfC,OAAO,EAAE;EACV;CACD;AAEF;AACa,MAAAC,SAAS,GAA8B;EAClDP,OAAO,EAAEH,YAAY;EACrBI,MAAM,EAAE,GAAG;EACXC,UAAU,EAAE;CACZ;AAEF;AACa,MAAAM,OAAO,GAA8B;EAChDR,OAAO,eAAE,IAAIF,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;EAC3CG,MAAM,EAAE;CACR;AAEF;AACa,MAAAQ,SAAS,GAA8B;EAClDT,OAAO,EAAEH,YAAY;EACrBI,MAAM,EAAE;CACR;AAEF;;;;;;AAMG;AACU,MAAAS,iBAAiB,GAA8B;EAC1DV,OAAO,eAAE,IAAIF,GAAG,CAAC,CAAC,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,CAAC;EACxCG,MAAM,EAAE,GAAG;EACXG,IAAI,EAAE;IACJC,UAAU,EAAE,GAAG;IACfC,OAAO,EAAE;EACV;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fetchPolyfill = /*#__PURE__*/require('../fetch-polyfill.cjs');
|
|
4
|
+
var responses = /*#__PURE__*/require('./responses.cjs');
|
|
5
|
+
fetchPolyfill.installUndiciOnNode18();
|
|
6
|
+
/**
|
|
7
|
+
* Fetches data from the supplied API endpoint.
|
|
8
|
+
*
|
|
9
|
+
* HTTP status code 200 returns plain text (data found).
|
|
10
|
+
* HTTP status code 400 throws an Error (bad request).
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
* @private
|
|
14
|
+
* @param {string} endpoint the API endpoint to query
|
|
15
|
+
* @param {object} [options] a configuration object
|
|
16
|
+
* @param {string} [options.baseUrl] a custom base URL for the
|
|
17
|
+
* pwnedpasswords.com API endpoints (default: `https://api.pwnedpasswords.com`)
|
|
18
|
+
* @param {string} [options.userAgent] a custom string to send as the User-Agent
|
|
19
|
+
* field in the request headers (default: `hibp <version>`)
|
|
20
|
+
* @param {boolean} [options.addPadding] ask the remote API to add padding to
|
|
21
|
+
* the response to obscure the password prefix (default: `false`)
|
|
22
|
+
* @param {'sha1' | 'ntlm'} [options.mode] return SHA-1 or NTLM hashes
|
|
23
|
+
* (default: `sha1`)
|
|
24
|
+
* @returns {Promise<string>} a Promise which resolves to the data resulting
|
|
25
|
+
* from the query, or rejects with an Error
|
|
26
|
+
*/
|
|
27
|
+
async function fetchFromApi(endpoint, options = {}) {
|
|
28
|
+
const {
|
|
29
|
+
baseUrl = 'https://api.pwnedpasswords.com',
|
|
30
|
+
userAgent,
|
|
31
|
+
addPadding = false,
|
|
32
|
+
mode = 'sha1'
|
|
33
|
+
} = options;
|
|
34
|
+
const config = Object.assign({}, userAgent ? {
|
|
35
|
+
headers: {
|
|
36
|
+
'User-Agent': userAgent
|
|
37
|
+
}
|
|
38
|
+
} : {}, addPadding ? {
|
|
39
|
+
headers: {
|
|
40
|
+
'Add-Padding': 'true'
|
|
41
|
+
}
|
|
42
|
+
} : {});
|
|
43
|
+
const url = `${baseUrl.replace(/\/$/g, '')}${endpoint}?mode=${mode}`;
|
|
44
|
+
const response = await fetch(url, config);
|
|
45
|
+
if (response.ok) return response.text();
|
|
46
|
+
if (response.status === responses.BAD_REQUEST.status) {
|
|
47
|
+
const text = await response.text();
|
|
48
|
+
throw new Error(text);
|
|
49
|
+
}
|
|
50
|
+
throw new Error(response.statusText);
|
|
51
|
+
}
|
|
52
|
+
exports.fetchFromApi = fetchFromApi;
|
|
53
|
+
//# sourceMappingURL=fetch-from-api.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-from-api.cjs","sources":["../../../../src/api/pwnedpasswords/fetch-from-api.ts"],"sourcesContent":["import { installUndiciOnNode18 } from '../fetch-polyfill.js';\nimport { BAD_REQUEST } from './responses.js';\n\ninstallUndiciOnNode18();\n\n/**\n * Fetches data from the supplied API endpoint.\n *\n * HTTP status code 200 returns plain text (data found).\n * HTTP status code 400 throws an Error (bad request).\n *\n * @internal\n * @private\n * @param {string} endpoint the API endpoint to query\n * @param {object} [options] a configuration object\n * @param {string} [options.baseUrl] a custom base URL for the\n * pwnedpasswords.com API endpoints (default: `https://api.pwnedpasswords.com`)\n * @param {string} [options.userAgent] a custom string to send as the User-Agent\n * field in the request headers (default: `hibp <version>`)\n * @param {boolean} [options.addPadding] ask the remote API to add padding to\n * the response to obscure the password prefix (default: `false`)\n * @param {'sha1' | 'ntlm'} [options.mode] return SHA-1 or NTLM hashes\n * (default: `sha1`)\n * @returns {Promise<string>} a Promise which resolves to the data resulting\n * from the query, or rejects with an Error\n */\nexport async function fetchFromApi(\n endpoint: string,\n options: {\n baseUrl?: string;\n userAgent?: string;\n addPadding?: boolean;\n mode?: 'sha1' | 'ntlm';\n } = {},\n): Promise<string> {\n const {\n baseUrl = 'https://api.pwnedpasswords.com',\n userAgent,\n addPadding = false,\n mode = 'sha1',\n } = options;\n\n const config = Object.assign(\n {},\n userAgent ? { headers: { 'User-Agent': userAgent } } : {},\n addPadding ? { headers: { 'Add-Padding': 'true' } } : {},\n );\n const url = `${baseUrl.replace(/\\/$/g, '')}${endpoint}?mode=${mode}`;\n const response = await fetch(url, config);\n\n if (response.ok) return response.text();\n\n if (response.status === BAD_REQUEST.status) {\n const text = await response.text();\n throw new Error(text);\n }\n\n throw new Error(response.statusText);\n}\n"],"names":["installUndiciOnNode18","fetchFromApi","endpoint","options","baseUrl","userAgent","addPadding","mode","config","Object","assign","headers","url","replace","response","fetch","ok","text","status","BAD_REQUEST","Error","statusText"],"mappings":";;;;AAGAA,aAAAA,CAAAA,qBAAqB,EAAE;AAEvB;;;;;;;;;;;;;;;;;;;;AAoBG;AACI,eAAeC,YAAYA,CAChCC,QAAgB,EAChBC,UAKI,EAAE,EAAA;EAEN,MAAM;IACJC,OAAO,GAAG,gCAAgC;IAC1CC,SAAS;IACTC,UAAU,GAAG,KAAK;IAClBC,IAAI,GAAG;EACR,CAAA,GAAGJ,OAAO;EAEX,MAAMK,MAAM,GAAGC,MAAM,CAACC,MAAM,CAC1B,CAAA,CAAE,EACFL,SAAS,GAAG;IAAEM,OAAO,EAAE;MAAE,YAAY,EAAEN;IAAW;EAAA,CAAE,GAAG,CAAE,CAAA,EACzDC,UAAU,GAAG;IAAEK,OAAO,EAAE;MAAE,aAAa,EAAE;IAAM;GAAI,GAAG,CAAA,CAAE,CACzD;EACD,MAAMC,GAAG,GAAG,GAAGR,OAAO,CAACS,OAAO,CAAC,MAAM,EAAE,EAAE,CAAI,GAAAX,QAAiB,SAAAK,MAAM;EACpE,MAAMO,QAAQ,GAAG,MAAMC,KAAK,CAACH,GAAG,EAAEJ,MAAM,CAAC;EAEzC,IAAIM,QAAQ,CAACE,EAAE,EAAE,OAAOF,QAAQ,CAACG,IAAI,EAAE;EAEvC,IAAIH,QAAQ,CAACI,MAAM,KAAKC,SAAW,CAAAA,WAAA,CAACD,MAAM,EAAE;IAC1C,MAAMD,IAAI,GAAG,MAAMH,QAAQ,CAACG,IAAI,EAAE;IAClC,MAAM,IAAIG,KAAK,CAACH,IAAI,CAAC;EACtB;EAED,MAAM,IAAIG,KAAK,CAACN,QAAQ,CAACO,UAAU,CAAC;AACtC;"}
|
|
@@ -7,14 +7,9 @@
|
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
/** @internal */
|
|
10
|
-
const OK = {
|
|
11
|
-
status: 200
|
|
12
|
-
};
|
|
13
|
-
/** @internal */
|
|
14
10
|
const BAD_REQUEST = {
|
|
15
11
|
status: 400,
|
|
16
12
|
body: 'The hash prefix was not in a valid format'
|
|
17
13
|
};
|
|
18
14
|
exports.BAD_REQUEST = BAD_REQUEST;
|
|
19
|
-
|
|
20
|
-
//# sourceMappingURL=responses.js.map
|
|
15
|
+
//# sourceMappingURL=responses.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responses.cjs","sources":["../../../../src/api/pwnedpasswords/responses.ts"],"sourcesContent":["/**\n * Known potential responses from the remote API.\n *\n * https://haveibeenpwned.com/api/v3#PwnedPasswords\n *\n */\n\n/** @internal */\nexport interface PwnedPasswordsApiResponse {\n status: number;\n body?: string;\n}\n\n/** @internal */\nexport const BAD_REQUEST: PwnedPasswordsApiResponse = {\n status: 400,\n body: 'The hash prefix was not in a valid format',\n};\n"],"names":["BAD_REQUEST","status","body"],"mappings":";;AAAA;;;;;AAKG;AAQH;AACa,MAAAA,WAAW,GAA8B;EACpDC,MAAM,EAAE,GAAG;EACXC,IAAI,EAAE;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/
|
|
3
|
+
var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetch-from-api.cjs');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* An object representing a breach.
|
|
@@ -14,13 +14,15 @@ var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetchFromApi.js');
|
|
|
14
14
|
* @property {string} ModifiedDate
|
|
15
15
|
* @property {number} PwnCount
|
|
16
16
|
* @property {string} Description
|
|
17
|
-
* @property {string} LogoPath
|
|
18
17
|
* @property {string[]} DataClasses
|
|
19
18
|
* @property {boolean} IsVerified
|
|
20
19
|
* @property {boolean} IsFabricated
|
|
21
20
|
* @property {boolean} IsSensitive
|
|
22
21
|
* @property {boolean} IsRetired
|
|
23
22
|
* @property {boolean} IsSpamList
|
|
23
|
+
* @property {boolean} IsMalware
|
|
24
|
+
* @property {boolean} IsSubscriptionFree
|
|
25
|
+
* @property {string} LogoPath
|
|
24
26
|
*/
|
|
25
27
|
/**
|
|
26
28
|
* Fetches data for a specific breach event.
|
|
@@ -36,20 +38,19 @@ var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetchFromApi.js');
|
|
|
36
38
|
* object representing a breach (or null if no breach was found), or rejects
|
|
37
39
|
* with an Error
|
|
38
40
|
* @example
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* // ...
|
|
45
|
-
* }
|
|
46
|
-
* })
|
|
47
|
-
* .catch(err => {
|
|
41
|
+
* try {
|
|
42
|
+
* const data = await breach("Adobe");
|
|
43
|
+
* if (data) {
|
|
44
|
+
* // ...
|
|
45
|
+
* } else {
|
|
48
46
|
* // ...
|
|
49
|
-
* }
|
|
47
|
+
* }
|
|
48
|
+
* } catch (err) {
|
|
49
|
+
* // ...
|
|
50
|
+
* }
|
|
50
51
|
*/
|
|
51
52
|
function breach(breachName, options = {}) {
|
|
52
53
|
return fetchFromApi.fetchFromApi(`/breach/${encodeURIComponent(breachName)}`, options);
|
|
53
54
|
}
|
|
54
55
|
exports.breach = breach;
|
|
55
|
-
//# sourceMappingURL=breach.
|
|
56
|
+
//# sourceMappingURL=breach.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breach.cjs","sources":["../../src/breach.ts"],"sourcesContent":["import type { Breach } from './api/haveibeenpwned/types.js';\nimport { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';\n\n/**\n * An object representing a breach.\n *\n * @typedef {object} Breach\n * @property {string} Name\n * @property {string} Title\n * @property {string} Domain\n * @property {string} BreachDate\n * @property {string} AddedDate\n * @property {string} ModifiedDate\n * @property {number} PwnCount\n * @property {string} Description\n * @property {string[]} DataClasses\n * @property {boolean} IsVerified\n * @property {boolean} IsFabricated\n * @property {boolean} IsSensitive\n * @property {boolean} IsRetired\n * @property {boolean} IsSpamList\n * @property {boolean} IsMalware\n * @property {boolean} IsSubscriptionFree\n * @property {string} LogoPath\n */\n\n/**\n * Fetches data for a specific breach event.\n *\n * @param {string} breachName the name of a breach in the system\n * @param {object} [options] a configuration object\n * @param {string} [options.baseUrl] a custom base URL for the\n * haveibeenpwned.com API endpoints (default:\n * `https://haveibeenpwned.com/api/v3`)\n * @param {string} [options.userAgent] a custom string to send as the User-Agent\n * field in the request headers (default: `hibp <version>`)\n * @returns {(Promise<Breach>|Promise<null>)} a Promise which resolves to an\n * object representing a breach (or null if no breach was found), or rejects\n * with an Error\n * @example\n * try {\n * const data = await breach(\"Adobe\");\n * if (data) {\n * // ...\n * } else {\n * // ...\n * }\n * } catch (err) {\n * // ...\n * }\n */\nexport function breach(\n breachName: string,\n options: {\n /**\n * a custom base URL for the haveibeenpwned.com API endpoints (default:\n * `https://haveibeenpwned.com/api/v3`)\n */\n baseUrl?: string;\n /**\n * a custom string to send as the User-Agent field in the request headers\n * (default: `hibp <version>`)\n */\n userAgent?: string;\n } = {},\n): Promise<Breach | null> {\n return fetchFromApi(\n `/breach/${encodeURIComponent(breachName)}`,\n options,\n ) as Promise<Breach | null>;\n}\n"],"names":["breach","breachName","options","fetchFromApi","encodeURIComponent"],"mappings":";;;;AAGA;;;;;;;;;;;;;;;;;;;;;AAqBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;SACaA,MAAMA,CACpBC,UAAkB,EAClBC,UAWI,EAAE,EAAA;EAEN,OAAOC,YAAAA,CAAAA,YAAY,CACjB,WAAWC,kBAAkB,CAACH,UAAU,CAAG,EAAA,EAC3CC,OAAO,CACkB;AAC7B;"}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/
|
|
3
|
+
var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetch-from-api.cjs');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Fetches breach data for a specific account.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `haveibeenpwned.com` now requires an API key from
|
|
8
|
+
* 🔑 `haveibeenpwned.com` requires an API key from
|
|
11
9
|
* https://haveibeenpwned.com/API/Key for the `breachedaccount` endpoint. The
|
|
12
10
|
* `apiKey` option here is not explicitly required, but direct requests made
|
|
13
|
-
* without it (
|
|
14
|
-
* valid API key on your behalf)
|
|
11
|
+
* without it will fail (unless you specify a `baseUrl` to a proxy that inserts
|
|
12
|
+
* a valid API key on your behalf).
|
|
15
13
|
*
|
|
16
14
|
* @param {string} account a username or email address
|
|
17
15
|
* @param {object} [options] a configuration object
|
|
@@ -32,70 +30,72 @@ var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetchFromApi.js');
|
|
|
32
30
|
* array of breach objects (or null if no breaches were found), or rejects with
|
|
33
31
|
* an Error
|
|
34
32
|
* @example
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* // ...
|
|
39
|
-
* } else {
|
|
40
|
-
* // ...
|
|
41
|
-
* }
|
|
42
|
-
* })
|
|
43
|
-
* .catch(err => {
|
|
33
|
+
* try {
|
|
34
|
+
* const data = await breachedAccount("foo", { apiKey: "my-api-key" });
|
|
35
|
+
* if (data) {
|
|
44
36
|
* // ...
|
|
45
|
-
* }
|
|
46
|
-
* @example
|
|
47
|
-
* breachedAccount('bar', {
|
|
48
|
-
* includeUnverified: false,
|
|
49
|
-
* baseUrl: 'https://my-hibp-proxy:8080',
|
|
50
|
-
* })
|
|
51
|
-
* .then(data => {
|
|
52
|
-
* if (data) {
|
|
53
|
-
* // ...
|
|
54
|
-
* } else {
|
|
55
|
-
* // ...
|
|
56
|
-
* }
|
|
57
|
-
* })
|
|
58
|
-
* .catch(err => {
|
|
37
|
+
* } else {
|
|
59
38
|
* // ...
|
|
60
|
-
* }
|
|
39
|
+
* }
|
|
40
|
+
* } catch (err) {
|
|
41
|
+
* // ...
|
|
42
|
+
* }
|
|
61
43
|
* @example
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* .then(data => {
|
|
69
|
-
* if (data) {
|
|
70
|
-
* // ...
|
|
71
|
-
* } else {
|
|
72
|
-
* // ...
|
|
73
|
-
* }
|
|
74
|
-
* })
|
|
75
|
-
* .catch(err => {
|
|
44
|
+
* try {
|
|
45
|
+
* const data = await breachedAccount("bar", {
|
|
46
|
+
* includeUnverified: false,
|
|
47
|
+
* baseUrl: "https://my-hibp-proxy:8080",
|
|
48
|
+
* });
|
|
49
|
+
* if (data) {
|
|
76
50
|
* // ...
|
|
51
|
+
* } else {
|
|
52
|
+
* // ...
|
|
53
|
+
* }
|
|
54
|
+
* } catch (err) {
|
|
55
|
+
* // ...
|
|
56
|
+
* }
|
|
57
|
+
* @example
|
|
58
|
+
* try {
|
|
59
|
+
* const data = await breachedAccount("baz", {
|
|
60
|
+
* apiKey: "my-api-key",
|
|
61
|
+
* domain: "adobe.com",
|
|
62
|
+
* truncate: false,
|
|
63
|
+
* userAgent: "my-app 1.0",
|
|
77
64
|
* });
|
|
65
|
+
* if (data) {
|
|
66
|
+
* // ...
|
|
67
|
+
* } else {
|
|
68
|
+
* // ...
|
|
69
|
+
* }
|
|
70
|
+
* } catch (err) {
|
|
71
|
+
* // ...
|
|
72
|
+
* }
|
|
78
73
|
*/
|
|
79
|
-
function breachedAccount(account, options = {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
74
|
+
function breachedAccount(account, options = {}) {
|
|
75
|
+
const {
|
|
76
|
+
apiKey,
|
|
77
|
+
domain,
|
|
78
|
+
includeUnverified = true,
|
|
79
|
+
truncate = true,
|
|
80
|
+
baseUrl,
|
|
81
|
+
userAgent
|
|
82
|
+
} = options;
|
|
83
83
|
const endpoint = `/breachedaccount/${encodeURIComponent(account)}?`;
|
|
84
84
|
const params = [];
|
|
85
|
-
if (
|
|
86
|
-
params.push(`domain=${encodeURIComponent(
|
|
85
|
+
if (domain) {
|
|
86
|
+
params.push(`domain=${encodeURIComponent(domain)}`);
|
|
87
87
|
}
|
|
88
|
-
if (
|
|
88
|
+
if (!includeUnverified) {
|
|
89
89
|
params.push('includeUnverified=false');
|
|
90
90
|
}
|
|
91
|
-
if (
|
|
91
|
+
if (!truncate) {
|
|
92
92
|
params.push('truncateResponse=false');
|
|
93
93
|
}
|
|
94
94
|
return fetchFromApi.fetchFromApi(`${endpoint}${params.join('&')}`, {
|
|
95
|
-
apiKey
|
|
96
|
-
baseUrl
|
|
97
|
-
userAgent
|
|
95
|
+
apiKey,
|
|
96
|
+
baseUrl,
|
|
97
|
+
userAgent
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
exports.breachedAccount = breachedAccount;
|
|
101
|
-
//# sourceMappingURL=
|
|
101
|
+
//# sourceMappingURL=breached-account.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breached-account.cjs","sources":["../../src/breached-account.ts"],"sourcesContent":["import type { Breach } from './api/haveibeenpwned/types.js';\nimport { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';\n\n/**\n * Fetches breach data for a specific account.\n *\n * 🔑 `haveibeenpwned.com` requires an API key from\n * https://haveibeenpwned.com/API/Key for the `breachedaccount` endpoint. The\n * `apiKey` option here is not explicitly required, but direct requests made\n * without it will fail (unless you specify a `baseUrl` to a proxy that inserts\n * a valid API key on your behalf).\n *\n * @param {string} account a username or email address\n * @param {object} [options] a configuration object\n * @param {string} [options.apiKey] an API key from\n * https://haveibeenpwned.com/API/Key (default: undefined)\n * @param {string} [options.domain] a domain by which to filter the results\n * (default: all domains)\n * @param {boolean} [options.includeUnverified] include \"unverified\" breaches in\n * the results (default: true)\n * @param {boolean} [options.truncate] truncate the results to only include\n * the name of each breach (default: true)\n * @param {string} [options.baseUrl] a custom base URL for the\n * haveibeenpwned.com API endpoints (default:\n * `https://haveibeenpwned.com/api/v3`)\n * @param {string} [options.userAgent] a custom string to send as the User-Agent\n * field in the request headers (default: `hibp <version>`)\n * @returns {(Promise<Breach[]> | Promise<null>)} a Promise which resolves to an\n * array of breach objects (or null if no breaches were found), or rejects with\n * an Error\n * @example\n * try {\n * const data = await breachedAccount(\"foo\", { apiKey: \"my-api-key\" });\n * if (data) {\n * // ...\n * } else {\n * // ...\n * }\n * } catch (err) {\n * // ...\n * }\n * @example\n * try {\n * const data = await breachedAccount(\"bar\", {\n * includeUnverified: false,\n * baseUrl: \"https://my-hibp-proxy:8080\",\n * });\n * if (data) {\n * // ...\n * } else {\n * // ...\n * }\n * } catch (err) {\n * // ...\n * }\n * @example\n * try {\n * const data = await breachedAccount(\"baz\", {\n * apiKey: \"my-api-key\",\n * domain: \"adobe.com\",\n * truncate: false,\n * userAgent: \"my-app 1.0\",\n * });\n * if (data) {\n * // ...\n * } else {\n * // ...\n * }\n * } catch (err) {\n * // ...\n * }\n */\nexport function breachedAccount(\n account: string,\n options: {\n /**\n * an API key from https://haveibeenpwned.com/API/Key (default: undefined)\n */\n apiKey?: string;\n /**\n * a domain by which to filter the results (default: all domains)\n */\n domain?: string;\n /**\n * include \"unverified\" breaches in the results (default: true)\n */\n includeUnverified?: boolean;\n /**\n * truncate the results to only include the name of each breach (default:\n * true)\n */\n truncate?: boolean;\n /**\n * a custom base URL for the haveibeenpwned.com API endpoints (default:\n * `https://haveibeenpwned.com/api/v3`)\n */\n baseUrl?: string;\n /**\n * a custom string to send as the User-Agent field in the request headers\n * (default: `hibp <version>`)\n */\n userAgent?: string;\n } = {},\n): Promise<Breach[] | null> {\n const {\n apiKey,\n domain,\n includeUnverified = true,\n truncate = true,\n baseUrl,\n userAgent,\n } = options;\n const endpoint = `/breachedaccount/${encodeURIComponent(account)}?`;\n const params: string[] = [];\n\n if (domain) {\n params.push(`domain=${encodeURIComponent(domain)}`);\n }\n\n if (!includeUnverified) {\n params.push('includeUnverified=false');\n }\n\n if (!truncate) {\n params.push('truncateResponse=false');\n }\n\n return fetchFromApi(`${endpoint}${params.join('&')}`, {\n apiKey,\n baseUrl,\n userAgent,\n }) as Promise<Breach[] | null>;\n}\n"],"names":["breachedAccount","account","options","apiKey","domain","includeUnverified","truncate","baseUrl","userAgent","endpoint","encodeURIComponent","params","push","fetchFromApi","join"],"mappings":";;;;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEG;SACaA,eAAeA,CAC7BC,OAAe,EACfC,UA4BI,EAAE,EAAA;EAEN,MAAM;IACJC,MAAM;IACNC,MAAM;IACNC,iBAAiB,GAAG,IAAI;IACxBC,QAAQ,GAAG,IAAI;IACfC,OAAO;IACPC;EACD,CAAA,GAAGN,OAAO;EACX,MAAMO,QAAQ,GAAuB,oBAAAC,kBAAkB,CAACT,OAAO,IAAI;EACnE,MAAMU,MAAM,GAAa,EAAE;EAE3B,IAAIP,MAAM,EAAE;IACVO,MAAM,CAACC,IAAI,CAAW,UAAAF,kBAAkB,CAACN,MAAM,CAAG,EAAA,CAAC;EACpD;EAED,IAAI,CAACC,iBAAiB,EAAE;IACtBM,MAAM,CAACC,IAAI,CAAC,yBAAyB,CAAC;EACvC;EAED,IAAI,CAACN,QAAQ,EAAE;IACbK,MAAM,CAACC,IAAI,CAAC,wBAAwB,CAAC;EACtC;EAED,OAAOC,YAAY,CAAAA,YAAA,CAAI,GAAAJ,QAAW,GAAAE,MAAM,CAACG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;IACpDX,MAAM;IACNI,OAAO;IACPC;EACD,CAAA,CAA6B;AAChC;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/
|
|
3
|
+
var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetch-from-api.cjs');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Fetches all breach events in the system.
|
|
@@ -16,40 +16,43 @@ var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetchFromApi.js');
|
|
|
16
16
|
* @returns {Promise<Breach[]>} a Promise which resolves to an array of breach
|
|
17
17
|
* objects (an empty array if no breaches were found), or rejects with an Error
|
|
18
18
|
* @example
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* // ...
|
|
23
|
-
* } else {
|
|
24
|
-
* // ...
|
|
25
|
-
* }
|
|
26
|
-
* })
|
|
27
|
-
* .catch(err => {
|
|
19
|
+
* try {
|
|
20
|
+
* const data = await breaches();
|
|
21
|
+
* if (data) {
|
|
28
22
|
* // ...
|
|
29
|
-
* }
|
|
23
|
+
* } else {
|
|
24
|
+
* // ...
|
|
25
|
+
* }
|
|
26
|
+
* } catch (err) {
|
|
27
|
+
* // ...
|
|
28
|
+
* }
|
|
30
29
|
* @example
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* // ...
|
|
37
|
-
* }
|
|
38
|
-
* })
|
|
39
|
-
* .catch(err => {
|
|
30
|
+
* try {
|
|
31
|
+
* const data = await breaches({ domain: "adobe.com" });
|
|
32
|
+
* if (data) {
|
|
33
|
+
* // ...
|
|
34
|
+
* } else {
|
|
40
35
|
* // ...
|
|
41
|
-
* }
|
|
36
|
+
* }
|
|
37
|
+
* } catch (err) {
|
|
38
|
+
* // ...
|
|
39
|
+
* }
|
|
42
40
|
*/
|
|
43
41
|
function breaches(options = {}) {
|
|
42
|
+
const {
|
|
43
|
+
domain,
|
|
44
|
+
baseUrl,
|
|
45
|
+
userAgent
|
|
46
|
+
} = options;
|
|
44
47
|
const endpoint = '/breaches?';
|
|
45
48
|
const params = [];
|
|
46
|
-
if (
|
|
47
|
-
params.push(`domain=${encodeURIComponent(
|
|
49
|
+
if (domain) {
|
|
50
|
+
params.push(`domain=${encodeURIComponent(domain)}`);
|
|
48
51
|
}
|
|
49
52
|
return fetchFromApi.fetchFromApi(`${endpoint}${params.join('&')}`, {
|
|
50
|
-
baseUrl
|
|
51
|
-
userAgent
|
|
53
|
+
baseUrl,
|
|
54
|
+
userAgent
|
|
52
55
|
});
|
|
53
56
|
}
|
|
54
57
|
exports.breaches = breaches;
|
|
55
|
-
//# sourceMappingURL=breaches.
|
|
58
|
+
//# sourceMappingURL=breaches.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breaches.cjs","sources":["../../src/breaches.ts"],"sourcesContent":["import type { Breach } from './api/haveibeenpwned/types.js';\nimport { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';\n\n/**\n * Fetches all breach events in the system.\n *\n * @param {object} [options] a configuration object\n * @param {string} [options.domain] a domain by which to filter the results\n * (default: all domains)\n * @param {string} [options.baseUrl] a custom base URL for the\n * haveibeenpwned.com API endpoints (default:\n * `https://haveibeenpwned.com/api/v3`)\n * @param {string} [options.userAgent] a custom string to send as the User-Agent\n * field in the request headers (default: `hibp <version>`)\n * @returns {Promise<Breach[]>} a Promise which resolves to an array of breach\n * objects (an empty array if no breaches were found), or rejects with an Error\n * @example\n * try {\n * const data = await breaches();\n * if (data) {\n * // ...\n * } else {\n * // ...\n * }\n * } catch (err) {\n * // ...\n * }\n * @example\n * try {\n * const data = await breaches({ domain: \"adobe.com\" });\n * if (data) {\n * // ...\n * } else {\n * // ...\n * }\n * } catch (err) {\n * // ...\n * }\n */\nexport function breaches(\n options: {\n /**\n * a domain by which to filter the results (default: all domains)\n */\n domain?: string;\n /**\n * a custom base URL for the haveibeenpwned.com API endpoints (default:\n * `https://haveibeenpwned.com/api/v3`)\n */\n baseUrl?: string;\n /**\n * a custom string to send as the User-Agent field in the request headers\n * (default: `hibp <version>`)\n */\n userAgent?: string;\n } = {},\n): Promise<Breach[]> {\n const { domain, baseUrl, userAgent } = options;\n const endpoint = '/breaches?';\n const params: string[] = [];\n\n if (domain) {\n params.push(`domain=${encodeURIComponent(domain)}`);\n }\n\n return fetchFromApi(`${endpoint}${params.join('&')}`, {\n baseUrl,\n userAgent,\n }) as Promise<Breach[]>;\n}\n"],"names":["breaches","options","domain","baseUrl","userAgent","endpoint","params","push","encodeURIComponent","fetchFromApi","join"],"mappings":";;;;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCG;AACa,SAAAA,QAAQA,CACtBC,OAAA,GAeI,EAAE,EAAA;EAEN,MAAM;IAAEC,MAAM;IAAEC,OAAO;IAAEC;EAAS,CAAE,GAAGH,OAAO;EAC9C,MAAMI,QAAQ,GAAG,YAAY;EAC7B,MAAMC,MAAM,GAAa,EAAE;EAE3B,IAAIJ,MAAM,EAAE;IACVI,MAAM,CAACC,IAAI,CAAW,UAAAC,kBAAkB,CAACN,MAAM,CAAG,EAAA,CAAC;EACpD;EAED,OAAOO,YAAY,CAAAA,YAAA,CAAI,GAAAJ,QAAW,GAAAC,MAAM,CAACI,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;IACpDP,OAAO;IACPC;EACD,CAAA,CAAsB;AACzB;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/
|
|
3
|
+
var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetch-from-api.cjs');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Fetches all data classes in the system.
|
|
@@ -15,20 +15,19 @@ var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetchFromApi.js');
|
|
|
15
15
|
* array of strings (or null if no data classes were found), or rejects with an
|
|
16
16
|
* Error
|
|
17
17
|
* @example
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* // ...
|
|
22
|
-
* } else {
|
|
23
|
-
* // ...
|
|
24
|
-
* }
|
|
25
|
-
* })
|
|
26
|
-
* .catch(err => {
|
|
18
|
+
* try {
|
|
19
|
+
* const data = await dataClasses();
|
|
20
|
+
* if (data) {
|
|
27
21
|
* // ...
|
|
28
|
-
* }
|
|
22
|
+
* } else {
|
|
23
|
+
* // ...
|
|
24
|
+
* }
|
|
25
|
+
* } catch (err) {
|
|
26
|
+
* // ...
|
|
27
|
+
* }
|
|
29
28
|
*/
|
|
30
29
|
function dataClasses(options = {}) {
|
|
31
30
|
return fetchFromApi.fetchFromApi('/dataclasses', options);
|
|
32
31
|
}
|
|
33
32
|
exports.dataClasses = dataClasses;
|
|
34
|
-
//# sourceMappingURL=
|
|
33
|
+
//# sourceMappingURL=data-classes.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-classes.cjs","sources":["../../src/data-classes.ts"],"sourcesContent":["import { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';\n\n/**\n * Fetches all data classes in the system.\n *\n * @param {object} [options] a configuration object\n * @param {string} [options.baseUrl] a custom base URL for the\n * haveibeenpwned.com API endpoints (default:\n * `https://haveibeenpwned.com/api/v3`)\n * @param {string} [options.userAgent] a custom string to send as the User-Agent\n * field in the request headers (default: `hibp <version>`)\n * @returns {(Promise<string[]> | Promise<null>)} a Promise which resolves to an\n * array of strings (or null if no data classes were found), or rejects with an\n * Error\n * @example\n * try {\n * const data = await dataClasses();\n * if (data) {\n * // ...\n * } else {\n * // ...\n * }\n * } catch (err) {\n * // ...\n * }\n */\nexport function dataClasses(\n options: {\n /**\n * a custom base URL for the haveibeenpwned.com API endpoints (default:\n * `https://haveibeenpwned.com/api/v3`)\n */\n baseUrl?: string;\n /**\n * a custom string to send as the User-Agent field in the request headers\n * (default: `hibp <version>`)\n */\n userAgent?: string;\n } = {},\n): Promise<string[] | null> {\n return fetchFromApi('/dataclasses', options) as Promise<string[] | null>;\n}\n"],"names":["dataClasses","options","fetchFromApi"],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AACa,SAAAA,WAAWA,CACzBC,OAAA,GAWI,EAAE,EAAA;EAEN,OAAOC,YAAY,CAAAA,YAAA,CAAC,cAAc,EAAED,OAAO,CAA6B;AAC1E;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetch-from-api.cjs');
|
|
4
|
+
var breach = /*#__PURE__*/require('./breach.cjs');
|
|
5
|
+
var breachedAccount = /*#__PURE__*/require('./breached-account.cjs');
|
|
6
|
+
var breaches = /*#__PURE__*/require('./breaches.cjs');
|
|
7
|
+
var dataClasses = /*#__PURE__*/require('./data-classes.cjs');
|
|
8
|
+
var pasteAccount = /*#__PURE__*/require('./paste-account.cjs');
|
|
9
|
+
var pwnedPassword = /*#__PURE__*/require('./pwned-password.cjs');
|
|
10
|
+
var pwnedPasswordRange = /*#__PURE__*/require('./pwned-password-range.cjs');
|
|
11
|
+
var search = /*#__PURE__*/require('./search.cjs');
|
|
12
|
+
var subscriptionStatus = /*#__PURE__*/require('./subscription-status.cjs');
|
|
13
|
+
exports.RateLimitError = fetchFromApi.RateLimitError;
|
|
14
|
+
exports.breach = breach.breach;
|
|
15
|
+
exports.breachedAccount = breachedAccount.breachedAccount;
|
|
16
|
+
exports.breaches = breaches.breaches;
|
|
17
|
+
exports.dataClasses = dataClasses.dataClasses;
|
|
18
|
+
exports.pasteAccount = pasteAccount.pasteAccount;
|
|
19
|
+
exports.pwnedPassword = pwnedPassword.pwnedPassword;
|
|
20
|
+
exports.pwnedPasswordRange = pwnedPasswordRange.pwnedPasswordRange;
|
|
21
|
+
exports.search = search.search;
|
|
22
|
+
exports.subscriptionStatus = subscriptionStatus.subscriptionStatus;
|
|
23
|
+
//# sourceMappingURL=hibp.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hibp.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
|