import { EventEmitter } from 'events'; import { AccountAPI } from './account/AccountAPI'; import { AssetAPI } from './asset/'; import { AccessTokenData, AuthAPI, Context, Cookie, InvalidTokenError, LoginData, RegisterData } from './auth/'; import { BroadcastAPI } from './broadcast/'; import { CellsAPI } from './cells/CellsAPI'; import { ClientAPI, ClientType } from './client/'; import { Config } from './Config'; import { ConnectionAPI } from './connection/'; import { ConversationAPI } from './conversation/'; import { GenericAPI } from './generic'; import { GiphyAPI } from './giphy/'; import { HttpClient } from './http/'; import { NotificationAPI } from './notification/'; import { OAuthAPI } from './oauth/OAuthAPI'; import { SelfAPI } from './self/'; import { ServiceProviderAPI } from './serviceProvider'; import { ServicesAPI } from './services'; import { OnConnect, WebSocketClient } from './tcp/'; import { FeatureAPI, IdentityProviderAPI, LegalHoldAPI, MemberAPI, PaymentAPI, BillingAPI, ServiceAPI, TeamAPI, TeamConversationAPI, TeamInvitationAPI } from './team/'; import { ScimAPI } from './team/scim/ScimAPI'; import { TeamSearchAPI } from './team/search'; import { SSOAPI } from './team/sso'; import { UserAPI } from './user/'; import { UserGroupAPI } from './userGroups/'; declare enum TOPIC { ACCESS_TOKEN_REFRESH = "APIClient.TOPIC.ACCESS_TOKEN_REFRESH", COOKIE_REFRESH = "APIClient.TOPIC.COOKIE_REFRESH", /** Event being sent when logout is done. */ ON_LOGOUT = "APIClient.TOPIC.ON_LOGOUT" } export interface APIClient { on(event: TOPIC.ON_LOGOUT, listener: (error: InvalidTokenError) => void): this; on(event: TOPIC.COOKIE_REFRESH, listener: (cookie?: Cookie) => void): this; on(event: TOPIC.ACCESS_TOKEN_REFRESH, listener: (accessToken: AccessTokenData) => void): this; } type Apis = { account: AccountAPI; asset: AssetAPI; auth: AuthAPI; broadcast: BroadcastAPI; cells: CellsAPI; client: ClientAPI; connection: ConnectionAPI; conversation: ConversationAPI; giphy: GiphyAPI; notification: NotificationAPI; oauth: OAuthAPI; self: SelfAPI; services: ServicesAPI; serviceProvider: ServiceProviderAPI; teams: { conversation: TeamConversationAPI; feature: FeatureAPI; identityProvider: IdentityProviderAPI; invitation: TeamInvitationAPI; legalhold: LegalHoldAPI; member: MemberAPI; payment: PaymentAPI; billing: BillingAPI; scim: ScimAPI; search: TeamSearchAPI; service: ServiceAPI; sso: SSOAPI; team: TeamAPI; }; userGroup: UserGroupAPI; user: UserAPI; generic: GenericAPI; }; /** map of all the features that the backend supports (depending on the backend api version number) */ export type BackendFeatures = { /** The actual version used to communicate with backend */ version: number; /** Does the backend API support federated endpoints */ federationEndpoints: boolean; /** Is the backend actually talking to other federated domains */ isFederated: boolean; /** Does the backend API support MLS features */ supportsMLS: boolean; /** Does the backend API support creating guest links with password */ supportsGuestLinksWithPassword: boolean; domain: string; }; export type BackendVersionResponse = { supported: number[]; federation?: boolean; development?: number[]; domain: string; }; export declare class APIClient extends EventEmitter { private readonly logger; api: Apis; private cellsApi; private readonly accessTokenStore; context?: Context; transport: { http: HttpClient; ws: WebSocketClient; }; config: Config; backendFeatures: BackendFeatures; private cookieRefreshListener?; static BACKEND: { PRODUCTION: import("./env/Backend").BackendData; STAGING: import("./env/Backend").BackendData; }; static readonly TOPIC: typeof TOPIC; static VERSION: string; constructor(config?: Config); private configureApis; /** * Will compute all the capabilities of the backend API according to the selected version and the version response payload * @param backendVersion The agreed used version between the client and the backend * @param responsePayload? The response from the server */ private computeBackendFeatures; /** * Sets the API client to use the highest supported version within a given range, * with a hard minimum of version 8 enforced. * * @param min - Minimum acceptable version (must be ≥ 8) * @param max - Maximum acceptable version * @param allowDev - If true, allows using development versions from the backend * @returns Backend feature configuration for the selected version * @throws Error if no compatible version is found */ useVersion(min: number, max: number, allowDev?: boolean): Promise; /** * Returns the highest version from the list that falls within the specified range. * * @param versions - List of available versions * @param min - Minimum required version * @param max - Maximum allowed version * @returns The highest version in the allowed range, or undefined if none are compatible */ private findHighestCompatibleVersion; init(clientType?: ClientType, cookie?: Cookie): Promise; login(loginData: LoginData): Promise; loginWithToken(accessTokenString: string, clientType?: ClientType): Promise; register(userAccount: RegisterData, clientType?: ClientType): Promise; logout(options?: { skipLogoutRequest: boolean; }): Promise; connect(onConnect?: OnConnect): WebSocketClient; private createContext; disconnect(reason?: string): void; get clientId(): string | undefined; get userId(): string | undefined; get domain(): string | undefined; /** Should be used in cases where the user ID is MANDATORY. */ get validatedUserId(): string; /** Should be used in cases where the client ID is MANDATORY. */ get validatedClientId(): string; /** * Will check if MLS is supported by backend (whether the api version used supports MLS, and whether a backend removal key is present). */ supportsMLS(): Promise; } export {}; //# sourceMappingURL=APIClient.d.ts.map