import { AtpBaseClient, AtpServiceClient, ComAtprotoServerCreateAccount, ComAtprotoServerCreateSession, ComAtprotoServerGetSession } from './client'; import { AtpSessionData, AtpAgentLoginOpts, AtpAgentFetchHandler, AtpAgentGlobalOpts, AtpPersistSessionHandler, AtpAgentOpts, AtprotoServiceType } from './types'; /** * An ATP "Agent" * Manages session token lifecycles and provides convenience methods. */ export declare class AtpAgent { service: URL; api: AtpServiceClient; session?: AtpSessionData; labelersHeader: string[]; proxyHeader: string | undefined; pdsUrl: URL | undefined; protected _baseClient: AtpBaseClient; protected _persistSession?: AtpPersistSessionHandler; protected _refreshSessionPromise: Promise | undefined; get com(): import("./client").ComNS; /** * The `fetch` implementation; must be implemented for your platform. */ static fetch: AtpAgentFetchHandler | undefined; /** * The labelers to be used across all requests with the takedown capability */ static appLabelers: string[]; /** * Configures the API globally. */ static configure(opts: AtpAgentGlobalOpts): void; constructor(opts: AtpAgentOpts); clone(): AtpAgent; copyInto(inst: AtpAgent): void; withProxy(serviceType: AtprotoServiceType, did: string): AtpAgent; /** * Is there any active session? */ get hasSession(): boolean; /** * Sets the "Persist Session" method which can be used to store access tokens * as they change. */ setPersistSessionHandler(handler?: AtpPersistSessionHandler): void; /** * Configures the moderation services to be applied on requests. * NOTE: this is called automatically by getPreferences() and the relevant moderation config * methods in BskyAgent instances. */ configureLabelersHeader(labelerDids: string[]): void; /** * Configures the atproto-proxy header to be applied on requests */ configureProxyHeader(serviceType: AtprotoServiceType, did: string): void; /** * Create a new account and hydrate its session in this agent. */ createAccount(opts: ComAtprotoServerCreateAccount.InputSchema): Promise; /** * Start a new session with this agent. */ login(opts: AtpAgentLoginOpts): Promise; /** * Resume a pre-existing session with this agent. */ resumeSession(session: AtpSessionData): Promise; /** * Internal helper to add authorization headers to requests. */ private _addHeaders; /** * Internal fetch handler which adds access-token management */ private _fetch; /** * Internal helper to refresh sessions * - Wraps the actual implementation in a promise-guard to ensure only * one refresh is attempted at a time. */ refreshSession(): Promise; /** * Internal helper to refresh sessions (actual behavior) */ private _refreshSessionInner; /** * Upload a binary blob to the server */ uploadBlob: typeof this.api.com.atproto.repo.uploadBlob; /** * Resolve a handle to a DID */ resolveHandle: typeof this.api.com.atproto.identity.resolveHandle; /** * Change the user's handle */ updateHandle: typeof this.api.com.atproto.identity.updateHandle; /** * Create a moderation report */ createModerationReport: typeof this.api.com.atproto.moderation.createReport; /** * Helper to update the pds endpoint dynamically. * * The session methods (create, resume, refresh) may respond with the user's * did document which contains the user's canonical PDS endpoint. That endpoint * may differ from the endpoint used to contact the server. We capture that * PDS endpoint and update the client to use that given endpoint for future * requests. (This helps ensure smooth migrations between PDSes, especially * when the PDSes are operated by a single org.) */ private _updateApiEndpoint; } //# sourceMappingURL=agent.d.ts.map