feat(flow): native cancellation signals and typed bridge errors - #329
Conversation
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
|
🐕 Review complete — View session on Shuni Portal 🐾 |
🐕 Suggested ReviewersThe 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.
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. |
There was a problem hiding this comment.
🐕 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!
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
c2241f5 to
82407a0
Compare
Related Issues
https://github.com/descope/etc/issues/16275
https://github.com/descope/etc/issues/16441
Description
OAuthNativeCancelled/PasskeyCancelled/WebAuthCancelledfailures on native dismissalFlowBridge.bridgeOnErrorparses bridge errors and mapsE102122toDescopeException.flowCancelledMust