start of Launcher API changes, should make it easier to understand what is being returned, and leaving V1 usable
This commit is contained in:
parent
18158bb4dc
commit
bca5d8236e
@ -16,7 +16,7 @@ export class LauncherCallbacks {
|
||||
@inject("LauncherController") protected launcherController: LauncherController,
|
||||
@inject("SaveServer") protected saveServer: SaveServer,
|
||||
@inject("Watermark") protected watermark: Watermark,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
public connect(): string {
|
||||
return this.httpResponse.noBody(this.launcherController.connect());
|
||||
|
98
project/src/callbacks/Launcherv2Callbacks.ts
Normal file
98
project/src/callbacks/Launcherv2Callbacks.ts
Normal file
@ -0,0 +1,98 @@
|
||||
import { LauncherV2Controller } from "@spt/controllers/LauncherV2Controller";
|
||||
import { ProfileController } from "@spt/controllers/ProfileController";
|
||||
import { IChangeRequestData } from "@spt/models/eft/launcher/IChangeRequestData";
|
||||
import { ILoginRequestData } from "@spt/models/eft/launcher/ILoginRequestData";
|
||||
import { IRegisterData } from "@spt/models/eft/launcher/IRegisterData";
|
||||
import { ILauncherV2LoginResponse } from "@spt/models/spt/launcher/ILauncherV2LoginResponse";
|
||||
import { ILauncherV2ModsResponse } from "@spt/models/spt/launcher/ILauncherV2ModsResponse";
|
||||
import { ILauncherV2PasswordChangeResponse } from "@spt/models/spt/launcher/ILauncherV2PasswordChangeResponse";
|
||||
import { ILauncherV2PingResponse } from "@spt/models/spt/launcher/ILauncherV2PingResponse";
|
||||
import { ILauncherV2ProfilesResponse } from "@spt/models/spt/launcher/ILauncherV2ProfilesResponse";
|
||||
import { ILauncherV2RegisterResponse } from "@spt/models/spt/launcher/ILauncherV2RegisterResponse";
|
||||
import { ILauncherV2RemoveResponse } from "@spt/models/spt/launcher/ILauncherV2RemoveResponse";
|
||||
import { ILauncherV2TypesResponse } from "@spt/models/spt/launcher/ILauncherV2TypesResponse";
|
||||
import { ILauncherV2VersionResponse } from "@spt/models/spt/launcher/ILauncherV2VersionResponse";
|
||||
import { SaveServer } from "@spt/servers/SaveServer";
|
||||
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
|
||||
import { Watermark } from "@spt/utils/Watermark";
|
||||
import { inject, injectable } from "tsyringe";
|
||||
|
||||
@injectable()
|
||||
export class LauncherV2Callbacks {
|
||||
|
||||
constructor(
|
||||
@inject("HttpResponseUtil") protected httpResponse: HttpResponseUtil,
|
||||
@inject("LauncherV2Controller") protected launcherV2Controller: LauncherV2Controller,
|
||||
@inject("ProfileController") protected profileController: ProfileController,
|
||||
@inject("SaveServer") protected saveServer: SaveServer,
|
||||
@inject("Watermark") protected watermark: Watermark,
|
||||
) { }
|
||||
|
||||
public ping(): ILauncherV2PingResponse {
|
||||
return this.httpResponse.noBody({
|
||||
response: this.launcherV2Controller.ping(),
|
||||
});
|
||||
}
|
||||
|
||||
public types(): ILauncherV2TypesResponse {
|
||||
return this.httpResponse.noBody({
|
||||
response: this.launcherV2Controller.types(),
|
||||
})
|
||||
}
|
||||
|
||||
public login(info: ILoginRequestData): ILauncherV2LoginResponse {
|
||||
return this.httpResponse.noBody({
|
||||
response: this.launcherV2Controller.login(info),
|
||||
})
|
||||
}
|
||||
|
||||
public register(info: IRegisterData): ILauncherV2RegisterResponse {
|
||||
return this.httpResponse.noBody({
|
||||
response: this.launcherV2Controller.register(info),
|
||||
profiles: this.profileController.getMiniProfiles(),
|
||||
})
|
||||
}
|
||||
|
||||
public passwordChange(info: IChangeRequestData): ILauncherV2PasswordChangeResponse {
|
||||
return this.httpResponse.noBody({
|
||||
response: this.launcherV2Controller.passwordChange(info),
|
||||
profiles: this.profileController.getMiniProfiles(),
|
||||
})
|
||||
}
|
||||
|
||||
public remove(info: ILoginRequestData): ILauncherV2RemoveResponse {
|
||||
return this.httpResponse.noBody({
|
||||
response: this.launcherV2Controller.remove(info),
|
||||
profiles: this.profileController.getMiniProfiles(),
|
||||
})
|
||||
}
|
||||
|
||||
public compatibleVersion(): ILauncherV2VersionResponse {
|
||||
return this.httpResponse.noBody({
|
||||
response: {
|
||||
sptVersion: this.launcherV2Controller.sptVersion(),
|
||||
eftVersion: this.launcherV2Controller.eftVersion(),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
public mods(): ILauncherV2ModsResponse {
|
||||
return this.httpResponse.noBody({
|
||||
response: this.launcherV2Controller.loadedMods(),
|
||||
})
|
||||
}
|
||||
|
||||
public profiles(): ILauncherV2ProfilesResponse {
|
||||
return this.httpResponse.noBody({
|
||||
response: this.profileController.getMiniProfiles(),
|
||||
})
|
||||
}
|
||||
|
||||
public profile(): Error {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
public profileMods(): Error {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
}
|
@ -80,7 +80,7 @@ export class LauncherController {
|
||||
public login(info: ILoginRequestData): string {
|
||||
for (const sessionID in this.saveServer.getProfiles()) {
|
||||
const account = this.saveServer.getProfile(sessionID).info;
|
||||
if (info.username === account.username) {
|
||||
if (info.username === account.username && info.password === account.password) {
|
||||
return sessionID;
|
||||
}
|
||||
}
|
||||
|
248
project/src/controllers/LauncherV2Controller.ts
Normal file
248
project/src/controllers/LauncherV2Controller.ts
Normal file
@ -0,0 +1,248 @@
|
||||
import { PreSptModLoader } from "@spt/loaders/PreSptModLoader";
|
||||
import { IChangeRequestData } from "@spt/models/eft/launcher/IChangeRequestData";
|
||||
import { ILoginRequestData } from "@spt/models/eft/launcher/ILoginRequestData";
|
||||
import { IRegisterData } from "@spt/models/eft/launcher/IRegisterData";
|
||||
import { Info } from "@spt/models/eft/profile/ISptProfile";
|
||||
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
|
||||
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
||||
import { IPackageJsonData } from "@spt/models/spt/mod/IPackageJsonData";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { SaveServer } from "@spt/servers/SaveServer";
|
||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||
import { HashUtil } from "@spt/utils/HashUtil";
|
||||
import { RandomUtil } from "@spt/utils/RandomUtil";
|
||||
import { TimeUtil } from "@spt/utils/TimeUtil";
|
||||
import { Watermark } from "@spt/utils/Watermark";
|
||||
import { inject, injectable } from "tsyringe";
|
||||
|
||||
@injectable()
|
||||
export class LauncherV2Controller {
|
||||
protected coreConfig: ICoreConfig
|
||||
|
||||
constructor(
|
||||
@inject("PrimaryLogger") protected logger: ILogger,
|
||||
@inject("DatabaseService") protected databaseService: DatabaseService,
|
||||
@inject("ConfigServer") protected configServer: ConfigServer,
|
||||
@inject("LocalisationService") protected localisationService: LocalisationService,
|
||||
@inject("SaveServer") protected saveServer: SaveServer,
|
||||
@inject("HashUtil") protected hashUtil: HashUtil,
|
||||
@inject("TimeUtil") protected timeUtil: TimeUtil,
|
||||
@inject("RandomUtil") protected randomUtil: RandomUtil,
|
||||
@inject("Watermark") protected watermark: Watermark,
|
||||
@inject("PreSptModLoader") protected preSptModLoader: PreSptModLoader,
|
||||
) {
|
||||
this.coreConfig = this.configServer.getConfig(ConfigTypes.CORE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a simple string of pong!
|
||||
* @returns "pong!"
|
||||
*/
|
||||
public ping(): string {
|
||||
return "pong!";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all available profile types and descriptions for creation.
|
||||
* - This is also localised.
|
||||
*
|
||||
* @returns Record of Profile types and Descriptions
|
||||
*/
|
||||
public types(): Record<string, string> {
|
||||
|
||||
const profileRecord: Record<string, string> = {};
|
||||
|
||||
// Get all possible profile types, excluding blacklisted ones
|
||||
const profileKeys = Object.keys(this.databaseService.getProfiles()).filter(
|
||||
(key) => !this.coreConfig.features.createNewProfileTypesBlacklist.includes(key),
|
||||
);
|
||||
|
||||
// Add them to record with description
|
||||
for (const profileKey in profileKeys) {
|
||||
profileRecord[profileKey] = this.getProfileDescription(profileKey);
|
||||
}
|
||||
|
||||
return profileRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string that represents the Profile types description.
|
||||
* - This is also localised.
|
||||
*
|
||||
* @param key Profile Type Name: eg "standard"
|
||||
* @returns Profile Type Description
|
||||
*/
|
||||
protected getProfileDescription(key: string): string {
|
||||
const dbProfiles = this.databaseService.getProfiles();
|
||||
const descKey = dbProfiles[key]?.descriptionLocaleKey;
|
||||
if (!descKey) {
|
||||
this.logger.warning(this.localisationService.getText("launcher-missing_property", key));
|
||||
return "";
|
||||
}
|
||||
|
||||
return this.localisationService.getText(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if login details were correct.
|
||||
*
|
||||
* @param info ILoginRequestData
|
||||
* @returns If login was successful or not
|
||||
*/
|
||||
public login(info: ILoginRequestData): boolean {
|
||||
const sessionID = this.getSessionID(info);
|
||||
|
||||
if (!sessionID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new profile.
|
||||
*
|
||||
* @param info IRegisterData
|
||||
* @returns If register was successful or not
|
||||
*/
|
||||
public register(info: IRegisterData): boolean {
|
||||
for (const sessionID in this.saveServer.getProfiles()) {
|
||||
if (info.username === this.saveServer.getProfile(sessionID).info.username) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
this.createAccount(info);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a password change.
|
||||
*
|
||||
* @param info IChangeRequestData
|
||||
* @returns If change was successful or not
|
||||
*/
|
||||
public passwordChange(info: IChangeRequestData): boolean {
|
||||
const sessionID = this.getSessionID(info);
|
||||
|
||||
if (!sessionID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.saveServer.getProfile(sessionID).info.password = info.change;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove profile from server.
|
||||
*
|
||||
* @param info ILoginRequestData
|
||||
* @returns If removal was successful or not
|
||||
*/
|
||||
public remove(info: ILoginRequestData): boolean {
|
||||
const sessionID = this.getSessionID(info);
|
||||
|
||||
if (!sessionID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.saveServer.removeProfile(sessionID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Servers SPT Version.
|
||||
*
|
||||
* @returns "3.10.0"
|
||||
*/
|
||||
public sptVersion(): string {
|
||||
return this.watermark.getVersionTag();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the compatible EFT Version.
|
||||
*
|
||||
* @returns "0.14.9.31124"
|
||||
*/
|
||||
public eftVersion(): string {
|
||||
return this.coreConfig.compatibleTarkovVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Servers loaded mods.
|
||||
*
|
||||
* @returns Record of Mod names to Mod Package Json Details
|
||||
*/
|
||||
public loadedMods(): Record<string, IPackageJsonData> {
|
||||
return this.preSptModLoader.getImportedModDetails();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the account from provided details.
|
||||
*
|
||||
* @param info IRegisterData
|
||||
* @returns ProfileID of new account
|
||||
*/
|
||||
protected createAccount(info: IRegisterData): string {
|
||||
const profileId = this.generateProfileId();
|
||||
const scavId = this.generateProfileId();
|
||||
const newProfileDetails: Info = {
|
||||
id: profileId,
|
||||
scavId: scavId,
|
||||
aid: this.hashUtil.generateAccountId(),
|
||||
username: info.username,
|
||||
password: info.password,
|
||||
wipe: true,
|
||||
edition: info.edition,
|
||||
};
|
||||
this.saveServer.createProfile(newProfileDetails);
|
||||
|
||||
this.saveServer.loadProfile(profileId);
|
||||
this.saveServer.saveProfile(profileId);
|
||||
|
||||
return profileId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new ProfileID to use.
|
||||
*
|
||||
* @returns ProfileID generated
|
||||
*/
|
||||
protected generateProfileId(): string {
|
||||
const timestamp = this.timeUtil.getTimestamp();
|
||||
|
||||
return this.formatID(timestamp, timestamp * this.randomUtil.getInt(1, 1000000));
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats ID by lower-casing.
|
||||
*
|
||||
* @param timeStamp number
|
||||
* @param counter number
|
||||
* @returns Formatted ID
|
||||
*/
|
||||
protected formatID(timeStamp: number, counter: number): string {
|
||||
const timeStampStr = timeStamp.toString(16).padStart(8, "0");
|
||||
const counterStr = counter.toString(16).padStart(16, "0");
|
||||
|
||||
return timeStampStr.toLowerCase() + counterStr.toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets ProfileID from profile.
|
||||
*
|
||||
* @param info ILoginRequestData
|
||||
* @returns ProfileID if successful otherwise empty string
|
||||
*/
|
||||
protected getSessionID(info: ILoginRequestData): string {
|
||||
for (const sessionID in this.saveServer.getProfiles()) {
|
||||
const account = this.saveServer.getProfile(sessionID).info;
|
||||
if (info.username === account.username && info.password === account.password) {
|
||||
return sessionID;
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
@ -55,7 +55,7 @@ export class ProfileController {
|
||||
@inject("DialogueHelper") protected dialogueHelper: DialogueHelper,
|
||||
@inject("QuestHelper") protected questHelper: QuestHelper,
|
||||
@inject("ProfileHelper") protected profileHelper: ProfileHelper,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Handle /launcher/profiles
|
||||
@ -77,38 +77,22 @@ export class ProfileController {
|
||||
|
||||
const pmc = profile.characters.pmc;
|
||||
const maxlvl = this.profileHelper.getMaxLevel();
|
||||
|
||||
// Player hasn't completed profile creation process, send defaults
|
||||
if (!pmc?.Info?.Level) {
|
||||
return {
|
||||
username: profile.info?.username ?? "",
|
||||
nickname: "unknown",
|
||||
side: "unknown",
|
||||
currlvl: 0,
|
||||
currexp: 0,
|
||||
prevexp: 0,
|
||||
nextlvl: 0,
|
||||
maxlvl: maxlvl,
|
||||
edition: profile.info?.edition ?? "",
|
||||
profileId: profile.info?.id ?? "",
|
||||
sptData: this.profileHelper.getDefaultSptDataObject(),
|
||||
};
|
||||
}
|
||||
|
||||
const currlvl = pmc.Info.Level;
|
||||
const currlvl = pmc?.Info?.Level ?? 0;
|
||||
const nextlvl = this.profileHelper.getExperience(currlvl + 1);
|
||||
|
||||
return {
|
||||
username: profile.info.username,
|
||||
nickname: pmc.Info.Nickname,
|
||||
side: pmc.Info.Side,
|
||||
currlvl: pmc.Info.Level,
|
||||
currexp: pmc.Info.Experience ?? 0,
|
||||
username: profile.info?.username ?? "",
|
||||
nickname: pmc.Info?.Nickname ?? "unknown",
|
||||
hasPassword: (profile?.info?.password !== ""),
|
||||
side: pmc?.Info?.Side ?? "unknown",
|
||||
currlvl: pmc?.Info?.Level ?? 0,
|
||||
currexp: pmc?.Info?.Experience ?? 0,
|
||||
prevexp: currlvl === 0 ? 0 : this.profileHelper.getExperience(currlvl),
|
||||
nextlvl: nextlvl,
|
||||
maxlvl: maxlvl,
|
||||
edition: profile.info?.edition ?? "",
|
||||
profileId: profile.info?.id ?? "",
|
||||
sptData: profile.spt,
|
||||
edition: profile?.info?.edition ?? "",
|
||||
profileId: profile?.info?.id ?? "",
|
||||
sptData: profile?.spt ?? this.profileHelper.getDefaultSptDataObject(),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@ import { InsuranceCallbacks } from "@spt/callbacks/InsuranceCallbacks";
|
||||
import { InventoryCallbacks } from "@spt/callbacks/InventoryCallbacks";
|
||||
import { ItemEventCallbacks } from "@spt/callbacks/ItemEventCallbacks";
|
||||
import { LauncherCallbacks } from "@spt/callbacks/LauncherCallbacks";
|
||||
import { LauncherV2Callbacks } from "@spt/callbacks/Launcherv2Callbacks";
|
||||
import { LocationCallbacks } from "@spt/callbacks/LocationCallbacks";
|
||||
import { MatchCallbacks } from "@spt/callbacks/MatchCallbacks";
|
||||
import { ModCallbacks } from "@spt/callbacks/ModCallbacks";
|
||||
@ -46,6 +47,7 @@ import { InraidController } from "@spt/controllers/InraidController";
|
||||
import { InsuranceController } from "@spt/controllers/InsuranceController";
|
||||
import { InventoryController } from "@spt/controllers/InventoryController";
|
||||
import { LauncherController } from "@spt/controllers/LauncherController";
|
||||
import { LauncherV2Controller } from "@spt/controllers/LauncherV2Controller";
|
||||
import { LocationController } from "@spt/controllers/LocationController";
|
||||
import { MatchController } from "@spt/controllers/MatchController";
|
||||
import { NoteController } from "@spt/controllers/NoteController";
|
||||
@ -177,6 +179,7 @@ import { InraidStaticRouter } from "@spt/routers/static/InraidStaticRouter";
|
||||
import { InsuranceStaticRouter } from "@spt/routers/static/InsuranceStaticRouter";
|
||||
import { ItemEventStaticRouter } from "@spt/routers/static/ItemEventStaticRouter";
|
||||
import { LauncherStaticRouter } from "@spt/routers/static/LauncherStaticRouter";
|
||||
import { LauncherV2StaticRouter } from "@spt/routers/static/LauncherV2StaticRouter";
|
||||
import { LocationStaticRouter } from "@spt/routers/static/LocationStaticRouter";
|
||||
import { MatchStaticRouter } from "@spt/routers/static/MatchStaticRouter";
|
||||
import { NotifierStaticRouter } from "@spt/routers/static/NotifierStaticRouter";
|
||||
@ -350,6 +353,7 @@ export class Container {
|
||||
depContainer.registerType("StaticRoutes", "InsuranceStaticRouter");
|
||||
depContainer.registerType("StaticRoutes", "ItemEventStaticRouter");
|
||||
depContainer.registerType("StaticRoutes", "LauncherStaticRouter");
|
||||
depContainer.registerType("StaticRoutes", "LauncherV2StaticRouter");
|
||||
depContainer.registerType("StaticRoutes", "LocationStaticRouter");
|
||||
depContainer.registerType("StaticRoutes", "WeatherStaticRouter");
|
||||
depContainer.registerType("StaticRoutes", "MatchStaticRouter");
|
||||
@ -515,6 +519,7 @@ export class Container {
|
||||
depContainer.register<InsuranceStaticRouter>("InsuranceStaticRouter", { useClass: InsuranceStaticRouter });
|
||||
depContainer.register<ItemEventStaticRouter>("ItemEventStaticRouter", { useClass: ItemEventStaticRouter });
|
||||
depContainer.register<LauncherStaticRouter>("LauncherStaticRouter", { useClass: LauncherStaticRouter });
|
||||
depContainer.register<LauncherV2StaticRouter>("LauncherV2StaticRouter", { useClass: LauncherV2StaticRouter });
|
||||
depContainer.register<LocationStaticRouter>("LocationStaticRouter", { useClass: LocationStaticRouter });
|
||||
depContainer.register<MatchStaticRouter>("MatchStaticRouter", { useClass: MatchStaticRouter });
|
||||
depContainer.register<NotifierStaticRouter>("NotifierStaticRouter", { useClass: NotifierStaticRouter });
|
||||
@ -666,6 +671,7 @@ export class Container {
|
||||
depContainer.register<InventoryCallbacks>("InventoryCallbacks", { useClass: InventoryCallbacks });
|
||||
depContainer.register<ItemEventCallbacks>("ItemEventCallbacks", { useClass: ItemEventCallbacks });
|
||||
depContainer.register<LauncherCallbacks>("LauncherCallbacks", { useClass: LauncherCallbacks });
|
||||
depContainer.register<LauncherV2Callbacks>("LauncherV2Callbacks", { useClass: LauncherV2Callbacks });
|
||||
depContainer.register<LocationCallbacks>("LocationCallbacks", { useClass: LocationCallbacks });
|
||||
depContainer.register<MatchCallbacks>("MatchCallbacks", { useClass: MatchCallbacks });
|
||||
depContainer.register<ModCallbacks>("ModCallbacks", { useClass: ModCallbacks });
|
||||
@ -836,6 +842,7 @@ export class Container {
|
||||
depContainer.register<InsuranceController>("InsuranceController", { useClass: InsuranceController });
|
||||
depContainer.register<InventoryController>("InventoryController", { useClass: InventoryController });
|
||||
depContainer.register<LauncherController>("LauncherController", { useClass: LauncherController });
|
||||
depContainer.register<LauncherV2Controller>("LauncherV2Controller", { useClass: LauncherV2Controller });
|
||||
depContainer.register<LocationController>("LocationController", { useClass: LocationController });
|
||||
depContainer.register<MatchController>("MatchController", MatchController);
|
||||
depContainer.register<NoteController>("NoteController", { useClass: NoteController });
|
||||
|
@ -3,6 +3,7 @@ import { Spt } from "../profile/ISptProfile";
|
||||
export interface IMiniProfile {
|
||||
username: string;
|
||||
nickname: string;
|
||||
hasPassword: boolean;
|
||||
side: string;
|
||||
currlvl: number;
|
||||
currexp: number;
|
||||
|
25
project/src/models/spt/callbacks/ILauncherV2Callbacks.ts
Normal file
25
project/src/models/spt/callbacks/ILauncherV2Callbacks.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { IChangeRequestData } from "@spt/models/eft/launcher/IChangeRequestData";
|
||||
import { ILoginRequestData } from "@spt/models/eft/launcher/ILoginRequestData";
|
||||
import { IRegisterData } from "@spt/models/eft/launcher/IRegisterData";
|
||||
import { ILauncherV2LoginResponse } from "../launcher/ILauncherV2LoginResponse";
|
||||
import { ILauncherV2ModsResponse } from "../launcher/ILauncherV2ModsResponse";
|
||||
import { ILauncherV2PasswordChangeResponse } from "../launcher/ILauncherV2PasswordChangeResponse";
|
||||
import { ILauncherV2PingResponse } from "../launcher/ILauncherV2PingResponse";
|
||||
import { ILauncherV2ProfilesResponse } from "../launcher/ILauncherV2ProfilesResponse";
|
||||
import { ILauncherV2RegisterResponse } from "../launcher/ILauncherV2RegisterResponse";
|
||||
import { ILauncherV2TypesResponse } from "../launcher/ILauncherV2TypesResponse";
|
||||
import { ILauncherV2VersionResponse } from "../launcher/ILauncherV2VersionResponse";
|
||||
|
||||
export interface ILauncherV2Callbacks {
|
||||
ping(): ILauncherV2PingResponse;
|
||||
types(): ILauncherV2TypesResponse;
|
||||
login(info: ILoginRequestData): ILauncherV2LoginResponse;
|
||||
register(info: IRegisterData): ILauncherV2RegisterResponse;
|
||||
passwordChange(info: IChangeRequestData): ILauncherV2PasswordChangeResponse;
|
||||
remove(info: ILoginRequestData): ILauncherV2LoginResponse;
|
||||
compatibleVersion(): ILauncherV2VersionResponse;
|
||||
mods(): ILauncherV2ModsResponse;
|
||||
profiles(): ILauncherV2ProfilesResponse;
|
||||
profile(): Error
|
||||
profileMods(): Error
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
export interface ILauncherV2CompatibleVersion {
|
||||
sptVersion: string
|
||||
eftVersion: string
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
export interface ILauncherV2LoginResponse {
|
||||
response: boolean
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
import { IPackageJsonData } from "../mod/IPackageJsonData";
|
||||
|
||||
export interface ILauncherV2ModsResponse {
|
||||
response: Record<string, IPackageJsonData>
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
import { IMiniProfile } from "@spt/models/eft/launcher/IMiniProfile"
|
||||
|
||||
export interface ILauncherV2PasswordChangeResponse {
|
||||
response: boolean
|
||||
profiles: IMiniProfile[]
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
export interface ILauncherV2PingResponse {
|
||||
response: string
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
import { IMiniProfile } from "@spt/models/eft/launcher/IMiniProfile";
|
||||
|
||||
export interface ILauncherV2ProfilesResponse {
|
||||
response: IMiniProfile[]
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
import { IMiniProfile } from "@spt/models/eft/launcher/IMiniProfile"
|
||||
|
||||
export interface ILauncherV2RegisterResponse {
|
||||
response: boolean
|
||||
profiles: IMiniProfile[]
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
import { IMiniProfile } from "@spt/models/eft/launcher/IMiniProfile"
|
||||
|
||||
export interface ILauncherV2RemoveResponse {
|
||||
response: boolean
|
||||
profiles: IMiniProfile[]
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
export interface ILauncherV2TypesResponse {
|
||||
response: Record<string, string>
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
import { ILauncherV2CompatibleVersion } from "@spt/models/spt/launcher/ILauncherV2CompatibleVersion";
|
||||
|
||||
export interface ILauncherV2VersionResponse {
|
||||
response: ILauncherV2CompatibleVersion
|
||||
}
|
94
project/src/routers/static/LauncherV2StaticRouter.ts
Normal file
94
project/src/routers/static/LauncherV2StaticRouter.ts
Normal file
@ -0,0 +1,94 @@
|
||||
import { LauncherV2Callbacks } from "@spt/callbacks/Launcherv2Callbacks";
|
||||
import { ProfileCallbacks } from "@spt/callbacks/ProfileCallbacks";
|
||||
import { RouteAction, StaticRouter } from "@spt/di/Router";
|
||||
import { IEmptyRequestData } from "@spt/models/eft/common/IEmptyRequestData";
|
||||
import { IChangeRequestData } from "@spt/models/eft/launcher/IChangeRequestData";
|
||||
import { ILoginRequestData } from "@spt/models/eft/launcher/ILoginRequestData";
|
||||
import { IRegisterData } from "@spt/models/eft/launcher/IRegisterData";
|
||||
import { ILauncherV2LoginResponse } from "@spt/models/spt/launcher/ILauncherV2LoginResponse";
|
||||
import { ILauncherV2ModsResponse } from "@spt/models/spt/launcher/ILauncherV2ModsResponse";
|
||||
import { ILauncherV2PasswordChangeResponse } from "@spt/models/spt/launcher/ILauncherV2PasswordChangeResponse";
|
||||
import { ILauncherV2PingResponse } from "@spt/models/spt/launcher/ILauncherV2PingResponse";
|
||||
import { ILauncherV2ProfilesResponse } from "@spt/models/spt/launcher/ILauncherV2ProfilesResponse";
|
||||
import { ILauncherV2RegisterResponse } from "@spt/models/spt/launcher/ILauncherV2RegisterResponse";
|
||||
import { ILauncherV2RemoveResponse } from "@spt/models/spt/launcher/ILauncherV2RemoveResponse";
|
||||
import { ILauncherV2TypesResponse } from "@spt/models/spt/launcher/ILauncherV2TypesResponse";
|
||||
import { ILauncherV2VersionResponse } from "@spt/models/spt/launcher/ILauncherV2VersionResponse";
|
||||
import { inject, injectable } from "tsyringe";
|
||||
|
||||
@injectable()
|
||||
export class LauncherV2StaticRouter extends StaticRouter {
|
||||
constructor(
|
||||
@inject("LauncherV2Callbacks") protected launcherV2Callbacks: LauncherV2Callbacks,
|
||||
@inject("ProfileCallbacks") protected profileCallbacks: ProfileCallbacks
|
||||
) {
|
||||
super([
|
||||
new RouteAction(
|
||||
"/launcher/v2/ping",
|
||||
async (url: string, info: IEmptyRequestData, sessionID: string, output: string): Promise<ILauncherV2PingResponse> => {
|
||||
return this.launcherV2Callbacks.ping();
|
||||
},
|
||||
),
|
||||
new RouteAction(
|
||||
"/launcher/v2/types",
|
||||
async (url: string, info: IEmptyRequestData, sessionID: string, output: string): Promise<ILauncherV2TypesResponse> => {
|
||||
return this.launcherV2Callbacks.types();
|
||||
},
|
||||
),
|
||||
new RouteAction(
|
||||
"/launcher/v2/Login",
|
||||
async (url: string, info: ILoginRequestData, sessionID: string, output: string): Promise<ILauncherV2LoginResponse> => {
|
||||
return this.launcherV2Callbacks.login(info);
|
||||
},
|
||||
),
|
||||
new RouteAction(
|
||||
"/launcher/v2/Register",
|
||||
async (url: string, info: IRegisterData, sessionID: string, output: string): Promise<ILauncherV2RegisterResponse> => {
|
||||
return this.launcherV2Callbacks.register(info);
|
||||
},
|
||||
),
|
||||
new RouteAction(
|
||||
"/launcher/v2/passwordChange",
|
||||
async (url: string, info: IChangeRequestData, sessionID: string, output: string): Promise<ILauncherV2PasswordChangeResponse> => {
|
||||
return this.launcherV2Callbacks.passwordChange(info);
|
||||
},
|
||||
),
|
||||
new RouteAction(
|
||||
"/launcher/v2/Remove",
|
||||
async (url: string, info: ILoginRequestData, sessionID: string, output: string): Promise<ILauncherV2RemoveResponse> => {
|
||||
return this.launcherV2Callbacks.remove(info);
|
||||
},
|
||||
),
|
||||
new RouteAction(
|
||||
"/launcher/v2/version",
|
||||
async (url: string, info: IEmptyRequestData, sessionID: string, output: string): Promise<ILauncherV2VersionResponse> => {
|
||||
return this.launcherV2Callbacks.compatibleVersion();
|
||||
},
|
||||
),
|
||||
new RouteAction(
|
||||
"/launcher/v2/mods",
|
||||
async (url: string, info: IEmptyRequestData, sessionID: string, output: string): Promise<ILauncherV2ModsResponse> => {
|
||||
return this.launcherV2Callbacks.mods();
|
||||
},
|
||||
),
|
||||
new RouteAction(
|
||||
"/launcher/v2/profiles",
|
||||
async (url: string, info: IEmptyRequestData, sessionID: string, output: string): Promise<ILauncherV2ProfilesResponse> => {
|
||||
return this.launcherV2Callbacks.profiles();
|
||||
},
|
||||
),
|
||||
new RouteAction(
|
||||
"/launcher/v2/profile",
|
||||
async (url: string, info: IEmptyRequestData, sessionID: string, output: string): Promise<ILauncherV2ProfilesResponse> => {
|
||||
return this.launcherV2Callbacks.profile();
|
||||
},
|
||||
),
|
||||
new RouteAction(
|
||||
"/launcher/v2/profileMods",
|
||||
async (url: string, info: IEmptyRequestData, sessionID: string, output: string): Promise<ILauncherV2ProfilesResponse> => {
|
||||
return this.launcherV2Callbacks.profileMods();
|
||||
},
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user