Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Flutter used for build, and fix linter warnings #199

Merged
merged 3 commits into from
Feb 23, 2023
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ orbs:
parameters:
flutter_version:
type: string
default: 3.0.5
default: 3.7.4
jobs:
test_flutter_package:
docker:
Expand Down
4 changes: 2 additions & 2 deletions auth0_flutter/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ analyzer:
unawaited_futures: error
parameter_assignments: warning
included_file_warning: warning
todo: ignore # 'warning' after EA
todo: warning

linter:
rules:
Expand Down Expand Up @@ -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
Widcket marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
4 changes: 2 additions & 2 deletions auth0_flutter/example/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Widcket marked this conversation as resolved.
Show resolved Hide resolved
missing_whitespace_between_adjacent_strings: true
no_leading_underscores_for_library_prefixes: true
no_leading_underscores_for_local_identifiers: true
Expand Down
2 changes: 1 addition & 1 deletion auth0_flutter/example/lib/api_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'constants.dart';

class ApiCard extends StatefulWidget {
final Future<void> Function(String usernameOrEmail, String password) action;
const ApiCard({required final this.action, final Key? key}) : super(key: key);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes unnecessary final warnings, as these are implicitly final.

const ApiCard({required this.action, final Key? key}) : super(key: key);

@override
ApiCardState createState() {
Expand Down
3 changes: 1 addition & 2 deletions auth0_flutter/example/lib/web_auth_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ class WebAuthCard extends StatelessWidget {
final String label;
final Future<void> 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
Expand Down
29 changes: 20 additions & 9 deletions auth0_flutter/lib/auth0_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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})
Expand All @@ -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:
///
Expand All @@ -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,
Expand Down
47 changes: 32 additions & 15 deletions auth0_flutter/lib/src/authentication_api.dart
Original file line number Diff line number Diff line change
@@ -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:
///
Expand All @@ -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
Expand All @@ -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
///
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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> userProfile(
{required final String accessToken,
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<void> resetPassword(
{required final String email,
Expand Down
27 changes: 18 additions & 9 deletions auth0_flutter/lib/src/credentials_manager.dart
Original file line number Diff line number Diff line change
@@ -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> credentials({
final int minTtl = 0,
Expand All @@ -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;
Expand All @@ -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> credentials({
final int minTtl = 0,
Expand All @@ -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<bool> 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<bool> hasValidCredentials({
final int minTtl = 0,
Expand Down
Loading