@heymarco/next-auth
Version:
A complete authentication solution for web applications.
115 lines (114 loc) • 4.78 kB
TypeScript
import { default as React } from 'react';
import type { BuiltInProviderType } from '@auth/core/providers';
import { EventHandler, GlobalStackableProps } from '@reusable-ui/core';
import { ModalExpandedChangeEvent, ModalBaseProps } from '@reusable-ui/components';
import type { CredentialsConfigClient } from '../../types.js';
import { FieldHandlers } from '../hooks.js';
export type SignInSection = 'signUp' | 'signIn' | 'recover' | 'reset';
export type ControllableSignInSection = Exclude<SignInSection, 'reset'>;
export type BusyState = false | 'signUp' | BuiltInProviderType | 'recover' | 'reset';
export type ValidityStatus = boolean | 'unknown' | 'loading' | 'error';
export interface SignInState {
nameMinLength: number;
nameMaxLength: number;
emailMinLength: number;
emailMaxLength: number;
emailFormat: RegExp;
emailFormatHint: React.ReactNode;
usernameMinLength: number;
usernameMaxLength: number;
usernameFormat: RegExp;
usernameFormatHint: React.ReactNode;
usernameProhibitedHint: React.ReactNode;
passwordMinLength: number;
passwordMaxLength: number;
passwordHasUppercase: boolean;
passwordHasLowercase: boolean;
passwordProhibitedHint: React.ReactNode;
callbackUrl: string | null;
passwordResetToken: string | null;
emailConfirmationToken: string | null;
section: SignInSection;
isSignUpSection: boolean;
isSignInSection: boolean;
isRecoverSection: boolean;
isResetSection: boolean;
tokenVerified: null | {} | false;
emailVerified: null | boolean;
isSignUpApplied: boolean;
isRecoverApplied: boolean;
isResetApplied: boolean;
isBusy: BusyState;
userInteracted: boolean;
formRef: React.MutableRefObject<HTMLFormElement | null>;
nameRef: React.MutableRefObject<HTMLInputElement | null>;
name: string;
nameHandlers: FieldHandlers<HTMLInputElement>;
nameFocused: boolean;
nameValid: boolean;
nameValidLength: boolean;
emailRef: React.MutableRefObject<HTMLInputElement | null>;
email: string;
emailHandlers: FieldHandlers<HTMLInputElement>;
emailFocused: boolean;
emailValid: ValidityStatus;
emailValidLength: boolean;
emailValidFormat: boolean;
emailValidAvailable: ValidityStatus;
usernameRef: React.MutableRefObject<HTMLInputElement | null>;
username: string;
usernameHandlers: FieldHandlers<HTMLInputElement>;
usernameFocused: boolean;
usernameValid: ValidityStatus;
usernameValidLength: boolean;
usernameValidFormat: boolean;
usernameValidAvailable: ValidityStatus;
usernameValidNotProhibited: ValidityStatus;
usernameOrEmailRef: React.MutableRefObject<HTMLInputElement | null>;
usernameOrEmail: string;
usernameOrEmailHandlers: FieldHandlers<HTMLInputElement>;
usernameOrEmailFocused: boolean;
usernameOrEmailValid: boolean;
passwordRef: React.MutableRefObject<HTMLInputElement | null>;
password: string;
passwordHandlers: FieldHandlers<HTMLInputElement>;
passwordFocused: boolean;
passwordValid: ValidityStatus;
passwordValidLength: boolean;
passwordValidUppercase: boolean;
passwordValidLowercase: boolean;
passwordValidNotProhibited: ValidityStatus;
password2Ref: React.MutableRefObject<HTMLInputElement | null>;
password2: string;
password2Handlers: FieldHandlers<HTMLInputElement>;
password2Focused: boolean;
password2Valid: boolean;
password2ValidLength: boolean;
password2ValidUppercase: boolean;
password2ValidLowercase: boolean;
password2ValidMatch: boolean;
gotoSignUp: () => void;
gotoSignIn: () => void;
gotoRecover: () => void;
gotoHome: () => void;
doSignUp: () => Promise<void>;
doSignIn: () => Promise<void>;
doSignInWith: (providerType: BuiltInProviderType) => Promise<void>;
doRecover: () => Promise<void>;
doReset: () => Promise<void>;
resolveProviderName: (oAuthProvider: BuiltInProviderType) => string;
}
export declare const useSignInState: () => SignInState;
export interface SignInStateProps {
credentialsConfigClient: CredentialsConfigClient;
resolveProviderName?: (oAuthProvider: BuiltInProviderType) => string;
basePath?: string;
homepagePath?: string;
defaultCallbackUrl?: string | null;
defaultSection?: ControllableSignInSection;
section?: ControllableSignInSection;
onSectionChange?: EventHandler<ControllableSignInSection>;
signInWithDialogComponent?: React.ReactComponentElement<any, (ModalBaseProps<Element, ModalExpandedChangeEvent<any>> & GlobalStackableProps)> | null;
}
declare const SignInStateProvider: (props: React.PropsWithChildren<SignInStateProps>) => React.JSX.Element;
export { SignInStateProvider, SignInStateProvider as default, };