From 6d1dd90110404cf69674dab1300aae1dc5a29cc3 Mon Sep 17 00:00:00 2001 From: Erwan Leboucher Date: Wed, 22 Jul 2026 09:05:18 +0200 Subject: [PATCH] fix: restore desktop SSO callback --- src/app/pages/auth/SSOTauri.test.ts | 19 +++++++++++++++++++ src/app/pages/auth/SSOTauri.ts | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/app/pages/auth/SSOTauri.test.ts b/src/app/pages/auth/SSOTauri.test.ts index 377f4680e..c16e9082b 100644 --- a/src/app/pages/auth/SSOTauri.test.ts +++ b/src/app/pages/auth/SSOTauri.test.ts @@ -1,4 +1,5 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { type as osType } from '@tauri-apps/plugin-os'; import { buildTauriSsoRedirectUrl, parseTauriOidcCallback, @@ -12,10 +13,28 @@ vi.mock('@tauri-apps/plugin-os', () => ({ })); beforeEach(() => { + vi.unstubAllEnvs(); + vi.mocked(osType).mockReturnValue('android'); localStorage.clear(); }); describe('buildTauriSsoRedirectUrl', () => { + it('uses the registered deep-link callback in production desktop builds', () => { + vi.stubEnv('DEV', false); + vi.mocked(osType).mockReturnValue('linux'); + + const url = new URL(buildTauriSsoRedirectUrl('https://hs.example')); + + expect(url.protocol).toBe('sable:'); + expect(url.hostname).toBe('login'); + expect(url.pathname).toBe('/lp/sso-callback'); + expect(url.searchParams.get('server')).toBe('https://hs.example'); + const nonce = url.searchParams.get('sso_nonce'); + expect(nonce).toBeTruthy(); + expect(takeTauriSsoNonce()).toBe(nonce); + expect(takeTauriSsoNonce()).toBeUndefined(); + }); + it('embeds the server and stores the same nonce it puts in the url', () => { const url = new URL(buildTauriSsoRedirectUrl('https://hs.example')); expect(url.searchParams.get('server')).toBe('https://hs.example'); diff --git a/src/app/pages/auth/SSOTauri.ts b/src/app/pages/auth/SSOTauri.ts index 6a60baa28..4100a75d4 100644 --- a/src/app/pages/auth/SSOTauri.ts +++ b/src/app/pages/auth/SSOTauri.ts @@ -16,7 +16,7 @@ const getAppBaseUrl = (): string => { return `${TAURI_SSO_PROTOCOL}//${TAURI_SSO_HOST}`; } - return 'https://app.sable.moe'; + return `${TAURI_SSO_PROTOCOL}//${TAURI_SSO_HOST}`; }; type TauriSsoCallback = {