Files

25 lines
666 B
TypeScript
Raw Permalink Normal View History

2026-10-05 18:10:18 -04:00
const HYTALE_OAUTH_ORIGIN = 'https://oauth.accounts.hytale.com';
const HYTALE_DEVICE_VERIFY_PATH = '/oauth2/device/verify';
export const hytaleOauthUrlPattern = /https:\/\/oauth\.accounts\.hytale\.com\/oauth2\/device\/verify\?user_code=[\w-]+/;
export const extractHytaleOauthUrl = (line: string): string | null => {
const match = hytaleOauthUrlPattern.exec(line);
2026-10-08 16:53:20 -04:00
2026-10-05 18:10:18 -04:00
if (!match) {
return null;
}
const url = new URL(match[0]);
2026-10-08 16:53:20 -04:00
2026-10-05 18:10:18 -04:00
if (
url.origin !== HYTALE_OAUTH_ORIGIN ||
url.pathname !== HYTALE_DEVICE_VERIFY_PATH ||
!url.searchParams.get('user_code')
) {
return null;
}
return url.href;
};