refactor(style): align template literals and whitespace formatting
- standardize string literals to single quotes in constants.js - remove unused variable and normalize whitespace in cookie.js - simplify nullish coalescing expression in device-auths.js This consistency improvement enhances code readability and enforces uniform style across the codebase.
This commit is contained in:
parent
22c84a759b
commit
c0d148dc8e
3 changed files with 10 additions and 11 deletions
|
|
@ -27,8 +27,8 @@ export const MFA_LOGIN_ENDPOINT = 'https://www.epicgames.com/id/api/login/mfa';
|
|||
export const UNREAL_SET_SID_ENDPOINT = 'https://www.unrealengine.com/id/api/set-sid';
|
||||
export const TWINMOTION_SET_SID_ENDPOINT = 'https://www.twinmotion.com/id/api/set-sid';
|
||||
export const CLIENT_REDIRECT_ENDPOINT = `https://www.epicgames.com/id/api/client/${EPIC_CLIENT_ID}`;
|
||||
export const AUTHENTICATE_ENDPOINT = `https://www.epicgames.com/id/api/authenticate`;
|
||||
export const LOCATION_ENDPOINT = `https://www.epicgames.com/id/api/location`;
|
||||
export const AUTHENTICATE_ENDPOINT = 'https://www.epicgames.com/id/api/authenticate';
|
||||
export const LOCATION_ENDPOINT = 'https://www.epicgames.com/id/api/location';
|
||||
export const PHASER_F_ENDPOINT = 'https://talon-service-prod.ak.epicgames.com/v1/phaser/f';
|
||||
export const PHASER_BATCH_ENDPOINT = 'https://talon-service-prod.ak.epicgames.com/v1/phaser/batch';
|
||||
export const TALON_IP_ENDPOINT = 'https://talon-service-v4-prod.ak.epicgames.com/v1/init/ip';
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ function getCookieJar(username) {
|
|||
if (cookieJar) {
|
||||
return cookieJar;
|
||||
}
|
||||
const cookieFilename = getCookiePath(username);
|
||||
cookieJar = new tough.CookieJar();
|
||||
cookieJars.set(username, cookieJar);
|
||||
return cookieJar;
|
||||
|
|
@ -41,8 +40,8 @@ function getCookieJar(username) {
|
|||
// Convert EditThisCookie format to tough-cookie file store format
|
||||
export function editThisCookieToToughCookieFileStore(etc) {
|
||||
const tcfs = {};
|
||||
|
||||
etc.forEach((etcCookie) => {
|
||||
|
||||
etc.forEach(etcCookie => {
|
||||
const domain = etcCookie.domain.replace(/^\./, '');
|
||||
const expires = etcCookie.expirationDate
|
||||
? new Date(etcCookie.expirationDate * 1000).toISOString()
|
||||
|
|
@ -69,7 +68,7 @@ export function editThisCookieToToughCookieFileStore(etc) {
|
|||
Object.assign(tcfs, temp);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return tcfs;
|
||||
}
|
||||
|
||||
|
|
@ -99,7 +98,7 @@ export async function getCookiesRaw(username) {
|
|||
// Set cookies from Playwright/Cookie format
|
||||
export async function setPuppeteerCookies(username, newCookies) {
|
||||
const cookieJar = getCookieJar(username);
|
||||
|
||||
|
||||
for (const cookie of newCookies) {
|
||||
const domain = cookie.domain.replace(/^\./, '');
|
||||
const tcfsCookie = new tough.Cookie({
|
||||
|
|
@ -112,7 +111,7 @@ export async function setPuppeteerCookies(username, newCookies) {
|
|||
httpOnly: cookie.httpOnly,
|
||||
hostOnly: !cookie.domain.startsWith('.'),
|
||||
});
|
||||
|
||||
|
||||
try {
|
||||
await cookieJar.setCookie(tcfsCookie, `https://${domain}`);
|
||||
} catch (err) {
|
||||
|
|
@ -137,11 +136,11 @@ export async function userHasValidCookie(username, cookieName) {
|
|||
try {
|
||||
const fileExists = fs.existsSync(cookieFilename);
|
||||
if (!fileExists) return false;
|
||||
|
||||
|
||||
const cookieData = JSON.parse(fs.readFileSync(cookieFilename, 'utf8'));
|
||||
const rememberCookieExpireDate = cookieData['epicgames.com']?.['/']?.[cookieName]?.expires;
|
||||
if (!rememberCookieExpireDate) return false;
|
||||
|
||||
|
||||
return new Date(rememberCookieExpireDate) > new Date();
|
||||
} catch {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ export async function writeDeviceAuths(deviceAuths) {
|
|||
}
|
||||
|
||||
export async function setAccountAuth(account, accountAuth) {
|
||||
const existingDeviceAuths = (await getDeviceAuths()) ?? {};
|
||||
const existingDeviceAuths = await getDeviceAuths() ?? {};
|
||||
existingDeviceAuths[account] = accountAuth;
|
||||
await writeDeviceAuths(existingDeviceAuths);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue