@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.
- package/LICENSE +21 -0
- package/README.md +68 -0
- package/dist/enums/Enums.d.ts +251 -0
- package/dist/enums/Enums.js +202 -0
- package/dist/enums/Enums.js.map +1 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.js +194 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/AuthClients.d.ts +39 -0
- package/dist/resources/AuthClients.js +41 -0
- package/dist/resources/AuthClients.js.map +1 -0
- package/dist/resources/BaseItemRating.json +5203 -0
- package/dist/resources/Endpoints.d.ts +58 -0
- package/dist/resources/Endpoints.js +71 -0
- package/dist/resources/Endpoints.js.map +1 -0
- package/dist/resources/HomebaseRatingMapping.json +255 -0
- package/dist/resources/PowerLevelCurves.d.ts +111 -0
- package/dist/resources/PowerLevelCurves.js +21 -0
- package/dist/resources/PowerLevelCurves.js.map +1 -0
- package/dist/resources/SurvivorItemRating.json +9343 -0
- package/dist/resources/constants.d.ts +2 -0
- package/dist/resources/constants.js +11 -0
- package/dist/resources/constants.js.map +1 -0
- package/dist/resources/defaultPartyMemberMeta.json +28 -0
- package/dist/resources/defaultPartyMeta.json +38 -0
- package/dist/resources/enums.d.ts +12 -0
- package/dist/resources/enums.js +18 -0
- package/dist/resources/enums.js.map +1 -0
- package/dist/resources/httpResponses.d.ts +773 -0
- package/dist/resources/httpResponses.js +3 -0
- package/dist/resources/httpResponses.js.map +1 -0
- package/dist/resources/structs.d.ts +1310 -0
- package/dist/resources/structs.js +3 -0
- package/dist/resources/structs.js.map +1 -0
- package/dist/src/Base.d.ts +15 -0
- package/dist/src/Base.js +15 -0
- package/dist/src/Base.js.map +1 -0
- package/dist/src/Client.d.ts +341 -0
- package/dist/src/Client.js +1043 -0
- package/dist/src/Client.js.map +1 -0
- package/dist/src/auth/Auth.d.ts +66 -0
- package/dist/src/auth/Auth.js +249 -0
- package/dist/src/auth/Auth.js.map +1 -0
- package/dist/src/auth/AuthSession.d.ts +41 -0
- package/dist/src/auth/AuthSession.js +25 -0
- package/dist/src/auth/AuthSession.js.map +1 -0
- package/dist/src/auth/EOSAuthSession.d.ts +19 -0
- package/dist/src/auth/EOSAuthSession.js +80 -0
- package/dist/src/auth/EOSAuthSession.js.map +1 -0
- package/dist/src/auth/FortniteAuthSession.d.ts +53 -0
- package/dist/src/auth/FortniteAuthSession.js +107 -0
- package/dist/src/auth/FortniteAuthSession.js.map +1 -0
- package/dist/src/auth/FortniteClientCredentialsAuthSession.d.ts +18 -0
- package/dist/src/auth/FortniteClientCredentialsAuthSession.js +88 -0
- package/dist/src/auth/FortniteClientCredentialsAuthSession.js.map +1 -0
- package/dist/src/auth/LauncherAuthSession.d.ts +23 -0
- package/dist/src/auth/LauncherAuthSession.js +120 -0
- package/dist/src/auth/LauncherAuthSession.js.map +1 -0
- package/dist/src/exceptions/AuthenticationMissingError.d.ts +15 -0
- package/dist/src/exceptions/AuthenticationMissingError.js +18 -0
- package/dist/src/exceptions/AuthenticationMissingError.js.map +1 -0
- package/dist/src/exceptions/CreativeIslandNotFoundError.d.ts +14 -0
- package/dist/src/exceptions/CreativeIslandNotFoundError.js +18 -0
- package/dist/src/exceptions/CreativeIslandNotFoundError.js.map +1 -0
- package/dist/src/exceptions/CreatorCodeNotFoundError.d.ts +14 -0
- package/dist/src/exceptions/CreatorCodeNotFoundError.js +18 -0
- package/dist/src/exceptions/CreatorCodeNotFoundError.js.map +1 -0
- package/dist/src/exceptions/DuplicateFriendshipError.d.ts +14 -0
- package/dist/src/exceptions/DuplicateFriendshipError.js +18 -0
- package/dist/src/exceptions/DuplicateFriendshipError.js.map +1 -0
- package/dist/src/exceptions/EpicgamesAPIError.d.ts +42 -0
- package/dist/src/exceptions/EpicgamesAPIError.js +27 -0
- package/dist/src/exceptions/EpicgamesAPIError.js.map +1 -0
- package/dist/src/exceptions/EventTimeoutError.d.ts +19 -0
- package/dist/src/exceptions/EventTimeoutError.js +20 -0
- package/dist/src/exceptions/EventTimeoutError.js.map +1 -0
- package/dist/src/exceptions/FriendNotFoundError.d.ts +14 -0
- package/dist/src/exceptions/FriendNotFoundError.js +18 -0
- package/dist/src/exceptions/FriendNotFoundError.js.map +1 -0
- package/dist/src/exceptions/FriendshipRequestAlreadySentError.d.ts +14 -0
- package/dist/src/exceptions/FriendshipRequestAlreadySentError.js +18 -0
- package/dist/src/exceptions/FriendshipRequestAlreadySentError.js.map +1 -0
- package/dist/src/exceptions/InviteeFriendshipRequestLimitExceededError.d.ts +14 -0
- package/dist/src/exceptions/InviteeFriendshipRequestLimitExceededError.js +18 -0
- package/dist/src/exceptions/InviteeFriendshipRequestLimitExceededError.js.map +1 -0
- package/dist/src/exceptions/InviteeFriendshipSettingsError.d.ts +14 -0
- package/dist/src/exceptions/InviteeFriendshipSettingsError.js +18 -0
- package/dist/src/exceptions/InviteeFriendshipSettingsError.js.map +1 -0
- package/dist/src/exceptions/InviteeFriendshipsLimitExceededError.d.ts +14 -0
- package/dist/src/exceptions/InviteeFriendshipsLimitExceededError.js +18 -0
- package/dist/src/exceptions/InviteeFriendshipsLimitExceededError.js.map +1 -0
- package/dist/src/exceptions/InviterFriendshipsLimitExceededError.d.ts +14 -0
- package/dist/src/exceptions/InviterFriendshipsLimitExceededError.js +18 -0
- package/dist/src/exceptions/InviterFriendshipsLimitExceededError.js.map +1 -0
- package/dist/src/exceptions/MatchNotFoundError.d.ts +14 -0
- package/dist/src/exceptions/MatchNotFoundError.js +18 -0
- package/dist/src/exceptions/MatchNotFoundError.js.map +1 -0
- package/dist/src/exceptions/OfferNotFoundError.d.ts +14 -0
- package/dist/src/exceptions/OfferNotFoundError.js +18 -0
- package/dist/src/exceptions/OfferNotFoundError.js.map +1 -0
- package/dist/src/exceptions/PartyAlreadyJoinedError.d.ts +7 -0
- package/dist/src/exceptions/PartyAlreadyJoinedError.js +14 -0
- package/dist/src/exceptions/PartyAlreadyJoinedError.js.map +1 -0
- package/dist/src/exceptions/PartyInvitationExpiredError.d.ts +7 -0
- package/dist/src/exceptions/PartyInvitationExpiredError.js +14 -0
- package/dist/src/exceptions/PartyInvitationExpiredError.js.map +1 -0
- package/dist/src/exceptions/PartyMaxSizeReachedError.d.ts +7 -0
- package/dist/src/exceptions/PartyMaxSizeReachedError.js +14 -0
- package/dist/src/exceptions/PartyMaxSizeReachedError.js.map +1 -0
- package/dist/src/exceptions/PartyMemberNotFoundError.d.ts +14 -0
- package/dist/src/exceptions/PartyMemberNotFoundError.js +18 -0
- package/dist/src/exceptions/PartyMemberNotFoundError.js.map +1 -0
- package/dist/src/exceptions/PartyNotFoundError.d.ts +7 -0
- package/dist/src/exceptions/PartyNotFoundError.js +14 -0
- package/dist/src/exceptions/PartyNotFoundError.js.map +1 -0
- package/dist/src/exceptions/PartyPermissionError.d.ts +7 -0
- package/dist/src/exceptions/PartyPermissionError.js +14 -0
- package/dist/src/exceptions/PartyPermissionError.js.map +1 -0
- package/dist/src/exceptions/SendMessageError.d.ts +27 -0
- package/dist/src/exceptions/SendMessageError.js +21 -0
- package/dist/src/exceptions/SendMessageError.js.map +1 -0
- package/dist/src/exceptions/StatsPrivacyError.d.ts +14 -0
- package/dist/src/exceptions/StatsPrivacyError.js +18 -0
- package/dist/src/exceptions/StatsPrivacyError.js.map +1 -0
- package/dist/src/exceptions/StompConnectionError.d.ts +14 -0
- package/dist/src/exceptions/StompConnectionError.js +18 -0
- package/dist/src/exceptions/StompConnectionError.js.map +1 -0
- package/dist/src/exceptions/UserNotFoundError.d.ts +14 -0
- package/dist/src/exceptions/UserNotFoundError.js +18 -0
- package/dist/src/exceptions/UserNotFoundError.js.map +1 -0
- package/dist/src/exceptions/XMPPConnectionError.d.ts +19 -0
- package/dist/src/exceptions/XMPPConnectionError.js +19 -0
- package/dist/src/exceptions/XMPPConnectionError.js.map +1 -0
- package/dist/src/exceptions/XMPPConnectionTimeoutError.d.ts +14 -0
- package/dist/src/exceptions/XMPPConnectionTimeoutError.js +18 -0
- package/dist/src/exceptions/XMPPConnectionTimeoutError.js.map +1 -0
- package/dist/src/http/HTTP.d.ts +40 -0
- package/dist/src/http/HTTP.js +124 -0
- package/dist/src/http/HTTP.js.map +1 -0
- package/dist/src/managers/ChatManager.d.ts +27 -0
- package/dist/src/managers/ChatManager.js +71 -0
- package/dist/src/managers/ChatManager.js.map +1 -0
- package/dist/src/managers/FriendManager.d.ts +66 -0
- package/dist/src/managers/FriendManager.js +175 -0
- package/dist/src/managers/FriendManager.js.map +1 -0
- package/dist/src/managers/STWManager.d.ts +29 -0
- package/dist/src/managers/STWManager.js +80 -0
- package/dist/src/managers/STWManager.js.map +1 -0
- package/dist/src/managers/TournamentManager.d.ts +51 -0
- package/dist/src/managers/TournamentManager.js +182 -0
- package/dist/src/managers/TournamentManager.js.map +1 -0
- package/dist/src/managers/UserManager.d.ts +78 -0
- package/dist/src/managers/UserManager.js +216 -0
- package/dist/src/managers/UserManager.js.map +1 -0
- package/dist/src/stomp/EOSConnect.d.ts +43 -0
- package/dist/src/stomp/EOSConnect.js +175 -0
- package/dist/src/stomp/EOSConnect.js.map +1 -0
- package/dist/src/structures/Avatar.d.ts +27 -0
- package/dist/src/structures/Avatar.js +22 -0
- package/dist/src/structures/Avatar.js.map +1 -0
- package/dist/src/structures/BaseMessage.d.ts +34 -0
- package/dist/src/structures/BaseMessage.js +22 -0
- package/dist/src/structures/BaseMessage.js.map +1 -0
- package/dist/src/structures/CreatorCode.d.ts +31 -0
- package/dist/src/structures/CreatorCode.js +22 -0
- package/dist/src/structures/CreatorCode.js.map +1 -0
- package/dist/src/structures/EpicgamesServerStatus.d.ts +52 -0
- package/dist/src/structures/EpicgamesServerStatus.js +31 -0
- package/dist/src/structures/EpicgamesServerStatus.js.map +1 -0
- package/dist/src/structures/EpicgamesServerStatusComponent.d.ts +67 -0
- package/dist/src/structures/EpicgamesServerStatusComponent.js +37 -0
- package/dist/src/structures/EpicgamesServerStatusComponent.js.map +1 -0
- package/dist/src/structures/EpicgamesServerStatusIncident.d.ts +58 -0
- package/dist/src/structures/EpicgamesServerStatusIncident.js +36 -0
- package/dist/src/structures/EpicgamesServerStatusIncident.js.map +1 -0
- package/dist/src/structures/EpicgamesServerStatusScheduledMainteance.d.ts +21 -0
- package/dist/src/structures/EpicgamesServerStatusScheduledMainteance.js +20 -0
- package/dist/src/structures/EpicgamesServerStatusScheduledMainteance.js.map +1 -0
- package/dist/src/structures/EventTokens.d.ts +32 -0
- package/dist/src/structures/EventTokens.js +45 -0
- package/dist/src/structures/EventTokens.js.map +1 -0
- package/dist/src/structures/FortniteServerStatus.d.ts +46 -0
- package/dist/src/structures/FortniteServerStatus.js +26 -0
- package/dist/src/structures/FortniteServerStatus.js.map +1 -0
- package/dist/src/structures/GlobalProfile.d.ts +36 -0
- package/dist/src/structures/GlobalProfile.js +25 -0
- package/dist/src/structures/GlobalProfile.js.map +1 -0
- package/dist/src/structures/Image.d.ts +36 -0
- package/dist/src/structures/Image.js +38 -0
- package/dist/src/structures/Image.js.map +1 -0
- package/dist/src/structures/NewsMessage.d.ts +56 -0
- package/dist/src/structures/NewsMessage.js +45 -0
- package/dist/src/structures/NewsMessage.js.map +1 -0
- package/dist/src/structures/NewsMessageVideo.d.ts +47 -0
- package/dist/src/structures/NewsMessageVideo.js +32 -0
- package/dist/src/structures/NewsMessageVideo.js.map +1 -0
- package/dist/src/structures/RadioStation.d.ts +31 -0
- package/dist/src/structures/RadioStation.js +33 -0
- package/dist/src/structures/RadioStation.js.map +1 -0
- package/dist/src/structures/Stats.d.ts +45 -0
- package/dist/src/structures/Stats.js +109 -0
- package/dist/src/structures/Stats.js.map +1 -0
- package/dist/src/structures/Tournament.d.ts +86 -0
- package/dist/src/structures/Tournament.js +64 -0
- package/dist/src/structures/Tournament.js.map +1 -0
- package/dist/src/structures/TournamentWindow.d.ts +124 -0
- package/dist/src/structures/TournamentWindow.js +52 -0
- package/dist/src/structures/TournamentWindow.js.map +1 -0
- package/dist/src/structures/friend/BaseFriendMessage.d.ts +32 -0
- package/dist/src/structures/friend/BaseFriendMessage.js +28 -0
- package/dist/src/structures/friend/BaseFriendMessage.js.map +1 -0
- package/dist/src/structures/friend/BasePendingFriend.d.ts +22 -0
- package/dist/src/structures/friend/BasePendingFriend.js +22 -0
- package/dist/src/structures/friend/BasePendingFriend.js.map +1 -0
- package/dist/src/structures/friend/Friend.d.ts +106 -0
- package/dist/src/structures/friend/Friend.js +97 -0
- package/dist/src/structures/friend/Friend.js.map +1 -0
- package/dist/src/structures/friend/FriendPresence.d.ts +84 -0
- package/dist/src/structures/friend/FriendPresence.js +48 -0
- package/dist/src/structures/friend/FriendPresence.js.map +1 -0
- package/dist/src/structures/friend/IncomingPendingFriend.d.ts +27 -0
- package/dist/src/structures/friend/IncomingPendingFriend.js +36 -0
- package/dist/src/structures/friend/IncomingPendingFriend.js.map +1 -0
- package/dist/src/structures/friend/OutgoingPendingFriend.d.ts +17 -0
- package/dist/src/structures/friend/OutgoingPendingFriend.js +24 -0
- package/dist/src/structures/friend/OutgoingPendingFriend.js.map +1 -0
- package/dist/src/structures/friend/ReceivedFriendMessage.d.ts +27 -0
- package/dist/src/structures/friend/ReceivedFriendMessage.js +27 -0
- package/dist/src/structures/friend/ReceivedFriendMessage.js.map +1 -0
- package/dist/src/structures/friend/SentFriendMessage.d.ts +21 -0
- package/dist/src/structures/friend/SentFriendMessage.js +19 -0
- package/dist/src/structures/friend/SentFriendMessage.js.map +1 -0
- package/dist/src/structures/party/BasePartyInvitation.d.ts +48 -0
- package/dist/src/structures/party/BasePartyInvitation.js +33 -0
- package/dist/src/structures/party/BasePartyInvitation.js.map +1 -0
- package/dist/src/structures/party/BasePartyJoinRequest.d.ts +37 -0
- package/dist/src/structures/party/BasePartyJoinRequest.js +30 -0
- package/dist/src/structures/party/BasePartyJoinRequest.js.map +1 -0
- package/dist/src/structures/party/ClientParty.d.ts +162 -0
- package/dist/src/structures/party/ClientParty.js +412 -0
- package/dist/src/structures/party/ClientParty.js.map +1 -0
- package/dist/src/structures/party/ClientPartyMember.d.ts +144 -0
- package/dist/src/structures/party/ClientPartyMember.js +463 -0
- package/dist/src/structures/party/ClientPartyMember.js.map +1 -0
- package/dist/src/structures/party/ClientPartyMemberMeta.d.ts +18 -0
- package/dist/src/structures/party/ClientPartyMemberMeta.js +54 -0
- package/dist/src/structures/party/ClientPartyMemberMeta.js.map +1 -0
- package/dist/src/structures/party/ClientPartyMeta.d.ts +23 -0
- package/dist/src/structures/party/ClientPartyMeta.js +59 -0
- package/dist/src/structures/party/ClientPartyMeta.js.map +1 -0
- package/dist/src/structures/party/Party.d.ts +95 -0
- package/dist/src/structures/party/Party.js +200 -0
- package/dist/src/structures/party/Party.js.map +1 -0
- package/dist/src/structures/party/PartyChat.d.ts +73 -0
- package/dist/src/structures/party/PartyChat.js +76 -0
- package/dist/src/structures/party/PartyChat.js.map +1 -0
- package/dist/src/structures/party/PartyMember.d.ts +139 -0
- package/dist/src/structures/party/PartyMember.js +201 -0
- package/dist/src/structures/party/PartyMember.js.map +1 -0
- package/dist/src/structures/party/PartyMemberConfirmation.d.ts +43 -0
- package/dist/src/structures/party/PartyMemberConfirmation.js +53 -0
- package/dist/src/structures/party/PartyMemberConfirmation.js.map +1 -0
- package/dist/src/structures/party/PartyMemberMeta.d.ts +76 -0
- package/dist/src/structures/party/PartyMemberMeta.js +145 -0
- package/dist/src/structures/party/PartyMemberMeta.js.map +1 -0
- package/dist/src/structures/party/PartyMessage.d.ts +30 -0
- package/dist/src/structures/party/PartyMessage.js +28 -0
- package/dist/src/structures/party/PartyMessage.js.map +1 -0
- package/dist/src/structures/party/PartyMeta.d.ts +24 -0
- package/dist/src/structures/party/PartyMeta.js +43 -0
- package/dist/src/structures/party/PartyMeta.js.map +1 -0
- package/dist/src/structures/party/PresenceParty.d.ts +66 -0
- package/dist/src/structures/party/PresenceParty.js +49 -0
- package/dist/src/structures/party/PresenceParty.js.map +1 -0
- package/dist/src/structures/party/ReceivedPartyInvitation.d.ts +33 -0
- package/dist/src/structures/party/ReceivedPartyInvitation.js +54 -0
- package/dist/src/structures/party/ReceivedPartyInvitation.js.map +1 -0
- package/dist/src/structures/party/ReceivedPartyJoinRequest.d.ts +26 -0
- package/dist/src/structures/party/ReceivedPartyJoinRequest.js +31 -0
- package/dist/src/structures/party/ReceivedPartyJoinRequest.js.map +1 -0
- package/dist/src/structures/party/SentPartyInvitation.d.ts +27 -0
- package/dist/src/structures/party/SentPartyInvitation.js +39 -0
- package/dist/src/structures/party/SentPartyInvitation.js.map +1 -0
- package/dist/src/structures/party/SentPartyJoinRequest.d.ts +19 -0
- package/dist/src/structures/party/SentPartyJoinRequest.js +22 -0
- package/dist/src/structures/party/SentPartyJoinRequest.js.map +1 -0
- package/dist/src/structures/stw/STWHero.d.ts +61 -0
- package/dist/src/structures/stw/STWHero.js +38 -0
- package/dist/src/structures/stw/STWHero.js.map +1 -0
- package/dist/src/structures/stw/STWHeroLoadout.d.ts +44 -0
- package/dist/src/structures/stw/STWHeroLoadout.js +34 -0
- package/dist/src/structures/stw/STWHeroLoadout.js.map +1 -0
- package/dist/src/structures/stw/STWItem.d.ts +31 -0
- package/dist/src/structures/stw/STWItem.js +23 -0
- package/dist/src/structures/stw/STWItem.js.map +1 -0
- package/dist/src/structures/stw/STWLocker.d.ts +32 -0
- package/dist/src/structures/stw/STWLocker.js +26 -0
- package/dist/src/structures/stw/STWLocker.js.map +1 -0
- package/dist/src/structures/stw/STWMeleeWeaponSchematic.d.ts +14 -0
- package/dist/src/structures/stw/STWMeleeWeaponSchematic.js +15 -0
- package/dist/src/structures/stw/STWMeleeWeaponSchematic.js.map +1 -0
- package/dist/src/structures/stw/STWNewsMessage.d.ts +42 -0
- package/dist/src/structures/stw/STWNewsMessage.js +27 -0
- package/dist/src/structures/stw/STWNewsMessage.js.map +1 -0
- package/dist/src/structures/stw/STWProfile.d.ts +132 -0
- package/dist/src/structures/stw/STWProfile.js +283 -0
- package/dist/src/structures/stw/STWProfile.js.map +1 -0
- package/dist/src/structures/stw/STWRangedWeaponSchematic.d.ts +14 -0
- package/dist/src/structures/stw/STWRangedWeaponSchematic.js +15 -0
- package/dist/src/structures/stw/STWRangedWeaponSchematic.js.map +1 -0
- package/dist/src/structures/stw/STWResource.d.ts +27 -0
- package/dist/src/structures/stw/STWResource.js +22 -0
- package/dist/src/structures/stw/STWResource.js.map +1 -0
- package/dist/src/structures/stw/STWSchematic.d.ts +72 -0
- package/dist/src/structures/stw/STWSchematic.js +40 -0
- package/dist/src/structures/stw/STWSchematic.js.map +1 -0
- package/dist/src/structures/stw/STWStats.d.ts +103 -0
- package/dist/src/structures/stw/STWStats.js +85 -0
- package/dist/src/structures/stw/STWStats.js.map +1 -0
- package/dist/src/structures/stw/STWSurvivor.d.ts +104 -0
- package/dist/src/structures/stw/STWSurvivor.js +76 -0
- package/dist/src/structures/stw/STWSurvivor.js.map +1 -0
- package/dist/src/structures/stw/STWTeamPerk.d.ts +19 -0
- package/dist/src/structures/stw/STWTeamPerk.js +20 -0
- package/dist/src/structures/stw/STWTeamPerk.js.map +1 -0
- package/dist/src/structures/stw/STWTrapSchematic.d.ts +15 -0
- package/dist/src/structures/stw/STWTrapSchematic.js +16 -0
- package/dist/src/structures/stw/STWTrapSchematic.js.map +1 -0
- package/dist/src/structures/stw/STWWeaponSchematic.d.ts +15 -0
- package/dist/src/structures/stw/STWWeaponSchematic.js +16 -0
- package/dist/src/structures/stw/STWWeaponSchematic.js.map +1 -0
- package/dist/src/structures/user/BlockedUser.d.ts +13 -0
- package/dist/src/structures/user/BlockedUser.js +19 -0
- package/dist/src/structures/user/BlockedUser.js.map +1 -0
- package/dist/src/structures/user/ClientUser.d.ts +78 -0
- package/dist/src/structures/user/ClientUser.js +34 -0
- package/dist/src/structures/user/ClientUser.js.map +1 -0
- package/dist/src/structures/user/User.d.ts +98 -0
- package/dist/src/structures/user/User.js +130 -0
- package/dist/src/structures/user/User.js.map +1 -0
- package/dist/src/structures/user/UserSearchResult.d.ts +31 -0
- package/dist/src/structures/user/UserSearchResult.js +23 -0
- package/dist/src/structures/user/UserSearchResult.js.map +1 -0
- package/dist/src/util/AsyncLock.d.ts +28 -0
- package/dist/src/util/AsyncLock.js +44 -0
- package/dist/src/util/AsyncLock.js.map +1 -0
- package/dist/src/util/BinaryWriter.d.ts +79 -0
- package/dist/src/util/BinaryWriter.js +136 -0
- package/dist/src/util/BinaryWriter.js.map +1 -0
- package/dist/src/util/CurveTable.d.ts +24 -0
- package/dist/src/util/CurveTable.js +37 -0
- package/dist/src/util/CurveTable.js.map +1 -0
- package/dist/src/util/Meta.d.ts +41 -0
- package/dist/src/util/Meta.js +73 -0
- package/dist/src/util/Meta.js.map +1 -0
- package/dist/src/util/Util.d.ts +162 -0
- package/dist/src/util/Util.js +539 -0
- package/dist/src/util/Util.js.map +1 -0
- package/dist/src/xmpp/XMPP.d.ts +100 -0
- package/dist/src/xmpp/XMPP.js +702 -0
- package/dist/src/xmpp/XMPP.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,1043 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
/* eslint-disable no-restricted-syntax */
|
|
5
|
+
const events_1 = require("events");
|
|
6
|
+
const Enums_1 = tslib_1.__importDefault(require("../enums/Enums"));
|
|
7
|
+
const Util_1 = require("./util/Util");
|
|
8
|
+
const Auth_1 = tslib_1.__importDefault(require("./auth/Auth"));
|
|
9
|
+
const HTTP_1 = tslib_1.__importDefault(require("./http/HTTP"));
|
|
10
|
+
const AsyncLock_1 = tslib_1.__importDefault(require("./util/AsyncLock"));
|
|
11
|
+
const Endpoints_1 = tslib_1.__importDefault(require("../resources/Endpoints"));
|
|
12
|
+
const XMPP_1 = tslib_1.__importDefault(require("./xmpp/XMPP"));
|
|
13
|
+
const Friend_1 = tslib_1.__importDefault(require("./structures/friend/Friend"));
|
|
14
|
+
const UserNotFoundError_1 = tslib_1.__importDefault(require("./exceptions/UserNotFoundError"));
|
|
15
|
+
const StatsPrivacyError_1 = tslib_1.__importDefault(require("./exceptions/StatsPrivacyError"));
|
|
16
|
+
const CreatorCode_1 = tslib_1.__importDefault(require("./structures/CreatorCode"));
|
|
17
|
+
const CreatorCodeNotFoundError_1 = tslib_1.__importDefault(require("./exceptions/CreatorCodeNotFoundError"));
|
|
18
|
+
const FriendNotFoundError_1 = tslib_1.__importDefault(require("./exceptions/FriendNotFoundError"));
|
|
19
|
+
const IncomingPendingFriend_1 = tslib_1.__importDefault(require("./structures/friend/IncomingPendingFriend"));
|
|
20
|
+
const OutgoingPendingFriend_1 = tslib_1.__importDefault(require("./structures/friend/OutgoingPendingFriend"));
|
|
21
|
+
const BlockedUser_1 = tslib_1.__importDefault(require("./structures/user/BlockedUser"));
|
|
22
|
+
const ClientParty_1 = tslib_1.__importDefault(require("./structures/party/ClientParty"));
|
|
23
|
+
const Party_1 = tslib_1.__importDefault(require("./structures/party/Party"));
|
|
24
|
+
const PartyNotFoundError_1 = tslib_1.__importDefault(require("./exceptions/PartyNotFoundError"));
|
|
25
|
+
const PartyPermissionError_1 = tslib_1.__importDefault(require("./exceptions/PartyPermissionError"));
|
|
26
|
+
const SentPartyJoinRequest_1 = tslib_1.__importDefault(require("./structures/party/SentPartyJoinRequest"));
|
|
27
|
+
const RadioStation_1 = tslib_1.__importDefault(require("./structures/RadioStation"));
|
|
28
|
+
const CreativeIslandNotFoundError_1 = tslib_1.__importDefault(require("./exceptions/CreativeIslandNotFoundError"));
|
|
29
|
+
const Stats_1 = tslib_1.__importDefault(require("./structures/Stats"));
|
|
30
|
+
const NewsMessage_1 = tslib_1.__importDefault(require("./structures/NewsMessage"));
|
|
31
|
+
const EventTimeoutError_1 = tslib_1.__importDefault(require("./exceptions/EventTimeoutError"));
|
|
32
|
+
const FortniteServerStatus_1 = tslib_1.__importDefault(require("./structures/FortniteServerStatus"));
|
|
33
|
+
const EpicgamesServerStatus_1 = tslib_1.__importDefault(require("./structures/EpicgamesServerStatus"));
|
|
34
|
+
const TournamentManager_1 = tslib_1.__importDefault(require("./managers/TournamentManager"));
|
|
35
|
+
const enums_1 = require("../resources/enums");
|
|
36
|
+
const EpicgamesAPIError_1 = tslib_1.__importDefault(require("./exceptions/EpicgamesAPIError"));
|
|
37
|
+
const UserManager_1 = tslib_1.__importDefault(require("./managers/UserManager"));
|
|
38
|
+
const FriendManager_1 = tslib_1.__importDefault(require("./managers/FriendManager"));
|
|
39
|
+
const STWManager_1 = tslib_1.__importDefault(require("./managers/STWManager"));
|
|
40
|
+
const EOSConnect_1 = tslib_1.__importDefault(require("./stomp/EOSConnect"));
|
|
41
|
+
const ChatManager_1 = tslib_1.__importDefault(require("./managers/ChatManager"));
|
|
42
|
+
/**
|
|
43
|
+
* Represets the main client
|
|
44
|
+
*/
|
|
45
|
+
class Client extends events_1.EventEmitter {
|
|
46
|
+
/**
|
|
47
|
+
* @param config The client's configuration options
|
|
48
|
+
*/
|
|
49
|
+
constructor(config = {}) {
|
|
50
|
+
var _a, _b;
|
|
51
|
+
super();
|
|
52
|
+
this.config = {
|
|
53
|
+
savePartyMemberMeta: true,
|
|
54
|
+
http: {},
|
|
55
|
+
debug: undefined,
|
|
56
|
+
httpDebug: undefined,
|
|
57
|
+
xmppDebug: undefined,
|
|
58
|
+
defaultStatus: undefined,
|
|
59
|
+
defaultOnlineType: Enums_1.default.PresenceOnlineType.ONLINE,
|
|
60
|
+
platform: 'WIN',
|
|
61
|
+
defaultPartyMemberMeta: {},
|
|
62
|
+
xmppKeepAliveInterval: 30,
|
|
63
|
+
xmppMaxConnectionRetries: 2,
|
|
64
|
+
createParty: true,
|
|
65
|
+
forceNewParty: true,
|
|
66
|
+
disablePartyService: false,
|
|
67
|
+
connectToXMPP: true,
|
|
68
|
+
connectToStompEOSConnect: true,
|
|
69
|
+
fetchFriends: true,
|
|
70
|
+
restRetryLimit: 1,
|
|
71
|
+
handleRatelimits: true,
|
|
72
|
+
partyBuildId: '1:3:',
|
|
73
|
+
restartOnInvalidRefresh: false,
|
|
74
|
+
language: 'en',
|
|
75
|
+
friendOnlineConnectionTimeout: 30000,
|
|
76
|
+
friendOfflineTimeout: 300000,
|
|
77
|
+
eosDeploymentId: '62a9473a2dca46b29ccf17577fcf42d7',
|
|
78
|
+
...config,
|
|
79
|
+
cacheSettings: {
|
|
80
|
+
...config.cacheSettings,
|
|
81
|
+
presences: {
|
|
82
|
+
maxLifetime: Infinity,
|
|
83
|
+
sweepInterval: 0,
|
|
84
|
+
...(_a = config.cacheSettings) === null || _a === void 0 ? void 0 : _a.presences,
|
|
85
|
+
},
|
|
86
|
+
users: {
|
|
87
|
+
maxLifetime: 0,
|
|
88
|
+
sweepInterval: 0,
|
|
89
|
+
...(_b = config.cacheSettings) === null || _b === void 0 ? void 0 : _b.users,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
auth: {
|
|
93
|
+
authorizationCode: async () => (0, Util_1.consoleQuestion)('Please enter an authorization code: '),
|
|
94
|
+
checkEULA: true,
|
|
95
|
+
killOtherTokens: true,
|
|
96
|
+
createLauncherSession: false,
|
|
97
|
+
authClient: 'fortniteIOSGameClient',
|
|
98
|
+
...config.auth,
|
|
99
|
+
},
|
|
100
|
+
partyConfig: {
|
|
101
|
+
privacy: Enums_1.default.PartyPrivacy.PUBLIC,
|
|
102
|
+
joinConfirmation: false,
|
|
103
|
+
joinability: 'OPEN',
|
|
104
|
+
maxSize: 16,
|
|
105
|
+
chatEnabled: true,
|
|
106
|
+
discoverability: 'ALL',
|
|
107
|
+
...config.partyConfig,
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
this.timeouts = new Set();
|
|
111
|
+
this.intervals = new Set();
|
|
112
|
+
this.auth = new Auth_1.default(this);
|
|
113
|
+
this.http = new HTTP_1.default(this);
|
|
114
|
+
this.xmpp = new XMPP_1.default(this);
|
|
115
|
+
this.stompEOSConnect = new EOSConnect_1.default(this);
|
|
116
|
+
this.partyLock = new AsyncLock_1.default();
|
|
117
|
+
this.cacheLock = new AsyncLock_1.default();
|
|
118
|
+
this.isReady = false;
|
|
119
|
+
this.friend = new FriendManager_1.default(this);
|
|
120
|
+
this.user = new UserManager_1.default(this);
|
|
121
|
+
this.party = undefined;
|
|
122
|
+
this.chat = new ChatManager_1.default(this);
|
|
123
|
+
this.tournaments = new TournamentManager_1.default(this);
|
|
124
|
+
this.lastPartyMemberMeta = this.config.defaultPartyMemberMeta;
|
|
125
|
+
this.stw = new STWManager_1.default(this);
|
|
126
|
+
}
|
|
127
|
+
// Events
|
|
128
|
+
on(event, listener) {
|
|
129
|
+
return super.on(event, listener);
|
|
130
|
+
}
|
|
131
|
+
once(event, listener) {
|
|
132
|
+
return super.once(event, listener);
|
|
133
|
+
}
|
|
134
|
+
emit(event, ...args) {
|
|
135
|
+
return super.emit(event, ...args);
|
|
136
|
+
}
|
|
137
|
+
/* -------------------------------------------------------------------------- */
|
|
138
|
+
/* CLIENT LOGIN AND LOGOUT */
|
|
139
|
+
/* -------------------------------------------------------------------------- */
|
|
140
|
+
/**
|
|
141
|
+
* Logs the client in.
|
|
142
|
+
* A valid authentication method must be provided in the client's config.
|
|
143
|
+
* By default, there will be a console prompt asking for an authorization code
|
|
144
|
+
* @throws {EpicgamesAPIError}
|
|
145
|
+
* @throws {EpicgamesGraphQLError}
|
|
146
|
+
*/
|
|
147
|
+
async login() {
|
|
148
|
+
await this.auth.authenticate();
|
|
149
|
+
await this.user.fetchSelf();
|
|
150
|
+
this.initCacheSweeping();
|
|
151
|
+
this.cacheLock.lock();
|
|
152
|
+
try {
|
|
153
|
+
if (this.config.connectToXMPP)
|
|
154
|
+
await this.xmpp.connect();
|
|
155
|
+
if (this.config.connectToStompEOSConnect)
|
|
156
|
+
await this.stompEOSConnect.connect();
|
|
157
|
+
if (this.config.fetchFriends)
|
|
158
|
+
await this.updateCaches();
|
|
159
|
+
}
|
|
160
|
+
finally {
|
|
161
|
+
this.cacheLock.unlock();
|
|
162
|
+
}
|
|
163
|
+
if (!this.config.disablePartyService)
|
|
164
|
+
await this.initParty(this.config.createParty, this.config.forceNewParty);
|
|
165
|
+
if (this.xmpp.isConnected)
|
|
166
|
+
this.setStatus();
|
|
167
|
+
this.isReady = true;
|
|
168
|
+
this.emit('ready');
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Logs the client out.
|
|
172
|
+
* Also clears all caches, etc
|
|
173
|
+
*/
|
|
174
|
+
async logout() {
|
|
175
|
+
await this.auth.revokeAllTokens();
|
|
176
|
+
this.xmpp.disconnect();
|
|
177
|
+
this.destroy();
|
|
178
|
+
this.isReady = false;
|
|
179
|
+
this.emit('disconnected');
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Restarts the client
|
|
183
|
+
*/
|
|
184
|
+
async restart() {
|
|
185
|
+
var _a;
|
|
186
|
+
const refreshToken = (_a = this.auth.sessions.get(enums_1.AuthSessionStoreKey.Fortnite)) === null || _a === void 0 ? void 0 : _a.refreshToken;
|
|
187
|
+
await this.logout();
|
|
188
|
+
this.config.auth.refreshToken = refreshToken;
|
|
189
|
+
await this.login();
|
|
190
|
+
this.config.auth.refreshToken = undefined;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Initializes {@link Client#party}
|
|
194
|
+
* @param createNew Whether to create a new party
|
|
195
|
+
* @param forceNew Whether to force create a new party
|
|
196
|
+
*/
|
|
197
|
+
async initParty(createNew = true, forceNew = true) {
|
|
198
|
+
this.party = await this.getClientParty();
|
|
199
|
+
if (!forceNew && this.party)
|
|
200
|
+
return;
|
|
201
|
+
if (createNew) {
|
|
202
|
+
await this.leaveParty(false);
|
|
203
|
+
await this.createParty();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Internal method that sets a {@link ClientParty} to the value of {@link Client#party}
|
|
208
|
+
* @param party The party
|
|
209
|
+
* @private
|
|
210
|
+
*/
|
|
211
|
+
setClientParty(party) {
|
|
212
|
+
this.party = new ClientParty_1.default(this, party);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Waits until the client is ready
|
|
216
|
+
* @param timeout How long to wait for until an error is thrown
|
|
217
|
+
*/
|
|
218
|
+
async waitUntilReady(timeout = 10000) {
|
|
219
|
+
if (this.isReady)
|
|
220
|
+
return;
|
|
221
|
+
this.setMaxListeners(this.getMaxListeners() + 1);
|
|
222
|
+
try {
|
|
223
|
+
await this.waitForEvent('ready', timeout);
|
|
224
|
+
}
|
|
225
|
+
finally {
|
|
226
|
+
this.setMaxListeners(this.getMaxListeners() - 1);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Cleanup method
|
|
231
|
+
*/
|
|
232
|
+
destroy() {
|
|
233
|
+
// Clear timeouts
|
|
234
|
+
for (const interval of this.intervals)
|
|
235
|
+
clearInterval(interval);
|
|
236
|
+
for (const timeout of this.timeouts)
|
|
237
|
+
clearTimeout(timeout);
|
|
238
|
+
this.timeouts.clear();
|
|
239
|
+
this.intervals.clear();
|
|
240
|
+
// Clear remaining caches
|
|
241
|
+
this.friend.list.clear();
|
|
242
|
+
this.friend.pendingList.clear();
|
|
243
|
+
this.user.blocklist.clear();
|
|
244
|
+
this.user.cache.clear();
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Initializes the sweeping of cached objects
|
|
248
|
+
*/
|
|
249
|
+
initCacheSweeping() {
|
|
250
|
+
const { cacheSettings } = this.config;
|
|
251
|
+
const presenceCacheSettings = cacheSettings.presences;
|
|
252
|
+
if (presenceCacheSettings && presenceCacheSettings.sweepInterval && presenceCacheSettings.sweepInterval > 0
|
|
253
|
+
&& presenceCacheSettings.maxLifetime > 0 && presenceCacheSettings.maxLifetime !== Infinity) {
|
|
254
|
+
this.setInterval(this.sweepPresences.bind(this), presenceCacheSettings.sweepInterval);
|
|
255
|
+
}
|
|
256
|
+
const userCacheSettings = cacheSettings.users;
|
|
257
|
+
if (userCacheSettings && userCacheSettings.sweepInterval && userCacheSettings.sweepInterval > 0
|
|
258
|
+
&& userCacheSettings.maxLifetime > 0 && userCacheSettings.maxLifetime !== Infinity) {
|
|
259
|
+
this.setInterval(this.sweepUsers.bind(this), userCacheSettings.sweepInterval);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Updates the client's caches
|
|
264
|
+
*/
|
|
265
|
+
async updateCaches() {
|
|
266
|
+
const friendsSummary = await this.http.epicgamesRequest({
|
|
267
|
+
url: `${Endpoints_1.default.FRIENDS}/${this.user.self.id}/summary`,
|
|
268
|
+
}, enums_1.AuthSessionStoreKey.Fortnite);
|
|
269
|
+
this.friend.list.clear();
|
|
270
|
+
this.friend.pendingList.clear();
|
|
271
|
+
this.user.blocklist.clear();
|
|
272
|
+
friendsSummary.friends.forEach((f) => {
|
|
273
|
+
this.friend.list.set(f.accountId, new Friend_1.default(this, { ...f, id: f.accountId }));
|
|
274
|
+
});
|
|
275
|
+
friendsSummary.incoming.forEach((f) => {
|
|
276
|
+
this.friend.pendingList.set(f.accountId, new IncomingPendingFriend_1.default(this, { ...f, id: f.accountId }));
|
|
277
|
+
});
|
|
278
|
+
friendsSummary.outgoing.forEach((f) => {
|
|
279
|
+
this.friend.pendingList.set(f.accountId, new OutgoingPendingFriend_1.default(this, { ...f, id: f.accountId }));
|
|
280
|
+
});
|
|
281
|
+
friendsSummary.blocklist.forEach((u) => {
|
|
282
|
+
this.user.blocklist.set(u.accountId, new BlockedUser_1.default(this, { ...u, id: u.accountId }));
|
|
283
|
+
});
|
|
284
|
+
const users = await this.user.fetchMultiple([
|
|
285
|
+
...this.friend.list.values(),
|
|
286
|
+
...this.friend.pendingList.values(),
|
|
287
|
+
...this.user.blocklist.values(),
|
|
288
|
+
]
|
|
289
|
+
.filter((u) => !!u.id)
|
|
290
|
+
.map((u) => u.id));
|
|
291
|
+
users.forEach((u) => {
|
|
292
|
+
var _a, _b, _c;
|
|
293
|
+
(_a = this.friend.list.get(u.id)) === null || _a === void 0 ? void 0 : _a.update(u);
|
|
294
|
+
(_b = this.friend.pendingList.get(u.id)) === null || _b === void 0 ? void 0 : _b.update(u);
|
|
295
|
+
(_c = this.user.blocklist.get(u.id)) === null || _c === void 0 ? void 0 : _c.update(u);
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Removes presences from the client's cache that are older than the max lifetime
|
|
300
|
+
* @param maxLifetime How old a presence cache entry must be before it can be sweeped (in seconds)
|
|
301
|
+
* @returns The amount of presences sweeped
|
|
302
|
+
*/
|
|
303
|
+
sweepPresences(maxLifetime) {
|
|
304
|
+
var _a, _b;
|
|
305
|
+
if (maxLifetime === void 0) { maxLifetime = (_a = this.config.cacheSettings.presences) === null || _a === void 0 ? void 0 : _a.maxLifetime; }
|
|
306
|
+
if (typeof maxLifetime !== 'number') {
|
|
307
|
+
throw new TypeError('maxLifetime must be typeof number');
|
|
308
|
+
}
|
|
309
|
+
let presences = 0;
|
|
310
|
+
for (const friend of this.friend.list.values()) {
|
|
311
|
+
if (typeof ((_b = friend.presence) === null || _b === void 0 ? void 0 : _b.receivedAt) !== 'undefined' && Date.now() - friend.presence.receivedAt.getTime() > maxLifetime * 1000) {
|
|
312
|
+
delete friend.presence;
|
|
313
|
+
presences += 1;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return presences;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Removes users from the client's cache that are older than the max lifetime
|
|
320
|
+
* @param maxLifetime How old a user cache entry must be before it can be sweeped (in seconds)
|
|
321
|
+
* @returns The amount of users sweeped
|
|
322
|
+
*/
|
|
323
|
+
sweepUsers(maxLifetime) {
|
|
324
|
+
var _a;
|
|
325
|
+
if (maxLifetime === void 0) { maxLifetime = (_a = this.config.cacheSettings.users) === null || _a === void 0 ? void 0 : _a.maxLifetime; }
|
|
326
|
+
if (typeof maxLifetime !== 'number') {
|
|
327
|
+
throw new TypeError('maxLifetime must be typeof number');
|
|
328
|
+
}
|
|
329
|
+
let users = 0;
|
|
330
|
+
for (const user of this.user.cache.values()) {
|
|
331
|
+
if (Date.now() - user.cachedAt > maxLifetime * 1000) {
|
|
332
|
+
this.user.cache.delete(user.id);
|
|
333
|
+
users += 1;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return users;
|
|
337
|
+
}
|
|
338
|
+
/* -------------------------------------------------------------------------- */
|
|
339
|
+
/* UTIL */
|
|
340
|
+
/* -------------------------------------------------------------------------- */
|
|
341
|
+
/**
|
|
342
|
+
* Wait until an event is emitted
|
|
343
|
+
* @param event The event that will be waited for
|
|
344
|
+
* @param timeout The timeout (in milliseconds)
|
|
345
|
+
* @param filter The filter for the event
|
|
346
|
+
*/
|
|
347
|
+
waitForEvent(event, timeout = 5000,
|
|
348
|
+
// eslint-disable-next-line no-unused-vars
|
|
349
|
+
filter) {
|
|
350
|
+
return new Promise((res, rej) => {
|
|
351
|
+
// eslint-disable-next-line no-undef
|
|
352
|
+
let rejectionTimeout;
|
|
353
|
+
const handler = (...data) => {
|
|
354
|
+
if (!filter || filter(...data)) {
|
|
355
|
+
this.removeListener(event, handler);
|
|
356
|
+
if (rejectionTimeout)
|
|
357
|
+
clearTimeout(rejectionTimeout);
|
|
358
|
+
res(data);
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
this.on(event, handler);
|
|
362
|
+
const err = new EventTimeoutError_1.default(event, timeout);
|
|
363
|
+
rejectionTimeout = setTimeout(() => {
|
|
364
|
+
this.removeListener(event, handler);
|
|
365
|
+
rej(err);
|
|
366
|
+
}, timeout);
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Sets a timeout that will be automatically cancelled if the client is logged out
|
|
371
|
+
* @param fn Function to execute
|
|
372
|
+
* @param delay Time to wait before executing (in milliseconds)
|
|
373
|
+
* @param args Arguments for the function
|
|
374
|
+
*/
|
|
375
|
+
// eslint-disable-next-line no-unused-vars
|
|
376
|
+
setTimeout(fn, delay, ...args) {
|
|
377
|
+
const timeout = setTimeout(() => {
|
|
378
|
+
fn(args);
|
|
379
|
+
this.timeouts.delete(timeout);
|
|
380
|
+
}, delay);
|
|
381
|
+
this.timeouts.add(timeout);
|
|
382
|
+
return timeout;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Clears a timeout
|
|
386
|
+
* @param timeout Timeout to cancel
|
|
387
|
+
*/
|
|
388
|
+
// eslint-disable-next-line no-undef
|
|
389
|
+
clearTimeout(timeout) {
|
|
390
|
+
clearTimeout(timeout);
|
|
391
|
+
this.timeouts.delete(timeout);
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Sets an interval that will be automatically cancelled if the client is logged out
|
|
395
|
+
* @param fn Function to execute
|
|
396
|
+
* @param delay Time to wait between executions (in milliseconds)
|
|
397
|
+
* @param args Arguments for the function
|
|
398
|
+
*/
|
|
399
|
+
// eslint-disable-next-line no-unused-vars
|
|
400
|
+
setInterval(fn, delay, ...args) {
|
|
401
|
+
const interval = setInterval(fn, delay, ...args);
|
|
402
|
+
this.intervals.add(interval);
|
|
403
|
+
return interval;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Clears an interval.
|
|
407
|
+
* @param interval Interval to cancel
|
|
408
|
+
*/
|
|
409
|
+
// eslint-disable-next-line no-undef
|
|
410
|
+
clearInterval(interval) {
|
|
411
|
+
clearInterval(interval);
|
|
412
|
+
this.intervals.delete(interval);
|
|
413
|
+
}
|
|
414
|
+
static consoleQuestion(question) {
|
|
415
|
+
return (0, Util_1.consoleQuestion)(question);
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Debug a message using the methods set in the client config
|
|
419
|
+
* @param message Text to debug
|
|
420
|
+
* @param type Debug type (regular, http or xmpp)
|
|
421
|
+
*/
|
|
422
|
+
debug(message, type = 'regular') {
|
|
423
|
+
switch (type) {
|
|
424
|
+
case 'regular':
|
|
425
|
+
if (typeof this.config.debug === 'function')
|
|
426
|
+
this.config.debug(message);
|
|
427
|
+
break;
|
|
428
|
+
case 'http':
|
|
429
|
+
if (typeof this.config.httpDebug === 'function') {
|
|
430
|
+
this.config.httpDebug(message);
|
|
431
|
+
}
|
|
432
|
+
break;
|
|
433
|
+
case 'xmpp':
|
|
434
|
+
if (typeof this.config.xmppDebug === 'function') {
|
|
435
|
+
this.config.xmppDebug(message);
|
|
436
|
+
}
|
|
437
|
+
break;
|
|
438
|
+
case 'eos-connect':
|
|
439
|
+
if (typeof this.config.stompEosConnectDebug === 'function') {
|
|
440
|
+
this.config.stompEosConnectDebug(message);
|
|
441
|
+
}
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
/* -------------------------------------------------------------------------- */
|
|
446
|
+
/* STATUS */
|
|
447
|
+
/* -------------------------------------------------------------------------- */
|
|
448
|
+
/**
|
|
449
|
+
* Sets the clients XMPP status
|
|
450
|
+
* @param status The status
|
|
451
|
+
* @param onlineType The presence's online type (eg "away")
|
|
452
|
+
* @param friend A specific friend you want to send this status to
|
|
453
|
+
* @throws {FriendNotFoundError} The user does not exist or is not friends with the client
|
|
454
|
+
*/
|
|
455
|
+
setStatus(status, onlineType, friend) {
|
|
456
|
+
var _a;
|
|
457
|
+
let toJID;
|
|
458
|
+
if (friend) {
|
|
459
|
+
const resolvedFriend = this.friend.resolve(friend);
|
|
460
|
+
if (!resolvedFriend)
|
|
461
|
+
throw new FriendNotFoundError_1.default(friend);
|
|
462
|
+
toJID = `${resolvedFriend.id}@${Endpoints_1.default.EPIC_PROD_ENV}`;
|
|
463
|
+
}
|
|
464
|
+
// eslint-disable-next-line no-undef-init
|
|
465
|
+
let partyJoinInfoData = undefined;
|
|
466
|
+
if (this.party) {
|
|
467
|
+
const partyPrivacy = this.party.config.privacy;
|
|
468
|
+
if (partyPrivacy.presencePermission === 'Noone'
|
|
469
|
+
|| (partyPrivacy.presencePermission === 'Leader'
|
|
470
|
+
&& !((_a = this.party.me) === null || _a === void 0 ? void 0 : _a.isLeader))) {
|
|
471
|
+
partyJoinInfoData = {
|
|
472
|
+
isPrivate: true,
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
partyJoinInfoData = {
|
|
477
|
+
sourceId: this.user.self.displayName,
|
|
478
|
+
sourceDisplayName: this.user.self.displayName,
|
|
479
|
+
sourcePlatform: this.config.platform,
|
|
480
|
+
partyId: this.party.id,
|
|
481
|
+
partyTypeId: 286331153,
|
|
482
|
+
key: 'k',
|
|
483
|
+
appId: 'Fortnite',
|
|
484
|
+
buildId: this.config.partyBuildId,
|
|
485
|
+
partyFlags: -2024557306,
|
|
486
|
+
notAcceptingReason: 0,
|
|
487
|
+
pc: this.party.size,
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
if (status && !toJID)
|
|
492
|
+
this.config.defaultStatus = status;
|
|
493
|
+
if (onlineType && !toJID)
|
|
494
|
+
this.config.defaultOnlineType = onlineType;
|
|
495
|
+
const rawStatus = {
|
|
496
|
+
Status: status || this.config.defaultStatus || (this.party && `Lobby - ${this.party.size} / ${this.party.maxSize}`)
|
|
497
|
+
|| 'Playing Battle Royale',
|
|
498
|
+
bIsPlaying: false,
|
|
499
|
+
bIsJoinable: this.party && !this.party.isPrivate && this.party.size !== this.party.maxSize,
|
|
500
|
+
bHasVoiceSupport: false,
|
|
501
|
+
SessionId: '',
|
|
502
|
+
ProductName: 'Fortnite',
|
|
503
|
+
Properties: {
|
|
504
|
+
'party.joininfodata.286331153_j': partyJoinInfoData,
|
|
505
|
+
FortBasicInfo_j: {
|
|
506
|
+
homeBaseRating: 0,
|
|
507
|
+
},
|
|
508
|
+
FortLFG_I: '0',
|
|
509
|
+
FortPartySize_i: 1,
|
|
510
|
+
FortSubGame_i: 1,
|
|
511
|
+
InUnjoinableMatch_b: false,
|
|
512
|
+
FortGameplayStats_j: {
|
|
513
|
+
state: '',
|
|
514
|
+
playlist: 'None',
|
|
515
|
+
numKills: 0,
|
|
516
|
+
bFellToDeath: false,
|
|
517
|
+
},
|
|
518
|
+
},
|
|
519
|
+
};
|
|
520
|
+
const rawOnlineType = (onlineType || this.config.defaultOnlineType) === 'online' ? undefined : onlineType || this.config.defaultOnlineType;
|
|
521
|
+
return this.xmpp.sendStatus(rawStatus, rawOnlineType, toJID);
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Resets the client's XMPP status and online type
|
|
525
|
+
*/
|
|
526
|
+
async resetStatus() {
|
|
527
|
+
this.config.defaultStatus = undefined;
|
|
528
|
+
this.config.defaultOnlineType = 'online';
|
|
529
|
+
return this.setStatus();
|
|
530
|
+
}
|
|
531
|
+
/* -------------------------------------------------------------------------- */
|
|
532
|
+
/* PARTIES */
|
|
533
|
+
/* -------------------------------------------------------------------------- */
|
|
534
|
+
/**
|
|
535
|
+
* Sends a party invitation to a friend
|
|
536
|
+
* @param friend The friend that will receive the invitation
|
|
537
|
+
* @throws {FriendNotFoundError} The user does not exist or is not friends with the client
|
|
538
|
+
* @throws {PartyAlreadyJoinedError} The user is already a member of this party
|
|
539
|
+
* @throws {PartyMaxSizeReachedError} The party reached its max size
|
|
540
|
+
* @throws {PartyNotFoundError} The client is not in party
|
|
541
|
+
* @throws {EpicgamesAPIError}
|
|
542
|
+
*/
|
|
543
|
+
async invite(friend) {
|
|
544
|
+
if (!this.party)
|
|
545
|
+
throw new PartyNotFoundError_1.default();
|
|
546
|
+
return this.party.invite(friend);
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Joins a party by its id
|
|
550
|
+
* @param id The party id
|
|
551
|
+
* @throws {PartyNotFoundError} The party wasn't found
|
|
552
|
+
* @throws {PartyPermissionError} The party cannot be fetched
|
|
553
|
+
* @throws {PartyMaxSizeReachedError} The party has reached its max size
|
|
554
|
+
* @throws {EpicgamesAPIError}
|
|
555
|
+
*/
|
|
556
|
+
async joinParty(id) {
|
|
557
|
+
const party = (await this.getParty(id));
|
|
558
|
+
return party.join(true);
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Creates a new party
|
|
562
|
+
* @param config The party config
|
|
563
|
+
* @throws {EpicgamesAPIError}
|
|
564
|
+
*/
|
|
565
|
+
async createParty(config) {
|
|
566
|
+
var _a;
|
|
567
|
+
if (this.party)
|
|
568
|
+
await this.party.leave();
|
|
569
|
+
this.partyLock.lock();
|
|
570
|
+
const partyConfig = { ...this.config.partyConfig, ...config };
|
|
571
|
+
let party;
|
|
572
|
+
try {
|
|
573
|
+
party = await this.http.epicgamesRequest({
|
|
574
|
+
method: 'POST',
|
|
575
|
+
url: `${Endpoints_1.default.BR_PARTY}/parties`,
|
|
576
|
+
headers: {
|
|
577
|
+
'Content-Type': 'application/json',
|
|
578
|
+
},
|
|
579
|
+
data: {
|
|
580
|
+
config: {
|
|
581
|
+
join_confirmation: partyConfig.joinConfirmation,
|
|
582
|
+
joinability: partyConfig.joinability,
|
|
583
|
+
max_size: partyConfig.maxSize,
|
|
584
|
+
},
|
|
585
|
+
join_info: {
|
|
586
|
+
connection: {
|
|
587
|
+
id: this.xmpp.JID,
|
|
588
|
+
meta: {
|
|
589
|
+
'urn:epic:conn:platform_s': this.config.platform,
|
|
590
|
+
'urn:epic:conn:type_s': 'game',
|
|
591
|
+
},
|
|
592
|
+
yield_leadership: false,
|
|
593
|
+
},
|
|
594
|
+
meta: {
|
|
595
|
+
'urn:epic:member:dn_s': this.user.self.displayName,
|
|
596
|
+
},
|
|
597
|
+
},
|
|
598
|
+
meta: {
|
|
599
|
+
'urn:epic:cfg:party-type-id_s': 'default',
|
|
600
|
+
'urn:epic:cfg:build-id_s': this.config.partyBuildId,
|
|
601
|
+
'urn:epic:cfg:join-request-action_s': 'Manual',
|
|
602
|
+
'urn:epic:cfg:chat-enabled_b': ((_a = partyConfig.chatEnabled) === null || _a === void 0 ? void 0 : _a.toString()) || 'true',
|
|
603
|
+
'urn:epic:cfg:can-join_b': 'true',
|
|
604
|
+
},
|
|
605
|
+
},
|
|
606
|
+
}, enums_1.AuthSessionStoreKey.Fortnite);
|
|
607
|
+
}
|
|
608
|
+
catch (e) {
|
|
609
|
+
this.partyLock.unlock();
|
|
610
|
+
if (e instanceof EpicgamesAPIError_1.default && e.code === 'errors.com.epicgames.social.party.user_has_party') {
|
|
611
|
+
await this.leaveParty(false);
|
|
612
|
+
return this.createParty(config);
|
|
613
|
+
}
|
|
614
|
+
throw e;
|
|
615
|
+
}
|
|
616
|
+
this.party = new ClientParty_1.default(this, party);
|
|
617
|
+
const newPrivacy = await this.party.setPrivacy(partyConfig.privacy || Enums_1.default.PartyPrivacy.PUBLIC, false);
|
|
618
|
+
await this.party.sendPatch({
|
|
619
|
+
...newPrivacy.updated,
|
|
620
|
+
...Object.keys(this.party.meta.schema)
|
|
621
|
+
.filter((k) => !k.startsWith('urn:'))
|
|
622
|
+
.reduce((obj, key) => {
|
|
623
|
+
var _a;
|
|
624
|
+
// eslint-disable-next-line no-param-reassign
|
|
625
|
+
obj[key] = (_a = this.party) === null || _a === void 0 ? void 0 : _a.meta.schema[key];
|
|
626
|
+
return obj;
|
|
627
|
+
}, {}),
|
|
628
|
+
}, newPrivacy.deleted);
|
|
629
|
+
this.partyLock.unlock();
|
|
630
|
+
await this.party.chat.join();
|
|
631
|
+
return undefined;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Leaves the client's current party
|
|
635
|
+
* @param createNew Whether a new party should be created
|
|
636
|
+
* @throws {EpicgamesAPIError}
|
|
637
|
+
*/
|
|
638
|
+
async leaveParty(createNew = true) {
|
|
639
|
+
if (!this.party)
|
|
640
|
+
return undefined;
|
|
641
|
+
return this.party.leave(createNew);
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Sends a party join request to a friend.
|
|
645
|
+
* When the friend confirms this, a party invite will be sent to the client
|
|
646
|
+
* @param friend The friend
|
|
647
|
+
* @throws {FriendNotFoundError} The user does not exist or is not friends with the client
|
|
648
|
+
* @throws {PartyNotFoundError} The friend is not in a party
|
|
649
|
+
* @throws {EpicgamesAPIError}
|
|
650
|
+
*/
|
|
651
|
+
async sendRequestToJoin(friend) {
|
|
652
|
+
const resolvedFriend = this.friend.list.find((f) => f.displayName === friend || f.id === friend);
|
|
653
|
+
if (!resolvedFriend)
|
|
654
|
+
throw new FriendNotFoundError_1.default(friend);
|
|
655
|
+
let intention;
|
|
656
|
+
try {
|
|
657
|
+
intention = await this.http.epicgamesRequest({
|
|
658
|
+
method: 'POST',
|
|
659
|
+
url: `${Endpoints_1.default.BR_PARTY}/members/${resolvedFriend.id}/intentions/${this.user.self.id}`,
|
|
660
|
+
headers: {
|
|
661
|
+
'Content-Type': 'application/json',
|
|
662
|
+
},
|
|
663
|
+
data: {
|
|
664
|
+
'urn:epic:invite:platformdata_s': '',
|
|
665
|
+
},
|
|
666
|
+
}, enums_1.AuthSessionStoreKey.Fortnite);
|
|
667
|
+
}
|
|
668
|
+
catch (e) {
|
|
669
|
+
if (e instanceof EpicgamesAPIError_1.default && e.code === 'errors.com.epicgames.social.party.user_has_no_party') {
|
|
670
|
+
throw new PartyNotFoundError_1.default();
|
|
671
|
+
}
|
|
672
|
+
throw e;
|
|
673
|
+
}
|
|
674
|
+
return new SentPartyJoinRequest_1.default(this, this.user.self, resolvedFriend, intention);
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Fetches the client's party
|
|
678
|
+
* @throws {EpicgamesAPIError}
|
|
679
|
+
*/
|
|
680
|
+
async getClientParty() {
|
|
681
|
+
const party = await this.http.epicgamesRequest({
|
|
682
|
+
method: 'GET',
|
|
683
|
+
url: `${Endpoints_1.default.BR_PARTY}/user/${this.user.self.id}`,
|
|
684
|
+
}, enums_1.AuthSessionStoreKey.Fortnite);
|
|
685
|
+
if (!(party === null || party === void 0 ? void 0 : party.current[0]))
|
|
686
|
+
return undefined;
|
|
687
|
+
return new ClientParty_1.default(this, party.current[0]);
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Fetches a party by its id
|
|
691
|
+
* @param id The party's id
|
|
692
|
+
* @param raw Whether to return the raw party data
|
|
693
|
+
* @throws {PartyNotFoundError} The party wasn't found
|
|
694
|
+
* @throws {PartyPermissionError} The party cannot be fetched due to a permission error
|
|
695
|
+
* @throws {EpicgamesAPIError}
|
|
696
|
+
*/
|
|
697
|
+
async getParty(id, raw = false) {
|
|
698
|
+
let party;
|
|
699
|
+
try {
|
|
700
|
+
party = await this.http.epicgamesRequest({
|
|
701
|
+
method: 'GET',
|
|
702
|
+
url: `${Endpoints_1.default.BR_PARTY}/parties/${id}`,
|
|
703
|
+
}, enums_1.AuthSessionStoreKey.Fortnite);
|
|
704
|
+
}
|
|
705
|
+
catch (e) {
|
|
706
|
+
if (e instanceof EpicgamesAPIError_1.default) {
|
|
707
|
+
if (e.code === 'errors.com.epicgames.social.party.party_not_found') {
|
|
708
|
+
throw new PartyNotFoundError_1.default();
|
|
709
|
+
}
|
|
710
|
+
if (e.code === 'errors.com.epicgames.social.party.party_query_forbidden') {
|
|
711
|
+
throw new PartyPermissionError_1.default();
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
throw e;
|
|
715
|
+
}
|
|
716
|
+
if (raw)
|
|
717
|
+
return party;
|
|
718
|
+
const constuctedParty = new Party_1.default(this, party);
|
|
719
|
+
await constuctedParty.updateMemberBasicInfo();
|
|
720
|
+
return constuctedParty;
|
|
721
|
+
}
|
|
722
|
+
/* -------------------------------------------------------------------------- */
|
|
723
|
+
/* FORTNITE */
|
|
724
|
+
/* -------------------------------------------------------------------------- */
|
|
725
|
+
/**
|
|
726
|
+
* Fetches the current Fortnite server status (lightswitch)
|
|
727
|
+
* @throws {EpicgamesAPIError}
|
|
728
|
+
*/
|
|
729
|
+
async getFortniteServerStatus() {
|
|
730
|
+
const fortniteServerStatus = await this.http.epicgamesRequest({
|
|
731
|
+
method: 'GET',
|
|
732
|
+
url: Endpoints_1.default.BR_SERVER_STATUS,
|
|
733
|
+
}, enums_1.AuthSessionStoreKey.Fortnite);
|
|
734
|
+
return new FortniteServerStatus_1.default(this, fortniteServerStatus[0]);
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Fetches the current epicgames server status (https://status.epicgames.com/)
|
|
738
|
+
* @throws {AxiosError}
|
|
739
|
+
*/
|
|
740
|
+
async getEpicgamesServerStatus() {
|
|
741
|
+
const epicgamesServerStatus = await this.http.request({
|
|
742
|
+
method: 'GET',
|
|
743
|
+
url: Endpoints_1.default.SERVER_STATUS_SUMMARY,
|
|
744
|
+
});
|
|
745
|
+
if (!epicgamesServerStatus) {
|
|
746
|
+
throw new Error('Request returned an empty body');
|
|
747
|
+
}
|
|
748
|
+
return new EpicgamesServerStatus_1.default(this, epicgamesServerStatus.data);
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Fetches the current Fortnite storefronts
|
|
752
|
+
* @param language The language
|
|
753
|
+
* @throws {EpicgamesAPIError}
|
|
754
|
+
*/
|
|
755
|
+
async getStorefronts(language = 'en') {
|
|
756
|
+
const store = await this.http.epicgamesRequest({
|
|
757
|
+
method: 'GET',
|
|
758
|
+
url: `${Endpoints_1.default.BR_STORE}?lang=${language}`,
|
|
759
|
+
}, enums_1.AuthSessionStoreKey.Fortnite);
|
|
760
|
+
return store.storefronts;
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Downloads a blurl stream (eg a radio station stream or a news video)
|
|
764
|
+
* @param id The stream ID
|
|
765
|
+
* @throws {AxiosError}
|
|
766
|
+
*/
|
|
767
|
+
async downloadBlurlStream(id) {
|
|
768
|
+
const blurlFile = await this.http.request({
|
|
769
|
+
method: 'GET',
|
|
770
|
+
url: `${Endpoints_1.default.BR_STREAM}/${id}/master.blurl`,
|
|
771
|
+
responseType: 'arraybuffer',
|
|
772
|
+
});
|
|
773
|
+
const streamData = await (0, Util_1.parseBlurlStream)(blurlFile.data);
|
|
774
|
+
const streamMetaData = {
|
|
775
|
+
subtitles: streamData.subtitles ? JSON.parse(streamData.subtitles) : {},
|
|
776
|
+
ucp: streamData.ucp,
|
|
777
|
+
audioonly: !!streamData.audioonly,
|
|
778
|
+
aspectratio: streamData.aspectratio,
|
|
779
|
+
partysync: !!streamData.partysync,
|
|
780
|
+
lrcs: streamData.lrcs ? JSON.parse(streamData.lrcs) : {},
|
|
781
|
+
duration: streamData.duration,
|
|
782
|
+
};
|
|
783
|
+
const languageStreams = streamData.playlists.filter((p) => p.type === 'master').map((s) => {
|
|
784
|
+
var _a, _b;
|
|
785
|
+
let baseURL = (_a = s.url.match(/.+\//)) === null || _a === void 0 ? void 0 : _a[0];
|
|
786
|
+
if (baseURL && !baseURL.endsWith('/'))
|
|
787
|
+
baseURL += '/';
|
|
788
|
+
const data = (0, Util_1.parseM3U8File)(s.data);
|
|
789
|
+
let variants = data.streams.map((ss) => {
|
|
790
|
+
var _a, _b;
|
|
791
|
+
return ({
|
|
792
|
+
data: {
|
|
793
|
+
codecs: ((_a = ss.data.CODECS) === null || _a === void 0 ? void 0 : _a.split(',')) || [],
|
|
794
|
+
bandwidth: parseInt(ss.data.BANDWIDTH, 10),
|
|
795
|
+
resolution: ss.data.RESOLUTION,
|
|
796
|
+
},
|
|
797
|
+
type: ss.data.RESOLUTION ? 'video' : 'audio',
|
|
798
|
+
url: `${baseURL || ''}${ss.url}`,
|
|
799
|
+
stream: (_b = streamData.playlists
|
|
800
|
+
.find((p) => p.type === 'variant' && p.rel_url === ss.url)) === null || _b === void 0 ? void 0 : _b.data.split(/\n/).map((l) => (!l.startsWith('#') && l.length > 0 ? `${baseURL || ''}${l}` : l)).join('\n').replace(/init_/g, `${baseURL || ''}init_`),
|
|
801
|
+
});
|
|
802
|
+
});
|
|
803
|
+
if (!streamMetaData.audioonly) {
|
|
804
|
+
const audioStreamUrl = (_b = variants.find((v) => v.type === 'audio')) === null || _b === void 0 ? void 0 : _b.url;
|
|
805
|
+
if (audioStreamUrl) {
|
|
806
|
+
variants = variants.map((v) => ({
|
|
807
|
+
...v,
|
|
808
|
+
stream: Buffer.from(v.type !== 'video' ? v.stream : v.stream.replace('#EXTINF:', '#EXT-X-STREAM-INF:AUDIO="group_audio"\n'
|
|
809
|
+
+ `#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio",NAME="audio",DEFAULT=YES,URI="${audioStreamUrl}"\n#EXTINF:`), 'utf8'),
|
|
810
|
+
}));
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
return {
|
|
814
|
+
language: s.language,
|
|
815
|
+
url: s.url,
|
|
816
|
+
variants,
|
|
817
|
+
};
|
|
818
|
+
});
|
|
819
|
+
return {
|
|
820
|
+
languages: languageStreams,
|
|
821
|
+
data: streamMetaData,
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Fetches Battle Royale v2 stats for one or multiple players
|
|
826
|
+
* @param user The id(s) or display name(s) of the user(s)
|
|
827
|
+
* @param startTime The timestamp in seconds to start fetching stats from, can be null/undefined for lifetime
|
|
828
|
+
* @param endTime The timestamp in seconds to stop fetching stats from, can be undefined for lifetime
|
|
829
|
+
* @param stats An array of stats keys. Required if you want to get the stats of multiple users at once (If not, ignore this)
|
|
830
|
+
* @throws {UserNotFoundError} The user wasn't found
|
|
831
|
+
* @throws {StatsPrivacyError} The user set their stats to private
|
|
832
|
+
* @throws {TypeError} You must provide an array of stats keys for multiple user lookup
|
|
833
|
+
* @throws {EpicgamesAPIError}
|
|
834
|
+
*/
|
|
835
|
+
async getBRStats(user, startTime, endTime, stats = []) {
|
|
836
|
+
const params = [];
|
|
837
|
+
if (startTime)
|
|
838
|
+
params.push(`startTime=${startTime}`);
|
|
839
|
+
if (endTime)
|
|
840
|
+
params.push(`endTime=${endTime}`);
|
|
841
|
+
const query = params[0] ? `?${params.join('&')}` : '';
|
|
842
|
+
if (typeof user === 'string') {
|
|
843
|
+
const resolvedUser = await this.user.fetch(user);
|
|
844
|
+
if (!resolvedUser)
|
|
845
|
+
throw new UserNotFoundError_1.default(user);
|
|
846
|
+
let statsResponse;
|
|
847
|
+
try {
|
|
848
|
+
statsResponse = await this.http.epicgamesRequest({
|
|
849
|
+
method: 'GET',
|
|
850
|
+
url: `${Endpoints_1.default.BR_STATS_V2}/account/${resolvedUser.id}${query}`,
|
|
851
|
+
}, enums_1.AuthSessionStoreKey.Fortnite);
|
|
852
|
+
}
|
|
853
|
+
catch (e) {
|
|
854
|
+
if (e instanceof EpicgamesAPIError_1.default) {
|
|
855
|
+
throw new StatsPrivacyError_1.default(user);
|
|
856
|
+
}
|
|
857
|
+
throw e;
|
|
858
|
+
}
|
|
859
|
+
return new Stats_1.default(this, statsResponse, resolvedUser);
|
|
860
|
+
}
|
|
861
|
+
if (!stats[0]) {
|
|
862
|
+
throw new TypeError('You need to provide an array of stats keys to fetch multiple user\'s stats');
|
|
863
|
+
}
|
|
864
|
+
const resolvedUsers = await this.user.fetchMultiple(user);
|
|
865
|
+
const idChunks = resolvedUsers
|
|
866
|
+
.map((u) => u.id)
|
|
867
|
+
.reduce((resArr, id, i) => {
|
|
868
|
+
const chunkIndex = Math.floor(i / 51);
|
|
869
|
+
// eslint-disable-next-line no-param-reassign
|
|
870
|
+
if (!resArr[chunkIndex])
|
|
871
|
+
resArr[chunkIndex] = [];
|
|
872
|
+
resArr[chunkIndex].push(id);
|
|
873
|
+
return resArr;
|
|
874
|
+
}, []);
|
|
875
|
+
const statsResponses = await Promise.all(idChunks.map((c) => this.http.epicgamesRequest({
|
|
876
|
+
method: 'POST',
|
|
877
|
+
url: `${Endpoints_1.default.BR_STATS_V2}/query${query}`,
|
|
878
|
+
headers: {
|
|
879
|
+
'Content-Type': 'application/json',
|
|
880
|
+
},
|
|
881
|
+
data: {
|
|
882
|
+
appId: 'fortnite',
|
|
883
|
+
owners: c,
|
|
884
|
+
stats,
|
|
885
|
+
},
|
|
886
|
+
}, enums_1.AuthSessionStoreKey.Fortnite)));
|
|
887
|
+
return statsResponses
|
|
888
|
+
.flat(1)
|
|
889
|
+
.map((r) => new Stats_1.default(this, r, resolvedUsers.find((u) => u.id === r.accountId)));
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Fetches the current Battle Royale news
|
|
893
|
+
* @param language The language of the news
|
|
894
|
+
* @param customPayload Extra data to send in the request body for a personalized news response (battle pass level, country, etc)
|
|
895
|
+
* @throws {EpicgamesAPIError}
|
|
896
|
+
*/
|
|
897
|
+
async getBRNews(language = Enums_1.default.Language.ENGLISH, customPayload) {
|
|
898
|
+
const news = await this.http.epicgamesRequest({
|
|
899
|
+
method: 'POST',
|
|
900
|
+
url: Endpoints_1.default.BR_NEWS,
|
|
901
|
+
headers: {
|
|
902
|
+
'Content-Type': 'application/json',
|
|
903
|
+
'Accept-Language': language,
|
|
904
|
+
},
|
|
905
|
+
data: {
|
|
906
|
+
platform: 'Windows',
|
|
907
|
+
language,
|
|
908
|
+
country: 'US',
|
|
909
|
+
serverRegion: 'NA',
|
|
910
|
+
subscription: false,
|
|
911
|
+
battlepass: false,
|
|
912
|
+
battlepassLevel: 1,
|
|
913
|
+
...customPayload,
|
|
914
|
+
},
|
|
915
|
+
}, enums_1.AuthSessionStoreKey.Fortnite);
|
|
916
|
+
return news.contentItems.map((i) => new NewsMessage_1.default(this, i));
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* Fetches data for a Support-A-Creator code
|
|
920
|
+
* @param code The Support-A-Creator code (slug)
|
|
921
|
+
* @throws {CreatorCodeNotFoundError} The Support-A-Creator code wasnt found
|
|
922
|
+
* @throws {EpicgamesAPIError}
|
|
923
|
+
*/
|
|
924
|
+
async getCreatorCode(code) {
|
|
925
|
+
let codeResponse;
|
|
926
|
+
try {
|
|
927
|
+
codeResponse = await this.http.epicgamesRequest({
|
|
928
|
+
method: 'GET',
|
|
929
|
+
url: `${Endpoints_1.default.BR_SAC}/${encodeURIComponent(code)}`,
|
|
930
|
+
}, enums_1.AuthSessionStoreKey.FortniteClientCredentials);
|
|
931
|
+
}
|
|
932
|
+
catch (e) {
|
|
933
|
+
if (e instanceof EpicgamesAPIError_1.default && e.code === 'errors.com.epicgames.ecommerce.affiliate.not_found') {
|
|
934
|
+
throw new CreatorCodeNotFoundError_1.default(code);
|
|
935
|
+
}
|
|
936
|
+
throw e;
|
|
937
|
+
}
|
|
938
|
+
const owner = await this.user.fetch(codeResponse.id);
|
|
939
|
+
return new CreatorCode_1.default(this, { ...codeResponse, owner });
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* Fetches the current Fortnite Battle Royale radio stations
|
|
943
|
+
* @throws {EpicgamesAPIError}
|
|
944
|
+
*/
|
|
945
|
+
async getRadioStations() {
|
|
946
|
+
const fortniteContent = await this.http.epicgamesRequest({
|
|
947
|
+
method: 'GET',
|
|
948
|
+
url: Endpoints_1.default.BR_NEWS,
|
|
949
|
+
});
|
|
950
|
+
const radioStations = fortniteContent.radioStations.radioStationList.stations;
|
|
951
|
+
return radioStations.map((s) => new RadioStation_1.default(this, s));
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Fetches the current Battle Royale event flags
|
|
955
|
+
* @param language The language
|
|
956
|
+
* @throws {EpicgamesAPIError}
|
|
957
|
+
*/
|
|
958
|
+
async getBREventFlags(language = 'en') {
|
|
959
|
+
const eventFlags = await this.http.epicgamesRequest({
|
|
960
|
+
method: 'GET',
|
|
961
|
+
url: `${Endpoints_1.default.BR_EVENT_FLAGS}?lang=${language}`,
|
|
962
|
+
}, enums_1.AuthSessionStoreKey.Fortnite);
|
|
963
|
+
return eventFlags;
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* Fetches the Battle Royale account level for one or multiple users
|
|
967
|
+
* @param user The id(s) and/or display name(s) of the user(s) to fetch the account level for
|
|
968
|
+
* @param seasonNumber The season number (eg. 16, 17, 18)
|
|
969
|
+
* @throws {UserNotFoundError} The user wasn't found
|
|
970
|
+
* @throws {StatsPrivacyError} The user set their stats to private
|
|
971
|
+
* @throws {EpicgamesAPIError}
|
|
972
|
+
*/
|
|
973
|
+
async getBRAccountLevel(user, seasonNumber) {
|
|
974
|
+
const users = Array.isArray(user) ? user : [user];
|
|
975
|
+
const accountLevels = await this.getBRStats(users, undefined, undefined, [`s${seasonNumber}_social_bp_level`]);
|
|
976
|
+
return accountLevels.map((al) => ({
|
|
977
|
+
user: al.user,
|
|
978
|
+
level: al.levelData[`s${seasonNumber}`] || { level: 0, progress: 0 },
|
|
979
|
+
}));
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* Fetches the storefront keychain
|
|
983
|
+
* @throws {EpicgamesAPIError}
|
|
984
|
+
*/
|
|
985
|
+
async getStorefrontKeychain() {
|
|
986
|
+
const keychain = await this.http.epicgamesRequest({
|
|
987
|
+
method: 'GET',
|
|
988
|
+
url: Endpoints_1.default.BR_STORE_KEYCHAIN,
|
|
989
|
+
}, enums_1.AuthSessionStoreKey.Fortnite);
|
|
990
|
+
return keychain;
|
|
991
|
+
}
|
|
992
|
+
/* -------------------------------------------------------------------------- */
|
|
993
|
+
/* FORTNITE CREATIVE */
|
|
994
|
+
/* -------------------------------------------------------------------------- */
|
|
995
|
+
/**
|
|
996
|
+
* Fetches a creative island by its code
|
|
997
|
+
* @param code The island code
|
|
998
|
+
* @throws {CreativeIslandNotFoundError} A creative island with the provided code does not exist
|
|
999
|
+
* @throws {EpicgamesAPIError}
|
|
1000
|
+
*/
|
|
1001
|
+
async getCreativeIsland(code) {
|
|
1002
|
+
let islandInfo;
|
|
1003
|
+
try {
|
|
1004
|
+
islandInfo = await this.http.epicgamesRequest({
|
|
1005
|
+
method: 'GET',
|
|
1006
|
+
url: `${Endpoints_1.default.CREATIVE_ISLAND_LOOKUP}/${code}`,
|
|
1007
|
+
}, enums_1.AuthSessionStoreKey.Fortnite);
|
|
1008
|
+
}
|
|
1009
|
+
catch (e) {
|
|
1010
|
+
if (e instanceof EpicgamesAPIError_1.default && e.code === 'errors.com.epicgames.links.no_active_version') {
|
|
1011
|
+
throw new CreativeIslandNotFoundError_1.default(code);
|
|
1012
|
+
}
|
|
1013
|
+
throw e;
|
|
1014
|
+
}
|
|
1015
|
+
return islandInfo;
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* Fetches the creative discovery surface
|
|
1019
|
+
* @param gameVersion The current game version (MAJOR.MINOR)
|
|
1020
|
+
* @throws {EpicgamesAPIError}
|
|
1021
|
+
*/
|
|
1022
|
+
// kept for backwards compatibility
|
|
1023
|
+
// eslint-disable-next-line @typescript-eslint/default-param-last
|
|
1024
|
+
async getCreativeDiscoveryPanels(gameVersion = '19.40', region) {
|
|
1025
|
+
const creativeDiscovery = await this.http.epicgamesRequest({
|
|
1026
|
+
method: 'POST',
|
|
1027
|
+
url: `${Endpoints_1.default.CREATIVE_DISCOVERY}/${this.user.self.id}?appId=Fortnite`,
|
|
1028
|
+
headers: {
|
|
1029
|
+
'Content-Type': 'application/json',
|
|
1030
|
+
'User-Agent': `Fortnite/++Fortnite+Release-${gameVersion}-CL-00000000 Windows/10.0.19044.1.768.64bit`,
|
|
1031
|
+
},
|
|
1032
|
+
data: {
|
|
1033
|
+
surfaceName: 'CreativeDiscoverySurface_Frontend',
|
|
1034
|
+
revision: -1,
|
|
1035
|
+
partyMemberIds: [this.user.self.id],
|
|
1036
|
+
matchmakingRegion: region,
|
|
1037
|
+
},
|
|
1038
|
+
}, enums_1.AuthSessionStoreKey.Fortnite);
|
|
1039
|
+
return creativeDiscovery;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
exports.default = Client;
|
|
1043
|
+
//# sourceMappingURL=Client.js.map
|