mirror of
https://github.com/amiayweb/Hytale-F2P.git
synced 2026-02-26 12:31:46 -03:00
revert generateLocalTokens, wrong analysis on game launching issue
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user