UNPKG

@periskope/baileys

Version:

WhatsApp API

96 lines 4.05 kB
import { proto } from '../../WAProto/index.js'; import type { SignalAuthState, SignalRepository, WAMessage, WAMessageKey } from '../Types/index.js'; import { type BinaryNode } from '../WABinary/index.js'; import type { ILogger } from './logger.js'; export declare const NO_MESSAGE_FOUND_ERROR_TEXT = "Message absent from node"; export declare const MISSING_KEYS_ERROR_TEXT = "Key used already or never filled"; export declare const DECRYPTION_RETRY_CONFIG: { maxRetries: number; baseDelayMs: number; sessionRecreateTimeout: number; requestFromPhoneDelay: number; sessionRecordErrors: string[]; macErrors: string[]; }; export interface MessageRetryState { retryCount: number; lastRetryTime: number; sessionRecreateHistory: Map<string, number>; } export interface RecentMessage { message: proto.IMessage; timestamp: number; } export interface RecentMessageKey { to: string; id: string; } export interface SessionRecreationContext { authState: SignalAuthState; logger: ILogger; signalRepository: SignalRepository; query: (node: BinaryNode) => Promise<BinaryNode>; } export declare function shouldRecreateSession(jid: string, retryCount: number, context?: SessionRecreationContext): Promise<{ reason: string; recreate: boolean; shouldFetchPreKeys: boolean; }>; /** * Execute session recreation by fetching prekeys * Inspired by whatsmeow's session recreation logic */ export declare function executeSessionRecreation(jid: string, context: SessionRecreationContext): Promise<boolean>; export declare function getMessageRetryState(messageKey: string): MessageRetryState; export declare function incrementRetryCount(messageKey: string): number; export declare function shouldStopRetrying(messageKey: string): boolean; export declare function addRecentMessage(to: string, id: string, message: proto.IMessage): void; export declare function getRecentMessage(to: string, id: string): RecentMessage | null; export declare function getMessageForRetry(to: string, id: string, getMessage?: (key: WAMessageKey) => Promise<proto.IMessage | undefined>): Promise<proto.IMessage | null>; export declare function incrementIncomingRetryCounter(senderJid: string, messageId: string): number; export declare function shouldDropRetryRequest(senderJid: string, messageId: string): boolean; export declare function cleanupOldRetryStates(): void; export declare const NACK_REASONS: { ParsingError: number; UnrecognizedStanza: number; UnrecognizedStanzaClass: number; UnrecognizedStanzaType: number; InvalidProtobuf: number; InvalidHostedCompanionStanza: number; MissingMessageSecret: number; SignalErrorOldCounter: number; MessageDeletedOnPeer: number; UnhandledError: number; UnsupportedAdminRevoke: number; UnsupportedLIDGroup: number; DBOperationFailed: number; }; export declare const extractAddressingContext: (stanza: BinaryNode) => { addressingMode: string; senderAlt: string | undefined; recipientAlt: string | undefined; }; /** * Decode the received node as a message. * @note this will only parse the message, not decrypt it */ export declare function decodeMessageNode(stanza: BinaryNode, meId: string, meLid: string): { fullMessage: WAMessage; author: string; sender: string; }; export declare const decryptMessageNode: (stanza: BinaryNode, meId: string, meLid: string, repository: SignalRepository, logger: ILogger, sendRetryRequestFn?: (node: BinaryNode, forceIncludeKeys: boolean) => Promise<void>, sessionContext?: SessionRecreationContext) => { fullMessage: WAMessage; category: string | undefined; author: string; decrypt(): Promise<void>; }; /** * Utility function to check if an error is specifically a MAC error */ export declare function isMacError(error: any): boolean; /** * Utility function to check if an error is related to missing session record */ export declare function isSessionRecordError(error: any): boolean; //# sourceMappingURL=decode-wa-message.d.ts.map