UNPKG

@better-auth-ui/core

Version:

Authentication components and data utilities for [Better Auth](https://better-auth.com), available for React and Solid.

49 lines (48 loc) 2.16 kB
export declare const REAUTHENTICATION_QUERY_PARAM = "reauthenticate"; /** * Build a callback URL from an optional origin, a configured base path, and a * view path. * * Separators are normalized so custom paths work whether callers include * leading or trailing slashes. */ export declare function getViewURL(baseURL: string, basePath: string, viewPath: string): string; /** * Add the current post-authentication destination to an internal auth link. */ export declare function getAuthLinkURL(href: string, redirectTo: string): string; /** Build a sign-in URL that returns to the exact current page after authentication. */ export declare function getReauthenticationSignInURL(currentURL: URL, signInPath: string): string; /** Return whether the current sign-in URL was opened for reauthentication. */ export declare function isReauthenticationSignInURL(currentURL: URL): boolean; /** * Normalize a redirect target to a same-origin path. * * Root-relative paths and same-origin HTTP(S) URLs are accepted. Invalid, * cross-origin, protocol-relative, and non-HTTP targets fall back to `/`. * * @param redirectTo - Requested redirect target * @param origin - Origin used to validate and normalize the target * @returns A same-origin path including its query string and hash */ export declare function getSafeRedirectTo(redirectTo: string | null | undefined, origin: string): string; export type AuthRedirectAction = { type: "redirect"; to: string; } | { type: "signIn"; to: string; }; /** * Resolve the next action for the authenticated redirect view. * * Signed-in users continue to the validated target. Signed-out users are sent * to sign in with the current redirect-view URL preserved, allowing the view * to perform a full-page redirect after authentication. * * @param currentURL - Current redirect-view URL * @param authenticated - Whether the current user has a session * @param signInPath - Same-origin path to the sign-in view * @returns The redirect or sign-in action to perform */ export declare function getAuthRedirectAction(currentURL: URL, authenticated: boolean, signInPath: string): AuthRedirectAction;