import type { Did } from '@atcute/lexicons'; import type { OAuthServerFactory } from './oauth-server-factory.ts'; import type { SessionStore, StoredSession } from './types/sessions.ts'; import { CachedGetter, type GetCachedOptions } from './utils/cached-getter.ts'; import type { LockFunction } from './utils/lock.ts'; export type { SessionStore, StoredSession }; export type SessionEventType = 'updated' | 'deleted'; export interface SessionUpdatedEvent { type: 'updated'; sub: Did; session: StoredSession; } export interface SessionDeletedEvent { type: 'deleted'; sub: Did; cause: unknown; } export type SessionEvent = SessionUpdatedEvent | SessionDeletedEvent; export type SessionEventListener = (event: SessionEvent) => void; export interface SessionGetterOptions { /** session store */ sessionStore: SessionStore; /** server factory for creating OAuthServerAgent */ serverFactory: OAuthServerFactory; /** * lock function for coordinating token refresh across processes. * * only needed for multi-process/distributed deployments where multiple * instances might try to refresh the same session concurrently. * single-process deployments can omit this. */ requestLock?: LockFunction; } /** * manages session retrieval and automatic token refresh. * * wraps a session store with caching and staleness checking. * automatically refreshes tokens when they're about to expire. */ export declare class SessionGetter extends CachedGetter { private readonly listeners; private readonly requestLock; constructor(options: SessionGetterOptions); /** * adds a listener for session events. */ addEventListener(listener: SessionEventListener): void; /** * removes a session event listener. */ removeEventListener(listener: SessionEventListener): void; private dispatchEvent; setStored(sub: Did, session: StoredSession): Promise; deleteStored(sub: Did, cause?: unknown): Promise; /** * gets a session, optionally forcing a refresh. * * @param sub user's DID * @param refresh true to force refresh, false to allow stale, 'auto' for normal behavior * @returns session data */ getSession(sub: Did, refresh?: boolean | 'auto'): Promise; get(sub: Did, options?: GetCachedOptions): Promise; } //# sourceMappingURL=session-getter.d.ts.map