Android: register @capacitor/browser with src/auth (setNativeBrowser, #37)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 00:30:18 -05:00
co-authored by Claude Opus 5.5
parent 19e6dc0463
commit 41ba669015
+6 -2
View File
@@ -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));
});