gifted-baileys 1.5.0 → 1.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1429 -684
  3. package/package.json +11 -26
  4. package/src/Defaults/baileys-version.json +3 -0
  5. package/{lib → src}/Defaults/index.js +16 -8
  6. package/src/Defaults/index.ts +131 -0
  7. package/src/Defaults/phonenumber-mcc.json +223 -0
  8. package/src/Signal/libsignal.js +180 -0
  9. package/src/Signal/libsignal.ts +141 -0
  10. package/src/Socket/Client/abstract-socket-client.ts +19 -0
  11. package/src/Socket/Client/index.ts +3 -0
  12. package/src/Socket/Client/mobile-socket-client.js +78 -0
  13. package/src/Socket/Client/mobile-socket-client.ts +66 -0
  14. package/src/Socket/Client/web-socket-client.js +75 -0
  15. package/src/Socket/Client/web-socket-client.ts +57 -0
  16. package/{lib → src}/Socket/business.js +33 -27
  17. package/src/Socket/business.ts +281 -0
  18. package/{lib → src}/Socket/chats.js +197 -178
  19. package/src/Socket/chats.ts +1030 -0
  20. package/{lib → src}/Socket/groups.js +69 -79
  21. package/src/Socket/groups.ts +356 -0
  22. package/{lib → src}/Socket/index.js +1 -4
  23. package/src/Socket/index.ts +13 -0
  24. package/{lib → src}/Socket/messages-recv.js +160 -108
  25. package/src/Socket/messages-recv.ts +985 -0
  26. package/{lib → src}/Socket/messages-send.js +183 -100
  27. package/src/Socket/messages-send.ts +871 -0
  28. package/src/Socket/newsletter.js +227 -0
  29. package/src/Socket/newsletter.ts +282 -0
  30. package/{lib → src}/Socket/registration.js +55 -63
  31. package/src/Socket/registration.ts +250 -0
  32. package/{lib → src}/Socket/socket.js +107 -66
  33. package/src/Socket/socket.ts +777 -0
  34. package/src/Store/index.ts +3 -0
  35. package/{lib → src}/Store/make-cache-manager-store.js +34 -25
  36. package/src/Store/make-cache-manager-store.ts +100 -0
  37. package/{lib → src}/Store/make-in-memory-store.js +51 -61
  38. package/src/Store/make-in-memory-store.ts +475 -0
  39. package/src/Store/make-ordered-dictionary.ts +86 -0
  40. package/{lib → src}/Store/object-repository.js +1 -1
  41. package/src/Store/object-repository.ts +32 -0
  42. package/src/Tests/test.app-state-sync.js +204 -0
  43. package/src/Tests/test.app-state-sync.ts +207 -0
  44. package/src/Tests/test.event-buffer.js +270 -0
  45. package/src/Tests/test.event-buffer.ts +319 -0
  46. package/src/Tests/test.key-store.js +76 -0
  47. package/src/Tests/test.key-store.ts +92 -0
  48. package/src/Tests/test.libsignal.js +141 -0
  49. package/src/Tests/test.libsignal.ts +186 -0
  50. package/src/Tests/test.media-download.js +93 -0
  51. package/src/Tests/test.media-download.ts +76 -0
  52. package/src/Tests/test.messages.js +33 -0
  53. package/src/Tests/test.messages.ts +37 -0
  54. package/src/Tests/utils.js +34 -0
  55. package/src/Tests/utils.ts +36 -0
  56. package/src/Types/Auth.ts +113 -0
  57. package/src/Types/Call.ts +15 -0
  58. package/src/Types/Chat.ts +106 -0
  59. package/{lib/Types/Contact.d.ts → src/Types/Contact.ts} +9 -8
  60. package/src/Types/Events.ts +93 -0
  61. package/src/Types/GroupMetadata.ts +53 -0
  62. package/{lib → src}/Types/Label.js +1 -1
  63. package/src/Types/Label.ts +36 -0
  64. package/{lib → src}/Types/LabelAssociation.js +1 -1
  65. package/{lib/Types/LabelAssociation.d.ts → src/Types/LabelAssociation.ts} +22 -16
  66. package/src/Types/Message.ts +288 -0
  67. package/src/Types/Newsletter.js +32 -0
  68. package/src/Types/Newsletter.ts +98 -0
  69. package/src/Types/Product.ts +85 -0
  70. package/src/Types/Signal.ts +68 -0
  71. package/{lib/Types/Socket.d.ts → src/Types/Socket.ts} +68 -56
  72. package/src/Types/State.ts +29 -0
  73. package/{lib → src}/Types/index.js +2 -1
  74. package/src/Types/index.ts +59 -0
  75. package/{lib → src}/Utils/auth-utils.js +95 -76
  76. package/src/Utils/auth-utils.ts +222 -0
  77. package/src/Utils/baileys-event-stream.js +92 -0
  78. package/src/Utils/baileys-event-stream.ts +66 -0
  79. package/{lib → src}/Utils/business.js +45 -17
  80. package/src/Utils/business.ts +275 -0
  81. package/{lib → src}/Utils/chat-utils.js +74 -46
  82. package/src/Utils/chat-utils.ts +860 -0
  83. package/{lib → src}/Utils/crypto.js +31 -21
  84. package/src/Utils/crypto.ts +131 -0
  85. package/src/Utils/decode-wa-message.js +211 -0
  86. package/src/Utils/decode-wa-message.ts +228 -0
  87. package/{lib → src}/Utils/event-buffer.js +13 -4
  88. package/src/Utils/event-buffer.ts +613 -0
  89. package/{lib → src}/Utils/generics.js +98 -45
  90. package/src/Utils/generics.ts +434 -0
  91. package/{lib → src}/Utils/history.js +39 -10
  92. package/src/Utils/history.ts +112 -0
  93. package/src/Utils/index.ts +17 -0
  94. package/{lib → src}/Utils/link-preview.js +54 -17
  95. package/src/Utils/link-preview.ts +122 -0
  96. package/src/Utils/logger.ts +3 -0
  97. package/src/Utils/lt-hash.ts +61 -0
  98. package/{lib → src}/Utils/make-mutex.js +13 -4
  99. package/src/Utils/make-mutex.ts +44 -0
  100. package/{lib → src}/Utils/messages-media.js +296 -192
  101. package/src/Utils/messages-media.ts +847 -0
  102. package/{lib → src}/Utils/messages.js +124 -113
  103. package/src/Utils/messages.ts +956 -0
  104. package/{lib → src}/Utils/noise-handler.js +16 -3
  105. package/src/Utils/noise-handler.ts +197 -0
  106. package/{lib → src}/Utils/process-message.js +33 -29
  107. package/src/Utils/process-message.ts +414 -0
  108. package/{lib → src}/Utils/signal.js +23 -14
  109. package/src/Utils/signal.ts +177 -0
  110. package/{lib → src}/Utils/use-multi-file-auth-state.js +28 -19
  111. package/src/Utils/use-multi-file-auth-state.ts +90 -0
  112. package/{lib → src}/Utils/validate-connection.js +25 -42
  113. package/src/Utils/validate-connection.ts +238 -0
  114. package/src/WABinary/constants.ts +42 -0
  115. package/{lib → src}/WABinary/decode.js +17 -7
  116. package/src/WABinary/decode.ts +265 -0
  117. package/{lib → src}/WABinary/encode.js +17 -7
  118. package/src/WABinary/encode.ts +236 -0
  119. package/{lib → src}/WABinary/generic-utils.js +2 -2
  120. package/src/WABinary/generic-utils.ts +121 -0
  121. package/src/WABinary/index.ts +5 -0
  122. package/{lib → src}/WABinary/jid-utils.js +4 -1
  123. package/src/WABinary/jid-utils.ts +68 -0
  124. package/src/WABinary/types.ts +17 -0
  125. package/src/WAM/BinaryInfo.js +13 -0
  126. package/src/WAM/BinaryInfo.ts +12 -0
  127. package/src/WAM/constants.js +15350 -0
  128. package/src/WAM/constants.ts +15382 -0
  129. package/src/WAM/encode.js +155 -0
  130. package/src/WAM/encode.ts +174 -0
  131. package/src/WAM/index.js +19 -0
  132. package/src/WAM/index.ts +3 -0
  133. package/src/gifted +1 -0
  134. package/{lib → src}/index.js +1 -0
  135. package/src/index.ts +13 -0
  136. package/lib/Defaults/baileys-version.json +0 -3
  137. package/lib/Defaults/index.d.ts +0 -284
  138. package/lib/Defaults/phonenumber-mcc.json +0 -223
  139. package/lib/Signal/libsignal.d.ts +0 -3
  140. package/lib/Signal/libsignal.js +0 -152
  141. package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
  142. package/lib/Socket/Client/index.d.ts +0 -3
  143. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
  144. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  145. package/lib/Socket/Client/web-socket-client.d.ts +0 -12
  146. package/lib/Socket/Client/web-socket-client.js +0 -62
  147. package/lib/Socket/business.d.ts +0 -135
  148. package/lib/Socket/chats.d.ts +0 -79
  149. package/lib/Socket/groups.d.ts +0 -113
  150. package/lib/Socket/index.d.ts +0 -137
  151. package/lib/Socket/messages-recv.d.ts +0 -124
  152. package/lib/Socket/messages-send.d.ts +0 -119
  153. package/lib/Socket/registration.d.ts +0 -232
  154. package/lib/Socket/socket.d.ts +0 -42
  155. package/lib/Store/index.d.ts +0 -3
  156. package/lib/Store/make-cache-manager-store.d.ts +0 -13
  157. package/lib/Store/make-in-memory-store.d.ts +0 -117
  158. package/lib/Store/make-ordered-dictionary.d.ts +0 -13
  159. package/lib/Store/object-repository.d.ts +0 -10
  160. package/lib/Types/Auth.d.ts +0 -108
  161. package/lib/Types/Call.d.ts +0 -13
  162. package/lib/Types/Chat.d.ts +0 -102
  163. package/lib/Types/Events.d.ts +0 -157
  164. package/lib/Types/GroupMetadata.d.ts +0 -52
  165. package/lib/Types/Label.d.ts +0 -35
  166. package/lib/Types/Message.d.ts +0 -261
  167. package/lib/Types/Product.d.ts +0 -78
  168. package/lib/Types/Signal.d.ts +0 -57
  169. package/lib/Types/State.d.ts +0 -27
  170. package/lib/Types/index.d.ts +0 -56
  171. package/lib/Utils/auth-utils.d.ts +0 -18
  172. package/lib/Utils/baileys-event-stream.d.ts +0 -16
  173. package/lib/Utils/baileys-event-stream.js +0 -63
  174. package/lib/Utils/business.d.ts +0 -22
  175. package/lib/Utils/chat-utils.d.ts +0 -71
  176. package/lib/Utils/crypto.d.ts +0 -41
  177. package/lib/Utils/decode-wa-message.d.ts +0 -19
  178. package/lib/Utils/decode-wa-message.js +0 -174
  179. package/lib/Utils/event-buffer.d.ts +0 -35
  180. package/lib/Utils/generics.d.ts +0 -94
  181. package/lib/Utils/history.d.ts +0 -15
  182. package/lib/Utils/index.d.ts +0 -17
  183. package/lib/Utils/link-preview.d.ts +0 -21
  184. package/lib/Utils/logger.d.ts +0 -4
  185. package/lib/Utils/lt-hash.d.ts +0 -12
  186. package/lib/Utils/make-mutex.d.ts +0 -7
  187. package/lib/Utils/messages-media.d.ts +0 -107
  188. package/lib/Utils/messages.d.ts +0 -76
  189. package/lib/Utils/noise-handler.d.ts +0 -20
  190. package/lib/Utils/process-message.d.ts +0 -41
  191. package/lib/Utils/signal.d.ts +0 -32
  192. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -12
  193. package/lib/Utils/validate-connection.d.ts +0 -11
  194. package/lib/WABinary/constants.d.ts +0 -27
  195. package/lib/WABinary/decode.d.ts +0 -7
  196. package/lib/WABinary/encode.d.ts +0 -3
  197. package/lib/WABinary/generic-utils.d.ts +0 -15
  198. package/lib/WABinary/index.d.ts +0 -5
  199. package/lib/WABinary/jid-utils.d.ts +0 -29
  200. package/lib/WABinary/types.d.ts +0 -18
  201. package/lib/index.d.ts +0 -10
  202. /package/{lib → src}/Socket/Client/abstract-socket-client.js +0 -0
  203. /package/{lib → src}/Socket/Client/index.js +0 -0
  204. /package/{lib → src}/Store/index.js +0 -0
  205. /package/{lib → src}/Store/make-ordered-dictionary.js +0 -0
  206. /package/{lib → src}/Types/Auth.js +0 -0
  207. /package/{lib → src}/Types/Call.js +0 -0
  208. /package/{lib → src}/Types/Chat.js +0 -0
  209. /package/{lib → src}/Types/Contact.js +0 -0
  210. /package/{lib → src}/Types/Events.js +0 -0
  211. /package/{lib → src}/Types/GroupMetadata.js +0 -0
  212. /package/{lib → src}/Types/Message.js +0 -0
  213. /package/{lib → src}/Types/Product.js +0 -0
  214. /package/{lib → src}/Types/Signal.js +0 -0
  215. /package/{lib → src}/Types/Socket.js +0 -0
  216. /package/{lib → src}/Types/State.js +0 -0
  217. /package/{lib → src}/Utils/index.js +0 -0
  218. /package/{lib → src}/Utils/logger.js +0 -0
  219. /package/{lib → src}/Utils/lt-hash.js +0 -0
  220. /package/{lib → src}/WABinary/constants.js +0 -0
  221. /package/{lib → src}/WABinary/index.js +0 -0
  222. /package/{lib → src}/WABinary/types.js +0 -0
@@ -1,94 +0,0 @@
1
- /// <reference types="node" />
2
- import { AxiosRequestConfig } from 'axios';
3
- import { Logger } from 'pino';
4
- import { proto } from '../../WAProto';
5
- import { BaileysEventEmitter, BaileysEventMap, WACallUpdateType, WAVersion } from '../Types';
6
- import { BinaryNode } from '../WABinary';
7
- export declare const Browsers: {
8
- ubuntu: (browser: any) => [string, string, string];
9
- macOS: (browser: any) => [string, string, string];
10
- baileys: (browser: any) => [string, string, string];
11
- windows: (browser: any) => [string, string, string];
12
- /** The appropriate browser based on your OS & release */
13
- appropriate: (browser: any) => [string, string, string];
14
- };
15
- export declare const BufferJSON: {
16
- replacer: (k: any, value: any) => any;
17
- reviver: (_: any, value: any) => any;
18
- };
19
- export declare const getKeyAuthor: (key: proto.IMessageKey | undefined | null, meId?: string) => string;
20
- export declare const writeRandomPadMax16: (msg: Uint8Array) => Buffer;
21
- export declare const unpadRandomMax16: (e: Uint8Array | Buffer) => Uint8Array;
22
- export declare const encodeWAMessage: (message: proto.IMessage) => Buffer;
23
- export declare const generateRegistrationId: () => number;
24
- export declare const encodeBigEndian: (e: number, t?: number) => Uint8Array;
25
- export declare const toNumber: (t: Long | number | null | undefined) => number;
26
- /** unix timestamp of a date in seconds */
27
- export declare const unixTimestampSeconds: (date?: Date) => number;
28
- export type DebouncedTimeout = ReturnType<typeof debouncedTimeout>;
29
- export declare const debouncedTimeout: (intervalMs?: number, task?: () => void) => {
30
- start: (newIntervalMs?: number, newTask?: () => void) => void;
31
- cancel: () => void;
32
- setTask: (newTask: () => void) => () => void;
33
- setInterval: (newInterval: number) => number;
34
- };
35
- export declare const delay: (ms: number) => Promise<void>;
36
- export declare const delayCancellable: (ms: number) => {
37
- delay: Promise<void>;
38
- cancel: () => void;
39
- };
40
- export declare function promiseTimeout<T>(ms: number | undefined, promise: (resolve: (v: T) => void, reject: (error: any) => void) => void): Promise<T>;
41
- export declare const generateMessageID: () => string;
42
- export declare function bindWaitForEvent<T extends keyof BaileysEventMap>(ev: BaileysEventEmitter, event: T): (check: (u: BaileysEventMap[T]) => boolean | undefined, timeoutMs?: number) => Promise<void>;
43
- export declare const bindWaitForConnectionUpdate: (ev: BaileysEventEmitter) => (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number) => Promise<void>;
44
- export declare const printQRIfNecessaryListener: (ev: BaileysEventEmitter, logger: Logger) => void;
45
- /**
46
- * utility that fetches latest baileys version from the master branch.
47
- * Use to ensure your WA connection is always on the latest version
48
- */
49
- export declare const fetchLatestBaileysVersion: (options?: AxiosRequestConfig<any>) => Promise<{
50
- version: WAVersion;
51
- isLatest: boolean;
52
- error?: undefined;
53
- } | {
54
- version: WAVersion;
55
- isLatest: boolean;
56
- error: any;
57
- }>;
58
- /**
59
- * A utility that fetches the latest web version of whatsapp.
60
- * Use to ensure your WA connection is always on the latest version
61
- */
62
- export declare const fetchLatestWaWebVersion: (options: AxiosRequestConfig<any>) => Promise<{
63
- version: WAVersion;
64
- isLatest: boolean;
65
- error?: undefined;
66
- } | {
67
- version: WAVersion;
68
- isLatest: boolean;
69
- error: any;
70
- }>;
71
- /** unique message tag prefix for MD clients */
72
- export declare const generateMdTagPrefix: () => string;
73
- /**
74
- * Given a type of receipt, returns what the new status of the message should be
75
- * @param type type from receipt
76
- */
77
- export declare const getStatusFromReceiptType: (type: string | undefined) => proto.WebMessageInfo.Status;
78
- /**
79
- * Stream errors generally provide a reason, map that to a baileys DisconnectReason
80
- * @param reason the string reason given, eg. "conflict"
81
- */
82
- export declare const getErrorCodeFromStreamError: (node: BinaryNode) => {
83
- reason: string;
84
- statusCode: number;
85
- };
86
- export declare const getCallStatusFromNode: ({ tag, attrs }: BinaryNode) => WACallUpdateType;
87
- export declare const getCodeFromWSError: (error: Error) => number;
88
- /**
89
- * Is the given platform WA business
90
- * @param platform AuthenticationCreds.platform
91
- */
92
- export declare const isWABusinessPlatform: (platform: string) => boolean;
93
- export declare function trimUndefined(obj: any): any;
94
- export declare function bytesToCrockford(buffer: Buffer): string;
@@ -1,15 +0,0 @@
1
- import { AxiosRequestConfig } from 'axios';
2
- import { proto } from '../../WAProto';
3
- import { Chat, Contact } from '../Types';
4
- export declare const downloadHistory: (msg: proto.Message.IHistorySyncNotification, options: AxiosRequestConfig<any>) => Promise<proto.HistorySync>;
5
- export declare const processHistoryMessage: (item: proto.IHistorySync) => {
6
- chats: Chat[];
7
- contacts: Contact[];
8
- messages: proto.IWebMessageInfo[];
9
- };
10
- export declare const downloadAndProcessHistorySyncNotification: (msg: proto.Message.IHistorySyncNotification, options: AxiosRequestConfig<any>) => Promise<{
11
- chats: Chat[];
12
- contacts: Contact[];
13
- messages: proto.IWebMessageInfo[];
14
- }>;
15
- export declare const getHistoryMsg: (message: proto.IMessage) => proto.Message.IHistorySyncNotification | null | undefined;
@@ -1,17 +0,0 @@
1
- export * from './generics';
2
- export * from './decode-wa-message';
3
- export * from './messages';
4
- export * from './messages-media';
5
- export * from './validate-connection';
6
- export * from './crypto';
7
- export * from './signal';
8
- export * from './noise-handler';
9
- export * from './history';
10
- export * from './chat-utils';
11
- export * from './lt-hash';
12
- export * from './auth-utils';
13
- export * from './baileys-event-stream';
14
- export * from './use-multi-file-auth-state';
15
- export * from './link-preview';
16
- export * from './event-buffer';
17
- export * from './process-message';
@@ -1,21 +0,0 @@
1
- import { AxiosRequestConfig } from 'axios';
2
- import { Logger } from 'pino';
3
- import { WAMediaUploadFunction, WAUrlInfo } from '../Types';
4
- export type URLGenerationOptions = {
5
- thumbnailWidth: number;
6
- fetchOpts: {
7
- /** Timeout in ms */
8
- timeout: number;
9
- proxyUrl?: string;
10
- headers?: AxiosRequestConfig<{}>['headers'];
11
- };
12
- uploadImage?: WAMediaUploadFunction;
13
- logger?: Logger;
14
- };
15
- /**
16
- * Given a piece of text, checks for any URL present, generates link preview for the same and returns it
17
- * Return undefined if the fetch failed or no URL was found
18
- * @param text first matched URL in text
19
- * @returns the URL info required to generate link preview
20
- */
21
- export declare const getUrlInfo: (text: string, opts?: URLGenerationOptions) => Promise<WAUrlInfo | undefined>;
@@ -1,4 +0,0 @@
1
- declare const _default: import("pino").Logger<{
2
- timestamp: () => string;
3
- }>;
4
- export default _default;
@@ -1,12 +0,0 @@
1
- declare class d {
2
- salt: string;
3
- constructor(e: string);
4
- add(e: any, t: any): any;
5
- subtract(e: any, t: any): any;
6
- subtractThenAdd(e: any, t: any, r: any): any;
7
- _addSingle(e: any, t: any): ArrayBuffer;
8
- _subtractSingle(e: any, t: any): ArrayBuffer;
9
- performPointwiseWithOverflow(e: any, t: any, r: any): ArrayBuffer;
10
- }
11
- export declare const LT_HASH_ANTI_TAMPERING: d;
12
- export {};
@@ -1,7 +0,0 @@
1
- export declare const makeMutex: () => {
2
- mutex<T>(code: () => T | Promise<T>): Promise<T>;
3
- };
4
- export type Mutex = ReturnType<typeof makeMutex>;
5
- export declare const makeKeyedMutex: () => {
6
- mutex<T>(key: string, task: () => T | Promise<T>): Promise<T>;
7
- };
@@ -1,107 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- import { Boom } from '@hapi/boom';
5
- import { AxiosRequestConfig } from 'axios';
6
- import type { Logger } from 'pino';
7
- import { Readable, Transform } from 'stream';
8
- import { URL } from 'url';
9
- import { proto } from '../../WAProto';
10
- import { DownloadableMessage, MediaConnInfo, MediaDecryptionKeyInfo, MediaType, SocketConfig, WAMediaUpload, WAMediaUploadFunction, WAMessageContent } from '../Types';
11
- import { BinaryNode } from '../WABinary';
12
- export declare const hkdfInfoKey: (type: MediaType) => string;
13
- /** generates all the keys required to encrypt/decrypt & sign a media message */
14
- export declare function getMediaKeys(buffer: Uint8Array | string | null | undefined, mediaType: MediaType): MediaDecryptionKeyInfo;
15
- export declare const extractImageThumb: (bufferOrFilePath: Readable | Buffer | string, width?: number) => Promise<{
16
- buffer: Buffer;
17
- original: {
18
- width: number | undefined;
19
- height: number | undefined;
20
- };
21
- }>;
22
- export declare const encodeBase64EncodedStringForUpload: (b64: string) => string;
23
- export declare const generateProfilePicture: (mediaUpload: WAMediaUpload) => Promise<{
24
- img: Buffer;
25
- }>;
26
- /** gets the SHA256 of the given media message */
27
- export declare const mediaMessageSHA256B64: (message: WAMessageContent) => string | null | undefined;
28
- export declare function getAudioDuration(buffer: Buffer | string | Readable): Promise<number | undefined>;
29
- /**
30
- referenced from and modifying https://github.com/wppconnect-team/wa-js/blob/main/src/chat/functions/prepareAudioWaveform.ts
31
- */
32
- export declare function getAudioWaveform(buffer: Buffer | string | Readable, logger?: Logger): Promise<Uint8Array | undefined>;
33
- export declare const toReadable: (buffer: Buffer) => Readable;
34
- export declare const toBuffer: (stream: Readable) => Promise<Buffer>;
35
- export declare const getStream: (item: WAMediaUpload, opts?: AxiosRequestConfig) => Promise<{
36
- readonly stream: Readable;
37
- readonly type: "buffer";
38
- } | {
39
- readonly stream: Readable;
40
- readonly type: "readable";
41
- } | {
42
- readonly stream: Readable;
43
- readonly type: "remote";
44
- } | {
45
- readonly stream: import("fs").ReadStream;
46
- readonly type: "file";
47
- }>;
48
- /** generates a thumbnail for a given media, if required */
49
- export declare function generateThumbnail(file: string, mediaType: 'video' | 'image', options: {
50
- logger?: Logger;
51
- }): Promise<{
52
- thumbnail: string | undefined;
53
- originalImageDimensions: {
54
- width: number;
55
- height: number;
56
- } | undefined;
57
- }>;
58
- export declare const getHttpStream: (url: string | URL, options?: AxiosRequestConfig & {
59
- isStream?: true;
60
- }) => Promise<Readable>;
61
- type EncryptedStreamOptions = {
62
- saveOriginalFileIfRequired?: boolean;
63
- logger?: Logger;
64
- opts?: AxiosRequestConfig;
65
- };
66
- export declare const encryptedStream: (media: WAMediaUpload, mediaType: MediaType, { logger, saveOriginalFileIfRequired, opts }?: EncryptedStreamOptions) => Promise<{
67
- mediaKey: Buffer;
68
- encWriteStream: Readable;
69
- bodyPath: string | undefined;
70
- mac: Buffer;
71
- fileEncSha256: Buffer;
72
- fileSha256: Buffer;
73
- fileLength: number;
74
- didSaveToTmpPath: boolean;
75
- }>;
76
- export type MediaDownloadOptions = {
77
- startByte?: number;
78
- endByte?: number;
79
- options?: AxiosRequestConfig<any>;
80
- };
81
- export declare const getUrlFromDirectPath: (directPath: string) => string;
82
- export declare const downloadContentFromMessage: ({ mediaKey, directPath, url }: DownloadableMessage, type: MediaType, opts?: MediaDownloadOptions) => Promise<Transform>;
83
- /**
84
- * Decrypts and downloads an AES256-CBC encrypted file given the keys.
85
- * Assumes the SHA256 of the plaintext is appended to the end of the ciphertext
86
- * */
87
- export declare const downloadEncryptedContent: (downloadUrl: string, { cipherKey, iv }: MediaDecryptionKeyInfo, { startByte, endByte, options }?: MediaDownloadOptions) => Promise<Transform>;
88
- export declare function extensionForMediaMessage(message: WAMessageContent): string;
89
- export declare const getWAUploadToServer: ({ customUploadHosts, fetchAgent, logger, options }: SocketConfig, refreshMediaConn: (force: boolean) => Promise<MediaConnInfo>) => WAMediaUploadFunction;
90
- /**
91
- * Generate a binary node that will request the phone to re-upload the media & return the newly uploaded URL
92
- */
93
- export declare const encryptMediaRetryRequest: (key: proto.IMessageKey, mediaKey: Buffer | Uint8Array, meId: string) => BinaryNode;
94
- export declare const decodeMediaRetryNode: (node: BinaryNode) => {
95
- key: proto.IMessageKey;
96
- media?: {
97
- ciphertext: Uint8Array;
98
- iv: Uint8Array;
99
- } | undefined;
100
- error?: Boom<any> | undefined;
101
- };
102
- export declare const decryptMediaRetryData: ({ ciphertext, iv }: {
103
- ciphertext: Uint8Array;
104
- iv: Uint8Array;
105
- }, mediaKey: Uint8Array, msgId: string) => proto.MediaRetryNotification;
106
- export declare const getStatusCodeForMediaRetry: (code: number) => any;
107
- export {};
@@ -1,76 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { Logger } from 'pino';
4
- import { proto } from '../../WAProto';
5
- import { AnyMediaMessageContent, AnyMessageContent, MediaGenerationOptions, MessageContentGenerationOptions, MessageGenerationOptions, MessageGenerationOptionsFromContent, MessageUserReceipt, WAMessage, WAMessageContent, WAProto } from '../Types';
6
- import { MediaDownloadOptions } from './messages-media';
7
- /**
8
- * Uses a regex to test whether the string contains a URL, and returns the URL if it does.
9
- * @param text eg. hello https://google.com
10
- * @returns the URL, eg. https://google.com
11
- */
12
- export declare const extractUrlFromText: (text: string) => string | undefined;
13
- export declare const generateLinkPreviewIfRequired: (text: string, getUrlInfo: MessageGenerationOptions['getUrlInfo'], logger: MessageGenerationOptions['logger']) => Promise<import("../Types").WAUrlInfo | undefined>;
14
- export declare const prepareWAMessageMedia: (message: AnyMediaMessageContent, options: MediaGenerationOptions) => Promise<proto.Message>;
15
- export declare const prepareDisappearingMessageSettingContent: (ephemeralExpiration?: number) => proto.Message;
16
- /**
17
- * Generate forwarded message content like WA does
18
- * @param message the message to forward
19
- * @param options.forceForward will show the message as forwarded even if it is from you
20
- */
21
- export declare const generateForwardMessageContent: (message: WAMessage, forceForward?: boolean) => proto.IMessage;
22
- export declare const generateWAMessageContent: (message: AnyMessageContent, options: MessageContentGenerationOptions) => Promise<proto.Message>;
23
- export declare const generateWAMessageFromContent: (jid: string, message: WAMessageContent, options: MessageGenerationOptionsFromContent) => proto.WebMessageInfo;
24
- export declare const generateWAMessage: (jid: string, content: AnyMessageContent, options: MessageGenerationOptions) => Promise<proto.WebMessageInfo>;
25
- /** Get the key to access the true type of content */
26
- export declare const getContentType: (content: WAProto.IMessage | undefined) => keyof proto.IMessage | undefined;
27
- /**
28
- * Normalizes ephemeral, view once messages to regular message content
29
- * Eg. image messages in ephemeral messages, in view once messages etc.
30
- * @param content
31
- * @returns
32
- */
33
- export declare const normalizeMessageContent: (content: WAMessageContent | null | undefined) => WAMessageContent | undefined;
34
- /**
35
- * Extract the true message content from a message
36
- * Eg. extracts the inner message from a disappearing message/view once message
37
- */
38
- export declare const extractMessageContent: (content: WAMessageContent | undefined | null) => WAMessageContent | undefined;
39
- /**
40
- * Returns the device predicted by message ID
41
- */
42
- export declare const getDevice: (id: string) => "android" | "unknown" | "web" | "ios" | "desktop";
43
- /** Upserts a receipt in the message */
44
- export declare const updateMessageWithReceipt: (msg: Pick<WAMessage, 'userReceipt'>, receipt: MessageUserReceipt) => void;
45
- /** Update the message with a new reaction */
46
- export declare const updateMessageWithReaction: (msg: Pick<WAMessage, 'reactions'>, reaction: proto.IReaction) => void;
47
- /** Update the message with a new poll update */
48
- export declare const updateMessageWithPollUpdate: (msg: Pick<WAMessage, 'pollUpdates'>, update: proto.IPollUpdate) => void;
49
- type VoteAggregation = {
50
- name: string;
51
- voters: string[];
52
- };
53
- /**
54
- * Aggregates all poll updates in a poll.
55
- * @param msg the poll creation message
56
- * @param meId your jid
57
- * @returns A list of options & their voters
58
- */
59
- export declare function getAggregateVotesInPollMessage({ message, pollUpdates }: Pick<WAMessage, 'pollUpdates' | 'message'>, meId?: string): VoteAggregation[];
60
- /** Given a list of message keys, aggregates them by chat & sender. Useful for sending read receipts in bulk */
61
- export declare const aggregateMessageKeysNotFromMe: (keys: proto.IMessageKey[]) => {
62
- jid: string;
63
- participant: string | undefined;
64
- messageIds: string[];
65
- }[];
66
- type DownloadMediaMessageContext = {
67
- reuploadRequest: (msg: WAMessage) => Promise<WAMessage>;
68
- logger: Logger;
69
- };
70
- /**
71
- * Downloads the given message. Throws an error if it's not a media message
72
- */
73
- export declare const downloadMediaMessage: (message: WAMessage, type: 'buffer' | 'stream', options: MediaDownloadOptions, ctx?: DownloadMediaMessageContext) => Promise<Buffer | import("stream").Transform>;
74
- /** Checks whether the given message is a media message; if it is returns the inner content */
75
- export declare const assertMediaContent: (content: proto.IMessage | null | undefined) => proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
76
- export {};
@@ -1,20 +0,0 @@
1
- /// <reference types="node" />
2
- import { Logger } from 'pino';
3
- import { proto } from '../../WAProto';
4
- import { KeyPair } from '../Types';
5
- import { BinaryNode } from '../WABinary';
6
- export declare const makeNoiseHandler: ({ keyPair: { private: privateKey, public: publicKey }, NOISE_HEADER, mobile, logger, }: {
7
- keyPair: KeyPair;
8
- NOISE_HEADER: Uint8Array;
9
- mobile: boolean;
10
- logger: Logger;
11
- }) => {
12
- encrypt: (plaintext: Uint8Array) => Buffer;
13
- decrypt: (ciphertext: Uint8Array) => Buffer;
14
- authenticate: (data: Uint8Array) => void;
15
- mixIntoKey: (data: Uint8Array) => void;
16
- finishInit: () => void;
17
- processHandshake: ({ serverHello }: proto.HandshakeMessage, noiseKey: KeyPair) => Buffer;
18
- encodeFrame: (data: Buffer | Uint8Array) => Buffer;
19
- decodeFrame: (newData: Buffer | Uint8Array, onFrame: (buff: Uint8Array | BinaryNode) => void) => void;
20
- };
@@ -1,41 +0,0 @@
1
- import { AxiosRequestConfig } from 'axios';
2
- import type { Logger } from 'pino';
3
- import { proto } from '../../WAProto';
4
- import { AuthenticationCreds, BaileysEventEmitter, SignalKeyStoreWithTransaction, SocketConfig } from '../Types';
5
- type ProcessMessageContext = {
6
- shouldProcessHistoryMsg: boolean;
7
- creds: AuthenticationCreds;
8
- keyStore: SignalKeyStoreWithTransaction;
9
- ev: BaileysEventEmitter;
10
- getMessage: SocketConfig['getMessage'];
11
- logger?: Logger;
12
- options: AxiosRequestConfig<{}>;
13
- };
14
- /** Cleans a received message to further processing */
15
- export declare const cleanMessage: (message: proto.IWebMessageInfo, meId: string) => void;
16
- export declare const isRealMessage: (message: proto.IWebMessageInfo, meId: string) => boolean | undefined;
17
- export declare const shouldIncrementChatUnread: (message: proto.IWebMessageInfo) => boolean;
18
- /**
19
- * Get the ID of the chat from the given key.
20
- * Typically -- that'll be the remoteJid, but for broadcasts, it'll be the participant
21
- */
22
- export declare const getChatId: ({ remoteJid, participant, fromMe }: proto.IMessageKey) => string;
23
- type PollContext = {
24
- /** normalised jid of the person that created the poll */
25
- pollCreatorJid: string;
26
- /** ID of the poll creation message */
27
- pollMsgId: string;
28
- /** poll creation message enc key */
29
- pollEncKey: Uint8Array;
30
- /** jid of the person that voted */
31
- voterJid: string;
32
- };
33
- /**
34
- * Decrypt a poll vote
35
- * @param vote encrypted vote
36
- * @param ctx additional info about the poll required for decryption
37
- * @returns list of SHA256 options
38
- */
39
- export declare function decryptPollVote({ encPayload, encIv }: proto.Message.IPollEncValue, { pollCreatorJid, pollMsgId, pollEncKey, voterJid, }: PollContext): proto.Message.PollVoteMessage;
40
- declare const processMessage: (message: proto.IWebMessageInfo, { shouldProcessHistoryMsg, ev, creds, keyStore, logger, options, getMessage }: ProcessMessageContext) => Promise<void>;
41
- export default processMessage;
@@ -1,32 +0,0 @@
1
- import { SignalRepository } from '../Types';
2
- import { AuthenticationCreds, AuthenticationState, KeyPair, SignalIdentity, SignalKeyStore, SignedKeyPair } from '../Types/Auth';
3
- import { BinaryNode, JidWithDevice } from '../WABinary';
4
- export declare const createSignalIdentity: (wid: string, accountSignatureKey: Uint8Array) => SignalIdentity;
5
- export declare const getPreKeys: ({ get }: SignalKeyStore, min: number, limit: number) => Promise<{
6
- [id: string]: KeyPair;
7
- }>;
8
- export declare const generateOrGetPreKeys: (creds: AuthenticationCreds, range: number) => {
9
- newPreKeys: {
10
- [id: number]: KeyPair;
11
- };
12
- lastPreKeyId: number;
13
- preKeysRange: readonly [number, number];
14
- };
15
- export declare const xmppSignedPreKey: (key: SignedKeyPair) => BinaryNode;
16
- export declare const xmppPreKey: (pair: KeyPair, id: number) => BinaryNode;
17
- export declare const parseAndInjectE2ESessions: (node: BinaryNode, repository: SignalRepository) => Promise<void>;
18
- export declare const extractDeviceJids: (result: BinaryNode, myJid: string, excludeZeroDevices: boolean) => JidWithDevice[];
19
- /**
20
- * get the next N keys for upload or processing
21
- * @param count number of pre-keys to get or generate
22
- */
23
- export declare const getNextPreKeys: ({ creds, keys }: AuthenticationState, count: number) => Promise<{
24
- update: Partial<AuthenticationCreds>;
25
- preKeys: {
26
- [id: string]: KeyPair;
27
- };
28
- }>;
29
- export declare const getNextPreKeysNode: (state: AuthenticationState, count: number) => Promise<{
30
- update: Partial<AuthenticationCreds>;
31
- node: BinaryNode;
32
- }>;
@@ -1,12 +0,0 @@
1
- import { AuthenticationState } from '../Types';
2
- /**
3
- * stores the full authentication state in a single folder.
4
- * Far more efficient than singlefileauthstate
5
- *
6
- * Again, I wouldn't endorse this for any production level use other than perhaps a bot.
7
- * Would recommend writing an auth state for use with a proper SQL or No-SQL DB
8
- * */
9
- export declare const useMultiFileAuthState: (folder: string) => Promise<{
10
- state: AuthenticationState;
11
- saveCreds: () => Promise<void>;
12
- }>;
@@ -1,11 +0,0 @@
1
- import { proto } from '../../WAProto';
2
- import type { AuthenticationCreds, SignalCreds, SocketConfig } from '../Types';
3
- import { BinaryNode } from '../WABinary';
4
- export declare const generateMobileNode: (config: SocketConfig) => proto.IClientPayload;
5
- export declare const generateLoginNode: (userJid: string, config: SocketConfig) => proto.IClientPayload;
6
- export declare const generateRegistrationNode: ({ registrationId, signedPreKey, signedIdentityKey }: SignalCreds, config: SocketConfig) => proto.ClientPayload;
7
- export declare const configureSuccessfulPairing: (stanza: BinaryNode, { advSecretKey, signedIdentityKey, signalIdentities }: Pick<AuthenticationCreds, 'advSecretKey' | 'signedIdentityKey' | 'signalIdentities'>) => {
8
- creds: Partial<AuthenticationCreds>;
9
- reply: BinaryNode;
10
- };
11
- export declare const encodeSignedDeviceIdentity: (account: proto.IADVSignedDeviceIdentity, includeSignatureKey: boolean) => Uint8Array;
@@ -1,27 +0,0 @@
1
- export declare const TAGS: {
2
- LIST_EMPTY: number;
3
- DICTIONARY_0: number;
4
- DICTIONARY_1: number;
5
- DICTIONARY_2: number;
6
- DICTIONARY_3: number;
7
- AD_JID: number;
8
- LIST_8: number;
9
- LIST_16: number;
10
- JID_PAIR: number;
11
- HEX_8: number;
12
- BINARY_8: number;
13
- BINARY_20: number;
14
- BINARY_32: number;
15
- NIBBLE_8: number;
16
- PACKED_MAX: number;
17
- SINGLE_BYTE_MAX: number;
18
- STREAM_END: number;
19
- };
20
- export declare const DOUBLE_BYTE_TOKENS: string[][];
21
- export declare const SINGLE_BYTE_TOKENS: (string | null)[];
22
- export declare const TOKEN_MAP: {
23
- [token: string]: {
24
- dict?: number;
25
- index: number;
26
- };
27
- };
@@ -1,7 +0,0 @@
1
- /// <reference types="node" />
2
- import type { BinaryNode, BinaryNodeCodingOptions } from './types';
3
- export declare const decompressingIfRequired: (buffer: Buffer) => Buffer;
4
- export declare const decodeDecompressedBinaryNode: (buffer: Buffer, opts: Pick<BinaryNodeCodingOptions, 'DOUBLE_BYTE_TOKENS' | 'SINGLE_BYTE_TOKENS' | 'TAGS'>, indexRef?: {
5
- index: number;
6
- }) => BinaryNode;
7
- export declare const decodeBinaryNode: (buff: Buffer) => BinaryNode;
@@ -1,3 +0,0 @@
1
- /// <reference types="node" />
2
- import type { BinaryNode, BinaryNodeCodingOptions } from './types';
3
- export declare const encodeBinaryNode: ({ tag, attrs, content }: BinaryNode, opts?: Pick<BinaryNodeCodingOptions, 'TAGS' | 'TOKEN_MAP'>, buffer?: number[]) => Buffer;
@@ -1,15 +0,0 @@
1
- /// <reference types="node" />
2
- import { proto } from '../../WAProto';
3
- import { BinaryNode } from './types';
4
- export declare const getBinaryNodeChildren: (node: BinaryNode | undefined, childTag: string) => BinaryNode[];
5
- export declare const getAllBinaryNodeChildren: ({ content }: BinaryNode) => BinaryNode[];
6
- export declare const getBinaryNodeChild: (node: BinaryNode | undefined, childTag: string) => BinaryNode | undefined;
7
- export declare const getBinaryNodeChildBuffer: (node: BinaryNode | undefined, childTag: string) => Uint8Array | Buffer | undefined;
8
- export declare const getBinaryNodeChildString: (node: BinaryNode | undefined, childTag: string) => string | undefined;
9
- export declare const getBinaryNodeChildUInt: (node: BinaryNode, childTag: string, length: number) => number | undefined;
10
- export declare const assertNodeErrorFree: (node: BinaryNode) => void;
11
- export declare const reduceBinaryNodeToDictionary: (node: BinaryNode, tag: string) => {
12
- [_: string]: string;
13
- };
14
- export declare const getBinaryNodeMessages: ({ content }: BinaryNode) => proto.WebMessageInfo[];
15
- export declare function binaryNodeToString(node: BinaryNode | BinaryNode['content'], i?: number): any;
@@ -1,5 +0,0 @@
1
- export * from './encode';
2
- export * from './decode';
3
- export * from './generic-utils';
4
- export * from './jid-utils';
5
- export * from './types';
@@ -1,29 +0,0 @@
1
- export declare const S_WHATSAPP_NET = "@s.whatsapp.net";
2
- export declare const OFFICIAL_BIZ_JID = "16505361212@c.us";
3
- export declare const SERVER_JID = "server@c.us";
4
- export declare const PSA_WID = "0@c.us";
5
- export declare const STORIES_JID = "status@broadcast";
6
- export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call' | 'lid';
7
- export type JidWithDevice = {
8
- user: string;
9
- device?: number;
10
- };
11
- export type FullJid = JidWithDevice & {
12
- server: JidServer | string;
13
- domainType?: number;
14
- };
15
- export declare const jidEncode: (user: string | number | null, server: JidServer, device?: number, agent?: number) => string;
16
- export declare const jidDecode: (jid: string | undefined) => FullJid | undefined;
17
- /** is the jid a user */
18
- export declare const areJidsSameUser: (jid1: string | undefined, jid2: string | undefined) => boolean;
19
- /** is the jid a user */
20
- export declare const isJidUser: (jid: string | undefined) => boolean | undefined;
21
- /** is the jid a group */
22
- export declare const isLidUser: (jid: string | undefined) => boolean | undefined;
23
- /** is the jid a broadcast */
24
- export declare const isJidBroadcast: (jid: string | undefined) => boolean | undefined;
25
- /** is the jid a group */
26
- export declare const isJidGroup: (jid: string | undefined) => boolean | undefined;
27
- /** is the jid the status broadcast */
28
- export declare const isJidStatusBroadcast: (jid: string) => boolean;
29
- export declare const jidNormalizedUser: (jid: string | undefined) => string;
@@ -1,18 +0,0 @@
1
- import * as constants from './constants';
2
- /**
3
- * the binary node WA uses internally for communication
4
- *
5
- * this is manipulated soley as an object and it does not have any functions.
6
- * This is done for easy serialization, to prevent running into issues with prototypes &
7
- * to maintain functional code structure
8
- * */
9
- export type BinaryNode = {
10
- tag: string;
11
- attrs: {
12
- [key: string]: string;
13
- };
14
- content?: BinaryNode[] | string | Uint8Array;
15
- };
16
- export type BinaryNodeAttributes = BinaryNode['attrs'];
17
- export type BinaryNodeData = BinaryNode['content'];
18
- export type BinaryNodeCodingOptions = typeof constants;
package/lib/index.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import makeWASocket from './Socket';
2
- export * from '../WAProto';
3
- export * from './Utils';
4
- export * from './Types';
5
- export * from './Store';
6
- export * from './Defaults';
7
- export * from './WABinary';
8
- export type WASocket = ReturnType<typeof makeWASocket>;
9
- export { makeWASocket };
10
- export default makeWASocket;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes