Skip to content

Fix Android Chrome return path breaking same-device completion (#58) - #59

Open
SuperstrongBE wants to merge 2 commits into
XPRNetwork:masterfrom
SuperstrongBE:fix/android-return-path
Open

Fix Android Chrome return path breaking same-device completion (#58)#59
SuperstrongBE wants to merge 2 commits into
XPRNetwork:masterfrom
SuperstrongBE:fix/android-return-path

Conversation

@SuperstrongBE

Copy link
Copy Markdown
Contributor

Summary

Fixes #58: on Android Chrome, the hard-coded android-app://com.android.chrome return_path relaunched Chrome on a fresh tab after signing in WebAuth, orphaning the originating tab's pending ConnectWallet() / session.transact() promise — login and same-device signing never completed.

Three fixes, all in @proton/browser-transport:

  1. Configurable returnUrl — new optional returnUrl?: string | (() => string) on BrowserTransportOptions, used for the return_path info key in both onSessionRequest and displayRequest. Flows through @proton/web-sdk's existing transportOptions spread with no further changes. Non-breaking.
  2. Same-tab return for stock Android ChromegenerateReturnUrl() no longer emits the bare-package Chrome intent; it falls through to window.location.href, so the return lands on the dApp's own origin where session-restore can complete. Intent schemes are kept for Firefox/Edge/Opera/Brave/WebView.
  3. Modernized isMobile() — drops the window.orientation dependency (removed in modern Chrome for Android) in favor of the UA-based isAndroid()/isAppleHandheld() signals, so the same-device trigger and the return-path logic agree on the platform.

Testing

  • pnpm --filter @proton/browser-transport build — OK (cjs, esm, types, bundle)
  • Full monorepo pnpm build — 10/10 turbo tasks OK
  • Real-device Android validation still needed: the bug only manifests with actual OS intent behavior (DevTools emulation does not reproduce it)

🤖 Generated with Claude Code

https://claude.ai/code/session_01FELCBotNWhbd72JvfEB9CN

…twork#58)

On Android Chrome, the hard-coded 'android-app://com.android.chrome'
return_path relaunched Chrome on a fresh tab after signing in WebAuth,
orphaning the originating tab's pending login/transact promise.

- generateReturnUrl(): drop the bare-package Chrome intent and fall
  through to window.location.href so the return lands on the dApp's
  own origin (intent schemes kept for Firefox/Edge/Opera/Brave/WebView)
- isMobile(): stop relying on window.orientation (removed in modern
  Chrome for Android); use the UA-based isAndroid()/isAppleHandheld()
  signals so the same-device trigger and return-path logic agree
- BrowserTransportOptions.returnUrl (string or factory): lets apps
  override return_path with their real URL for their own session-restore

Fixes XPRNetwork#58

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FELCBotNWhbd72JvfEB9CN
@SuperstrongBE
SuperstrongBE marked this pull request as draft July 23, 2026 12:22
On Android the wallet's return navigation always lands in a NEW Chrome
tab (no URL scheme can focus the originating one from another app), so
each same-device sign piled up an extra tab even though the original
tab completes the flow.

Tag the Android return URL with a '#webauth-return' fragment and, when
the transport boots in a tab carrying that marker, call window.close().
Tabs spawned by an external app intent are allowed to close themselves,
which drops the user back on the originating tab. If the close is
denied the tab simply stays on the dApp origin — no regression.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FELCBotNWhbd72JvfEB9CN
@SuperstrongBE

Copy link
Copy Markdown
Contributor Author

Follow-up commit after real-device testing: the flow now completes (the originating tab receives auth / identity proof / payment events), but each same-device sign still opened one extra Chrome tab — on Android the wallet's return navigation always lands in a new tab, since no URL scheme can focus an existing one from another app.

New commit tags the Android return URL with a #webauth-return fragment; when the transport boots in a tab carrying that marker it calls window.close(). Tabs spawned by an external app intent are allowed to self-close, which drops the user back on the originating tab. If the close is denied, the tab just stays on the dApp origin — no regression.

@andreyjamer

Copy link
Copy Markdown
Collaborator

@SuperstrongBE Is this PR still in Draft because you do some extra testing?

@SuperstrongBE

Copy link
Copy Markdown
Contributor Author

Check the issue, I commented after deep dive

// stock Chrome on Android: a bare `android-app://com.android.chrome` intent relaunches
// Chrome on a new tab instead of returning to the originating one, orphaning the pending
// request — fall through to the current URL so the flow completes on the dApp's origin
if (isAndroid()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@SuperstrongBE Does this cover the case when user works in browser different from Chrome? Firefox for example. Previous check had isChromeMobile

@andreyjamer

Copy link
Copy Markdown
Collaborator

Check the issue, I commented after deep dive

Yes, I saw it. I asked WebAuth team to check. But if I understand correctly your PR still fixes several issues, so it worth merging. That's why I wanted to clarify why it is marked as Draft.

@SuperstrongBE
SuperstrongBE marked this pull request as ready for review July 28, 2026 09:08
@SuperstrongBE

Copy link
Copy Markdown
Contributor Author

Check the issue, I commented after deep dive

Yes, I saw it. I asked WebAuth team to check. But if I understand correctly your PR still fixes several issues, so it worth merging. That's why I wanted to clarify why it is marked as Draft.

Got it. I make it ready to review. When webauth team come back, i can iterate to harden the fix if needed.

@SuperstrongBE

Copy link
Copy Markdown
Contributor Author

@andreyjamer waiting for your click on merge:)

@andreyjamer

Copy link
Copy Markdown
Collaborator

@SuperstrongBE Could you check my comment?

@andreyjamer
andreyjamer requested a review from DoDoIndex July 30, 2026 10:46
@andreyjamer andreyjamer self-assigned this Jul 30, 2026
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.

Android Chrome: hard-coded android-app:// return path opens a new tab after signing, breaking same-device session completion

2 participants