import { ServiceId } from '../../Address.js'; import { RequestOptions } from '../Chat.js'; import { GroupSendFullToken } from '../../zkgroup/index.js'; import { SingleOutboundSealedSenderMessage } from './SingleOutboundMessage.js'; declare module '../Chat' { interface UnauthenticatedChatConnection extends UnauthMessagesService { } } /** See {@link UnauthMessagesService#sendMultiRecipientMessage}. */ export type MultiRecipientMessageRequest = Readonly<{ payload: Uint8Array; timestamp: number; auth: 'story' | GroupSendFullToken; onlineOnly: boolean; urgent: boolean; }>; /** * Successful response for {@link UnauthMessagesService#sendMultiRecipientMessage}. * * When authenticating using a {@link GroupSendFullToken}, the server will report which recipients * are currently unregistered. For `story` auth the list will always be empty. */ export declare class MultiRecipientMessageResponse { unregisteredIds: ServiceId[]; constructor(unregisteredIds: ServiceId[]); } /** See {@link UnauthMessagesService#sendMessage}. */ export type SendSealedMessageRequest = Readonly<{ destination: ServiceId; timestamp: number; contents: Readonly; auth: 'story' | { accessKey: Uint8Array; } | GroupSendFullToken | 'unrestricted'; onlineOnly: boolean; urgent: boolean; }>; export interface UnauthMessagesService { /** * Sends a multi-recipient message encrypted with Sealed Sender v2. * * Messages to accounts that have been unregistered will be dropped by the server and (if using * {@link GroupSendFullToken}-based auth) reported in the resulting * {@link MultiRecipientMessageResponse}. * * @throws {RequestUnauthorizedError} if `auth` is not valid for the recipients specified in * `payload`. (This cannot happen when `auth` is `'story'`.) * @throws {MismatchedDevicesError} if the recipient devices specified in `payload` are out of * date in some way. This is not a "partial success" result; the message has not been sent to * anybody. * @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 `sealedSenderMultiRecipientEncrypt` * @see {@link MismatchedDevicesEntry} */ sendMultiRecipientMessage: (request: MultiRecipientMessageRequest, options?: RequestOptions) => Promise; /** * Sends a 1:1 message encrypted with Sealed Sender. * * @throws {RequestUnauthorizedError} if `auth` is not valid for the recipients specified in * `payload`. (This cannot happen when `auth` is `'story'`.) * @throws {MismatchedDevicesError} if the recipient devices specified in `payload` 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 {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 `sealedSenderEncrypt` * @see {@link MismatchedDevicesEntry} */ sendMessage: (request: SendSealedMessageRequest, options?: RequestOptions) => Promise; }