@aws-amplify/core
Version:
Core category of aws-amplify
29 lines (28 loc) • 1.64 kB
TypeScript
import { AmplifyContext } from '../../context/AmplifyContext';
import { AuthSession, FetchAuthSessionOptions } from '../Auth/types';
/**
* Fetch the auth session of the given {@link AmplifyContext} — e.g. the
* per-request context handed to an SSR `runWithAmplifyServerContext`
* operation — instead of the global context. This restores the pre-context
* v6 SSR calling pattern `fetchAuthSession(contextSpec)` (the deprecated
* `ContextSpec` type is an alias of `AmplifyContext`, so existing SSR code
* compiles unchanged).
*
* @param ctx - The explicit {@link AmplifyContext} whose auth providers are used.
* @param options - Options configuring the fetch behavior.
* @throws {@link AuthError} - Throws error when session information cannot be refreshed.
* @returns Promise<AuthSession>
*/
export declare function fetchAuthSession(ctx: AmplifyContext, options?: FetchAuthSessionOptions): Promise<AuthSession>;
/**
* Fetch the auth session including the tokens and credentials if they are available. By default it
* will automatically refresh expired auth tokens if a valid refresh token is present. You can force a refresh
* of non-expired tokens with `{ forceRefresh: true }` input.
*
* @param options - Options configuring the fetch behavior.
* @throws {@link AuthError} - Throws error when session information cannot be refreshed.
* @returns Promise<AuthSession> — before `Amplify.configure()` has run this
* resolves with an empty session (all fields `undefined`), matching the
* pre-context behavior.
*/
export declare function fetchAuthSession(options?: FetchAuthSessionOptions): Promise<AuthSession>;