From 4851a32e2307073b5ef104643d86db65c76c3e1e Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 19 Feb 2024 15:51:47 +0000 Subject: [PATCH] Fix Native OIDC for Element Desktop (#1510) --- src/protocol.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/protocol.ts b/src/protocol.ts index 72b2aea..0487309 100644 --- a/src/protocol.ts +++ b/src/protocol.ts @@ -86,8 +86,13 @@ export function getProfileFromDeeplink(args: string[]): string | undefined { if (deeplinkUrl?.includes(SEARCH_PARAM)) { const parsedUrl = new URL(deeplinkUrl); if (parsedUrl.protocol === PROTOCOL) { - const ssoID = parsedUrl.searchParams.get(SEARCH_PARAM)!; const store = readStore(); + let ssoID = parsedUrl.searchParams.get(SEARCH_PARAM); + if (!ssoID) { + // In OIDC, we must shuttle the value in the `state` param rather than `element-desktop-ssoid` + // We encode it as a suffix like `:element-desktop-ssoid:XXYYZZ` + ssoID = parsedUrl.searchParams.get("state")!.split(`:${SEARCH_PARAM}:`)[1]; + } console.log("Forwarding to profile: ", store[ssoID]); return store[ssoID]; }