import type { ConnectionScopeFactory } from "@remit/backend/create-remit-client"; import type { AccountItem } from "@remit/data-ports"; import { ConflictError } from "@remit/data-ports/errors"; import type { Logger } from "@remit/logger"; import type { ConnectionScope } from "@remit/mailbox-service"; import type { MailCredentials } from "@remit/mailbox-service/types"; import type { TokenService } from "./context.js"; /** * The account holds no credential a connection can be opened with: it stores * none, or its OAuth consent was withdrawn. The account has already been * flipped to the state that says so; the caller has to reconnect it. */ export declare class AccountNeedsReconnectError extends ConflictError { name: string; constructor(accountId: string); } export type OpenConnection = (account: AccountItem, credentials: MailCredentials) => ConnectionScope | Promise; /** * The read path's connection scope, resolving credentials under the same OAuth * lifecycle the queue handlers run: a rotated refresh token is persisted, and a * revoked token or a missing credential flips the account's connection state * and answers 409 instead of surfacing as a 500. */ export declare const lifecycleConnectionScope: (tokenService: TokenService, open: OpenConnection, log: Logger) => ConnectionScopeFactory;