Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
tnfAngel authored Nov 3, 2024
2 parents a4eec6e + dabeae9 commit 0e0f61a
Show file tree
Hide file tree
Showing 40 changed files with 2,755 additions and 2,150 deletions.
4,474 changes: 2,437 additions & 2,037 deletions package-lock.json

Large diffs are not rendered by default.

33 changes: 18 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"name": "fnbr",
"version": "4.0.0",
"name": "@fnlb-project/fnbr",
"version": "4.0.1",
"description": "A library to interact with Epic Games' Fortnite HTTP and XMPP services",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "node generateExports.js && npx tsc",
"lint": "eslint src/**/*.ts resources/**/*.ts enums/**/*.ts",
Expand Down Expand Up @@ -37,27 +40,27 @@
"promises"
],
"devDependencies": {
"@types/jest": "^29.5.0",
"@types/node": "^18.15.11",
"@typescript-eslint/eslint-plugin": "^5.60.1",
"@typescript-eslint/parser": "^5.60.1",
"eslint": "^8.31.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.9",
"@typescript-eslint/eslint-plugin": "^7.14.1",
"@typescript-eslint/parser": "^7.14.1",
"eslint": "^8.56.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-plugin-import": "^2.27.5",
"jest": "^29.5.0",
"typescript": "^5.0.4"
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-plugin-import": "^2.29.1",
"jest": "^29.7.0",
"typescript": "^5.5.2"
},
"dependencies": {
"@discordjs/collection": "^2.0.0",
"@sapphire/async-queue": "^1.5.0",
"@sapphire/async-queue": "^1.5.3",
"@stomp/stompjs": "^7.0.0",
"axios": "^1.3.5",
"axios": "^1.7.6",
"stanza": "^12.18.0",
"tslib": "^2.5.0",
"tslib": "^2.7.0",
"ws": "^8.18.0"
},
"optionalDependencies": {
"fsevents": "^2.3.2"
"fsevents": "^2.3.3"
}
}
6 changes: 3 additions & 3 deletions resources/PowerLevelCurves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function mapCurveTables<T extends { [k: keyof any]: { Keys: CurveKey[] } }>(stru
}

export default Object.freeze({
homebaseRating: Object.freeze(new CurveTable(HomebaseRatingMapping[0].ExportValue.UIMonsterRating.Keys)),
baseItemRating: mapCurveTables(BaseItemRating[0].ExportValue),
survivorItemRating: mapCurveTables(SurvivorItemRating[0].ExportValue),
homebaseRating: Object.freeze(new CurveTable(HomebaseRatingMapping[0]!.ExportValue.UIMonsterRating.Keys)),
baseItemRating: mapCurveTables(BaseItemRating[0]!.ExportValue),
survivorItemRating: mapCurveTables(SurvivorItemRating[0]!.ExportValue),
});
9 changes: 9 additions & 0 deletions resources/structs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,15 @@ export interface EOSAuthData extends AuthData {
scope: string;
}

export interface EOSAuthData extends AuthData {
refresh_expires: number;
refresh_expires_at: string;
refresh_token: string;
application_id: string;
merged_accounts: string[];
scope: string;
}

export interface AuthSessionStore<K, V> extends Collection<K, V> {
get(key: AuthSessionStoreKey.Fortnite): FortniteAuthSession | undefined;
get(key: AuthSessionStoreKey.Launcher): LauncherAuthSession | undefined;
Expand Down
16 changes: 8 additions & 8 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ class Client extends EventEmitter {
* Timeouts set by {@link Client#setTimeout} that are still active
*/
// eslint-disable-next-line no-undef
private timeouts: Set<NodeJS.Timeout>;
private timeouts: Set<any>;

/**
* Intervals set by {@link Client#setInterval} that are still active
*/
// eslint-disable-next-line no-undef
private intervals: Set<NodeJS.Timeout>;
private intervals: Set<any>;

/**
* All client configuration options
Expand Down Expand Up @@ -228,15 +228,15 @@ class Client extends EventEmitter {
}

// Events
public on<U extends keyof ClientEvents>(event: U, listener: ClientEvents[U]): this {
public override on<U extends keyof ClientEvents>(event: U, listener: ClientEvents[U]): this {
return super.on(event, listener);
}

public once<U extends keyof ClientEvents>(event: U, listener: ClientEvents[U]): this {
public override once<U extends keyof ClientEvents>(event: U, listener: ClientEvents[U]): this {
return super.once(event, listener);
}

public emit<U extends keyof ClientEvents>(event: U, ...args: Parameters<ClientEvents[U]>): boolean {
public override emit<U extends keyof ClientEvents>(event: U, ...args: Parameters<ClientEvents[U]>): boolean {
return super.emit(event, ...args);
}

Expand Down Expand Up @@ -473,7 +473,7 @@ class Client extends EventEmitter {
): Promise<Parameters<ClientEvents[U]>> {
return new Promise<any>((res, rej) => {
// eslint-disable-next-line no-undef
let rejectionTimeout: NodeJS.Timeout;
let rejectionTimeout: any;

const handler = (...data: any) => {
if (!filter || filter(...data)) {
Expand Down Expand Up @@ -514,7 +514,7 @@ class Client extends EventEmitter {
* @param timeout Timeout to cancel
*/
// eslint-disable-next-line no-undef
public clearTimeout(timeout: NodeJS.Timeout) {
public clearTimeout(timeout: any) {
clearTimeout(timeout);
this.timeouts.delete(timeout);
}
Expand All @@ -537,7 +537,7 @@ class Client extends EventEmitter {
* @param interval Interval to cancel
*/
// eslint-disable-next-line no-undef
public clearInterval(interval: NodeJS.Timeout) {
public clearInterval(interval: any) {
clearInterval(interval);
this.intervals.delete(interval);
}
Expand Down
2 changes: 1 addition & 1 deletion src/auth/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class Auth extends Base {
* Kills all active auth sessions
*/
public async revokeAllTokens() {
await Promise.all([...this.sessions.filter((s, k) => k !== AuthSessionStoreKey.Launcher).values()].map((s) => s.revoke()));
await Promise.all([...this.sessions.filter((_s, k) => k !== AuthSessionStoreKey.Launcher).values()].map((s) => s.revoke()));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/auth/FortniteAuthSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class FortniteAuthSession extends AuthSession<AuthSessionType.Fortnite> {
/**
* The refresh timeout
*/
public refreshTimeout?: NodeJS.Timeout;
public refreshTimeout?: any;
constructor(client: Client, data: FortniteAuthData, clientSecret: string) {
super(client, data, clientSecret, AuthSessionType.Fortnite);

Expand Down
2 changes: 1 addition & 1 deletion src/auth/FortniteClientCredentialsAuthSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class FortniteClientCredentialsAuthSession extends AuthSession<AuthSessionType.F
public isInternalClient: boolean;
public productId: string;
public applicationId: string;
public refreshTimeout?: NodeJS.Timeout;
public refreshTimeout?: any;
constructor(client: Client, data: FortniteClientCredentialsAuthData, clientSecret: string) {
super(client, data, clientSecret, AuthSessionType.FortniteClientCredentials);

Expand Down
2 changes: 1 addition & 1 deletion src/auth/LauncherAuthSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class LauncherAuthSession extends AuthSession<AuthSessionType.Launcher> {
public scope: string[];
public refreshToken: string;
public refreshTokenExpiresAt: Date;
public refreshTimeout?: NodeJS.Timeout;
public refreshTimeout?: any;
constructor(client: Client, data: LauncherAuthData, clientSecret: string) {
super(client, data, clientSecret, AuthSessionType.Launcher);

Expand Down
2 changes: 1 addition & 1 deletion src/exceptions/SendMessageError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SendMessageError extends Error {
/**
* The message related to this error
*/
public message: string;
public override message: string;

/**
* The message's type
Expand Down
4 changes: 0 additions & 4 deletions src/managers/ChatManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Endpoints from '../../resources/Endpoints';
import { AuthSessionStoreKey } from '../../resources/enums';
import Base from '../Base';
import UserNotFoundError from '../exceptions/UserNotFoundError';
import EpicgamesAPIError from '../exceptions/EpicgamesAPIError';
import type { ChatMessagePayload } from '../../resources/structs';

// private scope
Expand All @@ -25,8 +24,6 @@ class ChatManager extends Base {
* @param user the account id or displayname
* @param message the message object
* @returns the message id
* @throws {UserNotFoundError} When the specified user was not found
* @throws {EpicgamesAPIError} When the api request failed
*/
public async whisperUser(user: string, message: ChatMessagePayload) {
const accountId = await this.client.user.resolveId(user);
Expand Down Expand Up @@ -58,7 +55,6 @@ class ChatManager extends Base {
* @param message the message object
* @param allowedRecipients the account ids, that should receive the message
* @returns the message id
* @throws {EpicgamesAPIError} When the api request failed
*/
public async sendMessageInConversation(conversationId: string, message: ChatMessagePayload, allowedRecipients: string[]) {
const correlationId = generateCustomCorrelationId();
Expand Down
3 changes: 0 additions & 3 deletions src/stomp/EOSConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ class EOSConnect extends Base {

/**
* connect to the eos connect stomp server
* @throws {AuthenticationMissingError} When there is no eos auth to use for stomp auth
* @throws {StompConnectionError} When the connection failed for any reason
* @throws {Error} When there was an error with the underlying websocket
*/
public async connect() {
if (!this.client.auth.sessions.has(AuthSessionStoreKey.FortniteEOS)) {
Expand Down
6 changes: 3 additions & 3 deletions src/structures/EventTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ class EventTokens extends Base {
season = 'S9';
}

const divisionNumber = parseInt(division.replace('Division', ''), 10);
const divisionNumber = parseInt(division!.replace('Division', ''), 10);

if (!this.arenaDivisionData[season.toLowerCase()] || this.arenaDivisionData[season.toLowerCase()] < divisionNumber) {
this.arenaDivisionData[season.toLowerCase()] = divisionNumber;
if (!this.arenaDivisionData[season!.toLowerCase()] || this.arenaDivisionData[season!.toLowerCase()]! < divisionNumber) {
this.arenaDivisionData[season!.toLowerCase()] = divisionNumber;
}
} break;
case 'GroupIdentity':
Expand Down
2 changes: 1 addition & 1 deletion src/structures/Image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Image extends Base {
return res;
}

public toString() {
public override toString() {
return this.url;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/structures/Stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Stats extends Base {
: this.getPlaylistStatsType(playlistId);

if (playlistType !== 'other') {
const [parsedKey, parsedValue] = parseStatKey(statKey, data.stats[key]);
const [parsedKey, parsedValue] = parseStatKey(statKey, data.stats[key]!);

const inputTypePlaylistStats = this.stats[inputType][playlistType];
const inputTypeAllStats = this.stats[inputType].overall;
Expand Down Expand Up @@ -105,9 +105,9 @@ class Stats extends Base {
}
}
} else if (/^s\d\d?_social_bp_level$/.test(key)) {
this.levelData[key.split('_')[0]] = {
level: Math.round(data.stats[key] / 100),
progress: data.stats[key] % 100,
this.levelData[key.split('_')[0]!] = {
level: Math.round(data.stats[key]! / 100),
progress: data.stats[key]! % 100,
};
}
}
Expand Down
17 changes: 15 additions & 2 deletions src/structures/friend/BaseFriendMessage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import BaseMessage from '../BaseMessage';
import type ClientUser from '../user/ClientUser';
import type Friend from './Friend';
import type Client from '../../Client';
import type { MessageData } from '../../../resources/structs';

/**
* Represents a friend whisper message
Expand All @@ -9,12 +11,23 @@ class BaseFriendMessage extends BaseMessage {
/**
* The message's content
*/
public content!: string;
public override content: string;

/**
* The message's author
*/
public author!: Friend | ClientUser;
public override author: Friend | ClientUser;

/**
* @param client The main client
* @param data The message's data
*/
constructor(client: Client, data: MessageData & { author: Friend | ClientUser; }) {
super(client, data);

this.content = data.content;
this.author = data.author;
}

/**
* Replies to this whisper message
Expand Down
16 changes: 14 additions & 2 deletions src/structures/friend/ReceivedFriendMessage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import BaseFriendMessage from './BaseFriendMessage';
import type Friend from './Friend';
import type Client from '../../Client';
import type { MessageData } from '../../../resources/structs';

/**
* Represents a received friend whisper message
Expand All @@ -8,14 +10,24 @@ class ReceivedFriendMessage extends BaseFriendMessage {
/**
* The message's author
*/
public author!: Friend;
public override author: Friend;

/**
* @param client The main client
* @param data The message's data
*/
constructor(client: Client, data: MessageData & { author: Friend; }) {
super(client, data);

this.author = data.author;
}

/**
* Replies to this whisper message
* @param content The message that will be sent
* @throws {FriendNotFoundError} The user is not friends with the client
*/
public reply(content: string) {
public override reply(content: string) {
return this.client.friend.sendMessage(this.author.id, content);
}
}
Expand Down
14 changes: 13 additions & 1 deletion src/structures/friend/SentFriendMessage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import BaseFriendMessage from './BaseFriendMessage';
import type ClientUser from '../user/ClientUser';
import type Client from '../../Client';
import type { MessageData } from '../../../resources/structs';

/**
* Represents a sent friend whisper message
Expand All @@ -8,7 +10,17 @@ class SentFriendMessage extends BaseFriendMessage {
/**
* The message's author
*/
public author!: ClientUser;
public override author: ClientUser;

/**
* @param client The main client
* @param data The message's data
*/
constructor(client: Client, data: MessageData & { author: ClientUser; }) {
super(client, data);

this.author = data.author;
}
}

export default SentFriendMessage;
4 changes: 2 additions & 2 deletions src/structures/party/ClientParty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ClientParty extends Party {
/**
* The party's meta
*/
public meta: ClientPartyMeta;
public override meta: ClientPartyMeta;

/**
* The hidden member ids
Expand Down Expand Up @@ -145,7 +145,7 @@ class ClientParty extends Party {
}, AuthSessionStoreKey.Fortnite);
} catch (e) {
if (e instanceof EpicgamesAPIError && e.code === 'errors.com.epicgames.social.party.stale_revision') {
this.revision = parseInt(e.messageVars[1], 10);
this.revision = parseInt(e.messageVars[1]!, 10);
this.patchQueue.shift();
return this.sendPatch(updated);
}
Expand Down
Loading

0 comments on commit 0e0f61a

Please sign in to comment.