diff --git a/android/src/main/kotlin/com/onegini/mobile/sdk/flutter/OneWelcomeWrapperErrors.kt b/android/src/main/kotlin/com/onegini/mobile/sdk/flutter/OneWelcomeWrapperErrors.kt index 14c7432d..6bcfcaac 100644 --- a/android/src/main/kotlin/com/onegini/mobile/sdk/flutter/OneWelcomeWrapperErrors.kt +++ b/android/src/main/kotlin/com/onegini/mobile/sdk/flutter/OneWelcomeWrapperErrors.kt @@ -1,5 +1,6 @@ package com.onegini.mobile.sdk.flutter +// When editing these errors, make sure to also update the errors in lib/errors/error_codes.dart enum class OneWelcomeWrapperErrors(val code: Int, val message: String) { GENERIC_ERROR(8000, "Something went wrong"), NOT_AUTHENTICATED_USER(8040, "There is currently no User Profile authenticated"), diff --git a/example/ios/.swiftlint.yml b/example/ios/.swiftlint.yml index e36d81bd..39c7f2d1 100644 --- a/example/ios/.swiftlint.yml +++ b/example/ios/.swiftlint.yml @@ -14,7 +14,7 @@ excluded: # paths to ignore during linting. Takes precedence over `included`. - .swiftlint.yml - OneginiTests - OneginiUITests - - .symlinks/plugins/onegini/ios/Classes/Pigeon.swift + - .symlinks/plugins/onegini/ios/Classes/Pigeon.gen.swift # If true, SwiftLint will not fail if no lintable files are found. allow_zero_lintable_files: false diff --git a/example/lib/screens/user_screen.dart b/example/lib/screens/user_screen.dart index 7750e2dd..5ec3aa12 100644 --- a/example/lib/screens/user_screen.dart +++ b/example/lib/screens/user_screen.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:onegini/errors/error_codes.dart'; import 'package:onegini/events/onewelcome_events.dart'; import 'package:onegini/model/request_details.dart'; import 'package:onegini/onegini.dart'; @@ -83,7 +84,7 @@ class _UserScreenState extends State with RouteAware { _biometricAuthenticator = biometricAuthenticator; }); } on PlatformException catch (err) { - if (err.code != "8060") { + if (err.code != WrapperErrorCodes.biometricAuthenticationNotAvailable) { showFlutterToast(err.message); } } @@ -136,12 +137,11 @@ class _UserScreenState extends State with RouteAware { Onegini.instance.userClient.changePin().catchError((error) { if (error is PlatformException) { showFlutterToast(error.message); - // FIXME: this should be extracted into a seperate method and should also use constants (dont exist yet) - if (error.code == "8002" || - error.code == "9002" || - error.code == "9003" || - error.code == "9010" || - error.code == "10012") { + // FIXME: this should be extracted into a seperate method + if (error.code == WrapperErrorCodes.notAuthenticatedUser || + error.code == PlatformErrorCodes.deviceDeregistered || + error.code == PlatformErrorCodes.userDeregistered || + error.code == PlatformErrorCodes.userNotAuthenticated) { Navigator.pushReplacement( context, MaterialPageRoute(builder: (_) => LoginScreen()), diff --git a/ios/Classes/NativeBridge/Errors/ErrorMapper.swift b/ios/Classes/NativeBridge/Errors/ErrorMapper.swift index b347b63f..1806be38 100644 --- a/ios/Classes/NativeBridge/Errors/ErrorMapper.swift +++ b/ios/Classes/NativeBridge/Errors/ErrorMapper.swift @@ -1,6 +1,7 @@ // swiftlint:disable cyclomatic_complexity import OneginiSDKiOS +// When editing these errors, make sure to also update the errors in lib/errors/error_codes.dart enum OneWelcomeWrapperError { case genericError case notAuthenticatedUser diff --git a/lib/errors/error_codes.dart b/lib/errors/error_codes.dart new file mode 100644 index 00000000..1459d4bf --- /dev/null +++ b/lib/errors/error_codes.dart @@ -0,0 +1,131 @@ +// Dev note: When editing these error codes, make sure to update them in the native wrapper code aswel. + +/// Errors from the flutter sdk, some of these errors can only occur on a single platform. +class WrapperErrorCodes { + static const String genericError = "8000"; + static const String notAuthenticatedUser = "8040"; + static const String notAuthenticatedImplicit = "8041"; + static const String notFoundUserProfile = "8042"; + static const String notFoundAuthenticator = "8043"; + static const String notFoundIdentityProvider = "8044"; + + /// Android only + static const String notFoundSecurityController = "8045"; + + static const String httpRequestErrorInternal = "8046"; + static const String httpRequestErrorCode = "8047"; + + /// iOS only + static const String httpRequestErrorNoResponse = "8048"; + + /// Android only + static const String onewelcomeSdkNotInitialized = "8049"; + + static const String invalidUrl = "8050"; + static const String notInProgressCustomRegistration = "8051"; + static const String notInProgressAuthentication = "8052"; + static const String notInProgressOtpAuthentication = "8053"; + static const String notInProgressPinCreation = "8054"; + static const String notInProgressFingerprintAuthentication = "8055"; + + /// iOS only. Android will throw actionAlreadyInProgress + static const String alreadyInProgressMobileAuth = "8056"; + + static const String actionNotAllowedCustomRegistrationCancel = "8057"; + static const String actionNotAllowedBrowserRegistrationCancel = "8058"; + + /// Android only + static const String configError = "8059"; + + static const String biometricAuthenticationNotAvailable = "8060"; +} + +const String networkConnectivityProblem = "9000"; + +/// Error from the native sdk's, some of these errors can only occur on a single platform. +class PlatformErrorCodes { + static const String networkConnectivityProblem = "9000"; + static const String serverNotReachable = "9001"; + static const String deviceDeregistered = "9002"; + static const String userDeregistered = "9003"; + static const String outdatedApp = "9004"; + static const String outdatedOs = "9005"; + static const String actionCanceled = "9006"; + static const String actionAlreadyInProgress = "9007"; + static const String deviceRegistrationError = "9008"; + + /// iOS only + static const String authenticationErrorInvalidPin = "9009"; + + static const String userNotAuthenticated = "9010"; + static const String pinBlacklisted = "9011"; + static const String pinIsASequence = "9012"; + static const String pinUsesSimilarDigits = "9013"; + static const String wrongPinLength = "9014"; + static const String invalidAuthenticator = "9015"; + static const String deviceAlreadyEnrolled = "9016"; + static const String enrollmentNotAvailable = "9017"; + static const String userAlreadyEnrolled = "9018"; + static const String userDisenrolled = "9020"; + static const String mobileAuthenticationNotEnrolled = "9021"; + static const String authenticatorDeregistered = "9022"; + + /// Android only + static const String mobileAuthenticationDisenrolled = "9023"; + + static const String dataStorageNotAvailable = "9024"; + + /// iOS only + static const String genericErrorUnrecoverableDataState = "9025"; + + /// iOS only + static const String userNotAuthenticatedImplicitly = "9026"; + + static const String customAuthenticatorFailure = "9027"; + + /// iOS only + static const String alreadyHandled = "9029"; + + static const String authenticationErrorBiometricAuthenticatorFailure = "9030"; + + /// Android only + static const String invalidDatetime = "9031"; + + static const String generalError = "10000"; + static const String configurationError = "10001"; + static const String invalidState = "10002"; + static const String localDeregistration = "10003"; + static const String authenticatorAlreadyRegistered = "10004"; + + /// Android only + static const String fidoAuthenticationDisabledDeprecated = "10005"; + + static const String authenticatorNotSupported = "10006"; + static const String authenticatorNotRegistered = "10007"; + static const String authenticatorPinDeregistrationNotPossible = "10008"; + static const String localLogout = "10009"; + + /// iOS only + static const String fetchInvalidMethod = "10010"; + + static const String deviceNotAuthenticated = "10012"; + static const String mobileAuthenticationRequestNotFound = "10013"; + static const String invalidRequest = "10015"; + + /// Android only + static const String fidoServerNotReachableDeprecated = "10016"; + + static const String customAuthenticationDisabled = "10017"; + static const String notHandleable = "10018"; + + /// iOS only + static const String fetchInvalidHeaders = "10019"; + + /// Android only + static const String invalidIdentityProvider = "10020"; + + static const String customRegistrationExpired = "10021"; + static const String customRegistrationFailure = "10022"; + static const String singleSignOnDisabled = "10023"; + static const String appIntegrityFailure = "10024"; +} diff --git a/pubspec.yaml b/pubspec.yaml index 9357c204..69409ca8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 2.0.1 homepage: https://www.onegini.com environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=2.12.0 <4.0.0" flutter: ">=1.12.0" dependencies: