import { AgentSecret, LocalNode } from "cojson"; import { AuthSecretStorage } from "../auth/AuthSecretStorage.js"; import { KvStore } from "../auth/KvStoreContext.js"; import { Account } from "../coValues/account.js"; import { AuthCredentials } from "../types.js"; import { JazzContextType } from "../types.js"; import { AnonymousJazzAgent } from "./anonymousJazzAgent.js"; import { SubscriptionCache } from "../subscribe/SubscriptionCache.js"; export type JazzContextManagerAuthProps = { credentials?: AuthCredentials; newAccountProps?: { secret: AgentSecret; creationProps: { name: string; }; }; }; export type JazzContextManagerBaseProps = { onAnonymousAccountDiscarded?: (anonymousAccount: Acc) => Promise; onLogOut?: () => void | Promise; logOutReplacement?: () => void | Promise; }; type PlatformSpecificAuthContext = { me: Acc; node: LocalNode; logOut: () => Promise; done: () => void; addConnectionListener: (listener: (connected: boolean) => void) => () => void; connected: () => boolean; }; type PlatformSpecificGuestContext = { guest: AnonymousJazzAgent; node: LocalNode; logOut: () => Promise; done: () => void; addConnectionListener: (listener: (connected: boolean) => void) => () => void; connected: () => boolean; }; type PlatformSpecificContext = PlatformSpecificAuthContext | PlatformSpecificGuestContext; export declare class JazzContextManager> { protected value: JazzContextType | undefined; protected context: PlatformSpecificContext | undefined; protected props: P | undefined; protected authSecretStorage: AuthSecretStorage; protected keepContextOpen: boolean; contextPromise: Promise | undefined; protected authenticatingAccountID: string | null; private subscriptionCache; constructor(opts?: { useAnonymousFallback?: boolean; authSecretStorageKey?: string; }); getKvStore(): KvStore; createContext(props: P, authProps?: JazzContextManagerAuthProps): Promise; getNewContext(props: P, authProps?: JazzContextManagerAuthProps): Promise>; updateContext(props: P, context: PlatformSpecificContext, authProps?: JazzContextManagerAuthProps): Promise; propsChanged(props: P): void; getCurrentValue(): JazzContextType | undefined; setCurrentValue(value: JazzContextType): void; getAuthSecretStorage(): AuthSecretStorage; getAuthenticatingAccountID(): string | null; getSubscriptionScopeCache(): SubscriptionCache; /** * Flag to indicate if a logout operation is currently in progress. * Used to prevent concurrent logout attempts or double-logout issues. * Set to true when logout starts, reset to false once all logout logic runs. */ loggingOut: boolean; /** * Handles the logout process. * Uses the loggingOut flag to ensure only one logout can happen at a time. */ logOut: () => Promise; done: () => void; shouldMigrateAnonymousAccount: () => Promise; /** * Authenticates the user with the given credentials * @param credentials - The credentials to authenticate with * @param forceContextCreation - If true, the context will be created even if the same account is already authenticated */ authenticate: (credentials: AuthCredentials, forceContextCreation?: boolean) => Promise; register: (accountSecret: AgentSecret, creationProps: { name: string; }) => Promise; private handleAnonymousAccountMigration; listeners: Set<() => void>; subscribe: (callback: () => void) => () => void; notify(): void; } export {}; //# sourceMappingURL=ContextManager.d.ts.map