hibp 0.0.0-dev.0e634825

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 (81) hide show
  1. package/API.md +508 -0
  2. package/CHANGELOG.md +17 -0
  3. package/LICENSE.txt +22 -0
  4. package/MIGRATION.md +227 -0
  5. package/README.md +255 -0
  6. package/dist/browser/hibp.module.js +2 -0
  7. package/dist/browser/hibp.module.js.map +1 -0
  8. package/dist/browser/hibp.umd.js +2 -0
  9. package/dist/browser/hibp.umd.js.map +1 -0
  10. package/dist/cjs/api/haveibeenpwned/fetchFromApi.js +107 -0
  11. package/dist/cjs/api/haveibeenpwned/fetchFromApi.js.map +1 -0
  12. package/dist/cjs/api/haveibeenpwned/index.js +6 -0
  13. package/dist/cjs/api/haveibeenpwned/index.js.map +1 -0
  14. package/dist/cjs/api/haveibeenpwned/responses.js +79 -0
  15. package/dist/cjs/api/haveibeenpwned/responses.js.map +1 -0
  16. package/dist/cjs/api/pwnedpasswords/fetchFromApi.js +44 -0
  17. package/dist/cjs/api/pwnedpasswords/fetchFromApi.js.map +1 -0
  18. package/dist/cjs/api/pwnedpasswords/index.js +5 -0
  19. package/dist/cjs/api/pwnedpasswords/index.js.map +1 -0
  20. package/dist/cjs/api/pwnedpasswords/responses.js +20 -0
  21. package/dist/cjs/api/pwnedpasswords/responses.js.map +1 -0
  22. package/dist/cjs/api/web-fetch.js +14 -0
  23. package/dist/cjs/api/web-fetch.js.map +1 -0
  24. package/dist/cjs/breach.js +55 -0
  25. package/dist/cjs/breach.js.map +1 -0
  26. package/dist/cjs/breachedAccount.js +101 -0
  27. package/dist/cjs/breachedAccount.js.map +1 -0
  28. package/dist/cjs/breaches.js +55 -0
  29. package/dist/cjs/breaches.js.map +1 -0
  30. package/dist/cjs/dataClasses.js +34 -0
  31. package/dist/cjs/dataClasses.js.map +1 -0
  32. package/dist/cjs/hibp.d.ts +480 -0
  33. package/dist/cjs/hibp.js +21 -0
  34. package/dist/cjs/hibp.js.map +1 -0
  35. package/dist/cjs/package.json.js +7 -0
  36. package/dist/cjs/package.json.js.map +1 -0
  37. package/dist/cjs/pasteAccount.js +59 -0
  38. package/dist/cjs/pasteAccount.js.map +1 -0
  39. package/dist/cjs/pwnedPassword.js +45 -0
  40. package/dist/cjs/pwnedPassword.js.map +1 -0
  41. package/dist/cjs/pwnedPasswordRange.js +63 -0
  42. package/dist/cjs/pwnedPasswordRange.js.map +1 -0
  43. package/dist/cjs/search.js +97 -0
  44. package/dist/cjs/search.js.map +1 -0
  45. package/dist/esm/api/haveibeenpwned/fetchFromApi.mjs +104 -0
  46. package/dist/esm/api/haveibeenpwned/fetchFromApi.mjs.map +1 -0
  47. package/dist/esm/api/haveibeenpwned/index.mjs +2 -0
  48. package/dist/esm/api/haveibeenpwned/index.mjs.map +1 -0
  49. package/dist/esm/api/haveibeenpwned/responses.mjs +71 -0
  50. package/dist/esm/api/haveibeenpwned/responses.mjs.map +1 -0
  51. package/dist/esm/api/pwnedpasswords/fetchFromApi.mjs +42 -0
  52. package/dist/esm/api/pwnedpasswords/fetchFromApi.mjs.map +1 -0
  53. package/dist/esm/api/pwnedpasswords/index.mjs +2 -0
  54. package/dist/esm/api/pwnedpasswords/index.mjs.map +1 -0
  55. package/dist/esm/api/pwnedpasswords/responses.mjs +17 -0
  56. package/dist/esm/api/pwnedpasswords/responses.mjs.map +1 -0
  57. package/dist/esm/api/web-fetch.mjs +10 -0
  58. package/dist/esm/api/web-fetch.mjs.map +1 -0
  59. package/dist/esm/breach.mjs +53 -0
  60. package/dist/esm/breach.mjs.map +1 -0
  61. package/dist/esm/breachedAccount.mjs +99 -0
  62. package/dist/esm/breachedAccount.mjs.map +1 -0
  63. package/dist/esm/breaches.mjs +53 -0
  64. package/dist/esm/breaches.mjs.map +1 -0
  65. package/dist/esm/dataClasses.mjs +32 -0
  66. package/dist/esm/dataClasses.mjs.map +1 -0
  67. package/dist/esm/hibp.d.mts +480 -0
  68. package/dist/esm/hibp.mjs +10 -0
  69. package/dist/esm/hibp.mjs.map +1 -0
  70. package/dist/esm/package.json.mjs +4 -0
  71. package/dist/esm/package.json.mjs.map +1 -0
  72. package/dist/esm/pasteAccount.mjs +57 -0
  73. package/dist/esm/pasteAccount.mjs.map +1 -0
  74. package/dist/esm/pwnedPassword.mjs +43 -0
  75. package/dist/esm/pwnedPassword.mjs.map +1 -0
  76. package/dist/esm/pwnedPasswordRange.mjs +61 -0
  77. package/dist/esm/pwnedPasswordRange.mjs.map +1 -0
  78. package/dist/esm/search.mjs +95 -0
  79. package/dist/esm/search.mjs.map +1 -0
  80. package/example/runkit.js +16 -0
  81. package/package.json +138 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responses.js","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';\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 OK: HaveIBeenPwnedApiResponse = {\n headers: emptyHeaders,\n status: 200,\n};\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","OK","headers","status","BAD_REQUEST","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,EAAE,GAA8B;EAC3CC,OAAO,EAAEH,YAAY;EACrBI,MAAM,EAAE;CACR;AAEF;AACa,MAAAC,WAAW,GAA8B;EACpDF,OAAO,EAAEH,YAAY;EACrBI,MAAM,EAAE,GAAG;EACXE,UAAU,EACR;CACF;AAEF;;;;;;AAMG;AACU,MAAAC,YAAY,GAA8B;EACrDJ,OAAO,EAAEH,YAAY;EACrBI,MAAM,EAAE,GAAG;EACXI,IAAI,EAAE;IACJC,UAAU,EAAE,GAAG;IACfC,OAAO,EAAE;EACV;CACD;AAEF;AACa,MAAAC,SAAS,GAA8B;EAClDR,OAAO,EAAEH,YAAY;EACrBI,MAAM,EAAE,GAAG;EACXE,UAAU,EAAE;CACZ;AAEF;AACa,MAAAM,OAAO,GAA8B;EAChDT,OAAO,eAAE,IAAIF,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;EAC3CG,MAAM,EAAE;CACR;AAEF;AACa,MAAAS,SAAS,GAA8B;EAClDV,OAAO,EAAEH,YAAY;EACrBI,MAAM,EAAE;CACR;AAEF;;;;;;AAMG;AACU,MAAAU,iBAAiB,GAA8B;EAC1DX,OAAO,eAAE,IAAIF,GAAG,CAAC,CAAC,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,CAAC;EACxCG,MAAM,EAAE,GAAG;EACXI,IAAI,EAAE;IACJC,UAAU,EAAE,GAAG;IACfC,OAAO,EAAE;EACV;;;;;;;;"}
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ var webFetch = /*#__PURE__*/require('../web-fetch.js');
4
+ var responses = /*#__PURE__*/require('./responses.js');
5
+
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
+ * @returns {Promise<string>} a Promise which resolves to the data resulting
21
+ * from the query, or rejects with an Error
22
+ */
23
+ function fetchFromApi(endpoint, {
24
+ baseUrl = 'https://api.pwnedpasswords.com',
25
+ userAgent
26
+ } = {}) {
27
+ const config = Object.assign({}, userAgent ? {
28
+ headers: {
29
+ 'User-Agent': userAgent
30
+ }
31
+ } : {});
32
+ const url = `${baseUrl.replace(/\/$/g, '')}${endpoint}`;
33
+ return webFetch(url, config).then(res => {
34
+ if (res.ok) return res.text();
35
+ if (res.status === responses.BAD_REQUEST.status) {
36
+ return res.text().then(text => {
37
+ throw new Error(text);
38
+ });
39
+ }
40
+ throw new Error(res.statusText);
41
+ });
42
+ }
43
+ exports.fetchFromApi = fetchFromApi;
44
+ //# sourceMappingURL=fetchFromApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchFromApi.js","sources":["../../../../src/api/pwnedpasswords/fetchFromApi.ts"],"sourcesContent":["import fetch from '../web-fetch';\nimport { BAD_REQUEST } from './responses';\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 * @returns {Promise<string>} a Promise which resolves to the data resulting\n * from the query, or rejects with an Error\n */\nexport function fetchFromApi(\n endpoint: string,\n {\n baseUrl = 'https://api.pwnedpasswords.com',\n userAgent,\n }: { baseUrl?: string; userAgent?: string } = {},\n): Promise<string> {\n const config = Object.assign(\n {},\n userAgent\n ? {\n headers: {\n 'User-Agent': userAgent,\n },\n }\n : {},\n );\n\n const url = `${baseUrl.replace(/\\/$/g, '')}${endpoint}`;\n\n return fetch(url, config).then((res) => {\n if (res.ok) return res.text();\n\n if (res.status === BAD_REQUEST.status) {\n return res.text().then((text) => {\n throw new Error(text);\n });\n }\n\n throw new Error(res.statusText);\n });\n}\n"],"names":["fetchFromApi","endpoint","baseUrl","userAgent","config","Object","assign","headers","url","replace","fetch","then","res","ok","text","status","BAD_REQUEST","Error","statusText"],"mappings":";;;;;AAGA;;;;;;;;;;;;;;;;AAgBG;AACa,SAAAA,YAAYA,CAC1BC,QAAgB,EAChB;EACEC,OAAO,GAAG,gCAAgC;EAC1CC;AAAS,CAAA,GACmC,EAAE,EAAA;EAEhD,MAAMC,MAAM,GAAGC,MAAM,CAACC,MAAM,CAC1B,CAAE,CAAA,EACFH,SAAS,GACL;IACEI,OAAO,EAAE;MACP,YAAY,EAAEJ;IACf;EACF,CAAA,GACD,CAAA,CAAE,CACP;EAED,MAAMK,GAAG,GAAM,GAAAN,OAAO,CAACO,OAAO,CAAC,MAAM,EAAE,EAAE,CAAI,GAAAR,UAAU;EAEvD,OAAOS,QAAK,CAACF,GAAG,EAAEJ,MAAM,CAAC,CAACO,IAAI,CAAEC,GAAG,IAAI;IACrC,IAAIA,GAAG,CAACC,EAAE,EAAE,OAAOD,GAAG,CAACE,IAAI,EAAE;IAE7B,IAAIF,GAAG,CAACG,MAAM,KAAKC,SAAW,CAAAA,WAAA,CAACD,MAAM,EAAE;MACrC,OAAOH,GAAG,CAACE,IAAI,EAAE,CAACH,IAAI,CAAEG,IAAI,IAAI;QAC9B,MAAM,IAAIG,KAAK,CAACH,IAAI,CAAC;MACvB,CAAC,CAAC;IACH;IAED,MAAM,IAAIG,KAAK,CAACL,GAAG,CAACM,UAAU,CAAC;EACjC,CAAC,CAAC;AACJ;"}
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ var fetchFromApi = /*#__PURE__*/require('./fetchFromApi.js');
4
+ exports.fetchFromApi = fetchFromApi.fetchFromApi;
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Known potential responses from the remote API.
5
+ *
6
+ * https://haveibeenpwned.com/api/v3#PwnedPasswords
7
+ *
8
+ */
9
+ /** @internal */
10
+ const OK = {
11
+ status: 200
12
+ };
13
+ /** @internal */
14
+ const BAD_REQUEST = {
15
+ status: 400,
16
+ body: 'The hash prefix was not in a valid format'
17
+ };
18
+ exports.BAD_REQUEST = BAD_REQUEST;
19
+ exports.OK = OK;
20
+ //# sourceMappingURL=responses.js.map
@@ -0,0 +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 interface PwnedPasswordsApiResponse {\n status: number;\n body?: string;\n}\n\n/** @internal */\nexport const OK: PwnedPasswordsApiResponse = {\n status: 200,\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":["OK","status","BAD_REQUEST","body"],"mappings":";;AAAA;;;;;AAKG;AAQH;AACa,MAAAA,EAAE,GAA8B;EAC3CC,MAAM,EAAE;CACR;AAEF;AACa,MAAAC,WAAW,GAA8B;EACpDD,MAAM,EAAE,GAAG;EACXE,IAAI,EAAE;;;"}
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ /* c8 ignore next */
4
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
5
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
6
+ var fetch = typeof window !== 'undefined' ? window.fetch : fetchWrapper;
7
+ async function fetchWrapper(input, init) {
8
+ const {
9
+ default: webFetch
10
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require('@remix-run/web-fetch')));
11
+ return webFetch(input, init);
12
+ }
13
+ module.exports = fetch;
14
+ //# sourceMappingURL=web-fetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-fetch.js","sources":["../../../src/api/web-fetch.ts"],"sourcesContent":["/* c8 ignore next */\nexport default typeof window !== 'undefined' ? window.fetch : fetchWrapper;\n\nasync function fetchWrapper(\n input: string | URL,\n init?: RequestInit | undefined,\n): Promise<Response> {\n const { default: webFetch } = await import('@remix-run/web-fetch');\n return webFetch(input, init);\n}\n"],"names":["_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","_interopRequireWildcard","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","fetch","window","fetchWrapper","input","init","webFetch","Promise","resolve","then","require"],"mappings":";;AAAA;AAAA,SAAAA,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAI,wBAAAC,GAAA,EAAAL,WAAA,SAAAA,WAAA,IAAAK,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAT,wBAAA,CAAAC,WAAA,OAAAQ,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA;AACA,IAAeW,KAAA,GAAA,OAAOC,MAAM,KAAK,WAAW,GAAGA,MAAM,CAACD,KAAK,GAAGE,YAAY;AAE1E,eAAeA,YAAYA,CACzBC,KAAmB,EACnBC,IAA8B,EAAA;EAE9B,MAAM;IAAEnB,OAAO,EAAEoB;EAAU,CAAA,GAAG,MAAAC,OAAA,CAAAC,OAAA,GAAAC,IAAA,OAAA1B,uBAAA,CAAA2B,OAAA,CAAa,sBAAsB,GAAC;EAClE,OAAOJ,QAAQ,CAACF,KAAK,EAAEC,IAAI,CAAC;AAC9B;"}
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetchFromApi.js');
4
+
5
+ /**
6
+ * An object representing a breach.
7
+ *
8
+ * @typedef {object} Breach
9
+ * @property {string} Name
10
+ * @property {string} Title
11
+ * @property {string} Domain
12
+ * @property {string} BreachDate
13
+ * @property {string} AddedDate
14
+ * @property {string} ModifiedDate
15
+ * @property {number} PwnCount
16
+ * @property {string} Description
17
+ * @property {string} LogoPath
18
+ * @property {string[]} DataClasses
19
+ * @property {boolean} IsVerified
20
+ * @property {boolean} IsFabricated
21
+ * @property {boolean} IsSensitive
22
+ * @property {boolean} IsRetired
23
+ * @property {boolean} IsSpamList
24
+ */
25
+ /**
26
+ * Fetches data for a specific breach event.
27
+ *
28
+ * @param {string} breachName the name of a breach in the system
29
+ * @param {object} [options] a configuration object
30
+ * @param {string} [options.baseUrl] a custom base URL for the
31
+ * haveibeenpwned.com API endpoints (default:
32
+ * `https://haveibeenpwned.com/api/v3`)
33
+ * @param {string} [options.userAgent] a custom string to send as the User-Agent
34
+ * field in the request headers (default: `hibp <version>`)
35
+ * @returns {(Promise<Breach>|Promise<null>)} a Promise which resolves to an
36
+ * object representing a breach (or null if no breach was found), or rejects
37
+ * with an Error
38
+ * @example
39
+ * breach('Adobe')
40
+ * .then(data => {
41
+ * if (data) {
42
+ * // ...
43
+ * } else {
44
+ * // ...
45
+ * }
46
+ * })
47
+ * .catch(err => {
48
+ * // ...
49
+ * });
50
+ */
51
+ function breach(breachName, options = {}) {
52
+ return fetchFromApi.fetchFromApi(`/breach/${encodeURIComponent(breachName)}`, options);
53
+ }
54
+ exports.breach = breach;
55
+ //# sourceMappingURL=breach.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breach.js","sources":["../../src/breach.ts"],"sourcesContent":["import type { Breach } from './api/haveibeenpwned/types';\nimport { fetchFromApi } from './api/haveibeenpwned';\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} LogoPath\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 */\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 * breach('Adobe')\n * .then(data => {\n * if (data) {\n * // ...\n * } else {\n * // ...\n * }\n * })\n * .catch(err => {\n * // ...\n * });\n */\nexport function breach(\n breachName: string,\n options: { baseUrl?: string; userAgent?: string } = {},\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;;;;;;;;;;;;;;;;;;;AAmBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;AAyBG;SACaA,MAAMA,CACpBC,UAAkB,EAClBC,UAAoD,EAAE,EAAA;EAEtD,OAAOC,YAAAA,CAAAA,YAAY,CACjB,WAAWC,kBAAkB,CAACH,UAAU,CAAG,EAAA,EAC3CC,OAAO,CACkB;AAC7B;"}
@@ -0,0 +1,101 @@
1
+ 'use strict';
2
+
3
+ var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetchFromApi.js');
4
+
5
+ /**
6
+ * Fetches breach data for a specific account.
7
+ *
8
+ * ***Warning (July 18, 2019):***
9
+ *
10
+ * `haveibeenpwned.com` now requires an API key from
11
+ * https://haveibeenpwned.com/API/Key for the `breachedaccount` endpoint. The
12
+ * `apiKey` option here is not explicitly required, but direct requests made
13
+ * without it (that is, without specifying a `baseUrl` to a proxy that inserts a
14
+ * valid API key on your behalf) will fail.
15
+ *
16
+ * @param {string} account a username or email address
17
+ * @param {object} [options] a configuration object
18
+ * @param {string} [options.apiKey] an API key from
19
+ * https://haveibeenpwned.com/API/Key (default: undefined)
20
+ * @param {string} [options.domain] a domain by which to filter the results
21
+ * (default: all domains)
22
+ * @param {boolean} [options.includeUnverified] include "unverified" breaches in
23
+ * the results (default: true)
24
+ * @param {boolean} [options.truncate] truncate the results to only include
25
+ * the name of each breach (default: true)
26
+ * @param {string} [options.baseUrl] a custom base URL for the
27
+ * haveibeenpwned.com API endpoints (default:
28
+ * `https://haveibeenpwned.com/api/v3`)
29
+ * @param {string} [options.userAgent] a custom string to send as the User-Agent
30
+ * field in the request headers (default: `hibp <version>`)
31
+ * @returns {(Promise<Breach[]> | Promise<null>)} a Promise which resolves to an
32
+ * array of breach objects (or null if no breaches were found), or rejects with
33
+ * an Error
34
+ * @example
35
+ * breachedAccount('foo', { apiKey: 'my-api-key' })
36
+ * .then(data => {
37
+ * if (data) {
38
+ * // ...
39
+ * } else {
40
+ * // ...
41
+ * }
42
+ * })
43
+ * .catch(err => {
44
+ * // ...
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 => {
59
+ * // ...
60
+ * });
61
+ * @example
62
+ * breachedAccount('baz', {
63
+ * apiKey: 'my-api-key',
64
+ * domain: 'adobe.com',
65
+ * truncate: false,
66
+ * userAgent: 'my-app 1.0'
67
+ * })
68
+ * .then(data => {
69
+ * if (data) {
70
+ * // ...
71
+ * } else {
72
+ * // ...
73
+ * }
74
+ * })
75
+ * .catch(err => {
76
+ * // ...
77
+ * });
78
+ */
79
+ function breachedAccount(account, options = {
80
+ includeUnverified: true,
81
+ truncate: true
82
+ }) {
83
+ const endpoint = `/breachedaccount/${encodeURIComponent(account)}?`;
84
+ const params = [];
85
+ if (options.domain) {
86
+ params.push(`domain=${encodeURIComponent(options.domain)}`);
87
+ }
88
+ if (options.includeUnverified === false) {
89
+ params.push('includeUnverified=false');
90
+ }
91
+ if (options.truncate === false) {
92
+ params.push('truncateResponse=false');
93
+ }
94
+ return fetchFromApi.fetchFromApi(`${endpoint}${params.join('&')}`, {
95
+ apiKey: options.apiKey,
96
+ baseUrl: options.baseUrl,
97
+ userAgent: options.userAgent
98
+ });
99
+ }
100
+ exports.breachedAccount = breachedAccount;
101
+ //# sourceMappingURL=breachedAccount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breachedAccount.js","sources":["../../src/breachedAccount.ts"],"sourcesContent":["import type { Breach } from './api/haveibeenpwned/types';\nimport { fetchFromApi } from './api/haveibeenpwned';\n\n/**\n * Fetches breach data for a specific account.\n *\n * ***Warning (July 18, 2019):***\n *\n * `haveibeenpwned.com` now 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 (that is, without specifying a `baseUrl` to a proxy that inserts a\n * valid API key on your behalf) will fail.\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 * breachedAccount('foo', { apiKey: 'my-api-key' })\n * .then(data => {\n * if (data) {\n * // ...\n * } else {\n * // ...\n * }\n * })\n * .catch(err => {\n * // ...\n * });\n * @example\n * breachedAccount('bar', {\n * includeUnverified: false,\n * baseUrl: 'https://my-hibp-proxy:8080',\n * })\n * .then(data => {\n * if (data) {\n * // ...\n * } else {\n * // ...\n * }\n * })\n * .catch(err => {\n * // ...\n * });\n * @example\n * breachedAccount('baz', {\n * apiKey: 'my-api-key',\n * domain: 'adobe.com',\n * truncate: false,\n * userAgent: 'my-app 1.0'\n * })\n * .then(data => {\n * if (data) {\n * // ...\n * } else {\n * // ...\n * }\n * })\n * .catch(err => {\n * // ...\n * });\n */\nexport function breachedAccount(\n account: string,\n options: {\n apiKey?: string;\n domain?: string;\n includeUnverified?: boolean;\n truncate?: boolean;\n baseUrl?: string;\n userAgent?: string;\n } = {\n includeUnverified: true,\n truncate: true,\n },\n): Promise<Breach[] | null> {\n const endpoint = `/breachedaccount/${encodeURIComponent(account)}?`;\n const params: Array<string> = [];\n if (options.domain) {\n params.push(`domain=${encodeURIComponent(options.domain)}`);\n }\n if (options.includeUnverified === false) {\n params.push('includeUnverified=false');\n }\n if (options.truncate === false) {\n params.push('truncateResponse=false');\n }\n return fetchFromApi(`${endpoint}${params.join('&')}`, {\n apiKey: options.apiKey,\n baseUrl: options.baseUrl,\n userAgent: options.userAgent,\n }) as Promise<Breach[] | null>;\n}\n"],"names":["breachedAccount","account","options","includeUnverified","truncate","endpoint","encodeURIComponent","params","domain","push","fetchFromApi","join","apiKey","baseUrl","userAgent"],"mappings":";;;;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEG;AACa,SAAAA,eAAeA,CAC7BC,OAAe,EACfC,OAOI,GAAA;EACFC,iBAAiB,EAAE,IAAI;EACvBC,QAAQ,EAAE;AACX,CAAA,EAAA;EAED,MAAMC,QAAQ,GAAuB,oBAAAC,kBAAkB,CAACL,OAAO,IAAI;EACnE,MAAMM,MAAM,GAAkB,EAAE;EAChC,IAAIL,OAAO,CAACM,MAAM,EAAE;IAClBD,MAAM,CAACE,IAAI,CAAC,UAAUH,kBAAkB,CAACJ,OAAO,CAACM,MAAM,CAAG,EAAA,CAAC;EAC5D;EACD,IAAIN,OAAO,CAACC,iBAAiB,KAAK,KAAK,EAAE;IACvCI,MAAM,CAACE,IAAI,CAAC,yBAAyB,CAAC;EACvC;EACD,IAAIP,OAAO,CAACE,QAAQ,KAAK,KAAK,EAAE;IAC9BG,MAAM,CAACE,IAAI,CAAC,wBAAwB,CAAC;EACtC;EACD,OAAOC,YAAY,CAAAA,YAAA,CAAI,GAAAL,QAAW,GAAAE,MAAM,CAACI,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;IACpDC,MAAM,EAAEV,OAAO,CAACU,MAAM;IACtBC,OAAO,EAAEX,OAAO,CAACW,OAAO;IACxBC,SAAS,EAAEZ,OAAO,CAACY;EACpB,CAAA,CAA6B;AAChC;"}
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetchFromApi.js');
4
+
5
+ /**
6
+ * Fetches all breach events in the system.
7
+ *
8
+ * @param {object} [options] a configuration object
9
+ * @param {string} [options.domain] a domain by which to filter the results
10
+ * (default: all domains)
11
+ * @param {string} [options.baseUrl] a custom base URL for the
12
+ * haveibeenpwned.com API endpoints (default:
13
+ * `https://haveibeenpwned.com/api/v3`)
14
+ * @param {string} [options.userAgent] a custom string to send as the User-Agent
15
+ * field in the request headers (default: `hibp <version>`)
16
+ * @returns {Promise<Breach[]>} a Promise which resolves to an array of breach
17
+ * objects (an empty array if no breaches were found), or rejects with an Error
18
+ * @example
19
+ * breaches()
20
+ * .then(data => {
21
+ * if (data) {
22
+ * // ...
23
+ * } else {
24
+ * // ...
25
+ * }
26
+ * })
27
+ * .catch(err => {
28
+ * // ...
29
+ * });
30
+ * @example
31
+ * breaches({ domain: 'adobe.com' })
32
+ * .then(data => {
33
+ * if (data) {
34
+ * // ...
35
+ * } else {
36
+ * // ...
37
+ * }
38
+ * })
39
+ * .catch(err => {
40
+ * // ...
41
+ * });
42
+ */
43
+ function breaches(options = {}) {
44
+ const endpoint = '/breaches?';
45
+ const params = [];
46
+ if (options.domain) {
47
+ params.push(`domain=${encodeURIComponent(options.domain)}`);
48
+ }
49
+ return fetchFromApi.fetchFromApi(`${endpoint}${params.join('&')}`, {
50
+ baseUrl: options.baseUrl,
51
+ userAgent: options.userAgent
52
+ });
53
+ }
54
+ exports.breaches = breaches;
55
+ //# sourceMappingURL=breaches.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breaches.js","sources":["../../src/breaches.ts"],"sourcesContent":["import type { Breach } from './api/haveibeenpwned/types';\nimport { fetchFromApi } from './api/haveibeenpwned';\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 * breaches()\n * .then(data => {\n * if (data) {\n * // ...\n * } else {\n * // ...\n * }\n * })\n * .catch(err => {\n * // ...\n * });\n * @example\n * breaches({ domain: 'adobe.com' })\n * .then(data => {\n * if (data) {\n * // ...\n * } else {\n * // ...\n * }\n * })\n * .catch(err => {\n * // ...\n * });\n */\nexport function breaches(\n options: {\n domain?: string;\n baseUrl?: string;\n userAgent?: string;\n } = {},\n): Promise<Breach[]> {\n const endpoint = '/breaches?';\n const params: Array<string> = [];\n if (options.domain) {\n params.push(`domain=${encodeURIComponent(options.domain)}`);\n }\n return fetchFromApi(`${endpoint}${params.join('&')}`, {\n baseUrl: options.baseUrl,\n userAgent: options.userAgent,\n }) as Promise<Breach[]>;\n}\n"],"names":["breaches","options","endpoint","params","domain","push","encodeURIComponent","fetchFromApi","join","baseUrl","userAgent"],"mappings":";;;;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCG;AACa,SAAAA,QAAQA,CACtBC,OAAA,GAII,EAAE,EAAA;EAEN,MAAMC,QAAQ,GAAG,YAAY;EAC7B,MAAMC,MAAM,GAAkB,EAAE;EAChC,IAAIF,OAAO,CAACG,MAAM,EAAE;IAClBD,MAAM,CAACE,IAAI,CAAC,UAAUC,kBAAkB,CAACL,OAAO,CAACG,MAAM,CAAG,EAAA,CAAC;EAC5D;EACD,OAAOG,YAAY,CAAAA,YAAA,CAAI,GAAAL,QAAW,GAAAC,MAAM,CAACK,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;IACpDC,OAAO,EAAER,OAAO,CAACQ,OAAO;IACxBC,SAAS,EAAET,OAAO,CAACS;EACpB,CAAA,CAAsB;AACzB;"}
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ var fetchFromApi = /*#__PURE__*/require('./api/haveibeenpwned/fetchFromApi.js');
4
+
5
+ /**
6
+ * Fetches all data classes in the system.
7
+ *
8
+ * @param {object} [options] a configuration object
9
+ * @param {string} [options.baseUrl] a custom base URL for the
10
+ * haveibeenpwned.com API endpoints (default:
11
+ * `https://haveibeenpwned.com/api/v3`)
12
+ * @param {string} [options.userAgent] a custom string to send as the User-Agent
13
+ * field in the request headers (default: `hibp <version>`)
14
+ * @returns {(Promise<string[]> | Promise<null>)} a Promise which resolves to an
15
+ * array of strings (or null if no data classes were found), or rejects with an
16
+ * Error
17
+ * @example
18
+ * dataClasses()
19
+ * .then(data => {
20
+ * if (data) {
21
+ * // ...
22
+ * } else {
23
+ * // ...
24
+ * }
25
+ * })
26
+ * .catch(err => {
27
+ * // ...
28
+ * });
29
+ */
30
+ function dataClasses(options = {}) {
31
+ return fetchFromApi.fetchFromApi('/dataclasses', options);
32
+ }
33
+ exports.dataClasses = dataClasses;
34
+ //# sourceMappingURL=dataClasses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataClasses.js","sources":["../../src/dataClasses.ts"],"sourcesContent":["import { fetchFromApi } from './api/haveibeenpwned';\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 * dataClasses()\n * .then(data => {\n * if (data) {\n * // ...\n * } else {\n * // ...\n * }\n * })\n * .catch(err => {\n * // ...\n * });\n */\nexport function dataClasses(\n options: { baseUrl?: string; userAgent?: string } = {},\n): Promise<string[] | null> {\n return fetchFromApi('/dataclasses', options) as Promise<string[] | null>;\n}\n"],"names":["dataClasses","options","fetchFromApi"],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AACa,SAAAA,WAAWA,CACzBC,OAAA,GAAoD,EAAE,EAAA;EAEtD,OAAOC,YAAY,CAAAA,YAAA,CAAC,cAAc,EAAED,OAAO,CAA6B;AAC1E;"}