diff --git a/src/native.ts b/src/native.ts index 8442992..d46c2bd 100644 --- a/src/native.ts +++ b/src/native.ts @@ -2,6 +2,7 @@ // On the web it does nothing: relative `/api/...` requests keep going to the serving origin. import { Capacitor } from '@capacitor/core'; import { App } from '@capacitor/app'; +import { Browser } from '@capacitor/browser'; import './native.css'; /** True inside the Android/iOS app shell. Use it to hide desktop-only features such as RandomX mining. */ @@ -84,9 +85,12 @@ if (isNativeApp()) { if (parsed.protocol !== 'dev.eom.wikideck:') return; if (deepLinkHandlers.size) deepLinkHandlers.forEach(h => h(parsed)); else pendingDeepLink = parsed; }); - // eom.dev SSO return path (src/auth, sso team): finish the PKCE login when Dex redirects back. + // eom.dev SSO (src/auth, sso team). Imported lazily so this module still runs before anything else. + // Login opens Dex in the system browser (Custom Tab); the redirect comes back as a deep link. + const auth = import('./auth/session.ts'); + void auth.then(({ setNativeBrowser }) => setNativeBrowser(Browser)); onDeepLink(url => { - void import('./auth/session.ts').then(({ isCallback, completeLogin }) => { + void auth.then(({ isCallback, completeLogin }) => { if (isCallback(url.href)) return completeLogin(url.href); }).catch(error => console.warn('[native] SSO callback failed', error)); });