From d8f79dbd2c1e04b05d05a58093d7ccdda9e7c4ea Mon Sep 17 00:00:00 2001 From: cyrus Date: Wed, 11 Mar 2026 17:18:55 +0530 Subject: [PATCH] Refactor OAuth login URLs and improve deep link handling. Updated OAuth provider login URLs to use "responseType=json" for development mode. Enhanced deep link handling by adding support for an additional "key" parameter to distinguish token types. --- skills | 2 +- src/components/oauth/providerConfigs.tsx | 8 ++--- src/utils/desktopDeepLinkListener.ts | 37 ++++++++++++++---------- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/skills b/skills index 88c9c8c8d..e6dd1730e 160000 --- a/skills +++ b/skills @@ -1 +1 @@ -Subproject commit 88c9c8c8d1b567661e1172b0af8c2134608d2ec7 +Subproject commit e6dd1730eb57f897278cceae9763c0d641cd8c3e diff --git a/src/components/oauth/providerConfigs.tsx b/src/components/oauth/providerConfigs.tsx index 34227e34f..601395fbd 100644 --- a/src/components/oauth/providerConfigs.tsx +++ b/src/components/oauth/providerConfigs.tsx @@ -52,7 +52,7 @@ export const oauthProviderConfigs: OAuthProviderConfig[] = [ color: 'bg-white border border-gray-200', hoverColor: 'hover:bg-gray-50 hover:border-gray-300', textColor: 'text-gray-900', - loginUrl: `${BACKEND_URL}/auth/google/login${IS_DEV ? '?debug=true' : ''}`, + loginUrl: `${BACKEND_URL}/auth/google/login?${IS_DEV ? 'responseType=json' : ''}`, }, { id: 'github', @@ -61,7 +61,7 @@ export const oauthProviderConfigs: OAuthProviderConfig[] = [ color: 'bg-gray-900 border border-gray-800', hoverColor: 'hover:bg-gray-800 hover:border-gray-700', textColor: 'text-white', - loginUrl: `${BACKEND_URL}/auth/github/login${IS_DEV ? '?debug=true' : ''}`, + loginUrl: `${BACKEND_URL}/auth/github/login?${IS_DEV ? 'responseType=json' : ''}`, }, { id: 'twitter', @@ -70,7 +70,7 @@ export const oauthProviderConfigs: OAuthProviderConfig[] = [ color: 'bg-black border border-gray-800', hoverColor: 'hover:bg-gray-900 hover:border-gray-700', textColor: 'text-white', - loginUrl: `${BACKEND_URL}/auth/twitter/login${IS_DEV ? '?debug=true' : ''}`, + loginUrl: `${BACKEND_URL}/auth/twitter/login?${IS_DEV ? 'responseType=json' : ''}`, }, { id: 'discord', @@ -79,7 +79,7 @@ export const oauthProviderConfigs: OAuthProviderConfig[] = [ color: 'bg-indigo-600 border border-indigo-500', hoverColor: 'hover:bg-indigo-700 hover:border-indigo-600', textColor: 'text-white', - loginUrl: `${BACKEND_URL}/auth/discord/login${IS_DEV ? '?debug=true' : ''}`, + loginUrl: `${BACKEND_URL}/auth/discord/login?${IS_DEV ? 'responseType=json' : ''}`, }, ]; diff --git a/src/utils/desktopDeepLinkListener.ts b/src/utils/desktopDeepLinkListener.ts index a3956810f..3cd4bcbfb 100644 --- a/src/utils/desktopDeepLinkListener.ts +++ b/src/utils/desktopDeepLinkListener.ts @@ -1,17 +1,13 @@ -import { isTauri as coreIsTauri, invoke } from '@tauri-apps/api/core'; -import { getCurrent, onOpenUrl } from '@tauri-apps/plugin-deep-link'; +import {invoke, isTauri as coreIsTauri} from '@tauri-apps/api/core'; +import {getCurrent, onOpenUrl} from '@tauri-apps/plugin-deep-link'; -import { skillManager } from '../lib/skills/manager'; -import { consumeLoginToken, fetchIntegrationTokens } from '../services/api/authApi'; -import { buildManualSentryEvent, enqueueError } from '../services/errorReportQueue'; -import { store } from '../store'; -import { setToken } from '../store/authSlice'; -import { setSkillState } from '../store/skillsSlice'; -import { - decryptIntegrationTokens, - hexToBase64, - type IntegrationTokensPayload, -} from './integrationTokensCrypto'; +import {skillManager} from '../lib/skills/manager'; +import {consumeLoginToken, fetchIntegrationTokens} from '../services/api/authApi'; +import {buildManualSentryEvent, enqueueError} from '../services/errorReportQueue'; +import {store} from '../store'; +import {setToken} from '../store/authSlice'; +import {setSkillState} from '../store/skillsSlice'; +import {decryptIntegrationTokens, hexToBase64, type IntegrationTokensPayload,} from './integrationTokensCrypto'; function getCurrentUserId(): string | null { const state = store.getState(); @@ -40,11 +36,13 @@ function getCurrentUserId(): string | null { */ const handleAuthDeepLink = async (parsed: URL) => { const token = parsed.searchParams.get('token'); + const key = parsed.searchParams.get('key'); if (!token) { console.warn('[DeepLink] URL did not contain a token query parameter'); return; } + console.log('[DeepLink] Received auth token'); try { @@ -53,9 +51,16 @@ const handleAuthDeepLink = async (parsed: URL) => { console.warn('[DeepLink] Failed to show window:', err); } - const jwtToken = await consumeLoginToken(token); - store.dispatch(setToken(jwtToken)); - window.location.hash = '/onboarding'; + if (key === 'auth') { + store.dispatch(setToken(token)); + window.location.hash = '/onboarding'; + } else { + const jwtToken = await consumeLoginToken(token); + store.dispatch(setToken(jwtToken)); + window.location.hash = '/onboarding'; + } + + }; /**