Path: blob/master/node_modules/@adiwajshing/baileys/lib/Utils/messages-media.d.ts
1129 views
/// <reference types="node" />1/// <reference types="node" />2import { Boom } from '@hapi/boom';3import { AxiosRequestConfig } from 'axios';4import type { Logger } from 'pino';5import { Readable, Transform } from 'stream';6import { URL } from 'url';7import { proto } from '../../WAProto';8import { CommonSocketConfig, DownloadableMessage, MediaConnInfo, MediaDecryptionKeyInfo, MediaType, WAMediaUpload, WAMediaUploadFunction, WAMessageContent } from '../Types';9import { BinaryNode } from '../WABinary';10export declare const hkdfInfoKey: (type: MediaType) => string;11/** generates all the keys required to encrypt/decrypt & sign a media message */12export declare function getMediaKeys(buffer: Uint8Array | string | null | undefined, mediaType: MediaType): MediaDecryptionKeyInfo;13export declare const extractImageThumb: (bufferOrFilePath: Readable | Buffer | string, width?: number) => Promise<Buffer>;14export declare const generateProfilePicture: (mediaUpload: WAMediaUpload) => Promise<{15img: Buffer;16}>;17/** gets the SHA256 of the given media message */18export declare const mediaMessageSHA256B64: (message: WAMessageContent) => string | null | undefined;19export declare function getAudioDuration(buffer: Buffer | string | Readable): Promise<number | undefined>;20export declare const toReadable: (buffer: Buffer) => Readable;21export declare const toBuffer: (stream: Readable) => Promise<Buffer>;22export declare const getStream: (item: WAMediaUpload) => Promise<{23stream: Readable;24type: string;25}>;26/** generates a thumbnail for a given media, if required */27export declare function generateThumbnail(file: string, mediaType: 'video' | 'image', options: {28logger?: Logger;29}): Promise<string | undefined>;30export declare const getHttpStream: (url: string | URL, options?: AxiosRequestConfig & {31isStream?: true;32}) => Promise<Readable>;33export declare const encryptedStream: (media: WAMediaUpload, mediaType: MediaType, saveOriginalFileIfRequired?: boolean, logger?: Logger) => Promise<{34mediaKey: Buffer;35encWriteStream: Readable;36bodyPath: string | undefined;37mac: Buffer;38fileEncSha256: Buffer;39fileSha256: Buffer;40fileLength: number;41didSaveToTmpPath: boolean;42}>;43export declare type MediaDownloadOptions = {44startByte?: number;45endByte?: number;46};47export declare const getUrlFromDirectPath: (directPath: string) => string;48export declare const downloadContentFromMessage: ({ mediaKey, directPath, url }: DownloadableMessage, type: MediaType, opts?: MediaDownloadOptions) => Promise<Transform>;49/**50* Decrypts and downloads an AES256-CBC encrypted file given the keys.51* Assumes the SHA256 of the plaintext is appended to the end of the ciphertext52* */53export declare const downloadEncryptedContent: (downloadUrl: string, { cipherKey, iv }: MediaDecryptionKeyInfo, { startByte, endByte }?: MediaDownloadOptions) => Promise<Transform>;54export declare function extensionForMediaMessage(message: WAMessageContent): string;55export declare const getWAUploadToServer: ({ customUploadHosts, fetchAgent, logger }: CommonSocketConfig, refreshMediaConn: (force: boolean) => Promise<MediaConnInfo>) => WAMediaUploadFunction;56/**57* Generate a binary node that will request the phone to re-upload the media & return the newly uploaded URL58*/59export declare const encryptMediaRetryRequest: (key: proto.IMessageKey, mediaKey: Buffer | Uint8Array, meId: string) => BinaryNode;60export declare const decodeMediaRetryNode: (node: BinaryNode) => {61key: proto.IMessageKey;62media?: {63ciphertext: Uint8Array;64iv: Uint8Array;65} | undefined;66error?: Boom<any> | undefined;67};68export declare const decryptMediaRetryData: ({ ciphertext, iv }: {69ciphertext: Uint8Array;70iv: Uint8Array;71}, mediaKey: Uint8Array, msgId: string) => proto.MediaRetryNotification;72export declare const getStatusCodeForMediaRetry: (code: number) => any;737475