deactivate bedrock uuid resolver
All checks were successful
delpoy / build-and-deploy (push) Successful in 51s
All checks were successful
delpoy / build-and-deploy (push) Successful in 51s
This commit is contained in:
parent
1f150bae06
commit
63605e23b1
@ -9,14 +9,14 @@ export class UserNotFoundError extends Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MojangError extends Error {}
|
export class ApiError extends Error {}
|
||||||
|
|
||||||
export async function getJavaUuid(username: string): Promise<string> {
|
export async function getJavaUuid(username: string): Promise<string> {
|
||||||
const response = await fetch(`https://api.mojang.com/users/profiles/minecraft/${username}`);
|
const response = await fetch(`https://api.mojang.com/users/profiles/minecraft/${username}`);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw response.status < 500
|
throw response.status < 500
|
||||||
? new UserNotFoundError(username)
|
? new UserNotFoundError(username)
|
||||||
: new MojangError(`mojang server error (${response.status}): ${await response.text()}`);
|
: new ApiError(`mojang server error (${response.status}): ${await response.text()}`);
|
||||||
}
|
}
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
const id: string = json['id'];
|
const id: string = json['id'];
|
||||||
@ -29,12 +29,13 @@ export async function getBedrockUuid(username: string): Promise<string> {
|
|||||||
const initialPageResponse = await fetch('https://cxkes.me/xbox/xuid');
|
const initialPageResponse = await fetch('https://cxkes.me/xbox/xuid');
|
||||||
const initialPageContent = await initialPageResponse.text();
|
const initialPageContent = await initialPageResponse.text();
|
||||||
const token = /name="_token"\svalue="(?<token>\w+)"/.exec(initialPageContent)?.groups?.token;
|
const token = /name="_token"\svalue="(?<token>\w+)"/.exec(initialPageContent)?.groups?.token;
|
||||||
if (token === undefined) throw new Error("couldn't grab token from xuid converter website");
|
if (token === undefined) throw new ApiError("couldn't grab token from xuid converter website");
|
||||||
|
|
||||||
const cookies = initialPageResponse.headers.get('set-cookie')?.split(' ');
|
const cookies = initialPageResponse.headers.get('set-cookie')?.split(' ');
|
||||||
if (cookies === undefined)
|
if (cookies === undefined)
|
||||||
throw new Error("couldn't get response cookies from xuid converter website");
|
throw new ApiError("couldn't get response cookies from xuid converter website");
|
||||||
else if (cookies.length < 11) throw new Error('xuid converter website sent unexpected cookies');
|
else if (cookies.length < 11)
|
||||||
|
throw new ApiError('xuid converter website sent unexpected cookies');
|
||||||
|
|
||||||
const requestBody = new URLSearchParams();
|
const requestBody = new URLSearchParams();
|
||||||
requestBody.set('_token', token);
|
requestBody.set('_token', token);
|
||||||
@ -60,7 +61,7 @@ export async function getBedrockUuid(username: string): Promise<string> {
|
|||||||
'Sec-Fetch-User': '?1',
|
'Sec-Fetch-User': '?1',
|
||||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0',
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0',
|
||||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
|
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
|
||||||
'Accept-Language': 'es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3',
|
'Accept-Language': 'en-US,es;q=0.8,en-US;q=0.5,en;q=0.3',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
import {
|
import { ApiError, getJavaUuid, getNoAuthUuid, UserNotFoundError } from '$lib/server/minecraft';
|
||||||
getBedrockUuid,
|
|
||||||
getJavaUuid,
|
|
||||||
getNoAuthUuid,
|
|
||||||
MojangError,
|
|
||||||
UserNotFoundError
|
|
||||||
} from '$lib/server/minecraft';
|
|
||||||
import { error, type RequestHandler } from '@sveltejs/kit';
|
import { error, type RequestHandler } from '@sveltejs/kit';
|
||||||
import { User } from '$lib/server/database';
|
import { User } from '$lib/server/database';
|
||||||
|
|
||||||
@ -36,7 +30,8 @@ export const POST = (async ({ request }) => {
|
|||||||
uuid = await getJavaUuid(username);
|
uuid = await getJavaUuid(username);
|
||||||
break;
|
break;
|
||||||
case 'bedrock':
|
case 'bedrock':
|
||||||
uuid = await getBedrockUuid(username);
|
uuid = null;
|
||||||
|
// uuid = await getBedrockUuid(username);
|
||||||
break;
|
break;
|
||||||
case 'noauth':
|
case 'noauth':
|
||||||
uuid = getNoAuthUuid(username);
|
uuid = getNoAuthUuid(username);
|
||||||
@ -47,7 +42,7 @@ export const POST = (async ({ request }) => {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof UserNotFoundError) {
|
if (e instanceof UserNotFoundError) {
|
||||||
throw error(400, `Ein Spieler mit dem Namen '${username}' konnte nicht gefunden werden`);
|
throw error(400, `Ein Spieler mit dem Namen '${username}' konnte nicht gefunden werden`);
|
||||||
} else if (e instanceof MojangError) {
|
} else if (e instanceof ApiError) {
|
||||||
console.error((e as Error).message);
|
console.error((e as Error).message);
|
||||||
uuid = null;
|
uuid = null;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user