kage-baileys 25.3.11 → 25.3.13

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 (364) hide show
  1. package/Example/plugins/scarr.mjs +1 -1
  2. package/Example/plugins/unico6.mjs +1 -1
  3. package/extras/Extensions/package.json +3 -0
  4. package/extras/Extensions/rich-carousel.js +1 -1
  5. package/extras/Extensions/rich-classic.js +1 -1
  6. package/extras/index.js +10 -10
  7. package/helpers/package.json +3 -0
  8. package/lib/Defaults/connection.js +49 -108
  9. package/lib/Defaults/constants.js +71 -153
  10. package/lib/Defaults/index.js +0 -199
  11. package/lib/Defaults/media.js +0 -60
  12. package/lib/Defaults/prefix.js +17 -43
  13. package/lib/Modded/message_builder.js +0 -2355
  14. package/lib/Signal/Group/ciphertext-message.js +0 -54
  15. package/lib/Signal/Group/group-session-builder.js +0 -124
  16. package/lib/Signal/Group/group_cipher.js +0 -230
  17. package/lib/Signal/Group/index.js +0 -124
  18. package/lib/Signal/Group/keyhelper.js +0 -108
  19. package/lib/Signal/Group/sender-chain-key.js +0 -88
  20. package/lib/Signal/Group/sender-key-distribution-message.js +0 -157
  21. package/lib/Signal/Group/sender-key-message.js +0 -166
  22. package/lib/Signal/Group/sender-key-name.js +0 -130
  23. package/lib/Signal/Group/sender-key-record.js +0 -122
  24. package/lib/Signal/Group/sender-key-state.js +0 -220
  25. package/lib/Signal/Group/sender-message-key.js +0 -82
  26. package/lib/Signal/libsignal.js +0 -646
  27. package/lib/Signal/lid-mapping.js +0 -537
  28. package/lib/Socket/Client/index.js +0 -60
  29. package/lib/Socket/Client/types.js +0 -51
  30. package/lib/Socket/Client/websocket.js +0 -164
  31. package/lib/Socket/business.js +0 -708
  32. package/lib/Socket/chats.js +0 -2253
  33. package/lib/Socket/communities.js +0 -441
  34. package/lib/Socket/community.js +504 -1019
  35. package/lib/Socket/groups.js +0 -727
  36. package/lib/Socket/messages-recv.js +0 -2780
  37. package/lib/Socket/messages-send.js +0 -2640
  38. package/lib/Socket/mex.js +0 -128
  39. package/lib/Socket/newsletter.js +0 -486
  40. package/lib/Socket/socket.js +0 -1899
  41. package/lib/Store/index.js +0 -68
  42. package/lib/Store/make-cache-manager-store.js +0 -97
  43. package/lib/Store/make-in-memory-store.js +0 -908
  44. package/lib/Store/make-ordered-dictionary.js +0 -187
  45. package/lib/Store/object-repository.js +0 -78
  46. package/lib/Types/Bussines.js +2 -2
  47. package/lib/Types/Chat.js +0 -33
  48. package/lib/Types/Label.js +0 -78
  49. package/lib/Types/LabelAssociation.js +0 -42
  50. package/lib/Types/Message.js +0 -46
  51. package/lib/Types/Mex.js +0 -53
  52. package/lib/Types/MexUpdates.js +16 -43
  53. package/lib/Types/Newsletter.js +0 -27
  54. package/lib/Types/State.js +0 -42
  55. package/lib/Types/index.js +0 -134
  56. package/lib/Utils/auth-utils.js +0 -579
  57. package/lib/Utils/baileys-event-stream.js +65 -142
  58. package/lib/Utils/browser-utils.js +0 -104
  59. package/lib/Utils/business.js +0 -519
  60. package/lib/Utils/chat-utils.js +0 -1702
  61. package/lib/Utils/companion-reg-client-utils.js +0 -45
  62. package/lib/Utils/crypto.js +0 -382
  63. package/lib/Utils/decode-wa-message.js +0 -605
  64. package/lib/Utils/event-buffer.js +0 -1207
  65. package/lib/Utils/generics.js +0 -1020
  66. package/lib/Utils/history.js +0 -231
  67. package/lib/Utils/identity-change-handler.js +0 -59
  68. package/lib/Utils/index.js +0 -133
  69. package/lib/Utils/link-preview.js +0 -228
  70. package/lib/Utils/logger.js +0 -35
  71. package/lib/Utils/lt-hash.js +0 -60
  72. package/lib/Utils/make-mutex.js +0 -110
  73. package/lib/Utils/message-retry-manager.js +0 -429
  74. package/lib/Utils/messages-media.js +0 -1899
  75. package/lib/Utils/messages.js +0 -2950
  76. package/lib/Utils/noise-handler.js +0 -369
  77. package/lib/Utils/offline-node-processor.js +0 -50
  78. package/lib/Utils/pre-key-manager.js +0 -251
  79. package/lib/Utils/process-message.js +0 -1239
  80. package/lib/Utils/reporting-utils.js +0 -268
  81. package/lib/Utils/signal.js +0 -377
  82. package/lib/Utils/stanza-ack.js +0 -48
  83. package/lib/Utils/sync-action-utils.js +0 -58
  84. package/lib/Utils/tc-token-utils.js +0 -28
  85. package/lib/Utils/validate-connection.js +0 -508
  86. package/lib/VoIP/audio-feeder.js +0 -146
  87. package/lib/VoIP/index.js +0 -292
  88. package/lib/VoIP/relay-transport.js +0 -569
  89. package/lib/VoIP/signaling.js +0 -613
  90. package/lib/VoIP/types.js +0 -27
  91. package/lib/VoIP/wasm-engine.js +0 -1222
  92. package/lib/VoIP/worker-bootstrap.js +0 -1785
  93. package/lib/WABinary/constants.js +0 -2639
  94. package/lib/WABinary/decode.js +0 -612
  95. package/lib/WABinary/encode.js +0 -556
  96. package/lib/WABinary/generic-utils.js +0 -272
  97. package/lib/WABinary/index.js +0 -82
  98. package/lib/WABinary/jid-utils.js +0 -262
  99. package/lib/WAM/BinaryInfo.js +0 -50
  100. package/lib/WAM/constants.js +0 -38242
  101. package/lib/WAM/encode.js +0 -396
  102. package/lib/WAM/index.js +0 -78
  103. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +47 -109
  104. package/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -88
  105. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +0 -142
  106. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -85
  107. package/lib/WAUSync/Protocols/USyncLIDProtocol.js +30 -63
  108. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +0 -114
  109. package/lib/WAUSync/Protocols/index.js +0 -82
  110. package/lib/WAUSync/index.js +0 -78
  111. package/lib/assets/wasm/loader.js +0 -13
  112. package/lib/assets/wasm/worker-modules.js +0 -283
  113. package/lib/index.d.ts +483 -41
  114. package/lib/index.js +0 -93
  115. package/package.json +9 -6
  116. package/WAProto/index.d.ts +0 -46
  117. package/lib/Builders/index.d.ts +0 -454
  118. package/lib/Builders/mbuilder/bot-signature.d.ts +0 -22
  119. package/lib/Builders/mbuilder/extras.d.ts +0 -348
  120. package/lib/Builders/mbuilder/html-app.d.ts +0 -19
  121. package/lib/Builders/mbuilder/index.d.ts +0 -221
  122. package/lib/Builders/mbuilder/metaai.d.ts +0 -438
  123. package/lib/Defaults/index.d.ts +0 -145
  124. package/lib/Defaults/index.d.ts.map +0 -1
  125. package/lib/Defaults/index.js.map +0 -1
  126. package/lib/Signal/Group/ciphertext-message.d.ts +0 -10
  127. package/lib/Signal/Group/ciphertext-message.d.ts.map +0 -1
  128. package/lib/Signal/Group/ciphertext-message.js.map +0 -1
  129. package/lib/Signal/Group/group-session-builder.d.ts +0 -8
  130. package/lib/Signal/Group/group-session-builder.d.ts.map +0 -1
  131. package/lib/Signal/Group/group-session-builder.js.map +0 -1
  132. package/lib/Signal/Group/group_cipher.d.ts +0 -11
  133. package/lib/Signal/Group/group_cipher.d.ts.map +0 -1
  134. package/lib/Signal/Group/group_cipher.js.map +0 -1
  135. package/lib/Signal/Group/index.d.ts +0 -12
  136. package/lib/Signal/Group/index.d.ts.map +0 -1
  137. package/lib/Signal/Group/index.js.map +0 -1
  138. package/lib/Signal/Group/keyhelper.d.ts +0 -7
  139. package/lib/Signal/Group/keyhelper.d.ts.map +0 -1
  140. package/lib/Signal/Group/keyhelper.js.map +0 -1
  141. package/lib/Signal/Group/sender-chain-key.d.ts +0 -14
  142. package/lib/Signal/Group/sender-chain-key.d.ts.map +0 -1
  143. package/lib/Signal/Group/sender-chain-key.js.map +0 -1
  144. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -17
  145. package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +0 -1
  146. package/lib/Signal/Group/sender-key-distribution-message.js.map +0 -1
  147. package/lib/Signal/Group/sender-key-message.d.ts +0 -19
  148. package/lib/Signal/Group/sender-key-message.d.ts.map +0 -1
  149. package/lib/Signal/Group/sender-key-message.js.map +0 -1
  150. package/lib/Signal/Group/sender-key-name.d.ts +0 -12
  151. package/lib/Signal/Group/sender-key-name.d.ts.map +0 -1
  152. package/lib/Signal/Group/sender-key-name.js.map +0 -1
  153. package/lib/Signal/Group/sender-key-record.d.ts +0 -13
  154. package/lib/Signal/Group/sender-key-record.d.ts.map +0 -1
  155. package/lib/Signal/Group/sender-key-record.js.map +0 -1
  156. package/lib/Signal/Group/sender-key-state.d.ts +0 -17
  157. package/lib/Signal/Group/sender-key-state.d.ts.map +0 -1
  158. package/lib/Signal/Group/sender-key-state.js.map +0 -1
  159. package/lib/Signal/Group/sender-message-key.d.ts +0 -12
  160. package/lib/Signal/Group/sender-message-key.d.ts.map +0 -1
  161. package/lib/Signal/Group/sender-message-key.js.map +0 -1
  162. package/lib/Signal/libsignal.d.ts +0 -55
  163. package/lib/Signal/libsignal.d.ts.map +0 -1
  164. package/lib/Signal/libsignal.js.map +0 -1
  165. package/lib/Signal/lid-mapping.d.ts +0 -21
  166. package/lib/Signal/lid-mapping.d.ts.map +0 -1
  167. package/lib/Signal/lid-mapping.js.map +0 -1
  168. package/lib/Socket/Client/index.d.ts +0 -3
  169. package/lib/Socket/Client/index.d.ts.map +0 -1
  170. package/lib/Socket/Client/index.js.map +0 -1
  171. package/lib/Socket/Client/types.d.ts +0 -6
  172. package/lib/Socket/Client/types.d.ts.map +0 -1
  173. package/lib/Socket/Client/types.js.map +0 -1
  174. package/lib/Socket/Client/websocket.d.ts +0 -13
  175. package/lib/Socket/Client/websocket.d.ts.map +0 -1
  176. package/lib/Socket/Client/websocket.js.map +0 -1
  177. package/lib/Socket/business.d.ts +0 -395
  178. package/lib/Socket/business.d.ts.map +0 -1
  179. package/lib/Socket/business.js.map +0 -1
  180. package/lib/Socket/chats.d.ts +0 -137
  181. package/lib/Socket/chats.d.ts.map +0 -1
  182. package/lib/Socket/chats.js.map +0 -1
  183. package/lib/Socket/communities.d.ts +0 -562
  184. package/lib/Socket/communities.d.ts.map +0 -1
  185. package/lib/Socket/communities.js.map +0 -1
  186. package/lib/Socket/groups.d.ts +0 -286
  187. package/lib/Socket/groups.d.ts.map +0 -1
  188. package/lib/Socket/groups.js.map +0 -1
  189. package/lib/Socket/index.d.ts +0 -530
  190. package/lib/Socket/index.d.ts.map +0 -1
  191. package/lib/Socket/index.js.map +0 -1
  192. package/lib/Socket/messages-recv.d.ts +0 -334
  193. package/lib/Socket/messages-recv.d.ts.map +0 -1
  194. package/lib/Socket/messages-recv.js.map +0 -1
  195. package/lib/Socket/messages-send.d.ts +0 -330
  196. package/lib/Socket/messages-send.d.ts.map +0 -1
  197. package/lib/Socket/messages-send.js.map +0 -1
  198. package/lib/Socket/mex.d.ts +0 -2
  199. package/lib/Socket/mex.d.ts.map +0 -1
  200. package/lib/Socket/mex.js.map +0 -1
  201. package/lib/Socket/newsletter.d.ts +0 -283
  202. package/lib/Socket/newsletter.d.ts.map +0 -1
  203. package/lib/Socket/newsletter.js.map +0 -1
  204. package/lib/Socket/socket.d.ts +0 -61
  205. package/lib/Socket/socket.d.ts.map +0 -1
  206. package/lib/Socket/socket.js.map +0 -1
  207. package/lib/Store/index.d.ts +0 -4
  208. package/lib/Store/index.d.ts.map +0 -1
  209. package/lib/Store/index.js.map +0 -1
  210. package/lib/Store/make-in-memory-store.d.ts +0 -63
  211. package/lib/Store/make-in-memory-store.d.ts.map +0 -1
  212. package/lib/Store/make-in-memory-store.js.map +0 -1
  213. package/lib/Store/make-ordered-dictionary.d.ts +0 -13
  214. package/lib/Store/make-ordered-dictionary.d.ts.map +0 -1
  215. package/lib/Store/make-ordered-dictionary.js.map +0 -1
  216. package/lib/Store/object-repository.d.ts +0 -11
  217. package/lib/Store/object-repository.d.ts.map +0 -1
  218. package/lib/Store/object-repository.js.map +0 -1
  219. package/lib/Types/Auth.d.ts +0 -2
  220. package/lib/Types/Auth.d.ts.map +0 -1
  221. package/lib/Types/Auth.js.map +0 -1
  222. package/lib/Types/Bussines.d.ts +0 -2
  223. package/lib/Types/Bussines.d.ts.map +0 -1
  224. package/lib/Types/Call.d.ts +0 -2
  225. package/lib/Types/Call.d.ts.map +0 -1
  226. package/lib/Types/Chat.d.ts +0 -2
  227. package/lib/Types/Chat.d.ts.map +0 -1
  228. package/lib/Types/Contact.d.ts +0 -2
  229. package/lib/Types/Contact.d.ts.map +0 -1
  230. package/lib/Types/Events.d.ts +0 -2
  231. package/lib/Types/Events.d.ts.map +0 -1
  232. package/lib/Types/GroupMetadata.d.ts +0 -2
  233. package/lib/Types/GroupMetadata.d.ts.map +0 -1
  234. package/lib/Types/Label.d.ts +0 -3
  235. package/lib/Types/Label.d.ts.map +0 -1
  236. package/lib/Types/LabelAssociation.d.ts +0 -3
  237. package/lib/Types/LabelAssociation.d.ts.map +0 -1
  238. package/lib/Types/Message.d.ts +0 -12
  239. package/lib/Types/Message.d.ts.map +0 -1
  240. package/lib/Types/Mex.d.ts +0 -3
  241. package/lib/Types/Mex.d.ts.map +0 -1
  242. package/lib/Types/Product.d.ts +0 -2
  243. package/lib/Types/Product.d.ts.map +0 -1
  244. package/lib/Types/RichType.d.ts +0 -3
  245. package/lib/Types/RichType.d.ts.map +0 -1
  246. package/lib/Types/Signal.d.ts +0 -2
  247. package/lib/Types/Signal.d.ts.map +0 -1
  248. package/lib/Types/Socket.d.ts +0 -2
  249. package/lib/Types/Socket.d.ts.map +0 -1
  250. package/lib/Types/State.d.ts +0 -6
  251. package/lib/Types/State.d.ts.map +0 -1
  252. package/lib/Types/USync.d.ts +0 -2
  253. package/lib/Types/USync.d.ts.map +0 -1
  254. package/lib/Types/index.d.ts +0 -14
  255. package/lib/Types/index.d.ts.map +0 -1
  256. package/lib/Utils/auth-utils.d.ts +0 -58
  257. package/lib/Utils/auth-utils.d.ts.map +0 -1
  258. package/lib/Utils/auth-utils.js.map +0 -1
  259. package/lib/Utils/browser-utils.d.ts +0 -9
  260. package/lib/Utils/browser-utils.d.ts.map +0 -1
  261. package/lib/Utils/browser-utils.js.map +0 -1
  262. package/lib/Utils/business.d.ts +0 -50
  263. package/lib/Utils/business.d.ts.map +0 -1
  264. package/lib/Utils/business.js.map +0 -1
  265. package/lib/Utils/chat-utils.d.ts +0 -409
  266. package/lib/Utils/chat-utils.d.ts.map +0 -1
  267. package/lib/Utils/chat-utils.js.map +0 -1
  268. package/lib/Utils/companion-reg-client-utils.d.ts +0 -5
  269. package/lib/Utils/companion-reg-client-utils.d.ts.map +0 -1
  270. package/lib/Utils/companion-reg-client-utils.js.map +0 -1
  271. package/lib/Utils/crypto.d.ts +0 -40
  272. package/lib/Utils/crypto.d.ts.map +0 -1
  273. package/lib/Utils/crypto.js.map +0 -1
  274. package/lib/Utils/decode-wa-message.d.ts +0 -84
  275. package/lib/Utils/decode-wa-message.d.ts.map +0 -1
  276. package/lib/Utils/decode-wa-message.js.map +0 -1
  277. package/lib/Utils/event-buffer.d.ts +0 -13
  278. package/lib/Utils/event-buffer.d.ts.map +0 -1
  279. package/lib/Utils/event-buffer.js.map +0 -1
  280. package/lib/Utils/generics.d.ts +0 -71
  281. package/lib/Utils/generics.d.ts.map +0 -1
  282. package/lib/Utils/generics.js.map +0 -1
  283. package/lib/Utils/history.d.ts +0 -76
  284. package/lib/Utils/history.d.ts.map +0 -1
  285. package/lib/Utils/history.js.map +0 -1
  286. package/lib/Utils/identity-change-handler.d.ts +0 -14
  287. package/lib/Utils/identity-change-handler.d.ts.map +0 -1
  288. package/lib/Utils/identity-change-handler.js.map +0 -1
  289. package/lib/Utils/index.d.ts +0 -25
  290. package/lib/Utils/index.d.ts.map +0 -1
  291. package/lib/Utils/index.js.map +0 -1
  292. package/lib/Utils/link-preview.d.ts +0 -13
  293. package/lib/Utils/link-preview.d.ts.map +0 -1
  294. package/lib/Utils/link-preview.js.map +0 -1
  295. package/lib/Utils/logger.d.ts +0 -3
  296. package/lib/Utils/logger.d.ts.map +0 -1
  297. package/lib/Utils/logger.js.map +0 -1
  298. package/lib/Utils/lt-hash.d.ts +0 -7
  299. package/lib/Utils/lt-hash.d.ts.map +0 -1
  300. package/lib/Utils/lt-hash.js.map +0 -1
  301. package/lib/Utils/make-mutex.d.ts +0 -7
  302. package/lib/Utils/make-mutex.d.ts.map +0 -1
  303. package/lib/Utils/make-mutex.js.map +0 -1
  304. package/lib/Utils/message-retry-manager.d.ts +0 -80
  305. package/lib/Utils/message-retry-manager.d.ts.map +0 -1
  306. package/lib/Utils/message-retry-manager.js.map +0 -1
  307. package/lib/Utils/messages-media.d.ts +0 -137
  308. package/lib/Utils/messages-media.d.ts.map +0 -1
  309. package/lib/Utils/messages-media.js.map +0 -1
  310. package/lib/Utils/messages.d.ts +0 -47
  311. package/lib/Utils/messages.d.ts.map +0 -1
  312. package/lib/Utils/messages.js.map +0 -1
  313. package/lib/Utils/noise-handler.d.ts +0 -21
  314. package/lib/Utils/noise-handler.d.ts.map +0 -1
  315. package/lib/Utils/noise-handler.js.map +0 -1
  316. package/lib/Utils/offline-node-processor.d.ts +0 -10
  317. package/lib/Utils/offline-node-processor.d.ts.map +0 -1
  318. package/lib/Utils/offline-node-processor.js.map +0 -1
  319. package/lib/Utils/pre-key-manager.d.ts +0 -26
  320. package/lib/Utils/pre-key-manager.d.ts.map +0 -1
  321. package/lib/Utils/pre-key-manager.js.map +0 -1
  322. package/lib/Utils/process-message.d.ts +0 -84
  323. package/lib/Utils/process-message.d.ts.map +0 -1
  324. package/lib/Utils/process-message.js.map +0 -1
  325. package/lib/Utils/reporting-utils.d.ts +0 -13
  326. package/lib/Utils/reporting-utils.d.ts.map +0 -1
  327. package/lib/Utils/reporting-utils.js.map +0 -1
  328. package/lib/Utils/rich-message-utils.d.ts +0 -49
  329. package/lib/Utils/rich-message-utils.d.ts.map +0 -1
  330. package/lib/Utils/rich-message-utils.js.map +0 -1
  331. package/lib/Utils/signal.d.ts +0 -83
  332. package/lib/Utils/signal.d.ts.map +0 -1
  333. package/lib/Utils/signal.js.map +0 -1
  334. package/lib/Utils/stanza-ack.d.ts +0 -17
  335. package/lib/Utils/stanza-ack.d.ts.map +0 -1
  336. package/lib/Utils/stanza-ack.js.map +0 -1
  337. package/lib/Utils/sync-action-utils.d.ts +0 -3
  338. package/lib/Utils/sync-action-utils.d.ts.map +0 -1
  339. package/lib/Utils/sync-action-utils.js.map +0 -1
  340. package/lib/Utils/tc-token-utils.d.ts +0 -30
  341. package/lib/Utils/tc-token-utils.d.ts.map +0 -1
  342. package/lib/Utils/tc-token-utils.js.map +0 -1
  343. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -11
  344. package/lib/Utils/use-multi-file-auth-state.d.ts.map +0 -1
  345. package/lib/Utils/use-multi-file-auth-state.js.map +0 -1
  346. package/lib/Utils/use-single-file-auth-state.d.ts +0 -11
  347. package/lib/Utils/use-single-file-auth-state.d.ts.map +0 -1
  348. package/lib/Utils/use-single-file-auth-state.js.map +0 -1
  349. package/lib/Utils/use-sqlite-auth-state.d.ts +0 -11
  350. package/lib/Utils/use-sqlite-auth-state.d.ts.map +0 -1
  351. package/lib/Utils/use-sqlite-auth-state.js.map +0 -1
  352. package/lib/Utils/validate-connection.d.ts +0 -44
  353. package/lib/Utils/validate-connection.d.ts.map +0 -1
  354. package/lib/Utils/validate-connection.js.map +0 -1
  355. package/lib/WABinary/constants.d.ts +0 -62
  356. package/lib/WABinary/decode.d.ts +0 -10
  357. package/lib/WABinary/encode.d.ts +0 -3
  358. package/lib/WABinary/generic-utils.d.ts +0 -77
  359. package/lib/WABinary/index.d.ts +0 -6
  360. package/lib/WABinary/jid-utils.d.ts +0 -29
  361. package/lib/WABinary/types.d.ts +0 -2
  362. package/lib/index.d.ts.map +0 -1
  363. package/lib/index.js.map +0 -1
  364. /package/extras/{optional-media.js → optional-media.mjs} +0 -0
@@ -34,645 +34,6 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.makeLibSignalRepository = makeLibSignalRepository;
37
- const libsignal = __importStar(require("libsignal"));
38
-
39
- const Utils_1 = require("../Utils");
40
- const WABinary_1 = require("../WABinary");
41
- const sender_key_name_1 = require("./Group/sender-key-name");
42
- const sender_key_record_1 = require("./Group/sender-key-record");
43
- const Group_1 = require("./Group");
44
- function makeLibSignalRepository(auth) {
45
- const storage = signalStorage(auth);
46
- return {
47
- decryptGroupMessage({ group, authorJid, msg }) {
48
- const senderName = jidToSignalSenderKeyName(group, authorJid);
49
- const cipher = new Group_1.GroupCipher(storage, senderName);
50
- return cipher.decrypt(msg);
51
- },
52
- async processSenderKeyDistributionMessage({ item, authorJid }) {
53
- const builder = new Group_1.GroupSessionBuilder(storage);
54
- if (!item.groupId) {
55
- throw new Error('Group ID is required for sender key distribution message');
56
- }
57
- const senderName = jidToSignalSenderKeyName(item.groupId, authorJid);
58
- const senderMsg = new Group_1.SenderKeyDistributionMessage(null, null, null, null, item.axolotlSenderKeyDistributionMessage);
59
- const senderNameStr = senderName.toString();
60
- const { [senderNameStr]: senderKey } = await auth.keys.get('sender-key', [senderNameStr]);
61
- if (!senderKey) {
62
- await storage.storeSenderKey(senderName, new sender_key_record_1.SenderKeyRecord());
63
- }
64
- await builder.process(senderName, senderMsg);
65
- },
66
- async decryptMessage({ jid, type, ciphertext }) {
67
- const addr = jidToSignalProtocolAddress(jid);
68
- const session = new (require('./session-cipher').ScopedSessionCipher)(storage, addr);
69
- let result;
70
- switch (type) {
71
- case 'pkmsg':
72
- result = await session.decryptPreKeyWhisperMessage(ciphertext);
73
- break;
74
- case 'msg':
75
- result = await session.decryptWhisperMessage(ciphertext);
76
- break;
77
- default:
78
- throw new Error(`Unknown message type: ${type}`);
79
- }
80
- return result;
81
- },
82
- async encryptMessage({ jid, data }) {
83
- const addr = jidToSignalProtocolAddress(jid);
84
- const cipher = new (require('./session-cipher').ScopedSessionCipher)(storage, addr);
85
- const { type: sigType, body } = await cipher.encrypt(data);
86
- const type = sigType === 3 ? 'pkmsg' : 'msg';
87
- return { type, ciphertext: Buffer.from(body, 'binary') };
88
- },
89
- async encryptGroupMessage({ group, meId, data }) {
90
- const senderName = jidToSignalSenderKeyName(group, meId);
91
- const builder = new Group_1.GroupSessionBuilder(storage);
92
- const senderNameStr = senderName.toString();
93
- const { [senderNameStr]: senderKey } = await auth.keys.get('sender-key', [senderNameStr]);
94
- if (!senderKey) {
95
- await storage.storeSenderKey(senderName, new sender_key_record_1.SenderKeyRecord());
96
- }
97
- const senderKeyDistributionMessage = await builder.create(senderName);
98
- const session = new Group_1.GroupCipher(storage, senderName);
99
- const ciphertext = await session.encrypt(data);
100
- return {
101
- ciphertext,
102
- senderKeyDistributionMessage: senderKeyDistributionMessage.serialize()
103
- };
104
- },
105
- async injectE2ESession({ jid, session }) {
106
- const cipher = new libsignal.SessionBuilder(storage, jidToSignalProtocolAddress(jid));
107
- await cipher.initOutgoing(session);
108
- },
109
- jidToSignalProtocolAddress(jid) {
110
- return jidToSignalProtocolAddress(jid).toString();
111
- }
112
- };
113
- }
114
- const jidToSignalProtocolAddress = (jid) => {
115
- const { user, device } = (0, WABinary_1.jidDecode)(jid);
116
- return new libsignal.ProtocolAddress(user, device || 0);
117
- };
118
- const jidToSignalSenderKeyName = (group, user) => {
119
- return new sender_key_name_1.SenderKeyName(group, jidToSignalProtocolAddress(user));
120
- };
121
- function signalStorage({ creds, keys }) {
122
- return {
123
- loadSession: async (id) => {
124
- const { [id]: sess } = await keys.get('session', [id]);
125
- if (sess) {
126
- return libsignal.SessionRecord.deserialize(sess);
127
- }
128
- },
129
- storeSession: async (id, session) => {
130
- await keys.set({ session: { [id]: session.serialize() } });
131
- },
132
- isTrustedIdentity: () => {
133
- return true;
134
- },
135
- loadPreKey: async (id) => {
136
- const keyId = id.toString();
137
- const { [keyId]: key } = await keys.get('pre-key', [keyId]);
138
- if (key) {
139
- return {
140
- privKey: Buffer.from(key.private),
141
- pubKey: Buffer.from(key.public)
142
- };
143
- }
144
- },
145
- removePreKey: (id) => keys.set({ 'pre-key': { [id]: null } }),
146
- loadSignedPreKey: () => {
147
- const key = creds.signedPreKey;
148
- return {
149
- privKey: Buffer.from(key.keyPair.private),
150
- pubKey: Buffer.from(key.keyPair.public)
151
- };
152
- },
153
- loadSenderKey: async (senderKeyName) => {
154
- const keyId = senderKeyName.toString();
155
- const { [keyId]: key } = await keys.get('sender-key', [keyId]);
156
- if (key) {
157
- return sender_key_record_1.SenderKeyRecord.deserialize(key);
158
- }
159
- return new sender_key_record_1.SenderKeyRecord();
160
- },
161
- storeSenderKey: async (senderKeyName, key) => {
162
- const keyId = senderKeyName.toString();
163
- const serialized = JSON.stringify(key.serialize());
164
- await keys.set({ 'sender-key': { [keyId]: Buffer.from(serialized, 'utf-8') } });
165
- },
166
- getOurRegistrationId: () => creds.registrationId,
167
- getOurIdentity: () => {
168
- const { signedIdentityKey } = creds;
169
- return {
170
- privKey: Buffer.from(signedIdentityKey.private),
171
- pubKey: (0, Utils_1.generateSignalPubKey)(signedIdentityKey.public)
172
- };
173
- }
174
- };
175
- }
176
-
177
-
178
- const __kageModule19 = (() => {
179
- const module = { exports: {} }; const exports = module.exports;
180
- "use strict"
181
-
182
- Object.defineProperty(exports, "__esModule", { value: true })
183
-
184
- const {
185
- SessionCipher,
186
- SessionBuilder,
187
- SessionRecord,
188
- ProtocolAddress
189
- } = require("libsignal")
190
- const { generateSignalPubKey } = require("../Utils")
191
- const {
192
- isHostedLidUser,
193
- isHostedPnUser,
194
- isLidUser,
195
- isPnUser,
196
- jidDecode,
197
- transferDevice,
198
- WAJIDDomains
199
- } = require("../WABinary")
200
- const { SenderKeyName } = require("./Group/sender-key-name")
201
- const { SenderKeyRecord } = require("./Group/sender-key-record")
202
- const {
203
- GroupCipher,
204
- GroupSessionBuilder,
205
- SenderKeyDistributionMessage
206
- } = require("./Group")
207
- const { LRUCache } = require("lru-cache")
208
- const { LIDMappingStore } = require("./lid-mapping")
209
-
210
- function makeLibSignalRepository(auth, logger, pnToLIDFunc) {
211
- const lidMapping = new LIDMappingStore(auth.keys, logger, pnToLIDFunc)
212
- const storage = signalStorage(auth, lidMapping)
213
- const parsedKeys = auth.keys
214
- const migratedSessionCache = new LRUCache({
215
- ttl: 3 * 24 * 60 * 60 * 1000,
216
- ttlAutopurge: true,
217
- updateAgeOnGet: true
218
- })
219
-
220
- const repository = {
221
- decryptGroupMessage({ group, authorJid, msg }) {
222
- const senderName = jidToSignalSenderKeyName(group, authorJid)
223
- const cipher = new GroupCipher(storage, senderName)
224
-
225
-
226
- return parsedKeys.transaction(async () => {
227
- return cipher.decrypt(msg)
228
- }, group)
229
- },
230
-
231
- async processSenderKeyDistributionMessage({ item, authorJid }) {
232
- const builder = new GroupSessionBuilder(storage)
233
-
234
- if (!item.groupId) {
235
- throw new Error('Group ID is required for sender key distribution message')
236
- }
237
-
238
- const senderName = jidToSignalSenderKeyName(item.groupId, authorJid)
239
- const senderMsg = new SenderKeyDistributionMessage(null, null, null, null, item.axolotlSenderKeyDistributionMessage)
240
- const senderNameStr = senderName.toString()
241
- const { [senderNameStr]: senderKey } = await auth.keys.get('sender-key', [senderNameStr])
242
-
243
- if (!senderKey) {
244
- await storage.storeSenderKey(senderName, new SenderKeyRecord())
245
- }
246
-
247
- return parsedKeys.transaction(async () => {
248
- const { [senderNameStr]: senderKey } = await auth.keys.get('sender-key', [senderNameStr])
249
-
250
- if (!senderKey) {
251
- await storage.storeSenderKey(senderName, new SenderKeyRecord())
252
- }
253
-
254
- await builder.process(senderName, senderMsg)
255
- }, item.groupId)
256
- },
257
-
258
- async decryptMessage({ jid, type, ciphertext }) {
259
- const addr = jidToSignalProtocolAddress(jid)
260
- const session = new SessionCipher(storage, addr)
261
-
262
- async function doDecrypt() {
263
- let result
264
-
265
- switch (type) {
266
- case 'pkmsg':
267
- result = await session.decryptPreKeyWhisperMessage(ciphertext)
268
- break
269
- case 'msg':
270
- result = await session.decryptWhisperMessage(ciphertext)
271
- break
272
- }
273
-
274
- return result
275
- }
276
-
277
-
278
-
279
- return parsedKeys.transaction(async () => {
280
- return await doDecrypt()
281
- }, jid)
282
- },
283
-
284
- async encryptMessage({ jid, data }) {
285
- const addr = jidToSignalProtocolAddress(jid)
286
- const cipher = new SessionCipher(storage, addr)
287
-
288
-
289
- return parsedKeys.transaction(async () => {
290
- const { type: sigType, body } = await cipher.encrypt(data)
291
- const type = sigType === 3 ? 'pkmsg' : 'msg'
292
-
293
- return { type, ciphertext: Buffer.from(body, 'binary') }
294
- }, jid)
295
- },
296
-
297
- async encryptGroupMessage({ group, meId, data }) {
298
- const senderName = jidToSignalSenderKeyName(group, meId)
299
- const builder = new GroupSessionBuilder(storage)
300
- const senderNameStr = senderName.toString()
301
-
302
- return parsedKeys.transaction(async () => {
303
- const { [senderNameStr]: senderKey } = await auth.keys.get('sender-key', [senderNameStr])
304
-
305
- if (!senderKey) {
306
- await storage.storeSenderKey(senderName, new SenderKeyRecord())
307
- }
308
-
309
- const senderKeyDistributionMessage = await builder.create(senderName)
310
- const session = new GroupCipher(storage, senderName)
311
- const ciphertext = await session.encrypt(data)
312
-
313
- return {
314
- ciphertext,
315
- senderKeyDistributionMessage: senderKeyDistributionMessage.serialize()
316
- }
317
- }, group)
318
- },
319
-
320
- async injectE2ESession({ jid, session }) {
321
- logger.trace({ jid }, 'injecting E2EE session')
322
-
323
- const cipher = new SessionBuilder(storage, jidToSignalProtocolAddress(jid))
324
-
325
- return parsedKeys.transaction(async () => {
326
- await cipher.initOutgoing(session)
327
- }, jid)
328
- },
329
-
330
- jidToSignalProtocolAddress(jid) {
331
- return jidToSignalProtocolAddress(jid).toString()
332
- },
333
-
334
-
335
- lidMapping,
336
-
337
- async validateSession(jid) {
338
- try {
339
- const addr = jidToSignalProtocolAddress(jid)
340
- const session = await storage.loadSession(addr.toString())
341
-
342
- if (!session) {
343
- return { exists: false, reason: 'no session' }
344
- }
345
-
346
- if (!session.haveOpenSession()) {
347
- return { exists: false, reason: 'no open session' }
348
- }
349
-
350
- return { exists: true }
351
- }
352
-
353
- catch (error) {
354
- return { exists: false, reason: 'validation error' }
355
- }
356
- },
357
-
358
- async deleteSession(jids) {
359
- if (!jids.length) return
360
-
361
-
362
- const sessionUpdates = {}
363
-
364
- jids.forEach(jid => {
365
- const addr = jidToSignalProtocolAddress(jid)
366
- sessionUpdates[addr.toString()] = null
367
- })
368
-
369
-
370
- return parsedKeys.transaction(async () => {
371
- await auth.keys.set({ session: sessionUpdates })
372
- }, `delete-${jids.length}-sessions`)
373
- },
374
-
375
- async migrateSession(fromJid, toJid) {
376
-
377
- if (!fromJid || (!isLidUser(toJid) && !isHostedLidUser(toJid))) {
378
- return { migrated: 0, skipped: 0, total: 0 }
379
- }
380
-
381
-
382
- if (!isPnUser(fromJid) && !isHostedPnUser(fromJid)) {
383
- return { migrated: 0, skipped: 0, total: 1 }
384
- }
385
-
386
- const { user } = jidDecode(fromJid)
387
-
388
- logger.debug({ fromJid }, 'bulk device migration - loading all user devices')
389
-
390
-
391
- const { [user]: userDevices } = await parsedKeys.get('device-list', [user])
392
-
393
- if (!userDevices) {
394
- return { migrated: 0, skipped: 0, total: 0 }
395
- }
396
-
397
- const { device: fromDevice } = jidDecode(fromJid)
398
- const fromDeviceStr = fromDevice?.toString() || '0'
399
-
400
- if (!userDevices.includes(fromDeviceStr)) {
401
- userDevices.push(fromDeviceStr)
402
- }
403
-
404
-
405
- const uncachedDevices = userDevices.filter(device => {
406
- const deviceKey = `${user}.${device}`
407
- return !migratedSessionCache.has(deviceKey)
408
- })
409
-
410
-
411
- const deviceSessionKeys = uncachedDevices.map(device => `${user}.${device}`)
412
- const existingSessions = await parsedKeys.get('session', deviceSessionKeys)
413
-
414
-
415
- const deviceJids = []
416
-
417
- for (const [sessionKey, sessionData] of Object.entries(existingSessions)) {
418
- if (sessionData) {
419
-
420
- const deviceStr = sessionKey.split('.')[1]
421
-
422
- if (!deviceStr) continue
423
-
424
- const deviceNum = parseInt(deviceStr)
425
-
426
- let jid = deviceNum === 0 ? `${user}@s.whatsapp.net` : `${user}:${deviceNum}@s.whatsapp.net`
427
-
428
- if (deviceNum === 99) {
429
- jid = `${user}:99@hosted`
430
- }
431
-
432
- deviceJids.push(jid)
433
- }
434
- }
435
-
436
- logger.debug({
437
- fromJid,
438
- totalDevices: userDevices.length,
439
- devicesWithSessions: deviceJids.length,
440
- devices: deviceJids
441
- }, 'bulk device migration complete - all user devices processed')
442
-
443
-
444
- return parsedKeys.transaction(async () => {
445
- const migrationOps = deviceJids.map(jid => {
446
- const lidWithDevice = transferDevice(jid, toJid)
447
- const fromDecoded = jidDecode(jid)
448
- const toDecoded = jidDecode(lidWithDevice)
449
-
450
- return {
451
- fromJid: jid,
452
- toJid: lidWithDevice,
453
- pnUser: fromDecoded.user,
454
- lidUser: toDecoded.user,
455
- deviceId: fromDecoded.device || 0,
456
- fromAddr: jidToSignalProtocolAddress(jid),
457
- toAddr: jidToSignalProtocolAddress(lidWithDevice)
458
- }
459
- })
460
-
461
- const totalOps = migrationOps.length
462
-
463
- let migratedCount = 0
464
-
465
-
466
- const pnAddrStrings = Array.from(new Set(migrationOps.map(op => op.fromAddr.toString())))
467
- const pnSessions = await parsedKeys.get('session', pnAddrStrings)
468
-
469
-
470
- const sessionUpdates = {}
471
-
472
- for (const op of migrationOps) {
473
- const pnAddrStr = op.fromAddr.toString()
474
- const lidAddrStr = op.toAddr.toString()
475
- const pnSession = pnSessions[pnAddrStr]
476
-
477
- if (pnSession) {
478
-
479
- const fromSession = SessionRecord.deserialize(pnSession)
480
-
481
- if (fromSession.haveOpenSession()) {
482
-
483
- sessionUpdates[lidAddrStr] = fromSession.serialize()
484
- sessionUpdates[pnAddrStr] = null
485
- migratedCount++
486
- }
487
- }
488
- }
489
-
490
-
491
- if (Object.keys(sessionUpdates).length > 0) {
492
- await parsedKeys.set({ session: sessionUpdates })
493
-
494
- logger.debug({ migratedSessions: migratedCount }, 'bulk session migration complete')
495
-
496
-
497
- for (const op of migrationOps) {
498
- if (sessionUpdates[op.toAddr.toString()]) {
499
- const deviceKey = `${op.pnUser}.${op.deviceId}`
500
- migratedSessionCache.set(deviceKey, true)
501
- }
502
- }
503
- }
504
-
505
- const skippedCount = totalOps - migratedCount
506
-
507
- return { migrated: migratedCount, skipped: skippedCount, total: totalOps }
508
- }, `migrate-${deviceJids.length}-sessions-${jidDecode(toJid)?.user}`)
509
- }
510
- }
511
-
512
- return repository
513
- }
514
-
515
- const jidToSignalProtocolAddress = (jid) => {
516
- const decoded = jidDecode(jid)
517
- const { user, device, server, domainType } = decoded
518
-
519
- if (!user) {
520
- throw new Error(`JID decoded but user is empty: "${jid}" -> user: "${user}", server: "${server}", device: ${device}`)
521
- }
522
-
523
- const signalUser = domainType !== WAJIDDomains.WHATSAPP ? `${user}_${domainType}` : user
524
- const finalDevice = device || 0
525
-
526
- if (device === 99 && decoded.server !== 'hosted' && decoded.server !== 'hosted.lid') {
527
- throw new Error('Unexpected non-hosted device JID with device 99. This ID seems invalid. ID:' + jid)
528
- }
529
-
530
- return new ProtocolAddress(signalUser, finalDevice)
531
- }
532
-
533
- const jidToSignalSenderKeyName = (group, user) => {
534
- return new SenderKeyName(group, jidToSignalProtocolAddress(user))
535
- }
536
-
537
- function signalStorage({ creds, keys }, lidMapping) {
538
-
539
- const resolveLIDSignalAddress = async (id) => {
540
- if (id.includes('.')) {
541
- const [deviceId, device] = id.split('.')
542
- const [user, domainType_] = deviceId.split('_')
543
- const domainType = parseInt(domainType_ || '0')
544
-
545
- if (domainType === WAJIDDomains.LID || domainType === WAJIDDomains.HOSTED_LID) return id
546
-
547
- const pnJid = `${user}${device !== '0' ? `:${device}` : ''}@${domainType === WAJIDDomains.HOSTED ? 'hosted' : 's.whatsapp.net'}`
548
- const lidForPN = await lidMapping.getLIDForPN(pnJid)
549
-
550
- if (lidForPN) {
551
- const lidAddr = jidToSignalProtocolAddress(lidForPN)
552
- return lidAddr.toString()
553
- }
554
- }
555
-
556
- return id
557
- }
558
-
559
- return {
560
- loadSession: async (id) => {
561
- try {
562
- const wireJid = await resolveLIDSignalAddress(id)
563
- const { [wireJid]: sess } = await keys.get('session', [wireJid])
564
-
565
- if (sess) {
566
- return SessionRecord.deserialize(sess)
567
- }
568
- }
569
-
570
- catch (e) {
571
- return null
572
- }
573
-
574
- return null
575
- },
576
- storeSession: async (id, session) => {
577
- const wireJid = await resolveLIDSignalAddress(id)
578
- await keys.set({ session: { [wireJid]: session.serialize() } })
579
- },
580
- isTrustedIdentity: () => {
581
- return true
582
- },
583
- loadPreKey: async (id) => {
584
- const keyId = id.toString()
585
- const { [keyId]: key } = await keys.get('pre-key', [keyId])
586
-
587
- if (key) {
588
- return {
589
- privKey: Buffer.from(key.private),
590
- pubKey: Buffer.from(key.public)
591
- }
592
- }
593
- },
594
- removePreKey: (id) => keys.set({ 'pre-key': { [id]: null } }),
595
- loadSignedPreKey: () => {
596
- const key = creds.signedPreKey
597
- return {
598
- privKey: Buffer.from(key.keyPair.private),
599
- pubKey: Buffer.from(key.keyPair.public)
600
- }
601
- },
602
- loadSenderKey: async (senderKeyName) => {
603
- const keyId = senderKeyName.toString()
604
- const { [keyId]: key } = await keys.get('sender-key', [keyId])
605
-
606
- if (key) {
607
- return SenderKeyRecord.deserialize(key)
608
- }
609
-
610
- return new SenderKeyRecord()
611
- },
612
- storeSenderKey: async (senderKeyName, key) => {
613
- const keyId = senderKeyName.toString()
614
- const serialized = JSON.stringify(key.serialize())
615
- await keys.set({ 'sender-key': { [keyId]: Buffer.from(serialized, 'utf-8') } })
616
- },
617
- getOurRegistrationId: () => creds.registrationId,
618
- getOurIdentity: () => {
619
- const { signedIdentityKey } = creds
620
- return {
621
- privKey: Buffer.from(signedIdentityKey.private),
622
- pubKey: Buffer.from(generateSignalPubKey(signedIdentityKey.public))
623
- }
624
- }
625
- }
626
- }
627
-
628
- module.exports = {
629
- makeLibSignalRepository
630
- }
631
- return module.exports;
632
- })();
633
- for (const key of Object.keys(__kageModule19)) {
634
- if (key !== '__esModule' && !Object.prototype.hasOwnProperty.call(exports,key)) Object.defineProperty(exports,key,{enumerable:true,configurable:true,get:()=>__kageModule19[key]});
635
- }
636
-
637
-
638
- const __kageModule125 = (() => {
639
- const module = { exports: {} }; const exports = module.exports;
640
- "use strict";
641
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
642
- if (k2 === undefined) k2 = k;
643
- var desc = Object.getOwnPropertyDescriptor(m, k);
644
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
645
- desc = { enumerable: true, get: function() { return m[k]; } };
646
- }
647
- Object.defineProperty(o, k2, desc);
648
- }) : (function(o, m, k, k2) {
649
- if (k2 === undefined) k2 = k;
650
- o[k2] = m[k];
651
- }));
652
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
653
- Object.defineProperty(o, "default", { enumerable: true, value: v });
654
- }) : function(o, v) {
655
- o["default"] = v;
656
- });
657
- var __importStar = (this && this.__importStar) || (function () {
658
- var ownKeys = function(o) {
659
- ownKeys = Object.getOwnPropertyNames || function (o) {
660
- var ar = [];
661
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
662
- return ar;
663
- };
664
- return ownKeys(o);
665
- };
666
- return function (mod) {
667
- if (mod && mod.__esModule) return mod;
668
- var result = {};
669
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
670
- __setModuleDefault(result, mod);
671
- return result;
672
- };
673
- })();
674
- Object.defineProperty(exports, "__esModule", { value: true });
675
- exports.makeLibSignalRepository = makeLibSignalRepository;
676
37
 
677
38
  const libsignal = __importStar(require("libsignal"));
678
39
 
@@ -1101,10 +462,3 @@ function signalStorage({ creds, keys }, lidMapping) {
1101
462
  }
1102
463
  };
1103
464
  }
1104
-
1105
- return module.exports;
1106
- })();
1107
- for (const key of Object.keys(__kageModule125)) {
1108
- if (key !== '__esModule' && !Object.prototype.hasOwnProperty.call(exports,key)) Object.defineProperty(exports,key,{enumerable:true,configurable:true,get:()=>__kageModule125[key]});
1109
- }
1110
- Object.defineProperty(exports, Symbol.for('kage.advanced'), {value:__kageModule125, configurable:true});