From 43ae5915a6f1d440af19d6ef8d44bf6ac9f3622d Mon Sep 17 00:00:00 2001 From: Aaron van Meerten Date: Thu, 16 May 2024 13:03:12 -0500 Subject: [PATCH] feat: move jwt to URL hash from search parameters (#14749) * feat: move jwt to URL hash from search parameters * fix lint * comments for future work * comment format * fix to use ts-ignore like previous parseURLParams case --- react/features/base/jwt/functions.ts | 6 +++++- react/features/base/util/uri.ts | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/react/features/base/jwt/functions.ts b/react/features/base/jwt/functions.ts index a500103ade..02c7d62228 100644 --- a/react/features/base/jwt/functions.ts +++ b/react/features/base/jwt/functions.ts @@ -19,7 +19,11 @@ import logger from './logger'; */ export function parseJWTFromURLParams(url: URL | typeof window.location = window.location) { // @ts-ignore - return parseURLParams(url, true, 'search').jwt; + const jwt = parseURLParams(url, true, 'hash').jwt; + + // TODO: eventually remove the search param and only pull from the hash + // @ts-ignore + return jwt ? jwt : parseURLParams(url, true, 'search').jwt; } /** diff --git a/react/features/base/util/uri.ts b/react/features/base/util/uri.ts index 02a86a08ba..9c89c991e5 100644 --- a/react/features/base/util/uri.ts +++ b/react/features/base/util/uri.ts @@ -537,6 +537,7 @@ export function urlObjectToString(o: { [key: string]: any; }): string | undefine const search = new URLSearchParams(url.search); + // TODO: once all available versions are updated to support the jwt in the hash, remove this if (jwt) { search.set('jwt', jwt); } @@ -561,6 +562,14 @@ export function urlObjectToString(o: { [key: string]: any; }): string | undefine let { hash } = url; + if (jwt) { + if (hash.length) { + hash = `${hash}&jwt=${jwt}`; + } else { + hash = `#jwt=${jwt}`; + } + } + for (const urlPrefix of [ 'config', 'iceServers', 'interfaceConfig', 'devices', 'userInfo', 'appData' ]) { const urlParamsArray = _objectToURLParamsArray(