@nhost/nhost-js 4.4.0 → 4.5.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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../fetch-DWXwEnoe.cjs");exports.createAPIClient=(s,e=[])=>{let a=t.createEnhancedFetch(e);return{baseURL:s,pushChainFunction:s=>{e.push(s),a=t.createEnhancedFetch(e)},getJWKs:async e=>{const n=`${s}/.well-known/jwks.json`,r=await a(n,{...e,method:"GET",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}const i=[204,205,304].includes(r.status)?null:await r.text();return{body:i?JSON.parse(i):{},status:r.status,headers:r.headers}},elevateWebauthn:async e=>{const n=`${s}/elevate/webauthn`,r=await a(n,{...e,method:"POST",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}const i=[204,205,304].includes(r.status)?null:await r.text();return{body:i?JSON.parse(i):{},status:r.status,headers:r.headers}},verifyElevateWebauthn:async(e,n)=>{const r=`${s}/elevate/webauthn/verify`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},healthCheckGet:async e=>{const n=`${s}/healthz`,r=await a(n,{...e,method:"GET",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}const i=[204,205,304].includes(r.status)?null:await r.text();return{body:i?JSON.parse(i):{},status:r.status,headers:r.headers}},healthCheckHead:async e=>{const n=`${s}/healthz`,r=await a(n,{...e,method:"HEAD",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}return{body:void 0,status:r.status,headers:r.headers}},linkIdToken:async(e,n)=>{const r=`${s}/link/idtoken`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},changeUserMfa:async e=>{const n=`${s}/mfa/totp/generate`,r=await a(n,{...e,method:"GET",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}const i=[204,205,304].includes(r.status)?null:await r.text();return{body:i?JSON.parse(i):{},status:r.status,headers:r.headers}},createPAT:async(e,n)=>{const r=`${s}/pat`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},signInAnonymous:async(e,n)=>{const r=`${s}/signin/anonymous`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},signInEmailPassword:async(e,n)=>{const r=`${s}/signin/email-password`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},signInIdToken:async(e,n)=>{const r=`${s}/signin/idtoken`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},verifySignInMfaTotp:async(e,n)=>{const r=`${s}/signin/mfa/totp`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},signInOTPEmail:async(e,n)=>{const r=`${s}/signin/otp/email`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},verifySignInOTPEmail:async(e,n)=>{const r=`${s}/signin/otp/email/verify`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},signInPasswordlessEmail:async(e,n)=>{const r=`${s}/signin/passwordless/email`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},signInPasswordlessSms:async(e,n)=>{const r=`${s}/signin/passwordless/sms`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},verifySignInPasswordlessSms:async(e,n)=>{const r=`${s}/signin/passwordless/sms/otp`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},signInPAT:async(e,n)=>{const r=`${s}/signin/pat`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},signInProviderURL:(t,e)=>{const a=e&&Object.entries(e).flatMap((([t,s])=>{if("providerSpecificParams"===t)return"object"!=typeof s||null===s||Array.isArray(s)?[`${t}=${encodeURIComponent(String(s))}`]:Object.entries(s).map((([t,s])=>`${t}=${encodeURIComponent(String(s))}`));const e=Array.isArray(s)?s.join(","):"object"==typeof s&&null!==s?JSON.stringify(s):String(s);return[`${t}=${encodeURIComponent(e)}`]})).join("&");return a?`${s}/signin/provider/${t}?${a}`:`${s}/signin/provider/${t}`},getProviderTokens:async(e,n)=>{const r=`${s}/signin/provider/${e}/callback/tokens`,i=await a(r,{...n,method:"GET",headers:{...n?.headers}});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},signInWebauthn:async(e,n)=>{const r=`${s}/signin/webauthn`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},verifySignInWebauthn:async(e,n)=>{const r=`${s}/signin/webauthn/verify`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},signOut:async(e,n)=>{const r=`${s}/signout`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},signUpEmailPassword:async(e,n)=>{const r=`${s}/signup/email-password`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},signUpWebauthn:async(e,n)=>{const r=`${s}/signup/webauthn`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},verifySignUpWebauthn:async(e,n)=>{const r=`${s}/signup/webauthn/verify`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},refreshToken:async(e,n)=>{const r=`${s}/token`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},refreshProviderToken:async(e,n,r)=>{const i=`${s}/token/provider/${e}`,o=await a(i,{...r,method:"POST",headers:{"Content-Type":"application/json",...r?.headers},body:JSON.stringify(n)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const u=[204,205,304].includes(o.status)?null:await o.text();return{body:u?JSON.parse(u):{},status:o.status,headers:o.headers}},verifyToken:async(e,n)=>{const r=`${s}/token/verify`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},getUser:async e=>{const n=`${s}/user`,r=await a(n,{...e,method:"GET",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}const i=[204,205,304].includes(r.status)?null:await r.text();return{body:i?JSON.parse(i):{},status:r.status,headers:r.headers}},deanonymizeUser:async(e,n)=>{const r=`${s}/user/deanonymize`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},changeUserEmail:async(e,n)=>{const r=`${s}/user/email/change`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},sendVerificationEmail:async(e,n)=>{const r=`${s}/user/email/send-verification-email`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},verifyChangeUserMfa:async(e,n)=>{const r=`${s}/user/mfa`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},changeUserPassword:async(e,n)=>{const r=`${s}/user/password`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},sendPasswordResetEmail:async(e,n)=>{const r=`${s}/user/password/reset`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},addSecurityKey:async e=>{const n=`${s}/user/webauthn/add`,r=await a(n,{...e,method:"POST",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}const i=[204,205,304].includes(r.status)?null:await r.text();return{body:i?JSON.parse(i):{},status:r.status,headers:r.headers}},verifyAddSecurityKey:async(e,n)=>{const r=`${s}/user/webauthn/verify`,i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const o=[204,205,304].includes(i.status)?null:await i.text();return{body:o?JSON.parse(o):{},status:i.status,headers:i.headers}},verifyTicketURL:t=>{const e=t&&Object.entries(t).flatMap((([t,s])=>{const e=Array.isArray(s)?s.join(","):"object"==typeof s&&null!==s?JSON.stringify(s):String(s);return[`${t}=${encodeURIComponent(e)}`]})).join("&");return e?`${s}/verify?${e}`:`${s}/verify`},getVersion:async e=>{const n=`${s}/version`,r=await a(n,{...e,method:"GET",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}const i=[204,205,304].includes(r.status)?null:await r.text();return{body:i?JSON.parse(i):{},status:r.status,headers:r.headers}}}};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../fetch-DWXwEnoe.cjs");exports.createAPIClient=(s,e=[])=>{let a=t.createEnhancedFetch(e);return{baseURL:s,pushChainFunction:s=>{e.push(s),a=t.createEnhancedFetch(e)},getJWKs:async e=>{const n=`${s}/.well-known/jwks.json`,r=await a(n,{...e,method:"GET",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}const o=[204,205,304].includes(r.status)?null:await r.text();return{body:o?JSON.parse(o):{},status:r.status,headers:r.headers}},elevateWebauthn:async e=>{const n=`${s}/elevate/webauthn`,r=await a(n,{...e,method:"POST",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}const o=[204,205,304].includes(r.status)?null:await r.text();return{body:o?JSON.parse(o):{},status:r.status,headers:r.headers}},verifyElevateWebauthn:async(e,n)=>{const r=`${s}/elevate/webauthn/verify`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},healthCheckGet:async e=>{const n=`${s}/healthz`,r=await a(n,{...e,method:"GET",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}const o=[204,205,304].includes(r.status)?null:await r.text();return{body:o?JSON.parse(o):{},status:r.status,headers:r.headers}},healthCheckHead:async e=>{const n=`${s}/healthz`,r=await a(n,{...e,method:"HEAD",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}return{body:void 0,status:r.status,headers:r.headers}},linkIdToken:async(e,n)=>{const r=`${s}/link/idtoken`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},changeUserMfa:async e=>{const n=`${s}/mfa/totp/generate`,r=await a(n,{...e,method:"GET",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}const o=[204,205,304].includes(r.status)?null:await r.text();return{body:o?JSON.parse(o):{},status:r.status,headers:r.headers}},createPAT:async(e,n)=>{const r=`${s}/pat`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},signInAnonymous:async(e,n)=>{const r=`${s}/signin/anonymous`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},signInEmailPassword:async(e,n)=>{const r=`${s}/signin/email-password`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},signInIdToken:async(e,n)=>{const r=`${s}/signin/idtoken`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},verifySignInMfaTotp:async(e,n)=>{const r=`${s}/signin/mfa/totp`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},signInOTPEmail:async(e,n)=>{const r=`${s}/signin/otp/email`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},verifySignInOTPEmail:async(e,n)=>{const r=`${s}/signin/otp/email/verify`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},signInPasswordlessEmail:async(e,n)=>{const r=`${s}/signin/passwordless/email`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},signInPasswordlessSms:async(e,n)=>{const r=`${s}/signin/passwordless/sms`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},verifySignInPasswordlessSms:async(e,n)=>{const r=`${s}/signin/passwordless/sms/otp`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},signInPAT:async(e,n)=>{const r=`${s}/signin/pat`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},signInProviderURL:(t,e)=>{const a=e&&Object.entries(e).flatMap((([t,s])=>{if("providerSpecificParams"===t)return"object"!=typeof s||null===s||Array.isArray(s)?[`${t}=${encodeURIComponent(String(s))}`]:Object.entries(s).map((([t,s])=>`${t}=${encodeURIComponent(String(s))}`));const e=Array.isArray(s)?s.join(","):"object"==typeof s&&null!==s?JSON.stringify(s):String(s);return[`${t}=${encodeURIComponent(e)}`]})).join("&");return a?`${s}/signin/provider/${t}?${a}`:`${s}/signin/provider/${t}`},getProviderTokens:async(e,n)=>{const r=`${s}/signin/provider/${e}/callback/tokens`,o=await a(r,{...n,method:"GET",headers:{...n?.headers}});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},signInWebauthn:async(e,n)=>{const r=`${s}/signin/webauthn`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},verifySignInWebauthn:async(e,n)=>{const r=`${s}/signin/webauthn/verify`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},signOut:async(e,n)=>{const r=`${s}/signout`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},signUpEmailPassword:async(e,n)=>{const r=`${s}/signup/email-password`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},signUpWebauthn:async(e,n)=>{const r=`${s}/signup/webauthn`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},verifySignUpWebauthn:async(e,n)=>{const r=`${s}/signup/webauthn/verify`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},refreshToken:async(e,n)=>{const r=`${s}/token`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},refreshProviderToken:async(e,n,r)=>{const o=`${s}/token/provider/${e}`,i=await a(o,{...r,method:"POST",headers:{"Content-Type":"application/json",...r?.headers},body:JSON.stringify(n)});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const u=[204,205,304].includes(i.status)?null:await i.text();return{body:u?JSON.parse(u):{},status:i.status,headers:i.headers}},verifyToken:async(e,n)=>{const r=`${s}/token/verify`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},getUser:async e=>{const n=`${s}/user`,r=await a(n,{...e,method:"GET",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}const o=[204,205,304].includes(r.status)?null:await r.text();return{body:o?JSON.parse(o):{},status:r.status,headers:r.headers}},deanonymizeUser:async(e,n)=>{const r=`${s}/user/deanonymize`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},changeUserEmail:async(e,n)=>{const r=`${s}/user/email/change`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},sendVerificationEmail:async(e,n)=>{const r=`${s}/user/email/send-verification-email`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},verifyChangeUserMfa:async(e,n)=>{const r=`${s}/user/mfa`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},changeUserPassword:async(e,n)=>{const r=`${s}/user/password`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},sendPasswordResetEmail:async(e,n)=>{const r=`${s}/user/password/reset`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},addSecurityKey:async e=>{const n=`${s}/user/webauthn/add`,r=await a(n,{...e,method:"POST",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}const o=[204,205,304].includes(r.status)?null:await r.text();return{body:o?JSON.parse(o):{},status:r.status,headers:r.headers}},verifyAddSecurityKey:async(e,n)=>{const r=`${s}/user/webauthn/verify`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}},verifyTicketURL:t=>{const e=t&&Object.entries(t).flatMap((([t,s])=>{const e=Array.isArray(s)?s.join(","):"object"==typeof s&&null!==s?JSON.stringify(s):String(s);return[`${t}=${encodeURIComponent(e)}`]})).join("&");return e?`${s}/verify?${e}`:`${s}/verify`},getVersion:async e=>{const n=`${s}/version`,r=await a(n,{...e,method:"GET",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}const o=[204,205,304].includes(r.status)?null:await r.text();return{body:o?JSON.parse(o):{},status:r.status,headers:r.headers}},getOpenIDConfiguration:async e=>{const n=`${s}/.well-known/openid-configuration`,r=await a(n,{...e,method:"GET",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}const o=[204,205,304].includes(r.status)?null:await r.text();return{body:o?JSON.parse(o):{},status:r.status,headers:r.headers}},getOAuthAuthorizationServer:async e=>{const n=`${s}/.well-known/oauth-authorization-server`,r=await a(n,{...e,method:"GET",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}const o=[204,205,304].includes(r.status)?null:await r.text();return{body:o?JSON.parse(o):{},status:r.status,headers:r.headers}},oauth2AuthorizeURL:t=>{const e=t&&Object.entries(t).flatMap((([t,s])=>{const e=Array.isArray(s)?s.join(","):"object"==typeof s&&null!==s?JSON.stringify(s):String(s);return[`${t}=${encodeURIComponent(e)}`]})).join("&");return e?`${s}/oauth2/authorize?${e}`:`${s}/oauth2/authorize`},oauth2AuthorizePostURL:()=>`${s}/oauth2/authorize`,oauth2Token:async(e,n)=>{const r=`${s}/oauth2/token`,o=new URLSearchParams;void 0!==e.grant_type&&o.append("grant_type",String(e.grant_type)),void 0!==e.code&&o.append("code",String(e.code)),void 0!==e.redirect_uri&&o.append("redirect_uri",String(e.redirect_uri)),void 0!==e.client_id&&o.append("client_id",String(e.client_id)),void 0!==e.client_secret&&o.append("client_secret",String(e.client_secret)),void 0!==e.code_verifier&&o.append("code_verifier",String(e.code_verifier)),void 0!==e.refresh_token&&o.append("refresh_token",String(e.refresh_token)),void 0!==e.resource&&o.append("resource",String(e.resource));const i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",...n?.headers},body:o.toString()});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const u=[204,205,304].includes(i.status)?null:await i.text();return{body:u?JSON.parse(u):{},status:i.status,headers:i.headers}},oauth2UserinfoGet:async e=>{const n=`${s}/oauth2/userinfo`,r=await a(n,{...e,method:"GET",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}const o=[204,205,304].includes(r.status)?null:await r.text();return{body:o?JSON.parse(o):{},status:r.status,headers:r.headers}},oauth2UserinfoPost:async e=>{const n=`${s}/oauth2/userinfo`,r=await a(n,{...e,method:"POST",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}const o=[204,205,304].includes(r.status)?null:await r.text();return{body:o?JSON.parse(o):{},status:r.status,headers:r.headers}},oauth2Jwks:async e=>{const n=`${s}/oauth2/jwks`,r=await a(n,{...e,method:"GET",headers:{...e?.headers}});if(r.status>=300){const s=[412].includes(r.status)?null:await r.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,r.status,r.headers)}const o=[204,205,304].includes(r.status)?null:await r.text();return{body:o?JSON.parse(o):{},status:r.status,headers:r.headers}},oauth2Revoke:async(e,n)=>{const r=`${s}/oauth2/revoke`,o=new URLSearchParams;void 0!==e.token&&o.append("token",String(e.token)),void 0!==e.token_type_hint&&o.append("token_type_hint",String(e.token_type_hint)),void 0!==e.client_id&&o.append("client_id",String(e.client_id)),void 0!==e.client_secret&&o.append("client_secret",String(e.client_secret));const i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",...n?.headers},body:o.toString()});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}return{body:void 0,status:i.status,headers:i.headers}},oauth2Introspect:async(e,n)=>{const r=`${s}/oauth2/introspect`,o=new URLSearchParams;void 0!==e.token&&o.append("token",String(e.token)),void 0!==e.token_type_hint&&o.append("token_type_hint",String(e.token_type_hint)),void 0!==e.client_id&&o.append("client_id",String(e.client_id)),void 0!==e.client_secret&&o.append("client_secret",String(e.client_secret));const i=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",...n?.headers},body:o.toString()});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const u=[204,205,304].includes(i.status)?null:await i.text();return{body:u?JSON.parse(u):{},status:i.status,headers:i.headers}},oauth2LoginGet:async(e,n)=>{const r=e&&Object.entries(e).flatMap((([t,s])=>{const e=Array.isArray(s)?s.join(","):"object"==typeof s&&null!==s?JSON.stringify(s):String(s);return[`${t}=${encodeURIComponent(e)}`]})).join("&"),o=r?`${s}/oauth2/login?${r}`:`${s}/oauth2/login`,i=await a(o,{...n,method:"GET",headers:{...n?.headers}});if(i.status>=300){const s=[412].includes(i.status)?null:await i.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,i.status,i.headers)}const u=[204,205,304].includes(i.status)?null:await i.text();return{body:u?JSON.parse(u):{},status:i.status,headers:i.headers}},oauth2LoginPost:async(e,n)=>{const r=`${s}/oauth2/login`,o=await a(r,{...n,method:"POST",headers:{"Content-Type":"application/json",...n?.headers},body:JSON.stringify(e)});if(o.status>=300){const s=[412].includes(o.status)?null:await o.text(),e=s?JSON.parse(s):{};throw new t.FetchError(e,o.status,o.headers)}const i=[204,205,304].includes(o.status)?null:await o.text();return{body:i?JSON.parse(i):{},status:o.status,headers:o.headers}}}};
2
2
  //# sourceMappingURL=auth.cjs.map