hibp 15.0.0-dev.0 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Change Log
2
2
 
3
+ ## 15.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#509](https://github.com/wKovacs64/hibp/pull/509) [`e8d4986`](https://github.com/wKovacs64/hibp/commit/e8d498622020fe0c99847f915839ce382bf4d817) Thanks [@wKovacs64](https://github.com/wKovacs64)! - Drop support for Node 18 and remove the CommonJS and UMD builds:
8
+
9
+ - Drop support for Node.js 18 as it is [end-of-life](https://nodejs.org/en/about/releases/), making the new minimum Node.js runtime v20.19.0. Please upgrade your Node.js environment if necessary, or continue using a previous release if you are unable to upgrade your environment.
10
+
11
+ - This also allowed us to drop the `fetch` polyfill that was only necessary in Node 18, which reduced the bundle size by approximately 33%! 📉 The library now officially has **zero dependencies**. 🎉
12
+
13
+ - Remove the CommonJS build since [you can now `require()` ESM as of Node v20.19.0](https://github.com/nodejs/node/releases/tag/v20.19.0). **Consumers in a CommonJS environment should still be able to use the library as before** (given the appropriate Node.js version).
14
+ - Remove the UMD build as all modern browsers support importing ESM via `<script type="module">` tags. See the "[Using in the browser](https://github.com/wKovacs64/hibp?tab=readme-ov-file#using-in-the-browser)" section of the README for more details.
15
+
16
+ ### Minor Changes
17
+
18
+ - [#506](https://github.com/wKovacs64/hibp/pull/506) [`56fdf38`](https://github.com/wKovacs64/hibp/commit/56fdf3829846962231b08026d31ef195cde2fdef) Thanks [@wKovacs64](https://github.com/wKovacs64)! - Drop `JSSHA` dependency in favor of a native Web Crypto API SHA-1 hashing implementation. This change reduces the size of the library by approximately 30%! 📉
19
+
3
20
  ## 14.1.3
4
21
 
5
22
  ### Patch Changes
@@ -1,2 +1,2 @@
1
- var w="hibp",y="15.0.0-dev.0";var h={status:400,statusText:"Bad request \u2014 the account does not comply with an acceptable format."},P={status:401,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`},g={status:403,statusText:"Forbidden - access denied."};var x={status:404},U={headers:new Map([["retry-after","2"]]),status:429,body:{statusCode:429,message:"Rate limit is exceeded. Try again in 2 seconds."}};var d=class extends Error{retryAfterSeconds;constructor(t,r,n){super(r,n),this.name=this.constructor.name,this.retryAfterSeconds=typeof t=="string"?Number.parseInt(t,10):void 0}};function I(e){return`Request blocked, contact haveibeenpwned.com if this continues (Ray ID: ${e})`}async function u(e,t={}){let{apiKey:r,baseUrl:n="https://haveibeenpwned.com/api/v3",timeoutMs:o,userAgent:a}=t,i={};r&&(i["HIBP-API-Key"]=r),a&&(i["User-Agent"]=a),!a&&typeof navigator>"u"&&(i["User-Agent"]=`${w} ${y}`);let p={headers:i,...o?{signal:AbortSignal.timeout(o)}:{}},m=`${n.replace(/\/$/g,"")}${e}`,s=await fetch(m,p);if(s.ok)return s.json();switch(s.status){case h.status:throw new Error(h.statusText);case P.status:{let c=await s.text();throw new Error(c)}case g.status:{let c=s.headers.get("cf-ray");throw c?new Error(I(c)):new Error(g.statusText)}case x.status:return null;case U.status:{let c=await s.json(),f=s.headers.get("retry-after");throw new d(f,c.message)}default:throw new Error(s.statusText)}}function B(e,t={}){return u(`/breach/${encodeURIComponent(e)}`,t)}function l(e,t={}){let{apiKey:r,domain:n,includeUnverified:o=!0,timeoutMs:a,truncate:i=!0,baseUrl:p,userAgent:m}=t,s=`/breachedaccount/${encodeURIComponent(e)}?`,c=[];return n&&c.push(`domain=${encodeURIComponent(n)}`),o||c.push("includeUnverified=false"),i||c.push("truncateResponse=false"),u(`${s}${c.join("&")}`,{apiKey:r,baseUrl:p,timeoutMs:a,userAgent:m})}function M(e={}){let{domain:t,baseUrl:r,timeoutMs:n,userAgent:o}=e,a="/breaches?",i=[];return t&&i.push(`domain=${encodeURIComponent(t)}`),u(`${a}${i.join("&")}`,{baseUrl:r,timeoutMs:n,userAgent:o})}function T(e={}){return u("/dataclasses",e)}function b(e,t={}){return u(`/pasteaccount/${encodeURIComponent(e)}`,t)}var E={status:400,body:"The hash prefix was not in a valid format"};async function R(e,t={}){let{baseUrl:r="https://api.pwnedpasswords.com",timeoutMs:n,userAgent:o,addPadding:a=!1,mode:i="sha1"}=t,p={headers:{...o?{"User-Agent":o}:{},...a?{"Add-Padding":"true"}:{}},...n?{signal:AbortSignal.timeout(n)}:{}},m=`${r.replace(/\/$/g,"")}${e}?mode=${i}`,s=await fetch(m,p);if(s.ok)return s.text();if(s.status===E.status){let c=await s.text();throw new Error(c)}throw new Error(s.statusText)}async function A(e,t={}){let{baseUrl:r,timeoutMs:n,userAgent:o,addPadding:a=!1,mode:i="sha1"}=t;return(await R(`/range/${encodeURIComponent(e)}`,{baseUrl:r,timeoutMs:n,userAgent:o,addPadding:a,mode:i})).split(`
2
- `).filter(Boolean).reduce((s,c)=>{let[f,S]=c.split(":");return s[f]=Number.parseInt(S,10),s},{})}async function v(e,t={}){let[r,n]=await D(e);return(await A(r,t))[n]||0}async function D(e){if(typeof crypto=="object"&&crypto.subtle){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-1",t),o=Array.from(new Uint8Array(r)).map(a=>a.toString(16).padStart(2,"0")).join("").toUpperCase();return[o.slice(0,5),o.slice(5)]}throw new Error("The Web Crypto API is not available in this environment.")}async function $(e,t={}){let{apiKey:r,domain:n,truncate:o=!0,baseUrl:a,timeoutMs:i,userAgent:p}=t,[m,s]=await Promise.all([l(e,{apiKey:r,domain:n,truncate:o,baseUrl:a,timeoutMs:i,userAgent:p}),/^.+@.+$/.test(e)?b(e,{apiKey:r,baseUrl:a,timeoutMs:i,userAgent:p}):null]);return{breaches:m,pastes:s}}async function C(e={}){return u("/subscription/status",e)}export{d as RateLimitError,B as breach,l as breachedAccount,M as breaches,T as dataClasses,b as pasteAccount,v as pwnedPassword,A as pwnedPasswordRange,$ as search,C as subscriptionStatus};
1
+ var w="hibp",y="15.0.0";var h={status:400,statusText:"Bad request \u2014 the account does not comply with an acceptable format."},P={status:401,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`},g={status:403,statusText:"Forbidden - access denied."};var x={status:404},U={headers:new Map([["retry-after","2"]]),status:429,body:{statusCode:429,message:"Rate limit is exceeded. Try again in 2 seconds."}};var d=class extends Error{retryAfterSeconds;constructor(t,r,n){super(r,n),this.name=this.constructor.name,this.retryAfterSeconds=typeof t=="string"?Number.parseInt(t,10):void 0}};function I(e){return`Request blocked, contact haveibeenpwned.com if this continues (Ray ID: ${e})`}async function u(e,t={}){let{apiKey:r,baseUrl:n="https://haveibeenpwned.com/api/v3",timeoutMs:o,userAgent:a}=t,i={};r&&(i["HIBP-API-Key"]=r),a&&(i["User-Agent"]=a),!a&&typeof navigator>"u"&&(i["User-Agent"]=`${w} ${y}`);let p={headers:i,...o?{signal:AbortSignal.timeout(o)}:{}},m=`${n.replace(/\/$/g,"")}${e}`,s=await fetch(m,p);if(s.ok)return s.json();switch(s.status){case h.status:throw new Error(h.statusText);case P.status:{let c=await s.text();throw new Error(c)}case g.status:{let c=s.headers.get("cf-ray");throw c?new Error(I(c)):new Error(g.statusText)}case x.status:return null;case U.status:{let c=await s.json(),f=s.headers.get("retry-after");throw new d(f,c.message)}default:throw new Error(s.statusText)}}function B(e,t={}){return u(`/breach/${encodeURIComponent(e)}`,t)}function l(e,t={}){let{apiKey:r,domain:n,includeUnverified:o=!0,timeoutMs:a,truncate:i=!0,baseUrl:p,userAgent:m}=t,s=`/breachedaccount/${encodeURIComponent(e)}?`,c=[];return n&&c.push(`domain=${encodeURIComponent(n)}`),o||c.push("includeUnverified=false"),i||c.push("truncateResponse=false"),u(`${s}${c.join("&")}`,{apiKey:r,baseUrl:p,timeoutMs:a,userAgent:m})}function M(e={}){let{domain:t,baseUrl:r,timeoutMs:n,userAgent:o}=e,a="/breaches?",i=[];return t&&i.push(`domain=${encodeURIComponent(t)}`),u(`${a}${i.join("&")}`,{baseUrl:r,timeoutMs:n,userAgent:o})}function T(e={}){return u("/dataclasses",e)}function b(e,t={}){return u(`/pasteaccount/${encodeURIComponent(e)}`,t)}var E={status:400,body:"The hash prefix was not in a valid format"};async function R(e,t={}){let{baseUrl:r="https://api.pwnedpasswords.com",timeoutMs:n,userAgent:o,addPadding:a=!1,mode:i="sha1"}=t,p={headers:{...o?{"User-Agent":o}:{},...a?{"Add-Padding":"true"}:{}},...n?{signal:AbortSignal.timeout(n)}:{}},m=`${r.replace(/\/$/g,"")}${e}?mode=${i}`,s=await fetch(m,p);if(s.ok)return s.text();if(s.status===E.status){let c=await s.text();throw new Error(c)}throw new Error(s.statusText)}async function A(e,t={}){let{baseUrl:r,timeoutMs:n,userAgent:o,addPadding:a=!1,mode:i="sha1"}=t;return(await R(`/range/${encodeURIComponent(e)}`,{baseUrl:r,timeoutMs:n,userAgent:o,addPadding:a,mode:i})).split(`
2
+ `).filter(Boolean).reduce((s,c)=>{let[f,S]=c.split(":");return s[f]=Number.parseInt(S,10),s},{})}async function D(e,t={}){let[r,n]=await $(e);return(await A(r,t))[n]||0}async function $(e){if(typeof crypto=="object"&&crypto.subtle){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-1",t),o=Array.from(new Uint8Array(r)).map(a=>a.toString(16).padStart(2,"0")).join("").toUpperCase();return[o.slice(0,5),o.slice(5)]}throw new Error("The Web Crypto API is not available in this environment.")}async function v(e,t={}){let{apiKey:r,domain:n,truncate:o=!0,baseUrl:a,timeoutMs:i,userAgent:p}=t,[m,s]=await Promise.all([l(e,{apiKey:r,domain:n,truncate:o,baseUrl:a,timeoutMs:i,userAgent:p}),/^.+@.+$/.test(e)?b(e,{apiKey:r,baseUrl:a,timeoutMs:i,userAgent:p}):null]);return{breaches:m,pastes:s}}async function C(e={}){return u("/subscription/status",e)}export{d as RateLimitError,B as breach,l as breachedAccount,M as breaches,T as dataClasses,b as pasteAccount,D as pwnedPassword,A as pwnedPasswordRange,v as search,C as subscriptionStatus};
@@ -1,2 +1,2 @@
1
1
  export declare const PACKAGE_NAME = "hibp";
2
- export declare const PACKAGE_VERSION = "15.0.0-dev.0";
2
+ export declare const PACKAGE_VERSION = "15.0.0";
@@ -1,4 +1,4 @@
1
1
  // This file is auto-generated. Do not edit.
2
2
  export const PACKAGE_NAME = "hibp";
3
- export const PACKAGE_VERSION = "15.0.0-dev.0";
3
+ export const PACKAGE_VERSION = "15.0.0";
4
4
  //# sourceMappingURL=package-info.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"package-info.js","sourceRoot":"","sources":["../../../../src/api/haveibeenpwned/package-info.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC;AACnC,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAC"}
1
+ {"version":3,"file":"package-info.js","sourceRoot":"","sources":["../../../../src/api/haveibeenpwned/package-info.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC;AACnC,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hibp",
3
- "version": "15.0.0-dev.0",
3
+ "version": "15.0.0",
4
4
  "description": "An unofficial TypeScript SDK for the 'Have I been pwned?' service.",
5
5
  "keywords": [
6
6
  "haveibeenpwned",