@fnlb-project/fnbr 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (363) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +68 -0
  3. package/dist/enums/Enums.d.ts +251 -0
  4. package/dist/enums/Enums.js +202 -0
  5. package/dist/enums/Enums.js.map +1 -0
  6. package/dist/index.d.ts +92 -0
  7. package/dist/index.js +194 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/resources/AuthClients.d.ts +39 -0
  10. package/dist/resources/AuthClients.js +41 -0
  11. package/dist/resources/AuthClients.js.map +1 -0
  12. package/dist/resources/BaseItemRating.json +5203 -0
  13. package/dist/resources/Endpoints.d.ts +58 -0
  14. package/dist/resources/Endpoints.js +71 -0
  15. package/dist/resources/Endpoints.js.map +1 -0
  16. package/dist/resources/HomebaseRatingMapping.json +255 -0
  17. package/dist/resources/PowerLevelCurves.d.ts +111 -0
  18. package/dist/resources/PowerLevelCurves.js +21 -0
  19. package/dist/resources/PowerLevelCurves.js.map +1 -0
  20. package/dist/resources/SurvivorItemRating.json +9343 -0
  21. package/dist/resources/constants.d.ts +2 -0
  22. package/dist/resources/constants.js +11 -0
  23. package/dist/resources/constants.js.map +1 -0
  24. package/dist/resources/defaultPartyMemberMeta.json +28 -0
  25. package/dist/resources/defaultPartyMeta.json +38 -0
  26. package/dist/resources/enums.d.ts +12 -0
  27. package/dist/resources/enums.js +18 -0
  28. package/dist/resources/enums.js.map +1 -0
  29. package/dist/resources/httpResponses.d.ts +773 -0
  30. package/dist/resources/httpResponses.js +3 -0
  31. package/dist/resources/httpResponses.js.map +1 -0
  32. package/dist/resources/structs.d.ts +1310 -0
  33. package/dist/resources/structs.js +3 -0
  34. package/dist/resources/structs.js.map +1 -0
  35. package/dist/src/Base.d.ts +15 -0
  36. package/dist/src/Base.js +15 -0
  37. package/dist/src/Base.js.map +1 -0
  38. package/dist/src/Client.d.ts +341 -0
  39. package/dist/src/Client.js +1043 -0
  40. package/dist/src/Client.js.map +1 -0
  41. package/dist/src/auth/Auth.d.ts +66 -0
  42. package/dist/src/auth/Auth.js +249 -0
  43. package/dist/src/auth/Auth.js.map +1 -0
  44. package/dist/src/auth/AuthSession.d.ts +41 -0
  45. package/dist/src/auth/AuthSession.js +25 -0
  46. package/dist/src/auth/AuthSession.js.map +1 -0
  47. package/dist/src/auth/EOSAuthSession.d.ts +19 -0
  48. package/dist/src/auth/EOSAuthSession.js +80 -0
  49. package/dist/src/auth/EOSAuthSession.js.map +1 -0
  50. package/dist/src/auth/FortniteAuthSession.d.ts +53 -0
  51. package/dist/src/auth/FortniteAuthSession.js +107 -0
  52. package/dist/src/auth/FortniteAuthSession.js.map +1 -0
  53. package/dist/src/auth/FortniteClientCredentialsAuthSession.d.ts +18 -0
  54. package/dist/src/auth/FortniteClientCredentialsAuthSession.js +88 -0
  55. package/dist/src/auth/FortniteClientCredentialsAuthSession.js.map +1 -0
  56. package/dist/src/auth/LauncherAuthSession.d.ts +23 -0
  57. package/dist/src/auth/LauncherAuthSession.js +120 -0
  58. package/dist/src/auth/LauncherAuthSession.js.map +1 -0
  59. package/dist/src/exceptions/AuthenticationMissingError.d.ts +15 -0
  60. package/dist/src/exceptions/AuthenticationMissingError.js +18 -0
  61. package/dist/src/exceptions/AuthenticationMissingError.js.map +1 -0
  62. package/dist/src/exceptions/CreativeIslandNotFoundError.d.ts +14 -0
  63. package/dist/src/exceptions/CreativeIslandNotFoundError.js +18 -0
  64. package/dist/src/exceptions/CreativeIslandNotFoundError.js.map +1 -0
  65. package/dist/src/exceptions/CreatorCodeNotFoundError.d.ts +14 -0
  66. package/dist/src/exceptions/CreatorCodeNotFoundError.js +18 -0
  67. package/dist/src/exceptions/CreatorCodeNotFoundError.js.map +1 -0
  68. package/dist/src/exceptions/DuplicateFriendshipError.d.ts +14 -0
  69. package/dist/src/exceptions/DuplicateFriendshipError.js +18 -0
  70. package/dist/src/exceptions/DuplicateFriendshipError.js.map +1 -0
  71. package/dist/src/exceptions/EpicgamesAPIError.d.ts +42 -0
  72. package/dist/src/exceptions/EpicgamesAPIError.js +27 -0
  73. package/dist/src/exceptions/EpicgamesAPIError.js.map +1 -0
  74. package/dist/src/exceptions/EventTimeoutError.d.ts +19 -0
  75. package/dist/src/exceptions/EventTimeoutError.js +20 -0
  76. package/dist/src/exceptions/EventTimeoutError.js.map +1 -0
  77. package/dist/src/exceptions/FriendNotFoundError.d.ts +14 -0
  78. package/dist/src/exceptions/FriendNotFoundError.js +18 -0
  79. package/dist/src/exceptions/FriendNotFoundError.js.map +1 -0
  80. package/dist/src/exceptions/FriendshipRequestAlreadySentError.d.ts +14 -0
  81. package/dist/src/exceptions/FriendshipRequestAlreadySentError.js +18 -0
  82. package/dist/src/exceptions/FriendshipRequestAlreadySentError.js.map +1 -0
  83. package/dist/src/exceptions/InviteeFriendshipRequestLimitExceededError.d.ts +14 -0
  84. package/dist/src/exceptions/InviteeFriendshipRequestLimitExceededError.js +18 -0
  85. package/dist/src/exceptions/InviteeFriendshipRequestLimitExceededError.js.map +1 -0
  86. package/dist/src/exceptions/InviteeFriendshipSettingsError.d.ts +14 -0
  87. package/dist/src/exceptions/InviteeFriendshipSettingsError.js +18 -0
  88. package/dist/src/exceptions/InviteeFriendshipSettingsError.js.map +1 -0
  89. package/dist/src/exceptions/InviteeFriendshipsLimitExceededError.d.ts +14 -0
  90. package/dist/src/exceptions/InviteeFriendshipsLimitExceededError.js +18 -0
  91. package/dist/src/exceptions/InviteeFriendshipsLimitExceededError.js.map +1 -0
  92. package/dist/src/exceptions/InviterFriendshipsLimitExceededError.d.ts +14 -0
  93. package/dist/src/exceptions/InviterFriendshipsLimitExceededError.js +18 -0
  94. package/dist/src/exceptions/InviterFriendshipsLimitExceededError.js.map +1 -0
  95. package/dist/src/exceptions/MatchNotFoundError.d.ts +14 -0
  96. package/dist/src/exceptions/MatchNotFoundError.js +18 -0
  97. package/dist/src/exceptions/MatchNotFoundError.js.map +1 -0
  98. package/dist/src/exceptions/OfferNotFoundError.d.ts +14 -0
  99. package/dist/src/exceptions/OfferNotFoundError.js +18 -0
  100. package/dist/src/exceptions/OfferNotFoundError.js.map +1 -0
  101. package/dist/src/exceptions/PartyAlreadyJoinedError.d.ts +7 -0
  102. package/dist/src/exceptions/PartyAlreadyJoinedError.js +14 -0
  103. package/dist/src/exceptions/PartyAlreadyJoinedError.js.map +1 -0
  104. package/dist/src/exceptions/PartyInvitationExpiredError.d.ts +7 -0
  105. package/dist/src/exceptions/PartyInvitationExpiredError.js +14 -0
  106. package/dist/src/exceptions/PartyInvitationExpiredError.js.map +1 -0
  107. package/dist/src/exceptions/PartyMaxSizeReachedError.d.ts +7 -0
  108. package/dist/src/exceptions/PartyMaxSizeReachedError.js +14 -0
  109. package/dist/src/exceptions/PartyMaxSizeReachedError.js.map +1 -0
  110. package/dist/src/exceptions/PartyMemberNotFoundError.d.ts +14 -0
  111. package/dist/src/exceptions/PartyMemberNotFoundError.js +18 -0
  112. package/dist/src/exceptions/PartyMemberNotFoundError.js.map +1 -0
  113. package/dist/src/exceptions/PartyNotFoundError.d.ts +7 -0
  114. package/dist/src/exceptions/PartyNotFoundError.js +14 -0
  115. package/dist/src/exceptions/PartyNotFoundError.js.map +1 -0
  116. package/dist/src/exceptions/PartyPermissionError.d.ts +7 -0
  117. package/dist/src/exceptions/PartyPermissionError.js +14 -0
  118. package/dist/src/exceptions/PartyPermissionError.js.map +1 -0
  119. package/dist/src/exceptions/SendMessageError.d.ts +27 -0
  120. package/dist/src/exceptions/SendMessageError.js +21 -0
  121. package/dist/src/exceptions/SendMessageError.js.map +1 -0
  122. package/dist/src/exceptions/StatsPrivacyError.d.ts +14 -0
  123. package/dist/src/exceptions/StatsPrivacyError.js +18 -0
  124. package/dist/src/exceptions/StatsPrivacyError.js.map +1 -0
  125. package/dist/src/exceptions/StompConnectionError.d.ts +14 -0
  126. package/dist/src/exceptions/StompConnectionError.js +18 -0
  127. package/dist/src/exceptions/StompConnectionError.js.map +1 -0
  128. package/dist/src/exceptions/UserNotFoundError.d.ts +14 -0
  129. package/dist/src/exceptions/UserNotFoundError.js +18 -0
  130. package/dist/src/exceptions/UserNotFoundError.js.map +1 -0
  131. package/dist/src/exceptions/XMPPConnectionError.d.ts +19 -0
  132. package/dist/src/exceptions/XMPPConnectionError.js +19 -0
  133. package/dist/src/exceptions/XMPPConnectionError.js.map +1 -0
  134. package/dist/src/exceptions/XMPPConnectionTimeoutError.d.ts +14 -0
  135. package/dist/src/exceptions/XMPPConnectionTimeoutError.js +18 -0
  136. package/dist/src/exceptions/XMPPConnectionTimeoutError.js.map +1 -0
  137. package/dist/src/http/HTTP.d.ts +40 -0
  138. package/dist/src/http/HTTP.js +124 -0
  139. package/dist/src/http/HTTP.js.map +1 -0
  140. package/dist/src/managers/ChatManager.d.ts +27 -0
  141. package/dist/src/managers/ChatManager.js +71 -0
  142. package/dist/src/managers/ChatManager.js.map +1 -0
  143. package/dist/src/managers/FriendManager.d.ts +66 -0
  144. package/dist/src/managers/FriendManager.js +175 -0
  145. package/dist/src/managers/FriendManager.js.map +1 -0
  146. package/dist/src/managers/STWManager.d.ts +29 -0
  147. package/dist/src/managers/STWManager.js +80 -0
  148. package/dist/src/managers/STWManager.js.map +1 -0
  149. package/dist/src/managers/TournamentManager.d.ts +51 -0
  150. package/dist/src/managers/TournamentManager.js +182 -0
  151. package/dist/src/managers/TournamentManager.js.map +1 -0
  152. package/dist/src/managers/UserManager.d.ts +78 -0
  153. package/dist/src/managers/UserManager.js +216 -0
  154. package/dist/src/managers/UserManager.js.map +1 -0
  155. package/dist/src/stomp/EOSConnect.d.ts +43 -0
  156. package/dist/src/stomp/EOSConnect.js +175 -0
  157. package/dist/src/stomp/EOSConnect.js.map +1 -0
  158. package/dist/src/structures/Avatar.d.ts +27 -0
  159. package/dist/src/structures/Avatar.js +22 -0
  160. package/dist/src/structures/Avatar.js.map +1 -0
  161. package/dist/src/structures/BaseMessage.d.ts +34 -0
  162. package/dist/src/structures/BaseMessage.js +22 -0
  163. package/dist/src/structures/BaseMessage.js.map +1 -0
  164. package/dist/src/structures/CreatorCode.d.ts +31 -0
  165. package/dist/src/structures/CreatorCode.js +22 -0
  166. package/dist/src/structures/CreatorCode.js.map +1 -0
  167. package/dist/src/structures/EpicgamesServerStatus.d.ts +52 -0
  168. package/dist/src/structures/EpicgamesServerStatus.js +31 -0
  169. package/dist/src/structures/EpicgamesServerStatus.js.map +1 -0
  170. package/dist/src/structures/EpicgamesServerStatusComponent.d.ts +67 -0
  171. package/dist/src/structures/EpicgamesServerStatusComponent.js +37 -0
  172. package/dist/src/structures/EpicgamesServerStatusComponent.js.map +1 -0
  173. package/dist/src/structures/EpicgamesServerStatusIncident.d.ts +58 -0
  174. package/dist/src/structures/EpicgamesServerStatusIncident.js +36 -0
  175. package/dist/src/structures/EpicgamesServerStatusIncident.js.map +1 -0
  176. package/dist/src/structures/EpicgamesServerStatusScheduledMainteance.d.ts +21 -0
  177. package/dist/src/structures/EpicgamesServerStatusScheduledMainteance.js +20 -0
  178. package/dist/src/structures/EpicgamesServerStatusScheduledMainteance.js.map +1 -0
  179. package/dist/src/structures/EventTokens.d.ts +32 -0
  180. package/dist/src/structures/EventTokens.js +45 -0
  181. package/dist/src/structures/EventTokens.js.map +1 -0
  182. package/dist/src/structures/FortniteServerStatus.d.ts +46 -0
  183. package/dist/src/structures/FortniteServerStatus.js +26 -0
  184. package/dist/src/structures/FortniteServerStatus.js.map +1 -0
  185. package/dist/src/structures/GlobalProfile.d.ts +36 -0
  186. package/dist/src/structures/GlobalProfile.js +25 -0
  187. package/dist/src/structures/GlobalProfile.js.map +1 -0
  188. package/dist/src/structures/Image.d.ts +36 -0
  189. package/dist/src/structures/Image.js +38 -0
  190. package/dist/src/structures/Image.js.map +1 -0
  191. package/dist/src/structures/NewsMessage.d.ts +56 -0
  192. package/dist/src/structures/NewsMessage.js +45 -0
  193. package/dist/src/structures/NewsMessage.js.map +1 -0
  194. package/dist/src/structures/NewsMessageVideo.d.ts +47 -0
  195. package/dist/src/structures/NewsMessageVideo.js +32 -0
  196. package/dist/src/structures/NewsMessageVideo.js.map +1 -0
  197. package/dist/src/structures/RadioStation.d.ts +31 -0
  198. package/dist/src/structures/RadioStation.js +33 -0
  199. package/dist/src/structures/RadioStation.js.map +1 -0
  200. package/dist/src/structures/Stats.d.ts +45 -0
  201. package/dist/src/structures/Stats.js +109 -0
  202. package/dist/src/structures/Stats.js.map +1 -0
  203. package/dist/src/structures/Tournament.d.ts +86 -0
  204. package/dist/src/structures/Tournament.js +64 -0
  205. package/dist/src/structures/Tournament.js.map +1 -0
  206. package/dist/src/structures/TournamentWindow.d.ts +124 -0
  207. package/dist/src/structures/TournamentWindow.js +52 -0
  208. package/dist/src/structures/TournamentWindow.js.map +1 -0
  209. package/dist/src/structures/friend/BaseFriendMessage.d.ts +32 -0
  210. package/dist/src/structures/friend/BaseFriendMessage.js +28 -0
  211. package/dist/src/structures/friend/BaseFriendMessage.js.map +1 -0
  212. package/dist/src/structures/friend/BasePendingFriend.d.ts +22 -0
  213. package/dist/src/structures/friend/BasePendingFriend.js +22 -0
  214. package/dist/src/structures/friend/BasePendingFriend.js.map +1 -0
  215. package/dist/src/structures/friend/Friend.d.ts +106 -0
  216. package/dist/src/structures/friend/Friend.js +97 -0
  217. package/dist/src/structures/friend/Friend.js.map +1 -0
  218. package/dist/src/structures/friend/FriendPresence.d.ts +84 -0
  219. package/dist/src/structures/friend/FriendPresence.js +48 -0
  220. package/dist/src/structures/friend/FriendPresence.js.map +1 -0
  221. package/dist/src/structures/friend/IncomingPendingFriend.d.ts +27 -0
  222. package/dist/src/structures/friend/IncomingPendingFriend.js +36 -0
  223. package/dist/src/structures/friend/IncomingPendingFriend.js.map +1 -0
  224. package/dist/src/structures/friend/OutgoingPendingFriend.d.ts +17 -0
  225. package/dist/src/structures/friend/OutgoingPendingFriend.js +24 -0
  226. package/dist/src/structures/friend/OutgoingPendingFriend.js.map +1 -0
  227. package/dist/src/structures/friend/ReceivedFriendMessage.d.ts +27 -0
  228. package/dist/src/structures/friend/ReceivedFriendMessage.js +27 -0
  229. package/dist/src/structures/friend/ReceivedFriendMessage.js.map +1 -0
  230. package/dist/src/structures/friend/SentFriendMessage.d.ts +21 -0
  231. package/dist/src/structures/friend/SentFriendMessage.js +19 -0
  232. package/dist/src/structures/friend/SentFriendMessage.js.map +1 -0
  233. package/dist/src/structures/party/BasePartyInvitation.d.ts +48 -0
  234. package/dist/src/structures/party/BasePartyInvitation.js +33 -0
  235. package/dist/src/structures/party/BasePartyInvitation.js.map +1 -0
  236. package/dist/src/structures/party/BasePartyJoinRequest.d.ts +37 -0
  237. package/dist/src/structures/party/BasePartyJoinRequest.js +30 -0
  238. package/dist/src/structures/party/BasePartyJoinRequest.js.map +1 -0
  239. package/dist/src/structures/party/ClientParty.d.ts +162 -0
  240. package/dist/src/structures/party/ClientParty.js +412 -0
  241. package/dist/src/structures/party/ClientParty.js.map +1 -0
  242. package/dist/src/structures/party/ClientPartyMember.d.ts +144 -0
  243. package/dist/src/structures/party/ClientPartyMember.js +463 -0
  244. package/dist/src/structures/party/ClientPartyMember.js.map +1 -0
  245. package/dist/src/structures/party/ClientPartyMemberMeta.d.ts +18 -0
  246. package/dist/src/structures/party/ClientPartyMemberMeta.js +54 -0
  247. package/dist/src/structures/party/ClientPartyMemberMeta.js.map +1 -0
  248. package/dist/src/structures/party/ClientPartyMeta.d.ts +23 -0
  249. package/dist/src/structures/party/ClientPartyMeta.js +59 -0
  250. package/dist/src/structures/party/ClientPartyMeta.js.map +1 -0
  251. package/dist/src/structures/party/Party.d.ts +95 -0
  252. package/dist/src/structures/party/Party.js +200 -0
  253. package/dist/src/structures/party/Party.js.map +1 -0
  254. package/dist/src/structures/party/PartyChat.d.ts +73 -0
  255. package/dist/src/structures/party/PartyChat.js +76 -0
  256. package/dist/src/structures/party/PartyChat.js.map +1 -0
  257. package/dist/src/structures/party/PartyMember.d.ts +139 -0
  258. package/dist/src/structures/party/PartyMember.js +201 -0
  259. package/dist/src/structures/party/PartyMember.js.map +1 -0
  260. package/dist/src/structures/party/PartyMemberConfirmation.d.ts +43 -0
  261. package/dist/src/structures/party/PartyMemberConfirmation.js +53 -0
  262. package/dist/src/structures/party/PartyMemberConfirmation.js.map +1 -0
  263. package/dist/src/structures/party/PartyMemberMeta.d.ts +76 -0
  264. package/dist/src/structures/party/PartyMemberMeta.js +145 -0
  265. package/dist/src/structures/party/PartyMemberMeta.js.map +1 -0
  266. package/dist/src/structures/party/PartyMessage.d.ts +30 -0
  267. package/dist/src/structures/party/PartyMessage.js +28 -0
  268. package/dist/src/structures/party/PartyMessage.js.map +1 -0
  269. package/dist/src/structures/party/PartyMeta.d.ts +24 -0
  270. package/dist/src/structures/party/PartyMeta.js +43 -0
  271. package/dist/src/structures/party/PartyMeta.js.map +1 -0
  272. package/dist/src/structures/party/PresenceParty.d.ts +66 -0
  273. package/dist/src/structures/party/PresenceParty.js +49 -0
  274. package/dist/src/structures/party/PresenceParty.js.map +1 -0
  275. package/dist/src/structures/party/ReceivedPartyInvitation.d.ts +33 -0
  276. package/dist/src/structures/party/ReceivedPartyInvitation.js +54 -0
  277. package/dist/src/structures/party/ReceivedPartyInvitation.js.map +1 -0
  278. package/dist/src/structures/party/ReceivedPartyJoinRequest.d.ts +26 -0
  279. package/dist/src/structures/party/ReceivedPartyJoinRequest.js +31 -0
  280. package/dist/src/structures/party/ReceivedPartyJoinRequest.js.map +1 -0
  281. package/dist/src/structures/party/SentPartyInvitation.d.ts +27 -0
  282. package/dist/src/structures/party/SentPartyInvitation.js +39 -0
  283. package/dist/src/structures/party/SentPartyInvitation.js.map +1 -0
  284. package/dist/src/structures/party/SentPartyJoinRequest.d.ts +19 -0
  285. package/dist/src/structures/party/SentPartyJoinRequest.js +22 -0
  286. package/dist/src/structures/party/SentPartyJoinRequest.js.map +1 -0
  287. package/dist/src/structures/stw/STWHero.d.ts +61 -0
  288. package/dist/src/structures/stw/STWHero.js +38 -0
  289. package/dist/src/structures/stw/STWHero.js.map +1 -0
  290. package/dist/src/structures/stw/STWHeroLoadout.d.ts +44 -0
  291. package/dist/src/structures/stw/STWHeroLoadout.js +34 -0
  292. package/dist/src/structures/stw/STWHeroLoadout.js.map +1 -0
  293. package/dist/src/structures/stw/STWItem.d.ts +31 -0
  294. package/dist/src/structures/stw/STWItem.js +23 -0
  295. package/dist/src/structures/stw/STWItem.js.map +1 -0
  296. package/dist/src/structures/stw/STWLocker.d.ts +32 -0
  297. package/dist/src/structures/stw/STWLocker.js +26 -0
  298. package/dist/src/structures/stw/STWLocker.js.map +1 -0
  299. package/dist/src/structures/stw/STWMeleeWeaponSchematic.d.ts +14 -0
  300. package/dist/src/structures/stw/STWMeleeWeaponSchematic.js +15 -0
  301. package/dist/src/structures/stw/STWMeleeWeaponSchematic.js.map +1 -0
  302. package/dist/src/structures/stw/STWNewsMessage.d.ts +42 -0
  303. package/dist/src/structures/stw/STWNewsMessage.js +27 -0
  304. package/dist/src/structures/stw/STWNewsMessage.js.map +1 -0
  305. package/dist/src/structures/stw/STWProfile.d.ts +132 -0
  306. package/dist/src/structures/stw/STWProfile.js +283 -0
  307. package/dist/src/structures/stw/STWProfile.js.map +1 -0
  308. package/dist/src/structures/stw/STWRangedWeaponSchematic.d.ts +14 -0
  309. package/dist/src/structures/stw/STWRangedWeaponSchematic.js +15 -0
  310. package/dist/src/structures/stw/STWRangedWeaponSchematic.js.map +1 -0
  311. package/dist/src/structures/stw/STWResource.d.ts +27 -0
  312. package/dist/src/structures/stw/STWResource.js +22 -0
  313. package/dist/src/structures/stw/STWResource.js.map +1 -0
  314. package/dist/src/structures/stw/STWSchematic.d.ts +72 -0
  315. package/dist/src/structures/stw/STWSchematic.js +40 -0
  316. package/dist/src/structures/stw/STWSchematic.js.map +1 -0
  317. package/dist/src/structures/stw/STWStats.d.ts +103 -0
  318. package/dist/src/structures/stw/STWStats.js +85 -0
  319. package/dist/src/structures/stw/STWStats.js.map +1 -0
  320. package/dist/src/structures/stw/STWSurvivor.d.ts +104 -0
  321. package/dist/src/structures/stw/STWSurvivor.js +76 -0
  322. package/dist/src/structures/stw/STWSurvivor.js.map +1 -0
  323. package/dist/src/structures/stw/STWTeamPerk.d.ts +19 -0
  324. package/dist/src/structures/stw/STWTeamPerk.js +20 -0
  325. package/dist/src/structures/stw/STWTeamPerk.js.map +1 -0
  326. package/dist/src/structures/stw/STWTrapSchematic.d.ts +15 -0
  327. package/dist/src/structures/stw/STWTrapSchematic.js +16 -0
  328. package/dist/src/structures/stw/STWTrapSchematic.js.map +1 -0
  329. package/dist/src/structures/stw/STWWeaponSchematic.d.ts +15 -0
  330. package/dist/src/structures/stw/STWWeaponSchematic.js +16 -0
  331. package/dist/src/structures/stw/STWWeaponSchematic.js.map +1 -0
  332. package/dist/src/structures/user/BlockedUser.d.ts +13 -0
  333. package/dist/src/structures/user/BlockedUser.js +19 -0
  334. package/dist/src/structures/user/BlockedUser.js.map +1 -0
  335. package/dist/src/structures/user/ClientUser.d.ts +78 -0
  336. package/dist/src/structures/user/ClientUser.js +34 -0
  337. package/dist/src/structures/user/ClientUser.js.map +1 -0
  338. package/dist/src/structures/user/User.d.ts +98 -0
  339. package/dist/src/structures/user/User.js +130 -0
  340. package/dist/src/structures/user/User.js.map +1 -0
  341. package/dist/src/structures/user/UserSearchResult.d.ts +31 -0
  342. package/dist/src/structures/user/UserSearchResult.js +23 -0
  343. package/dist/src/structures/user/UserSearchResult.js.map +1 -0
  344. package/dist/src/util/AsyncLock.d.ts +28 -0
  345. package/dist/src/util/AsyncLock.js +44 -0
  346. package/dist/src/util/AsyncLock.js.map +1 -0
  347. package/dist/src/util/BinaryWriter.d.ts +79 -0
  348. package/dist/src/util/BinaryWriter.js +136 -0
  349. package/dist/src/util/BinaryWriter.js.map +1 -0
  350. package/dist/src/util/CurveTable.d.ts +24 -0
  351. package/dist/src/util/CurveTable.js +37 -0
  352. package/dist/src/util/CurveTable.js.map +1 -0
  353. package/dist/src/util/Meta.d.ts +41 -0
  354. package/dist/src/util/Meta.js +73 -0
  355. package/dist/src/util/Meta.js.map +1 -0
  356. package/dist/src/util/Util.d.ts +162 -0
  357. package/dist/src/util/Util.js +539 -0
  358. package/dist/src/util/Util.js.map +1 -0
  359. package/dist/src/xmpp/XMPP.d.ts +100 -0
  360. package/dist/src/xmpp/XMPP.js +702 -0
  361. package/dist/src/xmpp/XMPP.js.map +1 -0
  362. package/dist/tsconfig.tsbuildinfo +1 -0
  363. package/package.json +66 -0
@@ -0,0 +1,702 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const stanza_1 = require("stanza");
5
+ const crypto_1 = tslib_1.__importDefault(require("crypto"));
6
+ const Base_1 = tslib_1.__importDefault(require("../Base"));
7
+ const Endpoints_1 = tslib_1.__importDefault(require("../../resources/Endpoints"));
8
+ const PartyMessage_1 = tslib_1.__importDefault(require("../structures/party/PartyMessage"));
9
+ const FriendPresence_1 = tslib_1.__importDefault(require("../structures/friend/FriendPresence"));
10
+ const Friend_1 = tslib_1.__importDefault(require("../structures/friend/Friend"));
11
+ const IncomingPendingFriend_1 = tslib_1.__importDefault(require("../structures/friend/IncomingPendingFriend"));
12
+ const OutgoingPendingFriend_1 = tslib_1.__importDefault(require("../structures/friend/OutgoingPendingFriend"));
13
+ const BlockedUser_1 = tslib_1.__importDefault(require("../structures/user/BlockedUser"));
14
+ const Party_1 = tslib_1.__importDefault(require("../structures/party/Party"));
15
+ const Util_1 = require("../util/Util");
16
+ const ReceivedPartyInvitation_1 = tslib_1.__importDefault(require("../structures/party/ReceivedPartyInvitation"));
17
+ const FriendNotFoundError_1 = tslib_1.__importDefault(require("../exceptions/FriendNotFoundError"));
18
+ const ClientPartyMember_1 = tslib_1.__importDefault(require("../structures/party/ClientPartyMember"));
19
+ const PartyMember_1 = tslib_1.__importDefault(require("../structures/party/PartyMember"));
20
+ const PartyMemberNotFoundError_1 = tslib_1.__importDefault(require("../exceptions/PartyMemberNotFoundError"));
21
+ const PartyMemberConfirmation_1 = tslib_1.__importDefault(require("../structures/party/PartyMemberConfirmation"));
22
+ const ReceivedPartyJoinRequest_1 = tslib_1.__importDefault(require("../structures/party/ReceivedPartyJoinRequest"));
23
+ const PresenceParty_1 = tslib_1.__importDefault(require("../structures/party/PresenceParty"));
24
+ const ReceivedFriendMessage_1 = tslib_1.__importDefault(require("../structures/friend/ReceivedFriendMessage"));
25
+ const PartyMemberMeta_1 = tslib_1.__importDefault(require("../structures/party/PartyMemberMeta"));
26
+ const enums_1 = require("../../resources/enums");
27
+ const AuthenticationMissingError_1 = tslib_1.__importDefault(require("../exceptions/AuthenticationMissingError"));
28
+ const XMPPConnectionTimeoutError_1 = tslib_1.__importDefault(require("../exceptions/XMPPConnectionTimeoutError"));
29
+ const XMPPConnectionError_1 = tslib_1.__importDefault(require("../exceptions/XMPPConnectionError"));
30
+ /**
31
+ * Represents the client's XMPP manager
32
+ * @private
33
+ */
34
+ class XMPP extends Base_1.default {
35
+ /**
36
+ * @param client The main client
37
+ */
38
+ constructor(client) {
39
+ super(client);
40
+ this.connection = undefined;
41
+ this.connectedAt = undefined;
42
+ this.connectionRetryCount = 0;
43
+ }
44
+ /**
45
+ * Whether the XMPP agent is connected
46
+ */
47
+ get isConnected() {
48
+ return !!this.connection && this.connection.sessionStarted;
49
+ }
50
+ /**
51
+ * Returns the xmpp JID
52
+ */
53
+ get JID() {
54
+ var _a;
55
+ return (_a = this.connection) === null || _a === void 0 ? void 0 : _a.jid;
56
+ }
57
+ /**
58
+ * Returns the xmpp resource
59
+ */
60
+ get resource() {
61
+ var _a;
62
+ return (_a = this.connection) === null || _a === void 0 ? void 0 : _a.config.resource;
63
+ }
64
+ /**
65
+ * Connects the XMPP agent to Epicgames' XMPP servers
66
+ * @param sendStatusWhenConnected Whether to send an empty status status when connected
67
+ */
68
+ async connect(sendStatusWhenConnected = true) {
69
+ if (!this.client.auth.sessions.has(enums_1.AuthSessionStoreKey.Fortnite)) {
70
+ throw new AuthenticationMissingError_1.default(enums_1.AuthSessionStoreKey.Fortnite);
71
+ }
72
+ this.connection = (0, stanza_1.createClient)({
73
+ jid: `${this.client.user.self.id}@${Endpoints_1.default.EPIC_PROD_ENV}`,
74
+ server: Endpoints_1.default.EPIC_PROD_ENV,
75
+ transports: {
76
+ websocket: `wss://${Endpoints_1.default.XMPP_SERVER}`,
77
+ bosh: false,
78
+ },
79
+ credentials: {
80
+ host: Endpoints_1.default.EPIC_PROD_ENV,
81
+ username: this.client.user.self.id,
82
+ password: this.client.auth.sessions.get(enums_1.AuthSessionStoreKey.Fortnite).accessToken,
83
+ },
84
+ resource: `V2:Fortnite:${this.client.config.platform}::${crypto_1.default.randomBytes(16).toString('hex').toUpperCase()}`,
85
+ });
86
+ this.connection.enableKeepAlive({
87
+ interval: this.client.config.xmppKeepAliveInterval,
88
+ });
89
+ this.setupEvents();
90
+ this.client.debug('[XMPP] Connecting...');
91
+ const connectionStartTime = Date.now();
92
+ return new Promise((res, rej) => {
93
+ var _a;
94
+ const timeout = setTimeout(() => {
95
+ rej(new XMPPConnectionTimeoutError_1.default(15000));
96
+ }, 15000);
97
+ this.connection.once('session:started', () => {
98
+ clearTimeout(timeout);
99
+ this.client.debug(`[XMPP] Successfully connected (${((Date.now() - connectionStartTime) / 1000).toFixed(2)}s)`);
100
+ this.connectedAt = Date.now();
101
+ if (sendStatusWhenConnected)
102
+ this.sendStatus();
103
+ res();
104
+ });
105
+ (_a = this.connection) === null || _a === void 0 ? void 0 : _a.once('stream:error', (err) => {
106
+ clearTimeout(timeout);
107
+ rej(new XMPPConnectionError_1.default(err));
108
+ });
109
+ this.connection.connect();
110
+ });
111
+ }
112
+ /**
113
+ * Disconnects the XMPP client.
114
+ * Also performs a cleanup
115
+ */
116
+ disconnect() {
117
+ if (!this.connection)
118
+ return;
119
+ this.connection.removeAllListeners();
120
+ this.connection.disconnect();
121
+ this.connection = undefined;
122
+ this.client.debug('[XMPP] Disconnected');
123
+ }
124
+ /**
125
+ * Registers all events
126
+ */
127
+ setupEvents() {
128
+ this.connection.on('disconnected', async () => {
129
+ this.disconnect();
130
+ if (this.connectionRetryCount >= this.client.config.xmppMaxConnectionRetries) {
131
+ this.client.debug('[XMPP] Disconnected, reconnecting in 5 seconds...');
132
+ this.connectionRetryCount += 1;
133
+ await new Promise((res) => setTimeout(res, 5000));
134
+ await this.connect();
135
+ if (this.client.config.fetchFriends)
136
+ await this.client.updateCaches();
137
+ if (!this.client.config.disablePartyService)
138
+ await this.client.initParty(this.client.config.createParty, this.client.config.forceNewParty);
139
+ }
140
+ else {
141
+ this.client.debug('[XMPP] Disconnected, retry limit reached');
142
+ await this.client.logout();
143
+ }
144
+ });
145
+ this.connection.on('raw:incoming', (raw) => this.client.debug(`IN ${raw}`, 'xmpp'));
146
+ this.connection.on('raw:outgoing', (raw) => this.client.debug(`OUT ${raw}`, 'xmpp'));
147
+ this.connection.on('groupchat', async (m) => {
148
+ var _a, _b;
149
+ try {
150
+ await this.client.partyLock.wait();
151
+ const partyId = (_a = m.from.split('@')[0]) === null || _a === void 0 ? void 0 : _a.replace('Party-', '');
152
+ if (!this.client.party || this.client.party.id !== partyId)
153
+ return;
154
+ if (m.body === 'Welcome! You created new Multi User Chat Room.')
155
+ return;
156
+ const [, authorId] = m.from.split(':');
157
+ if (authorId === this.client.user.self.id)
158
+ return;
159
+ const authorMember = this.client.party.members.get(authorId);
160
+ if (!authorMember)
161
+ return;
162
+ const partyMessage = new PartyMessage_1.default(this.client, {
163
+ content: (_b = m.body) !== null && _b !== void 0 ? _b : '', author: authorMember, sentAt: new Date(), id: m.id, party: this.client.party,
164
+ });
165
+ this.client.emit('party:member:message', partyMessage);
166
+ }
167
+ catch (err) {
168
+ this.client.debug(`[XMPP] Error while processing party chat message: ${err.name} - ${err.message}`);
169
+ this.client.emit('xmpp:chat:error', err);
170
+ }
171
+ });
172
+ this.connection.on('chat', async (m) => {
173
+ try {
174
+ const friend = await this.waitForFriend(m.from.split('@')[0]);
175
+ if (!friend)
176
+ return;
177
+ const message = new ReceivedFriendMessage_1.default(this.client, {
178
+ content: m.body || '', author: friend, id: m.id, sentAt: new Date(),
179
+ });
180
+ this.client.emit('friend:message', message);
181
+ }
182
+ catch (err) {
183
+ this.client.debug(`[XMPP] Error while processing friend whisper message: ${err.name} - ${err.message}`);
184
+ this.client.emit('xmpp:chat:error', err);
185
+ }
186
+ });
187
+ this.connection.on('presence', async (p) => {
188
+ var _a, _b, _c;
189
+ try {
190
+ await this.client.cacheLock.wait();
191
+ if (!p.status)
192
+ return;
193
+ const friendId = p.from.split('@')[0];
194
+ if (friendId === this.client.user.self.id)
195
+ return;
196
+ const friend = await this.waitForFriend(friendId);
197
+ if (!friend)
198
+ return;
199
+ if (p.type === 'unavailable') {
200
+ friend.lastAvailableTimestamp = undefined;
201
+ friend.party = undefined;
202
+ this.client.emit('friend:offline', friend);
203
+ return;
204
+ }
205
+ const wasUnavailable = !friend.lastAvailableTimestamp;
206
+ friend.lastAvailableTimestamp = Date.now();
207
+ const presence = JSON.parse(p.status);
208
+ const before = (_a = this.client.friend.list.get(friendId)) === null || _a === void 0 ? void 0 : _a.presence;
209
+ const after = new FriendPresence_1.default(this.client, presence, friend, p.show || 'online', p.from);
210
+ if ((((_b = this.client.config.cacheSettings.presences) === null || _b === void 0 ? void 0 : _b.maxLifetime) || 0) > 0) {
211
+ friend.presence = after;
212
+ }
213
+ if ((_c = presence.Properties) === null || _c === void 0 ? void 0 : _c['party.joininfodata.286331153_j']) {
214
+ friend.party = new PresenceParty_1.default(this.client, presence.Properties['party.joininfodata.286331153_j']);
215
+ }
216
+ if (wasUnavailable && this.connectedAt && this.connectedAt > this.client.config.friendOnlineConnectionTimeout) {
217
+ this.client.emit('friend:online', friend);
218
+ }
219
+ this.client.emit('friend:presence', before, after);
220
+ }
221
+ catch (err) {
222
+ this.client.debug(`[XMPP] Error while processing presence: ${err.name} - ${err.message}`);
223
+ this.client.emit('xmpp:presence:error', err);
224
+ }
225
+ });
226
+ this.connection.on('message', async (m) => {
227
+ if (m.type && m.type !== 'normal')
228
+ return;
229
+ if (!m.body)
230
+ return;
231
+ if (m.from !== 'xmpp-admin@prod.ol.epicgames.com')
232
+ return;
233
+ let body;
234
+ try {
235
+ body = JSON.parse(m.body);
236
+ }
237
+ catch (err) {
238
+ return;
239
+ }
240
+ if (!body.type)
241
+ return;
242
+ try {
243
+ switch (body.type) {
244
+ case 'com.epicgames.friends.core.apiobjects.Friend':
245
+ {
246
+ const { payload: { status, accountId, favorite, created, direction, }, } = body;
247
+ const user = await this.client.user.fetch(accountId);
248
+ if (!user)
249
+ break;
250
+ if (status === 'ACCEPTED') {
251
+ const friend = new Friend_1.default(this.client, {
252
+ displayName: user.displayName,
253
+ id: user.id,
254
+ externalAuths: user.externalAuths,
255
+ favorite,
256
+ created,
257
+ alias: '',
258
+ note: '',
259
+ });
260
+ this.client.friend.list.set(friend.id, friend);
261
+ this.client.friend.pendingList.delete(friend.id);
262
+ this.client.emit('friend:added', friend);
263
+ }
264
+ else if (status === 'PENDING') {
265
+ if (direction === 'INBOUND') {
266
+ const pendingFriend = new IncomingPendingFriend_1.default(this.client, {
267
+ accountId: user.id,
268
+ // Type casting is fine here because the lookup by id always returns external auths
269
+ displayName: user.displayName,
270
+ created,
271
+ favorite,
272
+ });
273
+ this.client.friend.pendingList.set(pendingFriend.id, pendingFriend);
274
+ this.client.emit('friend:request', pendingFriend);
275
+ }
276
+ else if (direction === 'OUTBOUND') {
277
+ const pendingFriend = new OutgoingPendingFriend_1.default(this.client, {
278
+ accountId: user.id,
279
+ // Type casting is fine here because the lookup by id always returns external auths
280
+ displayName: user.displayName,
281
+ created,
282
+ favorite,
283
+ });
284
+ this.client.friend.pendingList.set(pendingFriend.id, pendingFriend);
285
+ this.client.emit('friend:request:sent', pendingFriend);
286
+ }
287
+ }
288
+ }
289
+ break;
290
+ case 'FRIENDSHIP_REMOVE':
291
+ {
292
+ const { from, to, reason } = body;
293
+ const accountId = from === this.client.user.self.id ? to : from;
294
+ if (reason === 'ABORTED') {
295
+ const pendingFriend = this.client.friend.pendingList.get(accountId);
296
+ if (!pendingFriend)
297
+ break;
298
+ this.client.friend.pendingList.delete(pendingFriend.id);
299
+ this.client.emit('friend:request:aborted', pendingFriend);
300
+ }
301
+ else if (reason === 'REJECTED') {
302
+ const pendingFriend = this.client.friend.pendingList.get(accountId);
303
+ if (!pendingFriend)
304
+ break;
305
+ this.client.friend.pendingList.delete(pendingFriend.id);
306
+ this.client.emit('friend:request:declined', pendingFriend);
307
+ }
308
+ else if (reason === 'DELETED') {
309
+ const friend = await this.waitForFriend(accountId);
310
+ if (!friend)
311
+ break;
312
+ this.client.friend.list.delete(friend.id);
313
+ this.client.emit('friend:removed', friend);
314
+ }
315
+ }
316
+ break;
317
+ case 'USER_BLOCKLIST_UPDATE':
318
+ {
319
+ const { status, accountId } = body;
320
+ if (status === 'BLOCKED') {
321
+ const user = await this.client.user.fetch(accountId);
322
+ if (!user)
323
+ break;
324
+ const blockedUser = new BlockedUser_1.default(this.client, user);
325
+ this.client.user.blocklist.set(user.id, blockedUser);
326
+ this.client.emit('user:blocked', blockedUser);
327
+ }
328
+ else if (status === 'UNBLOCKED') {
329
+ const blockedUser = this.client.user.blocklist.get(accountId);
330
+ if (!blockedUser)
331
+ break;
332
+ this.client.user.blocklist.delete(blockedUser.id);
333
+ this.client.emit('user:unblocked', blockedUser);
334
+ }
335
+ }
336
+ break;
337
+ case 'com.epicgames.social.party.notification.v0.PING':
338
+ {
339
+ if (this.client.config.disablePartyService)
340
+ break;
341
+ if (this.client.listenerCount('party:invite') === 0)
342
+ break;
343
+ const pingerId = body.pinger_id;
344
+ const friend = await this.waitForFriend(pingerId);
345
+ if (!friend)
346
+ throw new FriendNotFoundError_1.default(pingerId);
347
+ const data = await this.client.http.epicgamesRequest({
348
+ method: 'GET',
349
+ url: `${Endpoints_1.default.BR_PARTY}/user/${this.client.user.self.id}/pings/${pingerId}/parties`,
350
+ }, enums_1.AuthSessionStoreKey.Fortnite);
351
+ if (!data[0]) {
352
+ this.client.debug(`[XMPP] Error while processing ${body.type}: Could't find an active invitation`);
353
+ break;
354
+ }
355
+ const [partyData] = data;
356
+ let party;
357
+ if (partyData.config.discoverability === 'ALL')
358
+ party = await this.client.getParty(partyData.id);
359
+ else
360
+ party = new Party_1.default(this.client, partyData);
361
+ if (party.members.some((pm) => !pm.displayName))
362
+ await party.updateMemberBasicInfo();
363
+ let invitation = partyData.invites.find((i) => i.sent_by === pingerId && i.status === 'SENT');
364
+ if (!invitation)
365
+ invitation = (0, Util_1.createPartyInvitation)(this.client.user.self.id, pingerId, { ...body, ...partyData });
366
+ const invite = new ReceivedPartyInvitation_1.default(this.client, party, friend, this.client.user.self, invitation);
367
+ this.client.emit('party:invite', invite);
368
+ }
369
+ break;
370
+ case 'com.epicgames.social.party.notification.v0.MEMBER_JOINED':
371
+ {
372
+ if (this.client.config.disablePartyService)
373
+ break;
374
+ await this.client.partyLock.wait();
375
+ if (!this.client.party || this.client.party.id !== body.party_id)
376
+ break;
377
+ const memberId = body.account_id;
378
+ if (memberId === this.client.user.self.id) {
379
+ if (!this.client.party.me)
380
+ this.client.party.members.set(memberId, new ClientPartyMember_1.default(this.client.party, body));
381
+ await this.client.party.me.sendPatch(this.client.party.me.meta.schema);
382
+ }
383
+ else {
384
+ this.client.party.members.set(memberId, new PartyMember_1.default(this.client.party, body));
385
+ }
386
+ const member = this.client.party.members.get(memberId);
387
+ if (!member)
388
+ break;
389
+ if (!member.displayName)
390
+ await member.fetch();
391
+ this.client.setStatus();
392
+ if (this.client.party.me.isLeader)
393
+ await this.client.party.refreshSquadAssignments();
394
+ try {
395
+ await this.client.waitForEvent('party:member:updated', 2000, (um) => um.id === member.id);
396
+ }
397
+ catch (err) {
398
+ // ignore. meta will be partly undefined, but usually, if this takes longer than 2 seconds, something else went wrong
399
+ }
400
+ this.client.emit('party:member:joined', member);
401
+ }
402
+ break;
403
+ case 'com.epicgames.social.party.notification.v0.MEMBER_STATE_UPDATED':
404
+ {
405
+ if (this.client.config.disablePartyService)
406
+ break;
407
+ await this.client.partyLock.wait();
408
+ if (!this.client.party || this.client.party.id !== body.party_id)
409
+ return;
410
+ const memberId = body.account_id;
411
+ const member = this.client.party.members.get(memberId);
412
+ if (!member)
413
+ throw new PartyMemberNotFoundError_1.default(memberId);
414
+ if (member.receivedInitialStateUpdate) {
415
+ const newMeta = new PartyMemberMeta_1.default({ ...member.meta.schema });
416
+ newMeta.update(body.member_state_updated, true);
417
+ if (newMeta.outfit !== member.meta.outfit) {
418
+ this.client.emit('party:member:outfit:updated', member, newMeta.outfit, member.meta.outfit);
419
+ }
420
+ if (newMeta.backpack !== member.meta.backpack) {
421
+ this.client.emit('party:member:backpack:updated', member, newMeta.backpack, member.meta.backpack);
422
+ }
423
+ if (newMeta.pickaxe !== member.meta.pickaxe) {
424
+ this.client.emit('party:member:pickaxe:updated', member, newMeta.pickaxe, member.meta.pickaxe);
425
+ }
426
+ if (newMeta.emote !== member.meta.emote) {
427
+ this.client.emit('party:member:emote:updated', member, newMeta.emote, member.meta.emote);
428
+ }
429
+ if (newMeta.isReady !== member.meta.isReady) {
430
+ this.client.emit('party:member:readiness:updated', member, newMeta.isReady, member.meta.isReady);
431
+ }
432
+ if (JSON.stringify(newMeta.match) !== JSON.stringify(member.meta.match)) {
433
+ this.client.emit('party:member:matchstate:updated', member, newMeta.match, member.meta.match);
434
+ }
435
+ }
436
+ member.updateData(body);
437
+ member.receivedInitialStateUpdate = true;
438
+ this.client.emit('party:member:updated', member);
439
+ }
440
+ break;
441
+ case 'com.epicgames.social.party.notification.v0.MEMBER_LEFT':
442
+ {
443
+ if (this.client.config.disablePartyService)
444
+ break;
445
+ await this.client.partyLock.wait();
446
+ if (!this.client.party || this.client.party.id !== body.party_id)
447
+ break;
448
+ const memberId = body.account_id;
449
+ const member = this.client.party.members.get(memberId);
450
+ if (!member) {
451
+ if (this.client.party.pendingMemberConfirmations.has(memberId)) {
452
+ this.client.party.pendingMemberConfirmations.delete(memberId);
453
+ break;
454
+ }
455
+ throw new PartyMemberNotFoundError_1.default(memberId);
456
+ }
457
+ if (memberId === this.client.user.self.id) {
458
+ await this.client.initParty(true, false);
459
+ break;
460
+ }
461
+ this.client.party.members.delete(member.id);
462
+ this.client.setStatus();
463
+ if (this.client.party.me.isLeader)
464
+ await this.client.party.refreshSquadAssignments();
465
+ this.client.emit('party:member:left', member);
466
+ }
467
+ break;
468
+ case 'com.epicgames.social.party.notification.v0.MEMBER_EXPIRED':
469
+ {
470
+ if (this.client.config.disablePartyService)
471
+ break;
472
+ await this.client.partyLock.wait();
473
+ if (!this.client.party || this.client.party.id !== body.party_id
474
+ || body.account_id === this.client.user.self.id)
475
+ break;
476
+ const memberId = body.account_id;
477
+ const member = this.client.party.members.get(memberId);
478
+ if (!member)
479
+ return;
480
+ this.client.party.members.delete(member.id);
481
+ this.client.setStatus();
482
+ if (this.client.party.me.isLeader)
483
+ await this.client.party.refreshSquadAssignments();
484
+ this.client.emit('party:member:expired', member);
485
+ }
486
+ break;
487
+ case 'com.epicgames.social.party.notification.v0.MEMBER_KICKED':
488
+ {
489
+ if (this.client.config.disablePartyService)
490
+ break;
491
+ await this.client.partyLock.wait();
492
+ if (!this.client.party || this.client.party.id !== body.party_id)
493
+ break;
494
+ const memberId = body.account_id;
495
+ const member = this.client.party.members.get(memberId);
496
+ if (!member)
497
+ throw new PartyMemberNotFoundError_1.default(memberId);
498
+ if (member.id === this.client.user.self.id) {
499
+ this.client.party = undefined;
500
+ await this.client.initParty(true, false);
501
+ }
502
+ else {
503
+ this.client.party.members.delete(member.id);
504
+ this.client.setStatus();
505
+ if (this.client.party.me.isLeader)
506
+ await this.client.party.refreshSquadAssignments();
507
+ }
508
+ this.client.emit('party:member:kicked', member);
509
+ }
510
+ break;
511
+ case 'com.epicgames.social.party.notification.v0.MEMBER_DISCONNECTED':
512
+ {
513
+ if (this.client.config.disablePartyService)
514
+ break;
515
+ await this.client.partyLock.wait();
516
+ if (!this.client.party || this.client.party.id !== body.party_id)
517
+ break;
518
+ const memberId = body.account_id;
519
+ const member = this.client.party.members.get(memberId);
520
+ if (!member)
521
+ throw new PartyMemberNotFoundError_1.default(memberId);
522
+ this.client.party.members.delete(member.id);
523
+ this.client.setStatus();
524
+ if (this.client.party.me.isLeader)
525
+ await this.client.party.refreshSquadAssignments();
526
+ this.client.emit('party:member:disconnected', member);
527
+ }
528
+ break;
529
+ case 'com.epicgames.social.party.notification.v0.MEMBER_NEW_CAPTAIN':
530
+ {
531
+ if (this.client.config.disablePartyService)
532
+ break;
533
+ await this.client.partyLock.wait();
534
+ if (!this.client.party || this.client.party.id !== body.party_id)
535
+ break;
536
+ if (this.client.party.leader)
537
+ this.client.party.leader.role = '';
538
+ const memberId = body.account_id;
539
+ const member = this.client.party.members.get(memberId);
540
+ if (!member)
541
+ throw new PartyMemberNotFoundError_1.default(memberId);
542
+ member.role = 'CAPTAIN';
543
+ this.client.setStatus();
544
+ this.client.emit('party:member:promoted', member);
545
+ }
546
+ break;
547
+ case 'com.epicgames.social.party.notification.v0.PARTY_UPDATED':
548
+ if (this.client.config.disablePartyService)
549
+ break;
550
+ await this.client.partyLock.wait();
551
+ if (!this.client.party || this.client.party.id !== body.party_id)
552
+ break;
553
+ this.client.party.updateData(body);
554
+ this.client.setStatus();
555
+ this.client.emit('party:updated', this.client.party);
556
+ break;
557
+ case 'com.epicgames.social.party.notification.v0.MEMBER_REQUIRE_CONFIRMATION':
558
+ {
559
+ if (this.client.config.disablePartyService)
560
+ break;
561
+ await this.client.partyLock.wait();
562
+ if (!this.client.party || this.client.party.id !== body.party_id)
563
+ break;
564
+ const user = await this.client.user.fetch(body.account_id);
565
+ if (!user)
566
+ break;
567
+ const confirmation = new PartyMemberConfirmation_1.default(this.client, this.client.party, user, body);
568
+ this.client.party.pendingMemberConfirmations.set(user.id, confirmation);
569
+ if (this.client.listenerCount('party:member:confirmation') > 0) {
570
+ this.client.emit('party:member:confirmation', confirmation);
571
+ }
572
+ else {
573
+ await confirmation.confirm();
574
+ }
575
+ }
576
+ break;
577
+ case 'com.epicgames.social.party.notification.v0.INITIAL_INTENTION':
578
+ {
579
+ if (this.client.config.disablePartyService)
580
+ break;
581
+ await this.client.partyLock.wait();
582
+ if (!this.client.party || this.client.party.id !== body.party_id)
583
+ break;
584
+ const friend = await this.waitForFriend(body.requester_id);
585
+ if (!friend)
586
+ throw new FriendNotFoundError_1.default(body.requester_id);
587
+ const request = new ReceivedPartyJoinRequest_1.default(this.client, friend, this.client.user.self, body);
588
+ this.client.emit('party:joinrequest', request);
589
+ }
590
+ break;
591
+ }
592
+ }
593
+ catch (err) {
594
+ this.client.debug(`[XMPP] Error while processing ${body.type}: ${err.name} - ${err.message}`);
595
+ this.client.emit('xmpp:message:error', err);
596
+ }
597
+ });
598
+ }
599
+ /**
600
+ * Waits for a friend to be added to the clients cache
601
+ */
602
+ async waitForFriend(id) {
603
+ const cachedFriend = this.client.friend.list.get(id);
604
+ if (cachedFriend)
605
+ return cachedFriend;
606
+ try {
607
+ this.client.setMaxListeners(this.client.getMaxListeners() + 1);
608
+ const friend = await this.client.waitForEvent('friend:added', 5000, (f) => f.id === id);
609
+ return friend[0];
610
+ }
611
+ catch (e) {
612
+ return undefined;
613
+ }
614
+ finally {
615
+ this.client.setMaxListeners(this.client.getMaxListeners() - 1);
616
+ }
617
+ }
618
+ /**
619
+ * Sends a presence to all or a specific friend
620
+ * @param status The status message. Can be undefined if you want to reset it
621
+ * @param show The show type of the presence (eg "away")
622
+ * @param to The JID of a specific friend
623
+ */
624
+ sendStatus(status, show, to) {
625
+ if (!status) {
626
+ this.connection.sendPresence();
627
+ return;
628
+ }
629
+ this.connection.sendPresence({
630
+ status: JSON.stringify(typeof status === 'string' ? { Status: status } : status),
631
+ to,
632
+ show,
633
+ });
634
+ }
635
+ /**
636
+ * Sends an XMPP message
637
+ * @param to The message receiver's JID
638
+ * @param content The message that will be sent
639
+ * @param type The message type (eg "chat" or "groupchat")
640
+ * @deprecated this is useless now, since chat messages are handeled via an rest api now see {@link Client#chat}
641
+ */
642
+ async sendMessage(to, content, type = 'chat') {
643
+ return this.waitForSentMessage(this.connection.sendMessage({
644
+ to,
645
+ body: content,
646
+ type,
647
+ }));
648
+ }
649
+ /**
650
+ * Wait until a message is sent
651
+ * @param id The message id
652
+ * @param timeout How long to wait for the message
653
+ * @deprecated this is useless now, since chat messages are handeled via an rest api now see {@link Client#chat}
654
+ */
655
+ waitForSentMessage(id, timeout = 1000) {
656
+ return new Promise((res) => {
657
+ // eslint-disable-next-line no-undef
658
+ let messageTimeout;
659
+ const listener = (m) => {
660
+ if (m.id === id) {
661
+ this.connection.removeListener('message:sent', listener);
662
+ if (messageTimeout)
663
+ clearTimeout(messageTimeout);
664
+ res(m);
665
+ }
666
+ };
667
+ this.connection.on('message:sent', listener);
668
+ messageTimeout = setTimeout(() => {
669
+ res(undefined);
670
+ this.connection.removeListener('message:sent', listener);
671
+ }, timeout);
672
+ });
673
+ }
674
+ /**
675
+ * Joins a multi user chat room (MUC)
676
+ * @param jid The room's JID
677
+ * @param nick The client's nickname
678
+ * @deprecated this is useless now, since chat messages are handeled via an rest api now see {@link Client#chat}
679
+ */
680
+ async joinMUC(jid, nick) {
681
+ return this.connection.joinRoom(jid, nick);
682
+ }
683
+ /**
684
+ * Leaves a multi user chat room (MUC)
685
+ * @param jid The room's JID
686
+ * @param nick The client's nickname
687
+ * @deprecated this is useless now, since chat messages are handeled via an rest api now see {@link Client#chat}
688
+ */
689
+ async leaveMUC(jid, nick) {
690
+ return this.connection.leaveRoom(jid, nick);
691
+ }
692
+ /**
693
+ * Bans a member from a multi user chat room
694
+ * @param member The member that should be banned
695
+ * @deprecated this is useless now, since chat messages are handeled via an rest api now see {@link Client#chat}
696
+ */
697
+ async ban(jid, member) {
698
+ return this.connection.ban(jid, `${member}@${Endpoints_1.default.EPIC_PROD_ENV}`);
699
+ }
700
+ }
701
+ exports.default = XMPP;
702
+ //# sourceMappingURL=XMPP.js.map