From 0a5f40341b4dc8cbf6dca3289da35a87aa80d637 Mon Sep 17 00:00:00 2001 From: nocci Date: Sun, 8 Mar 2026 11:18:28 +0000 Subject: [PATCH] refactor(auth): add device auth reuse for legacy account migration - imports device auth utility functions - adds logic to reuse Epic Games device authentication from legacy mode - loads device auth cookies (EPIC_SSO_RM, EPIC_DEVICE, EPIC_SESSION_AP) when available - falls back to regular authentication if device auth is not present This enables seamless transition for users migrating from legacy authentication while maintaining backward compatibility. --- epic-claimer-new.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/epic-claimer-new.js b/epic-claimer-new.js index c4335af..8d81e14 100644 --- a/epic-claimer-new.js +++ b/epic-claimer-new.js @@ -14,6 +14,7 @@ import { handleSIGINT, } from './src/util.js'; import { cfg } from './src/config.js'; +import { getDeviceAuths, setAccountAuth } from './src/device-auths.js'; const URL_CLAIM = 'https://store.epicgames.com/en-US/free-games'; @@ -329,12 +330,26 @@ export const claimEpicGamesNew = async () => { const page = context.pages().length ? context.pages()[0] : await context.newPage(); await page.setViewportSize({ width: cfg.width, height: cfg.height }); + // Use device auths if available (from legacy mode) + const deviceAuths = await getDeviceAuths(); + if (deviceAuths && cfg.eg_email) { + const accountAuth = deviceAuths[cfg.eg_email]; + if (accountAuth) { + console.log('🔄 Reusing device auth from legacy mode'); + const cookies = [ + { name: 'EPIC_SSO_RM', value: accountAuth.deviceAuth?.refreshToken || '', domain: '.epicgames.com', path: '/' }, + { name: 'EPIC_DEVICE', value: accountAuth.deviceAuth?.deviceId || '', domain: '.epicgames.com', path: '/' }, + { name: 'EPIC_SESSION_AP', value: accountAuth.deviceAuth?.accountId || '', domain: '.epicgames.com', path: '/' }, + ]; + await context.addCookies(cookies); + console.log('✅ Device auth cookies loaded'); + } + } + let user; try { const auth = await getValidAuth({ - email: cfg.eg_email, - password: cfg.eg_password, otpKey: cfg.eg_otpkey, reuseCookies: true, cookiesPath: COOKIES_PATH,