FreedomeAccountClient class final
Client of the cloud account API (/api/v1/auth/*, /api/v1/me).
Constructors
- FreedomeAccountClient({Uri? baseUri, TokenStore? tokenStore, FreedomeTransportFactory? transports, FreedomeLogger? logger, String appName = 'app', String appVersion = '0', bool native = true, Duration timeout = const Duration(seconds: 10)})
-
Creates a client for
baseUri(scheme://host[:port]); tokens persist intokenStore(secure store in apps).
Properties
- appName → String
-
App name (
X-Freedome-Client).final - appVersion → String
-
App version.
final
- endpoint → FreedomeEndpoint
-
The cloud endpoint.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- logger → FreedomeLogger?
-
Log sink.
final
- native → bool
-
Native app (
client: native, refresh token in the body) or web (client: web, refresh cookie).final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- session → AccountSession?
-
Current session (null = signed out).
no setter
-
sessions
→ Stream<
AccountSession?> -
Session changes.
no setter
- tokenStore → TokenStore
-
Token persistence (key
cloud:<host>).final
Methods
-
accessToken(
{Duration skew = const Duration(seconds: 30)}) → Future< String> -
A valid access JWT (refreshed when it expires within
skew) — passCloudCredentials(account.accessToken)to a media-server client. Throws UnauthorizedException when signed out. -
cancelDeletion(
) → Future< CloudAccount> - Cancels a requested deletion.
-
changePassword(
String currentPassword, String newPassword) → Future< void> - Changes the password of the signed-in account.
-
checkEmail(
String email) → Future< bool> -
Whether an e-mail is still free. The cloud contract has no availability endpoint (sign-up answers 409 for a
taken e-mail): throws UnsupportedCapabilityException (SYNC TODO CT/CL:
GET /auth/availability). -
checkUsername(
String username) → Future< bool> - Whether a user name is still free — the cloud identifies accounts by e-mail only; see checkEmail.
-
close(
) → Future< void> - Releases the HTTP client.
-
confirmEmail(
String token) → Future< void> - Confirms the e-mail with the token of the verification mail.
-
deleteAccount(
) → Future< CloudAccount> - Requests account deletion (7-day grace; store requirement).
-
devices(
) → Future< List< CloudLoginDevice> > - Signed-in devices (sessions).
-
me(
) → Future< CloudAccount> -
The signed-in account (
GET /me). -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
refresh(
) → Future< bool> -
Rotates the refresh token (
POST /auth/refresh); false when the session is gone (→ sign in again). -
removeDevice(
String sessionId) → Future< void> - Signs out one device.
-
requestMagicLink(
String email) → Future< void> - Sends a sign-in link by e-mail.
-
requestReset(
String email) → Future< void> - Starts a password reset (mail with a token).
-
resendConfirmation(
) → Future< void> - Sends the verification mail again.
-
reset(
String token, String newPassword) → Future< void> - Completes a password reset.
-
restore(
) → Future< CloudAccount?> -
Restores a stored session (validated with
GET /me, refreshed when needed); null when there is none. -
signIn(
String email, String password) → Future< CloudAccount> -
Signs in with e-mail + password (
POST /auth/sign-in). -
signInWithProvider(
String provider, String idToken, {String? nonce, String? displayName}) → Future< CloudAccount> -
Sign in with Apple / Google (
POST /auth/oauth/{provider}with the provider's id token). -
signOut(
{bool all = false}) → Future< void> -
Signs out this session (
all: every session of the account). -
signUp(
{required String email, required String password, String? displayName, String? locale}) → Future< CloudAccount> -
Creates an account and signs in (
POST /auth/sign-up). -
toString(
) → String -
A string representation of this object.
inherited
-
updateProfile(
{String? displayName, String? locale}) → Future< CloudAccount> - Updates display name / locale.
-
verifyMagicLink(
String token) → Future< CloudAccount> - Signs in with the token of a magic link.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited