hibp 14.1.3 → 15.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.
Files changed (86) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +15 -39
  3. package/dist/browser/hibp.module.js +2 -2
  4. package/dist/esm/api/haveibeenpwned/fetch-from-api.d.ts +16 -0
  5. package/dist/esm/api/haveibeenpwned/fetch-from-api.js +67 -80
  6. package/dist/esm/api/haveibeenpwned/fetch-from-api.js.map +1 -1
  7. package/dist/esm/api/haveibeenpwned/package-info.d.ts +2 -0
  8. package/dist/esm/api/haveibeenpwned/package-info.js +4 -0
  9. package/dist/esm/api/haveibeenpwned/package-info.js.map +1 -0
  10. package/dist/esm/api/haveibeenpwned/responses.d.ts +11 -0
  11. package/dist/esm/api/haveibeenpwned/responses.js +22 -23
  12. package/dist/esm/api/haveibeenpwned/responses.js.map +1 -1
  13. package/dist/esm/api/haveibeenpwned/types.d.ts +38 -0
  14. package/dist/esm/api/haveibeenpwned/types.js +11 -2
  15. package/dist/esm/api/haveibeenpwned/types.js.map +1 -1
  16. package/dist/esm/api/pwnedpasswords/fetch-from-api.d.ts +1 -0
  17. package/dist/esm/api/pwnedpasswords/fetch-from-api.js +19 -33
  18. package/dist/esm/api/pwnedpasswords/fetch-from-api.js.map +1 -1
  19. package/dist/esm/api/pwnedpasswords/responses.d.ts +7 -0
  20. package/dist/esm/api/pwnedpasswords/responses.js +4 -5
  21. package/dist/esm/api/pwnedpasswords/responses.js.map +1 -1
  22. package/dist/{cjs/breach.cjs → esm/breach.d.ts} +17 -9
  23. package/dist/esm/breach.js +3 -5
  24. package/dist/esm/breach.js.map +1 -1
  25. package/dist/{cjs/breached-account.cjs → esm/breached-account.d.ts} +34 -34
  26. package/dist/esm/breached-account.js +20 -30
  27. package/dist/esm/breached-account.js.map +1 -1
  28. package/dist/{cjs/breaches.cjs → esm/breaches.d.ts} +21 -24
  29. package/dist/esm/breaches.js +13 -20
  30. package/dist/esm/breaches.js.map +1 -1
  31. package/dist/{cjs/data-classes.cjs → esm/data-classes.d.ts} +16 -9
  32. package/dist/esm/data-classes.js +3 -5
  33. package/dist/esm/data-classes.js.map +1 -1
  34. package/dist/esm/hibp.d.ts +21 -715
  35. package/dist/esm/hibp.js +23 -11
  36. package/dist/esm/hibp.js.map +1 -1
  37. package/dist/{cjs/paste-account.cjs → esm/paste-account.d.ts} +21 -9
  38. package/dist/esm/paste-account.js +3 -5
  39. package/dist/esm/paste-account.js.map +1 -1
  40. package/dist/{cjs/pwned-password-range.cjs → esm/pwned-password-range.d.ts} +26 -30
  41. package/dist/esm/pwned-password-range.js +18 -26
  42. package/dist/esm/pwned-password-range.js.map +1 -1
  43. package/dist/{cjs/pwned-password.cjs → esm/pwned-password.d.ts} +21 -19
  44. package/dist/esm/pwned-password.js +20 -15
  45. package/dist/esm/pwned-password.js.map +1 -1
  46. package/dist/{cjs/search.cjs → esm/search.d.ts} +34 -36
  47. package/dist/esm/search.js +18 -31
  48. package/dist/esm/search.js.map +1 -1
  49. package/dist/{cjs/subscription-status.cjs → esm/subscription-status.d.ts} +21 -10
  50. package/dist/esm/subscription-status.js +4 -6
  51. package/dist/esm/subscription-status.js.map +1 -1
  52. package/package.json +30 -48
  53. package/dist/browser/hibp.module.js.map +0 -1
  54. package/dist/browser/hibp.umd.js +0 -2
  55. package/dist/browser/hibp.umd.js.map +0 -1
  56. package/dist/cjs/api/fetch-polyfill.cjs +0 -27
  57. package/dist/cjs/api/fetch-polyfill.cjs.map +0 -1
  58. package/dist/cjs/api/haveibeenpwned/fetch-from-api.cjs +0 -123
  59. package/dist/cjs/api/haveibeenpwned/fetch-from-api.cjs.map +0 -1
  60. package/dist/cjs/api/haveibeenpwned/responses.cjs +0 -63
  61. package/dist/cjs/api/haveibeenpwned/responses.cjs.map +0 -1
  62. package/dist/cjs/api/haveibeenpwned/types.cjs +0 -2
  63. package/dist/cjs/api/haveibeenpwned/types.cjs.map +0 -1
  64. package/dist/cjs/api/pwnedpasswords/fetch-from-api.cjs +0 -60
  65. package/dist/cjs/api/pwnedpasswords/fetch-from-api.cjs.map +0 -1
  66. package/dist/cjs/api/pwnedpasswords/responses.cjs +0 -15
  67. package/dist/cjs/api/pwnedpasswords/responses.cjs.map +0 -1
  68. package/dist/cjs/breach.cjs.map +0 -1
  69. package/dist/cjs/breached-account.cjs.map +0 -1
  70. package/dist/cjs/breaches.cjs.map +0 -1
  71. package/dist/cjs/data-classes.cjs.map +0 -1
  72. package/dist/cjs/hibp.cjs +0 -23
  73. package/dist/cjs/hibp.cjs.map +0 -1
  74. package/dist/cjs/hibp.d.cts +0 -717
  75. package/dist/cjs/package.json.cjs +0 -7
  76. package/dist/cjs/package.json.cjs.map +0 -1
  77. package/dist/cjs/paste-account.cjs.map +0 -1
  78. package/dist/cjs/pwned-password-range.cjs.map +0 -1
  79. package/dist/cjs/pwned-password.cjs.map +0 -1
  80. package/dist/cjs/search.cjs.map +0 -1
  81. package/dist/cjs/subscription-status.cjs.map +0 -1
  82. package/dist/esm/api/fetch-polyfill.js +0 -25
  83. package/dist/esm/api/fetch-polyfill.js.map +0 -1
  84. package/dist/esm/package.json.js +0 -4
  85. package/dist/esm/package.json.js.map +0 -1
  86. package/example/runkit.js +0 -15
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-from-api.js","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 {number} [options.timeoutMs] timeout for the request in milliseconds\n * (default: none)\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 timeoutMs?: number;\n userAgent?: string;\n addPadding?: boolean;\n mode?: 'sha1' | 'ntlm';\n } = {},\n): Promise<string> {\n const {\n baseUrl = 'https://api.pwnedpasswords.com',\n timeoutMs,\n userAgent,\n addPadding = false,\n mode = 'sha1',\n } = options;\n\n const config: RequestInit = {\n headers: {\n ...(userAgent ? { 'User-Agent': userAgent } : {}),\n ...(addPadding ? { 'Add-Padding': 'true' } : {}),\n },\n ...(timeoutMs ? { signal: AbortSignal.timeout(timeoutMs) } : {}),\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","timeoutMs","userAgent","addPadding","mode","config","headers","signal","AbortSignal","timeout","url","replace","response","fetch","ok","text","status","BAD_REQUEST","Error","statusText"],"mappings":";;AAGAA,qBAAqB,CAAE,CAAA;AAEvB;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACI,eAAeC,YAAYA,CAChCC,QAAgB,EAChBC,UAMI,EAAE,EAAA;EAEN,MAAM;IACJC,OAAO,GAAG,gCAAgC;IAC1CC,SAAS;IACTC,SAAS;IACTC,UAAU,GAAG,KAAK;IAClBC,IAAI,GAAG;EAAM,CACd,GAAGL,OAAO;EAEX,MAAMM,MAAM,GAAgB;IAC1BC,OAAO,EAAE;MACP,IAAIJ,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AC,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACjD,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACjD;QACD,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACjE,CAAC;IACF,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,QAAQ,SAAS,IAAI,EAAE,CAAC;IACrE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAE1C,IAAI,QAAQ,CAAC,EAAE;QAAE,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;IAExC,IAAI,QAAQ,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM,EAAE,CAAC;QAC3C,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Known potential responses from the remote API.
3
+ *
4
+ * https://haveibeenpwned.com/api/v3#PwnedPasswords
5
+ *
6
+ */
7
+ export {};
@@ -5,9 +5,8 @@
5
5
  *
6
6
  */
7
7
  /** @internal */
8
- const BAD_REQUEST = {
9
- status: 400,
10
- body: 'The hash prefix was not in a valid format'
8
+ export const BAD_REQUEST = {
9
+ status: 400,
10
+ body: 'The hash prefix was not in a valid format',
11
11
  };
12
- export { BAD_REQUEST };
13
- //# sourceMappingURL=responses.js.map
12
+ //# sourceMappingURL=responses.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"responses.js","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 const BAD_REQUEST = {\n status: 400 as const,\n body: 'The hash prefix was not in a valid format',\n};\n"],"names":["BAD_REQUEST","status","body"],"mappings":"AAAA;;;;;AAKG;AAEH;AACa,MAAAA,WAAW,GAAG;EACzBC,MAAM,EAAE,GAAY;EACpBC,IAAI,EAAE;;"}
1
+ {"version":3,"file":"responses.js","sourceRoot":"","sources":["../../../../src/api/pwnedpasswords/responses.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,gBAAgB;AAChB,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,MAAM,EAAE,GAAY;IACpB,IAAI,EAAE,2CAA2C;CAClD,CAAC"}
@@ -1,7 +1,4 @@
1
- 'use strict';
2
-
3
- var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetch-from-api.cjs');
4
-
1
+ import type { Breach } from './api/haveibeenpwned/types.js';
5
2
  /**
6
3
  * An object representing a breach.
7
4
  *
@@ -51,8 +48,19 @@ var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetch-from-api.cjs
51
48
  * // ...
52
49
  * }
53
50
  */
54
- function breach(breachName, options = {}) {
55
- return fetchFromApi.fetchFromApi(`/breach/${encodeURIComponent(breachName)}`, options);
56
- }
57
- exports.breach = breach;
58
- //# sourceMappingURL=breach.cjs.map
51
+ export declare function breach(breachName: string, options?: {
52
+ /**
53
+ * a custom base URL for the haveibeenpwned.com API endpoints (default:
54
+ * `https://haveibeenpwned.com/api/v3`)
55
+ */
56
+ baseUrl?: string;
57
+ /**
58
+ * timeout for the request in milliseconds (default: none)
59
+ */
60
+ timeoutMs?: number;
61
+ /**
62
+ * a custom string to send as the User-Agent field in the request headers
63
+ * (default: `hibp <version>`)
64
+ */
65
+ userAgent?: string;
66
+ }): Promise<Breach | null>;
@@ -1,5 +1,4 @@
1
1
  import { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';
2
-
3
2
  /**
4
3
  * An object representing a breach.
5
4
  *
@@ -49,8 +48,7 @@ import { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';
49
48
  * // ...
50
49
  * }
51
50
  */
52
- function breach(breachName, options = {}) {
53
- return fetchFromApi(`/breach/${encodeURIComponent(breachName)}`, options);
51
+ export function breach(breachName, options = {}) {
52
+ return fetchFromApi(`/breach/${encodeURIComponent(breachName)}`, options);
54
53
  }
55
- export { breach };
56
- //# sourceMappingURL=breach.js.map
54
+ //# sourceMappingURL=breach.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"breach.js","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 {number} [options.timeoutMs] timeout for the request in milliseconds\n * (default: none)\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 * timeout for the request in milliseconds (default: none)\n */\n timeoutMs?: number;\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;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;SACaA,MAAMA,CACpBC,UAAkB,EAClBC,UAeI,EAAE,EAAA;EAEN,OAAOC,YAAY,CACjB,WAAWC,kBAAkB,CAACH,UAAU,CAAC,EAAE,EAC3CC,OAAO,CACkB;AAC7B;"}
1
+ {"version":3,"file":"breach.js","sourceRoot":"","sources":["../../src/breach.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,MAAM,CACpB,UAAkB,EAClB,UAeI,EAAE;IAEN,OAAO,YAAY,CACjB,WAAW,kBAAkB,CAAC,UAAU,CAAC,EAAE,EAC3C,OAAO,CACkB,CAAC;AAC9B,CAAC"}
@@ -1,7 +1,4 @@
1
- 'use strict';
2
-
3
- var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetch-from-api.cjs');
4
-
1
+ import type { Breach } from './api/haveibeenpwned/types.js';
5
2
  /**
6
3
  * Fetches breach data for a specific account.
7
4
  *
@@ -73,33 +70,36 @@ var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetch-from-api.cjs
73
70
  * // ...
74
71
  * }
75
72
  */
76
- function breachedAccount(account, options = {}) {
77
- const {
78
- apiKey,
79
- domain,
80
- includeUnverified = true,
81
- timeoutMs,
82
- truncate = true,
83
- baseUrl,
84
- userAgent
85
- } = options;
86
- const endpoint = `/breachedaccount/${encodeURIComponent(account)}?`;
87
- const params = [];
88
- if (domain) {
89
- params.push(`domain=${encodeURIComponent(domain)}`);
90
- }
91
- if (!includeUnverified) {
92
- params.push('includeUnverified=false');
93
- }
94
- if (!truncate) {
95
- params.push('truncateResponse=false');
96
- }
97
- return fetchFromApi.fetchFromApi(`${endpoint}${params.join('&')}`, {
98
- apiKey,
99
- baseUrl,
100
- timeoutMs,
101
- userAgent
102
- });
103
- }
104
- exports.breachedAccount = breachedAccount;
105
- //# sourceMappingURL=breached-account.cjs.map
73
+ export declare function breachedAccount(account: string, options?: {
74
+ /**
75
+ * an API key from https://haveibeenpwned.com/API/Key (default: undefined)
76
+ */
77
+ apiKey?: string;
78
+ /**
79
+ * a domain by which to filter the results (default: all domains)
80
+ */
81
+ domain?: string;
82
+ /**
83
+ * include "unverified" breaches in the results (default: true)
84
+ */
85
+ includeUnverified?: boolean;
86
+ /**
87
+ * timeout for the request in milliseconds (default: none)
88
+ */
89
+ timeoutMs?: number;
90
+ /**
91
+ * truncate the results to only include the name of each breach (default:
92
+ * true)
93
+ */
94
+ truncate?: boolean;
95
+ /**
96
+ * a custom base URL for the haveibeenpwned.com API endpoints (default:
97
+ * `https://haveibeenpwned.com/api/v3`)
98
+ */
99
+ baseUrl?: string;
100
+ /**
101
+ * a custom string to send as the User-Agent field in the request headers
102
+ * (default: `hibp <version>`)
103
+ */
104
+ userAgent?: string;
105
+ }): Promise<Breach[] | null>;
@@ -1,5 +1,4 @@
1
1
  import { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';
2
-
3
2
  /**
4
3
  * Fetches breach data for a specific account.
5
4
  *
@@ -71,33 +70,24 @@ import { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';
71
70
  * // ...
72
71
  * }
73
72
  */
74
- function breachedAccount(account, options = {}) {
75
- const {
76
- apiKey,
77
- domain,
78
- includeUnverified = true,
79
- timeoutMs,
80
- truncate = true,
81
- baseUrl,
82
- userAgent
83
- } = options;
84
- const endpoint = `/breachedaccount/${encodeURIComponent(account)}?`;
85
- const params = [];
86
- if (domain) {
87
- params.push(`domain=${encodeURIComponent(domain)}`);
88
- }
89
- if (!includeUnverified) {
90
- params.push('includeUnverified=false');
91
- }
92
- if (!truncate) {
93
- params.push('truncateResponse=false');
94
- }
95
- return fetchFromApi(`${endpoint}${params.join('&')}`, {
96
- apiKey,
97
- baseUrl,
98
- timeoutMs,
99
- userAgent
100
- });
73
+ export function breachedAccount(account, options = {}) {
74
+ const { apiKey, domain, includeUnverified = true, timeoutMs, truncate = true, baseUrl, userAgent, } = options;
75
+ const endpoint = `/breachedaccount/${encodeURIComponent(account)}?`;
76
+ const params = [];
77
+ if (domain) {
78
+ params.push(`domain=${encodeURIComponent(domain)}`);
79
+ }
80
+ if (!includeUnverified) {
81
+ params.push('includeUnverified=false');
82
+ }
83
+ if (!truncate) {
84
+ params.push('truncateResponse=false');
85
+ }
86
+ return fetchFromApi(`${endpoint}${params.join('&')}`, {
87
+ apiKey,
88
+ baseUrl,
89
+ timeoutMs,
90
+ userAgent,
91
+ });
101
92
  }
102
- export { breachedAccount };
103
- //# sourceMappingURL=breached-account.js.map
93
+ //# sourceMappingURL=breached-account.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"breached-account.js","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 {number} [options.timeoutMs] timeout for the request in milliseconds\n * (default: none)\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 * timeout for the request in milliseconds (default: none)\n */\n timeoutMs?: number;\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 timeoutMs,\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 timeoutMs,\n userAgent,\n }) as Promise<Breach[] | null>;\n}\n"],"names":["breachedAccount","account","options","apiKey","domain","includeUnverified","timeoutMs","truncate","baseUrl","userAgent","endpoint","encodeURIComponent","params","push","fetchFromApi","join"],"mappings":";;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEG;SACaA,eAAeA,CAC7BC,OAAe,EACfC,UAgCI,EAAE,EAAA;EAEN,MAAM;IACJC,MAAM;IACNC,MAAM;IACNC,iBAAiB,GAAG,IAAI;IACxBC,SAAS;IACTC,QAAQ,GAAG,IAAI;IACfC,OAAO;IACPC;EACD,CAAA,GAAGP,OAAO;EACX,MAAMQ,QAAQ,GAAG,oBAAoBC,kBAAkB,CAACV,OAAO,CAAC,GAAG;EACnE,MAAMW,MAAM,GAAa,EAAE;EAE3B,IAAIR,MAAM,EAAE;IACVQ,MAAM,CAACC,IAAI,CAAC,UAAUF,kBAAkB,CAACP,MAAM,CAAC,EAAE,CAAC;;EAGrD,IAAI,CAACC,iBAAiB,EAAE;IACtBO,MAAM,CA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QACP,SAAS;QACT,SAAS;KACV,CAA6B,CAAC;AACjC,CAAC"}
@@ -1,7 +1,4 @@
1
- 'use strict';
2
-
3
- var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetch-from-api.cjs');
4
-
1
+ import type { Breach } from './api/haveibeenpwned/types.js';
5
2
  /**
6
3
  * Fetches all breach events in the system.
7
4
  *
@@ -40,23 +37,23 @@ var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetch-from-api.cjs
40
37
  * // ...
41
38
  * }
42
39
  */
43
- function breaches(options = {}) {
44
- const {
45
- domain,
46
- baseUrl,
47
- timeoutMs,
48
- userAgent
49
- } = options;
50
- const endpoint = '/breaches?';
51
- const params = [];
52
- if (domain) {
53
- params.push(`domain=${encodeURIComponent(domain)}`);
54
- }
55
- return fetchFromApi.fetchFromApi(`${endpoint}${params.join('&')}`, {
56
- baseUrl,
57
- timeoutMs,
58
- userAgent
59
- });
60
- }
61
- exports.breaches = breaches;
62
- //# sourceMappingURL=breaches.cjs.map
40
+ export declare function breaches(options?: {
41
+ /**
42
+ * a domain by which to filter the results (default: all domains)
43
+ */
44
+ domain?: string;
45
+ /**
46
+ * a custom base URL for the haveibeenpwned.com API endpoints (default:
47
+ * `https://haveibeenpwned.com/api/v3`)
48
+ */
49
+ baseUrl?: string;
50
+ /**
51
+ * timeout for the request in milliseconds (default: none)
52
+ */
53
+ timeoutMs?: number;
54
+ /**
55
+ * a custom string to send as the User-Agent field in the request headers
56
+ * (default: `hibp <version>`)
57
+ */
58
+ userAgent?: string;
59
+ }): Promise<Breach[]>;
@@ -1,5 +1,4 @@
1
1
  import { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';
2
-
3
2
  /**
4
3
  * Fetches all breach events in the system.
5
4
  *
@@ -38,23 +37,17 @@ import { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';
38
37
  * // ...
39
38
  * }
40
39
  */
41
- function breaches(options = {}) {
42
- const {
43
- domain,
44
- baseUrl,
45
- timeoutMs,
46
- userAgent
47
- } = options;
48
- const endpoint = '/breaches?';
49
- const params = [];
50
- if (domain) {
51
- params.push(`domain=${encodeURIComponent(domain)}`);
52
- }
53
- return fetchFromApi(`${endpoint}${params.join('&')}`, {
54
- baseUrl,
55
- timeoutMs,
56
- userAgent
57
- });
40
+ export function breaches(options = {}) {
41
+ const { domain, baseUrl, timeoutMs, userAgent } = options;
42
+ const endpoint = '/breaches?';
43
+ const params = [];
44
+ if (domain) {
45
+ params.push(`domain=${encodeURIComponent(domain)}`);
46
+ }
47
+ return fetchFromApi(`${endpoint}${params.join('&')}`, {
48
+ baseUrl,
49
+ timeoutMs,
50
+ userAgent,
51
+ });
58
52
  }
59
- export { breaches };
60
- //# sourceMappingURL=breaches.js.map
53
+ //# sourceMappingURL=breaches.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"breaches.js","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 {number} [options.timeoutMs] timeout for the request in milliseconds\n * (default: none)\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 * timeout for the request in milliseconds (default: none)\n */\n timeoutMs?: number;\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, timeoutMs, 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 timeoutMs,\n userAgent,\n }) as Promise<Breach[]>;\n}\n"],"names":["breaches","options","domain","baseUrl","timeoutMs","userAgent","endpoint","params","push","encodeURIComponent","fetchFromApi","join"],"mappings":";;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCG;AACa,SAAAA,QAAQA,CACtBC,OAAA,GAmBI,EAAE,EAAA;EAEN,MAAM;IAAEC,MAAM;IAAEC,OAAO;IAAEC,SAAS;IAAEC;EAAW,CAAA,GAAGJ,OAAO;EACzD,MAAMK,QAAQ,GAAG,YAAY;EAC7B,MAAMC,MAAM,GAAa,EAAE;EAE3B,IAAIL,MAAM,EAAE;IACVK,MAAM,CAACC,IAAI,CAAC,UAAUC,kBAAkB,CAACP,MAAM,CAAC,EAAE,CAAC;;EAGrD,OAAOQ,YAAY,CAAC,GAAGJ,QAAQ,GAAGC,MAAM,CAACI,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;IACpDR,OAAO;IACPC,SAAS;IACTC;EACD,CAAA,CAAsB;AACzB;"}
1
+ {"version":3,"file":"breaches.js","sourceRoot":"","sources":["../../src/breaches.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,UAAU,QAAQ,CACtB,UAmBI,EAAE;IAEN,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC1D,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,OAAO,YAAY,CAAC,GAAG,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;QACpD,OAAO;QACP,SAAS;QACT,SAAS;KACV,CAAsB,CAAC;AAC1B,CAAC"}
@@ -1,7 +1,3 @@
1
- 'use strict';
2
-
3
- var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetch-from-api.cjs');
4
-
5
1
  /**
6
2
  * Fetches all data classes in the system.
7
3
  *
@@ -28,8 +24,19 @@ var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetch-from-api.cjs
28
24
  * // ...
29
25
  * }
30
26
  */
31
- function dataClasses(options = {}) {
32
- return fetchFromApi.fetchFromApi('/dataclasses', options);
33
- }
34
- exports.dataClasses = dataClasses;
35
- //# sourceMappingURL=data-classes.cjs.map
27
+ export declare function dataClasses(options?: {
28
+ /**
29
+ * a custom base URL for the haveibeenpwned.com API endpoints (default:
30
+ * `https://haveibeenpwned.com/api/v3`)
31
+ */
32
+ baseUrl?: string;
33
+ /**
34
+ * timeout for the request in milliseconds (default: none)
35
+ */
36
+ timeoutMs?: number;
37
+ /**
38
+ * a custom string to send as the User-Agent field in the request headers
39
+ * (default: `hibp <version>`)
40
+ */
41
+ userAgent?: string;
42
+ }): Promise<string[] | null>;
@@ -1,5 +1,4 @@
1
1
  import { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';
2
-
3
2
  /**
4
3
  * Fetches all data classes in the system.
5
4
  *
@@ -26,8 +25,7 @@ import { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';
26
25
  * // ...
27
26
  * }
28
27
  */
29
- function dataClasses(options = {}) {
30
- return fetchFromApi('/dataclasses', options);
28
+ export function dataClasses(options = {}) {
29
+ return fetchFromApi('/dataclasses', options);
31
30
  }
32
- export { dataClasses };
33
- //# sourceMappingURL=data-classes.js.map
31
+ //# sourceMappingURL=data-classes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"data-classes.js","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 {number} [options.timeoutMs] timeout for the request in milliseconds\n * (default: none)\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 * timeout for the request in milliseconds (default: none)\n */\n timeoutMs?: number;\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;;;;;;;;;;;;;;;;;;;;;;;;;AAyBG;AACa,SAAAA,WAAWA,CACzBC,OAAA,GAeI,EAAE,EAAA;EAEN,OAAOC,YAAY,CAAC,cAAc,EAAED,OAAO,CAA6B;AAC1E;"}
1
+ {"version":3,"file":"data-classes.js","sourceRoot":"","sources":["../../src/data-classes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,WAAW,CACzB,UAeI,EAAE;IAEN,OAAO,YAAY,CAAC,cAAc,EAAE,OAAO,CAA6B,CAAC;AAC3E,CAAC"}