From 3fcee58d8bc265803fa4ce9a3936fd4e39b37f86 Mon Sep 17 00:00:00 2001 From: Steve Hobbs Date: Thu, 23 Feb 2023 10:56:57 +0000 Subject: [PATCH 1/3] chore: update Flutter version for build --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6c81d17a..4e990f77 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -53,7 +53,7 @@ orbs: parameters: flutter_version: type: string - default: 3.0.5 + default: 3.7.4 jobs: test_flutter_package: docker: From b8f39d9937ace20e755151261dc0f85d2b5240db Mon Sep 17 00:00:00 2001 From: Steve Hobbs Date: Thu, 23 Feb 2023 11:10:18 +0000 Subject: [PATCH 2/3] chore: fix linter warnings (mostly lines > 80 chars in comments) --- auth0_flutter/analysis_options.yaml | 2 +- auth0_flutter/example/analysis_options.yaml | 2 +- auth0_flutter/example/lib/api_card.dart | 2 +- auth0_flutter/example/lib/web_auth_card.dart | 3 +- auth0_flutter/lib/auth0_flutter.dart | 29 +++++++---- auth0_flutter/lib/src/authentication_api.dart | 47 ++++++++++++------ .../lib/src/credentials_manager.dart | 27 +++++++---- auth0_flutter/lib/src/web_authentication.dart | 48 +++++++++++++------ .../test/web_authentication_test.dart | 6 ++- .../analysis_options.yaml | 2 +- .../credentials_manager_exception.dart | 6 ++- .../credentials_manager_platform.dart | 9 ++-- .../method_channel_credentials_manager.dart | 12 +++-- .../options/get_credentials_options.dart | 3 +- .../has_valid_credentials_options.dart | 3 +- .../options/local_authentication.dart | 6 ++- .../lib/src/credentials.dart | 12 +++-- .../lib/src/request/request.dart | 2 +- .../lib/src/user_profile.dart | 45 ++++++++--------- .../web-auth/id_token_validation_config.dart | 11 +++-- .../src/web-auth/safari_view_controller.dart | 3 +- .../src/web-auth/web_auth_login_options.dart | 2 - ...ethod_channel_auth0_flutter_auth_test.dart | 2 + ...d_channel_auth0_flutter_web_auth_test.dart | 2 + ...thod_channel_credentials_manager_test.dart | 2 + 25 files changed, 186 insertions(+), 102 deletions(-) diff --git a/auth0_flutter/analysis_options.yaml b/auth0_flutter/analysis_options.yaml index 7bfddbf3..adc438bd 100644 --- a/auth0_flutter/analysis_options.yaml +++ b/auth0_flutter/analysis_options.yaml @@ -52,7 +52,7 @@ linter: join_return_with_assignment: true leading_newlines_in_multiline_strings: true library_private_types_in_public_api: true - lines_longer_than_80_chars -> packages only: true + lines_longer_than_80_chars: true missing_whitespace_between_adjacent_strings: true no_leading_underscores_for_library_prefixes: true no_leading_underscores_for_local_identifiers: true diff --git a/auth0_flutter/example/analysis_options.yaml b/auth0_flutter/example/analysis_options.yaml index 324937c6..1319ea4c 100644 --- a/auth0_flutter/example/analysis_options.yaml +++ b/auth0_flutter/example/analysis_options.yaml @@ -73,7 +73,7 @@ linter: join_return_with_assignment: true leading_newlines_in_multiline_strings: true library_private_types_in_public_api: true - lines_longer_than_80_chars -> packages only: true + lines_longer_than_80_chars: true missing_whitespace_between_adjacent_strings: true no_leading_underscores_for_library_prefixes: true no_leading_underscores_for_local_identifiers: true diff --git a/auth0_flutter/example/lib/api_card.dart b/auth0_flutter/example/lib/api_card.dart index 068e3ec6..933335a0 100644 --- a/auth0_flutter/example/lib/api_card.dart +++ b/auth0_flutter/example/lib/api_card.dart @@ -6,7 +6,7 @@ import 'constants.dart'; class ApiCard extends StatefulWidget { final Future Function(String usernameOrEmail, String password) action; - const ApiCard({required final this.action, final Key? key}) : super(key: key); + const ApiCard({required this.action, final Key? key}) : super(key: key); @override ApiCardState createState() { diff --git a/auth0_flutter/example/lib/web_auth_card.dart b/auth0_flutter/example/lib/web_auth_card.dart index 0ffbb71e..44e73332 100644 --- a/auth0_flutter/example/lib/web_auth_card.dart +++ b/auth0_flutter/example/lib/web_auth_card.dart @@ -8,8 +8,7 @@ class WebAuthCard extends StatelessWidget { final String label; final Future Function() action; - const WebAuthCard( - {required final this.label, required final this.action, final Key? key}) + const WebAuthCard({required this.label, required this.action, final Key? key}) : super(key: key); @override diff --git a/auth0_flutter/lib/auth0_flutter.dart b/auth0_flutter/lib/auth0_flutter.dart index f91ee90c..6b2eb78d 100644 --- a/auth0_flutter/lib/auth0_flutter.dart +++ b/auth0_flutter/lib/auth0_flutter.dart @@ -22,7 +22,8 @@ export 'src/authentication_api.dart'; export 'src/credentials_manager.dart'; export 'src/web_authentication.dart'; -/// Primary interface for interacting with Auth0 using web authentication, or the authentication API. +/// Primary interface for interacting with Auth0 using web authentication, or +/// the authentication API. class Auth0 { final Account _account; @@ -34,13 +35,18 @@ class Auth0 { /// Secure [Credentials] store. CredentialsManager get credentialsManager => _credentialsManager; - /// Creates an intance of an Auth0 client with the provided [domain] and [clientId] properties. + /// Creates an intance of an Auth0 client with the provided [domain] and + /// [clientId] properties. /// /// [domain] and [clientId] are both values that can be retrieved from the application in your [Auth0 Dashboard](https://manage.auth0.com). - /// If you want to use your own implementation to handle credential storage, provide your own [CredentialsManager] implementation - /// by setting [credentialsManager]. A [DefaultCredentialsManager] instance is used by default. - /// If you want to use biometrics or pass-phrase when using the [DefaultCredentialsManager], set [localAuthentication]` to an instance of [LocalAuthentication]. - /// Note however that this setting has no effect when specifying a custom [credentialsManager]. + /// If you want to use your own implementation to handle credential storage, + /// provide your own [CredentialsManager] implementation by setting + /// [credentialsManager]. A [DefaultCredentialsManager] instance is used by + /// default. + /// If you want to use biometrics or pass-phrase when using the + /// [DefaultCredentialsManager], set [localAuthentication]` to an instance + /// of [LocalAuthentication]. Note however that this setting has no effect + /// when specifying a custom [credentialsManager]. Auth0(final String domain, final String clientId, {final LocalAuthentication? localAuthentication, final CredentialsManager? credentialsManager}) @@ -53,7 +59,8 @@ class Auth0 { ); } - /// An instance of [AuthenticationApi], the primary interface for interacting with the Auth0 Authentication API + /// An instance of [AuthenticationApi], the primary interface for interacting + /// with the Auth0 Authentication API /// /// Usage example: /// @@ -80,8 +87,12 @@ class Auth0 { /// final result = await auth0.webAuthentication().login(); /// final accessToken = result.accessToken; /// ``` - /// By default, the credentials will be stored in the [CredentialsManager]. In case you want to opt-out of using the [CredentialsManager], set [useCredentialsManager] to `false`. - /// (Android only): specify [scheme] if you're using a custom URL scheme for your app. This value must match the value used to configure the `auth0Scheme` manifest placeholder, for the Redirect intent filter to work + /// By default, the credentials will be stored in the [CredentialsManager]. + /// In case you want to opt-out of using the [CredentialsManager], set + /// [useCredentialsManager] to `false`. (Android only): specify [scheme] if + /// you're using a custom URL scheme for your app. This value must match the + /// value used to configure the `auth0Scheme` manifest placeholder, for the + /// Redirect intent filter to work. WebAuthentication webAuthentication( {final String? scheme, final bool useCredentialsManager = true}) => WebAuthentication(_account, _userAgent, scheme, diff --git a/auth0_flutter/lib/src/authentication_api.dart b/auth0_flutter/lib/src/authentication_api.dart index d47fe29d..e5fb99e3 100644 --- a/auth0_flutter/lib/src/authentication_api.dart +++ b/auth0_flutter/lib/src/authentication_api.dart @@ -1,12 +1,15 @@ import 'package:auth0_flutter_platform_interface/auth0_flutter_platform_interface.dart'; -/// An interface for calling some of the endpoints in [Auth0's Authentication API](https://auth0.com/docs/api/authentication). +/// An interface for calling some of the endpoints in +/// [Auth0's Authentication API](https://auth0.com/docs/api/authentication). /// -/// This class presents building blocks for doing more fine-grained authentication with Auth0 using Username and Password login. Unlike +/// This class presents building blocks for doing more fine-grained +/// authentication with Auth0 using Username and Password login. Unlike /// `WebAuthentication`, these do **not** use [Auth0 Universal Login](https://auth0.com/docs/authenticate/login/auth0-universal-login) (the recommended way of doing authentication), /// and thus users are not redirected to Auth0 for authentication. /// -/// It is not intended for you to instantiate this class yourself, as an instance of it is already exposed as `Auth0.api`. +/// It is not intended for you to instantiate this class yourself, as an +/// instance of it is already exposed as `Auth0.api`. /// /// Usage example: /// @@ -27,10 +30,13 @@ class AuthenticationApi { AuthenticationApi(this._account, this._userAgent); - /// Authenticates the user using a [usernameOrEmail] and a [password], with the specified [connectionOrRealm]. If successful, it returns - /// a set of tokens, as well as the user's profile (constructed from ID token claims). + /// Authenticates the user using a [usernameOrEmail] and a [password], with + /// the specified [connectionOrRealm]. If successful, it returns + /// a set of tokens, as well as the user's profile (constructed from ID token + /// claims). /// - /// If using the default username and password database connection, [connectionOrRealm] should be set to `Username-Password-Authentication`. + /// If using the default username and password database connection, + /// [connectionOrRealm] should be set to `Username-Password-Authentication`. /// /// ## Endpoint docs /// https://auth0.com/docs/api/authentication#login @@ -39,7 +45,8 @@ class AuthenticationApi { /// /// * [audience] relates to the API Identifier you want to reference in your access tokens (see [API settings](https://auth0.com/docs/get-started/apis/api-settings)) /// * [scopes] defaults to `openid profile email offline_access` - /// * [parameters] can be used to sent through custom parameters to the endpoint to be picked up in a Rule or Action. + /// * [parameters] can be used to sent through custom parameters to the + /// endpoint to be picked up in a Rule or Action. /// /// ## Usage example /// @@ -73,8 +80,11 @@ class AuthenticationApi { parameters: parameters, ))); - /// Authenticates the user using a [mfaToken] and an [otp], after [login] returned with an [ApiException] with [ApiException.isMultifactorRequired] set to `true`. - /// If successful, it returns a set of tokens, as well as the user's profile (constructed from ID token claims). + /// Authenticates the user using a [mfaToken] and an [otp], after [login] + /// returned with an [ApiException] with [ApiException.isMultifactorRequired] + /// set to `true`. + /// If successful, it returns a set of tokens, as well as the user's profile + /// (constructed from ID token claims). /// /// /// ## Endpoint docs @@ -112,7 +122,9 @@ class AuthenticationApi { /// connectionOrRealm: 'Username-Password-Authentication' /// }); /// - /// final profile = await auth0.api.userProfile({ accessToken: result.accessToken }); + /// final profile = await auth0.api.userProfile({ + /// accessToken: result.accessToken + /// }); /// ``` Future userProfile( {required final String accessToken, @@ -121,7 +133,8 @@ class AuthenticationApi { AuthUserInfoOptions( accessToken: accessToken, parameters: parameters))); - /// Registers a new user with the specified [email] address and [password] in the specified [connection]. + /// Registers a new user with the specified [email] address and [password] in + /// the specified [connection]. /// /// Endpoint /// https://auth0.com/docs/api/authentication#signup @@ -151,7 +164,8 @@ class AuthenticationApi { /// https://auth0.com/docs/api/authentication#refresh-token /// /// ## Notes - /// * Refresh tokens can be retrieved by specifying the `offline_access` scope during authentication. + /// * Refresh tokens can be retrieved by specifying the `offline_access` + /// scope during authentication. /// * [scopes] can be specified if a reduced set of scopes is desired. /// /// ## Further reading @@ -182,17 +196,20 @@ class AuthenticationApi { scopes: scopes, parameters: parameters))); - /// Initiates a reset of password of the user with the specific [email] address in the specific [connection]. + /// Initiates a reset of password of the user with the specific [email] + /// address in the specific [connection]. /// /// ## Endpoint /// https://auth0.com/docs/api/authentication#change-password /// /// ## Notes /// - /// Calling this endpoint does not reset the user's password in itself, but it asks Auth0 to send the user + /// Calling this endpoint does not reset the user's password in itself, but it + /// asks Auth0 to send the user /// an email with a link they can use to reset their password on the web. /// - /// Arbitrary [parameters] can be specified and then picked up in a custom Auth0 [Action](https://auth0.com/docs/customize/actions) or + /// Arbitrary [parameters] can be specified and then picked up in a custom + /// Auth0 [Action](https://auth0.com/docs/customize/actions) or /// [Rule](https://auth0.com/docs/customize/rules). Future resetPassword( {required final String email, diff --git a/auth0_flutter/lib/src/credentials_manager.dart b/auth0_flutter/lib/src/credentials_manager.dart index 30541429..4618fee4 100644 --- a/auth0_flutter/lib/src/credentials_manager.dart +++ b/auth0_flutter/lib/src/credentials_manager.dart @@ -1,6 +1,7 @@ import 'package:auth0_flutter_platform_interface/auth0_flutter_platform_interface.dart'; -/// Abstract CredentialsManager that can be used to provide a custom CredentialManager. +/// Abstract CredentialsManager that can be used to provide a custom +/// CredentialManager. abstract class CredentialsManager { Future credentials({ final int minTtl = 0, @@ -18,7 +19,8 @@ abstract class CredentialsManager { } /// Default [CredentialsManager] implementation that passes calls to -/// the Native CredentialManagers provided by Auth0.Android or Auth0.Swift, depending on the platform. +/// the Native CredentialManagers provided by Auth0.Android or Auth0.Swift, +/// depending on the platform. class DefaultCredentialsManager extends CredentialsManager { final Account _account; final UserAgent _userAgent; @@ -28,11 +30,15 @@ class DefaultCredentialsManager extends CredentialsManager { {final LocalAuthentication? localAuthentication}) : _localAuthentication = localAuthentication; - /// Retrieves the credentials from the storage and refreshes them if they have already expired. + /// Retrieves the credentials from the storage and refreshes them if they have + /// already expired. /// - /// Change the minimum time in seconds that the access token should last before expiration by setting the [minTtl]. - /// Use the [scopes] parameter to set the scope to request for the access token. If `null` is passed, the previous scope will be kept. - /// Use the [parameters] parameter to send additional parameters in the request to refresh expired credentials. + /// Change the minimum time in seconds that the access token should last + /// before expiration by setting the [minTtl]. + /// Use the [scopes] parameter to set the scope to request for the access + /// token. If `null` is passed, the previous scope will be kept. + /// Use the [parameters] parameter to send additional parameters in the + /// request to refresh expired credentials. @override Future credentials({ final int minTtl = 0, @@ -46,15 +52,18 @@ class DefaultCredentialsManager extends CredentialsManager { parameters: parameters, ))); - /// Stores the given credentials in the storage. Must have an `access_token` or `id_token` and a `expires_in` value. + /// Stores the given credentials in the storage. Must have an `access_token` + /// or `id_token` and a `expires_in` value. @override Future storeCredentials(final Credentials credentials) => CredentialsManagerPlatform.instance.saveCredentials( _createApiRequest(SaveCredentialsOptions(credentials: credentials))); - /// Checks if a non-expired pair of credentials can be obtained from this manager. + /// Checks if a non-expired pair of credentials can be obtained from this + /// manager. /// - /// Change the minimum time in seconds that the access token should last before expiration by setting the [minTtl]. + /// Change the minimum time in seconds that the access token should last + /// before expiration by setting the [minTtl]. @override Future hasValidCredentials({ final int minTtl = 0, diff --git a/auth0_flutter/lib/src/web_authentication.dart b/auth0_flutter/lib/src/web_authentication.dart index 8e34cf86..24a7c5bd 100644 --- a/auth0_flutter/lib/src/web_authentication.dart +++ b/auth0_flutter/lib/src/web_authentication.dart @@ -4,11 +4,13 @@ import '../auth0_flutter.dart'; /// An interface for authenticating users using the [Auth0 Universal Login page](https://auth0.com/docs/authenticate/login/auth0-universal-login). /// -/// Authentication using Universal Login works by redirecting your user to a login page hosted on Auth0's servers. To achieve this on a native device, +/// Authentication using Universal Login works by redirecting your user to a +/// login page hosted on Auth0's servers. To achieve this on a native device, /// this class uses the [Auth0.Android](https://github.com/auth0/Auth0.Android) and [Auth0.Swift](https://github.com/auth0/Auth0.swift) SDKs on Android and iOS respectively to /// perform interactions with Universal Login. /// -/// It is not intended for you to instantiate this class yourself, as an instance of it is already exposed as [Auth0.webAuthentication]. +/// It is not intended for you to instantiate this class yourself, as an +/// instance of it is already exposed as [Auth0.webAuthentication]. /// /// Usage example: /// @@ -27,22 +29,34 @@ class WebAuthentication { this._account, this._userAgent, this._scheme, this._credentialsManager); /// Redirects the user to the [Auth0 Universal Login page](https://auth0.com/docs/authenticate/login/auth0-universal-login) for authentication. If successful, it returns - /// a set of tokens, as well as the user's profile (constructed from ID token claims). + /// a set of tokens, as well as the user's profile (constructed from ID token + /// claims). /// - /// If [redirectUrl] is not specified, a default URL is used that incorporates the `domain` value specified to [Auth0.new], and scheme on Android, or the - /// bundle identifier in iOS. [redirectUrl] must appear in your **Allowed Callback URLs** list for the Auth0 app. [Read more about redirecting users](https://auth0.com/docs/authenticate/login/redirect-users-after-login). + /// If [redirectUrl] is not specified, a default URL is used that incorporates + /// the `domain` value specified to [Auth0.new], and scheme on Android, or + /// the bundle identifier in iOS. [redirectUrl] must appear in your + /// **Allowed Callback URLs** list for the Auth0 app. + /// [Read more about redirecting users](https://auth0.com/docs/authenticate/login/redirect-users-after-login). /// - /// How the ID token is validated can be configured using [idTokenValidationConfig], but in general the defaults for this are adequate. + /// How the ID token is validated can be configured using + /// [idTokenValidationConfig], but in general the defaults for this are + /// adequate. /// /// Additonal notes: /// /// * (iOS only): [useEphemeralSession] controls whether shared persistent storage is used for cookies. [Read more on the effects this setting has](https://github.com/auth0/Auth0.swift/blob/master/FAQ.md#1-how-can-i-disable-the-login-alert-box) /// * [audience] relates to the API Identifier you want to reference in your access tokens (see [API settings](https://auth0.com/docs/get-started/apis/api-settings)) - /// * [scopes] defaults to `openid profile email offline_access`. You can override these scopes, but `openid` is always requested regardless of this setting. - /// * Arbitrary [parameters] can be specified and then picked up in a custom Auth0 [Action](https://auth0.com/docs/customize/actions) or [Rule](https://auth0.com/docs/customize/rules). - /// * If you want to log into a specific organization, provide the [organizationId]. Provide [invitationUrl] if a user has been invited to - /// join an organization. - /// * (iOS only): [safariViewController] causes [`SFSafariViewController`](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) to be used when opening the + /// * [scopes] defaults to `openid profile email offline_access`. You can + /// override these scopes, but `openid` is always requested regardless of + /// this setting. + /// * Arbitrary [parameters] can be specified and then picked up in a custom + /// Auth0 [Action](https://auth0.com/docs/customize/actions) or + /// [Rule](https://auth0.com/docs/customize/rules). + /// * If you want to log into a specific organization, provide the + /// [organizationId]. Provide [invitationUrl] if a user has been invited + /// to join an organization. + /// * (iOS only): [safariViewController] causes + /// [`SFSafariViewController`](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) to be used when opening the /// Universal Login page, as an alternative to the default `ASWebAuthenticationSession`. You will also need to [configure your iOS app to automatically resume](https://github.com/auth0/auth0-flutter/blob/main/auth0_flutter/FAQ.md#use-sfsafariviewcontroller) the Web Auth operation after login. Future login( {final String? audience, @@ -78,11 +92,15 @@ class WebAuthentication { return credentials; } - /// Redirects the user to the Auth0 Logout endpoint to remove their authentication session, and log out. The user is immediately redirected back to the application - /// once logout is complete. + /// Redirects the user to the Auth0 Logout endpoint to remove their + /// authentication session, and log out. The user is immediately redirected + /// back to the application once logout is complete. /// - /// If [returnTo] is not specified, a default URL is used that incorporates the `domain` value specified to [Auth0.new], and the custom scheme on Android, or the - /// bundle identifier in iOS. [returnTo] must appear in your **Allowed Logout URLs** list for the Auth0 app. [Read more about redirecting users after logout](https://auth0.com/docs/authenticate/login/logout#redirect-users-after-logout). + /// If [returnTo] is not specified, a default URL is used that incorporates + /// the `domain` value specified to [Auth0.new], and the custom scheme on + /// Android, or the bundle identifier in iOS. [returnTo] must appear in your + /// **Allowed Logout URLs** list for the Auth0 app. + /// [Read more about redirecting users after logout](https://auth0.com/docs/authenticate/login/logout#redirect-users-after-logout). Future logout({final String? returnTo}) async { await Auth0FlutterWebAuthPlatform.instance.logout(_createWebAuthRequest( WebAuthLogoutOptions(returnTo: returnTo, scheme: _scheme), diff --git a/auth0_flutter/test/web_authentication_test.dart b/auth0_flutter/test/web_authentication_test.dart index bd7452ac..5484d156 100644 --- a/auth0_flutter/test/web_authentication_test.dart +++ b/auth0_flutter/test/web_authentication_test.dart @@ -146,7 +146,8 @@ void main() { redirectUrl: 'redirect_url', useEphemeralSession: true); - // Verify it doesn't call our own Platform Interface when providing a custom CredentialsManager + // Verify it doesn't call our own Platform Interface when providing a + // custom CredentialsManager verifyNever(mockedCMPlatform.saveCredentials(any)); final verificationResult = verify(mockCm.storeCredentials(captureAny)) @@ -255,7 +256,8 @@ void main() { .webAuthentication() .logout(returnTo: 'abc'); - // Verify it doesn't call our own Platform Interface when providing a custom CredentialsManager + // Verify it doesn't call our own Platform Interface when providing a + //custom CredentialsManager verifyNever(mockedCMPlatform.clearCredentials(any)); verify(mockCm.clearCredentials()).called(1); diff --git a/auth0_flutter_platform_interface/analysis_options.yaml b/auth0_flutter_platform_interface/analysis_options.yaml index 7bfddbf3..adc438bd 100644 --- a/auth0_flutter_platform_interface/analysis_options.yaml +++ b/auth0_flutter_platform_interface/analysis_options.yaml @@ -52,7 +52,7 @@ linter: join_return_with_assignment: true leading_newlines_in_multiline_strings: true library_private_types_in_public_api: true - lines_longer_than_80_chars -> packages only: true + lines_longer_than_80_chars: true missing_whitespace_between_adjacent_strings: true no_leading_underscores_for_library_prefixes: true no_leading_underscores_for_local_identifiers: true diff --git a/auth0_flutter_platform_interface/lib/src/credentials-manager/credentials_manager_exception.dart b/auth0_flutter_platform_interface/lib/src/credentials-manager/credentials_manager_exception.dart index 7ca18680..62ff70cb 100644 --- a/auth0_flutter_platform_interface/lib/src/credentials-manager/credentials_manager_exception.dart +++ b/auth0_flutter_platform_interface/lib/src/credentials-manager/credentials_manager_exception.dart @@ -4,7 +4,8 @@ import '../auth0_exception.dart'; import '../extensions/exception_extensions.dart'; // ignore: comment_references -/// Exception thrown by [MethodChannelCredentialsManager] when something goes wrong. +/// Exception thrown by [MethodChannelCredentialsManager] when something goes +/// wrong. class CredentialsManagerException extends Auth0Exception { const CredentialsManagerException(final String code, final String message, final Map details) @@ -13,7 +14,8 @@ class CredentialsManagerException extends Auth0Exception { const CredentialsManagerException.unknown(final String message) : super.unknown(message); // coverage:ignore-line - /// Fectory method that transforms a [PlatformException] to a [CredentialsManagerException]. + /// Fectory method that transforms a [PlatformException] to a + /// [CredentialsManagerException]. factory CredentialsManagerException.fromPlatformException( final PlatformException e) { final Map errorDetails = e.detailsMap; diff --git a/auth0_flutter_platform_interface/lib/src/credentials-manager/credentials_manager_platform.dart b/auth0_flutter_platform_interface/lib/src/credentials-manager/credentials_manager_platform.dart index d442c3ea..6a891e58 100644 --- a/auth0_flutter_platform_interface/lib/src/credentials-manager/credentials_manager_platform.dart +++ b/auth0_flutter_platform_interface/lib/src/credentials-manager/credentials_manager_platform.dart @@ -23,7 +23,8 @@ abstract class CredentialsManagerPlatform extends PlatformInterface { MethodChannelCredentialsManager(); /// Platform-specific plugins should set this with their own platform-specific - /// class that extends [CredentialsManagerPlatform] when they register themselves. + /// class that extends [CredentialsManagerPlatform] when they register + /// themselves. static set instance(final CredentialsManagerPlatform instance) { PlatformInterface.verifyToken(instance, _token); _instance = instance; @@ -40,13 +41,15 @@ abstract class CredentialsManagerPlatform extends PlatformInterface { throw UnimplementedError('clearCredentials() has not been implemented'); } - /// Stores the given credentials in the native storage. Must have an access_token or id_token and a expires_in value. + /// Stores the given credentials in the native storage. Must have an + /// access_token or id_token and a expires_in value. Future saveCredentials( final CredentialsManagerRequest request) { throw UnimplementedError('saveCredentials() has not been implemented'); } - /// Checks if a non-expired pair of credentials can be obtained from the native storage. + /// Checks if a non-expired pair of credentials can be obtained from the + /// native storage. Future hasValidCredentials( final CredentialsManagerRequest request) { throw UnimplementedError('hasValidCredentials() has not been implemented'); diff --git a/auth0_flutter_platform_interface/lib/src/credentials-manager/method_channel_credentials_manager.dart b/auth0_flutter_platform_interface/lib/src/credentials-manager/method_channel_credentials_manager.dart index 4d00797c..77cd4dfe 100644 --- a/auth0_flutter_platform_interface/lib/src/credentials-manager/method_channel_credentials_manager.dart +++ b/auth0_flutter_platform_interface/lib/src/credentials-manager/method_channel_credentials_manager.dart @@ -20,9 +20,11 @@ const String credentialsManagerClearCredentialsMethod = const String credentialsManagerHasValidCredentialsMethod = 'credentialsManager#hasValidCredentials'; -/// Method Channel implementation to communicate with the Native CredentialsManager +/// Method Channel implementation to communicate with the Native +/// CredentialsManager class MethodChannelCredentialsManager extends CredentialsManagerPlatform { - /// Retrieves the credentials from the native storage and refresh them if they have already expired. + /// Retrieves the credentials from the native storage and refresh them if + /// they have already expired. /// /// Uses the [MethodChannel] to communicate with the Native platforms. @override @@ -34,7 +36,8 @@ class MethodChannelCredentialsManager extends CredentialsManagerPlatform { return Credentials.fromMap(result); } - /// Stores the given credentials in the native storage. Must have an access_token or id_token and a expires_in value. + /// Stores the given credentials in the native storage. Must have an + /// access_token or id_token and a expires_in value. /// /// Uses the [MethodChannel] to communicate with the Native platforms. @override @@ -55,7 +58,8 @@ class MethodChannelCredentialsManager extends CredentialsManagerPlatform { return result ?? true; } - /// Checks if a non-expired pair of credentials can be obtained from the native storage. + /// Checks if a non-expired pair of credentials can be obtained from the + /// native storage. /// /// Uses the [MethodChannel] to communicate with the Native platforms. @override diff --git a/auth0_flutter_platform_interface/lib/src/credentials-manager/options/get_credentials_options.dart b/auth0_flutter_platform_interface/lib/src/credentials-manager/options/get_credentials_options.dart index 490bfa7e..740b8416 100644 --- a/auth0_flutter_platform_interface/lib/src/credentials-manager/options/get_credentials_options.dart +++ b/auth0_flutter_platform_interface/lib/src/credentials-manager/options/get_credentials_options.dart @@ -1,7 +1,8 @@ import '../../request/request_options.dart'; // ignore: comment_references -/// Options used to retrieve [Credentials] using the [CredentialsManagerPlatform]. +/// Options used to retrieve [Credentials] using the +/// `CredentialsManagerPlatform`. class GetCredentialsOptions implements RequestOptions { final int minTtl; final Set scopes; diff --git a/auth0_flutter_platform_interface/lib/src/credentials-manager/options/has_valid_credentials_options.dart b/auth0_flutter_platform_interface/lib/src/credentials-manager/options/has_valid_credentials_options.dart index d34d04d6..ed1c1a5c 100644 --- a/auth0_flutter_platform_interface/lib/src/credentials-manager/options/has_valid_credentials_options.dart +++ b/auth0_flutter_platform_interface/lib/src/credentials-manager/options/has_valid_credentials_options.dart @@ -1,7 +1,8 @@ import '../../request/request_options.dart'; // ignore: comment_references -/// Options used to check if a non-expired pair of [Credentials] can be obtained using the [CredentialsManagerPlatform]. +/// Options used to check if a non-expired pair of [Credentials] can be obtained +/// using the `CredentialsManagerPlatform`. class HasValidCredentialsOptions implements RequestOptions { final int minTtl; diff --git a/auth0_flutter_platform_interface/lib/src/credentials-manager/options/local_authentication.dart b/auth0_flutter_platform_interface/lib/src/credentials-manager/options/local_authentication.dart index ff19d457..1f29b7f0 100644 --- a/auth0_flutter_platform_interface/lib/src/credentials-manager/options/local_authentication.dart +++ b/auth0_flutter_platform_interface/lib/src/credentials-manager/options/local_authentication.dart @@ -1,6 +1,7 @@ /// Settings for local authentication prompts. class LocalAuthentication { - /// Title to display on the local authentication prompt. Defaults to **Please authenticate to continue** on iOS, `null` on Android. + /// Title to display on the local authentication prompt. Defaults to **Please + /// authenticate to continue** on iOS, `null` on Android. final String? title; /// (Android only): Description to display on the local authentication prompt. @@ -9,7 +10,8 @@ class LocalAuthentication { /// (iOS only): Cancel message to display on the local authentication prompt. final String? cancelTitle; - /// (iOS only): Fallback message to display on the local authentication prompt after a failed match. + /// (iOS only): Fallback message to display on the local authentication prompt + /// after a failed match. final String? fallbackTitle; const LocalAuthentication( diff --git a/auth0_flutter_platform_interface/lib/src/credentials.dart b/auth0_flutter_platform_interface/lib/src/credentials.dart index 9e55662b..dce38d8d 100644 --- a/auth0_flutter_platform_interface/lib/src/credentials.dart +++ b/auth0_flutter_platform_interface/lib/src/credentials.dart @@ -1,18 +1,21 @@ import '../auth0_flutter_platform_interface.dart'; -/// A collection of authentication artifacts obtained from Auth0 when a user logs in. +/// A collection of authentication artifacts obtained from Auth0 when a user +/// logs in. class Credentials { /// A [JSON web token](https://jwt.io/introduction) that contains the user information. /// /// **Important**: The [ID tokens](https://auth0.com/docs/security/tokens/id-tokens) obtained from Web Auth login are automatically validated by the underlying native SDK, ensuring their /// contents have not been tampered with. /// - /// **This is not the case for the ID tokens obtained when using the authentication API directly.** + /// **This is not the case for the ID tokens obtained when using the + /// authentication API directly.** /// /// You must [validate ID tokens](https://auth0.com/docs/security/tokens/id-tokens/validate-id-tokens) received from the Authentication API client before using the information they contain. final String idToken; - /// Token that can be used to make authenticated requests to the specified API (the **audience** value used on login). + /// Token that can be used to make authenticated requests to the specified API + /// (the **audience** value used on login). /// /// ## Futher reading /// - [Access tokens](https://auth0.com/docs/security/tokens/access-tokens) @@ -21,7 +24,8 @@ class Credentials { /// Token that can be used to request a new access token. /// - /// The scope `offline_access` must have been requested on login for a refresh token to be returned. + /// The scope `offline_access` must have been requested on login for a refresh + /// token to be returned. /// /// [Read more about refresh tokens](https://auth0.com/docs/secure/tokens/refresh-tokens). final String? refreshToken; diff --git a/auth0_flutter_platform_interface/lib/src/request/request.dart b/auth0_flutter_platform_interface/lib/src/request/request.dart index 828ebcf7..6bcf7b32 100644 --- a/auth0_flutter_platform_interface/lib/src/request/request.dart +++ b/auth0_flutter_platform_interface/lib/src/request/request.dart @@ -24,7 +24,7 @@ class CredentialsManagerRequest required final Account account, final TOptions? options, required final UserAgent userAgent, - final this.localAuthentication, + this.localAuthentication, }) : super(account: account, options: options, userAgent: userAgent); @override diff --git a/auth0_flutter_platform_interface/lib/src/user_profile.dart b/auth0_flutter_platform_interface/lib/src/user_profile.dart index c11a4b52..5f5ae4fb 100644 --- a/auth0_flutter_platform_interface/lib/src/user_profile.dart +++ b/auth0_flutter_platform_interface/lib/src/user_profile.dart @@ -1,4 +1,5 @@ -/// A collection of properties that represents the authenticated user, extracted from ID token claims. +/// A collection of properties that represents the authenticated user, extracted +/// from ID token claims. class UserProfile { /// The Auth0 user identifier. final String sub; @@ -102,27 +103,27 @@ class UserProfile { final Map? customClaims; const UserProfile({ - required final this.sub, - final this.name, - final this.givenName, - final this.familyName, - final this.middleName, - final this.nickname, - final this.preferredUsername, - final this.profileUrl, - final this.pictureUrl, - final this.websiteUrl, - final this.email, - final this.isEmailVerified, - final this.gender, - final this.birthdate, - final this.zoneinfo, - final this.locale, - final this.phoneNumber, - final this.isPhoneNumberVerified, - final this.address, - final this.updatedAt, - final this.customClaims, + required this.sub, + this.name, + this.givenName, + this.familyName, + this.middleName, + this.nickname, + this.preferredUsername, + this.profileUrl, + this.pictureUrl, + this.websiteUrl, + this.email, + this.isEmailVerified, + this.gender, + this.birthdate, + this.zoneinfo, + this.locale, + this.phoneNumber, + this.isPhoneNumberVerified, + this.address, + this.updatedAt, + this.customClaims, }); factory UserProfile.fromMap(final Map result) => UserProfile( diff --git a/auth0_flutter_platform_interface/lib/src/web-auth/id_token_validation_config.dart b/auth0_flutter_platform_interface/lib/src/web-auth/id_token_validation_config.dart index 3b460bd2..f9e17b0d 100644 --- a/auth0_flutter_platform_interface/lib/src/web-auth/id_token_validation_config.dart +++ b/auth0_flutter_platform_interface/lib/src/web-auth/id_token_validation_config.dart @@ -1,12 +1,17 @@ /// Configuration settings for ID token validation. class IdTokenValidationConfig { - /// The value in seconds used to account for clock skew in JWT expirations. Typically, this value is no more than a minute or two at maximum. Defaults to 60 seconds. + /// The value in seconds used to account for clock skew in JWT expirations. + /// Typically, this value is no more than a minute or two at maximum. + /// Defaults to 60 seconds. final int? leeway; - /// The issuer to be used for validation of JWTs. Defaults to the domain used to when calling `Auth0.new`. + /// The issuer to be used for validation of JWTs. Defaults to the domain used + /// to when calling `Auth0.new`. final String? issuer; - /// Maximum allowable elasped time (in seconds) since authentication. If the last time the user authenticated is greater than this value, the user must be reauthenticated. Defaults to 0. + /// Maximum allowable elasped time (in seconds) since authentication. + /// If the last time the user authenticated is greater than this value, the + /// user must be reauthenticated. Defaults to 0. final int? maxAge; const IdTokenValidationConfig({this.leeway, this.issuer, this.maxAge}); diff --git a/auth0_flutter_platform_interface/lib/src/web-auth/safari_view_controller.dart b/auth0_flutter_platform_interface/lib/src/web-auth/safari_view_controller.dart index 83f08a64..51b519de 100644 --- a/auth0_flutter_platform_interface/lib/src/web-auth/safari_view_controller.dart +++ b/auth0_flutter_platform_interface/lib/src/web-auth/safari_view_controller.dart @@ -19,7 +19,8 @@ enum SafariViewControllerPresentationStyle { /// Configuration for using `SFSafariViewController` on iOS. class SafariViewController { - /// The presentation style used when opening the browser window. Defaults to `fullScreen`. + /// The presentation style used when opening the browser window. + /// Defaults to `fullScreen`. final SafariViewControllerPresentationStyle? presentationStyle; const SafariViewController({this.presentationStyle}); diff --git a/auth0_flutter_platform_interface/lib/src/web-auth/web_auth_login_options.dart b/auth0_flutter_platform_interface/lib/src/web-auth/web_auth_login_options.dart index a5bfaf18..24c508a4 100644 --- a/auth0_flutter_platform_interface/lib/src/web-auth/web_auth_login_options.dart +++ b/auth0_flutter_platform_interface/lib/src/web-auth/web_auth_login_options.dart @@ -1,5 +1,3 @@ -import 'package:flutter/foundation.dart'; - import '../request/request_options.dart'; import 'id_token_validation_config.dart'; import 'safari_view_controller.dart'; diff --git a/auth0_flutter_platform_interface/test/method_channel_auth0_flutter_auth_test.dart b/auth0_flutter_platform_interface/test/method_channel_auth0_flutter_auth_test.dart index a87f4dcb..1689e15f 100644 --- a/auth0_flutter_platform_interface/test/method_channel_auth0_flutter_auth_test.dart +++ b/auth0_flutter_platform_interface/test/method_channel_auth0_flutter_auth_test.dart @@ -1,3 +1,5 @@ +// ignore_for_file: lines_longer_than_80_chars + import 'package:auth0_flutter_platform_interface/auth0_flutter_platform_interface.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/auth0_flutter_platform_interface/test/method_channel_auth0_flutter_web_auth_test.dart b/auth0_flutter_platform_interface/test/method_channel_auth0_flutter_web_auth_test.dart index d49ce511..1c7d8549 100644 --- a/auth0_flutter_platform_interface/test/method_channel_auth0_flutter_web_auth_test.dart +++ b/auth0_flutter_platform_interface/test/method_channel_auth0_flutter_web_auth_test.dart @@ -1,3 +1,5 @@ +// ignore_for_file: lines_longer_than_80_chars + import 'package:auth0_flutter_platform_interface/auth0_flutter_platform_interface.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/auth0_flutter_platform_interface/test/method_channel_credentials_manager_test.dart b/auth0_flutter_platform_interface/test/method_channel_credentials_manager_test.dart index 8da91dee..f2067de5 100644 --- a/auth0_flutter_platform_interface/test/method_channel_credentials_manager_test.dart +++ b/auth0_flutter_platform_interface/test/method_channel_credentials_manager_test.dart @@ -1,3 +1,5 @@ +// ignore_for_file: lines_longer_than_80_chars + import 'package:auth0_flutter_platform_interface/auth0_flutter_platform_interface.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; From 110bd0c24ea77e4bfefd9f02509a97bf85172637 Mon Sep 17 00:00:00 2001 From: Steve Hobbs Date: Thu, 23 Feb 2023 13:23:25 +0000 Subject: [PATCH 3/3] chore: 'todo' lint rule is now a warning --- auth0_flutter/analysis_options.yaml | 2 +- auth0_flutter/example/analysis_options.yaml | 2 +- auth0_flutter_platform_interface/analysis_options.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/auth0_flutter/analysis_options.yaml b/auth0_flutter/analysis_options.yaml index adc438bd..4c7c392c 100644 --- a/auth0_flutter/analysis_options.yaml +++ b/auth0_flutter/analysis_options.yaml @@ -17,7 +17,7 @@ analyzer: unawaited_futures: error parameter_assignments: warning included_file_warning: warning - todo: ignore # 'warning' after EA + todo: warning linter: rules: diff --git a/auth0_flutter/example/analysis_options.yaml b/auth0_flutter/example/analysis_options.yaml index 1319ea4c..51300275 100644 --- a/auth0_flutter/example/analysis_options.yaml +++ b/auth0_flutter/example/analysis_options.yaml @@ -26,7 +26,7 @@ analyzer: unawaited_futures: error parameter_assignments: warning included_file_warning: warning - todo: ignore # 'warning' after EA + todo: warning linter: # The lint rules applied to this project can be customized in the diff --git a/auth0_flutter_platform_interface/analysis_options.yaml b/auth0_flutter_platform_interface/analysis_options.yaml index adc438bd..4c7c392c 100644 --- a/auth0_flutter_platform_interface/analysis_options.yaml +++ b/auth0_flutter_platform_interface/analysis_options.yaml @@ -17,7 +17,7 @@ analyzer: unawaited_futures: error parameter_assignments: warning included_file_warning: warning - todo: ignore # 'warning' after EA + todo: warning linter: rules: