BasicAuthenticationConfig class
Constructors
-
BasicAuthenticationConfig.new({required Uri loginCredentialsAPIendpoint(), required Uri signupCredentialsAPIendpoint(), FutureOr<AuthenticationData> customLoginResponseParser(String response)?, FutureOr<User>? customUserMapper(Map<String, dynamic> userMap)?, Uri refreshTokenAPIendpoint(String refreshToken, JWT token)?, bool debug = false, FutureOr<Map<String, dynamic>> customLoginRequestMapper(String email, String password, AuthDeviceInfo? deviceInfo)?, FutureOr<AuthenticationData>? customSignupCredentialsResponseParser(String body)?, bool authenticateOnSignup = true, FutureOr<AuthCredentialsProvider> customAutoSignupAuthClbk(AuthSignUpPayload payload, AuthenticationData? authData)?, Uri fetchUserInformationAPIendpoint(AuthenticationData data)?, FutureOr<Map<String, dynamic>> customFetchUserInformationResponseMapper(Map<String, dynamic> data)?, bool initialAuthCheckedAfterUserFetch = true, bool autoLogoutOnSessionExpired = true, Duration? maxAge, FutureOr<Map<String, String>> customRefreshTokenResponseParser(String body)?, void onRefreshToken(Map<String, String> tokens)?, String? refreshTokenMethod, FutureOr<String> customRefreshTokenRequestBodyMapper(String refreshToken, String authToken, AuthDeviceInfo? deviceInfo)?, Duration? refreshTokenTimeout, void onRefreshTokenFailure(String token, Object exception)?, required Uri deleteAccountApiEndpoint(String userId), User? deleteAccountCustomResponseParser(Map<String, dynamic> response)?, bool logoutAfterDelete = true, FutureOr<Map<String, String>> customRefreshTokenCallback(String token, String? refreshToken, AuthDeviceInfo? deviceInfo)?, bool provideDeviceInfo = true})
-
Properties
-
authenticateOnSignup
→ bool
-
Specifies if the library should automatically authenticate the user after a successful signup
This will be performed just if the system successfully extracts an AuthenticationData from the response
or if user have defined a customAutoSignupAuthClbk callback
if this is set t true and the library fails to authenticate it will notify the result on the bloc bia AutoSignupAuthResult
Defaults to
true
final
-
autoLogoutOnSessionExpired
→ bool
-
Dispatch Logout event if session expired error returned from fetchUserData API
Defaults to
true
final
-
customAutoSignupAuthClbk
→ FutureOr<AuthCredentialsProvider> Function(AuthSignUpPayload payload, AuthenticationData? authData)?
-
Provides a callback to be used when trying to signIn after a successful signup
This is useful when no AuthenticationData was returned from the API call or may it's missing data
It provides access to the submitted AuthSignUpPayload and the returned AuthenticationData if any.
Should return a
final
-
customFetchUserInformationResponseMapper
→ FutureOr<Map<String, dynamic>> Function(Map<String, dynamic> data)?
-
Provides a way to transform fetchUserInformationAPIendpoint response to user map, then customUserMapper will be
used to the
final
-
customLoginRequestMapper
→ FutureOr<Map<String, dynamic>> Function(String email, String password, AuthDeviceInfo? deviceInfo)?
-
Provides a custom function that allows you to customize the way your request's body is sent to the API
Example
function(email, password) {
return {
'custom-email-key': email,
'custom-password-key': password,
}
}
final
-
customLoginResponseParser
→ FutureOr<AuthenticationData> Function(String response)?
-
Provides a way to transform Login response by providing RAW body
final
-
customRefreshTokenCallback
→ FutureOr<Map<String, String>> Function(String token, String? refreshToken, AuthDeviceInfo? deviceInfo)?
-
final
-
customRefreshTokenRequestBodyMapper
→ FutureOr<String> Function(String refreshToken, String authToken, AuthDeviceInfo? deviceInfo)?
-
Provide a function to be used in order to use/pass the refresh token to the
API endpoint
final
-
customRefreshTokenResponseParser
→ FutureOr<Map<String, String>> Function(String body)?
-
Defines a custom function to parse the response of your refresh token API, you must return an object
with "refreshToken" and "authToken", so it can replace your current session one
Example
{
"auth-token": "YourParsedAuthToken",
"auth-refresh-token": "YourParsedRefreshToken"
}
final
-
customSignupCredentialsResponseParser
→ FutureOr<AuthenticationData>? Function(String body)?
-
Provides a way to transform Signup with Credentials response by providing access to RAW body
final
-
customUserMapper
→ FutureOr<User>? Function(Map<String, dynamic> userMap)?
-
Provides a custom user mappers that will be using when decoding a user from user data API and from
auth session
final
-
debug
→ bool
-
Provides a flag for printing useful debugging data
Defaults to
false
final
-
deleteAccountApiEndpoint
→ Uri Function(String userId)
-
Provides an endpoint to be used when request an account delete
final
-
deleteAccountCustomResponseParser
→ User? Function(Map<String, dynamic> response)?
-
Provides a way to customize the way the response is parsed
final
-
fetchUserInformationAPIendpoint
→ Uri Function(AuthenticationData data)?
-
Provides an endpoint to be used when trying to fetch with credentials
final
-
hashCode
→ int
-
The hash code for this object.
no setterinherited
-
initialAuthCheckedAfterUserFetch
→ bool
-
Dispatch
initialAuthChecked
event just after we have an initial user fetch data
Defaults to true
final
-
loginCredentialsAPIendpoint
→ Uri Function()
-
Provides an endpoint to be used when trying to login with credentials
final
-
logoutAfterDelete
→ bool
-
Determine if user should be logged out after account deletion
Defaults to
true
final
-
maxAge
→ Duration?
-
Defines the JWT age thresshold in which the refresh token logic will trigger
final
-
onRefreshToken
→ void Function(Map<String, String> tokens)?
-
This Callback is called whenever a refresh token have been successfully retrieved
It provides access to the retrieved tokens
final
-
onRefreshTokenFailure
→ void Function(String token, Object exception)?
-
This Callback is called whenever a refresh token fail to be retrieved
It provides access to the refresh token used & the exception raised
final
-
provideDeviceInfo
→ bool
-
Provides device info to be associated with auth session
final
-
refreshTokenAPIendpoint
→ Uri Function(String refreshToken, JWT token)?
-
Defines a function to the URL in which a new token can be requested
Defining this property activates the 'refreshToken' mechanism
final
-
refreshTokenMethod
→ String?
-
Defines the 'http' (POST, PUT, etc) method to be used when requesting a new token to the API
final
-
refreshTokenTimeout
→ Duration?
-
Define a custom period to wait for the refresh token API, after defined period if no response
the API call waiting for the token will throw
final
-
runtimeType
→ Type
-
A representation of the runtime type of the object.
no setterinherited
-
signupCredentialsAPIendpoint
→ Uri Function()
-
Provides an endpoint to be used when trying to signup
final
Methods
-
copyWith({Uri loginCredentialsAPIendpoint()?, Uri signupCredentialsAPIendpoint()?, FutureOr<AuthenticationData> customLoginResponseParser(String response)?, FutureOr<User>? customUserMapper(Map<String, dynamic> userMap)?, Uri refreshTokenAPIendpoint(String refreshToken, JWT token)?, bool? debug, FutureOr<Map<String, dynamic>> customLoginRequestMapper(String email, String password, AuthDeviceInfo? deviceInfo)?, FutureOr<AuthenticationData>? customSignupCredentialsResponseParser(String response)?, bool? authenticateOnSignup, AuthCredentialsProvider customAutoSignupAuthClbk(AuthSignUpPayload payload, AuthenticationData? authData)?, Uri fetchUserInformationAPIendpoint(AuthenticationData data)?, FutureOr<Map<String, dynamic>> customFetchUserInformationResponseMapper(Map<String, dynamic> data)?, bool? initialAuthCheckedAfterUserFetch, bool? autoLogoutOnSessionExpired, Duration? maxAge, FutureOr<Map<String, String>> customRefreshTokenResponseParser(String body)?, void onRefreshToken(Map<String, String> tokens)?, String? refreshTokenMethod, FutureOr<String> customRefreshTokenRequestBodyMapper(String refreshToken, String authToken, AuthDeviceInfo? deviceInfo)?, Duration? refreshTokenTimeout, void onRefreshTokenFailure(String token, Object exception)?, Uri deleteAccountApiEndpoint(String userId)?, User? deleteAccountCustomResponseParser(Map<String, dynamic> response)?, bool? logoutAfterDelete, FutureOr<Map<String, String>> customRefreshTokenCallback(String token, String? refreshToken, AuthDeviceInfo? deviceInfo)?, bool? provideDeviceInfo})
→ BasicAuthenticationConfig
-
-
noSuchMethod(Invocation invocation)
→ dynamic
-
Invoked when a nonexistent method or property is accessed.
inherited
-
toString()
→ String
-
A string representation of this object.
inherited