import { ProtocolAddress, ServiceId } from './Address.js'; import * as Native from './Native.js'; export declare enum ErrorCode { Generic = 0, DuplicatedMessage = 1, SealedSenderSelfSend = 2, UntrustedIdentity = 3, InvalidRegistrationId = 4, InvalidProtocolAddress = 5, VerificationFailed = 6, InvalidSession = 7, InvalidSenderKeySession = 8, NicknameCannotBeEmpty = 9, CannotStartWithDigit = 10, MissingSeparator = 11, BadNicknameCharacter = 12, NicknameTooShort = 13, NicknameTooLong = 14, DiscriminatorCannotBeEmpty = 15, DiscriminatorCannotBeZero = 16, DiscriminatorCannotBeSingleDigit = 17, DiscriminatorCannotHaveLeadingZeros = 18, BadDiscriminatorCharacter = 19, DiscriminatorTooLarge = 20, IoError = 21, CdsiInvalidToken = 22, InvalidUri = 23, InvalidMediaInput = 24, UnsupportedMediaInput = 25, InputDataTooLong = 26, InvalidEntropyDataLength = 27, InvalidUsernameLinkEncryptedData = 28, RateLimitedError = 29, RateLimitChallengeError = 30, SvrDataMissing = 31, SvrRequestFailed = 32, SvrRestoreFailed = 33, SvrAttestationError = 34, SvrInvalidData = 35, ChatServiceInactive = 36, AppExpired = 37, DeviceDelinked = 38, ConnectionInvalidated = 39, ConnectedElsewhere = 40, PossibleCaptiveNetwork = 41, BackupValidation = 42, Cancelled = 43, KeyTransparencyError = 44, KeyTransparencyVerificationFailed = 45, IncrementalMacVerificationFailed = 46, RequestUnauthorized = 47, MismatchedDevices = 48, ServiceIdNotFound = 49, UploadTooLarge = 50 } /** Called out as a separate type so it's not confused with a normal ServiceIdBinary. */ type ServiceIdFixedWidthBinary = Uint8Array; /** * A failure sending to a recipient on account of not being up to date on their devices. * * An entry in {@link MismatchedDevicesError}. Each entry represents a recipient that has either * added, removed, or relinked some devices in their account (potentially including their primary * device), as represented by the {@link MismatchedDevicesEntry#missingDevices}, * {@link MismatchedDevicesEntry#extraDevices}, and {@link MismatchedDevicesEntry#staleDevices} * arrays, respectively. Handling the exception involves removing the "extra" devices and * establishing new sessions for the "missing" and "stale" devices. */ export declare class MismatchedDevicesEntry { account: ServiceId; missingDevices: number[]; extraDevices: number[]; staleDevices: number[]; constructor({ account, missingDevices, extraDevices, staleDevices, }: { account: ServiceId | ServiceIdFixedWidthBinary; missingDevices?: number[]; extraDevices?: number[]; staleDevices?: number[]; }); } export declare class LibSignalErrorBase extends Error { readonly code: ErrorCode; readonly operation: string; readonly _addr?: string | Native.ProtocolAddress; constructor(message: string, name: keyof typeof ErrorCode | undefined, operation: string, extraProps?: Record); get addr(): ProtocolAddress | string; toString(): string; is(code: E): this is Extract; static is(error: unknown, code: E): error is Extract; } export type LibSignalErrorCommon = Omit; export type GenericError = LibSignalErrorCommon & { code: ErrorCode.Generic; }; export type DuplicatedMessageError = LibSignalErrorCommon & { code: ErrorCode.DuplicatedMessage; }; export type SealedSenderSelfSendError = LibSignalErrorCommon & { code: ErrorCode.SealedSenderSelfSend; }; export type UntrustedIdentityError = LibSignalErrorCommon & { code: ErrorCode.UntrustedIdentity; addr: string; }; export type InvalidRegistrationIdError = LibSignalErrorCommon & { code: ErrorCode.InvalidRegistrationId; addr: ProtocolAddress; }; export type InvalidProtocolAddress = LibSignalErrorCommon & { code: ErrorCode.InvalidProtocolAddress; name: string; deviceId: number; }; export type VerificationFailedError = LibSignalErrorCommon & { code: ErrorCode.VerificationFailed; }; export type InvalidSessionError = LibSignalErrorCommon & { code: ErrorCode.InvalidSession; }; export type InvalidSenderKeySessionError = LibSignalErrorCommon & { code: ErrorCode.InvalidSenderKeySession; distributionId: string; }; export type NicknameCannotBeEmptyError = LibSignalErrorCommon & { code: ErrorCode.NicknameCannotBeEmpty; }; export type CannotStartWithDigitError = LibSignalErrorCommon & { code: ErrorCode.CannotStartWithDigit; }; export type MissingSeparatorError = LibSignalErrorCommon & { code: ErrorCode.MissingSeparator; }; export type BadNicknameCharacterError = LibSignalErrorCommon & { code: ErrorCode.BadNicknameCharacter; }; export type NicknameTooShortError = LibSignalErrorCommon & { code: ErrorCode.NicknameTooShort; }; export type NicknameTooLongError = LibSignalErrorCommon & { code: ErrorCode.NicknameTooLong; }; export type DiscriminatorCannotBeEmptyError = LibSignalErrorCommon & { code: ErrorCode.DiscriminatorCannotBeEmpty; }; export type DiscriminatorCannotBeZeroError = LibSignalErrorCommon & { code: ErrorCode.DiscriminatorCannotBeZero; }; export type DiscriminatorCannotBeSingleDigitError = LibSignalErrorCommon & { code: ErrorCode.DiscriminatorCannotBeSingleDigit; }; export type DiscriminatorCannotHaveLeadingZerosError = LibSignalErrorCommon & { code: ErrorCode.DiscriminatorCannotHaveLeadingZeros; }; export type BadDiscriminatorCharacterError = LibSignalErrorCommon & { code: ErrorCode.BadDiscriminatorCharacter; }; export type DiscriminatorTooLargeError = LibSignalErrorCommon & { code: ErrorCode.DiscriminatorTooLarge; }; export type InputDataTooLong = LibSignalErrorCommon & { code: ErrorCode.InputDataTooLong; }; export type InvalidEntropyDataLength = LibSignalErrorCommon & { code: ErrorCode.InvalidEntropyDataLength; }; export type InvalidUsernameLinkEncryptedData = LibSignalErrorCommon & { code: ErrorCode.InvalidUsernameLinkEncryptedData; }; export type IoError = LibSignalErrorCommon & { code: ErrorCode.IoError; }; export type CdsiInvalidTokenError = LibSignalErrorCommon & { code: ErrorCode.CdsiInvalidToken; }; export type InvalidUriError = LibSignalErrorCommon & { code: ErrorCode.InvalidUri; }; export type InvalidMediaInputError = LibSignalErrorCommon & { code: ErrorCode.InvalidMediaInput; }; export type UnsupportedMediaInputError = LibSignalErrorCommon & { code: ErrorCode.UnsupportedMediaInput; }; export type RateLimitedError = LibSignalErrorBase & { code: ErrorCode.RateLimitedError; readonly retryAfterSecs: number; }; export type RateLimitChallengeError = LibSignalErrorBase & { code: ErrorCode.RateLimitChallengeError; readonly token: string; readonly options: Set<'pushChallenge' | 'captcha'>; readonly retryAfterSecs: number | null; }; export type ChatServiceInactive = LibSignalErrorBase & { code: ErrorCode.ChatServiceInactive; }; export type AppExpiredError = LibSignalErrorBase & { code: ErrorCode.AppExpired; }; export type DeviceDelinkedError = LibSignalErrorBase & { code: ErrorCode.DeviceDelinked; }; export type ConnectionInvalidatedError = LibSignalErrorBase & { code: ErrorCode.ConnectionInvalidated; }; export type ConnectedElsewhereError = LibSignalErrorBase & { code: ErrorCode.ConnectedElsewhere; }; export type PossibleCaptiveNetworkError = LibSignalErrorBase & { code: ErrorCode.PossibleCaptiveNetwork; }; export type SvrDataMissingError = LibSignalErrorBase & { code: ErrorCode.SvrDataMissing; }; export type SvrRequestFailedError = LibSignalErrorCommon & { code: ErrorCode.SvrRequestFailed; }; export type SvrRestoreFailedError = LibSignalErrorCommon & { code: ErrorCode.SvrRestoreFailed; readonly triesRemaining: number; }; export type SvrAttestationError = LibSignalErrorCommon & { code: ErrorCode.SvrAttestationError; }; export type SvrInvalidDataError = LibSignalErrorCommon & { code: ErrorCode.SvrInvalidData; }; export type BackupValidationError = LibSignalErrorCommon & { code: ErrorCode.BackupValidation; readonly unknownFields: ReadonlyArray; }; export type CancellationError = LibSignalErrorCommon & { code: ErrorCode.Cancelled; }; export type KeyTransparencyError = LibSignalErrorCommon & { code: ErrorCode.KeyTransparencyError; }; export type KeyTransparencyVerificationFailed = LibSignalErrorCommon & { code: ErrorCode.KeyTransparencyVerificationFailed; }; export type IncrementalMacVerificationFailed = LibSignalErrorCommon & { code: ErrorCode.IncrementalMacVerificationFailed; }; export type RequestUnauthorizedError = LibSignalErrorCommon & { code: ErrorCode.RequestUnauthorized; }; export type MismatchedDevicesError = LibSignalErrorCommon & { code: ErrorCode.MismatchedDevices; readonly entries: MismatchedDevicesEntry[]; }; export type ServiceIdNotFound = LibSignalErrorCommon & { code: ErrorCode.ServiceIdNotFound; }; export type UploadTooLarge = LibSignalErrorCommon & { code: ErrorCode.UploadTooLarge; }; /** * @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. */ export type StandardNetworkError = ChatServiceInactive | IoError | RateLimitedError; export type LibSignalError = GenericError | DuplicatedMessageError | SealedSenderSelfSendError | UntrustedIdentityError | InvalidRegistrationIdError | InvalidProtocolAddress | VerificationFailedError | InvalidSessionError | InvalidSenderKeySessionError | NicknameCannotBeEmptyError | CannotStartWithDigitError | MissingSeparatorError | BadNicknameCharacterError | NicknameTooShortError | NicknameTooLongError | DiscriminatorCannotBeEmptyError | DiscriminatorCannotBeZeroError | DiscriminatorCannotBeSingleDigitError | DiscriminatorCannotHaveLeadingZerosError | BadDiscriminatorCharacterError | DiscriminatorTooLargeError | InputDataTooLong | InvalidEntropyDataLength | InvalidUsernameLinkEncryptedData | IoError | CdsiInvalidTokenError | InvalidUriError | InvalidMediaInputError | SvrDataMissingError | SvrRestoreFailedError | SvrRequestFailedError | SvrAttestationError | SvrInvalidDataError | UnsupportedMediaInputError | ChatServiceInactive | AppExpiredError | DeviceDelinkedError | ConnectionInvalidatedError | ConnectedElsewhereError | PossibleCaptiveNetworkError | RateLimitedError | RateLimitChallengeError | BackupValidationError | CancellationError | KeyTransparencyError | KeyTransparencyVerificationFailed | IncrementalMacVerificationFailed | RequestUnauthorizedError | MismatchedDevicesError | ServiceIdNotFound | UploadTooLarge; export {};