Skip to content

feat(flow): native cancellation signals and typed bridge errors - #329

Merged
itaihanski merged 3 commits into
mainfrom
feat/native-cancellation
Jun 30, 2026
Merged

feat(flow): native cancellation signals and typed bridge errors#329
itaihanski merged 3 commits into
mainfrom
feat/native-cancellation

Conversation

@itaihanski

@itaihanski itaihanski commented Jun 30, 2026

Copy link
Copy Markdown
Member

Related Issues

https://github.com/descope/etc/issues/16275
https://github.com/descope/etc/issues/16441

Description

  • OAuthNativeCancelled / PasskeyCancelled / WebAuthCancelled failures on native dismissal
  • FlowBridge.bridgeOnError parses bridge errors and maps E102122 to DescopeException.flowCancelled

Must

  • Tests
  • Documentation

ActivityHelper.openCustomTab gains an optional onCancel callback that's
registered JIT (lifecycle-bound to the current launch) so it can't
outlive the tab or be hijacked by a different caller. The helper
activity invokes it on the close branch of onResume; closeCustomTab
clears it. launchCustomTab threads onCancel through.

No call sites use it yet; subsequent commits wire it into WebAuth.
…/WebAuth dismissal

Return Failure("OAuthNativeCancelled") / Failure("PasskeyCancelled") /
Failure("WebAuthCancelled") instead of silently dropping the request
when the user dismisses a native OAuth prompt, a passkey prompt, or the
custom-tab-based WebAuth flow. The flow web layer now forwards a
routable cancellation to the backend (matching the iOS SDK) instead of
leaving the flow hanging.

WebAuth uses the new per-launch onCancel callback on launchCustomTab so
the cancellation signal is bounded to the active launch and can't be
hijacked by a later one.

Relates to descope/etc#16275
@shuni-bot-dev

shuni-bot-dev Bot commented Jun 30, 2026

Copy link
Copy Markdown

🐕 Review complete — View session on Shuni Portal 🐾

@shuni-bot-dev

shuni-bot-dev Bot commented Jun 30, 2026

Copy link
Copy Markdown

🐕 Suggested Reviewers

The reviewer selection prioritizes recent contributors who have worked on core flow and activity management files, ensuring familiarity with the specific changes related to cancellation signals and error handling.

Reviewer Reason
shilgapira Recent contributor who modified multiple core files related to flow handling and activity management, including DescopeFlowBridge.kt, DescopeFlowCoordinator.kt, and DescopeHelperActivity.kt, making them well-suited to review changes in these areas.
shilgapira Extensive recent modifications to the core classes involved suggest familiarity with the implementation details and recent development focus.

Suggested by Shuni based on git history and PR context. Names are not @-mentioned to avoid notifying anyone — request a review from whoever fits best.

@itaihanski
itaihanski requested a review from shilgapira June 30, 2026 08:43

@shuni-bot-dev shuni-bot-dev Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🐕 Shuni's Review

Adds native cancellation signals (OAuth/Passkey/WebAuth) and typed bridge errors, and relocates parseServerError. I traced the cancel paths — success clears the callback via closeCustomTab before the helper activity re-resumes, so no double-response. Good bones!

Sniffed out 1 issue:

  • 1 🟡 MEDIUM: cancel callback retained on the global singleton when launch throws

See inline comment for details. Woof!

Comment thread descopesdk/src/main/java/com/descope/internal/others/ActivityHelper.kt Outdated
Move parseServerError from internal/http/ClientErrors.kt to
internal/others/Errors.kt — the parser is a general-purpose JSON-to-
DescopeException converter, not an HTTP concern. DescopeClient picks
it up at its new location; ClientErrors.kt is left with the HTTP
response-code handling that's actually its job.

Apply parseServerError to the JS-bridge error channel too:
FlowBridge.bridgeOnError now parses the incoming error string as a
typed DescopeException. Server-emitted flow cancellation (errorCode
E102122) collapses onto the existing DescopeException.flowCancelled
identity, carrying the server's errorMessage as the exception message
for context.

Relates to descope/etc#16441
@itaihanski
itaihanski merged commit 2b8b98d into main Jun 30, 2026
11 checks passed
@itaihanski
itaihanski deleted the feat/native-cancellation branch June 30, 2026 12:03
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.

2 participants