auth: add applinks for auth on android and ios (#302)

This commit is contained in:
Huang Xin
2025-02-06 16:16:15 +01:00
committed by GitHub
parent 4121195fd3
commit 8bd9e18381
4 changed files with 42 additions and 13 deletions
@@ -0,0 +1,17 @@
{
"applinks": {
"details": [
{
"appIDs": [
"J5W48D69VR.com.bilingify.readest"
],
"components": [
{
"/": "/auth/*",
"comment": "Matches any URL whose path starts with /auth/"
}
]
}
]
}
}
@@ -0,0 +1,12 @@
[
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.bilingify.readest",
"sha256_cert_fingerprints": [
"65:2D:11:67:76:12:29:14:18:42:CB:3D:18:50:B6:E4:7E:46:E1:2F:4B:E4:7F:5A:6C:14:B6:D7:12:74:1E:82"
]
}
}
]
@@ -56,6 +56,9 @@
"section": "text"
}
},
"android": {
"minSdkVersion": 26
},
"fileAssociations": [
{
"name": "epub",
+10 -13
View File
@@ -7,7 +7,6 @@ import { Auth } from '@supabase/auth-ui-react';
import { ThemeSupa } from '@supabase/auth-ui-shared';
import { FcGoogle } from 'react-icons/fc';
import { FaApple } from 'react-icons/fa';
import { VscAzure } from 'react-icons/vsc';
import { FaGithub } from 'react-icons/fa';
import { IoArrowBack } from 'react-icons/io5';
@@ -21,6 +20,7 @@ import { onOpenUrl } from '@tauri-apps/plugin-deep-link';
import { start, cancel, onUrl, onInvalidUrl } from '@fabianlars/tauri-plugin-oauth';
import { openUrl } from '@tauri-apps/plugin-opener';
import { handleAuthCallback } from '@/helpers/auth';
import { getOSPlatform } from '@/utils/misc';
type OAuthProvider = 'google' | 'apple' | 'azure' | 'github';
@@ -60,8 +60,9 @@ export default function AuthPage() {
const [port, setPort] = useState<number | null>(null);
const isOAuthServerRunning = useRef(false);
const [isMounted, setIsMounted] = useState(false);
const osPlatform = getOSPlatform();
const signIn = async (provider: OAuthProvider) => {
const tauriSignIn = async (provider: OAuthProvider) => {
if (!supabase) {
throw new Error('No backend connected');
}
@@ -72,7 +73,9 @@ export default function AuthPage() {
skipBrowserRedirect: true,
redirectTo:
process.env.NODE_ENV === 'production'
? 'readest://auth/callback'
? ['android', 'ios'].includes(osPlatform)
? 'https://web.readest.com/auth/callback'
: 'readest://auth/callback'
: `http://localhost:${port}`,
},
});
@@ -200,25 +203,19 @@ export default function AuthPage() {
<div style={{ maxWidth: '420px', margin: 'auto', padding: '2rem' }}>
<ProviderLogin
provider='google'
handleSignIn={signIn}
handleSignIn={tauriSignIn}
Icon={FcGoogle}
label='Sign in with Google'
/>
<ProviderLogin
provider='apple'
handleSignIn={signIn}
handleSignIn={tauriSignIn}
Icon={FaApple}
label='Sign in with Apple'
/>
<ProviderLogin
provider='azure'
handleSignIn={signIn}
Icon={VscAzure}
label='Sign in with Azure'
/>
<ProviderLogin
provider='github'
handleSignIn={signIn}
handleSignIn={tauriSignIn}
Icon={FaGithub}
label='Sign in with GitHub'
/>
@@ -246,7 +243,7 @@ export default function AuthPage() {
appearance={{ theme: ThemeSupa }}
theme={isDarkMode ? 'dark' : 'light'}
magicLink={true}
providers={['google', 'apple', 'azure', 'github']}
providers={['google', 'apple', 'github']}
redirectTo='/auth/callback'
/>
</div>