@vanzxy/baileys 2.0.0

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 (281) hide show
  1. package/NOTICE.md +111 -0
  2. package/README.md +830 -0
  3. package/WAProto/index.d.ts +9 -0
  4. package/WAProto/index.js +142036 -0
  5. package/engine-requirements.js +13 -0
  6. package/lib/Defaults/index.d.ts +152 -0
  7. package/lib/Defaults/index.js +179 -0
  8. package/lib/Framework/Bot.js +209 -0
  9. package/lib/Framework/Context.js +90 -0
  10. package/lib/Framework/MediaManager.js +152 -0
  11. package/lib/Framework/SessionManager.js +34 -0
  12. package/lib/Framework/StatsManager.js +120 -0
  13. package/lib/Framework/Store/SQLiteStore.js +74 -0
  14. package/lib/Framework/index.js +11 -0
  15. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  16. package/lib/Signal/Group/ciphertext-message.js +12 -0
  17. package/lib/Signal/Group/group-session-builder.d.ts +7 -0
  18. package/lib/Signal/Group/group-session-builder.js +30 -0
  19. package/lib/Signal/Group/group_cipher.d.ts +10 -0
  20. package/lib/Signal/Group/group_cipher.js +82 -0
  21. package/lib/Signal/Group/index.d.ts +11 -0
  22. package/lib/Signal/Group/index.js +12 -0
  23. package/lib/Signal/Group/keyhelper.d.ts +6 -0
  24. package/lib/Signal/Group/keyhelper.js +18 -0
  25. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  26. package/lib/Signal/Group/sender-chain-key.js +26 -0
  27. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  28. package/lib/Signal/Group/sender-key-distribution-message.js +63 -0
  29. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  30. package/lib/Signal/Group/sender-key-message.js +66 -0
  31. package/lib/Signal/Group/sender-key-name.d.ts +11 -0
  32. package/lib/Signal/Group/sender-key-name.js +48 -0
  33. package/lib/Signal/Group/sender-key-record.d.ts +12 -0
  34. package/lib/Signal/Group/sender-key-record.js +41 -0
  35. package/lib/Signal/Group/sender-key-state.d.ts +16 -0
  36. package/lib/Signal/Group/sender-key-state.js +84 -0
  37. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  38. package/lib/Signal/Group/sender-message-key.js +26 -0
  39. package/lib/Signal/libsignal.d.ts +54 -0
  40. package/lib/Signal/libsignal.js +431 -0
  41. package/lib/Signal/lid-mapping.d.ts +20 -0
  42. package/lib/Signal/lid-mapping.js +277 -0
  43. package/lib/Socket/Client/index.d.ts +2 -0
  44. package/lib/Socket/Client/index.js +3 -0
  45. package/lib/Socket/Client/types.d.ts +5 -0
  46. package/lib/Socket/Client/types.js +11 -0
  47. package/lib/Socket/Client/websocket.d.ts +12 -0
  48. package/lib/Socket/Client/websocket.js +54 -0
  49. package/lib/Socket/business.d.ts +395 -0
  50. package/lib/Socket/business.js +380 -0
  51. package/lib/Socket/chats.d.ts +136 -0
  52. package/lib/Socket/chats.js +1328 -0
  53. package/lib/Socket/communities.d.ts +561 -0
  54. package/lib/Socket/communities.js +434 -0
  55. package/lib/Socket/dugong.d.ts +117 -0
  56. package/lib/Socket/dugong.js +799 -0
  57. package/lib/Socket/groups.d.ts +285 -0
  58. package/lib/Socket/groups.js +355 -0
  59. package/lib/Socket/index.d.ts +531 -0
  60. package/lib/Socket/index.js +34 -0
  61. package/lib/Socket/messages-recv.d.ts +333 -0
  62. package/lib/Socket/messages-recv.js +1782 -0
  63. package/lib/Socket/messages-send.d.ts +329 -0
  64. package/lib/Socket/messages-send.js +1383 -0
  65. package/lib/Socket/mex.d.ts +1 -0
  66. package/lib/Socket/mex.js +42 -0
  67. package/lib/Socket/newsletter.d.ts +281 -0
  68. package/lib/Socket/newsletter.js +321 -0
  69. package/lib/Socket/socket.d.ts +60 -0
  70. package/lib/Socket/socket.js +1001 -0
  71. package/lib/Socket/username.js +153 -0
  72. package/lib/Store/index.d.ts +3 -0
  73. package/lib/Store/index.js +4 -0
  74. package/lib/Store/make-in-memory-store.d.ts +62 -0
  75. package/lib/Store/make-in-memory-store.js +429 -0
  76. package/lib/Store/make-ordered-dictionary.d.ts +12 -0
  77. package/lib/Store/make-ordered-dictionary.js +79 -0
  78. package/lib/Store/object-repository.d.ts +10 -0
  79. package/lib/Store/object-repository.js +24 -0
  80. package/lib/Types/Auth.d.ts +117 -0
  81. package/lib/Types/Auth.js +2 -0
  82. package/lib/Types/Bussines.d.ts +25 -0
  83. package/lib/Types/Bussines.js +2 -0
  84. package/lib/Types/Call.d.ts +15 -0
  85. package/lib/Types/Call.js +2 -0
  86. package/lib/Types/Chat.d.ts +124 -0
  87. package/lib/Types/Chat.js +8 -0
  88. package/lib/Types/Contact.d.ts +26 -0
  89. package/lib/Types/Contact.js +2 -0
  90. package/lib/Types/Events.d.ts +256 -0
  91. package/lib/Types/Events.js +2 -0
  92. package/lib/Types/GroupMetadata.d.ts +71 -0
  93. package/lib/Types/GroupMetadata.js +2 -0
  94. package/lib/Types/Label.d.ts +2 -0
  95. package/lib/Types/Label.js +25 -0
  96. package/lib/Types/LabelAssociation.d.ts +2 -0
  97. package/lib/Types/LabelAssociation.js +7 -0
  98. package/lib/Types/Message.d.ts +11 -0
  99. package/lib/Types/Message.js +18 -0
  100. package/lib/Types/Mex.d.ts +2 -0
  101. package/lib/Types/Mex.js +39 -0
  102. package/lib/Types/Product.d.ts +79 -0
  103. package/lib/Types/Product.js +2 -0
  104. package/lib/Types/RichType.d.ts +2 -0
  105. package/lib/Types/RichType.js +23 -0
  106. package/lib/Types/Signal.d.ts +87 -0
  107. package/lib/Types/Signal.js +2 -0
  108. package/lib/Types/Socket.d.ts +136 -0
  109. package/lib/Types/Socket.js +2 -0
  110. package/lib/Types/State.d.ts +5 -0
  111. package/lib/Types/State.js +56 -0
  112. package/lib/Types/USync.d.ts +26 -0
  113. package/lib/Types/USync.js +2 -0
  114. package/lib/Types/index.d.ts +66 -0
  115. package/lib/Types/index.js +26 -0
  116. package/lib/Utils/A2UI.js +277 -0
  117. package/lib/Utils/MessageBuilder.js +4405 -0
  118. package/lib/Utils/MessageBuilder_d.ts +411 -0
  119. package/lib/Utils/PersistentStore.js +592 -0
  120. package/lib/Utils/PersistentStore_d.ts +60 -0
  121. package/lib/Utils/anti-delete.d.ts +74 -0
  122. package/lib/Utils/anti-delete.js +222 -0
  123. package/lib/Utils/auth-utils.d.ts +57 -0
  124. package/lib/Utils/auth-utils.js +307 -0
  125. package/lib/Utils/auto-reply.d.ts +47 -0
  126. package/lib/Utils/auto-reply.js +158 -0
  127. package/lib/Utils/baileys-event-stream.d.ts +8 -0
  128. package/lib/Utils/baileys-event-stream.js +62 -0
  129. package/lib/Utils/browser-utils.d.ts +8 -0
  130. package/lib/Utils/browser-utils.js +28 -0
  131. package/lib/Utils/business.d.ts +49 -0
  132. package/lib/Utils/business.js +240 -0
  133. package/lib/Utils/button-helper-utils.js +314 -0
  134. package/lib/Utils/button-sender.js +824 -0
  135. package/lib/Utils/chat-control.d.ts +159 -0
  136. package/lib/Utils/chat-control.js +232 -0
  137. package/lib/Utils/chat-history-helpers.d.ts +21 -0
  138. package/lib/Utils/chat-history-helpers.js +71 -0
  139. package/lib/Utils/chat-utils.d.ts +407 -0
  140. package/lib/Utils/chat-utils.js +886 -0
  141. package/lib/Utils/companion-reg-client-utils.d.ts +4 -0
  142. package/lib/Utils/companion-reg-client-utils.js +40 -0
  143. package/lib/Utils/crypto.d.ts +41 -0
  144. package/lib/Utils/crypto.js +148 -0
  145. package/lib/Utils/decode-wa-message.d.ts +83 -0
  146. package/lib/Utils/decode-wa-message.js +317 -0
  147. package/lib/Utils/event-buffer.d.ts +12 -0
  148. package/lib/Utils/event-buffer.js +636 -0
  149. package/lib/Utils/generics.d.ts +69 -0
  150. package/lib/Utils/generics.js +439 -0
  151. package/lib/Utils/history.d.ts +90 -0
  152. package/lib/Utils/history.js +147 -0
  153. package/lib/Utils/identity-change-handler.d.ts +13 -0
  154. package/lib/Utils/identity-change-handler.js +50 -0
  155. package/lib/Utils/index.d.ts +39 -0
  156. package/lib/Utils/index.js +46 -0
  157. package/lib/Utils/link-preview.d.ts +12 -0
  158. package/lib/Utils/link-preview.js +85 -0
  159. package/lib/Utils/logger.d.ts +2 -0
  160. package/lib/Utils/logger.js +3 -0
  161. package/lib/Utils/lt-hash.d.ts +12 -0
  162. package/lib/Utils/lt-hash.js +27 -0
  163. package/lib/Utils/make-mutex.d.ts +6 -0
  164. package/lib/Utils/make-mutex.js +33 -0
  165. package/lib/Utils/media-messages.d.ts +18 -0
  166. package/lib/Utils/media-messages.js +71 -0
  167. package/lib/Utils/media-set.d.ts +13 -0
  168. package/lib/Utils/media-set.js +172 -0
  169. package/lib/Utils/message-kind.js +139 -0
  170. package/lib/Utils/message-retry-manager.d.ts +79 -0
  171. package/lib/Utils/message-retry-manager.js +265 -0
  172. package/lib/Utils/message-search.d.ts +44 -0
  173. package/lib/Utils/message-search.js +189 -0
  174. package/lib/Utils/messages-media.d.ts +135 -0
  175. package/lib/Utils/messages-media.js +869 -0
  176. package/lib/Utils/messages.d.ts +44 -0
  177. package/lib/Utils/messages.js +2155 -0
  178. package/lib/Utils/noise-handler.d.ts +20 -0
  179. package/lib/Utils/noise-handler.js +201 -0
  180. package/lib/Utils/offline-node-processor.d.ts +9 -0
  181. package/lib/Utils/offline-node-processor.js +40 -0
  182. package/lib/Utils/past-participants.d.ts +14 -0
  183. package/lib/Utils/past-participants.js +40 -0
  184. package/lib/Utils/pre-key-manager.d.ts +25 -0
  185. package/lib/Utils/pre-key-manager.js +106 -0
  186. package/lib/Utils/process-message.d.ts +82 -0
  187. package/lib/Utils/process-message.js +809 -0
  188. package/lib/Utils/reporting-utils.d.ts +12 -0
  189. package/lib/Utils/reporting-utils.js +258 -0
  190. package/lib/Utils/rich-message-utils.d.ts +48 -0
  191. package/lib/Utils/rich-message-utils.js +445 -0
  192. package/lib/Utils/scheduling.d.ts +42 -0
  193. package/lib/Utils/scheduling.js +140 -0
  194. package/lib/Utils/signal.d.ts +82 -0
  195. package/lib/Utils/signal.js +201 -0
  196. package/lib/Utils/stanza-ack.d.ts +16 -0
  197. package/lib/Utils/stanza-ack.js +38 -0
  198. package/lib/Utils/status.d.ts +50 -0
  199. package/lib/Utils/status.js +108 -0
  200. package/lib/Utils/stickerpack.d.ts +51 -0
  201. package/lib/Utils/stickerpack.js +275 -0
  202. package/lib/Utils/sync-action-utils.d.ts +2 -0
  203. package/lib/Utils/sync-action-utils.js +49 -0
  204. package/lib/Utils/tc-token-utils.d.ts +29 -0
  205. package/lib/Utils/tc-token-utils.js +163 -0
  206. package/lib/Utils/templates.d.ts +76 -0
  207. package/lib/Utils/templates.js +151 -0
  208. package/lib/Utils/use-cache-manager-auth-state.d.ts +13 -0
  209. package/lib/Utils/use-cache-manager-auth-state.js +82 -0
  210. package/lib/Utils/use-multi-file-auth-state.d.ts +10 -0
  211. package/lib/Utils/use-multi-file-auth-state.js +167 -0
  212. package/lib/Utils/use-single-file-auth-state.d.ts +10 -0
  213. package/lib/Utils/use-single-file-auth-state.js +114 -0
  214. package/lib/Utils/use-sqlite-auth-state.d.ts +11 -0
  215. package/lib/Utils/use-sqlite-auth-state.js +170 -0
  216. package/lib/Utils/validate-connection.d.ts +42 -0
  217. package/lib/Utils/validate-connection.js +199 -0
  218. package/lib/Utils/vcard.d.ts +58 -0
  219. package/lib/Utils/vcard.js +105 -0
  220. package/lib/VoIP/audio-feeder.d.ts +15 -0
  221. package/lib/VoIP/audio-feeder.js +132 -0
  222. package/lib/VoIP/index.js +277 -0
  223. package/lib/VoIP/relay-transport.d.ts +43 -0
  224. package/lib/VoIP/relay-transport.js +559 -0
  225. package/lib/VoIP/signaling.js +624 -0
  226. package/lib/VoIP/types.d.ts +69 -0
  227. package/lib/VoIP/types.js +17 -0
  228. package/lib/VoIP/wasm-engine.d.ts +103 -0
  229. package/lib/VoIP/wasm-engine.js +1214 -0
  230. package/lib/VoIP/worker-bootstrap.js +1042 -0
  231. package/lib/WABinary/constants.d.ts +61 -0
  232. package/lib/WABinary/constants.js +1467 -0
  233. package/lib/WABinary/decode.d.ts +9 -0
  234. package/lib/WABinary/decode.js +262 -0
  235. package/lib/WABinary/encode.d.ts +2 -0
  236. package/lib/WABinary/encode.js +220 -0
  237. package/lib/WABinary/generic-utils.d.ts +74 -0
  238. package/lib/WABinary/generic-utils.js +277 -0
  239. package/lib/WABinary/index.d.ts +5 -0
  240. package/lib/WABinary/index.js +6 -0
  241. package/lib/WABinary/jid-utils.d.ts +28 -0
  242. package/lib/WABinary/jid-utils.js +96 -0
  243. package/lib/WABinary/types.d.ts +19 -0
  244. package/lib/WABinary/types.js +2 -0
  245. package/lib/WAM/BinaryInfo.d.ts +7 -0
  246. package/lib/WAM/BinaryInfo.js +10 -0
  247. package/lib/WAM/constants.d.ts +34926 -0
  248. package/lib/WAM/constants.js +22853 -0
  249. package/lib/WAM/encode.d.ts +1 -0
  250. package/lib/WAM/encode.js +150 -0
  251. package/lib/WAM/index.d.ts +3 -0
  252. package/lib/WAM/index.js +4 -0
  253. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +36 -0
  254. package/lib/WAUSync/Protocols/USyncContactProtocol.js +52 -0
  255. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +29 -0
  256. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +63 -0
  257. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  258. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -0
  259. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  260. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +38 -0
  261. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +9 -0
  262. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +25 -0
  263. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +38 -0
  264. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
  265. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +14 -0
  266. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
  267. package/lib/WAUSync/Protocols/index.d.ts +7 -0
  268. package/lib/WAUSync/Protocols/index.js +8 -0
  269. package/lib/WAUSync/USyncQuery.d.ts +20 -0
  270. package/lib/WAUSync/USyncQuery.js +122 -0
  271. package/lib/WAUSync/USyncUser.d.ts +16 -0
  272. package/lib/WAUSync/USyncUser.js +31 -0
  273. package/lib/WAUSync/index.d.ts +3 -0
  274. package/lib/WAUSync/index.js +4 -0
  275. package/lib/assets/wasm/loader.js +5 -0
  276. package/lib/assets/wasm/whatsapp.wasm +0 -0
  277. package/lib/assets/wasm/worker-modules.js +273 -0
  278. package/lib/index.d.ts +12 -0
  279. package/lib/index.js +20 -0
  280. package/package.json +175 -0
  281. package/postinstall-banner.js +56 -0
@@ -0,0 +1,136 @@
1
+ import type { Agent } from 'https';
2
+ import type { URL } from 'url';
3
+ import { proto } from '../../WAProto/index.js';
4
+ import type { ILogger } from '../Utils/logger.js';
5
+ import type { AuthenticationState, LIDMapping, SignalAuthState, TransactionCapabilityOptions } from './Auth.js';
6
+ import type { GroupMetadata } from './GroupMetadata.js';
7
+ import { type MediaConnInfo, type WAMessageKey } from './Message.js';
8
+ import type { SignalRepositoryWithLIDStore } from './Signal.js';
9
+ export type WAVersion = [number, number, number];
10
+ export type WABrowserDescription = [string, string, string];
11
+ export type CacheStore = {
12
+ /** get a cached key and change the stats */
13
+ get<T>(key: string): Promise<T> | T | undefined;
14
+ /** set a key in the cache */
15
+ set<T>(key: string, value: T): Promise<void> | void | number | boolean;
16
+ /** delete a key from the cache */
17
+ del(key: string): void | Promise<void> | number | boolean;
18
+ /** flush all data */
19
+ flushAll(): void | Promise<void>;
20
+ close?: () => void;
21
+ };
22
+ export type PossiblyExtendedCacheStore = CacheStore & {
23
+ mget?: <T>(keys: string[]) => Promise<Record<string, T | undefined>>;
24
+ mset?: <T>(entries: {
25
+ key: string;
26
+ value: T;
27
+ }[]) => Promise<void> | void | number | boolean;
28
+ mdel?: (keys: string[]) => void | Promise<void> | number | boolean;
29
+ };
30
+ export type PatchedMessageWithRecipientJID = proto.IMessage & {
31
+ recipientJid?: string;
32
+ };
33
+ export type SocketConfig = {
34
+ /** the WS url to connect to WA */
35
+ waWebSocketUrl: string | URL;
36
+ /** Fails the connection if the socket times out in this interval */
37
+ connectTimeoutMs: number;
38
+ /** Default timeout for queries, undefined for no timeout */
39
+ defaultQueryTimeoutMs: number | undefined;
40
+ /** ping-pong interval for WS connection */
41
+ keepAliveIntervalMs: number;
42
+ /** should baileys use the mobile api instead of the multi device api
43
+ * @deprecated This feature has been removed
44
+ */
45
+ mobile?: boolean;
46
+ /** proxy agent */
47
+ agent?: Agent;
48
+ /** logger */
49
+ logger: ILogger;
50
+ /** version to connect with */
51
+ version: WAVersion;
52
+ /** override browser config */
53
+ browser: WABrowserDescription;
54
+ /** Initial pushName carried in the registration ClientPayload (used by mock servers for deterministic phone assignment). */
55
+ pushName?: string;
56
+ /** agent used for fetch requests -- uploading/downloading media */
57
+ fetchAgent?: Agent;
58
+ /** should the QR be printed in the terminal
59
+ * @deprecated This feature has been removed
60
+ */
61
+ printQRInTerminal?: boolean;
62
+ /** should events be emitted for actions done by this socket connection */
63
+ emitOwnEvents: boolean;
64
+ /** custom upload hosts to upload media to */
65
+ customUploadHosts: MediaConnInfo['hosts'];
66
+ /** time to wait between sending new retry requests */
67
+ retryRequestDelayMs: number;
68
+ /** max retry count */
69
+ maxMsgRetryCount: number;
70
+ /** time to wait for the generation of the next QR in ms */
71
+ qrTimeout?: number;
72
+ /** provide an auth state object to maintain the auth state */
73
+ auth: AuthenticationState;
74
+ /** manage history processing with this control; by default will sync up everything */
75
+ shouldSyncHistoryMessage: (msg: proto.Message.IHistorySyncNotification) => boolean;
76
+ /** transaction capability options for SignalKeyStore */
77
+ transactionOpts: TransactionCapabilityOptions;
78
+ /** marks the client as online whenever the socket successfully connects */
79
+ markOnlineOnConnect: boolean;
80
+ /** alphanumeric country code (USA -> US) for the number used */
81
+ countryCode: string;
82
+ /** provide a cache to store media, so does not have to be re-uploaded */
83
+ mediaCache?: CacheStore;
84
+ /**
85
+ * map to store the retry counts for failed messages;
86
+ * used to determine whether to retry a message or not */
87
+ msgRetryCounterCache?: CacheStore;
88
+ /** provide a cache to store a user's device list */
89
+ userDevicesCache?: PossiblyExtendedCacheStore;
90
+ /** cache to store call offers */
91
+ callOfferCache?: CacheStore;
92
+ /** cache to track placeholder resends */
93
+ placeholderResendCache?: CacheStore;
94
+ /** width for link preview images */
95
+ linkPreviewImageThumbnailWidth: number;
96
+ /** Should Baileys ask the phone for full history, will be received async */
97
+ syncFullHistory: boolean;
98
+ /** Should baileys fire init queries automatically, default true */
99
+ fireInitQueries: boolean;
100
+ /**
101
+ * generate a high quality link preview,
102
+ * entails uploading the jpegThumbnail to WA
103
+ * */
104
+ generateHighQualityLinkPreview: boolean;
105
+ /** Enable automatic session recreation for failed messages */
106
+ enableAutoSessionRecreation: boolean;
107
+ /** Enable recent message caching for retry handling */
108
+ enableRecentMessageCache: boolean;
109
+ /**
110
+ * Returns if a jid should be ignored,
111
+ * no event for that jid will be triggered.
112
+ * Messages from that jid will also not be decrypted
113
+ * */
114
+ shouldIgnoreJid: (jid: string) => boolean | undefined;
115
+ /**
116
+ * Optionally patch the message before sending out
117
+ * */
118
+ patchMessageBeforeSending: (msg: proto.IMessage, recipientJids?: string[]) => Promise<PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID> | PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID;
119
+ /** verify app state MACs */
120
+ appStateMacVerification: {
121
+ patch: boolean;
122
+ snapshot: boolean;
123
+ };
124
+ /** options for HTTP fetch requests */
125
+ options: RequestInit;
126
+ /**
127
+ * fetch a message from your store
128
+ * implement this so that messages failed to send
129
+ * (solves the "this message can take a while" issue) can be retried
130
+ * */
131
+ getMessage: (key: WAMessageKey) => Promise<proto.IMessage | undefined>;
132
+ /** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
133
+ cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>;
134
+ makeSignalRepository: (auth: SignalAuthState, logger: ILogger, pnToLIDFunc?: (jids: string[]) => Promise<LIDMapping[] | undefined>) => SignalRepositoryWithLIDStore;
135
+ };
136
+ //# sourceMappingURL=Socket.d.ts.map
@@ -0,0 +1,2 @@
1
+ import { proto } from '../../WAProto/index.js';
2
+ //# sourceMappingURL=Socket.js.map
@@ -0,0 +1,5 @@
1
+ export const SyncState: any;
2
+ export const ReachoutTimelockEnforcementType: any;
3
+ export const NewChatMessageCappingStatusType: any;
4
+ export const NewChatMessageCappingMVStatusType: any;
5
+ export const NewChatMessageCappingOTEStatusType: any;
@@ -0,0 +1,56 @@
1
+ import { Boom } from '@hapi/boom';
2
+ export var SyncState;
3
+ (function (SyncState) {
4
+ /** The socket is connecting, but we haven't received pending notifications yet. */
5
+ SyncState[SyncState["Connecting"] = 0] = "Connecting";
6
+ /** Pending notifications received. Buffering events until we decide whether to sync or not. */
7
+ SyncState[SyncState["AwaitingInitialSync"] = 1] = "AwaitingInitialSync";
8
+ /** The initial app state sync (history, etc.) is in progress. Buffering continues. */
9
+ SyncState[SyncState["Syncing"] = 2] = "Syncing";
10
+ /** Initial sync is complete, or was skipped. The socket is fully operational and events are processed in real-time. */
11
+ SyncState[SyncState["Online"] = 3] = "Online";
12
+ })(SyncState || (SyncState = {}));
13
+ export var ReachoutTimelockEnforcementType;
14
+ (function (ReachoutTimelockEnforcementType) {
15
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_ALCOHOL"] = "BIZ_COMMERCE_VIOLATION_ALCOHOL";
16
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_ADULT"] = "BIZ_COMMERCE_VIOLATION_ADULT";
17
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_ANIMALS"] = "BIZ_COMMERCE_VIOLATION_ANIMALS";
18
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_BODY_PARTS_FLUIDS"] = "BIZ_COMMERCE_VIOLATION_BODY_PARTS_FLUIDS";
19
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_DATING"] = "BIZ_COMMERCE_VIOLATION_DATING";
20
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_DIGITAL_SERVICES_PRODUCTS"] = "BIZ_COMMERCE_VIOLATION_DIGITAL_SERVICES_PRODUCTS";
21
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_DRUGS"] = "BIZ_COMMERCE_VIOLATION_DRUGS";
22
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_DRUGS_ONLY_OTC"] = "BIZ_COMMERCE_VIOLATION_DRUGS_ONLY_OTC";
23
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_GAMBLING"] = "BIZ_COMMERCE_VIOLATION_GAMBLING";
24
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_HEALTHCARE"] = "BIZ_COMMERCE_VIOLATION_HEALTHCARE";
25
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_REAL_FAKE_CURRENCY"] = "BIZ_COMMERCE_VIOLATION_REAL_FAKE_CURRENCY";
26
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_SUPPLEMENTS"] = "BIZ_COMMERCE_VIOLATION_SUPPLEMENTS";
27
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_TOBACCO"] = "BIZ_COMMERCE_VIOLATION_TOBACCO";
28
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_VIOLENT_CONTENT"] = "BIZ_COMMERCE_VIOLATION_VIOLENT_CONTENT";
29
+ ReachoutTimelockEnforcementType["BIZ_COMMERCE_VIOLATION_WEAPONS"] = "BIZ_COMMERCE_VIOLATION_WEAPONS";
30
+ ReachoutTimelockEnforcementType["BIZ_QUALITY"] = "BIZ_QUALITY";
31
+ /** This means there is no restriction */
32
+ ReachoutTimelockEnforcementType["DEFAULT"] = "DEFAULT";
33
+ ReachoutTimelockEnforcementType["WEB_COMPANION_ONLY"] = "WEB_COMPANION_ONLY";
34
+ })(ReachoutTimelockEnforcementType || (ReachoutTimelockEnforcementType = {}));
35
+ export var NewChatMessageCappingStatusType;
36
+ (function (NewChatMessageCappingStatusType) {
37
+ NewChatMessageCappingStatusType["NONE"] = "NONE";
38
+ NewChatMessageCappingStatusType["FIRST_WARNING"] = "FIRST_WARNING";
39
+ NewChatMessageCappingStatusType["SECOND_WARNING"] = "SECOND_WARNING";
40
+ NewChatMessageCappingStatusType["CAPPED"] = "CAPPED";
41
+ })(NewChatMessageCappingStatusType || (NewChatMessageCappingStatusType = {}));
42
+ export var NewChatMessageCappingMVStatusType;
43
+ (function (NewChatMessageCappingMVStatusType) {
44
+ NewChatMessageCappingMVStatusType["NOT_ELIGIBLE"] = "NOT_ELIGIBLE";
45
+ NewChatMessageCappingMVStatusType["NOT_ACTIVE"] = "NOT_ACTIVE";
46
+ NewChatMessageCappingMVStatusType["ACTIVE"] = "ACTIVE";
47
+ NewChatMessageCappingMVStatusType["ACTIVE_UPGRADE_AVAILABLE"] = "ACTIVE_UPGRADE_AVAILABLE";
48
+ })(NewChatMessageCappingMVStatusType || (NewChatMessageCappingMVStatusType = {}));
49
+ export var NewChatMessageCappingOTEStatusType;
50
+ (function (NewChatMessageCappingOTEStatusType) {
51
+ NewChatMessageCappingOTEStatusType["NOT_ELIGIBLE"] = "NOT_ELIGIBLE";
52
+ NewChatMessageCappingOTEStatusType["ELIGIBLE"] = "ELIGIBLE";
53
+ NewChatMessageCappingOTEStatusType["ACTIVE_IN_CURRENT_CYCLE"] = "ACTIVE_IN_CURRENT_CYCLE";
54
+ NewChatMessageCappingOTEStatusType["EXHAUSTED"] = "EXHAUSTED";
55
+ })(NewChatMessageCappingOTEStatusType || (NewChatMessageCappingOTEStatusType = {}));
56
+ //# sourceMappingURL=State.js.map
@@ -0,0 +1,26 @@
1
+ import type { BinaryNode } from '../WABinary/index.js';
2
+ import { USyncUser } from '../WAUSync/index.js';
3
+ /**
4
+ * Defines the interface for a USyncQuery protocol
5
+ */
6
+ export interface USyncQueryProtocol {
7
+ /**
8
+ * The name of the protocol
9
+ */
10
+ name: string;
11
+ /**
12
+ * Defines what goes inside the query part of a USyncQuery
13
+ */
14
+ getQueryElement: () => BinaryNode;
15
+ /**
16
+ * Defines what goes inside the user part of a USyncQuery
17
+ */
18
+ getUserElement: (user: USyncUser) => BinaryNode | null;
19
+ /**
20
+ * Parse the result of the query
21
+ * @param data Data from the result
22
+ * @returns Whatever the protocol is supposed to return
23
+ */
24
+ parser: (data: BinaryNode) => unknown;
25
+ }
26
+ //# sourceMappingURL=USync.d.ts.map
@@ -0,0 +1,2 @@
1
+ import { USyncUser } from '../WAUSync/index.js';
2
+ //# sourceMappingURL=USync.js.map
@@ -0,0 +1,66 @@
1
+ export * from './Auth.js';
2
+ export * from './GroupMetadata.js';
3
+ export * from './Chat.js';
4
+ export * from './Contact.js';
5
+ export * from './State.js';
6
+ export * from './Message.js';
7
+ export * from './Socket.js';
8
+ export * from './Events.js';
9
+ export * from './Product.js';
10
+ export * from './Call.js';
11
+ export * from './Signal.js';
12
+ export * from './Mex.js';
13
+ import type { AuthenticationState } from './Auth.js';
14
+ import type { SocketConfig } from './Socket.js';
15
+ export type UserFacingSocketConfig = Partial<SocketConfig> & {
16
+ auth: AuthenticationState;
17
+ };
18
+ export type BrowsersMap = {
19
+ ubuntu(browser: string): [string, string, string];
20
+ macOS(browser: string): [string, string, string];
21
+ baileys(browser: string): [string, string, string];
22
+ windows(browser: string): [string, string, string];
23
+ android(browser: string): [string, string, string];
24
+ appropriate(browser: string): [string, string, string];
25
+ };
26
+ export declare enum DisconnectReason {
27
+ connectionClosed = 428,
28
+ connectionLost = 408,
29
+ connectionReplaced = 440,
30
+ timedOut = 408,
31
+ loggedOut = 401,
32
+ badSession = 500,
33
+ restartRequired = 515,
34
+ multideviceMismatch = 411,
35
+ forbidden = 403,
36
+ unavailableService = 503
37
+ }
38
+ export type WAInitResponse = {
39
+ ref: string;
40
+ ttl: number;
41
+ status: 200;
42
+ };
43
+ export type WABusinessHoursConfig = {
44
+ day_of_week: string;
45
+ mode: string;
46
+ open_time?: number;
47
+ close_time?: number;
48
+ };
49
+ export type WABusinessProfile = {
50
+ description: string;
51
+ email: string | undefined;
52
+ business_hours: {
53
+ timezone?: string;
54
+ config?: WABusinessHoursConfig[];
55
+ business_config?: WABusinessHoursConfig[];
56
+ };
57
+ website: string[];
58
+ category?: string;
59
+ wid?: string;
60
+ address?: string;
61
+ };
62
+ export type CurveKeyPair = {
63
+ private: Uint8Array;
64
+ public: Uint8Array;
65
+ };
66
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,26 @@
1
+ export * from './Auth.js';
2
+ export * from './GroupMetadata.js';
3
+ export * from './Chat.js';
4
+ export * from './Contact.js';
5
+ export * from './State.js';
6
+ export * from './Message.js';
7
+ export * from './Socket.js';
8
+ export * from './Events.js';
9
+ export * from './Product.js';
10
+ export * from './Call.js';
11
+ export * from './Signal.js';
12
+ export * from './Mex.js';
13
+ export var DisconnectReason;
14
+ (function (DisconnectReason) {
15
+ DisconnectReason[DisconnectReason["connectionClosed"] = 428] = "connectionClosed";
16
+ DisconnectReason[DisconnectReason["connectionLost"] = 408] = "connectionLost";
17
+ DisconnectReason[DisconnectReason["connectionReplaced"] = 440] = "connectionReplaced";
18
+ DisconnectReason[DisconnectReason["timedOut"] = 408] = "timedOut";
19
+ DisconnectReason[DisconnectReason["loggedOut"] = 401] = "loggedOut";
20
+ DisconnectReason[DisconnectReason["badSession"] = 500] = "badSession";
21
+ DisconnectReason[DisconnectReason["restartRequired"] = 515] = "restartRequired";
22
+ DisconnectReason[DisconnectReason["multideviceMismatch"] = 411] = "multideviceMismatch";
23
+ DisconnectReason[DisconnectReason["forbidden"] = 403] = "forbidden";
24
+ DisconnectReason[DisconnectReason["unavailableService"] = 503] = "unavailableService";
25
+ })(DisconnectReason || (DisconnectReason = {}));
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,277 @@
1
+ /**
2
+ * lib/Utils/A2UI.js — A2UI (Bloks) widget builder + sender
3
+ *
4
+ * Part of @vanzxy/baileys. Builds the flat `components` array A2UI/Bloks
5
+ * expects (id-referencing tree: Column/Row hold `children`, Card/Button hold
6
+ * `child`, Modal holds `trigger`/`content`) and sends it as an
7
+ * `interactiveMessage.bloksWidget` via the same `getBizBinaryNode()` path
8
+ * Button/ButtonV2 use, so the wire-level <biz>/<native_flow> node always
9
+ * matches the actual button names sent — no more hand-rolled duplicate of
10
+ * that logic living outside the library.
11
+ *
12
+ * See MessageBuilder.js's `Button.setBloksWidget()` for the declarative
13
+ * (nested-tree) alternative to this imperative (id-returning-factory) API;
14
+ * both produce the same wire format and can be mixed freely.
15
+ */
16
+ "use strict";
17
+
18
+ import crypto from "crypto";
19
+ import { generateWAMessageFromContent, prepareWAMessageMedia } from "./messages.js";
20
+ import { getBizBinaryNode } from "../WABinary/index.js";
21
+
22
+ class A2UI {
23
+ constructor({ catalogId = "https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json", version = "v0.9" } = {}) {
24
+ this._version = version;
25
+ this._catalogId = catalogId;
26
+ this._components = new Map();
27
+ this._counter = 0;
28
+ this._rootChildren = [];
29
+ }
30
+ #nextId(prefix) {
31
+ return `${prefix}_${(this._counter++).toString(36)}`;
32
+ }
33
+ #reg(id, component, extra = {}) {
34
+ id ??= this.#nextId(component.toLowerCase());
35
+ if (id === "root") throw new Error(`Component id "root" is reserved for the implicit root wrapper`);
36
+ if (this._components.has(id)) throw new Error(`Component id "${id}" already used`);
37
+ this._components.set(id, { id, component, ...extra });
38
+ return id;
39
+ }
40
+ text(text, { id, variant = "body" } = {}) {
41
+ return this.#reg(id, "Text", { text, variant });
42
+ }
43
+ image(url, { id, variant, fit = "cover" } = {}) {
44
+ return this.#reg(id, "Image", { url, ...(variant ? { variant } : {}), fit });
45
+ }
46
+ video(url, { id } = {}) {
47
+ return this.#reg(id, "Video", { url });
48
+ }
49
+ checkbox(label, { id, value = false } = {}) {
50
+ return this.#reg(id, "CheckBox", { label, value });
51
+ }
52
+ textField(label, { id, variant = "text" } = {}) {
53
+ return this.#reg(id, "TextField", { label, variant });
54
+ }
55
+ button(childId, { id, variant = "primary", action } = {}) {
56
+ if (!childId) throw new TypeError("button(childId) requires the id of a child component (e.g. from .text())");
57
+ return this.#reg(id, "Button", { child: childId, variant, ...(action ? { action } : {}) });
58
+ }
59
+ card(childId, { id } = {}) {
60
+ return this.#reg(id, "Card", { child: childId });
61
+ }
62
+ // trigger: id of the component that opens the modal (e.g. a Button); content: id of the
63
+ // component shown inside it. Both are ids of already-registered SIBLING components, not
64
+ // nested children — that's how the wire format expects Modal to reference them.
65
+ modal(triggerId, contentId, { id } = {}) {
66
+ if (!triggerId) throw new TypeError("modal(triggerId, contentId) requires the id of the trigger component");
67
+ if (!contentId) throw new TypeError("modal(triggerId, contentId) requires the id of the content component");
68
+ return this.#reg(id, "Modal", { trigger: triggerId, content: contentId });
69
+ }
70
+ // Escape hatch for any catalog component without a dedicated method yet (Divider, Slider,
71
+ // Switch, List, etc). props is merged as-is into the registered node.
72
+ raw(component, props = {}, { id } = {}) {
73
+ if (typeof component !== "string" || !component) throw new TypeError("raw(component, props) requires a non-empty component type string");
74
+ return this.#reg(id, component, props);
75
+ }
76
+ column(children = [], { id } = {}) {
77
+ if (!children.length) throw new TypeError("column(children) requires at least one child id");
78
+ return this.#reg(id, "Column", { children });
79
+ }
80
+ row(children = [], { id } = {}) {
81
+ if (!children.length) throw new TypeError("row(children) requires at least one child id");
82
+ return this.#reg(id, "Row", { children });
83
+ }
84
+ divider({ id } = {}) {
85
+ return this.#reg(id, "Divider", {});
86
+ }
87
+ choicePicker(label, options, { id, variant = "mutuallyExclusive", value, displayStyle = "checkbox", filterable = false } = {}) {
88
+ if (!Array.isArray(options) || !options.length) {
89
+ throw new TypeError("choicePicker(label, options) requires a non-empty options array of {label, value}");
90
+ }
91
+ return this.#reg(id, "ChoicePicker", {
92
+ label,
93
+ variant,
94
+ ...(value !== undefined ? { value } : {}),
95
+ options,
96
+ displayStyle,
97
+ filterable
98
+ });
99
+ }
100
+ root(children) {
101
+ if (!Array.isArray(children) || !children.length) {
102
+ throw new TypeError("root(children) requires a non-empty array of top-level component ids");
103
+ }
104
+ this._rootChildren = children;
105
+ return this;
106
+ }
107
+ // Vanz@Add 29-08-26 --- Product/list carousel card. This is a DIFFERENT wire
108
+ // payload shape from the Column/Row component-tree the rest of this class
109
+ // builds (type: 'list_card', flat items array) — not a catalog component, so
110
+ // it doesn't go through #reg()/root(). Call this instead of root()+build();
111
+ // build() returns the list_card payload directly when this was set.
112
+ listCard({ title, items, fallbackText, uuid = crypto.randomUUID() } = {}) {
113
+ if (!title) throw new TypeError("listCard requires a title");
114
+ if (!Array.isArray(items) || !items.length) {
115
+ throw new TypeError("listCard requires a non-empty items array");
116
+ }
117
+ this._listCardPayload = {
118
+ uuid,
119
+ data: JSON.stringify({
120
+ type: "list_card",
121
+ title,
122
+ fallback_text: fallbackText ?? "",
123
+ items: items.map((it) => ({
124
+ asset_id: it.assetId ?? crypto.randomUUID().replace(/-/g, "").slice(0, 17),
125
+ asset_type: it.assetType ?? "PRODUCT_ITEM",
126
+ title: it.title,
127
+ trailing_label: it.price ?? it.trailingLabel ?? "",
128
+ trailing_emphasis: it.emphasis ?? "strong"
129
+ }))
130
+ }),
131
+ type: "im_a2ui",
132
+ fallback: fallbackText ?? ""
133
+ };
134
+ return this;
135
+ }
136
+ // Vanz@Add 30-08-26 --- send(): terminal method so A2UI can be used as a one-liner like
137
+ // the other builders (Button/ButtonV2/AIRich `.send()`), instead of always needing the
138
+ // separate `sendA2UIWidget()` call. Thin wrapper only — root([...ids])/listCard() must
139
+ // still be called first, same as before build(); this doesn't change the id-returning
140
+ // factory API (child methods still return ids, not `this`, since sibling nodes need to
141
+ // reference each other by id when wiring children/trigger/content).
142
+ async send(client, jid, opts = {}) {
143
+ return sendA2UIWidget(client, jid, { ...opts, a2ui: this });
144
+ }
145
+ // Vanz@Add 30-08-26 --- validates that every structural id-reference (child/children on
146
+ // Button/Card/Column/Row, trigger/content on Modal) points at a component that was
147
+ // actually registered. Without this, a typo'd id just gets written into the wire payload
148
+ // as-is and the failure only surfaces as a broken/blank widget on the WA client, with no
149
+ // error on this end. Only covers the dedicated methods' known reference keys — raw()'s
150
+ // free-form props aren't inspected, since there's no way to know which of those are id
151
+ // references vs plain data.
152
+ #validateRefs(components) {
153
+ const validIds = new Set(components.map((c) => c.id));
154
+ for (const c of components) {
155
+ for (const key of ["child", "trigger", "content"]) {
156
+ if (c[key] !== undefined && !validIds.has(c[key])) {
157
+ throw new Error(`A2UI: component "${c.id}" (${c.component}) references unknown id "${c[key]}" via "${key}"`);
158
+ }
159
+ }
160
+ if (Array.isArray(c.children)) {
161
+ for (const childId of c.children) {
162
+ if (!validIds.has(childId)) {
163
+ throw new Error(`A2UI: component "${c.id}" (${c.component}) references unknown id "${childId}" in "children"`);
164
+ }
165
+ }
166
+ }
167
+ }
168
+ }
169
+ build({ uuid = crypto.randomUUID(), surfaceId, type = "im_a2ui", wrapped = true } = {}) {
170
+ if (this._listCardPayload) return this._listCardPayload;
171
+ if (!this._rootChildren.length) throw new Error("Call root([...ids]) before build()");
172
+ const root = { id: "root", component: "Column", children: this._rootChildren };
173
+ const components = [root, ...this._components.values()];
174
+ this.#validateRefs(components);
175
+ const data = wrapped
176
+ ? {
177
+ version: this._version,
178
+ createSurface: {
179
+ surfaceId: surfaceId ?? `starcore-widget=${uuid}`,
180
+ catalogId: this._catalogId,
181
+ components
182
+ }
183
+ }
184
+ : { components };
185
+ return {
186
+ uuid,
187
+ data: JSON.stringify(data),
188
+ type
189
+ };
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Build + send an A2UI/Bloks widget as an interactiveMessage.
195
+ * @param {import('../../WAProto/index.js').WASocket} client Active Baileys socket.
196
+ * @param {string} jid Destination chat/group jid.
197
+ */
198
+ async function sendA2UIWidget(client, jid, {
199
+ a2ui,
200
+ bodyText = "",
201
+ footer = "",
202
+ buttons = [],
203
+ contextInfo = {},
204
+ expiration,
205
+ quoted,
206
+ type = "im_a2ui",
207
+ wrapped = true,
208
+ singleScreen = false,
209
+ // Vanz@Add 30-08-26 --- optional header media, mirroring Button/ButtonV2's toCard()
210
+ // pattern (prepareWAMessageMedia + client.waUploadToServer). { title, subtitle, image
211
+ // | video | document: path/buffer/{url} } — media is mutually exclusive, image wins if
212
+ // more than one is passed. Falls back to a title/subtitle-only header (no attachment)
213
+ // when no media is given, same shape as before this change.
214
+ header
215
+ } = {}) {
216
+ if (!client) throw new Error("Socket is required");
217
+ if (!(a2ui instanceof A2UI)) throw new TypeError("a2ui must be an A2UI instance");
218
+
219
+ const nativeFlowMessage = buttons && buttons.length
220
+ ? {
221
+ buttons: buttons.map((b) => ({
222
+ name: b.name ?? "cta_url",
223
+ buttonParamsJson: typeof b.params === "string" ? b.params : JSON.stringify(b.params ?? {}),
224
+ })),
225
+ messageParamsJson: "{}",
226
+ messageVersion: 1
227
+ }
228
+ : { messageParamsJson: "" };
229
+
230
+ const headerMediaData = header?.image
231
+ ? { image: header.image }
232
+ : header?.video
233
+ ? { video: header.video }
234
+ : header?.document
235
+ ? { document: header.document }
236
+ : null;
237
+
238
+ const headerBlock = {
239
+ ...(header?.title !== undefined ? { title: header.title } : {}),
240
+ ...(header?.subtitle !== undefined ? { subtitle: header.subtitle } : {}),
241
+ hasMediaAttachment: !!headerMediaData,
242
+ ...(headerMediaData
243
+ ? await prepareWAMessageMedia(headerMediaData, { upload: client.waUploadToServer }).catch((e) => {
244
+ if (String(e).includes("Invalid media type")) return headerMediaData;
245
+ throw e;
246
+ })
247
+ : {})
248
+ };
249
+
250
+ const interactiveMessage = singleScreen
251
+ ? {
252
+ nativeFlowMessage,
253
+ bloksWidget: a2ui.build({ type, wrapped }),
254
+ ...(expiration || Object.keys(contextInfo).length ? { contextInfo: { ...(expiration ? { expiration } : {}), ...contextInfo } } : {})
255
+ }
256
+ : {
257
+ header: headerBlock,
258
+ body: { text: bodyText },
259
+ ...(footer ? { footer: { text: footer } } : {}),
260
+ nativeFlowMessage,
261
+ bloksWidget: a2ui.build({ type, wrapped }),
262
+ ...(expiration || Object.keys(contextInfo).length ? { contextInfo: { ...(expiration ? { expiration } : {}), ...contextInfo } } : {})
263
+ };
264
+
265
+ const msg = generateWAMessageFromContent(jid, {
266
+ messageContextInfo: { messageSecret: crypto.randomBytes(32) },
267
+ interactiveMessage
268
+ }, { quoted });
269
+
270
+ await client.relayMessage(msg.key.remoteJid, msg.message, {
271
+ messageId: msg.key.id,
272
+ additionalNodes: [getBizBinaryNode(msg.message)]
273
+ });
274
+ return msg;
275
+ }
276
+
277
+ export { A2UI, sendA2UIWidget };