Skip to content

Conversation

ahmedhamouda78
Copy link
Member

@ahmedhamouda78 ahmedhamouda78 commented Aug 26, 2025

Description of changes

This PR adds authentication support for Chromebook devices in the rtn-web-browser package. The changes include:

  • Added isChromebook() function to detect Chromebook devices using Expo Device API and native ChromeOS module
  • Implemented openAuthSessionChromeOs() function to handle auth sessions on Chromebook using Linking.openURL() instead of native browser tabs
  • Updated openAuthSessionAsync() to detect Chromebook devices and route to the appropriate auth session handler
  • Enhanced Android auth flow to fallback gracefully when Chromebook detection fails

Issue #, if available

#14459

Description of how you validated changes

Checklist

  • PR description included
  • yarn test passes
  • Unit Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

Checklist for repo maintainers

  • Verify E2E tests for existing workflows are working as expected or add E2E tests for newly added workflows
  • New source file paths included in this PR have been added to CODEOWNERS, if appropriate

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

pranavosu
pranavosu previously approved these changes Aug 28, 2025
export async function isChromebook(): Promise<boolean> {
// expo go
try {
const Device = require('expo-device');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand.

do we expect users to install expo-device optionally on their own?

why not include it as a dependency? and if we cannot include it as a dependency, why is this logic needed at all?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't require expo-device as a dependency. However, customers are free to use it with their Amplify react-native apps, so this line is just to support device detection in case customers are using expo. If customers are not using expo, we fallback to NativeModules on line 36

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it. thanks for the explanation

getAppStatePromise(),
]),
Linking.openURL(url),
]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is hard to follow.

this races between, 2 promises

  1. whenever a "linking" event happens
  2. when the app leaves inactive state and becomes active.

and then this race is part of an all, which resolves when the race resolved and an url has been opened.


doesn't Linking.openURL automatically mean that getRedirectPromise gets resolved.
as a result the same URL, which was just opened gets returned by this Promise construct
because:

if (redirectUrls.some(url => event.url.startsWith(url))) {
				resolve(event.url);
}

as

  1. getRedirectPromise sets up a listener on "Linking"-url change and resolves with that URL when this happens
  2. getAppStatePromise sets up a listener on "going active" and resolves with null
  3. openURL - navigates

so that.

  1. navigate.
  2. getRedirectPromise-emits
  3. redirectUrl === url

and then this makes another call to openURL with the same URL

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved this offline.

the solution uses Linking instead of native navigation if the latter fails to open the URL

export async function isChromebook(): Promise<boolean> {
// expo go
try {
const Device = require('expo-device');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it. thanks for the explanation

getAppStatePromise(),
]),
Linking.openURL(url),
]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved this offline.

the solution uses Linking instead of native navigation if the latter fails to open the URL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants