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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/API.md +275 -198
  2. package/CHANGELOG.md +70 -0
  3. package/README.md +20 -22
  4. package/dist/browser/hibp.module.js +1 -1
  5. package/dist/browser/hibp.module.js.map +1 -1
  6. package/dist/browser/hibp.umd.js +1 -1
  7. package/dist/browser/hibp.umd.js.map +1 -1
  8. package/dist/cjs/api/fetch-polyfill.cjs +28 -0
  9. package/dist/cjs/api/fetch-polyfill.cjs.map +1 -0
  10. package/dist/cjs/api/haveibeenpwned/{fetchFromApi.js → fetch-from-api.cjs} +43 -38
  11. package/dist/cjs/api/haveibeenpwned/fetch-from-api.cjs.map +1 -0
  12. package/dist/cjs/api/haveibeenpwned/{responses.js → responses.cjs} +1 -7
  13. package/dist/cjs/api/haveibeenpwned/responses.cjs.map +1 -0
  14. package/dist/cjs/api/haveibeenpwned/types.cjs +2 -0
  15. package/dist/cjs/api/haveibeenpwned/types.cjs.map +1 -0
  16. package/dist/cjs/api/pwnedpasswords/fetch-from-api.cjs +53 -0
  17. package/dist/cjs/api/pwnedpasswords/fetch-from-api.cjs.map +1 -0
  18. package/dist/cjs/api/pwnedpasswords/{responses.js → responses.cjs} +1 -6
  19. package/dist/cjs/api/pwnedpasswords/responses.cjs.map +1 -0
  20. package/dist/cjs/{breach.js → breach.cjs} +14 -13
  21. package/dist/cjs/breach.cjs.map +1 -0
  22. package/dist/cjs/{breachedAccount.js → breached-account.cjs} +56 -56
  23. package/dist/cjs/breached-account.cjs.map +1 -0
  24. package/dist/cjs/{breaches.js → breaches.cjs} +29 -26
  25. package/dist/cjs/breaches.cjs.map +1 -0
  26. package/dist/cjs/{dataClasses.js → data-classes.cjs} +11 -12
  27. package/dist/cjs/data-classes.cjs.map +1 -0
  28. package/dist/cjs/hibp.cjs +23 -0
  29. package/dist/cjs/hibp.cjs.map +1 -0
  30. package/dist/cjs/hibp.d.cts +663 -0
  31. package/dist/cjs/{package.json.js → package.json.cjs} +2 -2
  32. package/dist/cjs/package.json.cjs.map +1 -0
  33. package/dist/cjs/{pasteAccount.js → paste-account.cjs} +28 -22
  34. package/dist/cjs/paste-account.cjs.map +1 -0
  35. package/dist/cjs/{pwnedPasswordRange.js → pwned-password-range.cjs} +44 -25
  36. package/dist/cjs/pwned-password-range.cjs.map +1 -0
  37. package/dist/cjs/{pwnedPassword.js → pwned-password.cjs} +20 -15
  38. package/dist/cjs/pwned-password.cjs.map +1 -0
  39. package/dist/cjs/{search.js → search.cjs} +51 -49
  40. package/dist/cjs/search.cjs.map +1 -0
  41. package/dist/cjs/subscription-status.cjs +56 -0
  42. package/dist/cjs/subscription-status.cjs.map +1 -0
  43. package/dist/esm/api/fetch-polyfill.js +26 -0
  44. package/dist/esm/api/fetch-polyfill.js.map +1 -0
  45. package/dist/esm/api/haveibeenpwned/{fetchFromApi.mjs → fetch-from-api.js} +43 -38
  46. package/dist/esm/api/haveibeenpwned/fetch-from-api.js.map +1 -0
  47. package/dist/esm/api/haveibeenpwned/{responses.mjs → responses.js} +2 -7
  48. package/dist/esm/api/haveibeenpwned/responses.js.map +1 -0
  49. package/dist/esm/api/haveibeenpwned/types.js +2 -0
  50. package/dist/esm/api/haveibeenpwned/types.js.map +1 -0
  51. package/dist/esm/api/pwnedpasswords/fetch-from-api.js +51 -0
  52. package/dist/esm/api/pwnedpasswords/fetch-from-api.js.map +1 -0
  53. package/dist/esm/api/pwnedpasswords/{responses.mjs → responses.js} +2 -6
  54. package/dist/esm/api/pwnedpasswords/responses.js.map +1 -0
  55. package/dist/esm/{breach.mjs → breach.js} +14 -13
  56. package/dist/esm/breach.js.map +1 -0
  57. package/dist/esm/{breachedAccount.mjs → breached-account.js} +56 -56
  58. package/dist/esm/breached-account.js.map +1 -0
  59. package/dist/esm/{breaches.mjs → breaches.js} +29 -26
  60. package/dist/esm/breaches.js.map +1 -0
  61. package/dist/esm/{dataClasses.mjs → data-classes.js} +11 -12
  62. package/dist/esm/data-classes.js.map +1 -0
  63. package/dist/esm/hibp.d.ts +663 -0
  64. package/dist/esm/hibp.js +11 -0
  65. package/dist/{cjs → esm}/hibp.js.map +1 -1
  66. package/dist/esm/package.json.js +4 -0
  67. package/dist/{cjs → esm}/package.json.js.map +1 -1
  68. package/dist/esm/{pasteAccount.mjs → paste-account.js} +28 -22
  69. package/dist/esm/paste-account.js.map +1 -0
  70. package/dist/esm/{pwnedPasswordRange.mjs → pwned-password-range.js} +44 -25
  71. package/dist/esm/pwned-password-range.js.map +1 -0
  72. package/dist/esm/{pwnedPassword.mjs → pwned-password.js} +20 -15
  73. package/dist/esm/pwned-password.js.map +1 -0
  74. package/dist/esm/{search.mjs → search.js} +51 -49
  75. package/dist/esm/search.js.map +1 -0
  76. package/dist/esm/subscription-status.js +54 -0
  77. package/dist/esm/subscription-status.js.map +1 -0
  78. package/example/runkit.js +13 -14
  79. package/package.json +57 -64
  80. package/dist/cjs/api/haveibeenpwned/fetchFromApi.js.map +0 -1
  81. package/dist/cjs/api/haveibeenpwned/index.js +0 -6
  82. package/dist/cjs/api/haveibeenpwned/index.js.map +0 -1
  83. package/dist/cjs/api/haveibeenpwned/responses.js.map +0 -1
  84. package/dist/cjs/api/pwnedpasswords/fetchFromApi.js +0 -44
  85. package/dist/cjs/api/pwnedpasswords/fetchFromApi.js.map +0 -1
  86. package/dist/cjs/api/pwnedpasswords/index.js +0 -5
  87. package/dist/cjs/api/pwnedpasswords/index.js.map +0 -1
  88. package/dist/cjs/api/pwnedpasswords/responses.js.map +0 -1
  89. package/dist/cjs/breach.js.map +0 -1
  90. package/dist/cjs/breachedAccount.js.map +0 -1
  91. package/dist/cjs/breaches.js.map +0 -1
  92. package/dist/cjs/dataClasses.js.map +0 -1
  93. package/dist/cjs/hibp.js +0 -21
  94. package/dist/cjs/pasteAccount.js.map +0 -1
  95. package/dist/cjs/pwnedPassword.js.map +0 -1
  96. package/dist/cjs/pwnedPasswordRange.js.map +0 -1
  97. package/dist/cjs/search.js.map +0 -1
  98. package/dist/esm/api/haveibeenpwned/fetchFromApi.mjs.map +0 -1
  99. package/dist/esm/api/haveibeenpwned/index.mjs +0 -2
  100. package/dist/esm/api/haveibeenpwned/index.mjs.map +0 -1
  101. package/dist/esm/api/haveibeenpwned/responses.mjs.map +0 -1
  102. package/dist/esm/api/pwnedpasswords/fetchFromApi.mjs +0 -42
  103. package/dist/esm/api/pwnedpasswords/fetchFromApi.mjs.map +0 -1
  104. package/dist/esm/api/pwnedpasswords/index.mjs +0 -2
  105. package/dist/esm/api/pwnedpasswords/index.mjs.map +0 -1
  106. package/dist/esm/api/pwnedpasswords/responses.mjs.map +0 -1
  107. package/dist/esm/breach.mjs.map +0 -1
  108. package/dist/esm/breachedAccount.mjs.map +0 -1
  109. package/dist/esm/breaches.mjs.map +0 -1
  110. package/dist/esm/dataClasses.mjs.map +0 -1
  111. package/dist/esm/hibp.mjs +0 -10
  112. package/dist/esm/hibp.mjs.map +0 -1
  113. package/dist/esm/package.json.mjs +0 -4
  114. package/dist/esm/package.json.mjs.map +0 -1
  115. package/dist/esm/pasteAccount.mjs.map +0 -1
  116. package/dist/esm/pwnedPassword.mjs.map +0 -1
  117. package/dist/esm/pwnedPasswordRange.mjs.map +0 -1
  118. package/dist/esm/search.mjs.map +0 -1
  119. package/dist/hibp.d.ts +0 -502
@@ -1,4 +1,4 @@
1
- import { fetchFromApi } from './api/haveibeenpwned/fetchFromApi.mjs';
1
+ import { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';
2
2
 
3
3
  /**
4
4
  * An object representing a paste.
@@ -13,18 +13,16 @@ import { fetchFromApi } from './api/haveibeenpwned/fetchFromApi.mjs';
13
13
  /**
14
14
  * Fetches paste data for a specific account (email address).
15
15
  *
16
- * ***Warning (July 18, 2019):***
17
- *
18
- * `haveibeenpwned.com` now requires an API key from
16
+ * 🔑 `haveibeenpwned.com` requires an API key from
19
17
  * https://haveibeenpwned.com/API/Key for the `pasteaccount` endpoint. The
20
18
  * `apiKey` option here is not explicitly required, but direct requests made
21
- * without it (that is, without specifying a `baseUrl` to a proxy that inserts a
22
- * valid API key on your behalf) will fail.
19
+ * without it will fail (unless you specify a `baseUrl` to a proxy that inserts
20
+ * a valid API key on your behalf).
23
21
  *
24
22
  * @param {string} email the email address to query
25
23
  * @param {object} [options] a configuration object
26
24
  * @param {string} [options.apiKey] an API key from
27
- * https://haveibeenpwned.com/API/Key
25
+ * https://haveibeenpwned.com/API/Key (default: undefined)
28
26
  * @param {string} [options.baseUrl] a custom base URL for the
29
27
  * haveibeenpwned.com API endpoints (default:
30
28
  * `https://haveibeenpwned.com/api/v3`)
@@ -34,24 +32,32 @@ import { fetchFromApi } from './api/haveibeenpwned/fetchFromApi.mjs';
34
32
  * array of paste objects (or null if no pastes were found), or rejects with an
35
33
  * Error
36
34
  * @example
37
- * pasteAccount('foo@bar.com', { apiKey: 'my-api-key' })
38
- * .then(data => {
39
- * if (data) {
40
- * // ...
41
- * } else {
42
- * // ...
43
- * }
44
- * })
45
- * .catch(err => {
35
+ * try {
36
+ * const data = await pasteAccount("foo@bar.com", { apiKey: "my-api-key" });
37
+ * if (data) {
38
+ * // ...
39
+ * } else {
46
40
  * // ...
41
+ * }
42
+ * } catch (err) {
43
+ * // ...
44
+ * }
45
+ * @example
46
+ * try {
47
+ * const data = await pasteAccount("foo@bar.com", {
48
+ * baseUrl: "https://my-hibp-proxy:8080",
47
49
  * });
50
+ * if (data) {
51
+ * // ...
52
+ * } else {
53
+ * // ...
54
+ * }
55
+ * } catch (err) {
56
+ * // ...
57
+ * }
48
58
  */
49
59
  function pasteAccount(email, options = {}) {
50
- return fetchFromApi(`/pasteaccount/${encodeURIComponent(email)}`, {
51
- apiKey: options.apiKey,
52
- baseUrl: options.baseUrl,
53
- userAgent: options.userAgent
54
- });
60
+ return fetchFromApi(`/pasteaccount/${encodeURIComponent(email)}`, options);
55
61
  }
56
62
  export { pasteAccount };
57
- //# sourceMappingURL=pasteAccount.mjs.map
63
+ //# sourceMappingURL=paste-account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paste-account.js","sources":["../../src/paste-account.ts"],"sourcesContent":["import type { Paste } from './api/haveibeenpwned/types.js';\nimport { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';\n\n/**\n * An object representing a paste.\n *\n * @typedef {object} Paste\n * @property {string} Id\n * @property {string} Source\n * @property {string} Title\n * @property {string} Date\n * @property {number} EmailCount\n */\n\n/**\n * Fetches paste data for a specific account (email address).\n *\n * 🔑 `haveibeenpwned.com` requires an API key from\n * https://haveibeenpwned.com/API/Key for the `pasteaccount` 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} email the email address to query\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.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<Paste[]> | Promise<null>)} a Promise which resolves to an\n * array of paste objects (or null if no pastes were found), or rejects with an\n * Error\n * @example\n * try {\n * const data = await pasteAccount(\"foo@bar.com\", { 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 pasteAccount(\"foo@bar.com\", {\n * baseUrl: \"https://my-hibp-proxy:8080\",\n * });\n * if (data) {\n * // ...\n * } else {\n * // ...\n * }\n * } catch (err) {\n * // ...\n * }\n */\nexport function pasteAccount(\n email: string,\n options: {\n /**\n * an API key from https://haveibeenpwned.com/API/Key (default: undefined)\n */\n apiKey?: 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<Paste[] | null> {\n return fetchFromApi(\n `/pasteaccount/${encodeURIComponent(email)}`,\n options,\n ) as Promise<Paste[] | null>;\n}\n"],"names":["pasteAccount","email","options","fetchFromApi","encodeURIComponent"],"mappings":";;AAGA;;;;;;;;;AASG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CG;SACaA,YAAYA,CAC1BC,KAAa,EACbC,UAeI,EAAE,EAAA;EAEN,OAAOC,YAAY,CACjB,iBAAiBC,kBAAkB,CAACH,KAAK,CAAG,EAAA,EAC5CC,OAAO,CACmB;AAC9B;"}
@@ -1,4 +1,4 @@
1
- import { fetchFromApi } from './api/pwnedpasswords/fetchFromApi.mjs';
1
+ import { fetchFromApi } from './api/pwnedpasswords/fetch-from-api.js';
2
2
 
3
3
  /**
4
4
  * An object mapping an exposed password hash suffix (corresponding to a given
@@ -7,7 +7,8 @@ import { fetchFromApi } from './api/pwnedpasswords/fetchFromApi.mjs';
7
7
  * @typedef {Object.<string, number>} PwnedPasswordSuffixes
8
8
  */
9
9
  /**
10
- * Fetches the SHA-1 hash suffixes for the given 5-character SHA-1 hash prefix.
10
+ * Fetches the SHA-1 or NTLM hash suffixes for the given 5-character hash
11
+ * prefix.
11
12
  *
12
13
  * When a password hash with the same first 5 characters is found in the Pwned
13
14
  * Passwords repository, the API will respond with an HTTP 200 and include the
@@ -15,9 +16,13 @@ import { fetchFromApi } from './api/pwnedpasswords/fetchFromApi.mjs';
15
16
  * of how many times it appears in the data set. This function parses the
16
17
  * response and returns a more structured format.
17
18
  *
18
- * @param {string} prefix the first 5 characters of a SHA-1 password hash (case
19
+ * @param {string} prefix the first 5 characters of a password hash (case
19
20
  * insensitive)
20
21
  * @param {object} [options] a configuration object
22
+ * @param {boolean} [options.addPadding] ask the remote API to add padding to
23
+ * the response to obscure the password prefix (default: `false`)
24
+ * @param {'sha1' | 'ntlm'} [options.mode] return SHA-1 or NTLM hashes
25
+ * (default: `sha1`)
21
26
  * @param {string} [options.baseUrl] a custom base URL for the
22
27
  * pwnedpasswords.com API endpoints (default: `https://api.pwnedpasswords.com`)
23
28
  * @param {string} [options.userAgent] a custom string to send as the User-Agent
@@ -28,34 +33,48 @@ import { fetchFromApi } from './api/pwnedpasswords/fetchFromApi.mjs';
28
33
  * password data set, or rejects with an Error
29
34
  *
30
35
  * @example
31
- * pwnedPasswordRange('5BAA6')
32
- * .then(results => {
33
- * // results will have the following shape:
34
- * // {
35
- * // "003D68EB55068C33ACE09247EE4C639306B": 3,
36
- * // "012C192B2F16F82EA0EB9EF18D9D539B0DD": 1,
37
- * // ...
38
- * // }
39
- * })
36
+ * try {
37
+ * const results = await pwnedPasswordRange("5BAA6");
38
+ * // results will have the following shape:
39
+ * // {
40
+ * // "003D68EB55068C33ACE09247EE4C639306B": 3,
41
+ * // "012C192B2F16F82EA0EB9EF18D9D539B0DD": 1,
42
+ * // ...
43
+ * // }
44
+ * } catch (err) {
45
+ * // ...
46
+ * }
40
47
  * @example
41
- * const suffix = '1E4C9B93F3F0682250B6CF8331B7EE68FD8';
42
- * pwnedPasswordRange('5BAA6')
43
- * .then(results => (results[suffix] || 0))
44
- * .catch(err => {
45
- * // ...
46
- * });
48
+ * try {
49
+ * const suffix = "1E4C9B93F3F0682250B6CF8331B7EE68FD8";
50
+ * const results = await pwnedPasswordRange("5BAA6");
51
+ * const numPwns = results[suffix] || 0;
52
+ * } catch (err) {
53
+ * // ...
54
+ * }
47
55
  * @see https://haveibeenpwned.com/api/v3#SearchingPwnedPasswordsByRange
48
56
  */
49
- function pwnedPasswordRange(prefix, options = {}) {
50
- return fetchFromApi(`/range/${encodeURIComponent(prefix)}`, options)
57
+ async function pwnedPasswordRange(prefix, options = {}) {
58
+ const {
59
+ baseUrl,
60
+ userAgent,
61
+ addPadding = false,
62
+ mode = 'sha1'
63
+ } = options;
64
+ const data = await fetchFromApi(`/range/${encodeURIComponent(prefix)}`, {
65
+ baseUrl,
66
+ userAgent,
67
+ addPadding,
68
+ mode
69
+ });
51
70
  // create array from lines of text in response body
52
- .then(data => data.split('\n').filter(Boolean))
71
+ const results = data.split('\n').filter(Boolean);
53
72
  // convert into an object mapping suffix to count for each line
54
- .then(results => results.reduce((acc, row) => {
73
+ return results.reduce((acc, row) => {
55
74
  const [suffix, countString] = row.split(':');
56
- acc[suffix] = parseInt(countString, 10);
75
+ acc[suffix] = Number.parseInt(countString, 10);
57
76
  return acc;
58
- }, {}));
77
+ }, {});
59
78
  }
60
79
  export { pwnedPasswordRange };
61
- //# sourceMappingURL=pwnedPasswordRange.mjs.map
80
+ //# sourceMappingURL=pwned-password-range.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pwned-password-range.js","sources":["../../src/pwned-password-range.ts"],"sourcesContent":["import { fetchFromApi } from './api/pwnedpasswords/fetch-from-api.js';\n\nexport type PwnedPasswordSuffixes = Record<string, number>;\n\n/**\n * An object mapping an exposed password hash suffix (corresponding to a given\n * hash prefix) to how many times it occurred in the Pwned Passwords repository.\n *\n * @typedef {Object.<string, number>} PwnedPasswordSuffixes\n */\n\n/**\n * Fetches the SHA-1 or NTLM hash suffixes for the given 5-character hash\n * prefix.\n *\n * When a password hash with the same first 5 characters is found in the Pwned\n * Passwords repository, the API will respond with an HTTP 200 and include the\n * suffix of every hash beginning with the specified prefix, followed by a count\n * of how many times it appears in the data set. This function parses the\n * response and returns a more structured format.\n *\n * @param {string} prefix the first 5 characters of a password hash (case\n * insensitive)\n * @param {object} [options] a configuration object\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 * @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 * @returns {Promise<PwnedPasswordSuffixes>} a Promise which resolves to an\n * object mapping the `suffix` that when matched with the prefix composes the\n * complete hash, to the `count` of how many times it appears in the breached\n * password data set, or rejects with an Error\n *\n * @example\n * try {\n * const results = await pwnedPasswordRange(\"5BAA6\");\n * // results will have the following shape:\n * // {\n * // \"003D68EB55068C33ACE09247EE4C639306B\": 3,\n * // \"012C192B2F16F82EA0EB9EF18D9D539B0DD\": 1,\n * // ...\n * // }\n * } catch (err) {\n * // ...\n * }\n * @example\n * try {\n * const suffix = \"1E4C9B93F3F0682250B6CF8331B7EE68FD8\";\n * const results = await pwnedPasswordRange(\"5BAA6\");\n * const numPwns = results[suffix] || 0;\n * } catch (err) {\n * // ...\n * }\n * @see https://haveibeenpwned.com/api/v3#SearchingPwnedPasswordsByRange\n */\nexport async function pwnedPasswordRange(\n prefix: string,\n options: {\n /**\n * ask the remote API to add padding to the response to obscure the password\n * prefix (default: `false`)\n */\n addPadding?: boolean;\n /**\n * return SHA-1 or NTLM hashes (default: `sha1`)\n */\n mode?: 'sha1' | 'ntlm';\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<PwnedPasswordSuffixes> {\n const { baseUrl, userAgent, addPadding = false, mode = 'sha1' } = options;\n\n const data = await fetchFromApi(`/range/${encodeURIComponent(prefix)}`, {\n baseUrl,\n userAgent,\n addPadding,\n mode,\n });\n\n // create array from lines of text in response body\n const results = data.split('\\n').filter(Boolean);\n\n // convert into an object mapping suffix to count for each line\n return results.reduce<PwnedPasswordSuffixes>((acc, row) => {\n const [suffix, countString] = row.split(':');\n acc[suffix] = Number.parseInt(countString, 10);\n return acc;\n }, {});\n}\n"],"names":["pwnedPasswordRange","prefix","options","baseUrl","userAgent","addPadding","mode","data","fetchFromApi","encodeURIComponent","results","split","filter","Boolean","reduce","acc","row","suffix","countString","Number","parseInt"],"mappings":";;AAIA;;;;;AAKG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CG;AACI,eAAeA,kBAAkBA,CACtCC,MAAc,EACdC,UAoBI,EAAE,EAAA;EAEN,MAAM;IAAEC,OAAO;IAAEC,SAAS;IAAEC,UAAU,GAAG,KAAK;IAAEC,IAAI,GAAG;EAAQ,CAAA,GAAGJ,OAAO;EAEzE,MAAMK,IAAI,GAAG,MAAMC,YAAY,CAAW,UAAAC,kBAAkB,CAACR,MAAM,CAAC,EAAE,EAAE;IACtEE,OAAO;IACPC,SAAS;IACTC,UAAU;IACVC;EACD,CAAA,CAAC;;EAGF,MAAMI,OAAO,GAAGH,IAAI,CAACI,KAAK,CAAC,IAAI,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC;;EAGhD,OAAOH,OAAO,CAACI,MAAM,CAAwB,CAACC,GAAG,EAAEC,GAAG,KAAI;IACxD,MAAM,CAACC,MAAM,EAAEC,WAAW,CAAC,GAAGF,GAAG,CAACL,KAAK,CAAC,GAAG,CAAC;IAC5CI,GAAG,CAACE,MAAM,CAAC,GAAGE,MAAM,CAACC,QAAQ,CAACF,WAAW,EAAE,EAAE,CAAC;IAC9C,OAAOH,GAAG;EACX,CAAA,EAAE,CAAE,CAAA,CAAC;AACR;"}
@@ -1,5 +1,5 @@
1
1
  import JSSHA from 'jssha/dist/sha1';
2
- import { pwnedPasswordRange } from './pwnedPasswordRange.mjs';
2
+ import { pwnedPasswordRange } from './pwned-password-range.js';
3
3
 
4
4
  /**
5
5
  * Fetches the number of times the the given password has been exposed in a
@@ -8,6 +8,8 @@ import { pwnedPasswordRange } from './pwnedPasswordRange.mjs';
8
8
  *
9
9
  * @param {string} password a password in plain text
10
10
  * @param {object} [options] a configuration object
11
+ * @param {boolean} [options.addPadding] ask the remote API to add padding to
12
+ * the response to obscure the password prefix (default: `false`)
11
13
  * @param {string} [options.baseUrl] a custom base URL for the
12
14
  * pwnedpasswords.com API endpoints (default: `https://api.pwnedpasswords.com`)
13
15
  * @param {string} [options.userAgent] a custom string to send as the User-Agent
@@ -15,21 +17,22 @@ import { pwnedPasswordRange } from './pwnedPasswordRange.mjs';
15
17
  * @returns {Promise<number>} a Promise which resolves to the number of times
16
18
  * the password has been exposed in a breach, or rejects with an Error
17
19
  * @example
18
- * pwnedPassword('f00b4r')
19
- * .then(numPwns => {
20
- * // truthy check or numeric condition
21
- * if (numPwns) {
22
- * // ...
23
- * } else {
24
- * // ...
25
- * }
26
- * })
27
- * .catch(err => {
20
+ * try {
21
+ * const numPwns = await pwnedPassword("f00b4r");
22
+ * // truthy check or numeric condition
23
+ * if (numPwns) {
28
24
  * // ...
29
- * });
25
+ * } else {
26
+ * // ...
27
+ * }
28
+ * } catch (err) {
29
+ * // ...
30
+ * }
30
31
  * @see https://haveibeenpwned.com/api/v3#PwnedPasswords
31
32
  */
32
- function pwnedPassword(password, options = {}) {
33
+ async function pwnedPassword(password, options = {}) {
34
+ /* eslint-disable */
35
+ // @ts-expect-error: JSSHA types are busted
33
36
  const sha1 = new JSSHA('SHA-1', 'TEXT');
34
37
  sha1.update(password);
35
38
  const hash = sha1.getHash('HEX', {
@@ -37,7 +40,9 @@ function pwnedPassword(password, options = {}) {
37
40
  });
38
41
  const prefix = hash.slice(0, 5);
39
42
  const suffix = hash.slice(5);
40
- return pwnedPasswordRange(prefix, options).then(range => range[suffix] || 0);
43
+ const range = await pwnedPasswordRange(prefix, options);
44
+ return range[suffix] || 0;
45
+ /* eslint-enable */
41
46
  }
42
47
  export { pwnedPassword };
43
- //# sourceMappingURL=pwnedPassword.mjs.map
48
+ //# sourceMappingURL=pwned-password.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pwned-password.js","sources":["../../src/pwned-password.ts"],"sourcesContent":["import JSSHA from 'jssha/dist/sha1';\nimport { pwnedPasswordRange } from './pwned-password-range.js';\n\n/**\n * Fetches the number of times the the given password has been exposed in a\n * breach (0 indicating no exposure). The password is given in plain text, but\n * only the first 5 characters of its SHA-1 hash will be submitted to the API.\n *\n * @param {string} password a password in plain text\n * @param {object} [options] a configuration object\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 {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 * @returns {Promise<number>} a Promise which resolves to the number of times\n * the password has been exposed in a breach, or rejects with an Error\n * @example\n * try {\n * const numPwns = await pwnedPassword(\"f00b4r\");\n * // truthy check or numeric condition\n * if (numPwns) {\n * // ...\n * } else {\n * // ...\n * }\n * } catch (err) {\n * // ...\n * }\n * @see https://haveibeenpwned.com/api/v3#PwnedPasswords\n */\nexport async function pwnedPassword(\n password: string,\n options: {\n /**\n * ask the remote API to add padding to the response to obscure the password\n * prefix (default: `false`)\n */\n addPadding?: 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<number> {\n /* eslint-disable */\n // @ts-expect-error: JSSHA types are busted\n const sha1 = new JSSHA('SHA-1', 'TEXT');\n sha1.update(password);\n const hash = sha1.getHash('HEX', { outputUpper: true });\n const prefix = hash.slice(0, 5);\n const suffix = hash.slice(5);\n\n const range = await pwnedPasswordRange(prefix, options);\n return range[suffix] || 0;\n /* eslint-enable */\n}\n"],"names":["pwnedPassword","password","options","sha1","JSSHA","update","hash","getHash","outputUpper","prefix","slice","suffix","range","pwnedPasswordRange"],"mappings":";;;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;AACI,eAAeA,aAAaA,CACjCC,QAAgB,EAChBC,UAgBI,EAAE,EAAA;;;EAIN,MAAMC,IAAI,GAAG,IAAIC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC;EACvCD,IAAI,CAACE,MAAM,CAACJ,QAAQ,CAAC;EACrB,MAAMK,IAAI,GAAGH,IAAI,CAACI,OAAO,CAAC,KAAK,EAAE;IAAEC,WAAW,EAAE;EAAI,CAAE,CAAC;EACvD,MAAMC,MAAM,GAAGH,IAAI,CAACI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;EAC/B,MAAMC,MAAM,GAAGL,IAAI,CAACI,KAAK,CAAC,CAAC,CAAC;EAE5B,MAAME,KAAK,GAAG,MAAMC,kBAAkB,CAACJ,MAAM,EAAEP,OAAO,CAAC;EACvD,OAAOU,KAAK,CAACD,MAAM,CAAC,IAAI,CAAC;;AAE3B;"}
@@ -1,5 +1,5 @@
1
- import { breachedAccount } from './breachedAccount.mjs';
2
- import { pasteAccount } from './pasteAccount.mjs';
1
+ import { breachedAccount } from './breached-account.js';
2
+ import { pasteAccount } from './paste-account.js';
3
3
 
4
4
  /**
5
5
  * An object representing search results.
@@ -17,79 +17,81 @@ import { pasteAccount } from './pasteAccount.mjs';
17
17
  * exactly how searching via the current web interface behaves, which this
18
18
  * convenience method is designed to mimic.
19
19
  *
20
- * ***Warning (July 18, 2019):***
21
- *
22
- * `haveibeenpwned.com` now requires an API key from
20
+ * 🔑 `haveibeenpwned.com` requires an API key from
23
21
  * https://haveibeenpwned.com/API/Key for the `breachedaccount` and
24
- * `pasteaccount` endpoints. The `apiKey` option here is not explicitly
25
- * required, but direct requests made without it (that is, without specifying a
26
- * `baseUrl` to a proxy that inserts a valid API key on your behalf) will fail.
22
+ * `pasteaccount` endpoints. The `apiKey` option here is not explicitly
23
+ * required, but direct requests made without it will fail (unless you specify a
24
+ * `baseUrl` to a proxy that inserts a valid API key on your behalf).
27
25
  *
28
26
  * @param {string} account an email address or username
29
- * @param {object} [breachOptions] a configuration object pertaining to breach
30
- * queries
31
- * @param {string} [breachOptions.apiKey] an API key from
32
- * https://haveibeenpwned.com/API/Key
33
- * @param {string} [breachOptions.domain] a domain by which to filter the
27
+ * @param {object} [options] a configuration object
28
+ * @param {string} [options.apiKey] an API key from
29
+ * https://haveibeenpwned.com/API/Key (default: undefined)
30
+ * @param {string} [options.domain] a domain by which to filter the breach
34
31
  * results (default: all domains)
35
- * @param {boolean} [breachOptions.truncate] truncate the results to only
32
+ * @param {boolean} [options.truncate] truncate the breach results to only
36
33
  * include the name of each breach (default: true)
37
- * @param {string} [breachOptions.baseUrl] a custom base URL for the
34
+ * @param {string} [options.baseUrl] a custom base URL for the
38
35
  * haveibeenpwned.com API endpoints (default:
39
36
  * `https://haveibeenpwned.com/api/v3`)
40
- * @param {string} [breachOptions.userAgent] a custom string to send as the
37
+ * @param {string} [options.userAgent] a custom string to send as the
41
38
  * User-Agent field in the request headers (default: `hibp <version>`)
42
39
  * @returns {Promise<SearchResults>} a Promise which resolves to an object
43
40
  * containing a "breaches" key (which can be null or an array of breach objects)
44
41
  * and a "pastes" key (which can be null or an array of paste objects), or
45
42
  * rejects with an Error
46
43
  * @example
47
- * search('foo', { apiKey: 'my-api-key' })
48
- * .then(data => {
49
- * if (data.breaches || data.pastes) {
50
- * // ...
51
- * } else {
52
- * // ...
53
- * }
54
- * })
55
- * .catch(err => {
44
+ * try {
45
+ * const data = await search("foo", { apiKey: "my-api-key" });
46
+ * if (data.breaches || data.pastes) {
56
47
  * // ...
57
- * });
58
- * @example
59
- * search('nobody@nowhere.com', { apiKey: 'my-api-key', truncate: false })
60
- * .then(data => {
61
- * if (data.breaches || data.pastes) {
62
- * // ...
63
- * } else {
64
- * // ...
65
- * }
66
- * })
67
- * .catch(err => {
48
+ * } else {
68
49
  * // ...
50
+ * }
51
+ * } catch (err) {
52
+ * // ...
53
+ * }
54
+ * @example
55
+ * try {
56
+ * const data = await search("nobody@nowhere.com", {
57
+ * baseUrl: "https://my-hibp-proxy:8080",
58
+ * truncate: false,
69
59
  * });
70
- *
60
+ * if (data.breaches || data.pastes) {
61
+ * // ...
62
+ * } else {
63
+ * // ...
64
+ * }
65
+ * } catch (err) {
66
+ * // ...
67
+ * }
71
68
  * @see https://haveibeenpwned.com/
72
69
  */
73
- function search(account, breachOptions = {
74
- truncate: true
75
- }) {
70
+ async function search(account, options = {}) {
76
71
  const {
77
72
  apiKey,
73
+ domain,
74
+ truncate = true,
75
+ baseUrl,
76
+ userAgent
77
+ } = options;
78
+ const [breaches, pastes] = await Promise.all([breachedAccount(account, {
79
+ apiKey,
80
+ domain,
81
+ truncate,
78
82
  baseUrl,
79
83
  userAgent
80
- } = breachOptions;
81
- return Promise.all([breachedAccount(account, breachOptions),
84
+ }),
82
85
  // This email regex is garbage but it seems to be what the API uses:
83
86
  /^.+@.+$/.test(account) ? pasteAccount(account, {
84
87
  apiKey,
85
88
  baseUrl,
86
89
  userAgent
87
- }) : null]).then(
88
- // Avoid array destructuring here to prevent need for Babel helpers
89
- promises => ({
90
- breaches: promises[0],
91
- pastes: promises[1]
92
- }));
90
+ }) : null]);
91
+ return {
92
+ breaches,
93
+ pastes
94
+ };
93
95
  }
94
96
  export { search };
95
- //# sourceMappingURL=search.mjs.map
97
+ //# sourceMappingURL=search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.js","sources":["../../src/search.ts"],"sourcesContent":["import type { Breach, Paste } from './api/haveibeenpwned/types.js';\nimport { breachedAccount } from './breached-account.js';\nimport { pasteAccount } from './paste-account.js';\n\nexport interface SearchResults {\n breaches: Breach[] | null;\n pastes: Paste[] | null;\n}\n\n/**\n * An object representing search results.\n *\n * @typedef {object} SearchResults\n * @property {(Breach[] | null)} breaches\n * @property {(Paste[] | null)} pastes\n */\n\n/**\n * Fetches all breaches and all pastes associated with the provided account\n * (email address or username). Note that the remote API does not support\n * querying pastes by username (only email addresses), so in the event the\n * provided account is not a valid email address, only breach data is queried\n * and the \"pastes\" field of the resulting object will always be null. This is\n * exactly how searching via the current web interface behaves, which this\n * convenience method is designed to mimic.\n *\n * 🔑 `haveibeenpwned.com` requires an API key from\n * https://haveibeenpwned.com/API/Key for the `breachedaccount` and\n * `pasteaccount` endpoints. The `apiKey` option here is not explicitly\n * required, but direct requests made without it will fail (unless you specify a\n * `baseUrl` to a proxy that inserts a valid API key on your behalf).\n *\n * @param {string} account an email address or username\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 breach\n * results (default: all domains)\n * @param {boolean} [options.truncate] truncate the breach results to only\n * include 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\n * User-Agent field in the request headers (default: `hibp <version>`)\n * @returns {Promise<SearchResults>} a Promise which resolves to an object\n * containing a \"breaches\" key (which can be null or an array of breach objects)\n * and a \"pastes\" key (which can be null or an array of paste objects), or\n * rejects with an Error\n * @example\n * try {\n * const data = await search(\"foo\", { apiKey: \"my-api-key\" });\n * if (data.breaches || data.pastes) {\n * // ...\n * } else {\n * // ...\n * }\n * } catch (err) {\n * // ...\n * }\n * @example\n * try {\n * const data = await search(\"nobody@nowhere.com\", {\n * baseUrl: \"https://my-hibp-proxy:8080\",\n * truncate: false,\n * });\n * if (data.breaches || data.pastes) {\n * // ...\n * } else {\n * // ...\n * }\n * } catch (err) {\n * // ...\n * }\n * @see https://haveibeenpwned.com/\n */\nexport async function search(\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 * 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<SearchResults> {\n const { apiKey, domain, truncate = true, baseUrl, userAgent } = options;\n\n const [breaches, pastes] = await Promise.all([\n breachedAccount(account, { apiKey, domain, truncate, baseUrl, userAgent }),\n // This email regex is garbage but it seems to be what the API uses:\n /^.+@.+$/.test(account)\n ? pasteAccount(account, { apiKey, baseUrl, userAgent })\n : null,\n ]);\n\n return { breaches, pastes };\n}\n"],"names":["search","account","options","apiKey","domain","truncate","baseUrl","userAgent","breaches","pastes","Promise","all","breachedAccount","test","pasteAccount"],"mappings":";;;AASA;;;;;;AAMG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DG;AACI,eAAeA,MAAMA,CAC1BC,OAAe,EACfC,UAwBI,EAAE,EAAA;EAEN,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC,QAAQ,GAAG,IAAI;IAAEC,OAAO;IAAEC;EAAW,CAAA,GAAGL,OAAO;EAEvE,MAAM,CAACM,QAAQ,EAAEC,MAAM,CAAC,GAAG,MAAMC,OAAO,CAACC,GAAG,CAAC,CAC3CC,eAAe,CAACX,OAAO,EAAE;IAAEE,MAAM;IAAEC,MAAM;IAAEC,QAAQ;IAAEC,OAAO;IAAEC;GAAW,CAAC;;EAE1E,SAAS,CAACM,IAAI,CAACZ,OAAO,CAAC,GACnBa,YAAY,CAACb,OAAO,EAAE;IAAEE,MAAM;IAAEG,OAAO;IAAEC;EAAS,CAAE,CAAC,GACrD,IAAI,CACT,CAAC;EAEF,OAAO;IAAEC,QAAQ;IAAEC;GAAQ;AAC7B;"}
@@ -0,0 +1,54 @@
1
+ import { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';
2
+
3
+ /**
4
+ * An object representing the status of your HIBP subscription.
5
+ *
6
+ * @typedef {object} SubscriptionStatus
7
+ * @property {string} SubscriptionName
8
+ * @property {string} Description
9
+ * @property {string} SubscribedUntil
10
+ * @property {number} Rpm
11
+ * @property {number} DomainSearchMaxBreachedAccounts
12
+ */
13
+ /**
14
+ * Fetches the current status of your HIBP subscription (API key).
15
+ *
16
+ * 🔑 `haveibeenpwned.com` requires an API key from
17
+ * https://haveibeenpwned.com/API/Key for the `subscription/status` endpoint.
18
+ * The `apiKey` option here is not explicitly required, but direct requests made
19
+ * without it will fail (unless you specify a `baseUrl` to a proxy that inserts
20
+ * a valid API key on your behalf).
21
+ *
22
+ * @param {object} [options] a configuration object
23
+ * @param {string} [options.apiKey] an API key from
24
+ * https://haveibeenpwned.com/API/Key (default: undefined)
25
+ * @param {string} [options.baseUrl] a custom base URL for the
26
+ * haveibeenpwned.com API endpoints (default:
27
+ * `https://haveibeenpwned.com/api/v3`)
28
+ * @param {string} [options.userAgent] a custom string to send as the User-Agent
29
+ * field in the request headers (default: `hibp <version>`)
30
+ * @returns {Promise<SubscriptionStatus>} a Promise which resolves to a
31
+ * subscription status object, or rejects with an Error
32
+ * @example
33
+ * try {
34
+ * const data = await subscriptionStatus({ apiKey: "my-api-key" });
35
+ * // ...
36
+ * } catch (err) {
37
+ * // ...
38
+ * }
39
+ * @example
40
+ * try {
41
+ * const data = await subscriptionStatus({
42
+ * baseUrl: "https://my-hibp-proxy:8080",
43
+ * });
44
+ * // ...
45
+ * } catch (err) {
46
+ * // ...
47
+ * }
48
+ */
49
+ async function subscriptionStatus(options = {}) {
50
+ const endpoint = '/subscription/status';
51
+ return fetchFromApi(endpoint, options);
52
+ }
53
+ export { subscriptionStatus };
54
+ //# sourceMappingURL=subscription-status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription-status.js","sources":["../../src/subscription-status.ts"],"sourcesContent":["import type { SubscriptionStatus } from './api/haveibeenpwned/types.js';\nimport { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';\n\n/**\n * An object representing the status of your HIBP subscription.\n *\n * @typedef {object} SubscriptionStatus\n * @property {string} SubscriptionName\n * @property {string} Description\n * @property {string} SubscribedUntil\n * @property {number} Rpm\n * @property {number} DomainSearchMaxBreachedAccounts\n */\n\n/**\n * Fetches the current status of your HIBP subscription (API key).\n *\n * 🔑 `haveibeenpwned.com` requires an API key from\n * https://haveibeenpwned.com/API/Key for the `subscription/status` endpoint.\n * The `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 {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.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<SubscriptionStatus>} a Promise which resolves to a\n * subscription status object, or rejects with an Error\n * @example\n * try {\n * const data = await subscriptionStatus({ apiKey: \"my-api-key\" });\n * // ...\n * } catch (err) {\n * // ...\n * }\n * @example\n * try {\n * const data = await subscriptionStatus({\n * baseUrl: \"https://my-hibp-proxy:8080\",\n * });\n * // ...\n * } catch (err) {\n * // ...\n * }\n */\nexport async function subscriptionStatus(\n options: {\n /**\n * an API key from https://haveibeenpwned.com/API/Key (default: undefined)\n */\n apiKey?: 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) {\n const endpoint = '/subscription/status';\n\n return fetchFromApi(endpoint, options) as Promise<SubscriptionStatus>;\n}\n"],"names":["subscriptionStatus","options","endpoint","fetchFromApi"],"mappings":";;AAGA;;;;;;;;;AASG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCG;AACI,eAAeA,kBAAkBA,CACtCC,UAeI,EAAE,EAAA;EAEN,MAAMC,QAAQ,GAAG,sBAAsB;EAEvC,OAAOC,YAAY,CAACD,QAAQ,EAAED,OAAO,CAAgC;AACvE;"}
package/example/runkit.js CHANGED
@@ -1,16 +1,15 @@
1
1
  const hibp = require('hibp');
2
2
 
3
- hibp
4
- .breach('Adobe')
5
- .then((data) => {
6
- if (data) {
7
- // Breach data found
8
- console.log(data);
9
- } else {
10
- console.log('No breach data found by that name.');
11
- }
12
- })
13
- .catch((err) => {
14
- // Something went wrong.
15
- console.log(err.message);
16
- });
3
+ try {
4
+ const data = await hibp.breach('Adobe');
5
+
6
+ if (data) {
7
+ // Breach data found
8
+ console.log(data);
9
+ } else {
10
+ console.log('No breach data found by that name.');
11
+ }
12
+ } catch (err) {
13
+ // Something went wrong.
14
+ console.log(err.message);
15
+ }