mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-04 01:19:41 +00:00
feat(desktop): use healthchat:// deep-link scheme instead of element://
Switch the friendly deep-link / legacy SSO callback scheme from element:// to healthchat:// and stop registering element:// entirely. The reverse-DNS OIDC primary scheme (ch.healthchat.desktop://) is unchanged. Also rebrand the round-tripped SSO id param element-desktop-ssoid -> healthchat-desktop-ssoid on both the desktop and web sides.
This commit is contained in:
@@ -47,7 +47,7 @@ describe("ProtocolHandler", () => {
|
|||||||
expect(
|
expect(
|
||||||
handler.getProfileFromDeeplink([
|
handler.getProfileFromDeeplink([
|
||||||
"Element.app",
|
"Element.app",
|
||||||
`element://vector/webapp/?element-desktop-ssoid=${TEST_SESSION_ID}`,
|
`healthchat://vector/webapp/?healthchat-desktop-ssoid=${TEST_SESSION_ID}`,
|
||||||
]),
|
]),
|
||||||
).toBe(USER_DATA_DIR);
|
).toBe(USER_DATA_DIR);
|
||||||
});
|
});
|
||||||
@@ -56,7 +56,7 @@ describe("ProtocolHandler", () => {
|
|||||||
expect(
|
expect(
|
||||||
handler.getProfileFromDeeplink([
|
handler.getProfileFromDeeplink([
|
||||||
"Element.app",
|
"Element.app",
|
||||||
`${TEST_PROTOCOL}:/vector/webapp/?no_universal_links=true&code=DEADBEEF&state=foobar:element-desktop-ssoid:${TEST_SESSION_ID}`,
|
`${TEST_PROTOCOL}:/vector/webapp/?no_universal_links=true&code=DEADBEEF&state=foobar:healthchat-desktop-ssoid:${TEST_SESSION_ID}`,
|
||||||
]),
|
]),
|
||||||
).toBe(USER_DATA_DIR);
|
).toBe(USER_DATA_DIR);
|
||||||
});
|
});
|
||||||
@@ -65,7 +65,7 @@ describe("ProtocolHandler", () => {
|
|||||||
expect(
|
expect(
|
||||||
handler.getProfileFromDeeplink([
|
handler.getProfileFromDeeplink([
|
||||||
"Element.app",
|
"Element.app",
|
||||||
`${TEST_PROTOCOL}:/vector/webapp/?no_universal_links=true#code=DEADBEEF&state=foobar:element-desktop-ssoid:${TEST_SESSION_ID}`,
|
`${TEST_PROTOCOL}:/vector/webapp/?no_universal_links=true#code=DEADBEEF&state=foobar:healthchat-desktop-ssoid:${TEST_SESSION_ID}`,
|
||||||
]),
|
]),
|
||||||
).toBe(USER_DATA_DIR);
|
).toBe(USER_DATA_DIR);
|
||||||
});
|
});
|
||||||
@@ -74,7 +74,7 @@ describe("ProtocolHandler", () => {
|
|||||||
expect(
|
expect(
|
||||||
handler.getProfileFromDeeplink([
|
handler.getProfileFromDeeplink([
|
||||||
"Element.app",
|
"Element.app",
|
||||||
`${TEST_PROTOCOL}:/vector/webapp/?no_universal_links=true#code=DEADBEEF:element-desktop-ssoid:${TEST_SESSION_ID}`,
|
`${TEST_PROTOCOL}:/vector/webapp/?no_universal_links=true#code=DEADBEEF:healthchat-desktop-ssoid:${TEST_SESSION_ID}`,
|
||||||
]),
|
]),
|
||||||
).toBeUndefined();
|
).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import path from "node:path";
|
|||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import { randomUUID } from "node:crypto";
|
import { randomUUID } from "node:crypto";
|
||||||
|
|
||||||
const LEGACY_PROTOCOL = "element";
|
const LEGACY_PROTOCOL = "healthchat";
|
||||||
const SEARCH_PARAM = "element-desktop-ssoid";
|
const SEARCH_PARAM = "healthchat-desktop-ssoid";
|
||||||
const STORE_FILE_NAME = "sso-sessions.json";
|
const STORE_FILE_NAME = "sso-sessions.json";
|
||||||
|
|
||||||
// we getPath userData before electron-main changes it, so this is the default value
|
// we getPath userData before electron-main changes it, so this is the default value
|
||||||
@@ -130,8 +130,8 @@ export default class ProtocolHandler {
|
|||||||
const store = this.readStore();
|
const store = this.readStore();
|
||||||
let sessionId = parsedUrl.searchParams.get(SEARCH_PARAM);
|
let sessionId = parsedUrl.searchParams.get(SEARCH_PARAM);
|
||||||
if (!sessionId) {
|
if (!sessionId) {
|
||||||
// In OIDC, we must shuttle the value in the `state` param rather than `element-desktop-ssoid`
|
// In OIDC, we must shuttle the value in the `state` param rather than `healthchat-desktop-ssoid`
|
||||||
// We encode it as a suffix like `:element-desktop-ssoid:XXYYZZ`.
|
// We encode it as a suffix like `:healthchat-desktop-ssoid:XXYYZZ`.
|
||||||
// The OIDC flow may have used response_mode=fragment or query, so we need to handle both cases.
|
// The OIDC flow may have used response_mode=fragment or query, so we need to handle both cases.
|
||||||
let searchParams = parsedUrl.searchParams;
|
let searchParams = parsedUrl.searchParams;
|
||||||
if (parsedUrl.hash.includes("=")) {
|
if (parsedUrl.hash.includes("=")) {
|
||||||
|
|||||||
@@ -456,7 +456,7 @@ export default abstract class BasePlatform {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Suffix to append to the `state` parameter of OIDC /auth calls. Will be round-tripped to the callback URI.
|
* Suffix to append to the `state` parameter of OIDC /auth calls. Will be round-tripped to the callback URI.
|
||||||
* Currently only required for ElectronPlatform for passing element-desktop-ssoid.
|
* Currently only required for ElectronPlatform for passing healthchat-desktop-ssoid.
|
||||||
*/
|
*/
|
||||||
public getOidcClientState(): string {
|
public getOidcClientState(): string {
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ interface SquirrelUpdate {
|
|||||||
updateURL: string;
|
updateURL: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SSO_ID_KEY = "element-desktop-ssoid";
|
const SSO_ID_KEY = "healthchat-desktop-ssoid";
|
||||||
|
|
||||||
function platformFriendlyName(): string {
|
function platformFriendlyName(): string {
|
||||||
// used to use window.process but the same info is available here
|
// used to use window.process but the same info is available here
|
||||||
@@ -466,7 +466,7 @@ export default class ElectronPlatform extends BasePlatform {
|
|||||||
|
|
||||||
public getSSOCallbackUrl(fragmentAfterLogin?: string): URL {
|
public getSSOCallbackUrl(fragmentAfterLogin?: string): URL {
|
||||||
const url = super.getSSOCallbackUrl(fragmentAfterLogin);
|
const url = super.getSSOCallbackUrl(fragmentAfterLogin);
|
||||||
url.protocol = "element";
|
url.protocol = "healthchat";
|
||||||
url.searchParams.set(SSO_ID_KEY, this.sessionId);
|
url.searchParams.set(SSO_ID_KEY, this.sessionId);
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ describe("ElectronPlatform", () => {
|
|||||||
it("should return oidc client state as expected", async () => {
|
it("should return oidc client state as expected", async () => {
|
||||||
const platform = new ElectronPlatform();
|
const platform = new ElectronPlatform();
|
||||||
await platform.getConfig();
|
await platform.getConfig();
|
||||||
expect(platform.getOidcClientState()).toMatchInlineSnapshot(`":element-desktop-ssoid:session-id"`);
|
expect(platform.getOidcClientState()).toMatchInlineSnapshot(`":healthchat-desktop-ssoid:session-id"`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("dispatches view settings action on preferences event", () => {
|
it("dispatches view settings action on preferences event", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user