import cryptojs from "crypto-js"; import { type ContextSession, type ContextBase } from "./context.js"; import { GroupEventType } from "./models/GroupEvent.js"; import { FriendEventType } from "./models/FriendEvent.js"; import type { API } from "./zalo.js"; import type { AttachmentSource } from "./models/Attachment.js"; export declare const isBun: boolean; /** * Get signed key for API requests. * * @param type * @param params * @returns MD5 hash * */ export declare function getSignKey(type: string, params: Record): cryptojs.lib.WordArray; /** * * @param baseURL * @param params * @param apiVersion automatically add zalo api version to url params * @returns * */ export declare function makeURL(ctx: ContextBase, baseURL: string, params?: Record, apiVersion?: boolean): string; export declare class ParamsEncryptor { private zcid; private enc_ver; private zcid_ext; private encryptKey; constructor({ type, imei, firstLaunchTime }: { type: number; imei: string; firstLaunchTime: number; }); getEncryptKey(): string; createZcid(type: number, imei: string, firstLaunchTime: number): void; createEncryptKey(e?: number): boolean; getParams(): { zcid: string; zcid_ext: string; enc_ver: string; } | null; static processStr(e: string): { even: null; odd: null; } | { even: string[]; odd: string[]; }; static randomString(e?: number, t?: number): string; static encodeAES(e: string, message: string, type: "hex" | "base64", uppercase: boolean, s?: number): string | null; } export declare function decryptResp(key: string, data: string): Record | null | string; export declare function decodeBase64ToBuffer(data: string): Buffer; export declare function decodeUnit8Array(data: Uint8Array): string | null; export declare function encodeAES(secretKey: string, data: any, t?: number): string | null; export declare function decodeAES(secretKey: string, data: string, t?: number): string | null; export declare function getDefaultHeaders(ctx: ContextBase, origin?: string): Promise<{ Accept: string; "Accept-Encoding": string; "Accept-Language": string; "content-type": string; Cookie: string; Origin: string; Referer: string; "User-Agent": string; }>; export declare function request(ctx: ContextBase, url: string, options?: RequestInit, raw?: boolean): Promise; export declare function getImageMetaData(filePath: string): Promise<{ fileName: string; totalSize: number | undefined; width: number | undefined; height: number | undefined; }>; export declare function getFileSize(filePath: string): Promise; export declare function getGifMetaData(filePath: string): Promise<{ fileName: string; totalSize: number | undefined; width: number | undefined; height: number | undefined; }>; export declare function decodeEventData(parsed: any, cipherKey?: string): Promise; export declare function getMd5LargeFileObject(source: AttachmentSource, fileSize: number): Promise<{ currentChunk: number; data: string; }>; export declare const logger: (ctx: ContextBase) => { verbose: (...args: any[]) => void; info: (...args: any[]) => void; warn: (...args: any[]) => void; error: (...args: any[]) => void; }; export declare function getClientMessageType(msgType: string): 1 | 32 | 31 | 36 | 37 | 38 | 44 | 46 | 49 | 43; export declare function strPadLeft(e: any, t: string, n: number): any; export declare function formatTime(format: string, timestamp?: number): string; export declare function getFullTimeFromMillisecond(e: number): string; export declare function getFileExtension(e: string): string; export declare function getFileName(e: string): string; export declare function removeUndefinedKeys(e: Record): Record; export declare function getGroupEventType(act: string): GroupEventType; export declare function getFriendEventType(act: string): FriendEventType; type ZaloResponse = { data: T | null; error: { message: string; code?: number; } | null; }; export declare function handleZaloResponse(ctx: ContextSession, response: Response, isEncrypted?: boolean): Promise>; export declare function resolveResponse(ctx: ContextSession, res: Response, cb?: (result: ZaloResponse) => T, isEncrypted?: boolean): Promise; export type FactoryUtils = { makeURL: (baseURL: string, params?: Record, apiVersion?: boolean) => ReturnType; encodeAES: (data: any, t?: number) => ReturnType; request: (url: string, options?: RequestInit, raw?: boolean) => ReturnType; logger: ReturnType; resolve: (res: Response, cb?: (result: ZaloResponse) => T, isEncrypted?: boolean) => ReturnType>; }; export declare function apiFactory(): ) => any>(callback: K) => (ctx: ContextBase, api: API) => ReturnType; export declare function generateZaloUUID(userAgent: string): string; /** * Encrypts a 4-digit PIN to a 32-character hex string * @param pin 4-digit PIN number * @returns 32-character hex string */ export declare function encryptPin(pin: number): string; /** * Decrypts a 32-character hex string back to 4-digit PIN * Note: This is a one-way hash, so we can only verify if a PIN matches the hash * @param encryptedPin 32-character hex string * @param pin 4-digit PIN to verify * @returns true if the PIN matches the hash */ export declare function decryptPin(encryptedPin: string, pin?: number): boolean; export {};