@hansaka02/baileys 7.3.2 → 7.3.6

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 (210) hide show
  1. package/lib/Defaults/baileys-version.json +2 -2
  2. package/lib/Defaults/connection.js +51 -0
  3. package/lib/Defaults/constants.js +74 -0
  4. package/lib/Defaults/history.js +19 -0
  5. package/lib/Defaults/index.js +36 -142
  6. package/lib/Defaults/media.js +48 -0
  7. package/lib/Defaults/prefix.js +18 -0
  8. package/lib/Signal/Group/group-session-builder.js +10 -42
  9. package/lib/Signal/Group/group_cipher.js +9 -6
  10. package/lib/Signal/Group/index.js +39 -53
  11. package/lib/Signal/Group/keyhelper.js +8 -41
  12. package/lib/Signal/Group/sender-chain-key.js +5 -18
  13. package/lib/Signal/Group/sender-key-distribution-message.js +7 -7
  14. package/lib/Signal/Group/sender-key-message.js +12 -8
  15. package/lib/Signal/Group/sender-key-record.js +7 -16
  16. package/lib/Signal/Group/sender-key-state.js +15 -61
  17. package/lib/Signal/Group/sender-message-key.js +2 -2
  18. package/lib/Signal/libsignal.js +237 -177
  19. package/lib/Signal/lid-mapping.js +128 -71
  20. package/lib/Socket/Client/types.js +2 -2
  21. package/lib/Socket/Client/websocket.js +25 -16
  22. package/lib/Socket/business.js +46 -33
  23. package/lib/Socket/chats.js +286 -170
  24. package/lib/Socket/community.js +215 -77
  25. package/lib/Socket/groups.js +77 -61
  26. package/lib/Socket/index.js +4 -4
  27. package/lib/Socket/messages-recv.js +629 -457
  28. package/lib/Socket/messages-send.js +645 -656
  29. package/lib/Socket/mex.js +61 -0
  30. package/lib/Socket/newsletter.js +166 -245
  31. package/lib/Socket/socket.js +396 -170
  32. package/lib/Store/index.js +27 -11
  33. package/lib/Store/make-cache-manager-store.js +14 -15
  34. package/lib/Store/make-in-memory-store.js +28 -24
  35. package/lib/Types/LabelAssociation.js +2 -2
  36. package/lib/Types/Message.js +6 -6
  37. package/lib/Types/MexUpdates.js +5 -5
  38. package/lib/Types/Newsletter.js +32 -25
  39. package/lib/Types/State.js +4 -4
  40. package/lib/Types/index.js +28 -12
  41. package/lib/Utils/auth-utils.js +212 -375
  42. package/lib/Utils/baileys-event-stream.js +68 -69
  43. package/lib/Utils/browser-utils.js +43 -0
  44. package/lib/Utils/business.js +63 -53
  45. package/lib/Utils/chat-utils.js +241 -106
  46. package/lib/Utils/crypto.js +25 -45
  47. package/lib/Utils/decode-wa-message.js +361 -311
  48. package/lib/Utils/event-buffer.js +97 -42
  49. package/lib/Utils/generics.js +90 -207
  50. package/lib/Utils/history.js +29 -27
  51. package/lib/Utils/index.js +28 -14
  52. package/lib/Utils/link-preview.js +24 -62
  53. package/lib/Utils/logger.js +5 -5
  54. package/lib/Utils/lt-hash.js +29 -23
  55. package/lib/Utils/make-mutex.js +26 -28
  56. package/lib/Utils/message-retry-manager.js +55 -7
  57. package/lib/Utils/messages-media.js +434 -247
  58. package/lib/Utils/messages.js +963 -917
  59. package/lib/Utils/noise-handler.js +60 -20
  60. package/lib/Utils/pre-key-manager.js +126 -0
  61. package/lib/Utils/process-message.js +216 -141
  62. package/lib/Utils/signal.js +75 -37
  63. package/lib/Utils/use-multi-file-auth-state.js +18 -22
  64. package/lib/Utils/validate-connection.js +96 -66
  65. package/lib/WABinary/constants.js +1268 -1268
  66. package/lib/WABinary/decode.js +62 -34
  67. package/lib/WABinary/encode.js +57 -36
  68. package/lib/WABinary/generic-utils.js +4 -4
  69. package/lib/WABinary/index.js +27 -11
  70. package/lib/WABinary/jid-utils.js +58 -11
  71. package/lib/WAM/constants.js +19064 -11563
  72. package/lib/WAM/encode.js +71 -14
  73. package/lib/WAM/index.js +27 -11
  74. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +20 -16
  75. package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
  76. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +7 -4
  77. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -2
  78. package/lib/WAUSync/Protocols/USyncLIDProtocol.js +0 -2
  79. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -2
  80. package/lib/WAUSync/Protocols/index.js +27 -11
  81. package/lib/WAUSync/USyncQuery.js +51 -28
  82. package/lib/WAUSync/index.js +27 -11
  83. package/lib/index.js +60 -31
  84. package/package.json +12 -17
  85. package/WAProto/AICommon/AICommon.d.ts +0 -11702
  86. package/WAProto/Adv/Adv.d.ts +0 -643
  87. package/WAProto/BotMetadata/BotMetadata.d.ts +0 -5654
  88. package/WAProto/Cert/Cert.d.ts +0 -613
  89. package/WAProto/ChatLockSettings/ChatLockSettings.d.ts +0 -476
  90. package/WAProto/CompanionReg/CompanionReg.d.ts +0 -1361
  91. package/WAProto/DeviceCapabilities/DeviceCapabilities.d.ts +0 -577
  92. package/WAProto/E2E/E2E.d.ts +0 -41724
  93. package/WAProto/Ephemeral/Ephemeral.d.ts +0 -114
  94. package/WAProto/HistorySync/HistorySync.d.ts +0 -51700
  95. package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.d.ts +0 -229
  96. package/WAProto/MdStorageChatRowOpaqueData/MdStorageChatRowOpaqueData.d.ts +0 -583
  97. package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.d.ts +0 -42897
  98. package/WAProto/MmsRetry/MmsRetry.d.ts +0 -243
  99. package/WAProto/Protocol/Protocol.d.ts +0 -270
  100. package/WAProto/Reporting/Reporting.d.ts +0 -371
  101. package/WAProto/ServerSync/ServerSync.d.ts +0 -1285
  102. package/WAProto/SignalLocalStorageProtocol/SignalLocalStorageProtocol.d.ts +0 -1868
  103. package/WAProto/SignalWhisperTextProtocol/SignalWhisperTextProtocol.d.ts +0 -767
  104. package/WAProto/StatusAttributions/StatusAttributions.d.ts +0 -1027
  105. package/WAProto/SyncAction/SyncAction.d.ts +0 -11193
  106. package/WAProto/UserPassword/UserPassword.d.ts +0 -363
  107. package/WAProto/VnameCert/VnameCert.d.ts +0 -821
  108. package/WAProto/Wa6/Wa6.d.ts +0 -2128
  109. package/WAProto/Web/Web.d.ts +0 -46383
  110. package/WAProto/index.d.ts +0 -55
  111. package/lib/Defaults/index.d.ts +0 -77
  112. package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
  113. package/lib/Signal/Group/group-session-builder.d.ts +0 -17
  114. package/lib/Signal/Group/group_cipher.d.ts +0 -19
  115. package/lib/Signal/Group/index.d.ts +0 -11
  116. package/lib/Signal/Group/keyhelper.d.ts +0 -16
  117. package/lib/Signal/Group/sender-chain-key.d.ts +0 -14
  118. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -17
  119. package/lib/Signal/Group/sender-key-message.d.ts +0 -19
  120. package/lib/Signal/Group/sender-key-name.d.ts +0 -19
  121. package/lib/Signal/Group/sender-key-record.d.ts +0 -32
  122. package/lib/Signal/Group/sender-key-state.d.ts +0 -44
  123. package/lib/Signal/Group/sender-message-key.d.ts +0 -11
  124. package/lib/Signal/libsignal.d.ts +0 -8
  125. package/lib/Signal/lid-mapping.d.ts +0 -28
  126. package/lib/Socket/Client/index.d.ts +0 -2
  127. package/lib/Socket/Client/types.d.ts +0 -16
  128. package/lib/Socket/Client/websocket.d.ts +0 -13
  129. package/lib/Socket/business.d.ts +0 -187
  130. package/lib/Socket/chats.d.ts +0 -97
  131. package/lib/Socket/community.d.ts +0 -129
  132. package/lib/Socket/groups.d.ts +0 -129
  133. package/lib/Socket/index.d.ts +0 -191
  134. package/lib/Socket/messages-recv.d.ts +0 -174
  135. package/lib/Socket/messages-send.d.ts +0 -165
  136. package/lib/Socket/newsletter.d.ts +0 -145
  137. package/lib/Socket/socket.d.ts +0 -45
  138. package/lib/Socket/usync.d.ts +0 -37
  139. package/lib/Socket/usync.js +0 -83
  140. package/lib/Store/index.d.ts +0 -4
  141. package/lib/Store/make-cache-manager-store.d.ts +0 -14
  142. package/lib/Store/make-in-memory-store.d.ts +0 -123
  143. package/lib/Store/make-ordered-dictionary.d.ts +0 -12
  144. package/lib/Store/object-repository.d.ts +0 -10
  145. package/lib/Types/Auth.d.ts +0 -121
  146. package/lib/Types/Bussiness.d.ts +0 -28
  147. package/lib/Types/Call.d.ts +0 -14
  148. package/lib/Types/Chat.d.ts +0 -143
  149. package/lib/Types/Contact.d.ts +0 -23
  150. package/lib/Types/Events.d.ts +0 -226
  151. package/lib/Types/GroupMetadata.d.ts +0 -66
  152. package/lib/Types/Label.d.ts +0 -48
  153. package/lib/Types/LabelAssociation.d.ts +0 -35
  154. package/lib/Types/Message.d.ts +0 -484
  155. package/lib/Types/MexUpdates.d.ts +0 -9
  156. package/lib/Types/Newsletter.d.ts +0 -109
  157. package/lib/Types/Product.d.ts +0 -92
  158. package/lib/Types/Signal.d.ts +0 -98
  159. package/lib/Types/Socket.d.ts +0 -141
  160. package/lib/Types/State.d.ts +0 -41
  161. package/lib/Types/USync.d.ts +0 -26
  162. package/lib/Types/index.d.ts +0 -80
  163. package/lib/Utils/auth-utils.d.ts +0 -21
  164. package/lib/Utils/baileys-event-stream.d.ts +0 -18
  165. package/lib/Utils/business.d.ts +0 -29
  166. package/lib/Utils/chat-utils.d.ts +0 -82
  167. package/lib/Utils/crypto.d.ts +0 -56
  168. package/lib/Utils/decode-wa-message.d.ts +0 -53
  169. package/lib/Utils/event-buffer.d.ts +0 -39
  170. package/lib/Utils/generics.d.ts +0 -117
  171. package/lib/Utils/history.d.ts +0 -23
  172. package/lib/Utils/index.d.ts +0 -20
  173. package/lib/Utils/link-preview.d.ts +0 -23
  174. package/lib/Utils/logger.d.ts +0 -13
  175. package/lib/Utils/lt-hash.d.ts +0 -14
  176. package/lib/Utils/make-mutex.d.ts +0 -9
  177. package/lib/Utils/message-retry-manager.d.ts +0 -88
  178. package/lib/Utils/messages-media.d.ts +0 -135
  179. package/lib/Utils/messages.d.ts +0 -105
  180. package/lib/Utils/noise-handler.d.ts +0 -20
  181. package/lib/Utils/process-message.d.ts +0 -49
  182. package/lib/Utils/signal.d.ts +0 -42
  183. package/lib/Utils/use-mongo-file-auth-state.d.ts +0 -6
  184. package/lib/Utils/use-mongo-file-auth-state.js +0 -84
  185. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
  186. package/lib/Utils/use-single-file-auth-state.d.ts +0 -13
  187. package/lib/Utils/use-single-file-auth-state.js +0 -80
  188. package/lib/Utils/validate-connection.d.ts +0 -13
  189. package/lib/WABinary/constants.d.ts +0 -30
  190. package/lib/WABinary/decode.d.ts +0 -9
  191. package/lib/WABinary/encode.d.ts +0 -3
  192. package/lib/WABinary/generic-utils.d.ts +0 -28
  193. package/lib/WABinary/index.d.ts +0 -5
  194. package/lib/WABinary/jid-utils.d.ts +0 -58
  195. package/lib/WABinary/types.d.ts +0 -22
  196. package/lib/WAM/BinaryInfo.d.ts +0 -16
  197. package/lib/WAM/constants.d.ts +0 -47
  198. package/lib/WAM/encode.d.ts +0 -3
  199. package/lib/WAM/index.d.ts +0 -3
  200. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +0 -28
  201. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -10
  202. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -26
  203. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -14
  204. package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +0 -10
  205. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -14
  206. package/lib/WAUSync/Protocols/index.d.ts +0 -6
  207. package/lib/WAUSync/USyncQuery.d.ts +0 -31
  208. package/lib/WAUSync/USyncUser.d.ts +0 -12
  209. package/lib/WAUSync/index.d.ts +0 -3
  210. package/lib/index.d.ts +0 -13
@@ -1,39 +0,0 @@
1
- import { BaileysEventEmitter, BaileysEventMap } from '../Types'
2
- import { ILogger } from './logger'
3
-
4
- /**
5
- * A map that contains a list of all events that have been triggered
6
- *
7
- * Note, this can contain different type of events
8
- * this can make processing events extremely efficient -- since everything
9
- * can be done in a single transaction
10
- */
11
- type BaileysEventData = Partial<BaileysEventMap>
12
-
13
- type BaileysBufferableEventEmitter = BaileysEventEmitter & {
14
- /** Use to process events in a batch */
15
- process(handler: (events: BaileysEventData) => void | Promise<void>): (() => void)
16
- /**
17
- * starts buffering events, call flush() to release them
18
- * */
19
- buffer(): void
20
- /** buffers all events till the promise completes */
21
- createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>)
22
- /**
23
- * flushes all buffered events
24
- * @param force if true, will flush all data regardless of any pending buffers
25
- * @returns returns true if the flush actually happened, otherwise false
26
- */
27
- flush(force?: boolean): boolean
28
- /** is there an ongoing buffer */
29
- isBuffering(): boolean
30
- }
31
-
32
- /**
33
- * The event buffer logically consolidates different events into a single event
34
- * making the data processing more efficient.
35
- * @param ev the baileys event emitter
36
- */
37
- export declare const makeEventBuffer: (logger: ILogger) => BaileysBufferableEventEmitter
38
-
39
- export {}
@@ -1,117 +0,0 @@
1
- import { AxiosRequestConfig } from 'axios'
2
- import { ILogger } from './logger'
3
- import { proto } from '../../WAProto'
4
- import { BaileysEventEmitter, BaileysEventMap, BrowsersMap, ConnectionState, WACallUpdateType, WAVersion } from '../Types'
5
- import { BinaryNode } from '../WABinary'
6
-
7
- export declare const Browsers: BrowsersMap
8
-
9
- export declare const getPlatformId: (browser: string) => any
10
-
11
- export declare const BufferJSON: {
12
- replacer: (k: any, value: any) => any
13
- reviver: (_: any, value: any) => any
14
- }
15
-
16
- export declare const getKeyAuthor: (key: proto.IMessageKey | undefined | null, meId?: string) => string
17
-
18
- export declare const writeRandomPadMax16: (msg: Uint8Array) => Buffer
19
-
20
- export declare const unpadRandomMax16: (e: Uint8Array | Buffer) => Uint8Array
21
-
22
- export declare const encodeWAMessage: (message: proto.IMessage) => Buffer
23
-
24
- export declare const encodeNewsletterMessage: (message: proto.IMessage) => Uint8Array
25
-
26
- export declare const generateRegistrationId: () => number
27
-
28
- export declare const encodeBigEndian: (e: number, t?: number) => Uint8Array
29
-
30
- export declare const toNumber: (t: Long | number | null | undefined) => number
31
-
32
- /** unix timestamp of a date in seconds */
33
- export declare const unixTimestampSeconds: (date?: Date) => number
34
-
35
- export type DebouncedTimeout = ReturnType<typeof debouncedTimeout>
36
-
37
- export declare const debouncedTimeout: (intervalMs?: number, task?: () => void) => {
38
- start: (newIntervalMs?: number, newTask?: () => void) => void
39
- cancel: () => void
40
- setTask: (newTask: () => void) => () => void
41
- setInterval: (newInterval: number) => number
42
- }
43
-
44
- export declare const delay: (ms: number) => Promise<void>
45
-
46
- export declare const delayCancellable: (ms: number) => {
47
- delay: Promise<void>
48
- cancel: () => void
49
- }
50
-
51
- export declare function promiseTimeout<T>(ms: number | undefined, promise: (resolve: (v: T) => void, reject: (error: any) => void) => void): Promise<T>
52
-
53
- export declare const generateMessageID: (userId?: string) => string
54
-
55
- export declare const generateParticipantHashV2: (participants: string[]) => string
56
-
57
- export declare function bindWaitForEvent<T extends keyof BaileysEventMap>(ev: BaileysEventEmitter, event: T): (check: (u: BaileysEventMap[T]) => boolean | undefined, timeoutMs?: number) => Promise<void>
58
-
59
- export declare const bindWaitForConnectionUpdate: (ev: BaileysEventEmitter) => (check: (u: Partial<ConnectionState>) => boolean | undefined, timeoutMs?: number) => Promise<void>
60
-
61
- export declare const printQRIfNecessaryListener: (ev: BaileysEventEmitter, logger: ILogger) => void
62
- /**
63
- * utility that fetches latest baileys version from the master branch.
64
- * Use to ensure your WA connection is always on the latest version
65
- */
66
-
67
- export declare const fetchLatestBaileysVersion: (options?: AxiosRequestConfig<{}>) => Promise<{
68
- version: WAVersion
69
- isLatest: boolean
70
- error?: undefined
71
- } | {
72
- version: WAVersion
73
- isLatest: boolean
74
- error: any
75
- }>
76
-
77
- /** unique message tag prefix for MD clients */
78
- export declare const generateMdTagPrefix: () => string
79
- /**
80
- * Given a type of receipt, returns what the new status of the message should be
81
- * @param type type from receipt
82
- */
83
-
84
- export declare const getStatusFromReceiptType: (type: string | undefined) => proto.WebMessageInfo.Status
85
- /**
86
- * Stream errors generally provide a reason, map that to a baileys DisconnectReason
87
- * @param reason the string reason given, eg. "conflict"
88
- */
89
- export declare const getErrorCodeFromStreamError: (node: BinaryNode) => {
90
- reason: string
91
- statusCode: number
92
- }
93
-
94
- export declare const getCallStatusFromNode: ({ tag, attrs }: BinaryNode) => WACallUpdateType
95
-
96
- export declare const getCodeFromWSError: (error: Error) => number
97
- /**
98
- * Is the given platform WA business
99
- * @param platform AuthenticationCreds.platform
100
- */
101
- export declare const isWABusinessPlatform: (platform: string) => boolean
102
-
103
- export declare function trimUndefined(obj: {
104
- [_: string]: any
105
- }): {
106
- [_: string]: any
107
- }
108
-
109
- export declare function bytesToCrockford(buffer: Buffer): string
110
-
111
- export declare function toUnicodeEscape(text: string): string
112
-
113
- export declare function fromUnicodeEscape(escapedText: string): string
114
-
115
- export declare function asciiEncode(text: string): string
116
-
117
- export declare function asciiDecode(...codes: string[]): string[]
@@ -1,23 +0,0 @@
1
- import { AxiosRequestConfig } from 'axios'
2
- import { proto } from '../../WAProto'
3
- import { Chat, Contact } from '../Types'
4
-
5
- export declare const downloadHistory: (msg: proto.Message.IHistorySyncNotification, options: AxiosRequestConfig<{}>) => Promise<proto.HistorySync>
6
-
7
- export declare const processHistoryMessage: (item: proto.IHistorySync) => {
8
- chats: Chat[]
9
- contacts: Contact[]
10
- messages: proto.IWebMessageInfo[]
11
- syncType: proto.HistorySync.HistorySyncType
12
- progress: number | null | undefined
13
- }
14
-
15
- export declare const downloadAndProcessHistorySyncNotification: (msg: proto.Message.IHistorySyncNotification, options: AxiosRequestConfig<{}>) => Promise<{
16
- chats: Chat[]
17
- contacts: Contact[]
18
- messages: proto.IWebMessageInfo[]
19
- syncType: proto.HistorySync.HistorySyncType
20
- progress: number | null | undefined
21
- }>
22
-
23
- export declare const getHistoryMsg: (message: proto.IMessage) => proto.Message.IHistorySyncNotification | null | undefined
@@ -1,20 +0,0 @@
1
- export * from './generics'
2
- export * from './decode-wa-message'
3
- export * from './messages'
4
- export * from './messages-media'
5
- export * from './message-retry-manager'
6
- export * from './validate-connection'
7
- export * from './crypto'
8
- export * from './signal'
9
- export * from './noise-handler'
10
- export * from './history'
11
- export * from './chat-utils'
12
- export * from './lt-hash'
13
- export * from './auth-utils'
14
- export * from './baileys-event-stream'
15
- export * from './use-mongo-file-auth-state'
16
- export * from './use-single-file-auth-state'
17
- export * from './use-multi-file-auth-state'
18
- export * from './link-preview'
19
- export * from './event-buffer'
20
- export * from './process-message'
@@ -1,23 +0,0 @@
1
- import { AxiosRequestConfig } from 'axios'
2
- import { WAMediaUploadFunction, WAUrlInfo } from '../Types'
3
- import { ILogger } from './logger'
4
-
5
- export type URLGenerationOptions = {
6
- thumbnailWidth: number
7
- fetchOpts: {
8
- /** Timeout in ms */
9
- timeout: number
10
- proxyUrl?: string
11
- headers?: AxiosRequestConfig<{}>['headers']
12
- }
13
- uploadImage?: WAMediaUploadFunction
14
- logger?: ILogger
15
- }
16
-
17
- /**
18
- * Given a piece of text, checks for any URL present, generates link preview for the same and returns it
19
- * Return undefined if the fetch failed or no URL was found
20
- * @param text first matched URL in text
21
- * @returns the URL info required to generate link preview
22
- */
23
- export declare const getUrlInfo: (text: string, opts?: URLGenerationOptions) => Promise<WAUrlInfo | undefined>
@@ -1,13 +0,0 @@
1
- export interface ILogger {
2
- level: string
3
- child(obj: Record<string, unknown>): ILogger
4
- trace(obj: unknown, msg?: string): any
5
- debug(obj: unknown, msg?: string): any
6
- info(obj: unknown, msg?: string): any
7
- warn(obj: unknown, msg?: string): any
8
- error(obj: unknown, msg?: string): any
9
- }
10
-
11
- declare const _default: import("pino").Logger<never, boolean>
12
-
13
- export default _default
@@ -1,14 +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): Promise<ArrayBuffer>
8
- _subtractSingle(e: any, t: any): Promise<ArrayBuffer>
9
- performPointwiseWithOverflow(e: any, t: any, r: any): ArrayBuffer
10
- }
11
-
12
- export declare const LT_HASH_ANTI_TAMPERING: d
13
-
14
- export {}
@@ -1,9 +0,0 @@
1
- export declare const makeMutex: () => {
2
- mutex<T>(code: () => T | Promise<T>): Promise<T>
3
- }
4
-
5
- export type Mutex = ReturnType<typeof makeMutex>
6
-
7
- export declare const makeKeyedMutex: () => {
8
- mutex<T>(key: string, task: () => T | Promise<T>): Promise<T>
9
- }
@@ -1,88 +0,0 @@
1
- import { proto } from '../../WAProto'
2
- import { ILogger } from './logger'
3
-
4
- export interface RecentMessageKey {
5
- to: string
6
- id: string
7
- }
8
-
9
- export interface RecentMessage {
10
- message: proto.IMessage
11
- timestamp: number
12
- }
13
-
14
- export interface SessionRecreateHistory {
15
- [jid: string]: number
16
- }
17
-
18
- export interface RetryCounter {
19
- [messageId: string]: number
20
- }
21
-
22
- export interface PendingPhoneRequest {
23
- [messageId: string]: NodeJS.Timeout
24
- }
25
-
26
- export interface RetryStatistics {
27
- totalRetries: number
28
- successfulRetries: number
29
- failedRetries: number
30
- mediaRetries: number
31
- sessionRecreations: number
32
- phoneRequests: number
33
- }
34
-
35
- export declare class MessageRetryManager {
36
- private logger
37
- private recentMessagesMap
38
- private sessionRecreateHistory
39
- private retryCounters
40
- private pendingPhoneRequests
41
- private readonly maxMsgRetryCount
42
- private statistics
43
- constructor(logger: ILogger, maxMsgRetryCount: number)
44
- /**
45
- * Add a recent message to the cache for retry handling
46
- */
47
- addRecentMessage(to: string, id: string, message: proto.IMessage): void
48
- /**
49
- * Get a recent message from the cache
50
- */
51
- getRecentMessage(to: string, id: string): RecentMessage | undefined
52
- /**
53
- * Check if a session should be recreated based on retry count and history
54
- */
55
- shouldRecreateSession(jid: string, retryCount: number, hasSession: boolean): {
56
- reason: string
57
- recreate: boolean
58
- }
59
- /**
60
- * Increment retry counter for a message
61
- */
62
- incrementRetryCount(messageId: string): number
63
- /**
64
- * Get retry count for a message
65
- */
66
- getRetryCount(messageId: string): number
67
- /**
68
- * Check if message has exceeded maximum retry attempts
69
- */
70
- hasExceededMaxRetries(messageId: string): boolean
71
- /**
72
- * Mark retry as successful
73
- */
74
- markRetrySuccess(messageId: string): void
75
- /**
76
- * Mark retry as failed
77
- */
78
- markRetryFailed(messageId: string): void
79
- /**
80
- * Schedule a phone request with delay
81
- */
82
- schedulePhoneRequest(messageId: string, callback: () => void, delay?: number): void
83
- /**
84
- * Cancel pending phone request
85
- */
86
- cancelPendingPhoneRequest(messageId: string): void
87
- private keyToString
88
- }
@@ -1,135 +0,0 @@
1
- import { Boom } from '@hapi/boom'
2
- import { AxiosRequestConfig } from 'axios'
3
- import { Readable, Transform } from 'stream'
4
- import { URL } from 'url'
5
- import { proto } from '../../WAProto'
6
- import { DownloadableMessage, MediaConnInfo, MediaDecryptionKeyInfo, MediaType, SocketConfig, WAMediaUpload, WAMediaUploadFunction, WAMessageContent } from '../Types'
7
- import { BinaryNode } from '../WABinary'
8
- import { ILogger } from './logger'
9
-
10
- export declare const hkdfInfoKey: (type: MediaType) => string
11
-
12
- export declare const getRawMediaUploadData: (media: WAMediaUpload, mediaType: MediaType, logger?: ILogger) => Promise<{
13
- filePath: string
14
- fileSha256: Buffer<ArrayBufferLike>
15
- fileLength: number
16
- }>
17
-
18
- /** generates all the keys required to encrypt/decrypt & sign a media message */
19
- export declare function getMediaKeys(buffer: Uint8Array | string | null | undefined, mediaType: MediaType): MediaDecryptionKeyInfo
20
-
21
- export declare const extractImageThumb: (bufferOrFilePath: Readable | Buffer | string, width?: number) => Promise<{
22
- buffer: Buffer
23
- original: {
24
- width: number | undefined
25
- height: number | undefined
26
- }
27
- }>
28
-
29
- export declare const encodeBase64EncodedStringForUpload: (b64: string) => string
30
-
31
- export declare const generateProfilePicture: (mediaUpload: WAMediaUpload) => Promise<{
32
- img: Buffer
33
- }>
34
-
35
- /** gets the SHA256 of the given media message */
36
- export declare const mediaMessageSHA256B64: (message: WAMessageContent) => string | null | undefined
37
-
38
- export declare function getAudioDuration(buffer: Buffer | string | Readable): Promise<number | undefined>
39
-
40
- /**
41
- referenced from and modifying https://github.com/wppconnect-team/wa-js/blob/main/src/chat/functions/prepareAudioWaveform.ts
42
- */
43
- export declare function getAudioWaveform(buffer: Buffer | string | Readable, logger?: ILogger): Promise<Uint8Array | undefined>
44
-
45
- export declare const toReadable: (buffer: Buffer) => Readable
46
-
47
- export declare const toBuffer: (stream: Readable) => Promise<Buffer>
48
-
49
- export declare const getStream: (item: WAMediaUpload, opts?: AxiosRequestConfig) => Promise<{
50
- readonly stream: Readable
51
- readonly type: "buffer"
52
- } | {
53
- readonly stream: Readable
54
- readonly type: "readable"
55
- } | {
56
- readonly stream: Readable
57
- readonly type: "remote"
58
- } | {
59
- readonly stream: import("fs").ReadStream
60
- readonly type: "file"
61
- }>
62
-
63
- /** generates a thumbnail for a given media, if required */
64
- export declare function generateThumbnail(file: string, mediaType: 'video' | 'image', options: {
65
- logger?: Logger
66
- }): Promise<{
67
- thumbnail: string | undefined
68
- originalImageDimensions: {
69
- width: number
70
- height: number
71
- } | undefined
72
- }>
73
-
74
- export declare const getHttpStream: (url: string | URL, options?: AxiosRequestConfig & {
75
- isStream?: true
76
- }) => Promise<Readable>
77
-
78
- type EncryptedStreamOptions = {
79
- saveOriginalFileIfRequired?: boolean
80
- logger?: Logger
81
- opts?: AxiosRequestConfig
82
- }
83
-
84
- export declare const encryptedStream: (media: WAMediaUpload, mediaType: MediaType, { logger, saveOriginalFileIfRequired, opts }?: EncryptedStreamOptions) => Promise<{
85
- mediaKey: Buffer
86
- encWriteStream: Readable
87
- bodyPath: string | undefined
88
- mac: Buffer
89
- fileEncSha256: Buffer
90
- fileSha256: Buffer
91
- fileLength: number
92
- didSaveToTmpPath: boolean
93
- }>
94
-
95
- export type MediaDownloadOptions = {
96
- startByte?: number
97
- endByte?: number
98
- options?: AxiosRequestConfig<{}>
99
- }
100
-
101
- export declare const getUrlFromDirectPath: (directPath: string) => string
102
-
103
- export declare const downloadContentFromMessage: ({ mediaKey, directPath, url }: DownloadableMessage, type: MediaType, opts?: MediaDownloadOptions) => Promise<Transform>
104
-
105
- /**
106
- * Decrypts and downloads an AES256-CBC encrypted file given the keys.
107
- * Assumes the SHA256 of the plaintext is appended to the end of the ciphertext
108
- * */
109
- export declare const downloadEncryptedContent: (downloadUrl: string, { cipherKey, iv }: MediaDecryptionKeyInfo, { startByte, endByte, options }?: MediaDownloadOptions) => Promise<Transform>
110
-
111
- export declare function extensionForMediaMessage(message: WAMessageContent): string
112
-
113
- export declare const getWAUploadToServer: ({ customUploadHosts, fetchAgent, logger, options }: SocketConfig, refreshMediaConn: (force: boolean) => Promise<MediaConnInfo>) => WAMediaUploadFunction
114
- /**
115
- * Generate a binary node that will request the phone to re-upload the media & return the newly uploaded URL
116
- */
117
- export declare const encryptMediaRetryRequest: (key: proto.IMessageKey, mediaKey: Buffer | Uint8Array, meId: string) => BinaryNode
118
-
119
- export declare const decodeMediaRetryNode: (node: BinaryNode) => {
120
- key: proto.IMessageKey
121
- media?: {
122
- ciphertext: Uint8Array
123
- iv: Uint8Array
124
- } | undefined
125
- error?: Boom<any> | undefined
126
- }
127
-
128
- export declare const decryptMediaRetryData: ({ ciphertext, iv }: {
129
- ciphertext: Uint8Array
130
- iv: Uint8Array
131
- }, mediaKey: Uint8Array, msgId: string) => Promise<proto.MediaRetryNotification>
132
-
133
- export declare const getStatusCodeForMediaRetry: (code: number) => any
134
-
135
- export {}
@@ -1,105 +0,0 @@
1
- import { ILogger } from './logger'
2
- import { type Transform } from 'stream'
3
- import { proto } from '../../WAProto'
4
- import { AnyMediaMessageContent, AnyMessageContent, MediaGenerationOptions, MessageContentGenerationOptions, MessageGenerationOptions, MessageGenerationOptionsFromContent, MessageUserReceipt, WAMessage, WAMessageContent, WAProto } from '../Types'
5
- import { MediaDownloadOptions } from './messages-media'
6
-
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
-
14
- export declare const generateLinkPreviewIfRequired: (text: string, getUrlInfo: MessageGenerationOptions['getUrlInfo'], logger: MessageGenerationOptions['logger']) => Promise<import("../Types").WAUrlInfo | undefined>
15
-
16
- export declare const prepareWAMessageMedia: (message: AnyMediaMessageContent, options: MediaGenerationOptions) => Promise<proto.Message>
17
-
18
- export declare const prepareAlbumMessageContent: (jid: string, albums: WAProto.IMessage, options: MessageContentGenerationOptions) => Promise<proto.Message[]>
19
-
20
- export declare const prepareDisappearingMessageSettingContent: (ephemeralExpiration?: number) => proto.Message
21
-
22
- /**
23
- * Generate forwarded message content like WA does
24
- * @param message the message to forward
25
- * @param options.forceForward will show the message as forwarded even if it is from you
26
- */
27
- export declare const generateForwardMessageContent: (message: WAMessage, forceForward?: boolean) => proto.IMessage
28
-
29
- export declare const generateWAMessageContent: (message: AnyMessageContent, options: MessageContentGenerationOptions) => Promise<proto.Message>
30
-
31
- export declare const generateWAMessageFromContent: (jid: string, message: WAMessageContent, options: MessageGenerationOptionsFromContent) => proto.WebMessageInfo
32
-
33
- export declare const generateWAMessage: (jid: string, content: AnyMessageContent, options: MessageGenerationOptions) => Promise<proto.WebMessageInfo>
34
-
35
- /** Get the key to access the true type of content */
36
- export declare const getContentType: (content: WAProto.IMessage | undefined) => keyof proto.IMessage | undefined
37
-
38
- /**
39
- * Normalizes ephemeral, view once messages to regular message content
40
- * Eg. image messages in ephemeral messages, in view once messages etc.
41
- * @param content
42
- * @returns
43
- */
44
- export declare const normalizeMessageContent: (content: WAMessageContent | null | undefined) => WAMessageContent | undefined
45
-
46
- /**
47
- * Extract the true message content from a message
48
- * Eg. extracts the inner message from a disappearing message/view once message
49
- */
50
- export declare const extractMessageContent: (content: WAMessageContent | undefined | null) => WAMessageContent | undefined
51
-
52
- /**
53
- * Returns the device predicted by message ID
54
- */
55
- export declare const getDevice: (id: string) => "android" | "unknown" | "web" | "ios" | "desktop"
56
-
57
- /** Upserts a receipt in the message */
58
- export declare const updateMessageWithReceipt: (msg: Pick<WAMessage, 'userReceipt'>, receipt: MessageUserReceipt) => void
59
-
60
- /** Update the message with a new reaction */
61
- export declare const updateMessageWithReaction: (msg: Pick<WAMessage, 'reactions'>, reaction: proto.IReaction) => void
62
-
63
- /** Update the message with a new poll update */
64
- export declare const updateMessageWithPollUpdate: (msg: Pick<WAMessage, 'pollUpdates'>, update: proto.IPollUpdate) => void
65
-
66
- type VoteAggregation = {
67
- name: string
68
- voters: string[]
69
- }
70
-
71
- /**
72
- * Aggregates all poll updates in a poll.
73
- * @param msg the poll creation message
74
- * @param meId your jid
75
- * @returns A list of options & their voters
76
- */
77
- export declare function getAggregateVotesInPollMessage({ message, pollUpdates }: Pick<WAMessage, 'pollUpdates' | 'message'>, meId?: string): VoteAggregation[]
78
-
79
- /** Given a list of message keys, aggregates them by chat & sender. Useful for sending read receipts in bulk */
80
- export declare const aggregateMessageKeysNotFromMe: (keys: proto.IMessageKey[]) => {
81
- jid: string
82
- participant: string | undefined
83
- messageIds: string[]
84
- }[]
85
-
86
- type DownloadMediaMessageContext = {
87
- reuploadRequest: (msg: WAMessage) => Promise<WAMessage>
88
- logger: ILogger
89
- }
90
-
91
- /**
92
- * Downloads the given message. Throws an error if it's not a media message
93
- */
94
- export declare const downloadMediaMessage: <Type extends "stream" | "buffer">(message: WAMessage, type: Type, options: MediaDownloadOptions, ctx?: DownloadMediaMessageContext) => Promise<Type extends "buffer" ? Buffer : Transform>
95
-
96
- /** Checks whether the given message is a media message if it is returns the inner content */
97
- export declare const assertMediaContent: (content: proto.IMessage | null | undefined) => proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage
98
-
99
- /**
100
- * this is an experimental patch to make buttons work
101
- * Don't know how it works, but it does for now
102
- */
103
- export declare const patchMessageForMdIfRequired: (message: proto.IMessage) => proto.IMessage
104
-
105
- export {}
@@ -1,20 +0,0 @@
1
- import { proto } from '../../WAProto'
2
- import { KeyPair } from '../Types'
3
- import { BinaryNode } from '../WABinary'
4
- import { ILogger } from './logger'
5
-
6
- export declare const makeNoiseHandler: ({ keyPair: { private: privateKey, public: publicKey }, NOISE_HEADER, logger, routingInfo }: {
7
- keyPair: KeyPair
8
- NOISE_HEADER: Uint8Array
9
- logger: ILogger
10
- routingInfo?: Buffer | undefined
11
- }) => {
12
- encrypt: (plaintext: Uint8Array) => Buffer
13
- decrypt: (ciphertext: Uint8Array) => Buffer
14
- authenticate: (data: Uint8Array) => void
15
- mixIntoKey: (data: Uint8Array) => Promise<void>
16
- finishInit: () => Promise<void>
17
- processHandshake: ({ serverHello }: proto.HandshakeMessage, noiseKey: KeyPair) => Promise<Buffer>
18
- encodeFrame: (data: Buffer | Uint8Array) => Buffer
19
- decodeFrame: (newData: Buffer | Uint8Array, onFrame: (buff: Uint8Array | BinaryNode) => void) => Promise<void>
20
- }
@@ -1,49 +0,0 @@
1
- import { AxiosRequestConfig } from 'axios'
2
- import { proto } from '../../WAProto'
3
- import { AuthenticationCreds, BaileysEventEmitter, CacheStore, SignalKeyStoreWithTransaction, SocketConfig } from '../Types'
4
- import { ILogger } from './logger'
5
-
6
- type ProcessMessageContext = {
7
- shouldProcessHistoryMsg: boolean
8
- placeholderResendCache?: CacheStore
9
- creds: AuthenticationCreds
10
- keyStore: SignalKeyStoreWithTransaction
11
- ev: BaileysEventEmitter
12
- getMessage: SocketConfig['getMessage']
13
- logger?: ILogger
14
- options: AxiosRequestConfig<{}>
15
- }
16
-
17
- /** Cleans a received message to further processing */
18
- export declare const cleanMessage: (message: proto.IWebMessageInfo, meId: string) => void
19
-
20
- export declare const isRealMessage: (message: proto.IWebMessageInfo, meId: string) => boolean | undefined
21
-
22
- export declare const shouldIncrementChatUnread: (message: proto.IWebMessageInfo) => boolean
23
-
24
- /**
25
- * Get the ID of the chat from the given key.
26
- * Typically -- that'll be the remoteJid, but for broadcasts, it'll be the participant
27
- */
28
- export declare const getChatId: ({ remoteJid, participant, fromMe }: proto.IMessageKey) => string
29
-
30
- type PollContext = {
31
- /** normalised jid of the person that created the poll */
32
- pollCreatorJid: string
33
- /** ID of the poll creation message */
34
- pollMsgId: string
35
- /** poll creation message enc key */
36
- pollEncKey: Uint8Array
37
- /** jid of the person that voted */
38
- voterJid: string
39
- }
40
-
41
- /**
42
- * Decrypt a poll vote
43
- * @param vote encrypted vote
44
- * @param ctx additional info about the poll required for decryption
45
- * @returns list of SHA256 options
46
- */
47
- export declare function decryptPollVote({ encPayload, encIv }: proto.Message.IPollEncValue, { pollCreatorJid, pollMsgId, pollEncKey, voterJid, }: PollContext): proto.Message.PollVoteMessage
48
-
49
- export declare const processMessage: (message: proto.IWebMessageInfo, { shouldProcessHistoryMsg, placeholderResendCache, ev, creds, keyStore, logger, options, getMessage }: ProcessMessageContext) => Promise<void>