import { RequestOptions, type UploadForm } from '../Chat.js'; import { ServiceId } from '../../Address.js'; import { type SingleOutboundUnsealedMessage } from './SingleOutboundMessage.js'; declare module '../Chat' { interface AuthenticatedChatConnection extends AuthMessagesService { } } /** See {@link AuthMessagesService#sendMessage}. */ export type SendMessageRequest = Readonly<{ destination: ServiceId; timestamp: number; contents: Readonly; onlineOnly: boolean; urgent: boolean; }>; /** See {@link AuthMessagesService#sendSyncMessage}. */ export type SendSyncMessageRequest = Readonly<{ timestamp: number; contents: Readonly; urgent: boolean; }>; export interface AuthMessagesService { /** * Get an attachment upload form * * @throws {UploadTooLarge} if `uploadSize` is too large */ getUploadForm: (request: { uploadSize: bigint; }, options?: RequestOptions) => Promise; /** * Sends a 1:1 unsealed message. * * @throws {MismatchedDevicesError} if the recipient devices specified in `contents` are out of * date in some way. This is not a "partial success" result; the message has not been sent to * anybody. * @throws {ServiceIdNotFound} if the destination account has been unregistered. * @throws {RateLimitChallengeError} if a challenge must be completed before sending this message. * @throws {ChatServiceInactive} if the chat connection has been closed. * @throws {IoError} if an error occurred while communicating with the server. * @throws {RateLimitedError} if the server is rate limiting this client. This is **retryable** * after waiting the designated delay. * * @see {@link MismatchedDevicesEntry} */ sendMessage: (request: SendMessageRequest, options?: RequestOptions) => Promise; /** * Sends a 1:1 message to linked devices. * * @throws {MismatchedDevicesError} if the recipient devices specified in `contents` are out of * date in some way. This is not a "partial success" result; the message has not been sent to * anybody. * @throws {RateLimitChallengeError} if a challenge must be completed before sending this message. * @throws {ChatServiceInactive} if the chat connection has been closed. * @throws {IoError} if an error occurred while communicating with the server. * @throws {RateLimitedError} if the server is rate limiting this client. This is **retryable** * after waiting the designated delay. * * @see {@link MismatchedDevicesEntry} */ sendSyncMessage: (request: SendSyncMessageRequest, options?: RequestOptions) => Promise; }