@corbado/react-sdk
Advanced tools
Comparing version 1.0.2 to 1.1.0-alpha.0
@@ -34,4 +34,5 @@ /// <reference types="react" /> | ||
logout: () => void; | ||
setGlobalError: (error: NonRecoverableError | undefined) => void; | ||
} | ||
export declare const initialContext: CorbadoAppContextProps; | ||
export declare const CorbadoAppContext: import("react").Context<CorbadoAppContextProps>; |
@@ -8,4 +8,5 @@ import type { CorbadoApp, NonRecoverableError } from '@corbado/web-core'; | ||
globalError: NonRecoverableError | undefined; | ||
setGlobalError: (error: NonRecoverableError | undefined) => void; | ||
}>; | ||
export declare const CorbadoAppProvider: FC<CorbadoAppProviderParams>; | ||
export {}; |
@@ -1,4 +0,4 @@ | ||
import { InvalidEmailError, InvalidFullnameError, InvalidOtpInputError, InvalidPasskeyError, NoPasskeyAvailableError, PasskeyChallengeCancelledError, UnknownUserError, UserAlreadyExistsError } from '@corbado/web-core'; | ||
import { InvalidEmailError, InvalidFullnameError, InvalidOtpInputError, InvalidPasskeyError, NonRecoverableError, NoPasskeyAvailableError, PasskeyChallengeCancelledError, UnknownUserError, UserAlreadyExistsError } from '@corbado/web-core'; | ||
export * from './contexts'; | ||
export * from './hooks'; | ||
export { InvalidPasskeyError, NoPasskeyAvailableError, InvalidOtpInputError, PasskeyChallengeCancelledError, UnknownUserError, UserAlreadyExistsError, InvalidFullnameError, InvalidEmailError, }; | ||
export { InvalidPasskeyError, NoPasskeyAvailableError, InvalidOtpInputError, PasskeyChallengeCancelledError, UnknownUserError, UserAlreadyExistsError, InvalidFullnameError, InvalidEmailError, NonRecoverableError, }; |
@@ -1,2 +0,2 @@ | ||
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}; | ||
import*as e from"@corbado/web-core";import*as r from"react";var a={d:(e,r)=>{for(var i in r)a.o(r,i)&&!a.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r)},i={};a.d(i,{Hg:()=>p,lH:()=>t.InvalidEmailError,bu:()=>t.InvalidFullnameError,zT:()=>t.InvalidOtpInputError,CU:()=>t.InvalidPasskeyError,nJ:()=>t.NoPasskeyAvailableError,X1:()=>t.NonRecoverableError,X$:()=>t.PasskeyChallengeCancelledError,eA:()=>t.UnknownUserError,k5:()=>t.UserAlreadyExistsError,km:()=>g,Ye:()=>k});const t=(o={CorbadoApp:()=>e.CorbadoApp,InvalidEmailError:()=>e.InvalidEmailError,InvalidFullnameError:()=>e.InvalidFullnameError,InvalidOtpInputError:()=>e.InvalidOtpInputError,InvalidPasskeyError:()=>e.InvalidPasskeyError,NoPasskeyAvailableError:()=>e.NoPasskeyAvailableError,NonRecoverableError:()=>e.NonRecoverableError,PasskeyChallengeCancelledError:()=>e.PasskeyChallengeCancelledError,UnknownUserError:()=>e.UnknownUserError,UserAlreadyExistsError:()=>e.UserAlreadyExistsError},s={},a.d(s,o),s);var o,s;const l=(e=>{var r={};return a.d(r,e),r})({createContext:()=>r.createContext,default:()=>r.default,memo:()=>r.memo,useCallback:()=>r.useCallback,useContext:()=>r.useContext,useEffect:()=>r.useEffect,useRef:()=>r.useRef,useState:()=>r.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,setGlobalError:n},c=(0,l.createContext)(u),d=(0,l.memo)((({children:e,corbadoApp:r,loading:a,globalError:i,isAuthenticated:t,setGlobalError:o})=>{const s=(0,l.useCallback)(((e,a)=>r.authService.signUpWithPasskey(e,a)),[r]),n=(0,l.useCallback)((e=>r.authService.loginWithPasskey(e)),[r]),u=(0,l.useCallback)((()=>r.authService.loginWithConditionalUI()),[r]),d=(0,l.useCallback)((()=>r.authService.appendPasskey()),[r]),E=(0,l.useCallback)((()=>r.authService.passkeyList()),[r]),h=(0,l.useCallback)((e=>r.authService.passkeyDelete(e)),[r]),p=(0,l.useCallback)((e=>r.authService.initLoginWithEmailLink(e)),[r]),g=(0,l.useCallback)((()=>r.authService.completeLoginWithEmailLink()),[r]),k=(0,l.useCallback)(((e,a)=>r.authService.initSignUpWithEmailLink(e,a)),[r]),b=(0,l.useCallback)((()=>r.authService.completeSignupWithEmailLink()),[r]),m=(0,l.useCallback)((e=>r.authService.initLoginWithEmailOTP(e)),[r]),v=(0,l.useCallback)((e=>r.authService.completeLoginWithEmailOTP(e)),[r]),C=(0,l.useCallback)(((e,a)=>r.authService.initSignUpWithEmailOTP(e,a)),[r]),P=(0,l.useCallback)((e=>r.authService.completeSignupWithEmailOTP(e)),[r]),S=(0,l.useCallback)((e=>r.authService.authMethods(e)),[r]),y=(0,l.useCallback)((e=>r.authService.userExists(e)),[r]),W=(0,l.useCallback)((()=>r.projectService.getProjectConfig()),[r]),U=(0,l.useCallback)((()=>{r.authService.logout(),r.clearGlobalErrors()}),[r]);return l.default.createElement(c.Provider,{value:{corbadoApp:r,globalError:i,loading:a,isAuthenticated:t,signUpWithPasskey:s,loginWithPasskey:n,loginWithConditionalUI:u,initLoginWithEmailOTP:m,completeLoginWithEmailOTP:v,initSignUpWithEmailOTP:C,completeSignUpWithEmailOTP:P,initLoginWithEmailLink:p,completeLoginWithEmailLink:g,initSignUpWithEmailLink:k,completeSignUpWithEmailLink:b,appendPasskey:d,getPasskeys:E,deletePasskey:h,getUserAuthMethods:S,getProjectConfig:W,userExists:y,logout:U,setGlobalError:o}},e)})),E=(0,l.createContext)({shortSession:void 0,loading:!0,isAuthenticated:!1,user:void 0}),h=({children:e,loading:r,isAuthenticated:a,shortSession:i,user:t})=>l.default.createElement(E.Provider,{value:{shortSession:i,loading:r,user:t,isAuthenticated:a}},e),p=({children:e,corbadoAppInstance:r,...a})=>{const[i]=(0,l.useState)((()=>null!=r?r:new t.CorbadoApp(a))),[o,s]=(0,l.useState)(!0),[n,u]=(0,l.useState)(),[c,E]=(0,l.useState)(),[p,g]=(0,l.useState)(!1),[k,b]=(0,l.useState)(),m=(0,l.useRef)(!1);return(0,l.useEffect)((()=>{m.current||(s(!0),i.init().then((()=>{m.current=!0,s(!1)})),i.authService.userChanges.subscribe((e=>{u(e)})),i.globalErrors.subscribe((e=>{E(e)})),i.authService.authStateChanges.subscribe((e=>{g(!!e)})),i.authService.shortSessionChanges.subscribe((e=>{b(e)})))}),[]),l.default.createElement(h,{loading:o,user:n,isAuthenticated:p,shortSession:k},l.default.createElement(d,{corbadoApp:i,loading:o,isAuthenticated:p,globalError:c,setGlobalError:e=>{i.globalErrors.next(e)}},e))},g=(e=c)=>{const r=(0,l.useContext)(e);if(!r)throw new Error("Please make sure that your components are wrapped inside <CorbadoProvider />");return r},k=(e=E)=>{const r=(0,l.useContext)(e);if(!r)throw new Error("Please make sure that your components are wrapped inside <CorbadoProvider />");return r};var b=i.Hg,m=i.lH,v=i.bu,C=i.zT,P=i.CU,S=i.nJ,y=i.X1,W=i.X$,U=i.eA,A=i.k5,L=i.km,f=i.Ye;export{b as CorbadoProvider,m as InvalidEmailError,v as InvalidFullnameError,C as InvalidOtpInputError,P as InvalidPasskeyError,S as NoPasskeyAvailableError,y as NonRecoverableError,W as PasskeyChallengeCancelledError,U as UnknownUserError,A as UserAlreadyExistsError,L as useCorbado,f as useCorbadoSession}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@corbado/react-sdk", | ||
"version": "1.0.2", | ||
"version": "1.1.0-alpha.0", | ||
"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": "^1.0.2" | ||
"@corbado/web-core": "^1.1.0-alpha.0" | ||
}, | ||
"devDependencies": { | ||
"@corbado/types": "^1.0.2", | ||
"@corbado/types": "^1.1.0-alpha.0", | ||
"@types/react": "^18.2.0" | ||
}, | ||
"gitHead": "8dbcf1a3a958c904553dda08394a2da89eee5e20" | ||
"gitHead": "42c5765ce208dc6f62308853040924c4c4b60e75" | ||
} |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
38998
109
1