free-games-claimer/src/constants.ts
nocci 728b0c734b refactor[epic-games]: migrate to GraphQL API and modularize authentication logic
This commit refactors epic-games.js to use the GraphQL API instead of the legacy promotions endpoint for retrieving free games. Key architectural improvements include:

- Added modular authentication module (device-auths.ts) supporting persistent device auth tokens
- Introduces cookie management module (cookie.ts) for persistent session handling
- Extracts GraphQL query structures and API endpoints into constants.ts
- Implements multiple fallback strategies: device auth login, token exchange, and fallback to standard login
- Adds support for both GraphQL and promotions-based game discovery
- Streamlines claim process with improved tracking and error handling
- Removes legacy selectors and redundant logic

Additionally, updates package.json to include TypeScript and reorganizes dependency order for better maintainability.
2026-03-06 15:26:26 +00:00

43 lines
3.6 KiB
TypeScript

// Epic Games API Constants
// Based on https://github.com/claabs/epicgames-freegames-node
export const EPIC_CLIENT_ID = '875a3b57d3a640a6b7f9b4e883463ab4';
export const CSRF_ENDPOINT = 'https://www.epicgames.com/id/api/csrf';
export const ACCOUNT_CSRF_ENDPOINT = 'https://www.epicgames.com/account/v2/refresh-csrf';
export const ACCOUNT_SESSION_ENDPOINT = 'https://www.epicgames.com/account/personal';
export const LOGIN_ENDPOINT = 'https://www.epicgames.com/id/api/login';
export const REDIRECT_ENDPOINT = 'https://www.epicgames.com/id/api/redirect';
export const GRAPHQL_ENDPOINT = 'https://store.epicgames.com/graphql';
export const ARKOSE_BASE_URL = 'https://epic-games-api.arkoselabs.com';
export const CHANGE_EMAIL_ENDPOINT = 'https://www.epicgames.com/account/v2/api/email/change';
export const USER_INFO_ENDPOINT = 'https://www.epicgames.com/account/v2/personal/ajaxGet';
export const RESEND_VERIFICATION_ENDPOINT = 'https://www.epicgames.com/account/v2/resendEmailVerification';
export const REPUTATION_ENDPOINT = 'https://www.epicgames.com/id/api/reputation';
export const STORE_CONTENT = 'https://store-content-ipv4.ak.epicgames.com/api/en-US/content';
export const EMAIL_VERIFY = 'https://www.epicgames.com/id/api/email/verify';
export const SETUP_MFA = 'https://www.epicgames.com/account/v2/security/ajaxUpdateTwoFactorAuthSettings';
export const FREE_GAMES_PROMOTIONS_ENDPOINT = 'https://store-site-backend-static-ipv4.ak.epicgames.com/freeGamesPromotions';
export const STORE_HOMEPAGE = 'https://store.epicgames.com/';
export const STORE_HOMEPAGE_EN = `${STORE_HOMEPAGE}en-US/`;
export const STORE_CART_EN = `${STORE_HOMEPAGE}en-US/cart`;
export const ORDER_CONFIRM_ENDPOINT = 'https://payment-website-pci.ol.epicgames.com/purchase/confirm-order';
export const ORDER_PREVIEW_ENDPOINT = 'https://payment-website-pci.ol.epicgames.com/purchase/order-preview';
export const EPIC_PURCHASE_ENDPOINT = 'https://www.epicgames.com/store/purchase';
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 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';
export const TALON_INIT_ENDPOINT = 'https://talon-service-prod.ak.epicgames.com/v1/init';
export const TALON_EXECUTE_ENDPOINT = 'https://talon-service-v4-prod.ak.epicgames.com/v1/init/execute';
export const TALON_WEBSITE_BASE = 'https://talon-website-prod.ak.epicgames.com';
export const TALON_REFERRER = 'https://talon-website-prod.ak.epicgames.com/challenge?env=prod&flow=login_prod&origin=https%3A%2F%2Fwww.epicgames.com';
export const ACCOUNT_OAUTH_TOKEN = 'https://account-public-service-prod.ol.epicgames.com/account/api/oauth/token';
export const ACCOUNT_OAUTH_DEVICE_AUTH = 'https://account-public-service-prod.ol.epicgames.com/account/api/oauth/deviceAuthorization';
export const ID_LOGIN_ENDPOINT = 'https://www.epicgames.com/id/login';
export const EULA_AGREEMENTS_ENDPOINT = 'https://eulatracking-public-service-prod-m.ol.epicgames.com/eulatracking/api/public/agreements';
export const REQUIRED_EULAS = ['epicgames_privacy_policy_no_table', 'egstore'];