UNPKG

@ttoss/react-auth

Version:

ttoss authentication module for React apps.

109 lines (102 loc) 2.54 kB
import * as react_jsx_runtime from 'react/jsx-runtime'; import * as React from 'react'; type LogoContextProps = { logo?: React.ReactNode; children?: React.ReactNode; }; type OnSignInInput = { email: string; password: string; }; type OnSignIn = (input: OnSignInInput) => void; type OnSignUpInput = { email: string; password: string; confirmPassword: string; signUpTerms?: boolean; }; type OnSignUp = (input: OnSignUpInput) => void; type OnConfirmSignUp = (input: { email: string; code: string; }) => void; type OnForgotPassword = (input: { email: string; }) => void; type OnForgotPasswordResetPassword = (input: { email: string; code: string; newPassword: string; }) => void; type AuthSignUpProps = { onSignUp: OnSignUp; onReturnToSignIn: () => void; signUpTerms?: { isRequired: boolean; terms: { label: string; url: string; }[]; }; }; type AuthLogicProps = { signUpTerms?: AuthSignUpProps['signUpTerms']; }; type AuthLayout = { fullScreen?: boolean; sideContent?: React.ReactNode; sideContentPosition?: 'left' | 'right'; }; type AuthProps = LogoContextProps & AuthLogicProps & { layout?: AuthLayout; }; declare const Auth: (props: AuthProps) => react_jsx_runtime.JSX.Element; type User = { id: string; email: string; emailVerified: string; } | null; type Tokens = { idToken: string; accessToken: string; refreshToken: string; } | null; type AuthScreen = { value: 'signIn'; context: { email?: string; }; } | { value: 'signUp'; context: Record<string, never>; } | { value: 'signUpConfirm'; context: { email: string; }; } | { value: 'signUpResendConfirmation'; context: { email: string; }; } | { value: 'forgotPassword'; context: Record<string, never>; } | { value: 'forgotPasswordResetPassword'; context: { email: string; }; }; declare const AuthProvider: ({ children }: { children: React.ReactNode; }) => react_jsx_runtime.JSX.Element | null; declare const useAuth: () => { signOut: () => Promise<any>; isAuthenticated: boolean; user: User; tokens: Tokens; screen: AuthScreen; setScreen: React.Dispatch<React.SetStateAction<AuthScreen>>; }; export { Auth, type AuthProps, AuthProvider, type OnConfirmSignUp, type OnForgotPassword, type OnForgotPasswordResetPassword, type OnSignIn, type OnSignInInput, type OnSignUp, type OnSignUpInput, useAuth };