@deffa5556/bail 1.0.6 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (316) hide show
  1. package/cjs/WAProto/index.cjs +106053 -0
  2. package/cjs/deffa/config.cjs +14 -0
  3. package/cjs/deffa/plugins/ai/deepseekr1.cjs +35 -0
  4. package/cjs/deffa/plugins/ai/gita.cjs +26 -0
  5. package/cjs/deffa/plugins/ai/glm47flash.cjs +35 -0
  6. package/cjs/deffa/plugins/ai/gptoss120b.cjs +35 -0
  7. package/cjs/deffa/plugins/ai/qwq32b.cjs +35 -0
  8. package/cjs/deffa/plugins/berita/antara.cjs +25 -0
  9. package/cjs/deffa/plugins/berita/cnbcindonesia.cjs +25 -0
  10. package/cjs/deffa/plugins/berita/cnn.cjs +25 -0
  11. package/cjs/deffa/plugins/berita/kompas.cjs +25 -0
  12. package/cjs/deffa/plugins/berita/liputan6.cjs +25 -0
  13. package/cjs/deffa/plugins/berita/merdeka.cjs +25 -0
  14. package/cjs/deffa/plugins/berita/sindonews.cjs +25 -0
  15. package/cjs/deffa/plugins/berita/tribunnews.cjs +25 -0
  16. package/cjs/deffa/plugins/downloader/douyin.cjs +30 -0
  17. package/cjs/deffa/plugins/downloader/facebook.cjs +30 -0
  18. package/cjs/deffa/plugins/downloader/github.cjs +35 -0
  19. package/cjs/deffa/plugins/downloader/lahelu.cjs +30 -0
  20. package/cjs/deffa/plugins/downloader/snackvideo.cjs +30 -0
  21. package/cjs/deffa/plugins/downloader/soundcloud.cjs +30 -0
  22. package/cjs/deffa/plugins/downloader/tiktok.cjs +30 -0
  23. package/cjs/deffa/plugins/downloader/tiktokhd.cjs +30 -0
  24. package/cjs/deffa/plugins/downloader/twitter.cjs +30 -0
  25. package/cjs/deffa/plugins/downloader/ummy.cjs +36 -0
  26. package/cjs/deffa/plugins/index.cjs +213 -0
  27. package/cjs/deffa/plugins/info/bmkg.cjs +34 -0
  28. package/cjs/deffa/plugins/info/cuaca.cjs +31 -0
  29. package/cjs/deffa/plugins/info/jadwaltv.cjs +29 -0
  30. package/cjs/deffa/plugins/maker/brat.cjs +45 -0
  31. package/cjs/deffa/plugins/maker/bratvid.cjs +52 -0
  32. package/cjs/deffa/plugins/search/8font.cjs +28 -0
  33. package/cjs/deffa/plugins/search/applemusic.cjs +28 -0
  34. package/cjs/deffa/plugins/search/bimg.cjs +30 -0
  35. package/cjs/deffa/plugins/search/brave.cjs +34 -0
  36. package/cjs/deffa/plugins/search/duckduckgo.cjs +28 -0
  37. package/cjs/deffa/plugins/search/lahelu.cjs +28 -0
  38. package/cjs/deffa/plugins/search/mangatoon.cjs +28 -0
  39. package/cjs/deffa/plugins/search/mcpedl.cjs +28 -0
  40. package/cjs/deffa/plugins/search/myinstants.cjs +28 -0
  41. package/cjs/deffa/plugins/search/otakotaku.cjs +28 -0
  42. package/cjs/deffa/plugins/search/pinterest.cjs +30 -0
  43. package/cjs/deffa/plugins/search/resep.cjs +28 -0
  44. package/cjs/deffa/plugins/search/seegore.cjs +30 -0
  45. package/cjs/deffa/plugins/search/soundcloud.cjs +28 -0
  46. package/cjs/deffa/plugins/search/youtube.cjs +28 -0
  47. package/cjs/deffa/plugins/stalk/github.cjs +38 -0
  48. package/cjs/deffa/plugins/stalk/pinterest.cjs +37 -0
  49. package/cjs/deffa/plugins/stalk/threads.cjs +34 -0
  50. package/cjs/deffa/plugins/stalk/tiktok.cjs +37 -0
  51. package/cjs/deffa/plugins/stalk/twitter.cjs +37 -0
  52. package/cjs/deffa/plugins/stalk/youtube.cjs +37 -0
  53. package/cjs/lib/Defaults/index.cjs +158 -0
  54. package/cjs/lib/Discord/Client.cjs +263 -0
  55. package/cjs/lib/Discord/Constants.cjs +1842 -0
  56. package/cjs/lib/Discord/connect-dc.cjs +11 -0
  57. package/cjs/lib/Discord/esm-bridge.cjs +136 -0
  58. package/cjs/lib/Discord/gateway/Dispatcher.cjs +93 -0
  59. package/cjs/lib/Discord/gateway/Shard.cjs +695 -0
  60. package/cjs/lib/Discord/gateway/ShardManager.cjs +344 -0
  61. package/cjs/lib/Discord/gateway/compression/base.cjs +13 -0
  62. package/cjs/lib/Discord/gateway/compression/config.cjs +47 -0
  63. package/cjs/lib/Discord/gateway/compression/pako.cjs +44 -0
  64. package/cjs/lib/Discord/gateway/compression/zlib-native.cjs +47 -0
  65. package/cjs/lib/Discord/gateway/compression/zlib-sync.cjs +31 -0
  66. package/cjs/lib/Discord/gateway/compression/zstd-napi.cjs +80 -0
  67. package/cjs/lib/Discord/gateway/compression/zstd-native.cjs +46 -0
  68. package/cjs/lib/Discord/gateway/events.cjs +956 -0
  69. package/cjs/lib/Discord/index.cjs +238 -0
  70. package/cjs/lib/Discord/rest/Bucket.cjs +69 -0
  71. package/cjs/lib/Discord/rest/DiscordHTTPError.cjs +63 -0
  72. package/cjs/lib/Discord/rest/DiscordRESTError.cjs +84 -0
  73. package/cjs/lib/Discord/rest/OAuthHelper.cjs +226 -0
  74. package/cjs/lib/Discord/rest/RESTManager.cjs +116 -0
  75. package/cjs/lib/Discord/rest/RequestHandler.cjs +320 -0
  76. package/cjs/lib/Discord/rest/SequentialBucket.cjs +69 -0
  77. package/cjs/lib/Discord/routes/Applications.cjs +625 -0
  78. package/cjs/lib/Discord/routes/Channels.cjs +1199 -0
  79. package/cjs/lib/Discord/routes/Guilds.cjs +1792 -0
  80. package/cjs/lib/Discord/routes/Interactions.cjs +212 -0
  81. package/cjs/lib/Discord/routes/Lobbies.cjs +197 -0
  82. package/cjs/lib/Discord/routes/Miscellaneous.cjs +120 -0
  83. package/cjs/lib/Discord/routes/OAuth.cjs +350 -0
  84. package/cjs/lib/Discord/routes/Users.cjs +107 -0
  85. package/cjs/lib/Discord/routes/Webhooks.cjs +308 -0
  86. package/cjs/lib/Discord/structures/AnnouncementChannel.cjs +46 -0
  87. package/cjs/lib/Discord/structures/AnnouncementThreadChannel.cjs +28 -0
  88. package/cjs/lib/Discord/structures/Application.cjs +345 -0
  89. package/cjs/lib/Discord/structures/ApplicationCommand.cjs +109 -0
  90. package/cjs/lib/Discord/structures/Attachment.cjs +46 -0
  91. package/cjs/lib/Discord/structures/AuditLogEntry.cjs +41 -0
  92. package/cjs/lib/Discord/structures/AutoModerationRule.cjs +117 -0
  93. package/cjs/lib/Discord/structures/AutocompleteInteraction.cjs +90 -0
  94. package/cjs/lib/Discord/structures/Base.cjs +56 -0
  95. package/cjs/lib/Discord/structures/BaseEntitlement.cjs +40 -0
  96. package/cjs/lib/Discord/structures/CategoryChannel.cjs +102 -0
  97. package/cjs/lib/Discord/structures/Channel.cjs +89 -0
  98. package/cjs/lib/Discord/structures/ClientApplication.cjs +269 -0
  99. package/cjs/lib/Discord/structures/CommandInteraction.cjs +294 -0
  100. package/cjs/lib/Discord/structures/ComponentInteraction.cjs +306 -0
  101. package/cjs/lib/Discord/structures/Entitlement.cjs +24 -0
  102. package/cjs/lib/Discord/structures/ExtendedUser.cjs +48 -0
  103. package/cjs/lib/Discord/structures/ForumChannel.cjs +20 -0
  104. package/cjs/lib/Discord/structures/GroupChannel.cjs +160 -0
  105. package/cjs/lib/Discord/structures/Guild.cjs +1289 -0
  106. package/cjs/lib/Discord/structures/GuildChannel.cjs +82 -0
  107. package/cjs/lib/Discord/structures/GuildPreview.cjs +141 -0
  108. package/cjs/lib/Discord/structures/GuildScheduledEvent.cjs +166 -0
  109. package/cjs/lib/Discord/structures/GuildTemplate.cjs +96 -0
  110. package/cjs/lib/Discord/structures/Integration.cjs +123 -0
  111. package/cjs/lib/Discord/structures/Interaction.cjs +78 -0
  112. package/cjs/lib/Discord/structures/InteractionResolvedChannel.cjs +36 -0
  113. package/cjs/lib/Discord/structures/Invite.cjs +196 -0
  114. package/cjs/lib/Discord/structures/InviteGuild.cjs +117 -0
  115. package/cjs/lib/Discord/structures/InviteRole.cjs +88 -0
  116. package/cjs/lib/Discord/structures/Lobby.cjs +84 -0
  117. package/cjs/lib/Discord/structures/LobbyMember.cjs +30 -0
  118. package/cjs/lib/Discord/structures/MediaChannel.cjs +20 -0
  119. package/cjs/lib/Discord/structures/Member.cjs +300 -0
  120. package/cjs/lib/Discord/structures/Message.cjs +553 -0
  121. package/cjs/lib/Discord/structures/ModalSubmitInteraction.cjs +263 -0
  122. package/cjs/lib/Discord/structures/OAuthApplication.cjs +203 -0
  123. package/cjs/lib/Discord/structures/OAuthGuild.cjs +98 -0
  124. package/cjs/lib/Discord/structures/PartialApplication.cjs +97 -0
  125. package/cjs/lib/Discord/structures/Permission.cjs +61 -0
  126. package/cjs/lib/Discord/structures/PermissionOverwrite.cjs +46 -0
  127. package/cjs/lib/Discord/structures/PingInteraction.cjs +27 -0
  128. package/cjs/lib/Discord/structures/Poll.cjs +69 -0
  129. package/cjs/lib/Discord/structures/PrimaryGuild.cjs +93 -0
  130. package/cjs/lib/Discord/structures/PrivateChannel.cjs +131 -0
  131. package/cjs/lib/Discord/structures/PrivateThreadChannel.cjs +28 -0
  132. package/cjs/lib/Discord/structures/PublicThreadChannel.cjs +36 -0
  133. package/cjs/lib/Discord/structures/Role.cjs +126 -0
  134. package/cjs/lib/Discord/structures/SKU.cjs +58 -0
  135. package/cjs/lib/Discord/structures/Soundboard.cjs +58 -0
  136. package/cjs/lib/Discord/structures/StageChannel.cjs +45 -0
  137. package/cjs/lib/Discord/structures/StageInstance.cjs +80 -0
  138. package/cjs/lib/Discord/structures/Subscription.cjs +21 -0
  139. package/cjs/lib/Discord/structures/Team.cjs +70 -0
  140. package/cjs/lib/Discord/structures/TestEntitlement.cjs +22 -0
  141. package/cjs/lib/Discord/structures/TextChannel.cjs +48 -0
  142. package/cjs/lib/Discord/structures/TextableChannel.cjs +265 -0
  143. package/cjs/lib/Discord/structures/TextableVoiceChannel.cjs +70 -0
  144. package/cjs/lib/Discord/structures/ThreadChannel.cjs +276 -0
  145. package/cjs/lib/Discord/structures/ThreadOnlyChannel.cjs +205 -0
  146. package/cjs/lib/Discord/structures/ThreadableChannel.cjs +57 -0
  147. package/cjs/lib/Discord/structures/UnavailableGuild.cjs +21 -0
  148. package/cjs/lib/Discord/structures/User.cjs +223 -0
  149. package/cjs/lib/Discord/structures/VoiceChannel.cjs +34 -0
  150. package/cjs/lib/Discord/structures/VoiceState.cjs +113 -0
  151. package/cjs/lib/Discord/structures/Webhook.cjs +224 -0
  152. package/cjs/lib/Discord/util/Collection.cjs +77 -0
  153. package/cjs/lib/Discord/util/Errors.cjs +81 -0
  154. package/cjs/lib/Discord/util/QueryBuilder.cjs +20 -0
  155. package/cjs/lib/Discord/util/Routes.cjs +293 -0
  156. package/cjs/lib/Discord/util/SimpleCollection.cjs +78 -0
  157. package/cjs/lib/Discord/util/Time.cjs +92 -0
  158. package/cjs/lib/Discord/util/TypedCollection.cjs +78 -0
  159. package/cjs/lib/Discord/util/TypedEmitter.cjs +20 -0
  160. package/cjs/lib/Discord/util/Util.cjs +906 -0
  161. package/cjs/lib/Discord/util/interactions/InteractionOptionsWrapper.cjs +207 -0
  162. package/cjs/lib/Discord/util/interactions/MessageInteractionResponse.cjs +26 -0
  163. package/cjs/lib/Discord/util/interactions/ModalSubmitInteractionComponentsWrapper.cjs +98 -0
  164. package/cjs/lib/Discord/util/interactions/SelectMenuValuesWrapper.cjs +77 -0
  165. package/cjs/lib/Discord/util/interactions/shared.cjs +20 -0
  166. package/cjs/lib/Discord/util/warning.cjs +34 -0
  167. package/cjs/lib/Signal/Group/ciphertext-message.cjs +16 -0
  168. package/cjs/lib/Signal/Group/group-session-builder.cjs +67 -0
  169. package/cjs/lib/Signal/Group/group_cipher.cjs +86 -0
  170. package/cjs/lib/Signal/Group/index.cjs +58 -0
  171. package/cjs/lib/Signal/Group/keyhelper.cjs +56 -0
  172. package/cjs/lib/Signal/Group/sender-chain-key.cjs +30 -0
  173. package/cjs/lib/Signal/Group/sender-key-distribution-message.cjs +67 -0
  174. package/cjs/lib/Signal/Group/sender-key-message.cjs +70 -0
  175. package/cjs/lib/Signal/Group/sender-key-name.cjs +52 -0
  176. package/cjs/lib/Signal/Group/sender-key-record.cjs +45 -0
  177. package/cjs/lib/Signal/Group/sender-key-state.cjs +88 -0
  178. package/cjs/lib/Signal/Group/sender-message-key.cjs +30 -0
  179. package/cjs/lib/Signal/libsignal.cjs +467 -0
  180. package/cjs/lib/Signal/lid-mapping.cjs +281 -0
  181. package/cjs/lib/Socket/Client/index.cjs +19 -0
  182. package/cjs/lib/Socket/Client/types.cjs +15 -0
  183. package/cjs/lib/Socket/Client/websocket.cjs +61 -0
  184. package/cjs/lib/Socket/business.cjs +384 -0
  185. package/cjs/lib/Socket/chats.cjs +1221 -0
  186. package/cjs/lib/Socket/communities.cjs +440 -0
  187. package/cjs/lib/Socket/groups.cjs +353 -0
  188. package/cjs/lib/Socket/index.cjs +14 -0
  189. package/cjs/lib/Socket/messages-recv.cjs +1772 -0
  190. package/cjs/lib/Socket/messages-send.cjs +1376 -0
  191. package/cjs/lib/Socket/mex.cjs +46 -0
  192. package/cjs/lib/Socket/newsletter.cjs +230 -0
  193. package/cjs/lib/Socket/socket.cjs +976 -0
  194. package/cjs/lib/Store/index.cjs +20 -0
  195. package/cjs/lib/Store/make-in-memory-store.cjs +470 -0
  196. package/cjs/lib/Store/make-ordered-dictionary.cjs +82 -0
  197. package/cjs/lib/Store/object-repository.cjs +28 -0
  198. package/cjs/lib/Telegram/button.cjs +147 -0
  199. package/cjs/lib/Telegram/composer.cjs +582 -0
  200. package/cjs/lib/Telegram/context.cjs +853 -0
  201. package/cjs/lib/Telegram/core/helpers/args.cjs +57 -0
  202. package/cjs/lib/Telegram/core/helpers/check.cjs +55 -0
  203. package/cjs/lib/Telegram/core/helpers/compact.cjs +16 -0
  204. package/cjs/lib/Telegram/core/helpers/deunionize.cjs +12 -0
  205. package/cjs/lib/Telegram/core/helpers/formatting.cjs +91 -0
  206. package/cjs/lib/Telegram/core/helpers/util.cjs +50 -0
  207. package/cjs/lib/Telegram/core/network/client.cjs +338 -0
  208. package/cjs/lib/Telegram/core/network/error.cjs +21 -0
  209. package/cjs/lib/Telegram/core/network/multipart-stream.cjs +79 -0
  210. package/cjs/lib/Telegram/core/network/polling.cjs +87 -0
  211. package/cjs/lib/Telegram/core/network/webhook.cjs +54 -0
  212. package/cjs/lib/Telegram/core/types/typegram.cjs +31 -0
  213. package/cjs/lib/Telegram/deffa-telegraf.cjs +264 -0
  214. package/cjs/lib/Telegram/esm-bridge.cjs +20 -0
  215. package/cjs/lib/Telegram/filters.cjs +69 -0
  216. package/cjs/lib/Telegram/format.cjs +58 -0
  217. package/cjs/lib/Telegram/future.cjs +140 -0
  218. package/cjs/lib/Telegram/index.cjs +67 -0
  219. package/cjs/lib/Telegram/input.cjs +61 -0
  220. package/cjs/lib/Telegram/markup.cjs +129 -0
  221. package/cjs/lib/Telegram/middleware.cjs +2 -0
  222. package/cjs/lib/Telegram/reactions.cjs +84 -0
  223. package/cjs/lib/Telegram/router.cjs +46 -0
  224. package/cjs/lib/Telegram/scenes/base.cjs +39 -0
  225. package/cjs/lib/Telegram/scenes/context.cjs +104 -0
  226. package/cjs/lib/Telegram/scenes/index.cjs +21 -0
  227. package/cjs/lib/Telegram/scenes/stage.cjs +49 -0
  228. package/cjs/lib/Telegram/scenes/wizard/context.cjs +31 -0
  229. package/cjs/lib/Telegram/scenes/wizard/index.cjs +45 -0
  230. package/cjs/lib/Telegram/scenes.cjs +21 -0
  231. package/cjs/lib/Telegram/session.cjs +166 -0
  232. package/cjs/lib/Telegram/telegram-types.cjs +6 -0
  233. package/cjs/lib/Telegram/telegram.cjs +945 -0
  234. package/cjs/lib/Telegram/types.cjs +2 -0
  235. package/cjs/lib/Telegram/utils.cjs +5 -0
  236. package/cjs/lib/Types/Auth.cjs +3 -0
  237. package/cjs/lib/Types/Bussines.cjs +3 -0
  238. package/cjs/lib/Types/Call.cjs +3 -0
  239. package/cjs/lib/Types/Chat.cjs +11 -0
  240. package/cjs/lib/Types/Contact.cjs +3 -0
  241. package/cjs/lib/Types/Events.cjs +4 -0
  242. package/cjs/lib/Types/GroupMetadata.cjs +3 -0
  243. package/cjs/lib/Types/Label.cjs +26 -0
  244. package/cjs/lib/Types/LabelAssociation.cjs +8 -0
  245. package/cjs/lib/Types/Message.cjs +19 -0
  246. package/cjs/lib/Types/Mex.cjs +40 -0
  247. package/cjs/lib/Types/Product.cjs +3 -0
  248. package/cjs/lib/Types/RichType.cjs +24 -0
  249. package/cjs/lib/Types/Signal.cjs +4 -0
  250. package/cjs/lib/Types/Socket.cjs +4 -0
  251. package/cjs/lib/Types/State.cjs +54 -0
  252. package/cjs/lib/Types/USync.cjs +4 -0
  253. package/cjs/lib/Types/index.cjs +42 -0
  254. package/cjs/lib/Utils/auth-utils.cjs +312 -0
  255. package/cjs/lib/Utils/browser-utils.cjs +39 -0
  256. package/cjs/lib/Utils/business.cjs +241 -0
  257. package/cjs/lib/Utils/chat-utils.cjs +890 -0
  258. package/cjs/lib/Utils/companion-reg-client-utils.cjs +51 -0
  259. package/cjs/lib/Utils/crypto.cjs +170 -0
  260. package/cjs/lib/Utils/decode-wa-message.cjs +330 -0
  261. package/cjs/lib/Utils/event-buffer.cjs +629 -0
  262. package/cjs/lib/Utils/generics.cjs +427 -0
  263. package/cjs/lib/Utils/history.cjs +141 -0
  264. package/cjs/lib/Utils/identity-change-handler.cjs +56 -0
  265. package/cjs/lib/Utils/index.cjs +43 -0
  266. package/cjs/lib/Utils/link-preview.cjs +122 -0
  267. package/cjs/lib/Utils/logger.cjs +8 -0
  268. package/cjs/lib/Utils/lt-hash.cjs +11 -0
  269. package/cjs/lib/Utils/make-mutex.cjs +38 -0
  270. package/cjs/lib/Utils/message-retry-manager.cjs +267 -0
  271. package/cjs/lib/Utils/messages-media.cjs +906 -0
  272. package/cjs/lib/Utils/messages.cjs +1909 -0
  273. package/cjs/lib/Utils/noise-handler.cjs +205 -0
  274. package/cjs/lib/Utils/offline-node-processor.cjs +43 -0
  275. package/cjs/lib/Utils/pre-key-manager.cjs +113 -0
  276. package/cjs/lib/Utils/process-message.cjs +755 -0
  277. package/cjs/lib/Utils/reporting-utils.cjs +263 -0
  278. package/cjs/lib/Utils/rich-message-utils.cjs +434 -0
  279. package/cjs/lib/Utils/session-guard.cjs +163 -0
  280. package/cjs/lib/Utils/signal.cjs +214 -0
  281. package/cjs/lib/Utils/stanza-ack.cjs +41 -0
  282. package/cjs/lib/Utils/sync-action-utils.cjs +54 -0
  283. package/cjs/lib/Utils/tc-token-utils.cjs +174 -0
  284. package/cjs/lib/Utils/text-sticker.cjs +174 -0
  285. package/cjs/lib/Utils/use-multi-file-auth-state.cjs +125 -0
  286. package/cjs/lib/Utils/use-single-file-auth-state.cjs +113 -0
  287. package/cjs/lib/Utils/use-sqlite-auth-state.cjs +145 -0
  288. package/cjs/lib/Utils/validate-connection.cjs +210 -0
  289. package/cjs/lib/WABinary/constants.cjs +1470 -0
  290. package/cjs/lib/WABinary/decode.cjs +301 -0
  291. package/cjs/lib/WABinary/encode.cjs +257 -0
  292. package/cjs/lib/WABinary/generic-utils.cjs +240 -0
  293. package/cjs/lib/WABinary/index.cjs +22 -0
  294. package/cjs/lib/WABinary/jid-utils.cjs +114 -0
  295. package/cjs/lib/WABinary/types.cjs +37 -0
  296. package/cjs/lib/WAM/BinaryInfo.cjs +14 -0
  297. package/cjs/lib/WAM/constants.cjs +22856 -0
  298. package/cjs/lib/WAM/encode.cjs +154 -0
  299. package/cjs/lib/WAM/index.cjs +20 -0
  300. package/cjs/lib/WAUSync/Protocols/USyncContactProtocol.cjs +56 -0
  301. package/cjs/lib/WAUSync/Protocols/USyncDeviceProtocol.cjs +58 -0
  302. package/cjs/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.cjs +31 -0
  303. package/cjs/lib/WAUSync/Protocols/USyncStatusProtocol.cjs +42 -0
  304. package/cjs/lib/WAUSync/Protocols/USyncUsernameProtocol.cjs +29 -0
  305. package/cjs/lib/WAUSync/Protocols/UsyncBotProfileProtocol.cjs +55 -0
  306. package/cjs/lib/WAUSync/Protocols/UsyncLIDProtocol.cjs +33 -0
  307. package/cjs/lib/WAUSync/Protocols/index.cjs +22 -0
  308. package/cjs/lib/WAUSync/USyncQuery.cjs +102 -0
  309. package/cjs/lib/WAUSync/USyncUser.cjs +35 -0
  310. package/cjs/lib/WAUSync/index.cjs +20 -0
  311. package/cjs/lib/index.cjs +372 -0
  312. package/cjs/lib/plugins/loader.cjs +117 -0
  313. package/lib/Defaults/index.js +1 -1
  314. package/lib/Socket/socket.js +3 -3
  315. package/lib/Telegram/esm-bridge.mjs +1 -1
  316. package/package.json +11 -6
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Errors_1 = require("../Errors.cjs");
4
+ const Constants_1 = require("../../Constants.cjs");
5
+ /** A wrapper for interaction options. */
6
+ class InteractionOptionsWrapper {
7
+ constructor(data, resolved) {
8
+ this.raw = data;
9
+ this.resolved = resolved;
10
+ }
11
+ _getOption(name, required = false, type) {
12
+ const opt = this.getOptions().find(o => o.name === name && o.type === type);
13
+ if (!opt && required) {
14
+ throw new Errors_1.WrapperError(`Missing required option: ${name}`);
15
+ }
16
+ else {
17
+ return opt;
18
+ }
19
+ }
20
+ getAttachment(name, required) {
21
+ if (this.resolved === null) {
22
+ throw new TypeError("Attempt to use getAttachment with null resolved. If this is on an autocomplete interaction, use getAttachmentOption instead.");
23
+ }
24
+ let val;
25
+ if (!(val = this.getAttachmentOption(name, required)?.value)) {
26
+ return undefined;
27
+ }
28
+ const a = this.resolved.attachments.get(val);
29
+ if (!a && required) {
30
+ throw new Errors_1.WrapperError(`Attachment not present for required option: ${name}`);
31
+ }
32
+ return a;
33
+ }
34
+ getAttachmentOption(name, required) {
35
+ return this._getOption(name, required, Constants_1.ApplicationCommandOptionTypes.ATTACHMENT);
36
+ }
37
+ getBoolean(name, required) {
38
+ return this.getBooleanOption(name, required)?.value;
39
+ }
40
+ getBooleanOption(name, required) {
41
+ return this._getOption(name, required, Constants_1.ApplicationCommandOptionTypes.BOOLEAN);
42
+ }
43
+ getChannel(name, required) {
44
+ if (this.resolved === null) {
45
+ throw new TypeError("Attempt to use getChannel with null resolved. If this is on an autocomplete interaction, use getChannelOption instead.");
46
+ }
47
+ let val;
48
+ if (!(val = this.getChannelOption(name, required)?.value)) {
49
+ return undefined;
50
+ }
51
+ const ch = this.resolved.channels.get(val);
52
+ if (!ch && required) {
53
+ throw new Errors_1.WrapperError(`Channel not present for required option: ${name}`);
54
+ }
55
+ return ch;
56
+ }
57
+ getChannelOption(name, required) {
58
+ return this._getOption(name, required, Constants_1.ApplicationCommandOptionTypes.CHANNEL);
59
+ }
60
+ getCompleteChannel(name, required) {
61
+ const resolved = this.getChannel(name, required);
62
+ if (!resolved) {
63
+ return undefined; // required will be handled in getChannel
64
+ }
65
+ const channel = resolved.completeChannel ?? (resolved.type === Constants_1.ChannelTypes.DM ? resolved : undefined);
66
+ if (!channel && required) {
67
+ throw new Errors_1.WrapperError(`Failed to resolve complete channel for required option: ${name}`);
68
+ }
69
+ return channel;
70
+ }
71
+ getFocused(required) {
72
+ const opt = this.getOptions().find(o => o.focused === true);
73
+ if (!opt && required) {
74
+ throw new Errors_1.WrapperError("Missing required focused option");
75
+ }
76
+ else {
77
+ return opt;
78
+ }
79
+ }
80
+ getInteger(name, required) {
81
+ return this.getIntegerOption(name, required)?.value;
82
+ }
83
+ getIntegerOption(name, required) {
84
+ return this._getOption(name, required, Constants_1.ApplicationCommandOptionTypes.INTEGER);
85
+ }
86
+ getMember(name, required) {
87
+ if (this.resolved === null) {
88
+ throw new TypeError("Attempt to use getMember with null resolved. If this is on an autocomplete interaction, use getUserOption instead.");
89
+ }
90
+ let val;
91
+ if (!(val = this.getUserOption(name, required)?.value)) {
92
+ return undefined;
93
+ }
94
+ const ch = this.resolved.members.get(val);
95
+ if (!ch && required) {
96
+ throw new Errors_1.WrapperError(`Member not present for required option: ${name}`);
97
+ }
98
+ return ch;
99
+ }
100
+ getMentionable(name, required) {
101
+ if (this.resolved === null) {
102
+ throw new TypeError("Attempt to use getMentionable with null resolved. If this is on an autocomplete interaction, use getAttachmentOption instead.");
103
+ }
104
+ let val;
105
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
106
+ if (!(val = this._getOption(name, required, Constants_1.ApplicationCommandOptionTypes.MENTIONABLE)?.value)) {
107
+ return undefined;
108
+ }
109
+ const role = this.resolved.roles.get(val);
110
+ const user = this.resolved.users.get(val);
111
+ if ((!role && !user) && required) {
112
+ throw new Errors_1.WrapperError(`Value not present for required option: ${name}`);
113
+ }
114
+ return role ?? user;
115
+ }
116
+ getMentionableOption(name, required) {
117
+ return this._getOption(name, required, Constants_1.ApplicationCommandOptionTypes.MENTIONABLE);
118
+ }
119
+ getNumber(name, required) {
120
+ return this.getNumberOption(name, required)?.value;
121
+ }
122
+ getNumberOption(name, required) {
123
+ return this._getOption(name, required, Constants_1.ApplicationCommandOptionTypes.NUMBER);
124
+ }
125
+ /** Get the options received in this interaction, excluding subcommands and subcommand groups. */
126
+ getOptions() {
127
+ let baseOptions;
128
+ const sub = this.getSubCommand(false) ?? [];
129
+ switch (sub.length) {
130
+ case 0: {
131
+ baseOptions = this.raw;
132
+ break;
133
+ }
134
+ case 1: {
135
+ baseOptions = this.raw.find(o => o.name === sub[0] && o.type === Constants_1.ApplicationCommandOptionTypes.SUB_COMMAND)?.options;
136
+ break;
137
+ }
138
+ case 2: {
139
+ baseOptions = this.raw.find(o => o.name === sub[0] && o.type === Constants_1.ApplicationCommandOptionTypes.SUB_COMMAND_GROUP)?.options?.find(o2 => o2.name === sub[1] && o2.type === Constants_1.ApplicationCommandOptionTypes.SUB_COMMAND)?.options;
140
+ break;
141
+ }
142
+ }
143
+ return baseOptions ?? [];
144
+ }
145
+ getRole(name, required) {
146
+ if (this.resolved === null) {
147
+ throw new TypeError("Attempt to use getRole with null resolved. If this is on an autocomplete interaction, use getRoleOption instead.");
148
+ }
149
+ let val;
150
+ if (!(val = this.getRoleOption(name, required)?.value)) {
151
+ return undefined;
152
+ }
153
+ const ch = this.resolved.roles.get(val);
154
+ if (!ch && required) {
155
+ throw new Errors_1.WrapperError(`Role not present for required option: ${name}`);
156
+ }
157
+ return ch;
158
+ }
159
+ getRoleOption(name, required) {
160
+ return this._getOption(name, required, Constants_1.ApplicationCommandOptionTypes.ROLE);
161
+ }
162
+ getString(name, required) {
163
+ return this.getStringOption(name, required)?.value;
164
+ }
165
+ getStringOption(name, required) {
166
+ return this._getOption(name, required, Constants_1.ApplicationCommandOptionTypes.STRING);
167
+ }
168
+ getSubCommand(required) {
169
+ const opt = this.raw.find(o => o.type === Constants_1.ApplicationCommandOptionTypes.SUB_COMMAND || o.type === Constants_1.ApplicationCommandOptionTypes.SUB_COMMAND_GROUP);
170
+ if (opt?.options) {
171
+ // nested
172
+ if (opt.options.length === 1 && opt.type === Constants_1.ApplicationCommandOptionTypes.SUB_COMMAND_GROUP) {
173
+ const sub = opt.options.find(o => o.type === Constants_1.ApplicationCommandOptionTypes.SUB_COMMAND);
174
+ return sub?.options ? [opt.name, sub.name] : [opt.name];
175
+ }
176
+ else {
177
+ return [opt.name];
178
+ }
179
+ }
180
+ else {
181
+ if (required) {
182
+ throw new Errors_1.WrapperError("Missing required option: SubCommand/SubCommandGroup.");
183
+ }
184
+ else {
185
+ return undefined;
186
+ }
187
+ }
188
+ }
189
+ getUser(name, required) {
190
+ if (this.resolved === null) {
191
+ throw new TypeError("Attempt to use getUser with null resolved. If this is on an autocomplete interaction, use getUseOption instead.");
192
+ }
193
+ let val;
194
+ if (!(val = this.getUserOption(name, required)?.value)) {
195
+ return undefined;
196
+ }
197
+ const ch = this.resolved.users.get(val);
198
+ if (!ch && required) {
199
+ throw new Errors_1.WrapperError(`User not present for required option: ${name}`);
200
+ }
201
+ return ch;
202
+ }
203
+ getUserOption(name, required) {
204
+ return this._getOption(name, required, Constants_1.ApplicationCommandOptionTypes.USER);
205
+ }
206
+ }
207
+ exports.default = InteractionOptionsWrapper;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class MessageInteractionResponse {
4
+ constructor(interaction, message, type, callback) {
5
+ this.interaction = interaction;
6
+ this.message = message;
7
+ this.type = type;
8
+ this.callback = callback;
9
+ }
10
+ async deleteMessage() {
11
+ if (this.message !== null) {
12
+ return this.interaction.deleteFollowup(this.message.id);
13
+ }
14
+ return this.interaction.deleteOriginal();
15
+ }
16
+ async getMessage() {
17
+ if (this.message !== null) {
18
+ return this.message;
19
+ }
20
+ if (this.callback?.resource?.message) {
21
+ return this.callback.resource.message;
22
+ }
23
+ return this.interaction.getOriginal();
24
+ }
25
+ }
26
+ exports.default = MessageInteractionResponse;
@@ -0,0 +1,98 @@
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
+ /** @module ModalSubmitInteractionComponentsWrapper */
7
+ const shared_1 = require("./shared.cjs");
8
+ const Errors_1 = require("../Errors.cjs");
9
+ const Constants_1 = require("../../Constants.cjs");
10
+ const Collection_1 = __importDefault(require("../Collection.cjs"));
11
+ /** A wrapper for interaction components. */
12
+ class ModalSubmitInteractionComponentsWrapper {
13
+ constructor(resolved, data) {
14
+ this.raw = data;
15
+ this.resolved = resolved;
16
+ }
17
+ _getComponent(customID, required = false, type) {
18
+ const opt = this.getComponents().find(o => o.customID === customID && o.type === type);
19
+ if (!opt && required) {
20
+ throw new Errors_1.WrapperError(`Missing required component: ${customID}`);
21
+ }
22
+ else {
23
+ return opt;
24
+ }
25
+ }
26
+ getChannelSelectComponent(name, required) {
27
+ return this._getComponent(name, required, Constants_1.ComponentTypes.CHANNEL_SELECT);
28
+ }
29
+ getChannelSelectValues(name, required) {
30
+ const component = this.getChannelSelectComponent(name, required);
31
+ return component?.values && (0, shared_1.mapRawToResolved)("channel", component.values, this.resolved.channels, false);
32
+ }
33
+ getCheckboxComponent(name, required) {
34
+ return this._getComponent(name, required, Constants_1.ComponentTypes.CHECKBOX);
35
+ }
36
+ getCheckboxGroupComponent(name, required) {
37
+ return this._getComponent(name, required, Constants_1.ComponentTypes.CHECKBOX_GROUP);
38
+ }
39
+ getCheckboxGroupValues(name, required) {
40
+ return this.getCheckboxGroupComponent(name, required)?.values;
41
+ }
42
+ getCheckboxValue(name, required) {
43
+ return this.getCheckboxComponent(name, required)?.value;
44
+ }
45
+ /** Get the components in this interaction. */
46
+ getComponents() {
47
+ return this.raw
48
+ .flatMap(r => r.type === Constants_1.ComponentTypes.ACTION_ROW ? r.components : r.component)
49
+ .filter(c => c !== undefined);
50
+ }
51
+ getFileUploadComponent(name, required) {
52
+ return this._getComponent(name, required, Constants_1.ComponentTypes.FILE_UPLOAD);
53
+ }
54
+ getFileUploadValues(name, required) {
55
+ const component = this.getFileUploadComponent(name, required);
56
+ return component?.values && (0, shared_1.mapRawToResolved)("attachment", component.values, this.resolved.attachments, false);
57
+ }
58
+ getMentionableSelectComponent(name, required) {
59
+ return this._getComponent(name, required, Constants_1.ComponentTypes.MENTIONABLE_SELECT);
60
+ }
61
+ getMentionableSelectValues(name, required) {
62
+ const component = this.getMentionableSelectComponent(name, required);
63
+ return component?.values && (0, shared_1.mapRawToResolved)("mentionable", component.values, new Collection_1.default([...this.resolved.users, ...this.resolved.roles]), false);
64
+ }
65
+ getRadioGroupComponent(name, required) {
66
+ return this._getComponent(name, required, Constants_1.ComponentTypes.RADIO_GROUP);
67
+ }
68
+ getRadioGroupValue(name, required) {
69
+ return this.getRadioGroupComponent(name, required)?.value;
70
+ }
71
+ getRoleSelectComponent(name, required) {
72
+ return this._getComponent(name, required, Constants_1.ComponentTypes.ROLE_SELECT);
73
+ }
74
+ getRoleSelectValues(name, required) {
75
+ const component = this.getRoleSelectComponent(name, required);
76
+ return component?.values && (0, shared_1.mapRawToResolved)("role", component.values, this.resolved.roles, false);
77
+ }
78
+ getStringSelectComponent(name, required) {
79
+ return this._getComponent(name, required, Constants_1.ComponentTypes.STRING_SELECT);
80
+ }
81
+ getStringSelectValues(name, required) {
82
+ return this.getStringSelectComponent(name, required)?.values;
83
+ }
84
+ getTextInput(name, required) {
85
+ return this.getTextInputComponent(name, required)?.value;
86
+ }
87
+ getTextInputComponent(name, required) {
88
+ return this._getComponent(name, required, Constants_1.ComponentTypes.TEXT_INPUT);
89
+ }
90
+ getUserSelectComponent(name, required) {
91
+ return this._getComponent(name, required, Constants_1.ComponentTypes.USER_SELECT);
92
+ }
93
+ getUserSelectValues(name, required) {
94
+ const component = this.getUserSelectComponent(name, required);
95
+ return component?.values && (0, shared_1.mapRawToResolved)("user", component.values, this.resolved.users, false);
96
+ }
97
+ }
98
+ exports.default = ModalSubmitInteractionComponentsWrapper;
@@ -0,0 +1,77 @@
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
+ /** @module SelectMenuValuesWrapper */
7
+ const shared_1 = require("./shared.cjs");
8
+ const Constants_1 = require("../../Constants.cjs");
9
+ const Collection_1 = __importDefault(require("../Collection.cjs"));
10
+ /** A wrapper for select menu data. */
11
+ class SelectMenuValuesWrapper {
12
+ constructor(resolved, values) {
13
+ this.resolved = resolved;
14
+ this.raw = values;
15
+ }
16
+ /**
17
+ * Get the selected channels.
18
+ *
19
+ * If `ensurePresent` is false, channels that aren't in resolved will be ignored.
20
+ * @param ensurePresent If true, an error will be thrown if any value cannot be mapped to a channel.
21
+ */
22
+ getChannels(ensurePresent) {
23
+ return (0, shared_1.mapRawToResolved)("channel", this.raw, this.resolved.channels, ensurePresent);
24
+ }
25
+ /**
26
+ * Get the complete version of the selected channels. This will only succeed if the channel is cached. If the channel is private and isn't cached, an `InteractionResolvedChannel` instance will still be returned.
27
+ *
28
+ * If `ensurePresent` is false, channels that aren't in resolved will be ignored.
29
+ * @param ensurePresent If true, an error will be thrown if any value cannot be mapped to a channel.
30
+ */
31
+ getCompleteChannels(ensurePresent) {
32
+ return this.getChannels(ensurePresent).map(ch => ch.type === Constants_1.ChannelTypes.DM ? ch.completeChannel ?? ch : ch);
33
+ }
34
+ /**
35
+ * Get the selected members.
36
+ *
37
+ * If `ensurePresent` is false, members that aren't in resolved will be ignored.
38
+ * @param ensurePresent If true, an error will be thrown if any value cannot be mapped to a member.
39
+ */
40
+ getMembers(ensurePresent) {
41
+ return (0, shared_1.mapRawToResolved)("member", this.raw, this.resolved.members, ensurePresent);
42
+ }
43
+ /**
44
+ * Get the selected mentionables. (users, roles)
45
+ *
46
+ * If `ensurePresent` is false, mentionables that aren't in resolved will be ignored.
47
+ * @param ensurePresent If true, an error will be thrown if any value cannot be mapped to a user, or role.
48
+ */
49
+ getMentionables(ensurePresent) {
50
+ return (0, shared_1.mapRawToResolved)("mentionable", this.raw, new Collection_1.default([...this.resolved.users, ...this.resolved.roles]), ensurePresent);
51
+ }
52
+ /**
53
+ * Get the selected roles.
54
+ *
55
+ * If `ensurePresent` is false, roles that aren't in resolved will be ignored.
56
+ * @param ensurePresent If true, an error will be thrown if any value cannot be mapped to a role.
57
+ */
58
+ getRoles(ensurePresent) {
59
+ return (0, shared_1.mapRawToResolved)("role", this.raw, this.resolved.roles, ensurePresent);
60
+ }
61
+ /**
62
+ * Get the selected string values. This cannot fail.
63
+ */
64
+ getStrings() {
65
+ return this.raw;
66
+ }
67
+ /**
68
+ * Get the selected users.
69
+ *
70
+ * If `ensurePresent` is false, users that aren't in resolved will be ignored.
71
+ * @param ensurePresent If true, an error will be thrown if any value cannot be mapped to a user.
72
+ */
73
+ getUsers(ensurePresent) {
74
+ return (0, shared_1.mapRawToResolved)("user", this.raw, this.resolved.users, ensurePresent);
75
+ }
76
+ }
77
+ exports.default = SelectMenuValuesWrapper;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapRawToResolved = mapRawToResolved;
4
+ const Errors_1 = require("../Errors.cjs");
5
+ /**
6
+ * Maps raw select menu values to resolved objects.
7
+ *
8
+ * If `ensurePresent` is false, values that aren't in `resolved` will be ignored.
9
+ */
10
+ function mapRawToResolved(type, raw, resolved, ensurePresent = false) {
11
+ return raw
12
+ .map(id => {
13
+ const value = resolved.get(id);
14
+ if (!value && ensurePresent) {
15
+ throw new Errors_1.WrapperError(`Failed to find ${type} in resolved data: ${id}`);
16
+ }
17
+ return value;
18
+ })
19
+ .filter(Boolean);
20
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WarningCodes = void 0;
4
+ exports.warning = warning;
5
+ var WarningCodes;
6
+ (function (WarningCodes) {
7
+ WarningCodes["OCEANIC_CACHE_DISABLED"] = "OCEANIC_CACHE_DISABLED";
8
+ WarningCodes["OCEANIC_COLLECTIONS_LIMIT_WITH_CACHE_DISABLED"] = "OCEANIC_COLLECTIONS_LIMIT_WITH_CACHE_DISABLED";
9
+ WarningCodes["OCEANIC_AUTH_AND_TOKEN_PROVIDED"] = "OCEANIC_AUTH_AND_TOKEN_PROVIDED";
10
+ })(WarningCodes || (exports.WarningCodes = WarningCodes = {}));
11
+ const WarningOptions = {
12
+ [WarningCodes.OCEANIC_CACHE_DISABLED]: {
13
+ detail: "Set the disableCache option to the literal string \"no-warning\" to disable this warning.",
14
+ message: "Enabling the disableCache option is not recommended. This will break many aspects of the library, as it is not designed to function without cache."
15
+ },
16
+ [WarningCodes.OCEANIC_COLLECTIONS_LIMIT_WITH_CACHE_DISABLED]: {
17
+ detail: "Remove the collectionsLimit option, or zero out all of the possible options to disable this warning.",
18
+ message: "Providing the collectionsLimit option when the disableCache option has been enabled is redundant. Any provided values will be ignored."
19
+ },
20
+ [WarningCodes.OCEANIC_AUTH_AND_TOKEN_PROVIDED]: {
21
+ detail: "Remove either the auth or token option to disable this warning.",
22
+ message: "Providing both the token and auth options is redundant. The auth option will be used over token."
23
+ }
24
+ };
25
+ const warnedCodes = new Set();
26
+ function warning(code) {
27
+ if (warnedCodes.has(code))
28
+ return;
29
+ const options = WarningOptions[code];
30
+ process.emitWarning(options.message, {
31
+ code,
32
+ detail: options.detail
33
+ });
34
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CiphertextMessage = void 0;
4
+ class CiphertextMessage {
5
+ constructor() {
6
+ this.UNSUPPORTED_VERSION = 1;
7
+ this.CURRENT_VERSION = 3;
8
+ this.WHISPER_TYPE = 2;
9
+ this.PREKEY_TYPE = 3;
10
+ this.SENDERKEY_TYPE = 4;
11
+ this.SENDERKEY_DISTRIBUTION_TYPE = 5;
12
+ this.ENCRYPTED_MESSAGE_OVERHEAD = 53;
13
+ }
14
+ }
15
+ exports.CiphertextMessage = CiphertextMessage;
16
+ //# sourceMappingURL=ciphertext-message.js.map
@@ -0,0 +1,67 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.GroupSessionBuilder = void 0;
37
+ const keyhelper = __importStar(require("./keyhelper.cjs"));
38
+ const sender_key_distribution_message_js_1 = require("./sender-key-distribution-message.cjs");
39
+ const sender_key_name_js_1 = require("./sender-key-name.cjs");
40
+ const sender_key_record_js_1 = require("./sender-key-record.cjs");
41
+ class GroupSessionBuilder {
42
+ constructor(senderKeyStore) {
43
+ this.senderKeyStore = senderKeyStore;
44
+ }
45
+ async process(senderKeyName, senderKeyDistributionMessage) {
46
+ const senderKeyRecord = await this.senderKeyStore.loadSenderKey(senderKeyName);
47
+ senderKeyRecord.addSenderKeyState(senderKeyDistributionMessage.getId(), senderKeyDistributionMessage.getIteration(), senderKeyDistributionMessage.getChainKey(), senderKeyDistributionMessage.getSignatureKey());
48
+ await this.senderKeyStore.storeSenderKey(senderKeyName, senderKeyRecord);
49
+ }
50
+ async create(senderKeyName) {
51
+ const senderKeyRecord = await this.senderKeyStore.loadSenderKey(senderKeyName);
52
+ if (senderKeyRecord.isEmpty()) {
53
+ const keyId = keyhelper.generateSenderKeyId();
54
+ const senderKey = keyhelper.generateSenderKey();
55
+ const signingKey = keyhelper.generateSenderSigningKey();
56
+ senderKeyRecord.setSenderKeyState(keyId, 0, senderKey, signingKey);
57
+ await this.senderKeyStore.storeSenderKey(senderKeyName, senderKeyRecord);
58
+ }
59
+ const state = senderKeyRecord.getSenderKeyState();
60
+ if (!state) {
61
+ throw new Error('No session state available');
62
+ }
63
+ return new sender_key_distribution_message_js_1.SenderKeyDistributionMessage(state.getKeyId(), state.getSenderChainKey().getIteration(), state.getSenderChainKey().getSeed(), state.getSigningKeyPublic());
64
+ }
65
+ }
66
+ exports.GroupSessionBuilder = GroupSessionBuilder;
67
+ //# sourceMappingURL=group-session-builder.js.map
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GroupCipher = void 0;
4
+ const crypto_js_1 = require("libsignal/src/crypto.js");
5
+ const sender_key_message_js_1 = require("./sender-key-message.cjs");
6
+ const sender_key_name_js_1 = require("./sender-key-name.cjs");
7
+ const sender_key_record_js_1 = require("./sender-key-record.cjs");
8
+ const sender_key_state_js_1 = require("./sender-key-state.cjs");
9
+ class GroupCipher {
10
+ constructor(senderKeyStore, senderKeyName) {
11
+ this.senderKeyStore = senderKeyStore;
12
+ this.senderKeyName = senderKeyName;
13
+ }
14
+ async encrypt(paddedPlaintext) {
15
+ const record = await this.senderKeyStore.loadSenderKey(this.senderKeyName);
16
+ if (!record) {
17
+ throw new Error('No SenderKeyRecord found for encryption');
18
+ }
19
+ const senderKeyState = record.getSenderKeyState();
20
+ if (!senderKeyState) {
21
+ throw new Error('No session to encrypt message');
22
+ }
23
+ const iteration = senderKeyState.getSenderChainKey().getIteration();
24
+ const senderKey = this.getSenderKey(senderKeyState, iteration === 0 ? 0 : iteration + 1);
25
+ const ciphertext = await this.getCipherText(senderKey.getIv(), senderKey.getCipherKey(), paddedPlaintext);
26
+ const senderKeyMessage = new sender_key_message_js_1.SenderKeyMessage(senderKeyState.getKeyId(), senderKey.getIteration(), ciphertext, senderKeyState.getSigningKeyPrivate());
27
+ await this.senderKeyStore.storeSenderKey(this.senderKeyName, record);
28
+ return senderKeyMessage.serialize();
29
+ }
30
+ async decrypt(senderKeyMessageBytes) {
31
+ const record = await this.senderKeyStore.loadSenderKey(this.senderKeyName);
32
+ if (!record) {
33
+ throw new Error('No SenderKeyRecord found for decryption');
34
+ }
35
+ const senderKeyMessage = new sender_key_message_js_1.SenderKeyMessage(null, null, null, null, senderKeyMessageBytes);
36
+ const senderKeyState = record.getSenderKeyState(senderKeyMessage.getKeyId());
37
+ if (!senderKeyState) {
38
+ throw new Error('No session found to decrypt message');
39
+ }
40
+ senderKeyMessage.verifySignature(senderKeyState.getSigningKeyPublic());
41
+ const senderKey = this.getSenderKey(senderKeyState, senderKeyMessage.getIteration());
42
+ const plaintext = await this.getPlainText(senderKey.getIv(), senderKey.getCipherKey(), senderKeyMessage.getCipherText());
43
+ await this.senderKeyStore.storeSenderKey(this.senderKeyName, record);
44
+ return plaintext;
45
+ }
46
+ getSenderKey(senderKeyState, iteration) {
47
+ let senderChainKey = senderKeyState.getSenderChainKey();
48
+ if (senderChainKey.getIteration() > iteration) {
49
+ if (senderKeyState.hasSenderMessageKey(iteration)) {
50
+ const messageKey = senderKeyState.removeSenderMessageKey(iteration);
51
+ if (!messageKey) {
52
+ throw new Error('No sender message key found for iteration');
53
+ }
54
+ return messageKey;
55
+ }
56
+ throw new Error(`Received message with old counter: ${senderChainKey.getIteration()}, ${iteration}`);
57
+ }
58
+ if (iteration - senderChainKey.getIteration() > 2000) {
59
+ throw new Error('Over 2000 messages into the future!');
60
+ }
61
+ while (senderChainKey.getIteration() < iteration) {
62
+ senderKeyState.addSenderMessageKey(senderChainKey.getSenderMessageKey());
63
+ senderChainKey = senderChainKey.getNext();
64
+ }
65
+ senderKeyState.setSenderChainKey(senderChainKey.getNext());
66
+ return senderChainKey.getSenderMessageKey();
67
+ }
68
+ async getPlainText(iv, key, ciphertext) {
69
+ try {
70
+ return (0, crypto_js_1.decrypt)(key, ciphertext, iv);
71
+ }
72
+ catch (e) {
73
+ throw new Error('InvalidMessageException');
74
+ }
75
+ }
76
+ async getCipherText(iv, key, plaintext) {
77
+ try {
78
+ return (0, crypto_js_1.encrypt)(key, plaintext, iv);
79
+ }
80
+ catch (e) {
81
+ throw new Error('InvalidMessageException');
82
+ }
83
+ }
84
+ }
85
+ exports.GroupCipher = GroupCipher;
86
+ //# sourceMappingURL=group_cipher.js.map