hibp 15.2.1 → 16.0.1

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 (91) hide show
  1. package/API.md +433 -126
  2. package/CHANGELOG.md +52 -0
  3. package/MIGRATION.md +7 -5
  4. package/README.md +53 -27
  5. package/dist/browser/hibp.module.js +2 -2
  6. package/dist/esm/api/base-fetch.d.ts +9 -5
  7. package/dist/esm/api/base-fetch.js +17 -10
  8. package/dist/esm/api/base-fetch.js.map +1 -1
  9. package/dist/esm/api/haveibeenpwned/fetch-from-api.d.ts +1 -1
  10. package/dist/esm/api/haveibeenpwned/fetch-from-api.js +62 -44
  11. package/dist/esm/api/haveibeenpwned/fetch-from-api.js.map +1 -1
  12. package/dist/esm/api/haveibeenpwned/package-info.d.ts +1 -1
  13. package/dist/esm/api/haveibeenpwned/package-info.js +1 -1
  14. package/dist/esm/api/haveibeenpwned/post-to-api.d.ts +1 -0
  15. package/dist/esm/api/haveibeenpwned/post-to-api.js +23 -0
  16. package/dist/esm/api/haveibeenpwned/post-to-api.js.map +1 -0
  17. package/dist/esm/api/haveibeenpwned/responses.d.ts +0 -10
  18. package/dist/esm/api/haveibeenpwned/responses.js +5 -36
  19. package/dist/esm/api/haveibeenpwned/responses.js.map +1 -1
  20. package/dist/esm/api/haveibeenpwned/types.d.ts +22 -2
  21. package/dist/esm/api/haveibeenpwned/types.js +0 -3
  22. package/dist/esm/api/haveibeenpwned/types.js.map +1 -1
  23. package/dist/esm/api/pwnedpasswords/fetch-from-api.js +5 -28
  24. package/dist/esm/api/pwnedpasswords/fetch-from-api.js.map +1 -1
  25. package/dist/esm/api/pwnedpasswords/responses.d.ts +0 -6
  26. package/dist/esm/api/pwnedpasswords/responses.js +1 -7
  27. package/dist/esm/api/pwnedpasswords/responses.js.map +1 -1
  28. package/dist/esm/breach.d.ts +12 -5
  29. package/dist/esm/breach.js +8 -1
  30. package/dist/esm/breach.js.map +1 -1
  31. package/dist/esm/breached-account-range.d.ts +73 -0
  32. package/dist/esm/breached-account-range.js +60 -0
  33. package/dist/esm/breached-account-range.js.map +1 -0
  34. package/dist/esm/breached-account.d.ts +56 -45
  35. package/dist/esm/breached-account.js +4 -76
  36. package/dist/esm/breached-account.js.map +1 -1
  37. package/dist/esm/breached-domain.d.ts +7 -8
  38. package/dist/esm/breached-domain.js +2 -3
  39. package/dist/esm/breached-domain.js.map +1 -1
  40. package/dist/esm/breaches.d.ts +14 -7
  41. package/dist/esm/breaches.js +10 -5
  42. package/dist/esm/breaches.js.map +1 -1
  43. package/dist/esm/data-class-descriptions.d.ts +55 -0
  44. package/dist/esm/data-class-descriptions.js +39 -0
  45. package/dist/esm/data-class-descriptions.js.map +1 -0
  46. package/dist/esm/data-classes.d.ts +4 -4
  47. package/dist/esm/data-classes.js +2 -2
  48. package/dist/esm/data-classes.js.map +1 -1
  49. package/dist/esm/generate-dns-token.d.ts +67 -0
  50. package/dist/esm/generate-dns-token.js +49 -0
  51. package/dist/esm/generate-dns-token.js.map +1 -0
  52. package/dist/esm/hibp.d.ts +28 -18
  53. package/dist/esm/hibp.js +22 -28
  54. package/dist/esm/hibp.js.map +1 -1
  55. package/dist/esm/latest-breach.d.ts +5 -5
  56. package/dist/esm/latest-breach.js +2 -2
  57. package/dist/esm/latest-breach.js.map +1 -1
  58. package/dist/esm/paste-account.d.ts +13 -13
  59. package/dist/esm/paste-account.js +8 -8
  60. package/dist/esm/paste-account.js.map +1 -1
  61. package/dist/esm/pwned-password-range.d.ts +6 -6
  62. package/dist/esm/pwned-password-range.js +4 -6
  63. package/dist/esm/pwned-password-range.js.map +1 -1
  64. package/dist/esm/pwned-password.d.ts +5 -5
  65. package/dist/esm/pwned-password.js +12 -7
  66. package/dist/esm/pwned-password.js.map +1 -1
  67. package/dist/esm/search.d.ts +57 -40
  68. package/dist/esm/search.js +5 -74
  69. package/dist/esm/search.js.map +1 -1
  70. package/dist/esm/send-email.d.ts +69 -0
  71. package/dist/esm/send-email.js +49 -0
  72. package/dist/esm/send-email.js.map +1 -0
  73. package/dist/esm/stealer-logs-by-email-domain.d.ts +13 -14
  74. package/dist/esm/stealer-logs-by-email-domain.js +8 -9
  75. package/dist/esm/stealer-logs-by-email-domain.js.map +1 -1
  76. package/dist/esm/stealer-logs-by-email.d.ts +9 -10
  77. package/dist/esm/stealer-logs-by-email.js +5 -6
  78. package/dist/esm/stealer-logs-by-email.js.map +1 -1
  79. package/dist/esm/stealer-logs-by-website-domain.d.ts +9 -10
  80. package/dist/esm/stealer-logs-by-website-domain.js +5 -6
  81. package/dist/esm/stealer-logs-by-website-domain.js.map +1 -1
  82. package/dist/esm/subscribed-domains.d.ts +7 -8
  83. package/dist/esm/subscribed-domains.js +4 -5
  84. package/dist/esm/subscribed-domains.js.map +1 -1
  85. package/dist/esm/subscription-status.d.ts +16 -11
  86. package/dist/esm/subscription-status.js +13 -8
  87. package/dist/esm/subscription-status.js.map +1 -1
  88. package/dist/esm/verify-dns-token.d.ts +60 -0
  89. package/dist/esm/verify-dns-token.js +41 -0
  90. package/dist/esm/verify-dns-token.js.map +1 -0
  91. package/package.json +55 -56
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-to-api.js","sourceRoot":"","sources":["../../../../src/api/haveibeenpwned/post-to-api.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,UAAU,EACV,UAAU,GAEX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAE9D,gBAAgB;AAChB,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,QAAgB,EAChB,IAA4B,EAC5B,OAAoB;IAEpB,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAE3D,IAAI,QAAQ,CAAC,EAAE;QAAE,OAAO,QAAQ,CAAC;IAEjC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC;IACrC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACpC,MAAM,WAAW,GAAG,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC;IAE9E,MAAM,OAAO,GACX,WAAW,CAAC,IAAI,CAAC;QACjB,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM,IAAI,KAAK;YACnC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC;YACzB,CAAC,CAAC,SAAS,CAAC;QACd,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QAC/C,UAAU,CAAC,QAAQ,CAAC,CAAC;IAEvB,IAAI,MAAM,KAAK,iBAAiB,CAAC,MAAM,EAAE,CAAC;QACxC,MAAM,IAAI,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC"}
@@ -1,11 +1 @@
1
- /**
2
- * Known potential responses from the remote API.
3
- *
4
- * Unfortunately, the API does not send a decent human-readable message back with each response, but
5
- * they are documented on the website: https://haveibeenpwned.com/api/v3#ResponseCodes
6
- *
7
- * These objects simply provide a mapping between the HTTP response status code and the
8
- * corresponding human-readable message so we can throw a more descriptive error for the consumer.
9
- * (They are also leveraged in our tests.)
10
- */
11
1
  export {};
@@ -1,55 +1,24 @@
1
- /**
2
- * Known potential responses from the remote API.
3
- *
4
- * Unfortunately, the API does not send a decent human-readable message back with each response, but
5
- * they are documented on the website: https://haveibeenpwned.com/api/v3#ResponseCodes
6
- *
7
- * These objects simply provide a mapping between the HTTP response status code and the
8
- * corresponding human-readable message so we can throw a more descriptive error for the consumer.
9
- * (They are also leveraged in our tests.)
10
- */
11
1
  /** @internal */
12
2
  export const BAD_REQUEST = {
13
3
  status: 400,
14
- statusText: 'Bad request — the account does not comply with an acceptable format.',
4
+ statusText: "Bad request — the account does not comply with an acceptable format.",
15
5
  };
16
- /**
17
- * The API includes a human-readable error message as text in the body of this
18
- * response type. Manually populating the message here purely for use in tests.
19
- *
20
- * @internal
21
- */
6
+ /** @internal */
22
7
  export const UNAUTHORIZED = {
23
8
  status: 401,
24
- body: `Your request to the API couldn't be authorised. Check you have the right value in the "hibp-api-key" header, refer to the documentation for more: https://haveibeenpwned.com/API/v3#Authorisation`,
25
9
  };
26
10
  /** @internal */
27
11
  export const FORBIDDEN = {
28
12
  status: 403,
29
- statusText: 'Forbidden - access denied.',
30
- };
31
- /** @internal */
32
- export const BLOCKED = {
33
- headers: new Map([['cf-ray', 'someRayId']]),
34
- status: 403,
13
+ statusText: "Forbidden - access denied.",
35
14
  };
36
15
  /** @internal */
37
16
  export const NOT_FOUND = {
38
17
  status: 404,
18
+ statusText: "Not found.",
39
19
  };
40
- /**
41
- * The API includes a JSON object containing a human-readable message in the
42
- * body of this response type. Manually populating the message here purely for
43
- * use in tests.
44
- *
45
- * @internal
46
- */
20
+ /** @internal */
47
21
  export const TOO_MANY_REQUESTS = {
48
- headers: new Map([['retry-after', '2']]),
49
22
  status: 429,
50
- body: {
51
- statusCode: 429,
52
- message: 'Rate limit is exceeded. Try again in 2 seconds.',
53
- },
54
23
  };
55
24
  //# sourceMappingURL=responses.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"responses.js","sourceRoot":"","sources":["../../../../src/api/haveibeenpwned/responses.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,gBAAgB;AAChB,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,MAAM,EAAE,GAAY;IACpB,UAAU,EAAE,sEAAsE;CACnF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,MAAM,EAAE,GAAY;IACpB,IAAI,EAAE,mMAAmM;CAC1M,CAAC;AAEF,gBAAgB;AAChB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,MAAM,EAAE,GAAY;IACpB,UAAU,EAAE,4BAA4B;CACzC,CAAC;AAEF,gBAAgB;AAChB,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;IAC3C,MAAM,EAAE,GAAY;CACrB,CAAC;AAEF,gBAAgB;AAChB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,MAAM,EAAE,GAAY;CACrB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,CAAC;IACxC,MAAM,EAAE,GAAY;IACpB,IAAI,EAAE;QACJ,UAAU,EAAE,GAAY;QACxB,OAAO,EAAE,iDAAiD;KAC3D;CACF,CAAC"}
1
+ {"version":3,"file":"responses.js","sourceRoot":"","sources":["../../../../src/api/haveibeenpwned/responses.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,MAAM,EAAE,GAAY;IACpB,UAAU,EACR,sEAAsE;CACzE,CAAC;AAEF,gBAAgB;AAChB,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,MAAM,EAAE,GAAY;CACrB,CAAC;AAEF,gBAAgB;AAChB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,MAAM,EAAE,GAAY;IACpB,UAAU,EAAE,4BAA4B;CACzC,CAAC;AAEF,gBAAgB;AAChB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,MAAM,EAAE,GAAY;IACpB,UAAU,EAAE,YAAY;CACzB,CAAC;AAEF,gBAAgB;AAChB,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,MAAM,EAAE,GAAY;CACrB,CAAC"}
@@ -14,23 +14,35 @@ export interface Breach {
14
14
  IsRetired: boolean;
15
15
  IsSpamList: boolean;
16
16
  IsMalware: boolean;
17
+ IsStealerLog: boolean;
17
18
  IsSubscriptionFree: boolean;
18
19
  LogoPath: string;
20
+ Attribution: string | null;
21
+ DisclosureUrl: string | null;
19
22
  }
20
23
  export interface Paste {
21
24
  Id: string;
22
25
  Source: string;
23
- Title: string;
24
- Date: string;
26
+ Title?: string;
27
+ Date: string | null;
25
28
  EmailCount: number;
26
29
  }
30
+ export interface DataClassDescription {
31
+ name: string;
32
+ description: string;
33
+ }
27
34
  export interface SubscriptionStatus {
28
35
  SubscriptionName: string;
29
36
  Description: string;
30
37
  SubscribedUntil: string;
31
38
  Rpm: number;
32
39
  DomainSearchMaxBreachedAccounts: number;
40
+ MaxBreachedDomains: number | null;
33
41
  IncludesStealerLogs: boolean;
42
+ IncludesBulkDomainAdd: boolean;
43
+ IncludesAutoSubdomainVerification: boolean;
44
+ IncludesCustomerDomains: boolean;
45
+ IncludesKAnon: boolean;
34
46
  }
35
47
  export interface SubscribedDomain {
36
48
  DomainName: string;
@@ -39,5 +51,13 @@ export interface SubscribedDomain {
39
51
  PwnCountExcludingSpamListsAtLastSubscriptionRenewal: number | null;
40
52
  NextSubscriptionRenewal: string | null;
41
53
  }
54
+ export interface DnsToken {
55
+ txtRecordValue: string;
56
+ }
57
+ export type EmailAlias = "admin" | "hostmaster" | "info" | "security" | "webmaster";
42
58
  export type BreachedDomainsByEmailAlias = Record<string, string[]>;
59
+ export interface BreachedAccountRangeResult {
60
+ hashSuffix: string;
61
+ websites: string[];
62
+ }
43
63
  export type StealerLogDomainsByEmailAlias = Record<string, string[]>;
@@ -1,5 +1,2 @@
1
- //
2
- // Data Models from the API
3
- //
4
1
  export {};
5
2
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/haveibeenpwned/types.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,2BAA2B;AAC3B,EAAE"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/haveibeenpwned/types.ts"],"names":[],"mappings":""}
@@ -1,34 +1,11 @@
1
- import { baseFetch } from '../base-fetch.js';
2
- import { BAD_REQUEST } from './responses.js';
3
- /**
4
- * Fetches data from the supplied API endpoint.
5
- *
6
- * HTTP status code 200 returns plain text (data found).
7
- * HTTP status code 400 throws an Error (bad request).
8
- *
9
- * @internal
10
- * @private
11
- * @param {string} endpoint the API endpoint to query
12
- * @param {object} [options] a configuration object
13
- * @param {string} [options.baseUrl] a custom base URL for the
14
- * pwnedpasswords.com API endpoints (default: `https://api.pwnedpasswords.com`)
15
- * @param {number} [options.timeoutMs] timeout for the request in milliseconds
16
- * (default: none)
17
- * @param {AbortSignal} [options.signal] an AbortSignal to cancel the request (default: none)
18
- * @param {string} [options.userAgent] a custom string to send as the User-Agent
19
- * field in the request headers (default: `hibp <version>`)
20
- * @param {boolean} [options.addPadding] ask the remote API to add padding to
21
- * the response to obscure the password prefix (default: `false`)
22
- * @param {'sha1' | 'ntlm'} [options.mode] return SHA-1 or NTLM hashes
23
- * (default: `sha1`)
24
- * @returns {Promise<string>} a Promise which resolves to the data resulting
25
- * from the query, or rejects with an Error
26
- */
1
+ import { baseFetch } from "../base-fetch.js";
2
+ import { BAD_REQUEST } from "./responses.js";
3
+ /** @internal */
27
4
  export async function fetchFromApi(endpoint, options = {}) {
28
- const { baseUrl = 'https://api.pwnedpasswords.com', timeoutMs, signal, userAgent, addPadding = false, mode = 'sha1', } = options;
5
+ const { baseUrl = "https://api.pwnedpasswords.com", timeoutMs, signal, userAgent, addPadding = false, mode = "sha1", } = options;
29
6
  const headers = {};
30
7
  if (addPadding)
31
- headers['Add-Padding'] = 'true';
8
+ headers["Add-Padding"] = "true";
32
9
  const response = await baseFetch({
33
10
  baseUrl,
34
11
  endpoint,
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-from-api.js","sourceRoot":"","sources":["../../../../src/api/pwnedpasswords/fetch-from-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAgB,EAChB,UAOI,EAAE;IAEN,MAAM,EACJ,OAAO,GAAG,gCAAgC,EAC1C,SAAS,EACT,MAAM,EACN,SAAS,EACT,UAAU,GAAG,KAAK,EAClB,IAAI,GAAG,MAAM,GACd,GAAG,OAAO,CAAC;IAEZ,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,IAAI,UAAU;QAAE,OAAO,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC;IAEhD,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC;QAC/B,OAAO;QACP,QAAQ;QACR,OAAO;QACP,SAAS;QACT,MAAM;QACN,SAAS;QACT,WAAW,EAAE,EAAE,IAAI,EAAE;KACtB,CAAC,CAAC;IAEH,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"}
1
+ {"version":3,"file":"fetch-from-api.js","sourceRoot":"","sources":["../../../../src/api/pwnedpasswords/fetch-from-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,gBAAgB;AAChB,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAgB,EAChB,OAAO,GAOH,EAAE;IAEN,MAAM,EACJ,OAAO,GAAG,gCAAgC,EAC1C,SAAS,EACT,MAAM,EACN,SAAS,EACT,UAAU,GAAG,KAAK,EAClB,IAAI,GAAG,MAAM,GACd,GAAG,OAAO,CAAC;IAEZ,MAAM,OAAO,GAA2B,EAAE,CAAC;IAE3C,IAAI,UAAU;QAAE,OAAO,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC;IAEhD,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC;QAC/B,OAAO;QACP,QAAQ;QACR,OAAO;QACP,SAAS;QACT,MAAM;QACN,SAAS;QACT,WAAW,EAAE,EAAE,IAAI,EAAE;KACtB,CAAC,CAAC;IAEH,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"}
@@ -1,7 +1 @@
1
- /**
2
- * Known potential responses from the remote API.
3
- *
4
- * https://haveibeenpwned.com/api/v3#PwnedPasswords
5
- *
6
- */
7
1
  export {};
@@ -1,12 +1,6 @@
1
- /**
2
- * Known potential responses from the remote API.
3
- *
4
- * https://haveibeenpwned.com/api/v3#PwnedPasswords
5
- *
6
- */
7
1
  /** @internal */
8
2
  export const BAD_REQUEST = {
9
3
  status: 400,
10
- body: 'The hash prefix was not in a valid format',
4
+ body: "The hash prefix was not in a valid format",
11
5
  };
12
6
  //# sourceMappingURL=responses.js.map
@@ -1 +1 @@
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
+ {"version":3,"file":"responses.js","sourceRoot":"","sources":["../../../../src/api/pwnedpasswords/responses.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,MAAM,EAAE,GAAY;IACpB,IAAI,EAAE,2CAA2C;CAClD,CAAC"}
@@ -1,7 +1,11 @@
1
- import type { Breach } from './api/haveibeenpwned/types.js';
1
+ import type { Breach } from "./api/haveibeenpwned/types.js";
2
2
  /**
3
3
  * An object representing a breach.
4
4
  *
5
+ * `Attribution` and `DisclosureUrl` may be null. See the
6
+ * [breach model](https://haveibeenpwned.com/API/v3#BreachModel) and the
7
+ * [breach catalogue](https://haveibeenpwned.com/api/v3/breaches).
8
+ *
5
9
  * @typedef {object} Breach
6
10
  * @property {string} Name
7
11
  * @property {string} Title
@@ -18,8 +22,11 @@ import type { Breach } from './api/haveibeenpwned/types.js';
18
22
  * @property {boolean} IsRetired
19
23
  * @property {boolean} IsSpamList
20
24
  * @property {boolean} IsMalware
25
+ * @property {boolean} IsStealerLog whether the breach is sourced from stealer logs
21
26
  * @property {boolean} IsSubscriptionFree
22
27
  * @property {string} LogoPath
28
+ * @property {(string | null)} Attribution credit requested by the data provider, or null
29
+ * @property {(string | null)} DisclosureUrl breach disclosure URL, or null
23
30
  */
24
31
  /**
25
32
  * Fetches data for a specific breach event.
@@ -54,18 +61,18 @@ export declare function breach(breachName: string, options?: {
54
61
  * a custom base URL for the haveibeenpwned.com API endpoints (default:
55
62
  * `https://haveibeenpwned.com/api/v3`)
56
63
  */
57
- baseUrl?: string;
64
+ baseUrl?: string | undefined;
58
65
  /**
59
66
  * timeout for the request in milliseconds (default: none)
60
67
  */
61
- timeoutMs?: number;
68
+ timeoutMs?: number | undefined;
62
69
  /**
63
70
  * an AbortSignal to cancel the request (default: none)
64
71
  */
65
- signal?: AbortSignal;
72
+ signal?: AbortSignal | undefined;
66
73
  /**
67
74
  * a custom string to send as the User-Agent field in the request headers
68
75
  * (default: `hibp <version>`)
69
76
  */
70
- userAgent?: string;
77
+ userAgent?: string | undefined;
71
78
  }): Promise<Breach | null>;
@@ -1,7 +1,11 @@
1
- import { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';
1
+ import { fetchFromApi } from "./api/haveibeenpwned/fetch-from-api.js";
2
2
  /**
3
3
  * An object representing a breach.
4
4
  *
5
+ * `Attribution` and `DisclosureUrl` may be null. See the
6
+ * [breach model](https://haveibeenpwned.com/API/v3#BreachModel) and the
7
+ * [breach catalogue](https://haveibeenpwned.com/api/v3/breaches).
8
+ *
5
9
  * @typedef {object} Breach
6
10
  * @property {string} Name
7
11
  * @property {string} Title
@@ -18,8 +22,11 @@ import { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';
18
22
  * @property {boolean} IsRetired
19
23
  * @property {boolean} IsSpamList
20
24
  * @property {boolean} IsMalware
25
+ * @property {boolean} IsStealerLog whether the breach is sourced from stealer logs
21
26
  * @property {boolean} IsSubscriptionFree
22
27
  * @property {string} LogoPath
28
+ * @property {(string | null)} Attribution credit requested by the data provider, or null
29
+ * @property {(string | null)} DisclosureUrl breach disclosure URL, or null
23
30
  */
24
31
  /**
25
32
  * Fetches data for a specific breach event.
@@ -1 +1 @@
1
- {"version":3,"file":"breach.js","sourceRoot":"","sources":["../../src/breach.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,MAAM,CACpB,UAAkB,EAClB,UAmBI,EAAE;IAEN,OAAO,YAAY,CACjB,WAAW,kBAAkB,CAAC,UAAU,CAAC,EAAE,EAC3C,OAAO,CACkB,CAAC;AAC9B,CAAC"}
1
+ {"version":3,"file":"breach.js","sourceRoot":"","sources":["../../src/breach.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,MAAM,CACpB,UAAkB,EAClB,OAAO,GAmBH,EAAE;IAEN,OAAO,YAAY,CACjB,WAAW,kBAAkB,CAAC,UAAU,CAAC,EAAE,EAC3C,OAAO,CACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,73 @@
1
+ import type { BreachedAccountRangeResult } from "./api/haveibeenpwned/types.js";
2
+ /**
3
+ * A breached email hash suffix and the breach names associated with it.
4
+ *
5
+ * @typedef {Object} BreachedAccountRangeResult
6
+ * @property {string} hashSuffix the remaining 34 characters of a SHA-1 email hash
7
+ * @property {string[]} websites breach names, not website domains or URLs
8
+ */
9
+ /**
10
+ * Fetches breached email hash suffixes for a six-character SHA-1 email hash
11
+ * prefix.
12
+ *
13
+ * Requires a Pro or High RPM API key from https://haveibeenpwned.com/API/Key.
14
+ * The `apiKey` option here is not explicitly required, but direct requests made
15
+ * without it will fail (unless you specify a `baseUrl` to a proxy that inserts
16
+ * a valid API key on your behalf).
17
+ *
18
+ * Compare suffixes locally against the intended email hash. Per the
19
+ * haveibeenpwned.com terms of use, discard unrelated results immediately
20
+ * without storing or further processing them.
21
+ *
22
+ * @param {string} prefix the first six characters of a SHA-1 email hash
23
+ * (case-insensitive)
24
+ * @param {object} [options] a configuration object
25
+ * @param {string} [options.apiKey] an API key from
26
+ * https://haveibeenpwned.com/API/Key (default: undefined)
27
+ * @param {string} [options.baseUrl] a custom base URL for the
28
+ * haveibeenpwned.com API endpoints (default:
29
+ * `https://haveibeenpwned.com/api/v3`)
30
+ * @param {number} [options.timeoutMs] timeout for the request in milliseconds
31
+ * (default: none)
32
+ * @param {AbortSignal} [options.signal] an AbortSignal to cancel the request (default: none)
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<BreachedAccountRangeResult[]> | Promise<null>)} a Promise
36
+ * which resolves to an array of range results (or null if none were found), or
37
+ * rejects with an Error
38
+ * @example
39
+ * try {
40
+ * const data = await breachedAccountRange("6B5917", { apiKey: "my-api-key" });
41
+ * const match = data?.find(
42
+ * ({ hashSuffix }) => hashSuffix === "C6C0AADE0C085843D66E4944E108C4A4CD",
43
+ * );
44
+ * // match?.websites: ["Adobe", "Gawker", "Stratfor"] in the documented example
45
+ * } catch (err) {
46
+ * // ...
47
+ * }
48
+ * @see https://haveibeenpwned.com/API/v3#BreachesForHashRange
49
+ */
50
+ export declare function breachedAccountRange(prefix: string, options?: {
51
+ /**
52
+ * an API key from https://haveibeenpwned.com/API/Key (default: undefined)
53
+ */
54
+ apiKey?: string | undefined;
55
+ /**
56
+ * a custom base URL for the haveibeenpwned.com API endpoints (default:
57
+ * `https://haveibeenpwned.com/api/v3`)
58
+ */
59
+ baseUrl?: string | undefined;
60
+ /**
61
+ * timeout for the request in milliseconds (default: none)
62
+ */
63
+ timeoutMs?: number | undefined;
64
+ /**
65
+ * an AbortSignal to cancel the request (default: none)
66
+ */
67
+ signal?: AbortSignal | undefined;
68
+ /**
69
+ * a custom string to send as the User-Agent field in the request headers
70
+ * (default: `hibp <version>`)
71
+ */
72
+ userAgent?: string | undefined;
73
+ }): Promise<BreachedAccountRangeResult[] | null>;
@@ -0,0 +1,60 @@
1
+ import { fetchFromApi } from "./api/haveibeenpwned/fetch-from-api.js";
2
+ /**
3
+ * A breached email hash suffix and the breach names associated with it.
4
+ *
5
+ * @typedef {Object} BreachedAccountRangeResult
6
+ * @property {string} hashSuffix the remaining 34 characters of a SHA-1 email hash
7
+ * @property {string[]} websites breach names, not website domains or URLs
8
+ */
9
+ /**
10
+ * Fetches breached email hash suffixes for a six-character SHA-1 email hash
11
+ * prefix.
12
+ *
13
+ * Requires a Pro or High RPM API key from https://haveibeenpwned.com/API/Key.
14
+ * The `apiKey` option here is not explicitly required, but direct requests made
15
+ * without it will fail (unless you specify a `baseUrl` to a proxy that inserts
16
+ * a valid API key on your behalf).
17
+ *
18
+ * Compare suffixes locally against the intended email hash. Per the
19
+ * haveibeenpwned.com terms of use, discard unrelated results immediately
20
+ * without storing or further processing them.
21
+ *
22
+ * @param {string} prefix the first six characters of a SHA-1 email hash
23
+ * (case-insensitive)
24
+ * @param {object} [options] a configuration object
25
+ * @param {string} [options.apiKey] an API key from
26
+ * https://haveibeenpwned.com/API/Key (default: undefined)
27
+ * @param {string} [options.baseUrl] a custom base URL for the
28
+ * haveibeenpwned.com API endpoints (default:
29
+ * `https://haveibeenpwned.com/api/v3`)
30
+ * @param {number} [options.timeoutMs] timeout for the request in milliseconds
31
+ * (default: none)
32
+ * @param {AbortSignal} [options.signal] an AbortSignal to cancel the request (default: none)
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<BreachedAccountRangeResult[]> | Promise<null>)} a Promise
36
+ * which resolves to an array of range results (or null if none were found), or
37
+ * rejects with an Error
38
+ * @example
39
+ * try {
40
+ * const data = await breachedAccountRange("6B5917", { apiKey: "my-api-key" });
41
+ * const match = data?.find(
42
+ * ({ hashSuffix }) => hashSuffix === "C6C0AADE0C085843D66E4944E108C4A4CD",
43
+ * );
44
+ * // match?.websites: ["Adobe", "Gawker", "Stratfor"] in the documented example
45
+ * } catch (err) {
46
+ * // ...
47
+ * }
48
+ * @see https://haveibeenpwned.com/API/v3#BreachesForHashRange
49
+ */
50
+ export function breachedAccountRange(prefix, options = {}) {
51
+ const { apiKey, baseUrl, timeoutMs, signal, userAgent } = options;
52
+ return fetchFromApi(`/breachedaccount/range/${encodeURIComponent(prefix)}`, {
53
+ apiKey,
54
+ baseUrl,
55
+ timeoutMs,
56
+ signal,
57
+ userAgent,
58
+ });
59
+ }
60
+ //# sourceMappingURL=breached-account-range.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breached-account-range.js","sourceRoot":"","sources":["../../src/breached-account-range.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAc,EACd,OAAO,GAuBH,EAAE;IAEN,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAElE,OAAO,YAAY,CACjB,0BAA0B,kBAAkB,CAAC,MAAM,CAAC,EAAE,EACtD;QACE,MAAM;QACN,OAAO;QACP,SAAS;QACT,MAAM;QACN,SAAS;KACV,CACF,CAAC;AACJ,CAAC"}
@@ -1,12 +1,52 @@
1
- import type { Breach } from './api/haveibeenpwned/types.js';
1
+ import type { Breach } from "./api/haveibeenpwned/types.js";
2
+ interface BreachedAccountOptions {
3
+ /**
4
+ * an API key from https://haveibeenpwned.com/API/Key (default: undefined)
5
+ */
6
+ apiKey?: string | undefined;
7
+ /**
8
+ * a domain by which to filter the results (default: all domains)
9
+ */
10
+ domain?: string | undefined;
11
+ /**
12
+ * include "unverified" breaches in the results (default: true)
13
+ */
14
+ includeUnverified?: boolean | undefined;
15
+ /**
16
+ * timeout for the request in milliseconds (default: none)
17
+ */
18
+ timeoutMs?: number | undefined;
19
+ /**
20
+ * an AbortSignal to cancel the request (default: none)
21
+ */
22
+ signal?: AbortSignal | undefined;
23
+ /**
24
+ * truncate the results to only include the name of each breach (default:
25
+ * true)
26
+ */
27
+ truncate?: boolean | undefined;
28
+ /**
29
+ * a custom base URL for the haveibeenpwned.com API endpoints (default:
30
+ * `https://haveibeenpwned.com/api/v3`)
31
+ */
32
+ baseUrl?: string | undefined;
33
+ /**
34
+ * a custom string to send as the User-Agent field in the request headers
35
+ * (default: `hibp <version>`)
36
+ */
37
+ userAgent?: string | undefined;
38
+ }
2
39
  /**
3
40
  * Fetches breach data for a specific account.
4
41
  *
5
- * 🔑 `haveibeenpwned.com` requires an API key from
6
- * https://haveibeenpwned.com/API/Key for the `breachedaccount` endpoint. The
7
- * `apiKey` option here is not explicitly required, but direct requests made
8
- * without it will fail (unless you specify a `baseUrl` to a proxy that inserts
9
- * a valid API key on your behalf).
42
+ * Results contain only `Name` by default; pass `truncate: false` for full
43
+ * breaches.
44
+ *
45
+ * Requires a Core, Pro, or High RPM API key from
46
+ * https://haveibeenpwned.com/API/Key. The `apiKey` option here is not
47
+ * explicitly required, but direct requests made without it will fail (unless
48
+ * you specify a `baseUrl` to a proxy that inserts a valid API key on your
49
+ * behalf).
10
50
  *
11
51
  * @param {string} account a username or email address
12
52
  * @param {object} [options] a configuration object
@@ -26,9 +66,9 @@ import type { Breach } from './api/haveibeenpwned/types.js';
26
66
  * `https://haveibeenpwned.com/api/v3`)
27
67
  * @param {string} [options.userAgent] a custom string to send as the User-Agent
28
68
  * field in the request headers (default: `hibp <version>`)
29
- * @returns {(Promise<Breach[]> | Promise<null>)} a Promise which resolves to an
30
- * array of breach objects (or null if no breaches were found), or rejects with
31
- * an Error
69
+ * @returns {(Promise<Breach[]> | Promise<null>)} a Promise which
70
+ * resolves to name-only breaches by default, full breaches with
71
+ * `truncate: false`, or null if no breaches were found; rejects with an Error
32
72
  * @example
33
73
  * try {
34
74
  * const data = await breachedAccount("foo", { apiKey: "my-api-key" });
@@ -71,40 +111,11 @@ import type { Breach } from './api/haveibeenpwned/types.js';
71
111
  * // ...
72
112
  * }
73
113
  */
74
- export declare function breachedAccount(account: string, options?: {
75
- /**
76
- * an API key from https://haveibeenpwned.com/API/Key (default: undefined)
77
- */
78
- apiKey?: string;
79
- /**
80
- * a domain by which to filter the results (default: all domains)
81
- */
82
- domain?: string;
83
- /**
84
- * include "unverified" breaches in the results (default: true)
85
- */
86
- includeUnverified?: boolean;
87
- /**
88
- * timeout for the request in milliseconds (default: none)
89
- */
90
- timeoutMs?: number;
91
- /**
92
- * an AbortSignal to cancel the request (default: none)
93
- */
94
- signal?: AbortSignal;
95
- /**
96
- * truncate the results to only include the name of each breach (default:
97
- * true)
98
- */
99
- truncate?: boolean;
100
- /**
101
- * a custom base URL for the haveibeenpwned.com API endpoints (default:
102
- * `https://haveibeenpwned.com/api/v3`)
103
- */
104
- baseUrl?: string;
105
- /**
106
- * a custom string to send as the User-Agent field in the request headers
107
- * (default: `hibp <version>`)
108
- */
109
- userAgent?: string;
114
+ export declare function breachedAccount(account: string, options?: BreachedAccountOptions & {
115
+ truncate?: true | undefined;
116
+ }): Promise<Pick<Breach, "Name">[] | null>;
117
+ export declare function breachedAccount(account: string, options: BreachedAccountOptions & {
118
+ truncate: false;
110
119
  }): Promise<Breach[] | null>;
120
+ export declare function breachedAccount(account: string, options?: BreachedAccountOptions): Promise<Breach[] | Pick<Breach, "Name">[] | null>;
121
+ export {};
@@ -1,76 +1,4 @@
1
- import { fetchFromApi } from './api/haveibeenpwned/fetch-from-api.js';
2
- /**
3
- * Fetches breach data for a specific account.
4
- *
5
- * 🔑 `haveibeenpwned.com` requires an API key from
6
- * https://haveibeenpwned.com/API/Key for the `breachedaccount` endpoint. The
7
- * `apiKey` option here is not explicitly required, but direct requests made
8
- * without it will fail (unless you specify a `baseUrl` to a proxy that inserts
9
- * a valid API key on your behalf).
10
- *
11
- * @param {string} account a username or email address
12
- * @param {object} [options] a configuration object
13
- * @param {string} [options.apiKey] an API key from
14
- * https://haveibeenpwned.com/API/Key (default: undefined)
15
- * @param {string} [options.domain] a domain by which to filter the results
16
- * (default: all domains)
17
- * @param {boolean} [options.includeUnverified] include "unverified" breaches in
18
- * the results (default: true)
19
- * @param {number} [options.timeoutMs] timeout for the request in milliseconds
20
- * (default: none)
21
- * @param {AbortSignal} [options.signal] an AbortSignal to cancel the request (default: none)
22
- * @param {boolean} [options.truncate] truncate the results to only include
23
- * the name of each breach (default: true)
24
- * @param {string} [options.baseUrl] a custom base URL for the
25
- * haveibeenpwned.com API endpoints (default:
26
- * `https://haveibeenpwned.com/api/v3`)
27
- * @param {string} [options.userAgent] a custom string to send as the User-Agent
28
- * field in the request headers (default: `hibp <version>`)
29
- * @returns {(Promise<Breach[]> | Promise<null>)} a Promise which resolves to an
30
- * array of breach objects (or null if no breaches were found), or rejects with
31
- * an Error
32
- * @example
33
- * try {
34
- * const data = await breachedAccount("foo", { apiKey: "my-api-key" });
35
- * if (data) {
36
- * // ...
37
- * } else {
38
- * // ...
39
- * }
40
- * } catch (err) {
41
- * // ...
42
- * }
43
- * @example
44
- * try {
45
- * const data = await breachedAccount("bar", {
46
- * includeUnverified: false,
47
- * baseUrl: "https://my-hibp-proxy:8080",
48
- * });
49
- * if (data) {
50
- * // ...
51
- * } else {
52
- * // ...
53
- * }
54
- * } catch (err) {
55
- * // ...
56
- * }
57
- * @example
58
- * try {
59
- * const data = await breachedAccount("baz", {
60
- * apiKey: "my-api-key",
61
- * domain: "adobe.com",
62
- * truncate: false,
63
- * userAgent: "my-app 1.0",
64
- * });
65
- * if (data) {
66
- * // ...
67
- * } else {
68
- * // ...
69
- * }
70
- * } catch (err) {
71
- * // ...
72
- * }
73
- */
1
+ import { fetchFromApi } from "./api/haveibeenpwned/fetch-from-api.js";
74
2
  export function breachedAccount(account, options = {}) {
75
3
  const { apiKey, domain, includeUnverified = true, timeoutMs, signal, truncate = true, baseUrl, userAgent, } = options;
76
4
  const endpoint = `/breachedaccount/${encodeURIComponent(account)}?`;
@@ -79,12 +7,12 @@ export function breachedAccount(account, options = {}) {
79
7
  params.push(`domain=${encodeURIComponent(domain)}`);
80
8
  }
81
9
  if (!includeUnverified) {
82
- params.push('includeUnverified=false');
10
+ params.push("includeUnverified=false");
83
11
  }
84
12
  if (!truncate) {
85
- params.push('truncateResponse=false');
13
+ params.push("truncateResponse=false");
86
14
  }
87
- return fetchFromApi(`${endpoint}${params.join('&')}`, {
15
+ return fetchFromApi(`${endpoint}${params.join("&")}`, {
88
16
  apiKey,
89
17
  baseUrl,
90
18
  timeoutMs,