@realm/react
Version:
React specific hooks and implementation helpers for Realm
64 lines • 2.18 kB
TypeScript
export declare enum AuthOperationName {
LogIn = "logIn",
LogInWithAnonymous = "logInWithAnonymous",
LogInWithApiKey = "logInWithApiKey",
LogInWithEmailPassword = "logInWithEmailPassword",
LogInWithJWT = "logInWithJWT",
LogInWithGoogle = "logInWithGoogle",
LogInWithApple = "logInWithApple",
LogInWithFacebook = "logInWithFacebook",
LogInWithFunction = "logInWithFunction",
LogOut = "logOut",
Register = "register",
Confirm = "confirm",
ResendConfirmationEmail = "resendConfirmationEmail",
RetryCustomConfirmation = "retryCustomConfirmation",
SendResetPasswordEmail = "sendResetPasswordEmail",
ResetPassword = "resetPassword",
CallResetPasswordFunction = "callResetPasswordFunction"
}
/**
* The `AuthError` is set based on the operation name and the error message.
*/
export declare class AuthError extends Error {
operation: AuthOperationName;
constructor(operation: AuthOperationName, message: string);
}
/**
* The possible states an {@link OperationResult} can be in.
*/
export declare enum OperationState {
NotStarted = "not-started",
Pending = "pending",
Success = "success",
Error = "error"
}
/**
* Represents the state and result of a call to a hook operation. This is
* designed to allow the user to update their UI accordingly without needing to
* store separate React state to keep track of pending/error states etc.
*/
export type OperationResult = {
/**
* The current state of the operation.
*/
state: OperationState;
/**
* The string name of the current operation running.
*/
operation: AuthOperationName | null;
/**
* Convenience accessors, so users can write e.g. `loginResult.pending`
* instead of `loginResult.state === OperationState.Pending`
*/
pending: boolean;
success: boolean;
/**
* The error returned from the operation, if any. This will only be populated
* if `state === OperationState.Error`, and will be cleared each time the
* operation is called.
*/
error: AuthError | undefined;
};
export type AuthResult = OperationResult;
//# sourceMappingURL=types.d.ts.map