Path: blob/master/node_modules/@adiwajshing/baileys/lib/Utils/generics.d.ts
1129 views
/// <reference types="node" />1import { Logger } from 'pino';2import { proto } from '../../WAProto';3import { BaileysEventMap, CommonBaileysEventEmitter, WACallUpdateType, WAVersion } from '../Types';4import { BinaryNode } from '../WABinary';5export declare const Browsers: {6ubuntu: (browser: any) => [string, string, string];7macOS: (browser: any) => [string, string, string];8baileys: (browser: any) => [string, string, string];9/** The appropriate browser based on your OS & release */10appropriate: (browser: any) => [string, string, string];11};12export declare const BufferJSON: {13replacer: (k: any, value: any) => any;14reviver: (_: any, value: any) => any;15};16export declare const writeRandomPadMax16: (msg: Uint8Array) => Buffer;17export declare const unpadRandomMax16: (e: Uint8Array | Buffer) => Uint8Array;18export declare const encodeWAMessage: (message: proto.IMessage) => Buffer;19export declare const generateRegistrationId: () => number;20export declare const encodeBigEndian: (e: number, t?: number) => Uint8Array;21export declare const toNumber: (t: Long | number | null | undefined) => number;22/** unix timestamp of a date in seconds */23export declare const unixTimestampSeconds: (date?: Date) => number;24export declare type DebouncedTimeout = ReturnType<typeof debouncedTimeout>;25export declare const debouncedTimeout: (intervalMs?: number, task?: () => void) => {26start: (newIntervalMs?: number, newTask?: () => void) => void;27cancel: () => void;28setTask: (newTask: () => void) => () => void;29setInterval: (newInterval: number) => number;30};31export declare const delay: (ms: number) => Promise<void>;32export declare const delayCancellable: (ms: number) => {33delay: Promise<void>;34cancel: () => void;35};36export declare function promiseTimeout<T>(ms: number | undefined, promise: (resolve: (v?: T) => void, reject: (error: any) => void) => void): Promise<T | undefined>;37export declare const generateMessageID: () => string;38export declare function bindWaitForEvent<T extends keyof BaileysEventMap<any>>(ev: CommonBaileysEventEmitter<any>, event: T): (check: (u: BaileysEventMap<any>[T]) => boolean | undefined, timeoutMs?: number) => Promise<void>;39export declare const bindWaitForConnectionUpdate: (ev: CommonBaileysEventEmitter<any>) => (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number) => Promise<void>;40export declare const printQRIfNecessaryListener: (ev: CommonBaileysEventEmitter<any>, logger: Logger) => void;41/**42* utility that fetches latest baileys version from the master branch.43* Use to ensure your WA connection is always on the latest version44*/45export declare const fetchLatestBaileysVersion: () => Promise<{46version: WAVersion;47isLatest: boolean;48error?: undefined;49} | {50version: WAVersion;51isLatest: boolean;52error: any;53}>;54/**55* A utility that fetches the latest web version of whatsapp.56* Use to ensure your WA connection is always on the latest version57*/58export declare const fetchLatestWaWebVersion: () => Promise<{59version: WAVersion;60isLatest: boolean;61error?: undefined;62} | {63version: WAVersion;64isLatest: boolean;65error: any;66}>;67/** unique message tag prefix for MD clients */68export declare const generateMdTagPrefix: () => string;69/**70* Given a type of receipt, returns what the new status of the message should be71* @param type type from receipt72*/73export declare const getStatusFromReceiptType: (type: string | undefined) => proto.WebMessageInfo.Status;74/**75* Stream errors generally provide a reason, map that to a baileys DisconnectReason76* @param reason the string reason given, eg. "conflict"77*/78export declare const getErrorCodeFromStreamError: (node: BinaryNode) => {79reason: string;80statusCode: number;81};82export declare const getCallStatusFromNode: ({ tag, attrs }: BinaryNode) => WACallUpdateType;83export declare const getCodeFromWSError: (error: Error) => number;84/**85* Is the given platform WA business86* @param platform AuthenticationCreds.platform87*/88export declare const isWABusinessPlatform: (platform: string) => boolean;899091