@corbado/react-sdk
Advanced tools
Comparing version 0.1.7-alpha.4 to 0.1.7-alpha.6
@@ -1,1 +0,7 @@ | ||
export * from './CorbadoProvider'; | ||
import type { CorbadoAppParams } from '@corbado/types'; | ||
import { CorbadoApp } from '@corbado/web-core'; | ||
import type { FC, PropsWithChildren } from 'react'; | ||
export type CorbadoProviderParams = PropsWithChildren<CorbadoAppParams & { | ||
corbadoAppInstance?: CorbadoApp; | ||
}>; | ||
export declare const CorbadoProvider: FC<CorbadoProviderParams>; |
export { useCorbado } from './useCorbado'; | ||
export { useCorbadoSession } from './useCorbadoSession'; |
/// <reference types="react" /> | ||
import type { CorbadoContextProps } from '../contexts/CorbadoContext'; | ||
export declare const useCorbado: (context?: import("react").Context<CorbadoContextProps>) => CorbadoContextProps; | ||
import type { CorbadoAppContextProps } from '../contexts/CorbadoAppContext'; | ||
export declare const useCorbado: (context?: import("react").Context<CorbadoAppContextProps>) => CorbadoAppContextProps; |
@@ -1,2 +0,2 @@ | ||
import*as e from"@corbado/web-core";import*as a from"react";var i={d:(e,a)=>{for(var r in a)i.o(a,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:a[r]})},o:(e,a)=>Object.prototype.hasOwnProperty.call(e,a)},r={};i.d(r,{Hg:()=>E,lH:()=>t.InvalidEmailError,bu:()=>t.InvalidFullnameError,zT:()=>t.InvalidOtpInputError,CU:()=>t.InvalidPasskeyError,nJ:()=>t.NoPasskeyAvailableError,X$:()=>t.PasskeyChallengeCancelledError,eA:()=>t.UnknownUserError,k5:()=>t.UserAlreadyExistsError,km:()=>h});const t=(s={CorbadoApp:()=>e.CorbadoApp,InvalidEmailError:()=>e.InvalidEmailError,InvalidFullnameError:()=>e.InvalidFullnameError,InvalidOtpInputError:()=>e.InvalidOtpInputError,InvalidPasskeyError:()=>e.InvalidPasskeyError,NoPasskeyAvailableError:()=>e.NoPasskeyAvailableError,PasskeyChallengeCancelledError:()=>e.PasskeyChallengeCancelledError,UnknownUserError:()=>e.UnknownUserError,UserAlreadyExistsError:()=>e.UserAlreadyExistsError},l={},i.d(l,s),l);var s,l;const o=(e=>{var a={};return i.d(a,e),a})({createContext:()=>a.createContext,default:()=>a.default,useCallback:()=>a.useCallback,useContext:()=>a.useContext,useEffect:()=>a.useEffect,useMemo:()=>a.useMemo,useRef:()=>a.useRef,useState:()=>a.useState}),n=()=>{throw new Error("Please make sure that your components are wrapped inside <CorbadoProvider/>")},u={corbadoApp:void 0,shortSession:void 0,user:void 0,globalError:void 0,loading:!1,signUpWithPasskey:n,loginWithPasskey:n,loginWithConditionalUI:n,initLoginWithEmailOTP:n,completeLoginWithEmailOTP:n,logout:n,initSignUpWithEmailOTP:n,completeSignUpWithEmailOTP:n,initSignUpWithEmailLink:n,completeSignUpWithEmailLink:n,initLoginWithEmailLink:n,completeLoginWithEmailLink:n,appendPasskey:n,getPasskeys:n,deletePasskey:n,getUserAuthMethods:n,getProjectConfig:n,userExists:n},c=(0,o.createContext)(u),E=({children:e,corbadoAppInstance:a,...i})=>{const[r]=(0,o.useState)((()=>null!=a?a:new t.CorbadoApp(i))),[s,l]=(0,o.useState)(),[n,u]=(0,o.useState)(),[E,h]=(0,o.useState)(!0),[d,k]=(0,o.useState)(),p=(0,o.useRef)(!1);(0,o.useEffect)((()=>{p.current||(h(!0),r.init(),r.authService.shortSessionChanges.subscribe((e=>{void 0!==e&&l(e)})),r.authService.userChanges.subscribe((e=>{void 0!==e&&u(e)})),r.globalErrors.subscribe((e=>{k(e)})),p.current=!0,h(!1))}),[]);const g=(0,o.useCallback)(((e,a)=>r.authService.signUpWithPasskey(e,a)),[r]),m=(0,o.useCallback)((e=>r.authService.loginWithPasskey(e)),[r]),v=(0,o.useCallback)((()=>r.authService.loginWithConditionalUI()),[r]),C=(0,o.useCallback)((()=>r.authService.appendPasskey()),[r]),b=(0,o.useCallback)((()=>r.authService.passkeyList()),[r]),P=(0,o.useCallback)((e=>r.authService.passkeyDelete(e)),[r]),S=(0,o.useCallback)((e=>r.authService.initLoginWithEmailLink(e)),[r]),y=(0,o.useCallback)((()=>r.authService.completeLoginWithEmailLink()),[r]),W=(0,o.useCallback)(((e,a)=>r.authService.initSignUpWithEmailLink(e,a)),[r]),U=(0,o.useCallback)((()=>r.authService.completeSignupWithEmailLink()),[r]),L=(0,o.useCallback)((e=>r.authService.initLoginWithEmailOTP(e)),[r]),I=(0,o.useCallback)((e=>r.authService.completeLoginWithEmailOTP(e)),[r]),f=(0,o.useCallback)(((e,a)=>r.authService.initSignUpWithEmailOTP(e,a)),[r]),O=(0,o.useCallback)((e=>r.authService.completeSignupWithEmailOTP(e)),[r]),A=(0,o.useCallback)((e=>r.authService.authMethods(e)),[r]),x=(0,o.useCallback)((e=>r.authService.userExists(e)),[r]),T=(0,o.useCallback)((()=>r.projectService.getProjectConfig()),[r]),w=(0,o.useCallback)((()=>{r.authService.logout(),l(void 0),u(void 0)}),[r]),j=(0,o.useMemo)((()=>({corbadoApp:r,shortSession:s,user:n,globalError:d,loading:E,signUpWithPasskey:g,loginWithPasskey:m,loginWithConditionalUI:v,initLoginWithEmailOTP:L,completeLoginWithEmailOTP:I,initSignUpWithEmailOTP:f,completeSignUpWithEmailOTP:O,initLoginWithEmailLink:S,completeLoginWithEmailLink:y,initSignUpWithEmailLink:W,completeSignUpWithEmailLink:U,appendPasskey:C,getPasskeys:b,deletePasskey:P,getUserAuthMethods:A,getProjectConfig:T,userExists:x,logout:w})),[r,s,n,d,E,w,g,m,v,L,I,f,O,S,y,W,U,C,b,P,A,T,x]);return o.default.createElement(c.Provider,{value:j},e)},h=(e=c)=>(0,o.useContext)(e);var d=r.Hg,k=r.lH,p=r.bu,g=r.zT,m=r.CU,v=r.nJ,C=r.X$,b=r.eA,P=r.k5,S=r.km;export{d as CorbadoProvider,k as InvalidEmailError,p as InvalidFullnameError,g as InvalidOtpInputError,m as InvalidPasskeyError,v as NoPasskeyAvailableError,C as PasskeyChallengeCancelledError,b as UnknownUserError,P as UserAlreadyExistsError,S as useCorbado}; | ||
import*as e from"@corbado/web-core";import*as a from"react";var r={d:(e,a)=>{for(var i in a)r.o(a,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:a[i]})},o:(e,a)=>Object.prototype.hasOwnProperty.call(e,a)},i={};r.d(i,{Hg:()=>p,lH:()=>t.InvalidEmailError,bu:()=>t.InvalidFullnameError,zT:()=>t.InvalidOtpInputError,CU:()=>t.InvalidPasskeyError,nJ:()=>t.NoPasskeyAvailableError,X$:()=>t.PasskeyChallengeCancelledError,eA:()=>t.UnknownUserError,k5:()=>t.UserAlreadyExistsError,km:()=>k,Ye:()=>g});const t=(o={CorbadoApp:()=>e.CorbadoApp,InvalidEmailError:()=>e.InvalidEmailError,InvalidFullnameError:()=>e.InvalidFullnameError,InvalidOtpInputError:()=>e.InvalidOtpInputError,InvalidPasskeyError:()=>e.InvalidPasskeyError,NoPasskeyAvailableError:()=>e.NoPasskeyAvailableError,PasskeyChallengeCancelledError:()=>e.PasskeyChallengeCancelledError,UnknownUserError:()=>e.UnknownUserError,UserAlreadyExistsError:()=>e.UserAlreadyExistsError},s={},r.d(s,o),s);var o,s;const l=(e=>{var a={};return r.d(a,e),a})({createContext:()=>a.createContext,default:()=>a.default,memo:()=>a.memo,useCallback:()=>a.useCallback,useContext:()=>a.useContext,useEffect:()=>a.useEffect,useRef:()=>a.useRef,useState:()=>a.useState}),n=()=>{throw new Error("Please make sure that your components are wrapped inside <CorbadoProvider/>")},u={corbadoApp:void 0,globalError:void 0,loading:!1,isAuthenticated:!1,signUpWithPasskey:n,loginWithPasskey:n,loginWithConditionalUI:n,initLoginWithEmailOTP:n,completeLoginWithEmailOTP:n,logout:n,initSignUpWithEmailOTP:n,completeSignUpWithEmailOTP:n,initSignUpWithEmailLink:n,completeSignUpWithEmailLink:n,initLoginWithEmailLink:n,completeLoginWithEmailLink:n,appendPasskey:n,getPasskeys:n,deletePasskey:n,getUserAuthMethods:n,getProjectConfig:n,userExists:n},c=(0,l.createContext)(u),d=(0,l.memo)((({children:e,corbadoApp:a,loading:r,globalError:i,isAuthenticated:t})=>{const o=(0,l.useCallback)(((e,r)=>a.authService.signUpWithPasskey(e,r)),[a]),s=(0,l.useCallback)((e=>a.authService.loginWithPasskey(e)),[a]),n=(0,l.useCallback)((()=>a.authService.loginWithConditionalUI()),[a]),u=(0,l.useCallback)((()=>a.authService.appendPasskey()),[a]),d=(0,l.useCallback)((()=>a.authService.passkeyList()),[a]),h=(0,l.useCallback)((e=>a.authService.passkeyDelete(e)),[a]),E=(0,l.useCallback)((e=>a.authService.initLoginWithEmailLink(e)),[a]),p=(0,l.useCallback)((()=>a.authService.completeLoginWithEmailLink()),[a]),k=(0,l.useCallback)(((e,r)=>a.authService.initSignUpWithEmailLink(e,r)),[a]),g=(0,l.useCallback)((()=>a.authService.completeSignupWithEmailLink()),[a]),m=(0,l.useCallback)((e=>a.authService.initLoginWithEmailOTP(e)),[a]),b=(0,l.useCallback)((e=>a.authService.completeLoginWithEmailOTP(e)),[a]),v=(0,l.useCallback)(((e,r)=>a.authService.initSignUpWithEmailOTP(e,r)),[a]),C=(0,l.useCallback)((e=>a.authService.completeSignupWithEmailOTP(e)),[a]),P=(0,l.useCallback)((e=>a.authService.authMethods(e)),[a]),S=(0,l.useCallback)((e=>a.authService.userExists(e)),[a]),y=(0,l.useCallback)((()=>a.projectService.getProjectConfig()),[a]),W=(0,l.useCallback)((()=>{a.authService.logout(),a.clearGlobalErrors()}),[a]);return l.default.createElement(c.Provider,{value:{corbadoApp:a,globalError:i,loading:r,isAuthenticated:t,signUpWithPasskey:o,loginWithPasskey:s,loginWithConditionalUI:n,initLoginWithEmailOTP:m,completeLoginWithEmailOTP:b,initSignUpWithEmailOTP:v,completeSignUpWithEmailOTP:C,initLoginWithEmailLink:E,completeLoginWithEmailLink:p,initSignUpWithEmailLink:k,completeSignUpWithEmailLink:g,appendPasskey:u,getPasskeys:d,deletePasskey:h,getUserAuthMethods:P,getProjectConfig:y,userExists:S,logout:W}},e)})),h=(0,l.createContext)({shortSession:void 0,loading:!0,isAuthenticated:!1,user:void 0}),E=({children:e,loading:a,isAuthenticated:r,shortSession:i,user:t})=>l.default.createElement(h.Provider,{value:{shortSession:i,loading:a,user:t,isAuthenticated:r}},e),p=({children:e,corbadoAppInstance:a,...r})=>{const[i]=(0,l.useState)((()=>null!=a?a:new t.CorbadoApp(r))),[o,s]=(0,l.useState)(!0),[n,u]=(0,l.useState)(),[c,h]=(0,l.useState)(),[p,k]=(0,l.useState)(!1),[g,m]=(0,l.useState)(),b=(0,l.useRef)(!1);return(0,l.useEffect)((()=>{b.current||(s(!0),i.init().then((()=>{b.current=!0,s(!1)})),i.authService.userChanges.subscribe((e=>{u(e)})),i.globalErrors.subscribe((e=>{h(e)})),i.authService.authStateChanges.subscribe((e=>{k(!!e)})),i.authService.shortSessionChanges.subscribe((e=>{m(e)})))}),[]),l.default.createElement(E,{loading:o,user:n,isAuthenticated:p,shortSession:g},l.default.createElement(d,{corbadoApp:i,loading:o,isAuthenticated:p,globalError:c},e))},k=(e=c)=>{const a=(0,l.useContext)(e);if(!a)throw new Error("Please make sure that your components are wrapped inside <CorbadoProvider />");return a},g=(e=h)=>{const a=(0,l.useContext)(e);if(!a)throw new Error("Please make sure that your components are wrapped inside <CorbadoProvider />");return a};var m=i.Hg,b=i.lH,v=i.bu,C=i.zT,P=i.CU,S=i.nJ,y=i.X$,W=i.eA,U=i.k5,A=i.km,L=i.Ye;export{m as CorbadoProvider,b as InvalidEmailError,v as InvalidFullnameError,C as InvalidOtpInputError,P as InvalidPasskeyError,S as NoPasskeyAvailableError,y as PasskeyChallengeCancelledError,W as UnknownUserError,U as UserAlreadyExistsError,A as useCorbado,L as useCorbadoSession}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@corbado/react-sdk", | ||
"version": "0.1.7-alpha.4", | ||
"version": "0.1.7-alpha.6", | ||
"description": "This SDK is for developers who want to add Corbado's Authentication management in their applications but want to use a UI flow of their own.", | ||
@@ -38,9 +38,9 @@ "author": "Abdullah Shahbaz <abdullah_ghani@live.com>", | ||
"dependencies": { | ||
"@corbado/web-core": "^0.1.7-alpha.4" | ||
"@corbado/web-core": "^0.1.7-alpha.6" | ||
}, | ||
"devDependencies": { | ||
"@corbado/types": "^0.1.1-alpha.4", | ||
"@corbado/types": "^0.1.1-alpha.6", | ||
"@types/react": "^18.2.0" | ||
}, | ||
"gitHead": "3bd63094494204828688170d7461932d5786de53" | ||
"gitHead": "428496e91739752ac47e54808f2124a6ce6bcc2a" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37554
14
107