forked from WikiDeck/wikideck
Android: register @capacitor/browser with src/auth (setNativeBrowser, #37)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+6
-2
@@ -2,6 +2,7 @@
|
|||||||
// On the web it does nothing: relative `/api/...` requests keep going to the serving origin.
|
// On the web it does nothing: relative `/api/...` requests keep going to the serving origin.
|
||||||
import { Capacitor } from '@capacitor/core';
|
import { Capacitor } from '@capacitor/core';
|
||||||
import { App } from '@capacitor/app';
|
import { App } from '@capacitor/app';
|
||||||
|
import { Browser } from '@capacitor/browser';
|
||||||
import './native.css';
|
import './native.css';
|
||||||
|
|
||||||
/** True inside the Android/iOS app shell. Use it to hide desktop-only features such as RandomX mining. */
|
/** 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 (parsed.protocol !== 'dev.eom.wikideck:') return;
|
||||||
if (deepLinkHandlers.size) deepLinkHandlers.forEach(h => h(parsed)); else pendingDeepLink = parsed;
|
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 => {
|
onDeepLink(url => {
|
||||||
void import('./auth/session.ts').then(({ isCallback, completeLogin }) => {
|
void auth.then(({ isCallback, completeLogin }) => {
|
||||||
if (isCallback(url.href)) return completeLogin(url.href);
|
if (isCallback(url.href)) return completeLogin(url.href);
|
||||||
}).catch(error => console.warn('[native] SSO callback failed', error));
|
}).catch(error => console.warn('[native] SSO callback failed', error));
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user