import { ReactNode } from 'react';
import { Actor, InspectionEvent, Observer } from 'xstate';
import { authMachine } from './auth';
import { AuthTransport } from './transport';
export interface AuthContextType {
    authActor: Actor<typeof authMachine>;
    /**
     * The visitor's identity. Held steady for the duration of a session
     * transition — see the `AuthProvider` doc block for the two ordering
     * constraints that hold depends on (it must be mounted inside
     * `SessionTransitionProvider`, and the gate is `transitionRef`, not
     * `isTransitioning`).
     *
     * This is the ONLY session value published here. "Is a session change
     * happening?" belongs to `useSessionTransition()`, not to auth state.
     *
     * There used to be an `isLoggingOut` flag too, derived from
     * `unauthenticating || loggedOut.afterLogout`. It is deliberately gone:
     * `afterLogout` is a TERMINAL state, so the flag stayed true for the life of
     * the actor and wedged everything gated on it — the header account menu became
     * permanently unclickable, the logout overlay reappeared on unrelated pages,
     * and the account-page sign-in redirect stopped firing altogether. Every
     * consumer invented its own escape hatch and none of them held. Removing it
     * outright is what stops that being reintroduced (CTAP-1151).
     */
    isLoggedIn: boolean;
}
export declare const useAuth: () => AuthContextType;
type AuthOptions = {
    inspect: Observer<InspectionEvent> | undefined;
    endpoints: {
        login: string;
        logout: string;
        refresh: string;
        ssrRefresh: string;
    };
    /** Header injection for the auth HTTP calls — see `./transport`. */
    transport?: AuthTransport;
};
/**
 * runs on server side as part of withAuth HOF
 *
 * @todo should probably update signature to pass Partial<AuthContext> and
 * Options, endpoints should probably be moved into context
 */
export declare const getAuth: (refreshToken?: string, options?: AuthOptions) => Promise<Actor<import('xstate').StateMachine<import('./types').AuthMachineContext, import('./types').RefreshTokenEvent | import('./types').LoginEvent | import('./types').LogoutEvent | import('./types').SessionExpiredEvent | import('./types').SessionReissuedEvent | import('./types').ClearErrorsEvent | import('./types').RestoreEvent | import('xstate').DoneActorEvent<import('./types').AuthenticateSuccessEvent, string> | import('xstate').DoneActorEvent<import('./types').RefreshTokenSuccessEvent, string>, {
    [x: string]: import('xstate').ActorRefFromLogic<import('xstate').PromiseActorLogic<import('./types').AuthenticateSuccessEvent, import('./actors').AuthenticateInput, import('xstate').EventObject>> | import('xstate').ActorRefFromLogic<import('xstate').PromiseActorLogic<import('./types').RefreshTokenSuccessEvent, import('./actors').RefreshTokenInput, import('xstate').EventObject>> | import('xstate').ActorRefFromLogic<import('xstate').PromiseActorLogic<import('./types').UnauthenticateSuccessEvent, import('./actors').UnauthenticateInput, import('xstate').EventObject>> | undefined;
}, {
    src: "authenticate";
    logic: import('xstate').PromiseActorLogic<import('./types').AuthenticateSuccessEvent, import('./actors').AuthenticateInput, import('xstate').EventObject>;
    id: string | undefined;
} | {
    src: "refreshAccessToken";
    logic: import('xstate').PromiseActorLogic<import('./types').RefreshTokenSuccessEvent, import('./actors').RefreshTokenInput, import('xstate').EventObject>;
    id: string | undefined;
} | {
    src: "unauthenticate";
    logic: import('xstate').PromiseActorLogic<import('./types').UnauthenticateSuccessEvent, import('./actors').UnauthenticateInput, import('xstate').EventObject>;
    id: string | undefined;
}, {
    type: "addError";
    params: import('xstate').NonReducibleUnknown;
} | {
    type: "clearErrors";
    params: import('xstate').NonReducibleUnknown;
} | {
    type: "notifyAuthenticated";
    params: import('xstate').NonReducibleUnknown;
} | {
    type: "notifyUnauthenticated";
    params: import('xstate').NonReducibleUnknown;
} | {
    type: "setAccessToken";
    params: import('xstate').NonReducibleUnknown;
} | {
    type: "setReissuedAccessToken";
    params: import('xstate').NonReducibleUnknown;
} | {
    type: "notifyReissued";
    params: import('xstate').NonReducibleUnknown;
} | {
    type: "setIgnoreRefreshToken";
    params: import('xstate').NonReducibleUnknown;
} | {
    type: "markDeliberateLogout";
    params: import('xstate').NonReducibleUnknown;
} | {
    type: "markExpiredSession";
    params: import('xstate').NonReducibleUnknown;
} | {
    type: "setUserContext";
    params: import('xstate').NonReducibleUnknown;
} | {
    type: "unsetRefreshToken";
    params: import('xstate').NonReducibleUnknown;
} | {
    type: "unsetUserContext";
    params: import('xstate').NonReducibleUnknown;
}, never, "refresh", "initializing" | "loggedIn" | "authenticating" | "unauthenticating" | "refreshing" | "loggedInReady" | {
    loggedOut: "initial" | "afterFailedAuth" | "afterLogout" | "afterRefreshFailure";
}, string, {
    transport?: AuthTransport;
    initialContext: Partial<import('./types').AuthMachineContext>;
    initialState?: string;
}, import('xstate').NonReducibleUnknown, import('./types').AuthenticatedEmittedEvent | import('./types').UnauthenticatedEmittedEvent, import('xstate').MetaObject, {
    id: "auth";
    states: {
        readonly initializing: {};
        readonly authenticating: {};
        readonly unauthenticating: {};
        readonly refreshing: {};
        readonly loggedOut: {
            states: {
                readonly initial: {};
                readonly afterFailedAuth: {};
                readonly afterLogout: {};
                readonly afterRefreshFailure: {};
            };
        };
        readonly loggedInReady: {};
        readonly loggedIn: {};
    };
}>>>;
type Props = {
    actor: Actor<typeof authMachine>;
    children: ReactNode;
};
/**
 * Publishes the auth actor and a single derived `isLoggedIn`.
 *
 * ## Two ordering constraints you can get wrong silently
 *
 * **1. `SessionTransitionProvider` MUST be an ancestor of this provider.**
 * `isLoggedIn` is held steady for the duration of a session transition, and that
 * hold is read from `useSessionTransition()`. Mounted outside the transition
 * provider, this reads the inert default context (`transitionRef: {current:
 * false}`) — which is safe rather than throwing, so nothing warns and nothing
 * breaks in an obvious way. The identity simply flips mid-transition anyway: the
 * overlay covers the screen while the checkout swaps to the guest email form
 * underneath it, and the browser offers autofill for the guest email.
 *
 * **2. The hold is gated on `transitionRef`, not `isTransitioning`** — and any
 * consumer mirroring this identity into its own state must do the same.
 * `isTransitioning` is React state, so it only reflects a transition after a
 * re-render, while actor subscriptions fire synchronously on the machine's own
 * transitions and routinely outrun it: a local sign-out reaches `afterLogout`
 * while `isTransitioning` still reads `false`. If you keep a copy of the
 * identity (feeding a router provider, say), the fix is to **delete the mirror
 * and read the held value here** rather than to reproduce the ref gating.
 *
 * ## Why the identity is held but the actor is not
 *
 * The actor freeze in the app's provider tree covers the quote/checkout
 * subtrees, but the auth actor must stay LIVE — components send LOGIN/LOGOUT
 * through it and several subscribe directly, so a frozen proxy would deadlock
 * sign-in. The identity alone is held; transition progress stays live because the
 * overlay renders from it (CTAP-1150/1151).
 */
export declare function AuthProvider({ actor, children }: Props): import("react/jsx-runtime").JSX.Element;
export {};
