@deffa5556/bail 1.0.6 → 1.0.9

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 (316) hide show
  1. package/cjs/WAProto/index.cjs +106053 -0
  2. package/cjs/deffa/config.cjs +14 -0
  3. package/cjs/deffa/plugins/ai/deepseekr1.cjs +35 -0
  4. package/cjs/deffa/plugins/ai/gita.cjs +26 -0
  5. package/cjs/deffa/plugins/ai/glm47flash.cjs +35 -0
  6. package/cjs/deffa/plugins/ai/gptoss120b.cjs +35 -0
  7. package/cjs/deffa/plugins/ai/qwq32b.cjs +35 -0
  8. package/cjs/deffa/plugins/berita/antara.cjs +25 -0
  9. package/cjs/deffa/plugins/berita/cnbcindonesia.cjs +25 -0
  10. package/cjs/deffa/plugins/berita/cnn.cjs +25 -0
  11. package/cjs/deffa/plugins/berita/kompas.cjs +25 -0
  12. package/cjs/deffa/plugins/berita/liputan6.cjs +25 -0
  13. package/cjs/deffa/plugins/berita/merdeka.cjs +25 -0
  14. package/cjs/deffa/plugins/berita/sindonews.cjs +25 -0
  15. package/cjs/deffa/plugins/berita/tribunnews.cjs +25 -0
  16. package/cjs/deffa/plugins/downloader/douyin.cjs +30 -0
  17. package/cjs/deffa/plugins/downloader/facebook.cjs +30 -0
  18. package/cjs/deffa/plugins/downloader/github.cjs +35 -0
  19. package/cjs/deffa/plugins/downloader/lahelu.cjs +30 -0
  20. package/cjs/deffa/plugins/downloader/snackvideo.cjs +30 -0
  21. package/cjs/deffa/plugins/downloader/soundcloud.cjs +30 -0
  22. package/cjs/deffa/plugins/downloader/tiktok.cjs +30 -0
  23. package/cjs/deffa/plugins/downloader/tiktokhd.cjs +30 -0
  24. package/cjs/deffa/plugins/downloader/twitter.cjs +30 -0
  25. package/cjs/deffa/plugins/downloader/ummy.cjs +36 -0
  26. package/cjs/deffa/plugins/index.cjs +213 -0
  27. package/cjs/deffa/plugins/info/bmkg.cjs +34 -0
  28. package/cjs/deffa/plugins/info/cuaca.cjs +31 -0
  29. package/cjs/deffa/plugins/info/jadwaltv.cjs +29 -0
  30. package/cjs/deffa/plugins/maker/brat.cjs +45 -0
  31. package/cjs/deffa/plugins/maker/bratvid.cjs +52 -0
  32. package/cjs/deffa/plugins/search/8font.cjs +28 -0
  33. package/cjs/deffa/plugins/search/applemusic.cjs +28 -0
  34. package/cjs/deffa/plugins/search/bimg.cjs +30 -0
  35. package/cjs/deffa/plugins/search/brave.cjs +34 -0
  36. package/cjs/deffa/plugins/search/duckduckgo.cjs +28 -0
  37. package/cjs/deffa/plugins/search/lahelu.cjs +28 -0
  38. package/cjs/deffa/plugins/search/mangatoon.cjs +28 -0
  39. package/cjs/deffa/plugins/search/mcpedl.cjs +28 -0
  40. package/cjs/deffa/plugins/search/myinstants.cjs +28 -0
  41. package/cjs/deffa/plugins/search/otakotaku.cjs +28 -0
  42. package/cjs/deffa/plugins/search/pinterest.cjs +30 -0
  43. package/cjs/deffa/plugins/search/resep.cjs +28 -0
  44. package/cjs/deffa/plugins/search/seegore.cjs +30 -0
  45. package/cjs/deffa/plugins/search/soundcloud.cjs +28 -0
  46. package/cjs/deffa/plugins/search/youtube.cjs +28 -0
  47. package/cjs/deffa/plugins/stalk/github.cjs +38 -0
  48. package/cjs/deffa/plugins/stalk/pinterest.cjs +37 -0
  49. package/cjs/deffa/plugins/stalk/threads.cjs +34 -0
  50. package/cjs/deffa/plugins/stalk/tiktok.cjs +37 -0
  51. package/cjs/deffa/plugins/stalk/twitter.cjs +37 -0
  52. package/cjs/deffa/plugins/stalk/youtube.cjs +37 -0
  53. package/cjs/lib/Defaults/index.cjs +158 -0
  54. package/cjs/lib/Discord/Client.cjs +263 -0
  55. package/cjs/lib/Discord/Constants.cjs +1842 -0
  56. package/cjs/lib/Discord/connect-dc.cjs +11 -0
  57. package/cjs/lib/Discord/esm-bridge.cjs +136 -0
  58. package/cjs/lib/Discord/gateway/Dispatcher.cjs +93 -0
  59. package/cjs/lib/Discord/gateway/Shard.cjs +695 -0
  60. package/cjs/lib/Discord/gateway/ShardManager.cjs +344 -0
  61. package/cjs/lib/Discord/gateway/compression/base.cjs +13 -0
  62. package/cjs/lib/Discord/gateway/compression/config.cjs +47 -0
  63. package/cjs/lib/Discord/gateway/compression/pako.cjs +44 -0
  64. package/cjs/lib/Discord/gateway/compression/zlib-native.cjs +47 -0
  65. package/cjs/lib/Discord/gateway/compression/zlib-sync.cjs +31 -0
  66. package/cjs/lib/Discord/gateway/compression/zstd-napi.cjs +80 -0
  67. package/cjs/lib/Discord/gateway/compression/zstd-native.cjs +46 -0
  68. package/cjs/lib/Discord/gateway/events.cjs +956 -0
  69. package/cjs/lib/Discord/index.cjs +238 -0
  70. package/cjs/lib/Discord/rest/Bucket.cjs +69 -0
  71. package/cjs/lib/Discord/rest/DiscordHTTPError.cjs +63 -0
  72. package/cjs/lib/Discord/rest/DiscordRESTError.cjs +84 -0
  73. package/cjs/lib/Discord/rest/OAuthHelper.cjs +226 -0
  74. package/cjs/lib/Discord/rest/RESTManager.cjs +116 -0
  75. package/cjs/lib/Discord/rest/RequestHandler.cjs +320 -0
  76. package/cjs/lib/Discord/rest/SequentialBucket.cjs +69 -0
  77. package/cjs/lib/Discord/routes/Applications.cjs +625 -0
  78. package/cjs/lib/Discord/routes/Channels.cjs +1199 -0
  79. package/cjs/lib/Discord/routes/Guilds.cjs +1792 -0
  80. package/cjs/lib/Discord/routes/Interactions.cjs +212 -0
  81. package/cjs/lib/Discord/routes/Lobbies.cjs +197 -0
  82. package/cjs/lib/Discord/routes/Miscellaneous.cjs +120 -0
  83. package/cjs/lib/Discord/routes/OAuth.cjs +350 -0
  84. package/cjs/lib/Discord/routes/Users.cjs +107 -0
  85. package/cjs/lib/Discord/routes/Webhooks.cjs +308 -0
  86. package/cjs/lib/Discord/structures/AnnouncementChannel.cjs +46 -0
  87. package/cjs/lib/Discord/structures/AnnouncementThreadChannel.cjs +28 -0
  88. package/cjs/lib/Discord/structures/Application.cjs +345 -0
  89. package/cjs/lib/Discord/structures/ApplicationCommand.cjs +109 -0
  90. package/cjs/lib/Discord/structures/Attachment.cjs +46 -0
  91. package/cjs/lib/Discord/structures/AuditLogEntry.cjs +41 -0
  92. package/cjs/lib/Discord/structures/AutoModerationRule.cjs +117 -0
  93. package/cjs/lib/Discord/structures/AutocompleteInteraction.cjs +90 -0
  94. package/cjs/lib/Discord/structures/Base.cjs +56 -0
  95. package/cjs/lib/Discord/structures/BaseEntitlement.cjs +40 -0
  96. package/cjs/lib/Discord/structures/CategoryChannel.cjs +102 -0
  97. package/cjs/lib/Discord/structures/Channel.cjs +89 -0
  98. package/cjs/lib/Discord/structures/ClientApplication.cjs +269 -0
  99. package/cjs/lib/Discord/structures/CommandInteraction.cjs +294 -0
  100. package/cjs/lib/Discord/structures/ComponentInteraction.cjs +306 -0
  101. package/cjs/lib/Discord/structures/Entitlement.cjs +24 -0
  102. package/cjs/lib/Discord/structures/ExtendedUser.cjs +48 -0
  103. package/cjs/lib/Discord/structures/ForumChannel.cjs +20 -0
  104. package/cjs/lib/Discord/structures/GroupChannel.cjs +160 -0
  105. package/cjs/lib/Discord/structures/Guild.cjs +1289 -0
  106. package/cjs/lib/Discord/structures/GuildChannel.cjs +82 -0
  107. package/cjs/lib/Discord/structures/GuildPreview.cjs +141 -0
  108. package/cjs/lib/Discord/structures/GuildScheduledEvent.cjs +166 -0
  109. package/cjs/lib/Discord/structures/GuildTemplate.cjs +96 -0
  110. package/cjs/lib/Discord/structures/Integration.cjs +123 -0
  111. package/cjs/lib/Discord/structures/Interaction.cjs +78 -0
  112. package/cjs/lib/Discord/structures/InteractionResolvedChannel.cjs +36 -0
  113. package/cjs/lib/Discord/structures/Invite.cjs +196 -0
  114. package/cjs/lib/Discord/structures/InviteGuild.cjs +117 -0
  115. package/cjs/lib/Discord/structures/InviteRole.cjs +88 -0
  116. package/cjs/lib/Discord/structures/Lobby.cjs +84 -0
  117. package/cjs/lib/Discord/structures/LobbyMember.cjs +30 -0
  118. package/cjs/lib/Discord/structures/MediaChannel.cjs +20 -0
  119. package/cjs/lib/Discord/structures/Member.cjs +300 -0
  120. package/cjs/lib/Discord/structures/Message.cjs +553 -0
  121. package/cjs/lib/Discord/structures/ModalSubmitInteraction.cjs +263 -0
  122. package/cjs/lib/Discord/structures/OAuthApplication.cjs +203 -0
  123. package/cjs/lib/Discord/structures/OAuthGuild.cjs +98 -0
  124. package/cjs/lib/Discord/structures/PartialApplication.cjs +97 -0
  125. package/cjs/lib/Discord/structures/Permission.cjs +61 -0
  126. package/cjs/lib/Discord/structures/PermissionOverwrite.cjs +46 -0
  127. package/cjs/lib/Discord/structures/PingInteraction.cjs +27 -0
  128. package/cjs/lib/Discord/structures/Poll.cjs +69 -0
  129. package/cjs/lib/Discord/structures/PrimaryGuild.cjs +93 -0
  130. package/cjs/lib/Discord/structures/PrivateChannel.cjs +131 -0
  131. package/cjs/lib/Discord/structures/PrivateThreadChannel.cjs +28 -0
  132. package/cjs/lib/Discord/structures/PublicThreadChannel.cjs +36 -0
  133. package/cjs/lib/Discord/structures/Role.cjs +126 -0
  134. package/cjs/lib/Discord/structures/SKU.cjs +58 -0
  135. package/cjs/lib/Discord/structures/Soundboard.cjs +58 -0
  136. package/cjs/lib/Discord/structures/StageChannel.cjs +45 -0
  137. package/cjs/lib/Discord/structures/StageInstance.cjs +80 -0
  138. package/cjs/lib/Discord/structures/Subscription.cjs +21 -0
  139. package/cjs/lib/Discord/structures/Team.cjs +70 -0
  140. package/cjs/lib/Discord/structures/TestEntitlement.cjs +22 -0
  141. package/cjs/lib/Discord/structures/TextChannel.cjs +48 -0
  142. package/cjs/lib/Discord/structures/TextableChannel.cjs +265 -0
  143. package/cjs/lib/Discord/structures/TextableVoiceChannel.cjs +70 -0
  144. package/cjs/lib/Discord/structures/ThreadChannel.cjs +276 -0
  145. package/cjs/lib/Discord/structures/ThreadOnlyChannel.cjs +205 -0
  146. package/cjs/lib/Discord/structures/ThreadableChannel.cjs +57 -0
  147. package/cjs/lib/Discord/structures/UnavailableGuild.cjs +21 -0
  148. package/cjs/lib/Discord/structures/User.cjs +223 -0
  149. package/cjs/lib/Discord/structures/VoiceChannel.cjs +34 -0
  150. package/cjs/lib/Discord/structures/VoiceState.cjs +113 -0
  151. package/cjs/lib/Discord/structures/Webhook.cjs +224 -0
  152. package/cjs/lib/Discord/util/Collection.cjs +77 -0
  153. package/cjs/lib/Discord/util/Errors.cjs +81 -0
  154. package/cjs/lib/Discord/util/QueryBuilder.cjs +20 -0
  155. package/cjs/lib/Discord/util/Routes.cjs +293 -0
  156. package/cjs/lib/Discord/util/SimpleCollection.cjs +78 -0
  157. package/cjs/lib/Discord/util/Time.cjs +92 -0
  158. package/cjs/lib/Discord/util/TypedCollection.cjs +78 -0
  159. package/cjs/lib/Discord/util/TypedEmitter.cjs +20 -0
  160. package/cjs/lib/Discord/util/Util.cjs +906 -0
  161. package/cjs/lib/Discord/util/interactions/InteractionOptionsWrapper.cjs +207 -0
  162. package/cjs/lib/Discord/util/interactions/MessageInteractionResponse.cjs +26 -0
  163. package/cjs/lib/Discord/util/interactions/ModalSubmitInteractionComponentsWrapper.cjs +98 -0
  164. package/cjs/lib/Discord/util/interactions/SelectMenuValuesWrapper.cjs +77 -0
  165. package/cjs/lib/Discord/util/interactions/shared.cjs +20 -0
  166. package/cjs/lib/Discord/util/warning.cjs +34 -0
  167. package/cjs/lib/Signal/Group/ciphertext-message.cjs +16 -0
  168. package/cjs/lib/Signal/Group/group-session-builder.cjs +67 -0
  169. package/cjs/lib/Signal/Group/group_cipher.cjs +86 -0
  170. package/cjs/lib/Signal/Group/index.cjs +58 -0
  171. package/cjs/lib/Signal/Group/keyhelper.cjs +56 -0
  172. package/cjs/lib/Signal/Group/sender-chain-key.cjs +30 -0
  173. package/cjs/lib/Signal/Group/sender-key-distribution-message.cjs +67 -0
  174. package/cjs/lib/Signal/Group/sender-key-message.cjs +70 -0
  175. package/cjs/lib/Signal/Group/sender-key-name.cjs +52 -0
  176. package/cjs/lib/Signal/Group/sender-key-record.cjs +45 -0
  177. package/cjs/lib/Signal/Group/sender-key-state.cjs +88 -0
  178. package/cjs/lib/Signal/Group/sender-message-key.cjs +30 -0
  179. package/cjs/lib/Signal/libsignal.cjs +467 -0
  180. package/cjs/lib/Signal/lid-mapping.cjs +281 -0
  181. package/cjs/lib/Socket/Client/index.cjs +19 -0
  182. package/cjs/lib/Socket/Client/types.cjs +15 -0
  183. package/cjs/lib/Socket/Client/websocket.cjs +61 -0
  184. package/cjs/lib/Socket/business.cjs +384 -0
  185. package/cjs/lib/Socket/chats.cjs +1221 -0
  186. package/cjs/lib/Socket/communities.cjs +440 -0
  187. package/cjs/lib/Socket/groups.cjs +353 -0
  188. package/cjs/lib/Socket/index.cjs +14 -0
  189. package/cjs/lib/Socket/messages-recv.cjs +1772 -0
  190. package/cjs/lib/Socket/messages-send.cjs +1376 -0
  191. package/cjs/lib/Socket/mex.cjs +46 -0
  192. package/cjs/lib/Socket/newsletter.cjs +230 -0
  193. package/cjs/lib/Socket/socket.cjs +976 -0
  194. package/cjs/lib/Store/index.cjs +20 -0
  195. package/cjs/lib/Store/make-in-memory-store.cjs +470 -0
  196. package/cjs/lib/Store/make-ordered-dictionary.cjs +82 -0
  197. package/cjs/lib/Store/object-repository.cjs +28 -0
  198. package/cjs/lib/Telegram/button.cjs +147 -0
  199. package/cjs/lib/Telegram/composer.cjs +582 -0
  200. package/cjs/lib/Telegram/context.cjs +853 -0
  201. package/cjs/lib/Telegram/core/helpers/args.cjs +57 -0
  202. package/cjs/lib/Telegram/core/helpers/check.cjs +55 -0
  203. package/cjs/lib/Telegram/core/helpers/compact.cjs +16 -0
  204. package/cjs/lib/Telegram/core/helpers/deunionize.cjs +12 -0
  205. package/cjs/lib/Telegram/core/helpers/formatting.cjs +91 -0
  206. package/cjs/lib/Telegram/core/helpers/util.cjs +50 -0
  207. package/cjs/lib/Telegram/core/network/client.cjs +338 -0
  208. package/cjs/lib/Telegram/core/network/error.cjs +21 -0
  209. package/cjs/lib/Telegram/core/network/multipart-stream.cjs +79 -0
  210. package/cjs/lib/Telegram/core/network/polling.cjs +87 -0
  211. package/cjs/lib/Telegram/core/network/webhook.cjs +54 -0
  212. package/cjs/lib/Telegram/core/types/typegram.cjs +31 -0
  213. package/cjs/lib/Telegram/deffa-telegraf.cjs +264 -0
  214. package/cjs/lib/Telegram/esm-bridge.cjs +20 -0
  215. package/cjs/lib/Telegram/filters.cjs +69 -0
  216. package/cjs/lib/Telegram/format.cjs +58 -0
  217. package/cjs/lib/Telegram/future.cjs +140 -0
  218. package/cjs/lib/Telegram/index.cjs +67 -0
  219. package/cjs/lib/Telegram/input.cjs +61 -0
  220. package/cjs/lib/Telegram/markup.cjs +129 -0
  221. package/cjs/lib/Telegram/middleware.cjs +2 -0
  222. package/cjs/lib/Telegram/reactions.cjs +84 -0
  223. package/cjs/lib/Telegram/router.cjs +46 -0
  224. package/cjs/lib/Telegram/scenes/base.cjs +39 -0
  225. package/cjs/lib/Telegram/scenes/context.cjs +104 -0
  226. package/cjs/lib/Telegram/scenes/index.cjs +21 -0
  227. package/cjs/lib/Telegram/scenes/stage.cjs +49 -0
  228. package/cjs/lib/Telegram/scenes/wizard/context.cjs +31 -0
  229. package/cjs/lib/Telegram/scenes/wizard/index.cjs +45 -0
  230. package/cjs/lib/Telegram/scenes.cjs +21 -0
  231. package/cjs/lib/Telegram/session.cjs +166 -0
  232. package/cjs/lib/Telegram/telegram-types.cjs +6 -0
  233. package/cjs/lib/Telegram/telegram.cjs +945 -0
  234. package/cjs/lib/Telegram/types.cjs +2 -0
  235. package/cjs/lib/Telegram/utils.cjs +5 -0
  236. package/cjs/lib/Types/Auth.cjs +3 -0
  237. package/cjs/lib/Types/Bussines.cjs +3 -0
  238. package/cjs/lib/Types/Call.cjs +3 -0
  239. package/cjs/lib/Types/Chat.cjs +11 -0
  240. package/cjs/lib/Types/Contact.cjs +3 -0
  241. package/cjs/lib/Types/Events.cjs +4 -0
  242. package/cjs/lib/Types/GroupMetadata.cjs +3 -0
  243. package/cjs/lib/Types/Label.cjs +26 -0
  244. package/cjs/lib/Types/LabelAssociation.cjs +8 -0
  245. package/cjs/lib/Types/Message.cjs +19 -0
  246. package/cjs/lib/Types/Mex.cjs +40 -0
  247. package/cjs/lib/Types/Product.cjs +3 -0
  248. package/cjs/lib/Types/RichType.cjs +24 -0
  249. package/cjs/lib/Types/Signal.cjs +4 -0
  250. package/cjs/lib/Types/Socket.cjs +4 -0
  251. package/cjs/lib/Types/State.cjs +54 -0
  252. package/cjs/lib/Types/USync.cjs +4 -0
  253. package/cjs/lib/Types/index.cjs +42 -0
  254. package/cjs/lib/Utils/auth-utils.cjs +312 -0
  255. package/cjs/lib/Utils/browser-utils.cjs +39 -0
  256. package/cjs/lib/Utils/business.cjs +241 -0
  257. package/cjs/lib/Utils/chat-utils.cjs +890 -0
  258. package/cjs/lib/Utils/companion-reg-client-utils.cjs +51 -0
  259. package/cjs/lib/Utils/crypto.cjs +170 -0
  260. package/cjs/lib/Utils/decode-wa-message.cjs +330 -0
  261. package/cjs/lib/Utils/event-buffer.cjs +629 -0
  262. package/cjs/lib/Utils/generics.cjs +427 -0
  263. package/cjs/lib/Utils/history.cjs +141 -0
  264. package/cjs/lib/Utils/identity-change-handler.cjs +56 -0
  265. package/cjs/lib/Utils/index.cjs +43 -0
  266. package/cjs/lib/Utils/link-preview.cjs +122 -0
  267. package/cjs/lib/Utils/logger.cjs +8 -0
  268. package/cjs/lib/Utils/lt-hash.cjs +11 -0
  269. package/cjs/lib/Utils/make-mutex.cjs +38 -0
  270. package/cjs/lib/Utils/message-retry-manager.cjs +267 -0
  271. package/cjs/lib/Utils/messages-media.cjs +906 -0
  272. package/cjs/lib/Utils/messages.cjs +1909 -0
  273. package/cjs/lib/Utils/noise-handler.cjs +205 -0
  274. package/cjs/lib/Utils/offline-node-processor.cjs +43 -0
  275. package/cjs/lib/Utils/pre-key-manager.cjs +113 -0
  276. package/cjs/lib/Utils/process-message.cjs +755 -0
  277. package/cjs/lib/Utils/reporting-utils.cjs +263 -0
  278. package/cjs/lib/Utils/rich-message-utils.cjs +434 -0
  279. package/cjs/lib/Utils/session-guard.cjs +163 -0
  280. package/cjs/lib/Utils/signal.cjs +214 -0
  281. package/cjs/lib/Utils/stanza-ack.cjs +41 -0
  282. package/cjs/lib/Utils/sync-action-utils.cjs +54 -0
  283. package/cjs/lib/Utils/tc-token-utils.cjs +174 -0
  284. package/cjs/lib/Utils/text-sticker.cjs +174 -0
  285. package/cjs/lib/Utils/use-multi-file-auth-state.cjs +125 -0
  286. package/cjs/lib/Utils/use-single-file-auth-state.cjs +113 -0
  287. package/cjs/lib/Utils/use-sqlite-auth-state.cjs +145 -0
  288. package/cjs/lib/Utils/validate-connection.cjs +210 -0
  289. package/cjs/lib/WABinary/constants.cjs +1470 -0
  290. package/cjs/lib/WABinary/decode.cjs +301 -0
  291. package/cjs/lib/WABinary/encode.cjs +257 -0
  292. package/cjs/lib/WABinary/generic-utils.cjs +240 -0
  293. package/cjs/lib/WABinary/index.cjs +22 -0
  294. package/cjs/lib/WABinary/jid-utils.cjs +114 -0
  295. package/cjs/lib/WABinary/types.cjs +37 -0
  296. package/cjs/lib/WAM/BinaryInfo.cjs +14 -0
  297. package/cjs/lib/WAM/constants.cjs +22856 -0
  298. package/cjs/lib/WAM/encode.cjs +154 -0
  299. package/cjs/lib/WAM/index.cjs +20 -0
  300. package/cjs/lib/WAUSync/Protocols/USyncContactProtocol.cjs +56 -0
  301. package/cjs/lib/WAUSync/Protocols/USyncDeviceProtocol.cjs +58 -0
  302. package/cjs/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.cjs +31 -0
  303. package/cjs/lib/WAUSync/Protocols/USyncStatusProtocol.cjs +42 -0
  304. package/cjs/lib/WAUSync/Protocols/USyncUsernameProtocol.cjs +29 -0
  305. package/cjs/lib/WAUSync/Protocols/UsyncBotProfileProtocol.cjs +55 -0
  306. package/cjs/lib/WAUSync/Protocols/UsyncLIDProtocol.cjs +33 -0
  307. package/cjs/lib/WAUSync/Protocols/index.cjs +22 -0
  308. package/cjs/lib/WAUSync/USyncQuery.cjs +102 -0
  309. package/cjs/lib/WAUSync/USyncUser.cjs +35 -0
  310. package/cjs/lib/WAUSync/index.cjs +20 -0
  311. package/cjs/lib/index.cjs +372 -0
  312. package/cjs/lib/plugins/loader.cjs +117 -0
  313. package/lib/Defaults/index.js +1 -1
  314. package/lib/Socket/socket.js +3 -3
  315. package/lib/Telegram/esm-bridge.mjs +1 -1
  316. package/package.json +11 -6
@@ -0,0 +1,263 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMessageReportingToken = exports.shouldIncludeReportingToken = void 0;
4
+ const crypto_1 = require("crypto");
5
+ const index_js_1 = require("../../WAProto/index.cjs");
6
+ const crypto_js_1 = require("./crypto.cjs");
7
+ const reportingFields = [
8
+ { f: 1 },
9
+ {
10
+ f: 3,
11
+ s: [{ f: 2 }, { f: 3 }, { f: 8 }, { f: 11 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }, { f: 25 }]
12
+ },
13
+ { f: 4, s: [{ f: 1 }, { f: 16 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }] },
14
+ { f: 5, s: [{ f: 3 }, { f: 4 }, { f: 5 }, { f: 16 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }] },
15
+ { f: 6, s: [{ f: 1 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }, { f: 30 }] },
16
+ { f: 7, s: [{ f: 2 }, { f: 7 }, { f: 10 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }, { f: 20 }] },
17
+ { f: 8, s: [{ f: 2 }, { f: 7 }, { f: 9 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }, { f: 21 }] },
18
+ { f: 9, s: [{ f: 2 }, { f: 6 }, { f: 7 }, { f: 13 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }, { f: 20 }] },
19
+ { f: 12, s: [{ f: 1 }, { f: 2 }, { f: 14, m: true }, { f: 15 }] },
20
+ { f: 18, s: [{ f: 6 }, { f: 16 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }] },
21
+ { f: 26, s: [{ f: 4 }, { f: 5 }, { f: 8 }, { f: 13 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }] },
22
+ { f: 28, s: [{ f: 1 }, { f: 2 }, { f: 4 }, { f: 5 }, { f: 6 }, { f: 7, s: [{ f: 21 }, { f: 22 }] }] },
23
+ { f: 37, s: [{ f: 1, m: true }] },
24
+ {
25
+ f: 49,
26
+ s: [
27
+ { f: 2 },
28
+ { f: 3, s: [{ f: 1 }, { f: 2 }] },
29
+ { f: 5, s: [{ f: 21 }, { f: 22 }] },
30
+ { f: 8, s: [{ f: 1 }, { f: 2 }] }
31
+ ]
32
+ },
33
+ { f: 53, s: [{ f: 1, m: true }] },
34
+ { f: 55, s: [{ f: 1, m: true }] },
35
+ { f: 58, s: [{ f: 1, m: true }] },
36
+ { f: 59, s: [{ f: 1, m: true }] },
37
+ {
38
+ f: 60,
39
+ s: [
40
+ { f: 2 },
41
+ { f: 3, s: [{ f: 1 }, { f: 2 }] },
42
+ { f: 5, s: [{ f: 21 }, { f: 22 }] },
43
+ { f: 8, s: [{ f: 1 }, { f: 2 }] }
44
+ ]
45
+ },
46
+ {
47
+ f: 64,
48
+ s: [
49
+ { f: 2 },
50
+ { f: 3, s: [{ f: 1 }, { f: 2 }] },
51
+ { f: 5, s: [{ f: 21 }, { f: 22 }] },
52
+ { f: 8, s: [{ f: 1 }, { f: 2 }] }
53
+ ]
54
+ },
55
+ { f: 66, s: [{ f: 2 }, { f: 6 }, { f: 7 }, { f: 13 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }, { f: 20 }] },
56
+ { f: 74, s: [{ f: 1, m: true }] },
57
+ { f: 87, s: [{ f: 1, m: true }] },
58
+ { f: 88, s: [{ f: 1 }, { f: 2, s: [{ f: 1 }] }, { f: 3, s: [{ f: 21 }, { f: 22 }] }] },
59
+ { f: 92, s: [{ f: 1, m: true }] },
60
+ { f: 93, s: [{ f: 1, m: true }] },
61
+ { f: 94, s: [{ f: 1, m: true }] }
62
+ ];
63
+ const compileReportingFields = (fields) => {
64
+ const map = new Map();
65
+ for (const f of fields) {
66
+ map.set(f.f, {
67
+ m: f.m,
68
+ children: f.s ? compileReportingFields(f.s) : undefined
69
+ });
70
+ }
71
+ return map;
72
+ };
73
+ const compiledReportingFields = compileReportingFields(reportingFields);
74
+ const EMPTY_MAP = new Map();
75
+ const ENC_SECRET_REPORT_TOKEN = 'Report Token';
76
+ const WIRE = {
77
+ VARINT: 0,
78
+ FIXED64: 1,
79
+ BYTES: 2,
80
+ FIXED32: 5
81
+ };
82
+ const shouldIncludeReportingToken = (message) => !message.reactionMessage &&
83
+ !message.encReactionMessage &&
84
+ !message.encEventResponseMessage &&
85
+ !message.pollUpdateMessage;
86
+ exports.shouldIncludeReportingToken = shouldIncludeReportingToken;
87
+ const generateMsgSecretKey = (modificationType, origMsgId, origMsgSender, modificationSender, origMsgSecret) => {
88
+ const useCaseSecret = Buffer.concat([
89
+ Buffer.from(origMsgId, 'utf8'),
90
+ Buffer.from(origMsgSender, 'utf8'),
91
+ Buffer.from(modificationSender, 'utf8'),
92
+ Buffer.from(modificationType, 'utf8')
93
+ ]);
94
+ return (0, crypto_js_1.hkdf)(origMsgSecret, 32, { info: useCaseSecret.toString('latin1') });
95
+ };
96
+ const extractReportingTokenContent = (data, cfg) => {
97
+ const out = [];
98
+ let i = 0;
99
+ while (i < data.length) {
100
+ const tag = decodeVarint(data, i);
101
+ if (!tag.ok) {
102
+ return null;
103
+ }
104
+ const fieldNum = tag.value >> 3;
105
+ const wireType = tag.value & 0x7;
106
+ const fieldStart = i;
107
+ i += tag.bytes;
108
+ const fieldCfg = cfg.get(fieldNum);
109
+ const pushSlice = (end) => {
110
+ if (end > data.length) {
111
+ return false;
112
+ }
113
+ out.push({ num: fieldNum, bytes: data.subarray(fieldStart, end) });
114
+ i = end;
115
+ return true;
116
+ };
117
+ const skip = (end) => {
118
+ if (end > data.length) {
119
+ return false;
120
+ }
121
+ i = end;
122
+ return true;
123
+ };
124
+ if (wireType === WIRE.VARINT) {
125
+ const v = decodeVarint(data, i);
126
+ if (!v.ok) {
127
+ return null;
128
+ }
129
+ const end = i + v.bytes;
130
+ if (!fieldCfg) {
131
+ if (!skip(end)) {
132
+ return null;
133
+ }
134
+ continue;
135
+ }
136
+ if (!pushSlice(end)) {
137
+ return null;
138
+ }
139
+ continue;
140
+ }
141
+ if (wireType === WIRE.FIXED64) {
142
+ const end = i + 8;
143
+ if (!fieldCfg) {
144
+ if (!skip(end)) {
145
+ return null;
146
+ }
147
+ continue;
148
+ }
149
+ if (!pushSlice(end)) {
150
+ return null;
151
+ }
152
+ continue;
153
+ }
154
+ if (wireType === WIRE.FIXED32) {
155
+ const end = i + 4;
156
+ if (!fieldCfg) {
157
+ if (!skip(end)) {
158
+ return null;
159
+ }
160
+ continue;
161
+ }
162
+ if (!pushSlice(end)) {
163
+ return null;
164
+ }
165
+ continue;
166
+ }
167
+ if (wireType === WIRE.BYTES) {
168
+ const len = decodeVarint(data, i);
169
+ if (!len.ok) {
170
+ return null;
171
+ }
172
+ const valStart = i + len.bytes;
173
+ const valEnd = valStart + len.value;
174
+ if (valEnd > data.length) {
175
+ return null;
176
+ }
177
+ if (!fieldCfg) {
178
+ i = valEnd;
179
+ continue;
180
+ }
181
+ if (fieldCfg.m || fieldCfg.children) {
182
+ const sub = extractReportingTokenContent(data.subarray(valStart, valEnd), fieldCfg.children ?? EMPTY_MAP);
183
+ if (sub === null) {
184
+ return null;
185
+ }
186
+ if (sub.length > 0) {
187
+ const newTag = encodeVarint(tag.value);
188
+ const newLen = encodeVarint(sub.length);
189
+ out.push({
190
+ num: fieldNum,
191
+ bytes: Buffer.concat([newTag, newLen, sub])
192
+ });
193
+ }
194
+ i = valEnd;
195
+ continue;
196
+ }
197
+ out.push({ num: fieldNum, bytes: data.subarray(fieldStart, valEnd) });
198
+ i = valEnd;
199
+ continue;
200
+ }
201
+ return null;
202
+ }
203
+ if (out.length === 0) {
204
+ return Buffer.alloc(0);
205
+ }
206
+ out.sort((a, b) => a.num - b.num);
207
+ return Buffer.concat(out.map(f => f.bytes));
208
+ };
209
+ const decodeVarint = (buffer, offset) => {
210
+ let value = 0;
211
+ let bytes = 0;
212
+ let shift = 0;
213
+ while (offset + bytes < buffer.length) {
214
+ const current = buffer[offset + bytes];
215
+ value |= (current & 0x7f) << shift;
216
+ bytes++;
217
+ if ((current & 0x80) === 0) {
218
+ return { value, bytes, ok: true };
219
+ }
220
+ shift += 7;
221
+ if (shift > 35) {
222
+ return { value: 0, bytes: 0, ok: false };
223
+ }
224
+ }
225
+ return { value: 0, bytes: 0, ok: false };
226
+ };
227
+ const encodeVarint = (value) => {
228
+ const parts = [];
229
+ let remaining = value >>> 0;
230
+ while (remaining > 0x7f) {
231
+ parts.push((remaining & 0x7f) | 0x80);
232
+ remaining >>>= 7;
233
+ }
234
+ parts.push(remaining);
235
+ return Buffer.from(parts);
236
+ };
237
+ const getMessageReportingToken = async (msgProtobuf, message, key) => {
238
+ const msgSecret = message.messageContextInfo?.messageSecret;
239
+ if (!msgSecret || !key.id) {
240
+ return null;
241
+ }
242
+ const from = key.fromMe ? key.remoteJid : key.participant || key.remoteJid;
243
+ const to = key.fromMe ? key.participant || key.remoteJid : key.remoteJid;
244
+ const reportingSecret = generateMsgSecretKey(ENC_SECRET_REPORT_TOKEN, key.id, from, to, msgSecret);
245
+ const content = extractReportingTokenContent(msgProtobuf, compiledReportingFields);
246
+ if (!content || content.length === 0) {
247
+ return null;
248
+ }
249
+ const reportingToken = (0, crypto_1.createHmac)('sha256', reportingSecret).update(content).digest().subarray(0, 16);
250
+ return {
251
+ tag: 'reporting',
252
+ attrs: {},
253
+ content: [
254
+ {
255
+ tag: 'reporting_token',
256
+ attrs: { v: '2' },
257
+ content: reportingToken
258
+ }
259
+ ]
260
+ };
261
+ };
262
+ exports.getMessageReportingToken = getMessageReportingToken;
263
+ //# sourceMappingURL=reporting-utils.js.map
@@ -0,0 +1,434 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.wrapToBotForwardedMessage = exports.botMetadataCertificate = exports.botMetadataSignature = exports.prepareRichResponseMessage = exports.toUnified = exports.tokenizeCode = void 0;
4
+ /**
5
+ * Lia@Changes 09-04-26 [WIP]
6
+ * Adds support for tables and code blocks with richResponseMessage (wrapped inside botForwardedMessage).
7
+ *
8
+ * If you use or copy this code, please credit my name or project. AND DO NOT CHANGE THIS NOTE
9
+ */
10
+ const crypto_1 = require("crypto");
11
+ const index_js_1 = require("../Defaults/index.cjs");
12
+ const constants_js_1 = require("../WABinary/constants.cjs");
13
+ const RichType_js_1 = require("../Types/RichType.cjs");
14
+ const index_js_2 = require("../../WAProto/index.cjs");
15
+ const generics_js_1 = require("./generics.cjs");
16
+ const NOOP = new Set([]);
17
+ const tokenizeCode = (code, language = 'javascript') => {
18
+ const keywords = constants_js_1.LANGUAGE_KEYWORDS[language] || NOOP;
19
+ const blocks = [];
20
+ index_js_1.LEXER_REGEX.lastIndex = 0;
21
+ let match;
22
+ while ((match = index_js_1.LEXER_REGEX.exec(code)) !== null) {
23
+ if (match[1]) {
24
+ blocks.push({ highlightType: RichType_js_1.CodeHighlightType.COMMENT, codeContent: match[1] });
25
+ }
26
+ else if (match[2]) {
27
+ blocks.push({ highlightType: RichType_js_1.CodeHighlightType.STRING, codeContent: match[2] });
28
+ }
29
+ else if (match[3]) {
30
+ blocks.push({
31
+ highlightType: keywords.has(match[3]) ? RichType_js_1.CodeHighlightType.KEYWORD : RichType_js_1.CodeHighlightType.METHOD,
32
+ codeContent: match[3],
33
+ });
34
+ }
35
+ else if (match[4]) {
36
+ blocks.push({
37
+ highlightType: keywords.has(match[4]) ? RichType_js_1.CodeHighlightType.KEYWORD : RichType_js_1.CodeHighlightType.DEFAULT,
38
+ codeContent: match[4],
39
+ });
40
+ }
41
+ else if (match[5]) {
42
+ blocks.push({ highlightType: RichType_js_1.CodeHighlightType.NUMBER, codeContent: match[5] });
43
+ }
44
+ else {
45
+ blocks.push({ highlightType: RichType_js_1.CodeHighlightType.DEFAULT, codeContent: match[6] });
46
+ }
47
+ }
48
+ return blocks;
49
+ };
50
+ exports.tokenizeCode = tokenizeCode;
51
+ // Lia@Changes 09-04-26 --- Inject buffer into unifiedResponse.data to support proper rendering of rich messages (ex: tables and code blocks)
52
+ const toUnified = (submessages, uuid) => ({
53
+ response_id: uuid || (0, crypto_1.randomUUID)(),
54
+ sections: submessages.map((submessage, index) => {
55
+ switch (submessage.messageType) {
56
+ case RichType_js_1.RichSubMessageType.CODE:
57
+ const codeMetadata = submessage.codeMetadata;
58
+ return {
59
+ view_model: {
60
+ primitive: {
61
+ language: codeMetadata.codeLanguage,
62
+ code_blocks: codeMetadata.codeBlocks.map((block) => ({ content: block.codeContent, type: RichType_js_1.CodeHighlightType[block.highlightType] })),
63
+ __typename: 'GenAICodeUXPrimitive'
64
+ },
65
+ __typename: 'GenAISingleLayoutViewModel'
66
+ }
67
+ };
68
+ case RichType_js_1.RichSubMessageType.CONTENT_ITEMS:
69
+ return {};
70
+ case RichType_js_1.RichSubMessageType.INLINE_IMAGE:
71
+ const imgMeta = submessage.imageMetadata;
72
+ return {
73
+ view_model: {
74
+ primitive: {
75
+ image_url: {
76
+ image_preview_url: imgMeta?.imageUrl?.imagePreviewUrl,
77
+ image_high_res_url: imgMeta?.imageUrl?.imageHighResUrl,
78
+ source_url: imgMeta?.imageUrl?.sourceUrl
79
+ },
80
+ image_text: imgMeta?.imageText,
81
+ tap_link_url: imgMeta?.tapLinkUrl,
82
+ alignment: imgMeta?.alignment,
83
+ __typename: 'GenAIInlineImageUXPrimitive'
84
+ },
85
+ __typename: 'GenAISingleLayoutViewModel'
86
+ }
87
+ };
88
+ case RichType_js_1.RichSubMessageType.LATEX:
89
+ return {};
90
+ case RichType_js_1.RichSubMessageType.TABLE:
91
+ const tableMetadata = submessage.tableMetadata;
92
+ return {
93
+ view_model: {
94
+ primitive: {
95
+ title: tableMetadata.title,
96
+ rows: tableMetadata.rows.map((row) => ({
97
+ is_header: row.isHeading,
98
+ cells: row.items,
99
+ markdown_cells: row.items.map((item) => ({ text: item }))
100
+ })),
101
+ __typename: 'GenATableUXPrimitive'
102
+ },
103
+ __typename: 'GenAISingleLayoutViewModel'
104
+ }
105
+ };
106
+ case RichType_js_1.RichSubMessageType.TEXT:
107
+ return {
108
+ view_model: {
109
+ primitive: {
110
+ text: submessage.messageText,
111
+ inline_entities: submessage.inlineEntities || [],
112
+ __typename: 'GenAIMarkdownTextUXPrimitive'
113
+ },
114
+ __typename: 'GenAISingleLayoutViewModel'
115
+ }
116
+ };
117
+ }
118
+ return submessage;
119
+ })
120
+ });
121
+ exports.toUnified = toUnified;
122
+ const prepareRichResponseMessage = (content) => {
123
+ const { alignment, code, contentText, disclaimerText, footerText, headerText, imageText, inlineImage, inlineVideo, items, language, latex, links, noHeading, posts, products, suggested, richResponse, table, tapLinkUrl, title } = content;
124
+ let submessages = [];
125
+ if (Array.isArray(richResponse)) {
126
+ submessages = richResponse.flatMap((submessage) => {
127
+ if (submessage.text) {
128
+ return {
129
+ messageType: RichType_js_1.RichSubMessageType.TEXT,
130
+ messageText: submessage.text,
131
+ inlineEntities: submessage.inlineEntities
132
+ };
133
+ }
134
+ else if (submessage.code) {
135
+ return {
136
+ messageType: RichType_js_1.RichSubMessageType.CODE,
137
+ codeMetadata: {
138
+ codeLanguage: submessage.language,
139
+ codeBlocks: submessage.code
140
+ }
141
+ };
142
+ }
143
+ else if (submessage.items) {
144
+ return {
145
+ messageType: RichType_js_1.RichSubMessageType.CONTENT_ITEMS,
146
+ contentItemsMetadata: {
147
+ itemsMetadata: submessage.items,
148
+ contentType: index_js_2.proto.AIRichResponseContentItemsMetadata.ContentType.CAROUSEL
149
+ }
150
+ };
151
+ }
152
+ else if (submessage.inlineImage) {
153
+ const _inlineUrl = submessage.inlineImage;
154
+ return {
155
+ messageType: RichType_js_1.RichSubMessageType.INLINE_IMAGE,
156
+ imageMetadata: {
157
+ imageUrl: {
158
+ imagePreviewUrl: _inlineUrl,
159
+ imageHighResUrl: _inlineUrl,
160
+ sourceUrl: submessage.tapLinkUrl || _inlineUrl
161
+ },
162
+ imageText: submessage.imageText,
163
+ alignment: submessage.alignment,
164
+ tapLinkUrl: submessage.tapLinkUrl
165
+ }
166
+ };
167
+ }
168
+ else if (submessage.inlineVideo) {
169
+ return {
170
+ messageType: RichType_js_1.RichSubMessageType.TEXT,
171
+ messageText: 'INLINE_VIDEO'
172
+ };
173
+ }
174
+ else if (submessage.latex) {
175
+ return {
176
+ messageType: RichType_js_1.RichSubMessageType.LATEX,
177
+ latexMetadata: {
178
+ text: submessage.text,
179
+ expressions: submessage.latex
180
+ }
181
+ };
182
+ }
183
+ // deffa-baileys fix: 'links' submessages were unhandled in the array branch,
184
+ // falling through to a raw object with no messageType, which broke toUnified().
185
+ // Mirrors the non-array branch logic below (one link entry can expand to N TEXT submessages).
186
+ else if (submessage.links) {
187
+ return submessage.links.map((linkField, index) => {
188
+ const prefix = 'SS_' + index;
189
+ const url = linkField.url || index_js_1.DONATE_URL;
190
+ const sources = linkField.sources?.map((sourceField) => ({
191
+ source_type: 'THIRD_PARTY',
192
+ source_display_name: sourceField.displayName || 'Donate',
193
+ source_subtitle: sourceField.subtitle || 'Saweria',
194
+ source_url: sourceField.url || url
195
+ }));
196
+ return {
197
+ messageType: RichType_js_1.RichSubMessageType.TEXT,
198
+ messageText: linkField.text + ` {{${prefix}}}¹{{/${prefix}}} `,
199
+ inlineEntities: [{
200
+ key: prefix,
201
+ metadata: {
202
+ reference_id: index + 1,
203
+ reference_url: url,
204
+ reference_title: linkField.title || 'For Donation via Saweria',
205
+ reference_display_name: linkField.displayName || 'Donation',
206
+ sources: sources || [],
207
+ __typename: 'GenAISearchCitationItem'
208
+ }
209
+ }]
210
+ };
211
+ });
212
+ }
213
+ else if (submessage.posts) {
214
+ return {
215
+ messageType: RichType_js_1.RichSubMessageType.TEXT,
216
+ messageText: 'POSTS'
217
+ };
218
+ }
219
+ else if (submessage.products) {
220
+ return {
221
+ messageType: RichType_js_1.RichSubMessageType.TEXT,
222
+ messageText: 'PRODUCTS'
223
+ };
224
+ }
225
+ else if (submessage.suggested) {
226
+ return {
227
+ messageType: RichType_js_1.RichSubMessageType.TEXT,
228
+ messageText: 'SUGGESTED_PROMPT'
229
+ };
230
+ }
231
+ else if (submessage.table) {
232
+ return {
233
+ messageType: RichType_js_1.RichSubMessageType.TABLE,
234
+ tableMetadata: {
235
+ title: submessage.title,
236
+ rows: submessage.table
237
+ }
238
+ };
239
+ }
240
+ return submessage;
241
+ });
242
+ }
243
+ else {
244
+ if (headerText) {
245
+ submessages.push({
246
+ messageType: RichType_js_1.RichSubMessageType.TEXT,
247
+ messageText: headerText
248
+ });
249
+ }
250
+ if (contentText) {
251
+ submessages.push({
252
+ messageType: RichType_js_1.RichSubMessageType.TEXT,
253
+ messageText: contentText
254
+ });
255
+ }
256
+ if (code) {
257
+ language || (language = 'javascript');
258
+ submessages.push({
259
+ messageType: RichType_js_1.RichSubMessageType.CODE,
260
+ codeMetadata: {
261
+ codeLanguage: language,
262
+ codeBlocks: (0, exports.tokenizeCode)(code, language)
263
+ }
264
+ });
265
+ }
266
+ if (items) {
267
+ submessages.push({
268
+ messageType: RichType_js_1.RichSubMessageType.CONTENT_ITEMS,
269
+ contentItemsMetadata: {
270
+ itemsMetadata: items,
271
+ contentType: index_js_2.proto.AIRichResponseContentItemsMetadata.ContentType.CAROUSEL
272
+ }
273
+ });
274
+ }
275
+ if (inlineImage) {
276
+ submessages.push({
277
+ messageType: RichType_js_1.RichSubMessageType.INLINE_IMAGE,
278
+ imageMetadata: {
279
+ imageUrl: {
280
+ imagePreviewUrl: inlineImage,
281
+ imageHighResUrl: inlineImage,
282
+ sourceUrl: tapLinkUrl || inlineImage
283
+ },
284
+ imageText,
285
+ alignment,
286
+ tapLinkUrl
287
+ }
288
+ });
289
+ }
290
+ if (inlineVideo) {
291
+ submessages.push({
292
+ messageType: RichType_js_1.RichSubMessageType.TEXT,
293
+ messageText: 'INLINE_VIDEO'
294
+ });
295
+ }
296
+ if (latex) {
297
+ submessages.push({
298
+ messageType: RichType_js_1.RichSubMessageType.LATEX,
299
+ latexMetadata: {
300
+ text,
301
+ expressions: latex
302
+ }
303
+ });
304
+ }
305
+ if (links) {
306
+ links.forEach((linkField, index) => {
307
+ const prefix = 'SS_' + index;
308
+ const url = linkField.url || index_js_1.DONATE_URL;
309
+ const sources = linkField.sources?.map((sourceField) => ({
310
+ source_type: 'THIRD_PARTY',
311
+ source_display_name: sourceField.displayName || 'Donate',
312
+ source_subtitle: sourceField.subtitle || 'Saweria',
313
+ source_url: sourceField.url || url
314
+ }));
315
+ submessages.push({
316
+ messageType: RichType_js_1.RichSubMessageType.TEXT,
317
+ messageText: linkField.text + ` {{${prefix}}}¹{{/${prefix}}} `,
318
+ inlineEntities: [{
319
+ key: prefix,
320
+ metadata: {
321
+ reference_id: index + 1,
322
+ reference_url: url,
323
+ reference_title: linkField.title || 'For Donation via Saweria',
324
+ reference_display_name: linkField.displayName || 'Donation',
325
+ sources: sources || [],
326
+ __typename: 'GenAISearchCitationItem'
327
+ }
328
+ }]
329
+ });
330
+ });
331
+ }
332
+ if (posts) {
333
+ submessages.push({
334
+ messageType: RichType_js_1.RichSubMessageType.TEXT,
335
+ messageText: 'POSTS'
336
+ });
337
+ }
338
+ if (products) {
339
+ submessages.push({
340
+ messageType: RichType_js_1.RichSubMessageType.TEXT,
341
+ messageText: 'PRODUCTS'
342
+ });
343
+ }
344
+ if (suggested) {
345
+ submessages.push({
346
+ messageType: RichType_js_1.RichSubMessageType.TEXT,
347
+ messageText: 'SUGGESTED_PROMPT'
348
+ });
349
+ }
350
+ if (table) {
351
+ submessages.push({
352
+ messageType: RichType_js_1.RichSubMessageType.TABLE,
353
+ tableMetadata: {
354
+ title,
355
+ rows: table.map((items, index) => ({
356
+ isHeading: !noHeading && index == 0,
357
+ items
358
+ }))
359
+ }
360
+ });
361
+ }
362
+ if (footerText) {
363
+ submessages.push({
364
+ messageType: RichType_js_1.RichSubMessageType.TEXT,
365
+ messageText: footerText
366
+ });
367
+ }
368
+ }
369
+ const uuid = (0, crypto_1.randomUUID)();
370
+ const unified = (0, exports.toUnified)(submessages, uuid);
371
+ const richResponseMessage = index_js_2.proto.AIRichResponseMessage.create({
372
+ submessages,
373
+ messageType: index_js_2.proto.AIRichResponseMessageType.AI_RICH_RESPONSE_TYPE_STANDARD,
374
+ unifiedResponse: {
375
+ data: Buffer.from(JSON.stringify(unified)) // deffa-baileys
376
+ },
377
+ contextInfo: {
378
+ isForwarded: true,
379
+ forwardingScore: 1,
380
+ forwardedAiBotMessageInfo: { botJid: '867051314767696@bot' },
381
+ forwardOrigin: 4
382
+ }
383
+ });
384
+ const message = (0, exports.wrapToBotForwardedMessage)(richResponseMessage);
385
+ const botMetadata = message.messageContextInfo.botMetadata;
386
+ // deffa-baileys
387
+ if (disclaimerText) {
388
+ botMetadata.messageDisclaimerText = disclaimerText;
389
+ }
390
+ // deffa-baileys
391
+ botMetadata.botResponseId = uuid;
392
+ return message;
393
+ };
394
+ exports.prepareRichResponseMessage = prepareRichResponseMessage;
395
+ // deffa-baileys
396
+ const botMetadataSignature = () => {
397
+ const signature = new Uint8Array(64);
398
+ (0, crypto_1.getRandomValues)(signature);
399
+ return signature;
400
+ };
401
+ exports.botMetadataSignature = botMetadataSignature;
402
+ const botMetadataCertificate = (length = 685) => {
403
+ const certificate = new Uint8Array(length);
404
+ certificate[0] = 48;
405
+ certificate[1] = 130;
406
+ (0, crypto_1.getRandomValues)(certificate.subarray(2));
407
+ return certificate;
408
+ };
409
+ exports.botMetadataCertificate = botMetadataCertificate;
410
+ const wrapToBotForwardedMessage = (richResponseMessage) => ({
411
+ messageContextInfo: {
412
+ botMetadata: {
413
+ // deffa-baileys
414
+ verificationMetadata: {
415
+ proofs: [
416
+ {
417
+ certificateChain: [
418
+ (0, exports.botMetadataCertificate)(),
419
+ (0, exports.botMetadataCertificate)(892)
420
+ ],
421
+ version: 1,
422
+ useCase: 1,
423
+ signature: (0, exports.botMetadataSignature)()
424
+ }
425
+ ]
426
+ }
427
+ }
428
+ },
429
+ botForwardedMessage: {
430
+ message: { richResponseMessage }
431
+ }
432
+ });
433
+ exports.wrapToBotForwardedMessage = wrapToBotForwardedMessage;
434
+ //# sourceMappingURL=rich-message-utils.js.map