Skip to content
Merged
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.1.0

- **FEAT**: Add `passwordPolicy` method returning the `PasswordPolicy` configured for the ReachFive client (minimum length, minimum strength, required character classes and whether the password can be updated with only an access token)

# 2.0.5

- **FEAT**: Add `PasswordTooWeakException` thrown when trying to set a password that is too weak or that has leaked
Expand Down
1 change: 1 addition & 0 deletions flutter_reach_five/lib/flutter_reach_five.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export 'models/emails.dart';
export 'models/errors.dart';
export 'models/login_summary.dart';
export 'models/open_id_user.dart';
export 'models/password_policy.dart';
export 'models/profile.dart';
export 'models/profile_address.dart';
export 'models/profile_signup_request.dart';
Expand Down
2 changes: 1 addition & 1 deletion flutter_reach_five/lib/helpers/address_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter_reach_five_platform_interface/flutter_reach_five_platfor

import '../models/address.dart';

/// Used to be the link between the [AddressInterface]
/// Link between the [AddressInterface]
/// and the [Address] exported from this package
class AddressConverter {
/// convert a [Address] to a [AddressInterface]
Expand Down
2 changes: 1 addition & 1 deletion flutter_reach_five/lib/helpers/auth_token.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter_reach_five_platform_interface/flutter_reach_five_platfor
import '../models/auth_token.dart';
import 'open_id_user.dart';

/// Used to be the link between the [AuthTokenInterface]
/// Link between the [AuthTokenInterface]
/// and the [AuthToken] exported from this package
class AuthTokenConverter {
/// convert a [AuthToken] to a [AuthTokenInterface]
Expand Down
2 changes: 1 addition & 1 deletion flutter_reach_five/lib/helpers/consent_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter_reach_five_platform_interface/flutter_reach_five_platfor

import '../models/consent.dart';

/// Used to be the link between the [ConsentInterface]
/// Link between the [ConsentInterface]
/// and the [Consent] exported from this package
class ConsentConverter {
/// convert a [Consent] to a [ConsentInterface]
Expand Down
2 changes: 1 addition & 1 deletion flutter_reach_five/lib/helpers/emails_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter_reach_five_platform_interface/flutter_reach_five_platfor

import '../models/emails.dart';

/// Used to be the link between the [EmailsInterface]
/// Link between the [EmailsInterface]
/// and the [Emails] exported from this package
class EmailsConverter {
/// convert a [Emails] to a [EmailsInterface]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter_reach_five_platform_interface/flutter_reach_five_platfor

import '../models/login_summary.dart';

/// Used to be the link between the [LoginSummaryInterface]
/// Link between the [LoginSummaryInterface]
/// and the [LoginSummary] exported from this package
class LoginSummaryConverter {
/// convert a [LoginSummary] to a [LoginSummaryInterface]
Expand Down
2 changes: 1 addition & 1 deletion flutter_reach_five/lib/helpers/open_id_user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter_reach_five_platform_interface/flutter_reach_five_platfor
import '../models/open_id_user.dart';
import 'address_converter.dart';

/// Used to be the link between the [OpenIdUserInterface]
/// Link between the [OpenIdUserInterface]
/// and the [OpenIdUser] exported from this package
class OpenIdUserConverter {
/// convert a [OpenIdUser] to a [OpenIdUserInterface]
Expand Down
20 changes: 20 additions & 0 deletions flutter_reach_five/lib/helpers/password_policy_converter.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'package:reach_five_identity_repo/reach_five_identity_repo.dart';

import '../models/password_policy.dart';

/// Used as the link between the [PasswordPolicyResponse] from the
/// identity repo and the [PasswordPolicy] exported from this package
class PasswordPolicyConverter {
/// convert a [PasswordPolicyResponse] to a [PasswordPolicy]
static PasswordPolicy fromInterface(PasswordPolicyResponse passwordPolicy) =>
PasswordPolicy(
minLength: passwordPolicy.minLength,
minStrength: passwordPolicy.minStrength,
specialCharacters: passwordPolicy.specialCharacters,
uppercaseCharacters: passwordPolicy.uppercaseCharacters,
lowercaseCharacters: passwordPolicy.lowercaseCharacters,
digitCharacters: passwordPolicy.digitCharacters,
allowUpdateWithAccessTokenOnly:
passwordPolicy.allowUpdateWithAccessTokenOnly,
);
}
4 changes: 2 additions & 2 deletions flutter_reach_five/lib/helpers/profile_address_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter_reach_five_platform_interface/flutter_reach_five_platfor

import '../models/profile_address.dart';

/// Used to be the link between the [ProfileAddressTypeInterface]
/// Link between the [ProfileAddressTypeInterface]
/// and the [ProfileAddressType] exported from this package
class ProfileAddressTypeConverter {
/// convert a [ProfileAddressType] to a [ProfileAddressTypeInterface]
Expand Down Expand Up @@ -30,7 +30,7 @@ class ProfileAddressTypeConverter {
}
}

/// Used to be the link between the [ProfileAddressInterface]
/// Link between the [ProfileAddressInterface]
/// and the [ProfileAddress] exported from this package
class ProfileAddressConverter {
/// convert a [ProfileAddress] to a [ProfileAddressInterface]
Expand Down
2 changes: 1 addition & 1 deletion flutter_reach_five/lib/helpers/profile_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'emails_converter.dart';
import 'login_summary_converter.dart';
import 'profile_address_converter.dart';

/// Used to be the link between the [ProfileInterface]
/// Link between the [ProfileInterface]
/// and the [Profile] exported from this package
class ProfileConverter {
/// convert a [Profile] to a [ProfileInterface]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import '../models/profile_signup_request.dart';
import 'consent_converter.dart';
import 'profile_address_converter.dart';

/// Used to be the link between the [ProfileSignupRequestInterface]
/// Link between the [ProfileSignupRequestInterface]
/// and the [ProfileSignupRequest] exported from this package
class ProfileSignupRequestConverter {
/// convert a [ProfileSignupRequest] to a [ProfileSignupRequestInterface]
Expand Down
2 changes: 1 addition & 1 deletion flutter_reach_five/lib/helpers/provider_converter.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '../models/provider.dart';

/// Used to be the link between a [String]
/// Link between a [String]
/// and the [Provider] exported from this package
class ProviderConverter {
/// convert a [Provider] to a [String]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter_reach_five_platform_interface/flutter_reach_five_platfor

import '../models/provider_creator.dart';

/// Used to be the link between a [ProviderCreatorInterface]
/// Link between a [ProviderCreatorInterface]
/// and the [ProviderCreator] exported from this package
class ProviderCreatorConverter {
/// convert a [ProviderCreator] to a [ProviderCreatorInterface]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import '../models/reach_five_key.dart';
import 'provider_creator_converter.dart';
import 'sdk_config_converter.dart';

/// Used to be the link between the [ReachFiveKeyInterface]
/// Link between the [ReachFiveKeyInterface]
/// and the [ReachFiveKey] exported from this package
class ReachFiveKeyConverter {
/// convert a [ReachFiveKey] to a [ReachFiveKeyInterface]
Expand Down
2 changes: 1 addition & 1 deletion flutter_reach_five/lib/helpers/scope_value_converter.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '../models/scope_value.dart';

/// Used to be the link between a [String]
/// Link between a [String]
/// and the [ScopeValue] exported from this package
class ScopeValueConverter {
/// convert a [ScopeValue] to a [String]
Expand Down
2 changes: 1 addition & 1 deletion flutter_reach_five/lib/helpers/sdk_config_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter_reach_five_platform_interface/flutter_reach_five_platfor

import '../models/sdk_config.dart';

/// Used to be the link between the [SdkConfigInterface]
/// Link between the [SdkConfigInterface]
/// and the [SdkConfig] exported from this package
class SdkConfigConverter {
/// convert a [SdkConfig] to a [SdkConfigInterface]
Expand Down
53 changes: 53 additions & 0 deletions flutter_reach_five/lib/models/password_policy.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import 'package:equatable/equatable.dart';

/// [PasswordPolicy] class, contains the password policy configured for the
/// ReachFive client (as defined on the Password policy page of the console)
class PasswordPolicy extends Equatable {
/// [PasswordPolicy] default constructor
const PasswordPolicy({
required this.minLength,
required this.minStrength,
required this.allowUpdateWithAccessTokenOnly,
this.specialCharacters,
this.uppercaseCharacters,
this.lowercaseCharacters,
this.digitCharacters,
});

/// The minimum number of characters a password must contain
final int minLength;

/// The minimum strength a password must reach (from 0 to 4)
final int minStrength;

/// The minimum number of special characters a password must contain,
/// or `null` if not enforced
final int? specialCharacters;

/// The minimum number of uppercase characters a password must contain,
/// or `null` if not enforced
final int? uppercaseCharacters;

/// The minimum number of lowercase characters a password must contain,
/// or `null` if not enforced
final int? lowercaseCharacters;

/// The minimum number of digit characters a password must contain,
/// or `null` if not enforced
final int? digitCharacters;

/// Whether the password can be updated with only an access token
/// (without providing the old password)
final bool allowUpdateWithAccessTokenOnly;

@override
List<Object?> get props => [
minLength,
minStrength,
specialCharacters,
uppercaseCharacters,
lowercaseCharacters,
digitCharacters,
allowUpdateWithAccessTokenOnly,
];
}
30 changes: 30 additions & 0 deletions flutter_reach_five/lib/reach_five.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:reach_five_identity_repo/reach_five_identity_repo.dart';
import 'flutter_reach_five.dart';
import 'helpers/adapt_errors.dart';
import 'helpers/auth_token.dart';
import 'helpers/password_policy_converter.dart';
import 'helpers/profile_converter.dart';
import 'helpers/profile_signup_request_converter.dart';
import 'helpers/provider_converter.dart';
Expand Down Expand Up @@ -57,6 +58,12 @@ class ReachFive {
/// {@endtemplate}
EmailApi get emailApi => identityRepo.getEmailApi();

/// {@template flutter_reach_five.reachFive.configApi}
/// [ConfigApi] instance from [identityRepo] to be given in every
/// reachFive api methods that needs it
/// {@endtemplate}
ConfigApi get configApi => identityRepo.getConfigApi();

/// {@template flutter_reach_five.reachFive.signup}
/// Create and authenticate a new user with the specified data.
/// {@endtemplate}
Expand Down Expand Up @@ -345,6 +352,29 @@ class ReachFive {
}
}

/// {@template flutter_reach_five.reachFive.passwordPolicy}
/// Get the password policy configured for the ReachFive client.
///
/// These are the values configured on the `Password policy` page of the
/// ReachFive console (minimum length, minimum strength, required character
/// classes, ...).
/// {@endtemplate}
Future<PasswordPolicy> passwordPolicy() async {
final response = await configApi.getConfig(
clientId: reachFiveKey.sdkConfig.clientId,
);

final passwordPolicy = response.data?.passwordPolicy;

if (passwordPolicy == null) {
throw const FormatException(
'The ReachFive config response did not contain a password policy.',
);
}

return PasswordPolicyConverter.fromInterface(passwordPolicy);
}

/// {@template flutter_reach_five.reachFive.updatePassword}
/// Make request for password reset
///
Expand Down
4 changes: 2 additions & 2 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.5
version: 2.1.0
homepage: https://github.com/bamlab/Flutter-ReachFive
repository: https://github.com/bamlab/Flutter-ReachFive

Expand All @@ -27,7 +27,7 @@ dependencies:
flutter_reach_five_platform_interface: ^2.0.5
freezed: ^3.2.3
freezed_annotation: ^3.1.0
reach_five_identity_repo: ^2.0.0
reach_five_identity_repo: ^2.1.0

dev_dependencies:
build_runner: ^2.4.8
Expand Down
Loading
Loading