lordceaser-baileys 2.0.44 → 2.0.45

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 (414) hide show
  1. package/.config/termux/termux.properties +93 -0
  2. package/.npm/_cacache/content-v2/sha512/04/c1/a4e7841f265bfe9f6fe9a54ab0ad4aeb9b54bd69bca81fdbbfea32d6d40c87aa5c2c41967e3a9f8123e262e7214a19d37901846c59469ea1677b55e684a9 +0 -0
  3. package/.npm/_cacache/content-v2/sha512/0b/a3/5a59681982082a029c734428c8a506498026e269f0ed34013289b90252b86b220a3a908c9c04d93fcb85920bdea9e683bbf31bad37f3b9254aa872e85b7f +0 -0
  4. package/.npm/_cacache/content-v2/sha512/20/35/fc243b2c2a9a80464ab551328ec56f509a871f11b7d5fe7e868a0352e506e6f7bc3cfd6c7950319465ade091dfd2cc96907473ded8ac564122a7ce498b53 +0 -0
  5. package/.npm/_cacache/content-v2/sha512/22/73/7c1e7e6ec12797b37b0c597eaceda7555b5e8fd41919a12b56ecc9860598035686f36d21ea3db9d5688503aaf749e9d67fbb16aec859e2d23d9ad33ac67b +0 -0
  6. package/.npm/_cacache/content-v2/sha512/24/3c/ee06d20f46237ea4d4bfd6bb9c69f13feafc5418c5eaf430f43f8852167ccd8fa9f26424c9c7f147b887f4f620f82d46efabbd72ae4c101da391f71f8edb +1 -0
  7. package/.npm/_cacache/content-v2/sha512/29/0c/2bba6b33fe70f1a950d25a3903dd04c749bb27cbd41382d4f5d441cdbbda6543c34b6d1ef2ae6d2d954700504b4e0e29c84d696e84e77963cc7b2711a875 +0 -0
  8. package/.npm/_cacache/content-v2/sha512/2a/21/dae896cf66eb9870a007d150043dad671ce5f482fbefb0863a43828485b268c66e693543170f5a2aafcc5da2c8f2930687bf33b6db1f922e91e4142a8193 +0 -0
  9. package/.npm/_cacache/content-v2/sha512/37/83/9b4665deb8302bf5aaa82fa78783905989fd75bec5f816e2304b802b748bf79ecdc74aa1509382e4f59239ac222fd3b4dd9f8392d9418271b0b173dbcdef +0 -0
  10. package/.npm/_cacache/content-v2/sha512/3c/dd/f5c709ac93d5d28176bb22eac5fe9768a4d65a4bd32e7582eeb52441dc37d523aeb98298a4811bac4aef443697baad357222b43e7e64428dd41c8d678077 +1 -0
  11. package/.npm/_cacache/content-v2/sha512/3d/f1/8c78f26f9f6c3e6ee52575646a2056be786be69af1ea9ebeb9d77469e7cb051fba4841e56b1807adcbf65f27ca2796b8adcf4e7089827e259657e300608b +1 -0
  12. package/.npm/_cacache/content-v2/sha512/47/ef/cb5c9061fda45ebd1ed0aaadda4d661c8be0c479e94d120d63af7b129798a88b693253ba610571b6ff20eae1a14e3b0f8363a036c9f1cb9d3dbcd7cd1f71 +0 -0
  13. package/.npm/_cacache/content-v2/sha512/4c/8a/efe49c399567eeaba40b14247a4c7d6588cc1de5ddcc1f88f5ad4e2b1b9694b78bb65902b30c9f10dc1ca808dcaa0c60aa7cb7e3c725111ebf5f4b9ac529 +0 -0
  14. package/.npm/_cacache/content-v2/sha512/54/68/a908e1bb5cc1db3cff8bc90472ae7118b5c6a5285ff62561a4b2a182bc034181a49b459e3cf32007e5cb7f9be831e7b030e175f2c12cf7d3677753bb69a2 +1 -0
  15. package/.npm/_cacache/content-v2/sha512/57/cf/309075d2cb07d593b16e2a3b23c2363cadfd229f427d85c045f3acc02b2b7da77cd140c4f7d57ae6a2b5919735ed66edd399b092a945f5b980b8a63fcbd9 +0 -0
  16. package/.npm/_cacache/content-v2/sha512/58/af/97f23bbc4cf1b1bd622c3fc86b63a241e8596d62e15efafb2a29f8ce617db924e6e28fda8b7f6737646765d50faf845c1b9d3f80666580079a53bf399289 +0 -0
  17. package/.npm/_cacache/content-v2/sha512/5b/f7/540d2b39e21c9ecf170959f9c18ca5e7f621eb1571ba4fa300fe6ea63580a5a0a305dbf0ce8574da6a26632ce85ce52bbcc266037c316d66aa192a0857d5 +1 -0
  18. package/.npm/_cacache/content-v2/sha512/66/4b/a28bc36c0530eb895a9a959bbaae66575de84c89df21aca17d2eb489c28aee2cb91d1d6c77485e64559432b56d29ffc806ebacfa5db95566772d7ca7465f +1 -0
  19. package/.npm/_cacache/content-v2/sha512/66/c4/64f2f76e6fd3cb6a54e920e1e93cc53157369a91e857de5e798c60c0c5172a27bdf274ee4dae740cb5f1862b9e6a898042191f09d31c5ad52edd73fa33ff +1 -0
  20. package/.npm/_cacache/content-v2/sha512/73/6b/d03ab18788acb29bd3bf637768d856fd5b6cbccdd37ffb7803377b3cebcaba945f9607a8709ddfe861b72f3b4ade73b16ce27c709d819a4dbd4ebd475658 +1 -0
  21. package/.npm/_cacache/content-v2/sha512/7a/67/1a898325808e983d393b84bd443a7657c1f36e162183bf34172f9abd0d5b1fd0fbfa2287dbccbdacd4abbba6f9fab0896d9434ef74ceaae2edf5188690b5 +0 -0
  22. package/.npm/_cacache/content-v2/sha512/7c/6c/acda26ea37960abbac8daf0dc259216b34de0836e8faf83e4a269f74a04128670c50fb2981c71a7726d2d423146e6a47b30cae5d2ee8e793180e519e9b82 +0 -0
  23. package/.npm/_cacache/content-v2/sha512/8c/3d/876af61c79649c1d86d2299ac45fefa179121f2812dc0a499a2c06a428908548b9d0ceec8061ad58d019aac076b36edfdd929446b71dba10e2deaf3dfa9a +0 -0
  24. package/.npm/_cacache/content-v2/sha512/8d/a3/711cecf3a6a634044b80dafc79b6134acc922a7daac6c14e4154acfd722de7081b4dc0e22ac64ed88011d71da2473b4ccea3cac3016fb76e6c13a8eb9b9e +1 -0
  25. package/.npm/_cacache/content-v2/sha512/8e/aa/0a70ad0558990da15ecebd28f985958aab0e259f64e8577cf2c5c73becffe2eb6dc263596ecc7fb2fb772d60473a6ced55a54e01499f1a9c010b9d5a01fd +0 -0
  26. package/.npm/_cacache/content-v2/sha512/90/c2/06ad3d753ea8d354b394aad2564854dd666b02015a94a5a400ac88edecd6e54971f151b2f4210db7f5636ae0798af1f1f1a3414bf76e9f5c18a3f0c7f0b6 +1 -0
  27. package/.npm/_cacache/content-v2/sha512/9b/db/aa56b4b8f6fcc1cc6f053cf817074faf1c2690a766010dc449333a7a97d1450b7a1d6897d1893b743b8cc691c8aa8ea79978f26f3ebde0422cff03640da2 +1 -0
  28. package/.npm/_cacache/content-v2/sha512/9e/c9/9cb8ab874a8339e8708d042bc137954989a36626c0571ff5892584ddff80e2119bafeac5b4dca6d86828094cd44677c91ab7e6cdad87df7e2adc75325192 +0 -0
  29. package/.npm/_cacache/content-v2/sha512/a6/89/9732c9fc52a3280dacd7ee6e004fd91387d37ee89108a504626ced30ef0ea07a8aadb1a98c9d0a00d8027d93c45a27618df5056c6313a692b35c0fe10944 +1 -0
  30. package/.npm/_cacache/content-v2/sha512/a7/44/329d9218fd6175ac0c2230440a12724490ff182d5197013c2d6244055b4e55bd0b2c07fb7261cc41f31158ed4cee7d0e0befc05570b8f922dcf54b2a4edc +0 -0
  31. package/.npm/_cacache/content-v2/sha512/b8/e1/efd9fbf933c2c182d8b03f2a33f534b5504fc165f8edd1f16c40b74f79bf98a84d6c5d72e8664334dc7659f251e3517bdd4ddf828e0cb37270fc1a60fd43 +0 -0
  32. package/.npm/_cacache/content-v2/sha512/bf/c9/1f9299906c9492fc030237160a31e7fb0d11ba3042633753fa455978caa5367c233468c20b9ed65d26c233eeea5c5ef712b2f235c00074b4398600c9bb1c +1 -0
  33. package/.npm/_cacache/content-v2/sha512/c6/f4/30d5cb38d2070b009f5d84e2dada84c4c4da89ae90eacde848245f37060ff8449da4723260d891f1dc0b3d724d14ac321d3034d9074783fa85f7db932ace +1 -0
  34. package/.npm/_cacache/content-v2/sha512/d4/4c/cb7a4b9ead8f4471be9d920502d7873ef23e1332fd17436e526e7521e2836c9fdc35087f9f07b4d2939e41eeab23f8037df069f171b350eaf5b152c43115 +1 -0
  35. package/.npm/_cacache/content-v2/sha512/d6/83/50e4d5d8b865cbbdf848ec204d8bd5517f64d087f161ff3d2f34fcd920874a429f89b95cafc56f46361deab826f461017ab0b895d8fa03c1adb9ed4c0e60 +0 -0
  36. package/.npm/_cacache/content-v2/sha512/d9/ed/e3f8b8857a8b8d92cb2f28481d2a56717cb2bd4aa2631ea9ff4dec090fb342efbcf93016fe0952910a712a273a9f4ffe5dd34a0a1cf2b7239edc44579483 +0 -0
  37. package/.npm/_cacache/content-v2/sha512/da/b6/070676fc8aa90dbee81b1e5a83bd1ed9136c538f5f217c8355a11a17752bee79fcf462cfcc2cf6183c828a18279ec278a2d837d358fc7ca0c553dfdab497 +1 -0
  38. package/.npm/_cacache/content-v2/sha512/e8/22/d4998efd23d8f8621fcdb60fbb615764fa41b8ea774e79d0d4cb2e30b6813c0e59030da2b5d7ee65fdd7f0b2556e098570d0dc0bde672c72f79d12596ad3 +0 -0
  39. package/.npm/_cacache/content-v2/sha512/ed/a7/d3bdd0c3cf779e22b5ddd73fe6d9848de5e8512d2b471651ee4c19afd50a3fda580481ba12aa0b41be1dfed6c589a60ea926bb307f6576a027d266bf2f28 +1 -0
  40. package/.npm/_cacache/content-v2/sha512/f3/69/13ba2896e217ed93824f71f86156975a0caee79b4c9036f5564332a37295b29213259c83042550b80960a17c4686cf08c9cf37b24cc71f285385bd03f6cc +0 -0
  41. package/.npm/_cacache/content-v2/sha512/fd/13/9f593b1e80be64fe9a7846e8fcb2500274dc00790b52301fd9482fe81779f6c13c662cc383cf642ec186cabce628e19abf9fdb35878ea93f786201409ed9 +0 -0
  42. package/.npm/_cacache/index-v5/79/9d/b9f2c9dde37f046c31b4e9c79fa005adfac128c0dd4f9acbb5a26ee6f2be +2 -0
  43. package/.npm/_cacache/index-v5/a4/cd/47e4f02a3bf5cdf2f503e2480fa63df8b51052feacb7cb3829a97ea24697 +7 -0
  44. package/.npm/_cacache/index-v5/b0/83/0c92634a1fd78bb963be6f3f094ec034e6c2612c76ec4c728330ce206907 +2 -0
  45. package/.npm/_cacache/index-v5/e0/f3/563a92774ad5fa62edb9cbc4624c17a784676e377b3852d16ab8dcb28bea +4 -0
  46. package/.npm/_cacache/index-v5/ed/a3/bb067b3296c94f40818cac61184db5090e511ef596b7b166aab2d9b18f59 +22 -0
  47. package/.npm/_cacache/index-v5/f0/7e/c8d04191b7c9f8f2c3a06807c6d03e683ee6da6a0775b23812fa291d9f04 +3 -0
  48. package/.npm/_cacache/index-v5/f6/34/73eefb1f7f68d405e4bb8568fe273a8354fa103495303a0ff74fb4167cf6 +3 -0
  49. package/.npm/_logs/2026-09-11T07_46_36_034Z-debug-0.log +191 -0
  50. package/.npm/_logs/2026-09-11T07_47_53_565Z-debug-0.log +193 -0
  51. package/.npm/_logs/2026-09-11T07_48_05_542Z-debug-0.log +193 -0
  52. package/.npm/_logs/2026-09-11T07_48_23_626Z-debug-0.log +202 -0
  53. package/.npm/_logs/2026-09-11T07_49_09_747Z-debug-0.log +20 -0
  54. package/.npm/_logs/2026-09-11T07_49_11_150Z-debug-0.log +193 -0
  55. package/.npm/_logs/2026-09-11T07_49_18_210Z-debug-0.log +197 -0
  56. package/.npm/_logs/2026-09-11T12_37_02_183Z-debug-0.log +190 -0
  57. package/.npm/_logs/2026-09-11T12_37_10_268Z-debug-0.log +19 -0
  58. package/.npm/_logs/2026-09-11T12_37_11_707Z-debug-0.log +579 -0
  59. package/.npm/_logs/2026-09-11T12_37_23_100Z-debug-0.log +14 -0
  60. package/.npm/_update-notifier-last-checked +0 -0
  61. package/.ssh/authorized_keys +0 -0
  62. package/C4-Society/node_modules/lordceaser-baileys/index.js +192 -0
  63. package/C4-Society/node_modules/lordceaser-baileys/package.json +42 -0
  64. package/WAProto/GenerateStatics.sh +4 -0
  65. package/WAProto/WAProto.proto +3344 -0
  66. package/WAProto/index.d.ts +37016 -0
  67. package/WAProto/index.js +101044 -0
  68. package/index.js +414 -52
  69. package/lordceaser-baileys/.editorconfig +5 -0
  70. package/lordceaser-baileys/.gitattributes +2 -0
  71. package/lordceaser-baileys/.github/FUNDING.yml +1 -0
  72. package/lordceaser-baileys/.github/ISSUE_TEMPLATE/bug_report.md +29 -0
  73. package/lordceaser-baileys/.github/ISSUE_TEMPLATE/config.yml +4 -0
  74. package/lordceaser-baileys/.github/ISSUE_TEMPLATE/feature-requests.md +15 -0
  75. package/lordceaser-baileys/.github/README.md +64 -0
  76. package/lordceaser-baileys/.github/workflows/build.yml +40 -0
  77. package/lordceaser-baileys/.github/workflows/e2e.yml +72 -0
  78. package/lordceaser-baileys/.github/workflows/lint.yml +40 -0
  79. package/lordceaser-baileys/.github/workflows/manual-release.yml +49 -0
  80. package/lordceaser-baileys/.github/workflows/pr-comment.yml +53 -0
  81. package/lordceaser-baileys/.github/workflows/publish-release.yml +88 -0
  82. package/lordceaser-baileys/.github/workflows/stale.yml +21 -0
  83. package/lordceaser-baileys/.github/workflows/test.yml +41 -0
  84. package/lordceaser-baileys/.github/workflows/update-proto.yml +64 -0
  85. package/lordceaser-baileys/.github/workflows/update-version.yml +88 -0
  86. package/lordceaser-baileys/.prettierignore +9 -0
  87. package/lordceaser-baileys/.prettierrc +11 -0
  88. package/lordceaser-baileys/.release-it.yml +14 -0
  89. package/lordceaser-baileys/.yarnrc.yml +1 -0
  90. package/lordceaser-baileys/AGENTS.md +303 -0
  91. package/lordceaser-baileys/CHANGELOG.md +4 -0
  92. package/lordceaser-baileys/CLAUDE.md +9 -0
  93. package/lordceaser-baileys/CODE_OF_CONDUCT.md +100 -0
  94. package/lordceaser-baileys/Example/example.ts +235 -0
  95. package/lordceaser-baileys/Media/cat.jpeg +0 -0
  96. package/lordceaser-baileys/Media/icon.png +0 -0
  97. package/lordceaser-baileys/Media/logo.png +0 -0
  98. package/lordceaser-baileys/Media/ma_gif.mp4 +0 -0
  99. package/lordceaser-baileys/Media/meme.jpeg +0 -0
  100. package/lordceaser-baileys/Media/octopus.webp +0 -0
  101. package/lordceaser-baileys/Media/sonata.mp3 +0 -0
  102. package/lordceaser-baileys/SECURITY.md +78 -0
  103. package/lordceaser-baileys/docs/.nojekyll +1 -0
  104. package/lordceaser-baileys/docs/404.html +16 -0
  105. package/lordceaser-baileys/docs/index.html +16 -0
  106. package/lordceaser-baileys/engine-requirements.js +10 -0
  107. package/lordceaser-baileys/eslint.config.mts +75 -0
  108. package/lordceaser-baileys/index.js +55 -0
  109. package/lordceaser-baileys/jest.config.ts +43 -0
  110. package/lordceaser-baileys/lib/Defaults/baileys-version.json +3 -0
  111. package/lordceaser-baileys/lib/Defaults/index.d.ts +283 -0
  112. package/lordceaser-baileys/lib/Defaults/index.js +121 -0
  113. package/lordceaser-baileys/lib/Defaults/phonenumber-mcc.json +223 -0
  114. package/lordceaser-baileys/lib/Signal/libsignal.d.ts +3 -0
  115. package/lordceaser-baileys/lib/Signal/libsignal.js +152 -0
  116. package/lordceaser-baileys/lib/Socket/Client/abstract-socket-client.d.ts +17 -0
  117. package/lordceaser-baileys/lib/Socket/Client/abstract-socket-client.js +13 -0
  118. package/lordceaser-baileys/lib/Socket/Client/index.d.ts +3 -0
  119. package/lordceaser-baileys/lib/Socket/Client/index.js +19 -0
  120. package/lordceaser-baileys/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  121. package/lordceaser-baileys/lib/Socket/Client/mobile-socket-client.js +65 -0
  122. package/lordceaser-baileys/lib/Socket/Client/web-socket-client.d.ts +12 -0
  123. package/lordceaser-baileys/lib/Socket/Client/web-socket-client.js +62 -0
  124. package/lordceaser-baileys/lib/Socket/business.d.ts +148 -0
  125. package/lordceaser-baileys/lib/Socket/business.js +260 -0
  126. package/lordceaser-baileys/lib/Socket/chats.d.ts +83 -0
  127. package/lordceaser-baileys/lib/Socket/chats.js +879 -0
  128. package/lordceaser-baileys/lib/Socket/groups.d.ts +123 -0
  129. package/lordceaser-baileys/lib/Socket/groups.js +314 -0
  130. package/lordceaser-baileys/lib/Socket/index.d.ts +150 -0
  131. package/lordceaser-baileys/lib/Socket/index.js +10 -0
  132. package/lordceaser-baileys/lib/Socket/messages-recv.d.ts +135 -0
  133. package/lordceaser-baileys/lib/Socket/messages-recv.js +867 -0
  134. package/lordceaser-baileys/lib/Socket/messages-send.d.ts +128 -0
  135. package/lordceaser-baileys/lib/Socket/messages-send.js +677 -0
  136. package/lordceaser-baileys/lib/Socket/registration.d.ts +242 -0
  137. package/lordceaser-baileys/lib/Socket/registration.js +166 -0
  138. package/lordceaser-baileys/lib/Socket/socket.d.ts +43 -0
  139. package/lordceaser-baileys/lib/Socket/socket.js +619 -0
  140. package/lordceaser-baileys/lib/Store/index.d.ts +3 -0
  141. package/lordceaser-baileys/lib/Store/index.js +10 -0
  142. package/lordceaser-baileys/lib/Store/make-cache-manager-store.d.ts +14 -0
  143. package/lordceaser-baileys/lib/Store/make-cache-manager-store.js +83 -0
  144. package/lordceaser-baileys/lib/Store/make-in-memory-store.d.ts +118 -0
  145. package/lordceaser-baileys/lib/Store/make-in-memory-store.js +422 -0
  146. package/lordceaser-baileys/lib/Store/make-ordered-dictionary.d.ts +13 -0
  147. package/lordceaser-baileys/lib/Store/make-ordered-dictionary.js +81 -0
  148. package/lordceaser-baileys/lib/Store/object-repository.d.ts +10 -0
  149. package/lordceaser-baileys/lib/Store/object-repository.js +27 -0
  150. package/lordceaser-baileys/lib/Types/Auth.d.ts +110 -0
  151. package/lordceaser-baileys/lib/Types/Auth.js +2 -0
  152. package/lordceaser-baileys/lib/Types/Call.d.ts +13 -0
  153. package/lordceaser-baileys/lib/Types/Call.js +2 -0
  154. package/lordceaser-baileys/lib/Types/Chat.d.ts +107 -0
  155. package/lordceaser-baileys/lib/Types/Chat.js +4 -0
  156. package/lordceaser-baileys/lib/Types/Contact.d.ts +19 -0
  157. package/lordceaser-baileys/lib/Types/Contact.js +2 -0
  158. package/lordceaser-baileys/lib/Types/Events.d.ts +172 -0
  159. package/lordceaser-baileys/lib/Types/Events.js +2 -0
  160. package/lordceaser-baileys/lib/Types/GroupMetadata.d.ts +56 -0
  161. package/lordceaser-baileys/lib/Types/GroupMetadata.js +2 -0
  162. package/lordceaser-baileys/lib/Types/Label.d.ts +46 -0
  163. package/lordceaser-baileys/lib/Types/Label.js +27 -0
  164. package/lordceaser-baileys/lib/Types/LabelAssociation.d.ts +29 -0
  165. package/lordceaser-baileys/lib/Types/LabelAssociation.js +9 -0
  166. package/lordceaser-baileys/lib/Types/Message.d.ts +268 -0
  167. package/lordceaser-baileys/lib/Types/Message.js +9 -0
  168. package/lordceaser-baileys/lib/Types/Product.d.ts +78 -0
  169. package/lordceaser-baileys/lib/Types/Product.js +2 -0
  170. package/lordceaser-baileys/lib/Types/Signal.d.ts +57 -0
  171. package/lordceaser-baileys/lib/Types/Signal.js +2 -0
  172. package/lordceaser-baileys/lib/Types/Socket.d.ts +116 -0
  173. package/lordceaser-baileys/lib/Types/Socket.js +2 -0
  174. package/lordceaser-baileys/lib/Types/State.d.ts +27 -0
  175. package/lordceaser-baileys/lib/Types/State.js +2 -0
  176. package/lordceaser-baileys/lib/Types/index.d.ts +63 -0
  177. package/lordceaser-baileys/lib/Types/index.js +41 -0
  178. package/lordceaser-baileys/lib/Utils/auth-utils.d.ts +18 -0
  179. package/lordceaser-baileys/lib/Utils/auth-utils.js +206 -0
  180. package/lordceaser-baileys/lib/Utils/baileys-event-stream.d.ts +16 -0
  181. package/lordceaser-baileys/lib/Utils/baileys-event-stream.js +63 -0
  182. package/lordceaser-baileys/lib/Utils/business.d.ts +22 -0
  183. package/lordceaser-baileys/lib/Utils/business.js +234 -0
  184. package/lordceaser-baileys/lib/Utils/chat-utils.d.ts +71 -0
  185. package/lordceaser-baileys/lib/Utils/chat-utils.js +740 -0
  186. package/lordceaser-baileys/lib/Utils/crypto.d.ts +41 -0
  187. package/lordceaser-baileys/lib/Utils/crypto.js +153 -0
  188. package/lordceaser-baileys/lib/Utils/decode-wa-message.d.ts +20 -0
  189. package/lordceaser-baileys/lib/Utils/decode-wa-message.js +188 -0
  190. package/lordceaser-baileys/lib/Utils/event-buffer.d.ts +35 -0
  191. package/lordceaser-baileys/lib/Utils/event-buffer.js +520 -0
  192. package/lordceaser-baileys/lib/Utils/generics.d.ts +89 -0
  193. package/lordceaser-baileys/lib/Utils/generics.js +394 -0
  194. package/lordceaser-baileys/lib/Utils/history.d.ts +19 -0
  195. package/lordceaser-baileys/lib/Utils/history.js +94 -0
  196. package/lordceaser-baileys/lib/Utils/index.d.ts +17 -0
  197. package/lordceaser-baileys/lib/Utils/index.js +33 -0
  198. package/lordceaser-baileys/lib/Utils/link-preview.d.ts +21 -0
  199. package/lordceaser-baileys/lib/Utils/link-preview.js +93 -0
  200. package/lordceaser-baileys/lib/Utils/logger.d.ts +4 -0
  201. package/lordceaser-baileys/lib/Utils/logger.js +7 -0
  202. package/lordceaser-baileys/lib/Utils/lt-hash.d.ts +12 -0
  203. package/lordceaser-baileys/lib/Utils/lt-hash.js +51 -0
  204. package/lordceaser-baileys/lib/Utils/make-mutex.d.ts +7 -0
  205. package/lordceaser-baileys/lib/Utils/make-mutex.js +43 -0
  206. package/lordceaser-baileys/lib/Utils/messages-media.d.ts +107 -0
  207. package/lordceaser-baileys/lib/Utils/messages-media.js +674 -0
  208. package/lordceaser-baileys/lib/Utils/messages.d.ts +77 -0
  209. package/lordceaser-baileys/lib/Utils/messages.js +758 -0
  210. package/lordceaser-baileys/lib/Utils/noise-handler.d.ts +21 -0
  211. package/lordceaser-baileys/lib/Utils/noise-handler.js +155 -0
  212. package/lordceaser-baileys/lib/Utils/process-message.d.ts +42 -0
  213. package/lordceaser-baileys/lib/Utils/process-message.js +354 -0
  214. package/lordceaser-baileys/lib/Utils/signal.d.ts +32 -0
  215. package/lordceaser-baileys/lib/Utils/signal.js +161 -0
  216. package/lordceaser-baileys/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
  217. package/lordceaser-baileys/lib/Utils/use-multi-file-auth-state.js +93 -0
  218. package/lordceaser-baileys/lib/Utils/validate-connection.d.ts +11 -0
  219. package/lordceaser-baileys/lib/Utils/validate-connection.js +205 -0
  220. package/lordceaser-baileys/lib/WABinary/constants.d.ts +27 -0
  221. package/lordceaser-baileys/lib/WABinary/constants.js +40 -0
  222. package/lordceaser-baileys/lib/WABinary/decode.d.ts +7 -0
  223. package/lordceaser-baileys/lib/WABinary/decode.js +254 -0
  224. package/lordceaser-baileys/lib/WABinary/encode.d.ts +3 -0
  225. package/lordceaser-baileys/lib/WABinary/encode.js +232 -0
  226. package/lordceaser-baileys/lib/WABinary/generic-utils.d.ts +15 -0
  227. package/lordceaser-baileys/lib/WABinary/generic-utils.js +110 -0
  228. package/lordceaser-baileys/lib/WABinary/index.d.ts +5 -0
  229. package/lordceaser-baileys/lib/WABinary/index.js +21 -0
  230. package/lordceaser-baileys/lib/WABinary/jid-utils.d.ts +31 -0
  231. package/lordceaser-baileys/lib/WABinary/jid-utils.js +62 -0
  232. package/lordceaser-baileys/lib/WABinary/types.d.ts +18 -0
  233. package/lordceaser-baileys/lib/WABinary/types.js +2 -0
  234. package/lordceaser-baileys/lib/WAM/BinaryInfo.d.ts +17 -0
  235. package/lordceaser-baileys/lib/WAM/BinaryInfo.js +13 -0
  236. package/lordceaser-baileys/lib/WAM/constants.d.ts +38 -0
  237. package/lordceaser-baileys/lib/WAM/constants.js +15350 -0
  238. package/lordceaser-baileys/lib/WAM/encode.d.ts +3 -0
  239. package/lordceaser-baileys/lib/WAM/encode.js +155 -0
  240. package/lordceaser-baileys/lib/WAM/index.d.ts +3 -0
  241. package/lordceaser-baileys/lib/WAM/index.js +19 -0
  242. package/lordceaser-baileys/lib/index.d.ts +11 -0
  243. package/lordceaser-baileys/lib/index.js +30 -0
  244. package/lordceaser-baileys/package.json +49 -0
  245. package/lordceaser-baileys/proto-extract/README.md +10 -0
  246. package/lordceaser-baileys/proto-extract/index.js +507 -0
  247. package/lordceaser-baileys/proto-extract/package-lock.json +511 -0
  248. package/lordceaser-baileys/proto-extract/package.json +15 -0
  249. package/lordceaser-baileys/proto-extract/yarn.lock +494 -0
  250. package/lordceaser-baileys/scripts/update-version.ts +149 -0
  251. package/lordceaser-baileys/src/Defaults/baileys-version.json +1 -0
  252. package/lordceaser-baileys/src/Defaults/index.ts +151 -0
  253. package/lordceaser-baileys/src/Signal/Group/ciphertext-message.ts +9 -0
  254. package/lordceaser-baileys/src/Signal/Group/group-session-builder.ts +56 -0
  255. package/lordceaser-baileys/src/Signal/Group/group_cipher.ts +117 -0
  256. package/lordceaser-baileys/src/Signal/Group/index.ts +11 -0
  257. package/lordceaser-baileys/src/Signal/Group/keyhelper.ts +28 -0
  258. package/lordceaser-baileys/src/Signal/Group/sender-chain-key.ts +34 -0
  259. package/lordceaser-baileys/src/Signal/Group/sender-key-distribution-message.ts +95 -0
  260. package/lordceaser-baileys/src/Signal/Group/sender-key-message.ts +96 -0
  261. package/lordceaser-baileys/src/Signal/Group/sender-key-name.ts +66 -0
  262. package/lordceaser-baileys/src/Signal/Group/sender-key-record.ts +69 -0
  263. package/lordceaser-baileys/src/Signal/Group/sender-key-state.ts +134 -0
  264. package/lordceaser-baileys/src/Signal/Group/sender-message-key.ts +36 -0
  265. package/lordceaser-baileys/src/Signal/libsignal.ts +555 -0
  266. package/lordceaser-baileys/src/Signal/lid-mapping.ts +335 -0
  267. package/lordceaser-baileys/src/Socket/Client/index.ts +2 -0
  268. package/lordceaser-baileys/src/Socket/Client/types.ts +22 -0
  269. package/lordceaser-baileys/src/Socket/Client/websocket.ts +63 -0
  270. package/lordceaser-baileys/src/Socket/business.ts +424 -0
  271. package/lordceaser-baileys/src/Socket/chats.ts +1533 -0
  272. package/lordceaser-baileys/src/Socket/communities.ts +477 -0
  273. package/lordceaser-baileys/src/Socket/groups.ts +384 -0
  274. package/lordceaser-baileys/src/Socket/index.ts +15 -0
  275. package/lordceaser-baileys/src/Socket/messages-recv.ts +2174 -0
  276. package/lordceaser-baileys/src/Socket/messages-send.ts +1419 -0
  277. package/lordceaser-baileys/src/Socket/mex.ts +58 -0
  278. package/lordceaser-baileys/src/Socket/newsletter.ts +229 -0
  279. package/lordceaser-baileys/src/Socket/socket.ts +1200 -0
  280. package/lordceaser-baileys/src/Types/Auth.ts +116 -0
  281. package/lordceaser-baileys/src/Types/Bussines.ts +20 -0
  282. package/lordceaser-baileys/src/Types/Call.ts +24 -0
  283. package/lordceaser-baileys/src/Types/Chat.ts +139 -0
  284. package/lordceaser-baileys/src/Types/Contact.ts +26 -0
  285. package/lordceaser-baileys/src/Types/Events.ts +179 -0
  286. package/lordceaser-baileys/src/Types/GroupMetadata.ts +74 -0
  287. package/lordceaser-baileys/src/Types/Label.ts +48 -0
  288. package/lordceaser-baileys/src/Types/LabelAssociation.ts +35 -0
  289. package/lordceaser-baileys/src/Types/Message.ts +398 -0
  290. package/lordceaser-baileys/src/Types/Mex.ts +105 -0
  291. package/lordceaser-baileys/src/Types/Product.ts +85 -0
  292. package/lordceaser-baileys/src/Types/Signal.ts +85 -0
  293. package/lordceaser-baileys/src/Types/Socket.ts +153 -0
  294. package/lordceaser-baileys/src/Types/State.ts +108 -0
  295. package/lordceaser-baileys/src/Types/USync.ts +27 -0
  296. package/lordceaser-baileys/src/Types/globals.d.ts +8 -0
  297. package/lordceaser-baileys/src/Types/index.ts +68 -0
  298. package/lordceaser-baileys/src/Utils/auth-utils.ts +382 -0
  299. package/lordceaser-baileys/src/Utils/browser-utils.ts +32 -0
  300. package/lordceaser-baileys/src/Utils/business.ts +286 -0
  301. package/lordceaser-baileys/src/Utils/chat-utils.ts +1040 -0
  302. package/lordceaser-baileys/src/Utils/companion-reg-client-utils.ts +48 -0
  303. package/lordceaser-baileys/src/Utils/crypto.ts +147 -0
  304. package/lordceaser-baileys/src/Utils/decode-wa-message.ts +393 -0
  305. package/lordceaser-baileys/src/Utils/event-buffer.ts +747 -0
  306. package/lordceaser-baileys/src/Utils/generics.ts +484 -0
  307. package/lordceaser-baileys/src/Utils/history.ts +162 -0
  308. package/lordceaser-baileys/src/Utils/identity-change-handler.ts +92 -0
  309. package/lordceaser-baileys/src/Utils/index.ts +21 -0
  310. package/lordceaser-baileys/src/Utils/link-preview.ts +111 -0
  311. package/lordceaser-baileys/src/Utils/logger.ts +13 -0
  312. package/lordceaser-baileys/src/Utils/lt-hash.ts +8 -0
  313. package/lordceaser-baileys/src/Utils/make-mutex.ts +42 -0
  314. package/lordceaser-baileys/src/Utils/message-retry-manager.ts +341 -0
  315. package/lordceaser-baileys/src/Utils/messages-media.ts +1001 -0
  316. package/lordceaser-baileys/src/Utils/messages.ts +1124 -0
  317. package/lordceaser-baileys/src/Utils/noise-handler.ts +268 -0
  318. package/lordceaser-baileys/src/Utils/offline-node-processor.ts +70 -0
  319. package/lordceaser-baileys/src/Utils/pre-key-manager.ts +126 -0
  320. package/lordceaser-baileys/src/Utils/process-message.ts +792 -0
  321. package/lordceaser-baileys/src/Utils/reporting-utils.ts +344 -0
  322. package/lordceaser-baileys/src/Utils/signal.ts +261 -0
  323. package/lordceaser-baileys/src/Utils/stanza-ack.ts +45 -0
  324. package/lordceaser-baileys/src/Utils/sync-action-utils.ts +75 -0
  325. package/lordceaser-baileys/src/Utils/tc-token-utils.ts +218 -0
  326. package/lordceaser-baileys/src/Utils/use-multi-file-auth-state.ts +136 -0
  327. package/lordceaser-baileys/src/Utils/validate-connection.ts +265 -0
  328. package/lordceaser-baileys/src/WABinary/constants.ts +1305 -0
  329. package/lordceaser-baileys/src/WABinary/decode.ts +308 -0
  330. package/lordceaser-baileys/src/WABinary/encode.ts +258 -0
  331. package/lordceaser-baileys/src/WABinary/generic-utils.ts +141 -0
  332. package/lordceaser-baileys/src/WABinary/index.ts +5 -0
  333. package/lordceaser-baileys/src/WABinary/jid-utils.ts +128 -0
  334. package/lordceaser-baileys/src/WABinary/types.ts +17 -0
  335. package/lordceaser-baileys/src/WAM/BinaryInfo.ts +12 -0
  336. package/lordceaser-baileys/src/WAM/constants.ts +22889 -0
  337. package/lordceaser-baileys/src/WAM/encode.ts +169 -0
  338. package/lordceaser-baileys/src/WAM/index.ts +3 -0
  339. package/lordceaser-baileys/src/WAUSync/Protocols/USyncContactProtocol.ts +58 -0
  340. package/lordceaser-baileys/src/WAUSync/Protocols/USyncDeviceProtocol.ts +78 -0
  341. package/lordceaser-baileys/src/WAUSync/Protocols/USyncDisappearingModeProtocol.ts +35 -0
  342. package/lordceaser-baileys/src/WAUSync/Protocols/USyncStatusProtocol.ts +44 -0
  343. package/lordceaser-baileys/src/WAUSync/Protocols/USyncUsernameProtocol.ts +28 -0
  344. package/lordceaser-baileys/src/WAUSync/Protocols/UsyncBotProfileProtocol.ts +76 -0
  345. package/lordceaser-baileys/src/WAUSync/Protocols/UsyncLIDProtocol.ts +33 -0
  346. package/lordceaser-baileys/src/WAUSync/Protocols/index.ts +5 -0
  347. package/lordceaser-baileys/src/WAUSync/USyncQuery.ts +139 -0
  348. package/lordceaser-baileys/src/WAUSync/USyncUser.ts +44 -0
  349. package/lordceaser-baileys/src/WAUSync/index.ts +3 -0
  350. package/lordceaser-baileys/src/__tests__/Signal/Group/sender-key-state-regression.test.ts +22 -0
  351. package/lordceaser-baileys/src/__tests__/Signal/lid-mapping.test.ts +47 -0
  352. package/lordceaser-baileys/src/__tests__/Socket/chats.test.ts +29 -0
  353. package/lordceaser-baileys/src/__tests__/Socket/groups.test.ts +93 -0
  354. package/lordceaser-baileys/src/__tests__/Socket/identity-change-handling.test.ts +252 -0
  355. package/lordceaser-baileys/src/__tests__/TestUtils/session.ts +47 -0
  356. package/lordceaser-baileys/src/__tests__/Utils/app-state-sync-resilience.test.ts +112 -0
  357. package/lordceaser-baileys/src/__tests__/Utils/app-state-version.test.ts +64 -0
  358. package/lordceaser-baileys/src/__tests__/Utils/auth-utils.test.ts +37 -0
  359. package/lordceaser-baileys/src/__tests__/Utils/chat-utils-resilience.test.ts +166 -0
  360. package/lordceaser-baileys/src/__tests__/Utils/decode-wa-message.test.ts +86 -0
  361. package/lordceaser-baileys/src/__tests__/Utils/event-buffer.test.ts +154 -0
  362. package/lordceaser-baileys/src/__tests__/Utils/generics.test.ts +70 -0
  363. package/lordceaser-baileys/src/__tests__/Utils/history.test.ts +432 -0
  364. package/lordceaser-baileys/src/__tests__/Utils/lt-hash-generator.test.ts +152 -0
  365. package/lordceaser-baileys/src/__tests__/Utils/messages-media.test.ts +488 -0
  366. package/lordceaser-baileys/src/__tests__/Utils/noise-handler.test.ts +339 -0
  367. package/lordceaser-baileys/src/__tests__/Utils/offline-node-processor.test.ts +318 -0
  368. package/lordceaser-baileys/src/__tests__/Utils/process-message.test.ts +189 -0
  369. package/lordceaser-baileys/src/__tests__/Utils/process-sync-action.test.ts +359 -0
  370. package/lordceaser-baileys/src/__tests__/Utils/reporting-utils.test.ts +160 -0
  371. package/lordceaser-baileys/src/__tests__/Utils/signal.test.ts +69 -0
  372. package/lordceaser-baileys/src/__tests__/Utils/stanza-ack.test.ts +420 -0
  373. package/lordceaser-baileys/src/__tests__/Utils/sync-action-utils.test.ts +183 -0
  374. package/lordceaser-baileys/src/__tests__/Utils/tc-token.test.ts +1110 -0
  375. package/lordceaser-baileys/src/__tests__/bigint-validation.test.ts +186 -0
  376. package/lordceaser-baileys/src/__tests__/binary/connection-deadlock.test.ts +54 -0
  377. package/lordceaser-baileys/src/__tests__/binary/reconnection-sync-skip.test.ts +86 -0
  378. package/lordceaser-baileys/src/__tests__/e2e/fetch-wa-web-version.test-e2e.ts +60 -0
  379. package/lordceaser-baileys/src/__tests__/e2e/groups.test-e2e.ts +113 -0
  380. package/lordceaser-baileys/src/__tests__/e2e/helpers/mock-phone.ts +41 -0
  381. package/lordceaser-baileys/src/__tests__/e2e/helpers/test-client.ts +302 -0
  382. package/lordceaser-baileys/src/__tests__/e2e/messaging.test-e2e.ts +67 -0
  383. package/lordceaser-baileys/src/__tests__/e2e/send-receive-message.test-e2e.ts +259 -0
  384. package/lordceaser-baileys/src/__tests__/proto-tojson-long.test.ts +115 -0
  385. package/lordceaser-baileys/src/index.ts +13 -0
  386. package/lordceaser-baileys/tsconfig.build.json +12 -0
  387. package/lordceaser-baileys/tsconfig.json +39 -0
  388. package/lordceaser-baileys/typedoc.json +13 -0
  389. package/lordceaser-baileys/yarn.lock +8832 -0
  390. package/package.json +4 -19
  391. /package/{LICENSE → lordceaser-baileys/LICENSE} +0 -0
  392. /package/{README.md → lordceaser-baileys/README.md} +0 -0
  393. /package/{WABinary → lordceaser-baileys/WABinary}/constants.d.ts +0 -0
  394. /package/{WABinary → lordceaser-baileys/WABinary}/constants.js +0 -0
  395. /package/{WABinary → lordceaser-baileys/WABinary}/decode.d.ts +0 -0
  396. /package/{WABinary → lordceaser-baileys/WABinary}/decode.js +0 -0
  397. /package/{WABinary → lordceaser-baileys/WABinary}/encode.d.ts +0 -0
  398. /package/{WABinary → lordceaser-baileys/WABinary}/encode.js +0 -0
  399. /package/{WABinary → lordceaser-baileys/WABinary}/generic-utils.d.ts +0 -0
  400. /package/{WABinary → lordceaser-baileys/WABinary}/generic-utils.js +0 -0
  401. /package/{WABinary → lordceaser-baileys/WABinary}/index.d.ts +0 -0
  402. /package/{WABinary → lordceaser-baileys/WABinary}/index.js +0 -0
  403. /package/{WABinary → lordceaser-baileys/WABinary}/jid-utils.d.ts +0 -0
  404. /package/{WABinary → lordceaser-baileys/WABinary}/jid-utils.js +0 -0
  405. /package/{WABinary → lordceaser-baileys/WABinary}/types.d.ts +0 -0
  406. /package/{WABinary → lordceaser-baileys/WABinary}/types.js +0 -0
  407. /package/{WAMessage → lordceaser-baileys/WAMessage}/BinaryInfo.d.ts +0 -0
  408. /package/{WAMessage → lordceaser-baileys/WAMessage}/BinaryInfo.js +0 -0
  409. /package/{WAMessage → lordceaser-baileys/WAMessage}/constants.d.ts +0 -0
  410. /package/{WAMessage → lordceaser-baileys/WAMessage}/constants.js +0 -0
  411. /package/{WAMessage → lordceaser-baileys/WAMessage}/encode.d.ts +0 -0
  412. /package/{WAMessage → lordceaser-baileys/WAMessage}/encode.js +0 -0
  413. /package/{WAMessage → lordceaser-baileys/WAMessage}/index.d.ts +0 -0
  414. /package/{WAMessage → lordceaser-baileys/WAMessage}/index.js +0 -0
@@ -0,0 +1,394 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.bytesToCrockford = exports.trimUndefined = exports.isWABusinessPlatform = exports.getCodeFromWSError = exports.getCallStatusFromNode = exports.getErrorCodeFromStreamError = exports.getStatusFromReceiptType = exports.generateMdTagPrefix = exports.fetchLatestWaWebVersion = exports.fetchLatestBaileysVersion = exports.printQRIfNecessaryListener = exports.bindWaitForConnectionUpdate = exports.bindWaitForEvent = exports.generateMessageID = exports.generateMessageIDV2 = exports.promiseTimeout = exports.delayCancellable = exports.delay = exports.debouncedTimeout = exports.unixTimestampSeconds = exports.toNumber = exports.encodeBigEndian = exports.generateRegistrationId = exports.encodeWAMessage = exports.unpadRandomMax16 = exports.writeRandomPadMax16 = exports.getKeyAuthor = exports.BufferJSON = exports.getPlatformId = exports.Browsers = void 0;
7
+ const boom_1 = require("@hapi/boom");
8
+ const axios_1 = __importDefault(require("axios"));
9
+ const crypto_1 = require("crypto");
10
+ const os_1 = require("os");
11
+ const WAProto_1 = require("../../WAProto");
12
+ const baileys_version_json_1 = require("../Defaults/baileys-version.json");
13
+ const Types_1 = require("../Types");
14
+ const WABinary_1 = require("../WABinary");
15
+ const PLATFORM_MAP = {
16
+ 'aix': 'AIX',
17
+ 'darwin': 'Mac OS',
18
+ 'win32': 'Windows',
19
+ 'android': 'Android',
20
+ 'freebsd': 'FreeBSD',
21
+ 'openbsd': 'OpenBSD',
22
+ 'sunos': 'Solaris'
23
+ };
24
+ exports.Browsers = {
25
+ ubuntu: (browser) => ['Ubuntu', browser, '22.04.4'],
26
+ macOS: (browser) => ['Mac OS', browser, '14.4.1'],
27
+ baileys: (browser) => ['Baileys', browser, '6.5.0'],
28
+ windows: (browser) => ['Windows', browser, '10.0.22631'],
29
+ /** The appropriate browser based on your OS & release */
30
+ appropriate: (browser) => [PLATFORM_MAP[(0, os_1.platform)()] || 'Ubuntu', browser, (0, os_1.release)()]
31
+ };
32
+ const getPlatformId = (browser) => {
33
+ const platformType = WAProto_1.proto.DeviceProps.PlatformType[browser.toUpperCase()];
34
+ return platformType ? platformType.toString().charCodeAt(0).toString() : '49'; //chrome
35
+ };
36
+ exports.getPlatformId = getPlatformId;
37
+ exports.BufferJSON = {
38
+ replacer: (k, value) => {
39
+ if (Buffer.isBuffer(value) || value instanceof Uint8Array || (value === null || value === void 0 ? void 0 : value.type) === 'Buffer') {
40
+ return { type: 'Buffer', data: Buffer.from((value === null || value === void 0 ? void 0 : value.data) || value).toString('base64') };
41
+ }
42
+ return value;
43
+ },
44
+ reviver: (_, value) => {
45
+ if (typeof value === 'object' && !!value && (value.buffer === true || value.type === 'Buffer')) {
46
+ const val = value.data || value.value;
47
+ return typeof val === 'string' ? Buffer.from(val, 'base64') : Buffer.from(val || []);
48
+ }
49
+ return value;
50
+ }
51
+ };
52
+ const getKeyAuthor = (key, meId = 'me') => (((key === null || key === void 0 ? void 0 : key.fromMe) ? meId : (key === null || key === void 0 ? void 0 : key.participant) || (key === null || key === void 0 ? void 0 : key.remoteJid)) || '');
53
+ exports.getKeyAuthor = getKeyAuthor;
54
+ const writeRandomPadMax16 = (msg) => {
55
+ const pad = (0, crypto_1.randomBytes)(1);
56
+ pad[0] &= 0xf;
57
+ if (!pad[0]) {
58
+ pad[0] = 0xf;
59
+ }
60
+ return Buffer.concat([msg, Buffer.alloc(pad[0], pad[0])]);
61
+ };
62
+ exports.writeRandomPadMax16 = writeRandomPadMax16;
63
+ const unpadRandomMax16 = (e) => {
64
+ const t = new Uint8Array(e);
65
+ if (0 === t.length) {
66
+ throw new Error('unpadPkcs7 given empty bytes');
67
+ }
68
+ var r = t[t.length - 1];
69
+ if (r > t.length) {
70
+ throw new Error(`unpad given ${t.length} bytes, but pad is ${r}`);
71
+ }
72
+ return new Uint8Array(t.buffer, t.byteOffset, t.length - r);
73
+ };
74
+ exports.unpadRandomMax16 = unpadRandomMax16;
75
+ const encodeWAMessage = (message) => ((0, exports.writeRandomPadMax16)(WAProto_1.proto.Message.encode(message).finish()));
76
+ exports.encodeWAMessage = encodeWAMessage;
77
+ const generateRegistrationId = () => {
78
+ return Uint16Array.from((0, crypto_1.randomBytes)(2))[0] & 16383;
79
+ };
80
+ exports.generateRegistrationId = generateRegistrationId;
81
+ const encodeBigEndian = (e, t = 4) => {
82
+ let r = e;
83
+ const a = new Uint8Array(t);
84
+ for (let i = t - 1; i >= 0; i--) {
85
+ a[i] = 255 & r;
86
+ r >>>= 8;
87
+ }
88
+ return a;
89
+ };
90
+ exports.encodeBigEndian = encodeBigEndian;
91
+ const toNumber = (t) => ((typeof t === 'object' && t) ? ('toNumber' in t ? t.toNumber() : t.low) : t);
92
+ exports.toNumber = toNumber;
93
+ /** unix timestamp of a date in seconds */
94
+ const unixTimestampSeconds = (date = new Date()) => Math.floor(date.getTime() / 1000);
95
+ exports.unixTimestampSeconds = unixTimestampSeconds;
96
+ const debouncedTimeout = (intervalMs = 1000, task) => {
97
+ let timeout;
98
+ return {
99
+ start: (newIntervalMs, newTask) => {
100
+ task = newTask || task;
101
+ intervalMs = newIntervalMs || intervalMs;
102
+ timeout && clearTimeout(timeout);
103
+ timeout = setTimeout(() => task === null || task === void 0 ? void 0 : task(), intervalMs);
104
+ },
105
+ cancel: () => {
106
+ timeout && clearTimeout(timeout);
107
+ timeout = undefined;
108
+ },
109
+ setTask: (newTask) => task = newTask,
110
+ setInterval: (newInterval) => intervalMs = newInterval
111
+ };
112
+ };
113
+ exports.debouncedTimeout = debouncedTimeout;
114
+ const delay = (ms) => (0, exports.delayCancellable)(ms).delay;
115
+ exports.delay = delay;
116
+ const delayCancellable = (ms) => {
117
+ const stack = new Error().stack;
118
+ let timeout;
119
+ let reject;
120
+ const delay = new Promise((resolve, _reject) => {
121
+ timeout = setTimeout(resolve, ms);
122
+ reject = _reject;
123
+ });
124
+ const cancel = () => {
125
+ clearTimeout(timeout);
126
+ reject(new boom_1.Boom('Cancelled', {
127
+ statusCode: 500,
128
+ data: {
129
+ stack
130
+ }
131
+ }));
132
+ };
133
+ return { delay, cancel };
134
+ };
135
+ exports.delayCancellable = delayCancellable;
136
+ async function promiseTimeout(ms, promise) {
137
+ if (!ms) {
138
+ return new Promise(promise);
139
+ }
140
+ const stack = new Error().stack;
141
+ // Create a promise that rejects in <ms> milliseconds
142
+ const { delay, cancel } = (0, exports.delayCancellable)(ms);
143
+ const p = new Promise((resolve, reject) => {
144
+ delay
145
+ .then(() => reject(new boom_1.Boom('Timed Out', {
146
+ statusCode: Types_1.DisconnectReason.timedOut,
147
+ data: {
148
+ stack
149
+ }
150
+ })))
151
+ .catch(err => reject(err));
152
+ promise(resolve, reject);
153
+ })
154
+ .finally(cancel);
155
+ return p;
156
+ }
157
+ exports.promiseTimeout = promiseTimeout;
158
+ // inspired from whatsmeow code
159
+ // https://github.com/tulir/whatsmeow/blob/64bc969fbe78d31ae0dd443b8d4c80a5d026d07a/send.go#L42
160
+ const generateMessageIDV2 = (userId) => {
161
+ const data = Buffer.alloc(8 + 20 + 16);
162
+ data.writeBigUInt64BE(BigInt(Math.floor(Date.now() / 1000)));
163
+ if (userId) {
164
+ const id = (0, WABinary_1.jidDecode)(userId);
165
+ if (id === null || id === void 0 ? void 0 : id.user) {
166
+ data.write(id.user, 8);
167
+ data.write('@c.us', 8 + id.user.length);
168
+ }
169
+ }
170
+ const random = (0, crypto_1.randomBytes)(16);
171
+ random.copy(data, 28);
172
+ const hash = (0, crypto_1.createHash)('sha256').update(data).digest();
173
+ return '3EB0' + hash.toString('hex').toUpperCase().substring(0, 18);
174
+ };
175
+ exports.generateMessageIDV2 = generateMessageIDV2;
176
+ // generate a random ID to attach to a message
177
+ const generateMessageID = () => '3EB0' + (0, crypto_1.randomBytes)(18).toString('hex').toUpperCase();
178
+ exports.generateMessageID = generateMessageID;
179
+ function bindWaitForEvent(ev, event) {
180
+ return async (check, timeoutMs) => {
181
+ let listener;
182
+ let closeListener;
183
+ await (promiseTimeout(timeoutMs, (resolve, reject) => {
184
+ closeListener = ({ connection, lastDisconnect }) => {
185
+ if (connection === 'close') {
186
+ reject((lastDisconnect === null || lastDisconnect === void 0 ? void 0 : lastDisconnect.error)
187
+ || new boom_1.Boom('Connection Closed', { statusCode: Types_1.DisconnectReason.connectionClosed }));
188
+ }
189
+ };
190
+ ev.on('connection.update', closeListener);
191
+ listener = (update) => {
192
+ if (check(update)) {
193
+ resolve();
194
+ }
195
+ };
196
+ ev.on(event, listener);
197
+ })
198
+ .finally(() => {
199
+ ev.off(event, listener);
200
+ ev.off('connection.update', closeListener);
201
+ }));
202
+ };
203
+ }
204
+ exports.bindWaitForEvent = bindWaitForEvent;
205
+ const bindWaitForConnectionUpdate = (ev) => bindWaitForEvent(ev, 'connection.update');
206
+ exports.bindWaitForConnectionUpdate = bindWaitForConnectionUpdate;
207
+ const printQRIfNecessaryListener = (ev, logger) => {
208
+ ev.on('connection.update', async ({ qr }) => {
209
+ if (qr) {
210
+ const QR = await import('qrcode-terminal')
211
+ .then(m => m.default || m)
212
+ .catch(() => {
213
+ logger.error('QR code terminal not added as dependency');
214
+ });
215
+ QR === null || QR === void 0 ? void 0 : QR.generate(qr, { small: true });
216
+ }
217
+ });
218
+ };
219
+ exports.printQRIfNecessaryListener = printQRIfNecessaryListener;
220
+ /**
221
+ * utility that fetches latest baileys version from the master branch.
222
+ * Use to ensure your WA connection is always on the latest version
223
+ */
224
+ const fetchLatestBaileysVersion = async (options = {}) => {
225
+ const URL = 'https://raw.githubusercontent.com/WhiskeySockets/Baileys/master/src/Defaults/baileys-version.json';
226
+ try {
227
+ const result = await axios_1.default.get(URL, {
228
+ ...options,
229
+ responseType: 'json'
230
+ });
231
+ return {
232
+ version: result.data.version,
233
+ isLatest: true
234
+ };
235
+ }
236
+ catch (error) {
237
+ return {
238
+ version: baileys_version_json_1.version,
239
+ isLatest: false,
240
+ error
241
+ };
242
+ }
243
+ };
244
+ exports.fetchLatestBaileysVersion = fetchLatestBaileysVersion;
245
+ /**
246
+ * A utility that fetches the latest web version of whatsapp.
247
+ * Use to ensure your WA connection is always on the latest version
248
+ */
249
+ const fetchLatestWaWebVersion = async (options) => {
250
+ try {
251
+ const result = await axios_1.default.get('https://web.whatsapp.com/check-update?version=1&platform=web', {
252
+ ...options,
253
+ responseType: 'json'
254
+ });
255
+ const version = result.data.currentVersion.split('.');
256
+ return {
257
+ version: [+version[0], +version[1], +version[2]],
258
+ isLatest: true
259
+ };
260
+ }
261
+ catch (error) {
262
+ return {
263
+ version: baileys_version_json_1.version,
264
+ isLatest: false,
265
+ error
266
+ };
267
+ }
268
+ };
269
+ exports.fetchLatestWaWebVersion = fetchLatestWaWebVersion;
270
+ /** unique message tag prefix for MD clients */
271
+ const generateMdTagPrefix = () => {
272
+ const bytes = (0, crypto_1.randomBytes)(4);
273
+ return `${bytes.readUInt16BE()}.${bytes.readUInt16BE(2)}-`;
274
+ };
275
+ exports.generateMdTagPrefix = generateMdTagPrefix;
276
+ const STATUS_MAP = {
277
+ 'played': WAProto_1.proto.WebMessageInfo.Status.PLAYED,
278
+ 'read': WAProto_1.proto.WebMessageInfo.Status.READ,
279
+ 'read-self': WAProto_1.proto.WebMessageInfo.Status.READ
280
+ };
281
+ /**
282
+ * Given a type of receipt, returns what the new status of the message should be
283
+ * @param type type from receipt
284
+ */
285
+ const getStatusFromReceiptType = (type) => {
286
+ const status = STATUS_MAP[type];
287
+ if (typeof type === 'undefined') {
288
+ return WAProto_1.proto.WebMessageInfo.Status.DELIVERY_ACK;
289
+ }
290
+ return status;
291
+ };
292
+ exports.getStatusFromReceiptType = getStatusFromReceiptType;
293
+ const CODE_MAP = {
294
+ conflict: Types_1.DisconnectReason.connectionReplaced
295
+ };
296
+ /**
297
+ * Stream errors generally provide a reason, map that to a baileys DisconnectReason
298
+ * @param reason the string reason given, eg. "conflict"
299
+ */
300
+ const getErrorCodeFromStreamError = (node) => {
301
+ const [reasonNode] = (0, WABinary_1.getAllBinaryNodeChildren)(node);
302
+ let reason = (reasonNode === null || reasonNode === void 0 ? void 0 : reasonNode.tag) || 'unknown';
303
+ const statusCode = +(node.attrs.code || CODE_MAP[reason] || Types_1.DisconnectReason.badSession);
304
+ if (statusCode === Types_1.DisconnectReason.restartRequired) {
305
+ reason = 'restart required';
306
+ }
307
+ return {
308
+ reason,
309
+ statusCode
310
+ };
311
+ };
312
+ exports.getErrorCodeFromStreamError = getErrorCodeFromStreamError;
313
+ const getCallStatusFromNode = ({ tag, attrs }) => {
314
+ let status;
315
+ switch (tag) {
316
+ case 'offer':
317
+ case 'offer_notice':
318
+ status = 'offer';
319
+ break;
320
+ case 'terminate':
321
+ if (attrs.reason === 'timeout') {
322
+ status = 'timeout';
323
+ }
324
+ else {
325
+ //fired when accepted/rejected/timeout/caller hangs up
326
+ status = 'terminate';
327
+ }
328
+ break;
329
+ case 'reject':
330
+ status = 'reject';
331
+ break;
332
+ case 'accept':
333
+ status = 'accept';
334
+ break;
335
+ default:
336
+ status = 'ringing';
337
+ break;
338
+ }
339
+ return status;
340
+ };
341
+ exports.getCallStatusFromNode = getCallStatusFromNode;
342
+ const UNEXPECTED_SERVER_CODE_TEXT = 'Unexpected server response: ';
343
+ const getCodeFromWSError = (error) => {
344
+ var _a, _b, _c;
345
+ let statusCode = 500;
346
+ if ((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes(UNEXPECTED_SERVER_CODE_TEXT)) {
347
+ const code = +(error === null || error === void 0 ? void 0 : error.message.slice(UNEXPECTED_SERVER_CODE_TEXT.length));
348
+ if (!Number.isNaN(code) && code >= 400) {
349
+ statusCode = code;
350
+ }
351
+ }
352
+ else if (((_b = error === null || error === void 0 ? void 0 : error.code) === null || _b === void 0 ? void 0 : _b.startsWith('E'))
353
+ || ((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.includes('timed out'))) { // handle ETIMEOUT, ENOTFOUND etc
354
+ statusCode = 408;
355
+ }
356
+ return statusCode;
357
+ };
358
+ exports.getCodeFromWSError = getCodeFromWSError;
359
+ /**
360
+ * Is the given platform WA business
361
+ * @param platform AuthenticationCreds.platform
362
+ */
363
+ const isWABusinessPlatform = (platform) => {
364
+ return platform === 'smbi' || platform === 'smba';
365
+ };
366
+ exports.isWABusinessPlatform = isWABusinessPlatform;
367
+ function trimUndefined(obj) {
368
+ for (const key in obj) {
369
+ if (typeof obj[key] === 'undefined') {
370
+ delete obj[key];
371
+ }
372
+ }
373
+ return obj;
374
+ }
375
+ exports.trimUndefined = trimUndefined;
376
+ const CROCKFORD_CHARACTERS = '123456789ABCDEFGHJKLMNPQRSTVWXYZ';
377
+ function bytesToCrockford(buffer) {
378
+ let value = 0;
379
+ let bitCount = 0;
380
+ const crockford = [];
381
+ for (let i = 0; i < buffer.length; i++) {
382
+ value = (value << 8) | (buffer[i] & 0xff);
383
+ bitCount += 8;
384
+ while (bitCount >= 5) {
385
+ crockford.push(CROCKFORD_CHARACTERS.charAt((value >>> (bitCount - 5)) & 31));
386
+ bitCount -= 5;
387
+ }
388
+ }
389
+ if (bitCount > 0) {
390
+ crockford.push(CROCKFORD_CHARACTERS.charAt((value << (5 - bitCount)) & 31));
391
+ }
392
+ return crockford.join('');
393
+ }
394
+ exports.bytesToCrockford = bytesToCrockford;
@@ -0,0 +1,19 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { proto } from '../../WAProto';
3
+ import { Chat, Contact } from '../Types';
4
+ export declare const downloadHistory: (msg: proto.Message.IHistorySyncNotification, options: AxiosRequestConfig<any>) => Promise<proto.HistorySync>;
5
+ export declare const processHistoryMessage: (item: proto.IHistorySync) => {
6
+ chats: Chat[];
7
+ contacts: Contact[];
8
+ messages: proto.IWebMessageInfo[];
9
+ syncType: proto.HistorySync.HistorySyncType;
10
+ progress: number | null | undefined;
11
+ };
12
+ export declare const downloadAndProcessHistorySyncNotification: (msg: proto.Message.IHistorySyncNotification, options: AxiosRequestConfig<any>) => Promise<{
13
+ chats: Chat[];
14
+ contacts: Contact[];
15
+ messages: proto.IWebMessageInfo[];
16
+ syncType: proto.HistorySync.HistorySyncType;
17
+ progress: number | null | undefined;
18
+ }>;
19
+ export declare const getHistoryMsg: (message: proto.IMessage) => proto.Message.IHistorySyncNotification | null | undefined;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getHistoryMsg = exports.downloadAndProcessHistorySyncNotification = exports.processHistoryMessage = exports.downloadHistory = void 0;
4
+ const util_1 = require("util");
5
+ const zlib_1 = require("zlib");
6
+ const WAProto_1 = require("../../WAProto");
7
+ const Types_1 = require("../Types");
8
+ const WABinary_1 = require("../WABinary");
9
+ const generics_1 = require("./generics");
10
+ const messages_1 = require("./messages");
11
+ const messages_media_1 = require("./messages-media");
12
+ const inflatePromise = (0, util_1.promisify)(zlib_1.inflate);
13
+ const downloadHistory = async (msg, options) => {
14
+ const stream = await (0, messages_media_1.downloadContentFromMessage)(msg, 'md-msg-hist', { options });
15
+ const bufferArray = [];
16
+ for await (const chunk of stream) {
17
+ bufferArray.push(chunk);
18
+ }
19
+ let buffer = Buffer.concat(bufferArray);
20
+ // decompress buffer
21
+ buffer = await inflatePromise(buffer);
22
+ const syncData = WAProto_1.proto.HistorySync.decode(buffer);
23
+ return syncData;
24
+ };
25
+ exports.downloadHistory = downloadHistory;
26
+ const processHistoryMessage = (item) => {
27
+ var _a, _b, _c;
28
+ const messages = [];
29
+ const contacts = [];
30
+ const chats = [];
31
+ switch (item.syncType) {
32
+ case WAProto_1.proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP:
33
+ case WAProto_1.proto.HistorySync.HistorySyncType.RECENT:
34
+ case WAProto_1.proto.HistorySync.HistorySyncType.FULL:
35
+ case WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND:
36
+ for (const chat of item.conversations) {
37
+ contacts.push({ id: chat.id, name: chat.name || undefined });
38
+ const msgs = chat.messages || [];
39
+ delete chat.messages;
40
+ delete chat.archived;
41
+ delete chat.muteEndTime;
42
+ delete chat.pinned;
43
+ for (const item of msgs) {
44
+ const message = item.message;
45
+ messages.push(message);
46
+ if (!((_a = chat.messages) === null || _a === void 0 ? void 0 : _a.length)) {
47
+ // keep only the most recent message in the chat array
48
+ chat.messages = [{ message }];
49
+ }
50
+ if (!message.key.fromMe && !chat.lastMessageRecvTimestamp) {
51
+ chat.lastMessageRecvTimestamp = (0, generics_1.toNumber)(message.messageTimestamp);
52
+ }
53
+ if ((message.messageStubType === Types_1.WAMessageStubType.BIZ_PRIVACY_MODE_TO_BSP
54
+ || message.messageStubType === Types_1.WAMessageStubType.BIZ_PRIVACY_MODE_TO_FB)
55
+ && ((_b = message.messageStubParameters) === null || _b === void 0 ? void 0 : _b[0])) {
56
+ contacts.push({
57
+ id: message.key.participant || message.key.remoteJid,
58
+ verifiedName: (_c = message.messageStubParameters) === null || _c === void 0 ? void 0 : _c[0],
59
+ });
60
+ }
61
+ }
62
+ if ((0, WABinary_1.isJidUser)(chat.id) && chat.readOnly && chat.archived) {
63
+ delete chat.readOnly;
64
+ }
65
+ chats.push({ ...chat });
66
+ }
67
+ break;
68
+ case WAProto_1.proto.HistorySync.HistorySyncType.PUSH_NAME:
69
+ for (const c of item.pushnames) {
70
+ contacts.push({ id: c.id, notify: c.pushname });
71
+ }
72
+ break;
73
+ }
74
+ return {
75
+ chats,
76
+ contacts,
77
+ messages,
78
+ syncType: item.syncType,
79
+ progress: item.progress
80
+ };
81
+ };
82
+ exports.processHistoryMessage = processHistoryMessage;
83
+ const downloadAndProcessHistorySyncNotification = async (msg, options) => {
84
+ const historyMsg = await (0, exports.downloadHistory)(msg, options);
85
+ return (0, exports.processHistoryMessage)(historyMsg);
86
+ };
87
+ exports.downloadAndProcessHistorySyncNotification = downloadAndProcessHistorySyncNotification;
88
+ const getHistoryMsg = (message) => {
89
+ var _a;
90
+ const normalizedContent = !!message ? (0, messages_1.normalizeMessageContent)(message) : undefined;
91
+ const anyHistoryMsg = (_a = normalizedContent === null || normalizedContent === void 0 ? void 0 : normalizedContent.protocolMessage) === null || _a === void 0 ? void 0 : _a.historySyncNotification;
92
+ return anyHistoryMsg;
93
+ };
94
+ exports.getHistoryMsg = getHistoryMsg;
@@ -0,0 +1,17 @@
1
+ export * from './generics';
2
+ export * from './decode-wa-message';
3
+ export * from './messages';
4
+ export * from './messages-media';
5
+ export * from './validate-connection';
6
+ export * from './crypto';
7
+ export * from './signal';
8
+ export * from './noise-handler';
9
+ export * from './history';
10
+ export * from './chat-utils';
11
+ export * from './lt-hash';
12
+ export * from './auth-utils';
13
+ export * from './baileys-event-stream';
14
+ export * from './use-multi-file-auth-state';
15
+ export * from './link-preview';
16
+ export * from './event-buffer';
17
+ export * from './process-message';
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./generics"), exports);
18
+ __exportStar(require("./decode-wa-message"), exports);
19
+ __exportStar(require("./messages"), exports);
20
+ __exportStar(require("./messages-media"), exports);
21
+ __exportStar(require("./validate-connection"), exports);
22
+ __exportStar(require("./crypto"), exports);
23
+ __exportStar(require("./signal"), exports);
24
+ __exportStar(require("./noise-handler"), exports);
25
+ __exportStar(require("./history"), exports);
26
+ __exportStar(require("./chat-utils"), exports);
27
+ __exportStar(require("./lt-hash"), exports);
28
+ __exportStar(require("./auth-utils"), exports);
29
+ __exportStar(require("./baileys-event-stream"), exports);
30
+ __exportStar(require("./use-multi-file-auth-state"), exports);
31
+ __exportStar(require("./link-preview"), exports);
32
+ __exportStar(require("./event-buffer"), exports);
33
+ __exportStar(require("./process-message"), exports);
@@ -0,0 +1,21 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { Logger } from 'pino';
3
+ import { WAMediaUploadFunction, WAUrlInfo } from '../Types';
4
+ export type URLGenerationOptions = {
5
+ thumbnailWidth: number;
6
+ fetchOpts: {
7
+ /** Timeout in ms */
8
+ timeout: number;
9
+ proxyUrl?: string;
10
+ headers?: AxiosRequestConfig<{}>['headers'];
11
+ };
12
+ uploadImage?: WAMediaUploadFunction;
13
+ logger?: Logger;
14
+ };
15
+ /**
16
+ * Given a piece of text, checks for any URL present, generates link preview for the same and returns it
17
+ * Return undefined if the fetch failed or no URL was found
18
+ * @param text first matched URL in text
19
+ * @returns the URL info required to generate link preview
20
+ */
21
+ export declare const getUrlInfo: (text: string, opts?: URLGenerationOptions) => Promise<WAUrlInfo | undefined>;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getUrlInfo = void 0;
4
+ const messages_1 = require("./messages");
5
+ const messages_media_1 = require("./messages-media");
6
+ const THUMBNAIL_WIDTH_PX = 192;
7
+ /** Fetches an image and generates a thumbnail for it */
8
+ const getCompressedJpegThumbnail = async (url, { thumbnailWidth, fetchOpts }) => {
9
+ const stream = await (0, messages_media_1.getHttpStream)(url, fetchOpts);
10
+ const result = await (0, messages_media_1.extractImageThumb)(stream, thumbnailWidth);
11
+ return result;
12
+ };
13
+ /**
14
+ * Given a piece of text, checks for any URL present, generates link preview for the same and returns it
15
+ * Return undefined if the fetch failed or no URL was found
16
+ * @param text first matched URL in text
17
+ * @returns the URL info required to generate link preview
18
+ */
19
+ const getUrlInfo = async (text, opts = {
20
+ thumbnailWidth: THUMBNAIL_WIDTH_PX,
21
+ fetchOpts: { timeout: 3000 }
22
+ }) => {
23
+ var _a;
24
+ try {
25
+ // retries
26
+ const retries = 0;
27
+ const maxRetry = 5;
28
+ const { getLinkPreview } = await import('link-preview-js');
29
+ let previewLink = text;
30
+ if (!text.startsWith('https://') && !text.startsWith('http://')) {
31
+ previewLink = 'https://' + previewLink;
32
+ }
33
+ const info = await getLinkPreview(previewLink, {
34
+ ...opts.fetchOpts,
35
+ followRedirects: 'follow',
36
+ handleRedirects: (baseURL, forwardedURL) => {
37
+ const urlObj = new URL(baseURL);
38
+ const forwardedURLObj = new URL(forwardedURL);
39
+ if (retries >= maxRetry) {
40
+ return false;
41
+ }
42
+ if (forwardedURLObj.hostname === urlObj.hostname
43
+ || forwardedURLObj.hostname === 'www.' + urlObj.hostname
44
+ || 'www.' + forwardedURLObj.hostname === urlObj.hostname) {
45
+ retries + 1;
46
+ return true;
47
+ }
48
+ else {
49
+ return false;
50
+ }
51
+ },
52
+ headers: opts.fetchOpts
53
+ });
54
+ if (info && 'title' in info && info.title) {
55
+ const [image] = info.images;
56
+ const urlInfo = {
57
+ 'canonical-url': info.url,
58
+ 'matched-text': text,
59
+ title: info.title,
60
+ description: info.description,
61
+ originalThumbnailUrl: image
62
+ };
63
+ if (opts.uploadImage) {
64
+ const { imageMessage } = await (0, messages_1.prepareWAMessageMedia)({ image: { url: image } }, {
65
+ upload: opts.uploadImage,
66
+ mediaTypeOverride: 'thumbnail-link',
67
+ options: opts.fetchOpts
68
+ });
69
+ urlInfo.jpegThumbnail = (imageMessage === null || imageMessage === void 0 ? void 0 : imageMessage.jpegThumbnail)
70
+ ? Buffer.from(imageMessage.jpegThumbnail)
71
+ : undefined;
72
+ urlInfo.highQualityThumbnail = imageMessage || undefined;
73
+ }
74
+ else {
75
+ try {
76
+ urlInfo.jpegThumbnail = image
77
+ ? (await getCompressedJpegThumbnail(image, opts)).buffer
78
+ : undefined;
79
+ }
80
+ catch (error) {
81
+ (_a = opts.logger) === null || _a === void 0 ? void 0 : _a.debug({ err: error.stack, url: previewLink }, 'error in generating thumbnail');
82
+ }
83
+ }
84
+ return urlInfo;
85
+ }
86
+ }
87
+ catch (error) {
88
+ if (!error.message.includes('receive a valid')) {
89
+ throw error;
90
+ }
91
+ }
92
+ };
93
+ exports.getUrlInfo = getUrlInfo;
@@ -0,0 +1,4 @@
1
+ declare const _default: import("pino").Logger<{
2
+ timestamp: () => string;
3
+ }>;
4
+ export default _default;