react-with-sanctum
Version:
React package for easy authenticate with Laravel Sanctum
39 lines (38 loc) • 1.56 kB
TypeScript
import * as React from 'react';
import { AxiosError } from 'axios';
interface Props {
config: {
apiUrl: string;
csrfCookieRoute: string;
signInRoute: string;
signUpRoute: string;
signOutRoute: string;
forgotPasswordRoute: string;
resetPasswordRoute: string;
userObjectRoute: string;
};
checkOnInit?: boolean;
}
interface State {
user: null | Record<string, never> | false;
authenticated: null | boolean;
}
declare class Sanctum extends React.Component<Props, State> {
static defaultProps: {
checkOnInit: boolean;
};
constructor(props: Props);
handleError(error: AxiosError): boolean | AxiosError;
getCSRF(): Promise<boolean | AxiosError>;
getUserData(): Promise<Record<string, never> | AxiosError | boolean>;
checkAuthentication(): Promise<boolean | AxiosError>;
signIn(signInData: Record<string, never>): Promise<() => Promise<Record<string, never> | AxiosError | boolean>>;
signUp(signUpData: Record<string, never>): Promise<() => Promise<Record<string, never> | AxiosError | boolean>>;
forgotPassword(forgotPasswordData: Record<string, never>): Promise<boolean | AxiosError>;
resetPassword(resetPasswordData: Record<string, never>): Promise<boolean | AxiosError>;
signOut(): Promise<boolean | AxiosError>;
setUser(user: Record<string, never> | false | null, authenticated?: boolean): void;
componentDidMount(): void;
render(): JSX.Element;
}
export default Sanctum;