DVSessionClient class
The generated backend's sessions, from the device.
The generated runtime installs one over the application's backend, hands
its token to DartvelClient.setAuthToken through onToken, and makes it
DV.Auth's provider unless the application configures its own.
Constructors
-
DVSessionClient({required Uri api(String path), void onToken(String? token)?, DVSessionTokenStore? tokens, bool? web, String? device, Future<
DVHttpResponse> send(DVHttpRequest request)?})
Properties
- api → Uri Function(String path)
-
The backend URL for an API path, such as
DartvelRuntime.api.final - awaitingSecondFactor → bool
-
Whether a sign-in is waiting for its second factor.
no setter
- current → DVSession?
-
This device's session, or null when nobody is signed in here.
no setter
- deletionCancelled → bool
-
Whether the last sign-in on this device cancelled a deletion the
account was waiting out, so a sign-in page can say so: a person who
asked for their account to be deleted is told signing in kept it.
no setter
- device → String?
-
What the platform reports the device as, recorded on the session.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- onToken → void Function(String? token)?
-
Called with the live token when there is one and with null when there
no longer is -- never with a token waiting for its second factor, and
never in a browser.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
session
→ DVLifecycleSignal<
DVSession?> -
This device's session as a read-only signal. Only the server's answers
change it.
no setter
- web → bool
-
Whether this runs in a browser, where the cookie is the session.
final
Methods
-
account(
) → Future< DVAccount> - The signed-in person's account, including an address change still waiting for its code.
-
beginTotpEnrollment(
) → Future< DVTotpEnrollment> - Starts enrolling an authenticator app: the secret to show as a QR code and as text. Nothing is active, and this device keeps none of it, until confirmTotpEnrollment presents a code from the app.
-
changePassword(
{required String currentPassword, required String newPassword, String? code, String? recoveryCode}) → Future< int> -
Changes the password, presenting the current one -- and a
codeorrecoveryCodewhen the account has a second factor. This device adopts the rotated session; the answer is how many other sessions the server revoked. -
completeSecondFactor(
{String? code, String? recoveryCode}) → Future< DVAuthUser> - Presents a code from the account's authenticator, or one recovery code, for the sign-in waiting on it -- or again, as step-up, for this session.
-
confirmEmailChange(
String code) → Future< DVAccount> - Presents the code sent to the new address. The address changes, the server rotates the session, and this device keeps the rotated one.
-
confirmTotpEnrollment(
String code) → Future< void> -
Activates the authenticator being enrolled with a
codefrom it. The server rotates the session, and this device keeps the rotated one. -
deleteAccount(
{required String password, String? code, String? recoveryCode}) → Future< DateTime?> -
Deletes the account, presenting its
password-- and acodeorrecoveryCodewhen it has a second factor. Only once the server confirms is the session forgotten here; a refusal throws and leaves the device signed in. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
refresh(
) → Future< DVSession?> - Asks the server which session this device is on.
-
regenerateRecoveryCodes(
) → Future< DVRecoveryCodes> - A new set of recovery codes, replacing every earlier one. The returned codes are the only copy anywhere: they are not stored on this device.
-
removeSecondFactor(
{String? code, String? recoveryCode}) → Future< void> -
Removes the authenticator and every recovery code, presenting a
codefrom the authenticator or onerecoveryCodewith the request. -
requestEmailChange(
String email) → Future< void> -
Asks for the account's address to become
email. The server sends a code to that address; nothing changes until confirmEmailChange presents it. -
restore(
) → Future< DVSession?> - At launch: the stored session, if the server still honours it.
-
revoke(
String sessionId) → Future< void> - Revokes one of the signed-in person's sessions by its listed id. The server refuses another person's as not found, which throws here. Revoking this device's own session signs this device out.
-
revokeOthers(
) → Future< int> - Revokes every other session of the signed-in person on this tenant and answers how many. This device's session is the one the server keeps.
-
secondFactors(
) → Future< DVSecondFactorStatus> - Whether the signed-in person has an authenticator, and how many unspent recovery codes. A count: no endpoint answers a code twice.
-
send(
String method, String path, {Map< String, Object?> ? body}) → Future<DVHttpResponse> - Sends one request to the application's own backend as this session: the bearer token on a device, the cookie and CSRF token in a browser.
-
sessions(
) → Future< List< DVSession> > - Every live session of the signed-in person on this tenant, newest sign-in first, with this device's marked current. The server answers for the person this session belongs to and nobody else.
-
signIn(
{required String email, required String password}) → Future< DVAuthUser> - Signs in. Throws DVMfaRequired when the account has a second factor, which completeSecondFactor then presents.
-
signOut(
) → Future< void> - Revokes this session on the server, then forgets it here.
-
signUp(
{required String email, required String password, String? name}) → Future< DVAuthUser> - Creates an account and signs in.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- installed → DVSessionClient?
-
The client the generated runtime installed, or null.
no setter
Static Methods
-
install(
DVSessionClient client) → void -
uninstall(
) → void - Takes the installed client away, for a test.