mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
feat: unified abstraction
This commit is contained in:
1 parent
7cb67bd44b
commit
d3bdbc39d2
2 files changed
+51
-16
No files matched your search
@@ -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<SteamUser["logOn"]>) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user