Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions flutter_reach_five/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.0.5

- **FEAT**: Add `PasswordTooWeakException` thrown when trying to set a password that is too weak or that has leaked

# 2.0.4

- **FEAT**: Add `AccountTemporarilySuspendedException` thrown when an account is temporarily suspended (for example because of a detected usage of leaked credentials)
Expand Down
3 changes: 3 additions & 0 deletions flutter_reach_five/lib/helpers/adapt_errors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@ Never adaptErrors({required Object error, required StackTrace stackTrace}) {
if (error is AccountTemporarilySuspendedExceptionInterface) {
throw AccountTemporarilySuspendedException(error.message);
}
if (error is PasswordTooWeakExceptionInterface) {
throw PasswordTooWeakException();
}
Error.throwWithStackTrace(error, stackTrace);
}
5 changes: 5 additions & 0 deletions flutter_reach_five/lib/models/errors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,8 @@ class AccountTemporarilySuspendedException extends FormatException {
/// {@macro flutter_reach_five.errors.account_temporarily_suspended}
const AccountTemporarilySuspendedException([super.message = '']);
}

/// {@template flutter_reach_five.errors.password_too_weak}
/// Error thrown when trying to set a password that is too weak or that has leaked
/// {@endtemplate}
class PasswordTooWeakException implements Exception {}
8 changes: 4 additions & 4 deletions flutter_reach_five/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_reach_five
description: This package allows you to use the methods from the reachFive android and ios native sdks in Flutter
version: 2.0.4
version: 2.0.5
homepage: https://github.com/bamlab/Flutter-ReachFive
repository: https://github.com/bamlab/Flutter-ReachFive

Expand All @@ -22,9 +22,9 @@ dependencies:
equatable: ^2.0.5
flutter:
sdk: flutter
flutter_reach_five_android: ^2.0.4
flutter_reach_five_ios: ^2.0.4
flutter_reach_five_platform_interface: ^2.0.4
flutter_reach_five_android: ^2.0.5
flutter_reach_five_ios: ^2.0.5
flutter_reach_five_platform_interface: ^2.0.5
freezed: ^3.2.3
freezed_annotation: ^3.1.0
reach_five_identity_repo: ^2.0.0
Expand Down
15 changes: 15 additions & 0 deletions flutter_reach_five/test/helpers/adapt_errors_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,5 +203,20 @@ void main() {

expect(error, isA<AccountTemporarilySuspendedException>());
});

test('$PasswordTooWeakException', () async {
Object? error;

try {
adaptErrors(
error: PasswordTooWeakExceptionInterface(),
stackTrace: StackTrace.fromString('test'),
);
} catch (e) {
error = e;
}

expect(error, isA<PasswordTooWeakException>());
});
});
}
4 changes: 4 additions & 0 deletions flutter_reach_five_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.0.5

- **FEAT**: Handle password too weak error (`password_too_weak`)

# 2.0.4

- **FEAT**: Handle account temporarily suspended error (`error.account.temporarilySuspended`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ class Converters {
details = null
)
}
if (reachFiveError.data?.error == "password_too_weak") {
val errorCode = errorCodesInterface.passwordTooWeakError
return FlutterError(
code= errorCode,
message= null,
details = null
)
}
return defaultFlutterError
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ data class ErrorCodesInterface (
val accountBlockedAfterMultipleLoginAttempts: String,
val tooManyAttempts: String,
val passwordPolicyError: String,
val accountTemporarilySuspended: String
val accountTemporarilySuspended: String,
val passwordTooWeakError: String
)
{
companion object {
Expand All @@ -245,7 +246,8 @@ data class ErrorCodesInterface (
val tooManyAttempts = pigeonVar_list[9] as String
val passwordPolicyError = pigeonVar_list[10] as String
val accountTemporarilySuspended = pigeonVar_list[11] as String
return ErrorCodesInterface(emailAlreadyInUseCode, invalidEmailOrPasswordCode, invalidVerificationCode, updateSamePassword, invalidGrant, userCancelledOrClosedTheWebFlow, socialAccountEmailAlreadyInUse, unauthorizedRefreshToken, accountBlockedAfterMultipleLoginAttempts, tooManyAttempts, passwordPolicyError, accountTemporarilySuspended)
val passwordTooWeakError = pigeonVar_list[12] as String
return ErrorCodesInterface(emailAlreadyInUseCode, invalidEmailOrPasswordCode, invalidVerificationCode, updateSamePassword, invalidGrant, userCancelledOrClosedTheWebFlow, socialAccountEmailAlreadyInUse, unauthorizedRefreshToken, accountBlockedAfterMultipleLoginAttempts, tooManyAttempts, passwordPolicyError, accountTemporarilySuspended, passwordTooWeakError)
}
}
fun toList(): List<Any?> {
Expand All @@ -262,6 +264,7 @@ data class ErrorCodesInterface (
tooManyAttempts,
passwordPolicyError,
accountTemporarilySuspended,
passwordTooWeakError,
)
}
override fun equals(other: Any?): Boolean {
Expand All @@ -272,7 +275,7 @@ data class ErrorCodesInterface (
return true
}
val other = other as ErrorCodesInterface
return ReachFiveApiPigeonUtils.deepEquals(this.emailAlreadyInUseCode, other.emailAlreadyInUseCode) && ReachFiveApiPigeonUtils.deepEquals(this.invalidEmailOrPasswordCode, other.invalidEmailOrPasswordCode) && ReachFiveApiPigeonUtils.deepEquals(this.invalidVerificationCode, other.invalidVerificationCode) && ReachFiveApiPigeonUtils.deepEquals(this.updateSamePassword, other.updateSamePassword) && ReachFiveApiPigeonUtils.deepEquals(this.invalidGrant, other.invalidGrant) && ReachFiveApiPigeonUtils.deepEquals(this.userCancelledOrClosedTheWebFlow, other.userCancelledOrClosedTheWebFlow) && ReachFiveApiPigeonUtils.deepEquals(this.socialAccountEmailAlreadyInUse, other.socialAccountEmailAlreadyInUse) && ReachFiveApiPigeonUtils.deepEquals(this.unauthorizedRefreshToken, other.unauthorizedRefreshToken) && ReachFiveApiPigeonUtils.deepEquals(this.accountBlockedAfterMultipleLoginAttempts, other.accountBlockedAfterMultipleLoginAttempts) && ReachFiveApiPigeonUtils.deepEquals(this.tooManyAttempts, other.tooManyAttempts) && ReachFiveApiPigeonUtils.deepEquals(this.passwordPolicyError, other.passwordPolicyError) && ReachFiveApiPigeonUtils.deepEquals(this.accountTemporarilySuspended, other.accountTemporarilySuspended)
return ReachFiveApiPigeonUtils.deepEquals(this.emailAlreadyInUseCode, other.emailAlreadyInUseCode) && ReachFiveApiPigeonUtils.deepEquals(this.invalidEmailOrPasswordCode, other.invalidEmailOrPasswordCode) && ReachFiveApiPigeonUtils.deepEquals(this.invalidVerificationCode, other.invalidVerificationCode) && ReachFiveApiPigeonUtils.deepEquals(this.updateSamePassword, other.updateSamePassword) && ReachFiveApiPigeonUtils.deepEquals(this.invalidGrant, other.invalidGrant) && ReachFiveApiPigeonUtils.deepEquals(this.userCancelledOrClosedTheWebFlow, other.userCancelledOrClosedTheWebFlow) && ReachFiveApiPigeonUtils.deepEquals(this.socialAccountEmailAlreadyInUse, other.socialAccountEmailAlreadyInUse) && ReachFiveApiPigeonUtils.deepEquals(this.unauthorizedRefreshToken, other.unauthorizedRefreshToken) && ReachFiveApiPigeonUtils.deepEquals(this.accountBlockedAfterMultipleLoginAttempts, other.accountBlockedAfterMultipleLoginAttempts) && ReachFiveApiPigeonUtils.deepEquals(this.tooManyAttempts, other.tooManyAttempts) && ReachFiveApiPigeonUtils.deepEquals(this.passwordPolicyError, other.passwordPolicyError) && ReachFiveApiPigeonUtils.deepEquals(this.accountTemporarilySuspended, other.accountTemporarilySuspended) && ReachFiveApiPigeonUtils.deepEquals(this.passwordTooWeakError, other.passwordTooWeakError)
}

override fun hashCode(): Int {
Expand All @@ -289,6 +292,7 @@ data class ErrorCodesInterface (
result = 31 * result + ReachFiveApiPigeonUtils.deepHash(this.tooManyAttempts)
result = 31 * result + ReachFiveApiPigeonUtils.deepHash(this.passwordPolicyError)
result = 31 * result + ReachFiveApiPigeonUtils.deepHash(this.accountTemporarilySuspended)
result = 31 * result + ReachFiveApiPigeonUtils.deepHash(this.passwordTooWeakError)
return result
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class FlutterReachFiveAndroid extends FlutterReachFivePlatform {
throw AccountTemporarilySuspendedExceptionInterface(
error.message ?? '',
);
} else if (errorCode.contains(errorCodesInterface.passwordTooWeakError)) {
throw PasswordTooWeakExceptionInterface();
}
}
return Error.throwWithStackTrace(error, stackTrace);
Expand Down
4 changes: 2 additions & 2 deletions flutter_reach_five_android/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_reach_five_android
description: Android implementation of the flutter_reach_five plugin
version: 2.0.4
version: 2.0.5
homepage: https://github.com/bamlab/Flutter-ReachFive

environment:
Expand All @@ -19,7 +19,7 @@ flutter:
dependencies:
flutter:
sdk: flutter
flutter_reach_five_platform_interface: ^2.0.4
flutter_reach_five_platform_interface: ^2.0.5

dev_dependencies:
flutter_test:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,26 @@ void main() {

expect(error, isA<AccountTemporarilySuspendedExceptionInterface>());
});

test('$PasswordTooWeakExceptionInterface', () {
final exception = PlatformException(
code: 'Error - ${errorCodesInterface.passwordTooWeakError}',
message: 'FlutterError',
);

Object? error;

try {
FlutterReachFiveAndroid().parseError(
exception,
StackTrace.fromString('test'),
);
} catch (e) {
error = e;
}

expect(error, isA<PasswordTooWeakExceptionInterface>());
});
});
});
}
4 changes: 4 additions & 0 deletions flutter_reach_five_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.0.5

- **FEAT**: Handle password too weak error (`password_too_weak`)

# 2.0.4

- **FEAT**: Handle account temporarily suspended error (`error.account.temporarilySuspended`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ public class Converters {
details: nil
)
}
if (apiError.error == "password_too_weak") {
return PigeonError(
code: errorCodesInterface.passwordTooWeakError,
message: nil,
details: nil
)
}
return defaultFlutterError
case .AuthFailure(reason: _, apiError: let apiError):
if (apiError?.errorMessageKey == "error.invalidEmailOrPassword") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ struct ErrorCodesInterface: Hashable {
var tooManyAttempts: String
var passwordPolicyError: String
var accountTemporarilySuspended: String
var passwordTooWeakError: String


// swift-format-ignore: AlwaysUseLowerCamelCase
Expand All @@ -215,6 +216,7 @@ struct ErrorCodesInterface: Hashable {
let tooManyAttempts = pigeonVar_list[9] as! String
let passwordPolicyError = pigeonVar_list[10] as! String
let accountTemporarilySuspended = pigeonVar_list[11] as! String
let passwordTooWeakError = pigeonVar_list[12] as! String

return ErrorCodesInterface(
emailAlreadyInUseCode: emailAlreadyInUseCode,
Expand All @@ -228,7 +230,8 @@ struct ErrorCodesInterface: Hashable {
accountBlockedAfterMultipleLoginAttempts: accountBlockedAfterMultipleLoginAttempts,
tooManyAttempts: tooManyAttempts,
passwordPolicyError: passwordPolicyError,
accountTemporarilySuspended: accountTemporarilySuspended
accountTemporarilySuspended: accountTemporarilySuspended,
passwordTooWeakError: passwordTooWeakError
)
}
func toList() -> [Any?] {
Expand All @@ -245,13 +248,14 @@ struct ErrorCodesInterface: Hashable {
tooManyAttempts,
passwordPolicyError,
accountTemporarilySuspended,
passwordTooWeakError,
]
}
static func == (lhs: ErrorCodesInterface, rhs: ErrorCodesInterface) -> Bool {
if Swift.type(of: lhs) != Swift.type(of: rhs) {
return false
}
return deepEqualsreach_five_api(lhs.emailAlreadyInUseCode, rhs.emailAlreadyInUseCode) && deepEqualsreach_five_api(lhs.invalidEmailOrPasswordCode, rhs.invalidEmailOrPasswordCode) && deepEqualsreach_five_api(lhs.invalidVerificationCode, rhs.invalidVerificationCode) && deepEqualsreach_five_api(lhs.updateSamePassword, rhs.updateSamePassword) && deepEqualsreach_five_api(lhs.invalidGrant, rhs.invalidGrant) && deepEqualsreach_five_api(lhs.userCancelledOrClosedTheWebFlow, rhs.userCancelledOrClosedTheWebFlow) && deepEqualsreach_five_api(lhs.socialAccountEmailAlreadyInUse, rhs.socialAccountEmailAlreadyInUse) && deepEqualsreach_five_api(lhs.unauthorizedRefreshToken, rhs.unauthorizedRefreshToken) && deepEqualsreach_five_api(lhs.accountBlockedAfterMultipleLoginAttempts, rhs.accountBlockedAfterMultipleLoginAttempts) && deepEqualsreach_five_api(lhs.tooManyAttempts, rhs.tooManyAttempts) && deepEqualsreach_five_api(lhs.passwordPolicyError, rhs.passwordPolicyError) && deepEqualsreach_five_api(lhs.accountTemporarilySuspended, rhs.accountTemporarilySuspended)
return deepEqualsreach_five_api(lhs.emailAlreadyInUseCode, rhs.emailAlreadyInUseCode) && deepEqualsreach_five_api(lhs.invalidEmailOrPasswordCode, rhs.invalidEmailOrPasswordCode) && deepEqualsreach_five_api(lhs.invalidVerificationCode, rhs.invalidVerificationCode) && deepEqualsreach_five_api(lhs.updateSamePassword, rhs.updateSamePassword) && deepEqualsreach_five_api(lhs.invalidGrant, rhs.invalidGrant) && deepEqualsreach_five_api(lhs.userCancelledOrClosedTheWebFlow, rhs.userCancelledOrClosedTheWebFlow) && deepEqualsreach_five_api(lhs.socialAccountEmailAlreadyInUse, rhs.socialAccountEmailAlreadyInUse) && deepEqualsreach_five_api(lhs.unauthorizedRefreshToken, rhs.unauthorizedRefreshToken) && deepEqualsreach_five_api(lhs.accountBlockedAfterMultipleLoginAttempts, rhs.accountBlockedAfterMultipleLoginAttempts) && deepEqualsreach_five_api(lhs.tooManyAttempts, rhs.tooManyAttempts) && deepEqualsreach_five_api(lhs.passwordPolicyError, rhs.passwordPolicyError) && deepEqualsreach_five_api(lhs.accountTemporarilySuspended, rhs.accountTemporarilySuspended) && deepEqualsreach_five_api(lhs.passwordTooWeakError, rhs.passwordTooWeakError)
}

func hash(into hasher: inout Hasher) {
Expand All @@ -268,6 +272,7 @@ struct ErrorCodesInterface: Hashable {
deepHashreach_five_api(value: tooManyAttempts, hasher: &hasher)
deepHashreach_five_api(value: passwordPolicyError, hasher: &hasher)
deepHashreach_five_api(value: accountTemporarilySuspended, hasher: &hasher)
deepHashreach_five_api(value: passwordTooWeakError, hasher: &hasher)
}
}

Expand Down
2 changes: 2 additions & 0 deletions flutter_reach_five_ios/lib/flutter_reach_five_ios.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class FlutterReachFiveIOS extends FlutterReachFivePlatform {
throw AccountTemporarilySuspendedExceptionInterface(
error.message ?? "",
);
} else if (error.code == errorCodesInterface.passwordTooWeakError) {
throw PasswordTooWeakExceptionInterface();
}
}
return Error.throwWithStackTrace(error, stackTrace);
Expand Down
4 changes: 2 additions & 2 deletions flutter_reach_five_ios/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_reach_five_ios
description: iOS implementation of the flutter_reach_five plugin
version: 2.0.4
version: 2.0.5
homepage: https://github.com/bamlab/Flutter-ReachFive

environment:
Expand All @@ -18,7 +18,7 @@ flutter:
dependencies:
flutter:
sdk: flutter
flutter_reach_five_platform_interface: ^2.0.4
flutter_reach_five_platform_interface: ^2.0.5

dev_dependencies:
flutter_test:
Expand Down
19 changes: 19 additions & 0 deletions flutter_reach_five_ios/test/flutter_reach_five_ios_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,25 @@ void main() {

expect(error, isA<AccountTemporarilySuspendedExceptionInterface>());
});

test('$PasswordTooWeakExceptionInterface', () {
final exception = PlatformException(
code: errorCodesInterface.passwordTooWeakError,
);

Object? error;

try {
FlutterReachFiveIOS().parseError(
exception,
StackTrace.fromString('test'),
);
} catch (e) {
error = e;
}

expect(error, isA<PasswordTooWeakExceptionInterface>());
});
});
});
}
4 changes: 4 additions & 0 deletions flutter_reach_five_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.0.5

- **FEAT**: Add `passwordTooWeakError` error code to `ErrorCodesInterface`

# 2.0.4

- **FEAT**: Add `accountTemporarilySuspended` error code to `ErrorCodesInterface`
Expand Down
4 changes: 4 additions & 0 deletions flutter_reach_five_platform_interface/lib/src/errors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ final errorCodesInterface = ErrorCodesInterface(
tooManyAttempts: 'rate_limiter_too_many_attempts',
passwordPolicyError: 'password_policy',
accountTemporarilySuspended: 'account_temporarily_suspended',
passwordTooWeakError: 'password_too_weak',
);

/// {@macro flutter_reach_five.errors.email_already_in_use}
Expand Down Expand Up @@ -77,3 +78,6 @@ class AccountTemporarilySuspendedExceptionInterface extends FormatException {
const AccountTemporarilySuspendedExceptionInterface([super.message = '']);
// coverage:ignore-end
}

/// {@macro flutter_reach_five.errors.password_too_weak}
class PasswordTooWeakExceptionInterface implements Exception {}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class ErrorCodesInterface {
required this.tooManyAttempts,
required this.passwordPolicyError,
required this.accountTemporarilySuspended,
required this.passwordTooWeakError,
});

String emailAlreadyInUseCode;
Expand All @@ -141,6 +142,8 @@ class ErrorCodesInterface {

String accountTemporarilySuspended;

String passwordTooWeakError;

List<Object?> _toList() {
return <Object?>[
emailAlreadyInUseCode,
Expand All @@ -155,6 +158,7 @@ class ErrorCodesInterface {
tooManyAttempts,
passwordPolicyError,
accountTemporarilySuspended,
passwordTooWeakError,
];
}

Expand All @@ -177,6 +181,7 @@ class ErrorCodesInterface {
tooManyAttempts: result[9]! as String,
passwordPolicyError: result[10]! as String,
accountTemporarilySuspended: result[11]! as String,
passwordTooWeakError: result[12]! as String,
);
}

Expand Down Expand Up @@ -215,7 +220,8 @@ class ErrorCodesInterface {
_deepEquals(
accountTemporarilySuspended,
other.accountTemporarilySuspended,
);
) &&
_deepEquals(passwordTooWeakError, other.passwordTooWeakError);
}

@override
Expand Down
2 changes: 2 additions & 0 deletions flutter_reach_five_platform_interface/pigeons/reach_five.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ErrorCodesInterface {
required this.tooManyAttempts,
required this.passwordPolicyError,
required this.accountTemporarilySuspended,
required this.passwordTooWeakError,
});

final String emailAlreadyInUseCode;
Expand All @@ -40,6 +41,7 @@ class ErrorCodesInterface {
final String tooManyAttempts;
final String passwordPolicyError;
final String accountTemporarilySuspended;
final String passwordTooWeakError;
}

class SdkConfigInterface {
Expand Down
Loading
Loading