fix: Multiple bug fixes and code cleanup
All checks were successful
build-and-push / lint (push) Successful in 8s
build-and-push / sonar (push) Successful in 21s
build-and-push / docker (push) Successful in 25s

- package.json: Add missing @eslint/js and globals devDependencies
- docker-entrypoint.sh: Fix X11 lock file name (.X1-lock → .X11-lock)
- epic-claimer-new.js: Use imported solveCloudflare/isCloudflareChallenge instead of duplicate implementations
- src/cloudflare.js: Fix solveCloudflare to use cfg.flaresolverr_url, remove unused imports
- epic-games.js: Remove unused code (getFreeGamesFromGraphQL, exchangeTokenForCookies, FREE_GAMES_QUERY, deviceAuthLoginSuccess variable)
- Run eslint --fix to clean up trailing spaces
This commit is contained in:
root 2026-03-08 13:58:57 +00:00
parent b14530537a
commit 48c861b3de
6 changed files with 166 additions and 174 deletions

View file

@ -76,27 +76,6 @@ if (cfg.debug_network) {
const notify_games = [];
let user;
// GraphQL query for free games
const FREE_GAMES_QUERY = {
operationName: 'searchStoreQuery',
variables: {
allowCountries: 'US',
category: 'games/edition/base|software/edition/base|editors|bundles/games',
count: 1000,
country: 'US',
sortBy: 'relevancy',
sortDir: 'DESC',
start: 0,
withPrice: true,
},
extensions: {
persistedQuery: {
version: 1,
sha256Hash: '7d58e12d9dd8cb14c84a3ff18d360bf9f0caa96bf218f2c5fda68ba88d68a437',
},
},
};
// Generate login redirect URL
const generateLoginRedirect = redirectUrl => {
const loginRedirectUrl = new URL(ID_LOGIN_ENDPOINT);
@ -115,53 +94,6 @@ const generateCheckoutUrl = offers => {
return generateLoginRedirect(checkoutUrl);
};
// Get free games from GraphQL API (unused - kept for reference)
const getFreeGamesFromGraphQL = async () => {
const items = [];
let start = 0;
const pageLimit = 1000;
do {
const response = await page.evaluate(async (query, startOffset) => {
const variables = { ...query.variables, start: startOffset };
const resp = await fetch(GRAPHQL_ENDPOINT, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
operationName: query.operationName,
variables: JSON.stringify(variables),
extensions: JSON.stringify(query.extensions),
}),
});
return await resp.json();
}, [FREE_GAMES_QUERY, start]);
const elements = response.data?.Catalog?.searchStore?.elements;
if (!elements) break;
items.push(...elements);
start += pageLimit;
} while (items.length < pageLimit);
// Filter free games
const freeGames = items.filter(game => game.price?.totalPrice?.discountPrice === 0);
// Deduplicate by productSlug
const uniqueGames = new Map();
for (const game of freeGames) {
if (!uniqueGames.has(game.productSlug)) {
uniqueGames.set(game.productSlug, game);
}
}
return Array.from(uniqueGames.values()).map(game => ({
offerId: game.id,
offerNamespace: game.namespace,
productName: game.title,
productSlug: game.productSlug || game.urlSlug,
}));
};
// Get free games from promotions API (weekly free games)
const getFreeGamesFromPromotions = async () => {
const response = await page.evaluate(async () => {
@ -237,25 +169,6 @@ const loginWithDeviceAuth = async () => {
return false;
};
// Exchange token for cookies (alternative method - unused)
const exchangeTokenForCookies = async accessToken => {
try {
const cookies = await page.evaluate(async token => {
const resp = await fetch('https://store.epicgames.com/', {
headers: {
Authorization: `Bearer ${token}`,
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
},
});
return await resp.headers.get('set-cookie');
}, accessToken);
return cookies;
} catch {
return null;
}
};
// Save device auth
const saveDeviceAuth = async (accessToken, refreshToken, expiresAt) => {
const deviceAuth = {
@ -292,8 +205,8 @@ try {
if (cfg.time) console.timeEnd('startup');
if (cfg.time) console.time('login');
// Try device auth first (unused - kept for reference)
const deviceAuthLoginSuccess = await loginWithDeviceAuth();
// Try device auth first
await loginWithDeviceAuth();
// If device auth failed, try regular login
while (await page.locator('egs-navigation').getAttribute('isloggedin') != 'true') {