Download mobile/src/utils/auth/openAuthBrowser.ts from Anirudh1950/MentraOS: direct link, hf CLI and curl.
- Browser
- Download file 847 Bytes
-
https://huggingface.co/Anirudh1950/MentraOS/resolve/main/mobile/src/utils/auth/openAuthBrowser.ts
- Command line
-
hf download hf://Anirudh1950/MentraOS/mobile/src/utils/auth/openAuthBrowser.ts
-
curl -L -o openAuthBrowser.ts https://huggingface.co/Anirudh1950/MentraOS/resolve/main/mobile/src/utils/auth/openAuthBrowser.ts
847 Bytes
| import * as WebBrowser from "expo-web-browser" | |
| import {Platform} from "react-native" | |
| /** Returns false when the user cancels, so the caller can leave the sign-in screen. */ | |
| export async function openAuthBrowser(url: string, processUrl: (url: string) => Promise<void>): Promise<boolean> { | |
| if (Platform.OS === "ios") { | |
| // Preserve the in-app Safari flow without the auth-session consent prompt. | |
| // DeeplinkProvider completes the handoff and dismisses this browser; the | |
| // user's Done button produces "cancel" instead of "dismiss". | |
| const result = await WebBrowser.openBrowserAsync(url) | |
| return result.type === "dismiss" | |
| } | |
| const result = await WebBrowser.openAuthSessionAsync(url, "com.mentra://auth/callback") | |
| if (result.type !== "success") return false | |
| await processUrl(result.url) | |
| return true | |
| } | |