InMemoryAuthStore class

In-memory store for tests, examples, and local development.

This implementation deliberately keeps password hashes outside AuthUser attributes. It is not intended for production persistence; production applications should provide an implementation backed by their database and password-hashing policy.

Implemented types

Constructors

InMemoryAuthStore({AuthAnonymousInMemoryFaultInjector? anonymousFaultInjector, AuthEmailBackendFaultInjector? emailBackendFaultInjector, AuthPhoneNumberInMemoryFaultInjector? phoneNumberFaultInjector, int maxPhoneNumberVerifications = 2048, AuthUsernameFaultInjector? usernameFaultInjector, AuthUserDeletionFaultInjector? userDeletionFaultInjector})
Creates an in-memory store for tests and local development.

Properties

accounts AuthAccountStore
External provider-account persistence operations.
final
anonymousFaultInjector AuthAnonymousInMemoryFaultInjector?
Optional deterministic failures for anonymous-account rollback tests.
final
credentials AuthCredentialStore
Password credential persistence operations.
final
deviceAuthorizations AuthDeviceAuthorizationStore
Device-authorization persistence operations.
final
emailBackendFaultInjector AuthEmailBackendFaultInjector?
Optional deterministic failures for email backend rollback tests.
final
emailChangeTokens AuthEmailChangeTokenStore
Email-change token persistence operations.
final
emailOtps AuthEmailOtpStore
Email one-time-password persistence operations.
final
emailOtpStore AuthEmailOtpStore
OTP persistence boundary used by the plugin's deletion plan.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
jwtVersions AuthJwtVersionStore
JWT-version persistence operations.
final
maxPhoneNumberVerifications int
Maximum number of phone verifications retained in memory.
final
oauthChallenges AuthOAuthChallengeStore
OAuth authorization-challenge persistence operations.
final
passwordResetTokens AuthPasswordResetTokenStore
Password-reset token persistence operations.
final
phoneNumberFaultInjector AuthPhoneNumberInMemoryFaultInjector?
Optional deterministic failures for phone-number rollback tests.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sessions AuthSessionStore
Server-side session persistence operations.
final
userDeletionCoordinator AuthUserDeletionCoordinator
The user deletion coordinator exposed by this component.
no setteroverride
users AuthUserStore
User persistence operations.
final
verificationTokens AuthVerificationTokenStore
Email-verification token persistence operations.
final
webAuthnAuthenticators AuthWebAuthnAuthenticatorStore
Authenticator store owned by the capability provider.
final
webAuthnChallenges AuthWebAuthnChallengeStore
Challenge store owned by the capability provider.
final

Methods

bindUserDeletionPlanContributors(Iterable<AuthUserDeletionPlanContributor> contributors) → void
Freezes the complete plugin-owned deletion topology.
override
captureDeletionState() Object
Captures deletion state.
override
changeUsername(AuthUsernameChangeCommand command) Future<AuthUsernameMutationResult>
Changes a username while preserving uniqueness atomically.
override
completeAnonymousAccountUpgrade(AuthAnonymousCompleteUpgradeCommand command) Future<AuthAnonymousMutationResult>
Completes anonymous account upgrade.
override
Consumes a link and resolves or creates its verified user atomically.
override
consumeUserDeletionToken(String userId, String token) Future<bool>
Consumes user deletion token.
override
createAnonymousAccount(AuthAnonymousCreateAccountCommand command) Future<AuthAnonymousMutationResult>
Creates anonymous account.
override
delete(String userId) Future<void>
Removes all policy state belonging to userId.
override
deleteAnonymousAccount(AuthAnonymousDeleteAccountCommand command) Future<AuthAnonymousMutationResult>
Deletes anonymous account.
override
deleteCoreUserData(String userId) Future<bool>
Deletes core user data.
override
deleteUserForAdministration(String userId) Future<bool>
Deletes all core user-owned records as one transaction.
override
disable(String userId, {String? reason, DateTime? now}) Future<AuthAccountState>
Disables an account.
override
enable(String userId, {DateTime? now}) Future<AuthAccountState>
Enables a disabled account.
override
find(String userId) Future<AuthAccountState?>
Finds account state by user ID.
override
findByUsername(String username) Future<AuthPasswordCredential?>
Finds a username credential by its canonical username.
override
findCredentialForUser(String userId) Future<AuthPasswordCredential?>
Finds a password credential owned by userId.
override
findInactiveAccounts({required int inactiveDays, DateTime? now}) Future<List<AuthAccountState>>
Lists accounts that should be auto-disabled due to inactivity.
override
findPhoneNumberIdentity(String phoneNumber) Future<AuthPhoneNumberIdentity?>
Finds the identity bound to phoneNumber.
override
findPhoneNumberIdentityForUser(String userId) Future<AuthPhoneNumberIdentity?>
Finds the phone identity owned by userId.
override
findUserForDeletion(String userId) Future<AuthUser?>
Looks up user for deletion.
override
findUsernameForUser(String userId) Future<AuthPasswordCredential?>
Finds the username credential owned by userId.
override
issueEmailOtp(AuthEmailOtpIssueCommand command) Future<void>
Replaces the active email/purpose OTP atomically.
override
Replaces the active provider/email record atomically.
override
issuePhoneNumberCode(AuthPhoneNumberIssueCodeCommand command) Future<AuthPhoneNumberIssueResult>
Issues a challenge in the store-owned transaction.
override
listUsersForAdministration() Future<List<AuthUser>>
Lists users for an administrative view.
override
markEmailVerified(String userId, {DateTime? now}) Future<AuthAccountState>
Marks email as verified.
override
mutateAuthenticationMethodIfSafe({required String userId, required AuthAuthenticationMethod target, required AuthAuthenticationMethodInventoryLoader loadInventory, required AuthAuthenticationMethodMutation mutate}) Future<AuthAuthenticationMethodMutationResult>
Mutates target only when loadInventory proves it is safe.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
purgeTombstonedUserForAdministration(String userId) Future<bool>
Permanently removes a previously tombstoned user during retention purge.
override
recordEmailVerificationSent(String userId, {DateTime? now}) Future<AuthAccountState>
Updates the last email verification sent timestamp.
override
recordFailedLogin(String userId, {required AuthAccountPolicy policy, DateTime? now}) Future<AuthAccountState>
Records a failed login attempt and potentially locks the account.
override
recordLogin(String userId, {DateTime? now}) Future<AuthAccountState>
Records a successful login.
override
registerUsername(AuthUsernameRegistrationCommand command) Future<AuthUsernameMutationResult>
Registers a username and its password credential atomically.
override
removePhoneNumberIfSafe(AuthPhoneNumberRemovalCommand command) Future<AuthAuthenticationMethodMutationResult>
Removes the identity when the composed auth topology remains usable.
override
removeUsernameIfSafe(AuthUsernameRemovalCommand command) Future<AuthAuthenticationMethodMutationResult>
Removes the exact username credential only when another usable method remains.
override
resetFailedAttempts(String userId, {DateTime? now}) Future<AuthAccountState>
Resets failed login attempts after successful authentication.
override
restoreDeletionState(Object state) → void
Restores deletion state.
override
signInWithEmailOtp(AuthEmailOtpSignInCommand command) Future<AuthEmailOtpUserTransitionResult>
Consumes a sign-in OTP and applies its user transition atomically.
override
tombstoneUserForAdministration(String userId, {DateTime? deletedAt}) Future<bool>
Replaces a user with a minimal unavailable tombstone and removes the user's core credentials, identities, sessions, and reset tokens.
override
toString() String
A string representation of this object.
inherited
unlinkOAuthAccountIfSafe({required String userId, required String providerId, required String providerAccountId, required AuthAuthenticationMethodInventoryLoader loadInventory}) Future<AuthAuthenticationMethodMutationResult>
Unlinks the exact provider account when the mutation is safe.
override
unlock(String userId, {DateTime? now}) Future<AuthAccountState>
Unlocks a locked account.
override
updateUserForAdministration(AuthUser user) Future<AuthUser?>
Updates a user through an administrative operation.
override
upsert(AuthAccountState state) Future<AuthAccountState>
Creates or updates account state.
override
upsertCredentialForAdministration(AuthPasswordCredential credential) Future<AuthPasswordCredential>
Creates or updates a password credential through administration.
override
validateUserDeletion(String userId) Future<void>
Validates user deletion.
override
verifyEmailOtp(AuthEmailOtpVerifyCommand command) Future<AuthEmailOtpVerificationResult>
Compares a digest, counts the attempt, and consumes a valid OTP atomically.
override
verifyPhoneNumberCode(AuthPhoneNumberVerifyCodeCommand command) Future<AuthPhoneNumberVerifyResult>
Verifies and consumes a challenge in the store-owned transaction.
override
verifyUserEmailWithOtp(AuthEmailOtpVerifyUserCommand command) Future<AuthEmailOtpUserTransitionResult>
Consumes an authenticated user's email-verification OTP atomically.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited