mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 09:01:17 -08:00
fix: restore desktop SSO callback
This commit is contained in:
2 files changed
+20
-1
No files matched your search
@@ -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');
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in new issue
Block a user