@nhost/nhost-js 4.7.0 → 4.7.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.
- package/dist/fetch-DAaKgbl_.cjs +2 -0
- package/dist/{fetch-DjLYNzv8.cjs.map → fetch-DAaKgbl_.cjs.map} +1 -1
- package/dist/fetch-DGzwPw2i.js +2 -0
- package/dist/{fetch-DsJJyobH.js.map → fetch-DGzwPw2i.js.map} +1 -1
- package/dist/{graphql-BEFThamT.cjs → graphql-CDOwJ-ZX.cjs} +2 -2
- package/dist/{graphql-BEFThamT.cjs.map → graphql-CDOwJ-ZX.cjs.map} +1 -1
- package/dist/{graphql-CTZ9QikM.js → graphql-q05DEErT.js} +2 -2
- package/dist/{graphql-CTZ9QikM.js.map → graphql-q05DEErT.js.map} +1 -1
- package/dist/nhost-js/auth.cjs +1 -1
- package/dist/nhost-js/auth.cjs.map +1 -1
- package/dist/nhost-js/auth.js +1 -1
- package/dist/nhost-js/auth.js.map +1 -1
- package/dist/nhost-js/fetch.cjs +1 -1
- package/dist/nhost-js/fetch.js +1 -1
- package/dist/nhost-js/functions.cjs +1 -1
- package/dist/nhost-js/functions.cjs.map +1 -1
- package/dist/nhost-js/functions.js +1 -1
- package/dist/nhost-js/functions.js.map +1 -1
- package/dist/nhost-js/graphql.cjs +1 -1
- package/dist/nhost-js/graphql.js +1 -1
- package/dist/nhost-js/session.cjs +1 -1
- package/dist/nhost-js/session.js +1 -1
- package/dist/nhost-js/storage.cjs +1 -1
- package/dist/nhost-js/storage.cjs.map +1 -1
- package/dist/nhost-js/storage.js +1 -1
- package/dist/nhost-js/storage.js.map +1 -1
- package/dist/nhost-js.cjs +1 -1
- package/dist/nhost-js.cjs.map +1 -1
- package/dist/nhost-js.js +1 -1
- package/dist/nhost-js.js.map +1 -1
- package/dist/nhost-js.umd.js +1 -1
- package/dist/nhost-js.umd.js.map +1 -1
- package/dist/{refreshSession-ZW-JniXX.cjs → refreshSession-DDTo2b9R.js} +2 -2
- package/dist/refreshSession-DDTo2b9R.js.map +1 -0
- package/dist/refreshSession-D_vFKIeJ.cjs +2 -0
- package/dist/refreshSession-D_vFKIeJ.cjs.map +1 -0
- package/dist/session-oECsmiRB.js.map +1 -1
- package/dist/session-r_9IPgQp.cjs.map +1 -1
- package/dist/src/auth/client.d.ts +3 -0
- package/dist/src/auth/client.d.ts.map +1 -1
- package/dist/src/auth/client.js.map +1 -1
- package/dist/src/fetch/middlewareUpdateSessionFromResponse.d.ts.map +1 -1
- package/dist/src/fetch/middlewareUpdateSessionFromResponse.js +8 -0
- package/dist/src/fetch/middlewareUpdateSessionFromResponse.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/nhost.d.ts +12 -12
- package/dist/src/nhost.d.ts.map +1 -1
- package/dist/src/nhost.js +9 -9
- package/dist/src/nhost.js.map +1 -1
- package/dist/src/session/index.d.ts +1 -1
- package/dist/src/session/index.d.ts.map +1 -1
- package/dist/src/session/refreshSession.d.ts +2 -2
- package/dist/src/session/refreshSession.d.ts.map +1 -1
- package/dist/src/session/refreshSession.js +1 -1
- package/dist/src/session/refreshSession.js.map +1 -1
- package/dist/src/session/session.d.ts +23 -1
- package/dist/src/session/session.d.ts.map +1 -1
- package/dist/src/session/session.js.map +1 -1
- package/dist/src/session/storage.d.ts +3 -3
- package/dist/src/session/storage.d.ts.map +1 -1
- package/dist/src/session/storage.js.map +1 -1
- package/dist/src/session/storageBackend.d.ts +26 -9
- package/dist/src/session/storageBackend.d.ts.map +1 -1
- package/dist/src/session/storageBackend.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/fetch-DjLYNzv8.cjs +0 -2
- package/dist/fetch-DsJJyobH.js +0 -2
- package/dist/refreshSession-BvZuC-Or.js +0 -2
- package/dist/refreshSession-BvZuC-Or.js.map +0 -1
- package/dist/refreshSession-ZW-JniXX.cjs.map +0 -1
package/dist/nhost-js/auth.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as t,s}from"../fetch-DsJJyobH.js";var e=(e,a=[])=>{let n=t(a);return{baseURL:e,pushChainFunction:s=>{a.push(s),n=t(a)},getJWKs:async t=>{const a=`${e}/.well-known/jwks.json`,r=await n(a,{...t,method:"GET",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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 t=>{const a=`${e}/elevate/webauthn`,r=await n(a,{...t,method:"POST",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/elevate/webauthn/verify`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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 t=>{const a=`${e}/healthz`,r=await n(a,{...t,method:"GET",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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 t=>{const a=`${e}/healthz`,r=await n(a,{...t,method:"HEAD",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},r.status,r.headers)}return{body:void 0,status:r.status,headers:r.headers}},linkIdToken:async(t,a)=>{const r=`${e}/link/idtoken`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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 t=>{const a=`${e}/mfa/totp/generate`,r=await n(a,{...t,method:"GET",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/pat`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/anonymous`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/email-password`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/idtoken`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/mfa/totp`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/otp/email`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/otp/email/verify`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/passwordless/email`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/passwordless/sms`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/passwordless/sms/otp`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/pat`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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,s)=>{const a=s&&Object.entries(s).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?`${e}/signin/provider/${t}?${a}`:`${e}/signin/provider/${t}`},getProviderTokens:async(t,a)=>{const r=`${e}/signin/provider/${t}/callback/tokens`,i=await n(r,{...a,method:"GET",headers:{...a?.headers}});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/webauthn`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/webauthn/verify`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signout`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signup/email-password`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signup/webauthn`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signup/webauthn/verify`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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}},signUpPasswordlessEmail:async(t,a)=>{const r=`${e}/signup/passwordless/email`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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}},signUpOTPEmail:async(t,a)=>{const r=`${e}/signup/otp/email`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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}},signUpPasswordlessSms:async(t,a)=>{const r=`${e}/signup/passwordless/sms`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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}},signUpIdToken:async(t,a)=>{const r=`${e}/signup/idtoken`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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}},signUpProviderURL:(t,s)=>{const a=s&&Object.entries(s).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?`${e}/signup/provider/${t}?${a}`:`${e}/signup/provider/${t}`},refreshToken:async(t,a)=>{const r=`${e}/token`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a,r)=>{const i=`${e}/token/provider/${t}`,o=await n(i,{...r,method:"POST",headers:{"Content-Type":"application/json",...r?.headers},body:JSON.stringify(a)});if(o.status>=300){const t=[412].includes(o.status)?null:await o.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/token/verify`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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 t=>{const a=`${e}/user`,r=await n(a,{...t,method:"GET",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/user/deanonymize`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/user/email/change`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/user/email/send-verification-email`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/user/mfa`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/user/password`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/user/password/reset`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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 t=>{const a=`${e}/user/webauthn/add`,r=await n(a,{...t,method:"POST",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/user/webauthn/verify`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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}},tokenExchange:async(t,a)=>{const r=`${e}/token/exchange`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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 s=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 s?`${e}/verify?${s}`:`${e}/verify`},getVersion:async t=>{const a=`${e}/version`,r=await n(a,{...t,method:"GET",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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}},getOpenIDConfiguration:async t=>{const a=`${e}/.well-known/openid-configuration`,r=await n(a,{...t,method:"GET",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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}},getOAuthAuthorizationServer:async t=>{const a=`${e}/.well-known/oauth-authorization-server`,r=await n(a,{...t,method:"GET",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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}},oauth2AuthorizeURL:t=>{const s=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 s?`${e}/oauth2/authorize?${s}`:`${e}/oauth2/authorize`},oauth2AuthorizePostURL:()=>`${e}/oauth2/authorize`,oauth2Token:async(t,a)=>{const r=`${e}/oauth2/token`,i=new URLSearchParams;void 0!==t.grant_type&&i.append("grant_type",String(t.grant_type)),void 0!==t.code&&i.append("code",String(t.code)),void 0!==t.redirect_uri&&i.append("redirect_uri",String(t.redirect_uri)),void 0!==t.client_id&&i.append("client_id",String(t.client_id)),void 0!==t.client_secret&&i.append("client_secret",String(t.client_secret)),void 0!==t.code_verifier&&i.append("code_verifier",String(t.code_verifier)),void 0!==t.refresh_token&&i.append("refresh_token",String(t.refresh_token)),void 0!==t.resource&&i.append("resource",String(t.resource));const o=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",...a?.headers},body:i.toString()});if(o.status>=300){const t=[412].includes(o.status)?null:await o.text();throw new s(t?JSON.parse(t):{},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}},oauth2UserinfoGet:async t=>{const a=`${e}/oauth2/userinfo`,r=await n(a,{...t,method:"GET",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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}},oauth2UserinfoPost:async t=>{const a=`${e}/oauth2/userinfo`,r=await n(a,{...t,method:"POST",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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}},oauth2Jwks:async t=>{const a=`${e}/oauth2/jwks`,r=await n(a,{...t,method:"GET",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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}},oauth2Revoke:async(t,a)=>{const r=`${e}/oauth2/revoke`,i=new URLSearchParams;void 0!==t.token&&i.append("token",String(t.token)),void 0!==t.token_type_hint&&i.append("token_type_hint",String(t.token_type_hint)),void 0!==t.client_id&&i.append("client_id",String(t.client_id)),void 0!==t.client_secret&&i.append("client_secret",String(t.client_secret));const o=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",...a?.headers},body:i.toString()});if(o.status>=300){const t=[412].includes(o.status)?null:await o.text();throw new s(t?JSON.parse(t):{},o.status,o.headers)}return{body:void 0,status:o.status,headers:o.headers}},oauth2Introspect:async(t,a)=>{const r=`${e}/oauth2/introspect`,i=new URLSearchParams;void 0!==t.token&&i.append("token",String(t.token)),void 0!==t.token_type_hint&&i.append("token_type_hint",String(t.token_type_hint)),void 0!==t.client_id&&i.append("client_id",String(t.client_id)),void 0!==t.client_secret&&i.append("client_secret",String(t.client_secret));const o=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",...a?.headers},body:i.toString()});if(o.status>=300){const t=[412].includes(o.status)?null:await o.text();throw new s(t?JSON.parse(t):{},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}},oauth2LoginGet:async(t,a)=>{const r=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("&"),i=r?`${e}/oauth2/login?${r}`:`${e}/oauth2/login`,o=await n(i,{...a,method:"GET",headers:{...a?.headers}});if(o.status>=300){const t=[412].includes(o.status)?null:await o.text();throw new s(t?JSON.parse(t):{},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}},oauth2LoginPost:async(t,a)=>{const r=`${e}/oauth2/login`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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}}}};function a(t){let s="";for(const e of t)s+=String.fromCharCode(e);return btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function n(){const t=new Uint8Array(32);return crypto.getRandomValues(t),a(t)}async function r(t){const s=await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(t));return a(new Uint8Array(s))}async function i(){const t=n();return{verifier:t,challenge:await r(t)}}export{e as createAPIClient,r as generateCodeChallenge,n as generateCodeVerifier,i as generatePKCEPair};
|
|
1
|
+
import{c as t,s}from"../fetch-DGzwPw2i.js";var e=(e,a=[])=>{let n=t(a);return{baseURL:e,pushChainFunction:s=>{a.push(s),n=t(a)},getJWKs:async t=>{const a=`${e}/.well-known/jwks.json`,r=await n(a,{...t,method:"GET",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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 t=>{const a=`${e}/elevate/webauthn`,r=await n(a,{...t,method:"POST",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/elevate/webauthn/verify`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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 t=>{const a=`${e}/healthz`,r=await n(a,{...t,method:"GET",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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 t=>{const a=`${e}/healthz`,r=await n(a,{...t,method:"HEAD",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},r.status,r.headers)}return{body:void 0,status:r.status,headers:r.headers}},linkIdToken:async(t,a)=>{const r=`${e}/link/idtoken`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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 t=>{const a=`${e}/mfa/totp/generate`,r=await n(a,{...t,method:"GET",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/pat`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/anonymous`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/email-password`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/idtoken`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/mfa/totp`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/otp/email`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/otp/email/verify`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/passwordless/email`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/passwordless/sms`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/passwordless/sms/otp`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/pat`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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,s)=>{const a=s&&Object.entries(s).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?`${e}/signin/provider/${t}?${a}`:`${e}/signin/provider/${t}`},getProviderTokens:async(t,a)=>{const r=`${e}/signin/provider/${t}/callback/tokens`,i=await n(r,{...a,method:"GET",headers:{...a?.headers}});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/webauthn`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signin/webauthn/verify`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signout`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signup/email-password`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signup/webauthn`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/signup/webauthn/verify`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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}},signUpPasswordlessEmail:async(t,a)=>{const r=`${e}/signup/passwordless/email`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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}},signUpOTPEmail:async(t,a)=>{const r=`${e}/signup/otp/email`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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}},signUpPasswordlessSms:async(t,a)=>{const r=`${e}/signup/passwordless/sms`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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}},signUpIdToken:async(t,a)=>{const r=`${e}/signup/idtoken`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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}},signUpProviderURL:(t,s)=>{const a=s&&Object.entries(s).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?`${e}/signup/provider/${t}?${a}`:`${e}/signup/provider/${t}`},refreshToken:async(t,a)=>{const r=`${e}/token`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a,r)=>{const i=`${e}/token/provider/${t}`,o=await n(i,{...r,method:"POST",headers:{"Content-Type":"application/json",...r?.headers},body:JSON.stringify(a)});if(o.status>=300){const t=[412].includes(o.status)?null:await o.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/token/verify`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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 t=>{const a=`${e}/user`,r=await n(a,{...t,method:"GET",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/user/deanonymize`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/user/email/change`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/user/email/send-verification-email`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/user/mfa`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/user/password`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/user/password/reset`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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 t=>{const a=`${e}/user/webauthn/add`,r=await n(a,{...t,method:"POST",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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(t,a)=>{const r=`${e}/user/webauthn/verify`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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}},tokenExchange:async(t,a)=>{const r=`${e}/token/exchange`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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 s=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 s?`${e}/verify?${s}`:`${e}/verify`},getVersion:async t=>{const a=`${e}/version`,r=await n(a,{...t,method:"GET",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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}},getOpenIDConfiguration:async t=>{const a=`${e}/.well-known/openid-configuration`,r=await n(a,{...t,method:"GET",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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}},getOAuthAuthorizationServer:async t=>{const a=`${e}/.well-known/oauth-authorization-server`,r=await n(a,{...t,method:"GET",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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}},oauth2AuthorizeURL:t=>{const s=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 s?`${e}/oauth2/authorize?${s}`:`${e}/oauth2/authorize`},oauth2AuthorizePostURL:()=>`${e}/oauth2/authorize`,oauth2Token:async(t,a)=>{const r=`${e}/oauth2/token`,i=new URLSearchParams;void 0!==t.grant_type&&i.append("grant_type",String(t.grant_type)),void 0!==t.code&&i.append("code",String(t.code)),void 0!==t.redirect_uri&&i.append("redirect_uri",String(t.redirect_uri)),void 0!==t.client_id&&i.append("client_id",String(t.client_id)),void 0!==t.client_secret&&i.append("client_secret",String(t.client_secret)),void 0!==t.code_verifier&&i.append("code_verifier",String(t.code_verifier)),void 0!==t.refresh_token&&i.append("refresh_token",String(t.refresh_token)),void 0!==t.resource&&i.append("resource",String(t.resource));const o=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",...a?.headers},body:i.toString()});if(o.status>=300){const t=[412].includes(o.status)?null:await o.text();throw new s(t?JSON.parse(t):{},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}},oauth2UserinfoGet:async t=>{const a=`${e}/oauth2/userinfo`,r=await n(a,{...t,method:"GET",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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}},oauth2UserinfoPost:async t=>{const a=`${e}/oauth2/userinfo`,r=await n(a,{...t,method:"POST",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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}},oauth2Jwks:async t=>{const a=`${e}/oauth2/jwks`,r=await n(a,{...t,method:"GET",headers:{...t?.headers}});if(r.status>=300){const t=[412].includes(r.status)?null:await r.text();throw new s(t?JSON.parse(t):{},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}},oauth2Revoke:async(t,a)=>{const r=`${e}/oauth2/revoke`,i=new URLSearchParams;void 0!==t.token&&i.append("token",String(t.token)),void 0!==t.token_type_hint&&i.append("token_type_hint",String(t.token_type_hint)),void 0!==t.client_id&&i.append("client_id",String(t.client_id)),void 0!==t.client_secret&&i.append("client_secret",String(t.client_secret));const o=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",...a?.headers},body:i.toString()});if(o.status>=300){const t=[412].includes(o.status)?null:await o.text();throw new s(t?JSON.parse(t):{},o.status,o.headers)}return{body:void 0,status:o.status,headers:o.headers}},oauth2Introspect:async(t,a)=>{const r=`${e}/oauth2/introspect`,i=new URLSearchParams;void 0!==t.token&&i.append("token",String(t.token)),void 0!==t.token_type_hint&&i.append("token_type_hint",String(t.token_type_hint)),void 0!==t.client_id&&i.append("client_id",String(t.client_id)),void 0!==t.client_secret&&i.append("client_secret",String(t.client_secret));const o=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",...a?.headers},body:i.toString()});if(o.status>=300){const t=[412].includes(o.status)?null:await o.text();throw new s(t?JSON.parse(t):{},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}},oauth2LoginGet:async(t,a)=>{const r=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("&"),i=r?`${e}/oauth2/login?${r}`:`${e}/oauth2/login`,o=await n(i,{...a,method:"GET",headers:{...a?.headers}});if(o.status>=300){const t=[412].includes(o.status)?null:await o.text();throw new s(t?JSON.parse(t):{},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}},oauth2LoginPost:async(t,a)=>{const r=`${e}/oauth2/login`,i=await n(r,{...a,method:"POST",headers:{"Content-Type":"application/json",...a?.headers},body:JSON.stringify(t)});if(i.status>=300){const t=[412].includes(i.status)?null:await i.text();throw new s(t?JSON.parse(t):{},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}}}};function a(t){let s="";for(const e of t)s+=String.fromCharCode(e);return btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function n(){const t=new Uint8Array(32);return crypto.getRandomValues(t),a(t)}async function r(t){const s=await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(t));return a(new Uint8Array(s))}async function i(){const t=n();return{verifier:t,challenge:await r(t)}}export{e as createAPIClient,r as generateCodeChallenge,n as generateCodeVerifier,i as generatePKCEPair};
|
|
2
2
|
//# sourceMappingURL=auth.js.map
|