136 lines
4.6 KiB
TypeScript
136 lines
4.6 KiB
TypeScript
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
import { ReactNode } from 'react';
|
|
|
|
type AuthGuardProps = {
|
|
children: React.ReactNode;
|
|
fetchCurrentUser: () => Promise<unknown>;
|
|
redirectTo?: string;
|
|
loadingFallback?: React.ReactNode;
|
|
authenticatedWrapper?: (children: React.ReactNode) => React.ReactNode;
|
|
};
|
|
declare function AuthGuard({ children, fetchCurrentUser, redirectTo, loadingFallback, authenticatedWrapper }: AuthGuardProps): react_jsx_runtime.JSX.Element;
|
|
|
|
type AuthProviderKey = "google" | "slack" | (string & {});
|
|
type AuthProviderAvailability = Partial<Record<AuthProviderKey, boolean>>;
|
|
type LoginMode = "signIn" | "register";
|
|
type AuthSubmitValues = {
|
|
name: string;
|
|
email: string;
|
|
password: string;
|
|
passwordConfirm: string;
|
|
};
|
|
type PasswordResetMode = "reset" | "create";
|
|
type PasswordResetTokenState = {
|
|
status: "loading";
|
|
} | {
|
|
status: "invalid";
|
|
error: string;
|
|
} | {
|
|
status: "valid";
|
|
email: string;
|
|
mode: PasswordResetMode;
|
|
};
|
|
|
|
type CreateAuthClientOptions = {
|
|
apiUrl: (path: string) => string;
|
|
authUrl?: (path: string) => string;
|
|
fetchImpl?: typeof fetch;
|
|
credentials?: RequestCredentials;
|
|
defaultOAuthCallbackUrl?: string | (() => string);
|
|
};
|
|
type LoginInput = {
|
|
email: string;
|
|
password: string;
|
|
};
|
|
type RegisterInput = LoginInput & {
|
|
name: string;
|
|
};
|
|
declare function createAuthClient(options: CreateAuthClientOptions): {
|
|
getProviders(): Promise<AuthProviderAvailability>;
|
|
getCurrentUser<TUser>(): Promise<TUser>;
|
|
register(input: RegisterInput): Promise<void>;
|
|
login(input: LoginInput): Promise<void>;
|
|
requestPasswordReset(email: string): Promise<void>;
|
|
validatePasswordResetToken(token: string): Promise<{
|
|
email: string;
|
|
mode: PasswordResetMode;
|
|
}>;
|
|
confirmPasswordReset(input: {
|
|
token: string;
|
|
password: string;
|
|
}): Promise<void>;
|
|
logout(): Promise<void>;
|
|
startOAuthSignIn(provider: string, callbackUrl?: string): Promise<void>;
|
|
};
|
|
|
|
type LoginFormTexts = {
|
|
nameLabel: string;
|
|
emailLabel: string;
|
|
passwordLabel: string;
|
|
passwordConfirmLabel: string;
|
|
submitRegisterLabel: string;
|
|
submitSignInLabel: string;
|
|
toggleToRegisterLabel: string;
|
|
toggleToSignInLabel: string;
|
|
forgotPasswordLabel: string;
|
|
googleLabel: string;
|
|
slackLabel: string;
|
|
};
|
|
type LoginFormProps = {
|
|
mode: LoginMode;
|
|
texts: LoginFormTexts;
|
|
onSubmit: (values: AuthSubmitValues) => void | Promise<void>;
|
|
onModeToggle: () => void;
|
|
loading?: boolean;
|
|
oauthLoadingProvider?: AuthProviderKey | null;
|
|
providers?: AuthProviderAvailability;
|
|
onOAuthSignIn?: (provider: AuthProviderKey) => void | Promise<void>;
|
|
errorMessage?: string | null;
|
|
successMessage?: string | null;
|
|
footer?: ReactNode;
|
|
forgotPasswordLink?: ReactNode;
|
|
emailPlaceholder?: string;
|
|
namePlaceholder?: string;
|
|
};
|
|
declare function LoginForm({ mode, texts, onSubmit, onModeToggle, loading, oauthLoadingProvider, providers, onOAuthSignIn, errorMessage, successMessage, footer, forgotPasswordLink, emailPlaceholder, namePlaceholder }: LoginFormProps): react_jsx_runtime.JSX.Element;
|
|
|
|
type PasswordResetRequestTexts = {
|
|
emailLabel: string;
|
|
submitLabel: string;
|
|
requestSentMessage: string;
|
|
};
|
|
type PasswordResetRequestFormProps = {
|
|
texts: PasswordResetRequestTexts;
|
|
helperText: ReactNode;
|
|
loading?: boolean;
|
|
requestSent?: boolean;
|
|
onSubmit: (values: {
|
|
email: string;
|
|
}) => void | Promise<void>;
|
|
emailPlaceholder?: string;
|
|
};
|
|
type PasswordResetConfirmTexts = {
|
|
loadingLabel: string;
|
|
passwordLabel: string;
|
|
passwordConfirmLabel: string;
|
|
invalidLinkLabel: string;
|
|
resetSubmitLabel: string;
|
|
createSubmitLabel: string;
|
|
resetSuccessLabel: string;
|
|
createSuccessLabel: string;
|
|
};
|
|
type PasswordResetConfirmFormProps = {
|
|
texts: PasswordResetConfirmTexts;
|
|
tokenState: PasswordResetTokenState;
|
|
loading?: boolean;
|
|
completedMode?: PasswordResetMode | null;
|
|
onSubmit: (values: {
|
|
password: string;
|
|
passwordConfirm: string;
|
|
}) => void | Promise<void>;
|
|
};
|
|
declare function PasswordResetRequestForm({ texts, helperText, loading, requestSent, onSubmit, emailPlaceholder }: PasswordResetRequestFormProps): react_jsx_runtime.JSX.Element;
|
|
declare function PasswordResetConfirmForm({ texts, tokenState, loading, completedMode, onSubmit }: PasswordResetConfirmFormProps): react_jsx_runtime.JSX.Element;
|
|
|
|
export { AuthGuard, type AuthProviderAvailability, type AuthProviderKey, type AuthSubmitValues, LoginForm, type LoginMode, PasswordResetConfirmForm, type PasswordResetMode, PasswordResetRequestForm, type PasswordResetTokenState, createAuthClient };
|