Skip to content

Commit 6d1dd90

Browse files
committed
fix: restore desktop SSO callback
1 parent e6b16c8 commit 6d1dd90

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/app/pages/auth/SSOTauri.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { beforeEach, describe, expect, it, vi } from 'vitest';
2+
import { type as osType } from '@tauri-apps/plugin-os';
23
import {
34
buildTauriSsoRedirectUrl,
45
parseTauriOidcCallback,
@@ -12,10 +13,28 @@ vi.mock('@tauri-apps/plugin-os', () => ({
1213
}));
1314

1415
beforeEach(() => {
16+
vi.unstubAllEnvs();
17+
vi.mocked(osType).mockReturnValue('android');
1518
localStorage.clear();
1619
});
1720

1821
describe('buildTauriSsoRedirectUrl', () => {
22+
it('uses the registered deep-link callback in production desktop builds', () => {
23+
vi.stubEnv('DEV', false);
24+
vi.mocked(osType).mockReturnValue('linux');
25+
26+
const url = new URL(buildTauriSsoRedirectUrl('https://hs.example'));
27+
28+
expect(url.protocol).toBe('sable:');
29+
expect(url.hostname).toBe('login');
30+
expect(url.pathname).toBe('/lp/sso-callback');
31+
expect(url.searchParams.get('server')).toBe('https://hs.example');
32+
const nonce = url.searchParams.get('sso_nonce');
33+
expect(nonce).toBeTruthy();
34+
expect(takeTauriSsoNonce()).toBe(nonce);
35+
expect(takeTauriSsoNonce()).toBeUndefined();
36+
});
37+
1938
it('embeds the server and stores the same nonce it puts in the url', () => {
2039
const url = new URL(buildTauriSsoRedirectUrl('https://hs.example'));
2140
expect(url.searchParams.get('server')).toBe('https://hs.example');

src/app/pages/auth/SSOTauri.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const getAppBaseUrl = (): string => {
1616
return `${TAURI_SSO_PROTOCOL}//${TAURI_SSO_HOST}`;
1717
}
1818

19-
return 'https://app.sable.moe';
19+
return `${TAURI_SSO_PROTOCOL}//${TAURI_SSO_HOST}`;
2020
};
2121

2222
type TauriSsoCallback = {

0 commit comments

Comments
 (0)