import { type LoaderFunctionArgs, type SessionData } from '@remix-run/node'; import type { AuthKitLoaderOptions, AuthorizedData, DataWithResponseInit, Session, UnauthorizedData } from './interfaces.js'; export type TypedResponse = Response & { json(): Promise; }; export declare class SessionRefreshError extends Error { constructor(cause: unknown); } /** * This function is used to refresh the session by using the refresh token. * It will authenticate the user with the refresh token and return a new session object. * @param request - The request object * @param options - Optional configuration options * @returns A promise that resolves to the new session object */ export declare function refreshSession(request: Request, { organizationId }?: { organizationId?: string; }): Promise<{ user: import("@workos-inc/node").User; sessionId: string; accessToken: string; organizationId: string | undefined; role: string | undefined; roles: string[] | undefined; permissions: string[] | undefined; entitlements: string[] | undefined; impersonator: import("@workos-inc/node").Impersonator | null; sealedSession: any; headers: Record; }>; export declare function encryptSession(session: Session): Promise; type LoaderValue = Response | TypedResponse | NonNullable | null; type LoaderReturnValue = Promise> | LoaderValue; type AuthLoader = (args: LoaderFunctionArgs & { auth: AuthorizedData | UnauthorizedData; getAccessToken: () => string | null; }) => LoaderReturnValue; type AuthorizedAuthLoader = (args: LoaderFunctionArgs & { auth: AuthorizedData; getAccessToken: () => string; }) => LoaderReturnValue; /** * This loader handles authentication state, session management, and access token refreshing * automatically, making it easier to build authenticated routes. * * Creates an authentication-aware loader function for React Router. * * This loader handles authentication state, session management, and access token refreshing * automatically, making it easier to build authenticated routes. * * @overload * Basic usage with enforced authentication that redirects unauthenticated users to sign in. * * @param loaderArgs - The loader arguments provided by React Router * @param options - Configuration options with enforced sign-in * * @example * export async function loader({ request }: LoaderFunctionArgs) { * return authkitLoader( * { request }, * { ensureSignedIn: true } * ); * } */ export declare function authkitLoader(loaderArgs: LoaderFunctionArgs, options: AuthKitLoaderOptions & { ensureSignedIn: true; }): Promise>; /** * This loader handles authentication state, session management, and access token refreshing * automatically, making it easier to build authenticated routes. * * @overload * Basic usage without enforced authentication, allowing both signed-in and anonymous users. * * @param loaderArgs - The loader arguments provided by React Router * @param options - Optional configuration options * * @example * export async function loader({ request }: LoaderFunctionArgs) { * return authkitLoader({ request }); * } */ export declare function authkitLoader(loaderArgs: LoaderFunctionArgs, options?: AuthKitLoaderOptions): Promise>; /** * This loader handles authentication state, session management, and access token refreshing * automatically, making it easier to build authenticated routes. * * @overload * Custom loader with enforced authentication, providing your own loader function * that will only be called for authenticated users. * * @param loaderArgs - The loader arguments provided by React Router * @param loader - A custom loader function that receives authentication data * @param options - Configuration options with enforced sign-in * * @example * export async function loader({ request }: LoaderFunctionArgs) { * return authkitLoader( * { request }, * async ({ auth }) => { * // This will only be called for authenticated users * const userData = await fetchUserData(auth.accessToken); * return { userData }; * }, * { ensureSignedIn: true } * ); * } */ export declare function authkitLoader(loaderArgs: LoaderFunctionArgs, loader: AuthorizedAuthLoader, options: AuthKitLoaderOptions & { ensureSignedIn: true; }): Promise>; /** * This loader handles authentication state, session management, and access token refreshing * automatically, making it easier to build authenticated routes. * * @overload * Custom loader without enforced authentication, providing your own loader function * that will be called for both authenticated and unauthenticated users. * * @param loaderArgs - The loader arguments provided by React Router * @param loader - A custom loader function that receives authentication data * @param options - Optional configuration options * * @example * export async function loader({ request }: LoaderFunctionArgs) { * return authkitLoader( * { request }, * async ({ auth }) => { * if (auth.user) { * // User is authenticated * const userData = await fetchUserData(auth.accessToken); * return { userData }; * } else { * // User is not authenticated * return { publicData: await fetchPublicData() }; * } * } * ); * } */ export declare function authkitLoader(loaderArgs: LoaderFunctionArgs, loader: AuthLoader, options?: AuthKitLoaderOptions): Promise>; export declare function terminateSession(request: Request, { returnTo }?: { returnTo?: string; }): Promise>; export declare function getClaimsFromAccessToken(accessToken: string): { iss: string | undefined; exp: number | undefined; sessionId: string; organizationId: string | undefined; role: string | undefined; roles: string[] | undefined; permissions: string[] | undefined; entitlements: string[] | undefined; }; export declare function getSessionFromCookie(cookie: string, session?: SessionData): Promise; export {};