improve error handling for excludeCredentials on iOS 26 and Android 16+#237
Open
acn-masatadakurihara wants to merge 3 commits intocorbado:mainfrom
Open
Conversation
…redentials-match ASAuthorizationError code 1006 (.matchedExcludedCredential, iOS 18+) indicates the device already holds a credential listed in excludeCredentials. Previously this fell through to the default case and was mapped to "unknown", causing a raw PlatformException to surface instead of ExcludeCredentialsCanNotBeRegisteredException. Closes corbado#232
…rror detection Use case-insensitive substring match (contains) instead of exact string comparison (Objects.equals) for detecting excluded credentials errors. The error message can vary across Android / Google Play Services versions and the previous exact match missed cases where the error arrives as TYPE_INVALID_STATE_ERROR with a different message format. Closes corbado#232
…nhandledAuthenticatorException The register() method's default PlatformException handler used rethrow, leaking raw PlatformExceptions to callers. The authenticate() method already wraps android-unhandled and ios-unhandled codes in UnhandledAuthenticatorException. Apply the same pattern to register() for consistency. Also applies dart format to the file. Closes corbado#232
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Resolves #232
On iOS 26 and Android 16+, calling
register()to re-register an existing passkey throws an unmappedPlatformExceptioninstead of the expectedExcludeCredentialsCanNotBeRegisteredException. This forces consumer applications to implement fragile, platform-specific error string parsing.Root Cause
The issue stems from inconsistent error handling across three layers:
iOS (ErrorExtension.swift)
ASAuthorizationErrorcode 1006 is undocumented and not mappedWKErrorDomainis currently handledAndroid (MessageHandler.java)
Dart (authenticator.dart)
register()method lacks unhandled exception wrappingauthenticate(), it doesn't convert platform errors to Dart exception codesPlatformExceptionbubbles up to consumersSolution
Commit 1: iOS Native Map
ASAuthorizationErrorcode 1006 → "exclude-credentials-match"Commit 2: Android Native Map
Commit 3: Dart Layer Unification
register()matchingauthenticate()ios-unhandledandandroid-unhandledcodes are wrapped asUnhandledAuthenticatorExceptionImpact
No breaking changes — all changes are additive exception mappings
Consumer benefit — can now catch
ExcludeCredentialsCanNotBeRegisteredExceptionconsistentlyAPI consistency —
register()andauthenticate()error handling now alignedTesting
authenticate()References