revert generateLocalTokens, wrong analysis on game launching issue

This commit is contained in:
Fazri Gading
2026-02-01 23:24:22 +08:00
parent 38d436ceb7
commit 3fee5b0f72

View File

@@ -68,11 +68,53 @@ async function fetchAuthTokens(uuid, name) {
}; };
} catch (error) { } catch (error) {
console.error('Failed to fetch auth tokens:', error.message); console.error('Failed to fetch auth tokens:', error.message);
// Don't use invalid local tokens that cause the game to hang // Fallback to local generation if server unavailable
throw new Error(`Authentication server unavailable: ${error.message}. Please check your internet connection or try again later.`); return generateLocalTokens(uuid, name);
} }
} }
// Fallback: Generate tokens locally (won't pass signature validation but allows offline testing)
function generateLocalTokens(uuid, name) {
console.log('Using locally generated tokens (fallback mode)');
const authServerUrl = getAuthServerUrl();
const now = Math.floor(Date.now() / 1000);
const exp = now + 36000;
const header = Buffer.from(JSON.stringify({
alg: 'EdDSA',
kid: '2025-10-01',
typ: 'JWT'
})).toString('base64url');
const identityPayload = Buffer.from(JSON.stringify({
sub: uuid,
name: name,
username: name,
entitlements: ['game.base'],
scope: 'hytale:server hytale:client',
iat: now,
exp: exp,
iss: authServerUrl,
jti: uuidv4()
})).toString('base64url');
const sessionPayload = Buffer.from(JSON.stringify({
sub: uuid,
scope: 'hytale:server',
iat: now,
exp: exp,
iss: authServerUrl,
jti: uuidv4()
})).toString('base64url');
const signature = crypto.randomBytes(64).toString('base64url');
return {
identityToken: `${header}.${identityPayload}.${signature}`,
sessionToken: `${header}.${sessionPayload}.${signature}`
};
}
async function launchGame(playerNameOverride = null, progressCallback, javaPathOverride, installPathOverride, gpuPreference = 'auto', branchOverride = null) { async function launchGame(playerNameOverride = null, progressCallback, javaPathOverride, installPathOverride, gpuPreference = 'auto', branchOverride = null) {
// ========================================================================== // ==========================================================================
// STEP 1: Validate player identity FIRST (before any other operations) // STEP 1: Validate player identity FIRST (before any other operations)