import * as React from "react" import { IncomingMessage } from "http" import { Session } from "." import { ProviderType } from "./providers" import { SessionContextValue } from "internals/react" export interface CtxOrReq { req?: IncomingMessage ctx?: { req: IncomingMessage } } /*************** * Session types **************/ export type GetSessionOptions = CtxOrReq & { event?: "storage" | "timer" | "hidden" | string triggerEvent?: boolean } export interface UseSessionOptions { required: R /** Defaults to `signIn` */ action?(): void } /** * React Hook that gives you access * to the logged in user's session data. * * [Documentation](https://next-auth.js.org/getting-started/client#usesession) */ export function useSession( options?: UseSessionOptions ): SessionContextValue export function getSession(options?: GetSessionOptions): Promise /******************* * CSRF Token types ******************/ /** * Returns the current Cross Site Request Forgery Token (CSRF Token) * required to make POST requests (e.g. for signing in and signing out). * You likely only need to use this if you are not using the built-in * `signIn()` and `signOut()` methods. * * [Documentation](https://next-auth.js.org/getting-started/client#getcsrftoken) */ export function getCsrfToken(ctxOrReq?: CtxOrReq): Promise /****************** * Providers types *****************/ export interface ClientSafeProvider { id: string name: string type: ProviderType signinUrl: string callbackUrl: string } /** * It calls `/api/auth/providers` and returns * a list of the currently configured authentication providers. * It can be useful if you are creating a dynamic custom sign in page. * * [Documentation](https://next-auth.js.org/getting-started/client#getproviders) */ export function getProviders(): Promise | null> /**************** * Sign in types ***************/ export type RedirectableProvider = "email" | "credentials" export type SignInProvider = RedirectableProvider | string | undefined export interface SignInOptions extends Record { /** * Defaults to the current URL. * @docs https://next-auth.js.org/getting-started/client#specifying-a-callbackurl */ callbackUrl?: string /** @docs https://next-auth.js.org/getting-started/client#using-the-redirect-false-option */ redirect?: boolean } export interface SignInResponse { error: string | undefined status: number ok: boolean url: string | null } /** Match `inputType` of `new URLSearchParams(inputType)` */ export type SignInAuthorisationParams = | string | string[][] | Record | URLSearchParams /** * Client-side method to initiate a signin flow * or send the user to the signin page listing all possible providers. * Automatically adds the CSRF token to the request. * * [Documentation](https://next-auth.js.org/getting-started/client#signin) */ export function signIn

( provider?: P, options?: SignInOptions, authorizationParams?: SignInAuthorisationParams ): Promise< P extends RedirectableProvider ? SignInResponse | undefined : undefined > /**************** * Sign out types ****************/ /** @docs https://next-auth.js.org/getting-started/client#using-the-redirect-false-option-1 */ export interface SignOutResponse { url: string } export interface SignOutParams { /** @docs https://next-auth.js.org/getting-started/client#specifying-a-callbackurl-1 */ callbackUrl?: string /** @docs https://next-auth.js.org/getting-started/client#using-the-redirect-false-option-1 */ redirect?: R } /** * Signs the user out, by removing the session cookie. * Automatically adds the CSRF token to the request. * * [Documentation](https://next-auth.js.org/getting-started/client#signout) */ export function signOut( params?: SignOutParams ): Promise /************************ * SessionProvider types ***********************/ /** @docs: https://next-auth.js.org/getting-started/client#options */ export interface SessionProviderProps { session?: Session baseUrl?: string basePath?: string /** * The amount of time (in seconds) after a session should be considered stale. * If set to `0` (default), the session will never be re-fetched. */ staleTime?: number /** * A time interval (in seconds) after which the session will be re-fetched. * If set to `0` (default), the session is not polled. */ refetchInterval?: number } /** * Provider to wrap the app in to make session data available globally. * Can also be used to throttle the number of requests to the endpoint * `/api/auth/session`. * * [Documentation](https://next-auth.js.org/getting-started/client#sessionprovider) */ export const SessionProvider: React.FC