synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
25 lines • 1.31 kB
TypeScript
import { TwoFactorAuthErrorResponse } from '@sage-bionetworks/synapse-client/generated/models/TwoFactorAuthErrorResponse';
import { TwoFactorAuthOtpType } from '@sage-bionetworks/synapse-types';
import { Dispatch, SetStateAction } from 'react';
import { ONE_TIME_PASSWORD_STEP } from '@/components/Authentication/OneTimePasswordForm';
export type UseLoginOptions = {
sessionCallback?: () => void;
twoFaErrorResponse?: TwoFactorAuthErrorResponse;
onTwoFactorAuthRequired?: (twoFaToken: Pick<TwoFactorAuthErrorResponse, 'twoFaToken' | 'userId'>) => void;
};
export type UseLoginReturn = {
step: 'CHOOSE_AUTH_METHOD' | 'USERNAME_PASSWORD' | ONE_TIME_PASSWORD_STEP | 'LOGGED_IN';
onStepChange: Dispatch<SetStateAction<UseLoginReturn['step']>>;
submitUsernameAndPassword: (username: string, password: string) => void;
submitOneTimePassword: (code: string, otpType?: TwoFactorAuthOtpType) => void;
beginTwoFactorAuthReset: (twoFaResetEndpoint: string) => void;
twoFactorAuthResetIsPending: boolean;
twoFactorAuthResetIsSuccess: boolean;
errorMessage: string | undefined;
loginIsPending: boolean;
};
/**
* Stateful hook that manages logging into Synapse
*/
export default function useLogin(opts: UseLoginOptions): UseLoginReturn;
//# sourceMappingURL=useLogin.d.ts.map