Options
All
  • Public
  • Public/Protected
  • All
Menu

Project @adiwajshing/baileys

Index

References

Namespaces

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

References

WAMessageProto

Renames and exports proto

WA_MESSAGE_STATUS_TYPE

Renames and exports WebMessageInfoStatus

WA_MESSAGE_STUB_TYPE

Renames and exports WebMessageInfoStubType

Type aliases

AnyAuthenticationCredentials

BaileysEvent

BaileysEvent: "open" | "connecting" | "close" | "ws-close" | "qr" | "connection-phone-change" | "contacts-received" | "chats-received" | "chat-new" | "chat-update" | "message-status-update" | "group-participants-update" | "group-update" | "received-pong" | "credentials-updated" | "connection-validated" | "blocklist-update" | "contact-update"

WAChatIndex

WAChatIndex: { index: string; owner: "true" | "false"; participant?: string }

Type declaration

  • index: string
  • owner: "true" | "false"
  • Optional participant?: string

WAChatUpdate

WAChatUpdate: Partial<WAChat> & { hasNewMessage?: boolean; jid: string }

WAConnectOptions

WAConnectOptions: { agent?: Agent; alwaysUseTakeover?: boolean; connectCooldownMs?: number; fetchAgent?: Agent; maxIdleTimeMs?: number; maxRetries?: number; phoneResponseTime?: number; regenerateQRIntervalMs?: number; waitForChats?: boolean; waitOnlyForLastMessage?: boolean }

Type declaration

  • Optional agent?: Agent

    agent used for WS connections

  • Optional alwaysUseTakeover?: boolean

    Always uses takeover for connections

  • Optional connectCooldownMs?: number
  • Optional fetchAgent?: Agent

    agent used for fetch requests -- uploading/downloading media

  • Optional maxIdleTimeMs?: number

    fails the connection if no data is received for X seconds

  • Optional maxRetries?: number

    maximum attempts to connect

  • Optional phoneResponseTime?: number

    max time for the phone to respond to a connectivity test

  • Optional regenerateQRIntervalMs?: number

    New QR generation interval, set to null if you don't want to regenerate

    deprecated

    no need to set this as we use WA ttl

  • Optional waitForChats?: boolean
    deprecated

    -- use the chats-received & contacts-received events should the chats be waited for

  • Optional waitOnlyForLastMessage?: boolean
    deprecated

    -- use the chats-received & contacts-received events if set to true, the connect only waits for the last message of the chat

WAConnectionState

WAConnectionState: "open" | "connecting" | "close"

WAContactMessage

WAContactMessage: ContactMessage

WAContactUpdate

WAContactUpdate: Partial<WAContact> & { jid: string; status?: string }

WAContextInfo

WAContextInfo: IContextInfo

WAGenericMediaMessage

WAGroupParticipant

WAGroupParticipant: WAContact & { isAdmin: boolean; isSuperAdmin: boolean }

WAInitResponse

WAInitResponse: { ref: string; status: 200; ttl: number }

Type declaration

  • ref: string
  • status: 200
  • ttl: number

WALoadChatOptions

WALoadChatOptions: { custom?: (c: WAChat) => boolean; loadProfilePicture?: boolean; searchString?: string }

Type declaration

  • Optional custom?: (c: WAChat) => boolean
  • Optional loadProfilePicture?: boolean
  • Optional searchString?: string

WAMessage

WAMessage: WebMessageInfo

WAMessageContent

WAMessageContent: IMessage

WAMessageKey

WAMessageKey: IMessageKey

WANode

WANode: Node

WAParticipantAction

WAParticipantAction: "add" | "remove" | "promote" | "demote"

WATag

WATag: [WAMetric, WAFlag]

Tag used with binary queries

WATextMessage

WATextMessage: ExtendedTextMessage

Variables

Const Browsers

Browsers: { appropriate: (browser: any) => [string, string, string]; baileys: (browser: any) => [string, string, string]; macOS: (browser: any) => [string, string, string]; ubuntu: (browser: any) => [string, string, string] } = ...

Type declaration

  • appropriate: (browser: any) => [string, string, string]
      • (browser: any): [string, string, string]
      • The appropriate browser based on your OS & release

        Parameters

        • browser: any

        Returns [string, string, string]

  • baileys: (browser: any) => [string, string, string]
      • (browser: any): [string, string, string]
      • Parameters

        • browser: any

        Returns [string, string, string]

  • macOS: (browser: any) => [string, string, string]
      • (browser: any): [string, string, string]
      • Parameters

        • browser: any

        Returns [string, string, string]

  • ubuntu: (browser: any) => [string, string, string]
      • (browser: any): [string, string, string]
      • Parameters

        • browser: any

        Returns [string, string, string]

Const DEFAULT_ORIGIN

DEFAULT_ORIGIN: "https://web.whatsapp.com" = 'https://web.whatsapp.com'

Const HKDFInfoKeys

HKDFInfoKeys: { audioMessage: string; documentMessage: string; imageMessage: string; stickerMessage: string; videoMessage: string } = ...

Type declaration

  • audioMessage: string
  • documentMessage: string
  • imageMessage: string
  • stickerMessage: string
  • videoMessage: string

Const KEEP_ALIVE_INTERVAL_MS

KEEP_ALIVE_INTERVAL_MS: number = ...

Const MediaPathMap

MediaPathMap: { audioMessage: string; documentMessage: string; imageMessage: string; stickerMessage: string; videoMessage: string } = ...

Type declaration

  • audioMessage: string
  • documentMessage: string
  • imageMessage: string
  • stickerMessage: string
  • videoMessage: string

Const MessageTypeProto

MessageTypeProto: { audioMessage: typeof AudioMessage; documentMessage: typeof DocumentMessage; imageMessage: typeof ImageMessage; stickerMessage: typeof StickerMessage; videoMessage: typeof VideoMessage } = ...

Type declaration

Const MimetypeMap

MimetypeMap: { audioMessage: Mimetype; documentMessage: Mimetype; imageMessage: Mimetype; stickerMessage: Mimetype; videoMessage: Mimetype } = ...

Type declaration

Const STORIES_JID

STORIES_JID: "status@broadcast" = 'status@broadcast'

Const UNAUTHORIZED_CODES

UNAUTHORIZED_CODES: number[] = ...

Const URL_REGEX

URL_REGEX: RegExp = ...

Const WA_DEFAULT_EPHEMERAL

WA_DEFAULT_EPHEMERAL: number = ...

Const WA_MESSAGE_STUB_TYPES

WA_MESSAGE_STUB_TYPES: Record<number, string> = ...

Reverse stub type dictionary

Const WS_URL

WS_URL: "wss://web.whatsapp.com/ws" = 'wss://web.whatsapp.com/ws'

Const waMessageKey

waMessageKey: { compare: (k1: string, k2: string) => number; key: (m: WebMessageInfo) => string } = ...

Type declaration

  • compare: (k1: string, k2: string) => number
      • (k1: string, k2: string): number
      • Parameters

        • k1: string
        • k2: string

        Returns number

  • key: (m: WebMessageInfo) => string

Functions

Const CancelledError

Const GET_MESSAGE_ID

Mutex

  • Mutex(keyGetter?: (...args: any[]) => string): (_: any, __: any, descriptor: PropertyDescriptor) => void
  • A simple mutex that can be used as a decorator. For examples, see Tests.Mutex.ts

    Parameters

    • Optional keyGetter: (...args: any[]) => string

      if you want to lock functions based on certain arguments, specify the key for the function based on the arguments

        • (...args: any[]): string
        • Parameters

          • Rest ...args: any[]

          Returns string

    Returns (_: any, __: any, descriptor: PropertyDescriptor) => void

      • (_: any, __: any, descriptor: PropertyDescriptor): void
      • Parameters

        • _: any
        • __: any
        • descriptor: PropertyDescriptor

        Returns void

Const ProxyAgent

  • ProxyAgent(host: string | URL): Agent

Const TimedOutError

Const WA_MESSAGE_ID

aesDecrypt

  • aesDecrypt(buffer: Buffer, key: Buffer): Buffer
  • decrypt AES 256 CBC; where the IV is prefixed to the buffer

    Parameters

    • buffer: Buffer
    • key: Buffer

    Returns Buffer

aesDecryptWithIV

  • aesDecryptWithIV(buffer: Buffer, key: Buffer, IV: Buffer): Buffer

aesEncrypWithIV

  • aesEncrypWithIV(buffer: Buffer, key: Buffer, IV: Buffer): Buffer

aesEncrypt

  • aesEncrypt(buffer: Buffer, key: Buffer): Buffer

Const compressImage

  • compressImage(buffer: Buffer): Promise<Buffer>

decodeMediaMessageBuffer

  • decodeMediaMessageBuffer(message: WAMessageContent, fetchRequest: (host: string, method: string) => Promise<Response>): Promise<Buffer>
  • Decode a media message (video, image, document, audio) & return decrypted buffer

    Parameters

    • message: WAMessageContent

      the media message you want to decode

    • fetchRequest: (host: string, method: string) => Promise<Response>
        • (host: string, method: string): Promise<Response>
        • Parameters

          • host: string
          • method: string

          Returns Promise<Response>

    Returns Promise<Buffer>

decryptWA

  • decryptWA(message: string | Buffer, macKey: Buffer, encKey: Buffer, decoder: Decoder, fromMe?: boolean): [string, Object, [number, number]?]
  • Parameters

    • message: string | Buffer
    • macKey: Buffer
    • encKey: Buffer
    • decoder: Decoder
    • fromMe: boolean = false

    Returns [string, Object, [number, number]?]

Const delay

  • delay(ms: number): Promise<void>

Const delayCancellable

  • delayCancellable(ms: number): { cancel: () => void; delay: Promise<void> }
  • Parameters

    • ms: number

    Returns { cancel: () => void; delay: Promise<void> }

    • cancel: () => void
        • (): void
        • Returns void

    • delay: Promise<void>

extensionForMediaMessage

generateClientID

  • generateClientID(): string

generateMessageID

  • generateMessageID(): string

generateMessageTag

  • generateMessageTag(epoch?: number): string

Const generateProfilePicture

  • generateProfilePicture(buffer: Buffer): Promise<{ img: Buffer; preview: Buffer }>

generateThumbnail

getAudioDuration

  • getAudioDuration(buffer: Buffer): Promise<number>

getMediaKeys

  • getMediaKeys(buffer: any, mediaType: MessageType): { cipherKey: Buffer; iv: Buffer; macKey: Buffer }
  • generates all the keys required to encrypt/decrypt & sign a media message

    Parameters

    Returns { cipherKey: Buffer; iv: Buffer; macKey: Buffer }

    • cipherKey: Buffer
    • iv: Buffer
    • macKey: Buffer

hkdf

  • hkdf(buffer: Buffer, expandedLength: number, info?: any): Buffer

hmacSign

  • hmacSign(buffer: Buffer, key: Buffer): Buffer

Const isGroupID

  • isGroupID(jid: string): boolean

Const mediaMessageSHA256B64

  • mediaMessageSHA256B64(message: IMessage): string

Const newMessagesDB

promiseTimeout

  • promiseTimeout<T>(ms: number, promise: (resolve: (v?: T) => void, reject: (error: any) => void) => void): Promise<T>
  • Type parameters

    • T

    Parameters

    • ms: number
    • promise: (resolve: (v?: T) => void, reject: (error: any) => void) => void
        • (resolve: (v?: T) => void, reject: (error: any) => void): void
        • Parameters

          • resolve: (v?: T) => void
              • (v?: T): void
              • Parameters

                • Optional v: T

                Returns void

          • reject: (error: any) => void
              • (error: any): void
              • Parameters

                • error: any

                Returns void

          Returns void

    Returns Promise<T>

randomBytes

  • randomBytes(length: any): Buffer

sha256

  • sha256(buffer: Buffer): Buffer

shallowChanges

  • shallowChanges<T>(old: T, current: T, __namedParameters: { lookForDeletedKeys: boolean }): Partial<T>
  • Type parameters

    • T

    Parameters

    • old: T
    • current: T
    • __namedParameters: { lookForDeletedKeys: boolean }
      • lookForDeletedKeys: boolean

    Returns Partial<T>

Const toNumber

  • toNumber(t: number | Long): number

Const unixTimestampSeconds

  • unixTimestampSeconds(date?: Date): number

Const waChatKey

  • waChatKey(pin: boolean): { compare: (k1: string, k2: string) => number; key: (c: WAChat) => string }
  • Parameters

    • pin: boolean

    Returns { compare: (k1: string, k2: string) => number; key: (c: WAChat) => string }

    • compare: (k1: string, k2: string) => number
        • (k1: string, k2: string): number
        • Parameters

          • k1: string
          • k2: string

          Returns number

    • key: (c: WAChat) => string

Const whatsappID

  • whatsappID(jid: string): string

Generated using TypeDoc