Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates packages #38

Merged
merged 3 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,29 @@
},
"dependencies": {
"@commander-js/extra-typings": "commander-js/extra-typings",
"axios": "^1.7.7",
"bgutils-js": "^2.1.0",
"body-parser": "^1.20.2",
"axios": "^1.7.9",
"bgutils-js": "^3.1.0",
"body-parser": "^1.20.3",
"commander": "^12.1.0",
"express": "^4.19.2",
"https-proxy-agent": "^7.0.5",
"jsdom": "^25.0.0",
"socks-proxy-agent": "^8.0.4",
"youtubei.js": "^10.4.0"
"express": "^4.21.2",
"https-proxy-agent": "^7.0.6",
"jsdom": "^25.0.1",
"socks-proxy-agent": "^8.0.5",
"youtubei.js": "^12.2.0"
},
"devDependencies": {
"@eslint/js": "^9.10.0",
"@types/express": "^4.17.21",
"@eslint/js": "^9.17.0",
"@types/express": "^5.0.0",
"@types/jsdom": "^21.1.7",
"@types/node": "^22.5.0",
"@typescript-eslint/parser": "^8.5.0",
"eslint": "^9.10.0",
"@types/node": "^22.10.2",
"@typescript-eslint/parser": "^8.18.2",
"eslint": "^9.17.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-only-warn": "^1.1.0",
"eslint-plugin-prettier": "^5.2.1",
"prettier": "3.3.3",
"prettier": "3.4.2",
"ts-node": "^10.9.2",
"typescript": "^5.5.4",
"typescript-eslint": "^8.5.0"
"typescript": "^5.7.2",
"typescript-eslint": "^8.18.2"
}
}
26 changes: 16 additions & 10 deletions server/src/session_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,20 +206,24 @@ export class SessionManager {
);
}
if (!challenge) throw new Error("Could not get Botguard challenge");
if (challenge.script) {
const script = challenge.script.find((sc) => sc !== null);
if (script) new Function(script)();
} else {
this.logger.log("Unable to load Botguard.");
}

const interpreterJavascript =
challenge.interpreterJavascript
.privateDoNotAccessOrElseSafeScriptWrappedValue;

if (interpreterJavascript) {
new Function(interpreterJavascript)();
} else throw new Error("Could not load VM");

let poToken: string | undefined;
try {
poToken = await BG.PoToken.generate({
program: challenge.challenge,
const poTokenResult = await BG.PoToken.generate({
program: challenge.program,
globalName: challenge.globalName,
bgConfig,
});

poToken = poTokenResult.poToken;
} catch (e) {
throw new Error(
`Error while trying to generate PO token. err.name = ${e.name}. err.message = ${e.message}. err.stack = ${e.stack}`,
Expand All @@ -234,12 +238,14 @@ export class SessionManager {
throw new Error("po_token unexpected undefined");
}

this.youtubeSessionDataCaches[visitIdentifier] = {
const youtubeSessionData = {
visitIdentifier: visitIdentifier,
poToken: poToken,
generatedAt: new Date(),
};

return this.youtubeSessionDataCaches[visitIdentifier];
this.youtubeSessionDataCaches[visitIdentifier] = youtubeSessionData;

return youtubeSessionData;
}
}
Loading
Loading