diff --git a/.vscode/settings.json b/.vscode/settings.json index b4d1dc48b..7304e64d5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -112,6 +112,7 @@ "leaderboards", "lerp", "LINEARSIZE", + "linktarget", "lmao", "loadouts", "loddist", diff --git a/packages/core/src/steam/steam.ts b/packages/core/src/steam/steam.ts index f1352c658..09b47d234 100644 --- a/packages/core/src/steam/steam.ts +++ b/packages/core/src/steam/steam.ts @@ -1,23 +1,57 @@ -import SteamUser from "steam-user"; +import SteamUser, { EConnectionProtocol } from "steam-user"; -export class Steam extends SteamUser { - // call me master hacker the way i be cheesing this up - async logOn(...parameters: Parameters) { - let loggedOn = false; - const self = this; +interface SteamManifest { + files: { + chunks: { + sha: string; + crc: number; + offset: string; + cb_original: number; + cb_compressed: number; + }[]; + filename: string; + size: string; + flags: number; + sha_filename: string; + sha_content: string; + linktarget: unknown; + }[]; +} - this.on("loggedOn", () => { - console.log(`Logged onto ${self.steamID!.steam3()}`); - loggedOn = true; +export class SteamVFS { + private steam = new SteamUser({ protocol: EConnectionProtocol.TCP }); + + private manifest: SteamManifest; + + constructor( + private username: string, + private password: string, + private app: number, + private depot: number + ) {} + + async init() { + this.steam.logOn({ + accountName: this.username, + password: this.password, }); - while (!loggedOn) { - // @ts-ignore - this._connectionClosed = false; + await new Promise((resolve) => this.steam.once("loggedOn", resolve)); - console.log("Attempting to log on..."); - super.logOn(...parameters); - await new Promise((resolve) => setTimeout(resolve, 1000)); - } + const productInfo = await this.steam.getProductInfo([this.app], []); + const manifest = await new Promise((resolve) => { + this.steam.getManifest( + this.app, + this.depot, + productInfo.apps[this.app].appinfo.depots[this.depot].manifests.public + .gid, + "public", + (_, response) => { + resolve(response); + } + ); + }); + + console.log(JSON.stringify(manifest.files[0], null, 2)); } }