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.
This commit is contained in:
parent
d55706c5f3
commit
0a5f40341b
1 changed files with 17 additions and 2 deletions
|
|
@ -14,6 +14,7 @@ import {
|
||||||
handleSIGINT,
|
handleSIGINT,
|
||||||
} from './src/util.js';
|
} from './src/util.js';
|
||||||
import { cfg } from './src/config.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';
|
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();
|
const page = context.pages().length ? context.pages()[0] : await context.newPage();
|
||||||
await page.setViewportSize({ width: cfg.width, height: cfg.height });
|
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;
|
let user;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const auth = await getValidAuth({
|
const auth = await getValidAuth({
|
||||||
email: cfg.eg_email,
|
|
||||||
password: cfg.eg_password,
|
|
||||||
otpKey: cfg.eg_otpkey,
|
otpKey: cfg.eg_otpkey,
|
||||||
reuseCookies: true,
|
reuseCookies: true,
|
||||||
cookiesPath: COOKIES_PATH,
|
cookiesPath: COOKIES_PATH,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue