mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 11:25:52 -05:00
Co-authored-by: Anthony <anthony@infraly.co> Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
23 lines
664 B
TypeScript
23 lines
664 B
TypeScript
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);
|
|
if (!match) {
|
|
return null;
|
|
}
|
|
|
|
const url = new URL(match[0]);
|
|
if (
|
|
url.origin !== HYTALE_OAUTH_ORIGIN ||
|
|
url.pathname !== HYTALE_DEVICE_VERIFY_PATH ||
|
|
!url.searchParams.get('user_code')
|
|
) {
|
|
return null;
|
|
}
|
|
|
|
return url.href;
|
|
};
|