FirebaseProjectAuth class

ProjectAuth on Firebase Auth and the Codelessly backend.

Signs in anonymously when nobody is signed in, reads the cached access (valid while it's for the same token and the user's token still has the project's claim, then verified again in the background), else verifies the project token with the backend and waits for the claim to reach the user's token: it polls (no auth event follows a claim), re-verifies every claimsReverifyEvery polls in case the claim was granted and lost, and fails after claimsPropagationTimeout instead of hanging.

Implemented types

Constructors

FirebaseProjectAuth({required ProjectAuthConfig config, required FirebaseAuth auth, Client? client, KeyValueCache? cache, Duration claimsPropagationTimeout = const Duration(seconds: 30), Duration claimsPollInterval = const Duration(seconds: 2), int claimsReverifyEvery = 3, Duration restoreTimeout = const Duration(seconds: 3), bool? claimsFromToken, void onError(Object error, StackTrace stack)?})

Properties

access → ProjectAccess?
The current access, or null before (or without) authentication.
no setteroverride
auth → FirebaseAuth
final
cache → KeyValueCache
final
changes → Stream<ProjectAccess?>
access, on every change.
no setteroverride
claimsFromToken → bool
Reads claims from the token's payload (Windows, where the plugin doesn't return them).
final
claimsPollInterval → Duration
final
claimsPropagationTimeout → Duration
final
claimsReverifyEvery → int
final
client → Client
final
config → ProjectAuthConfig
final
hasCloudAccess → bool
Whether the signed-in user's token has the project's claim.
no setter
hashCode → int
The hash code for this object.
no setterinherited
onError → void Function(Object error, StackTrace stack)?
Errors of background verification.
final
restoreTimeout → Duration
How long authenticate waits for Firebase to restore a persisted user before signing in anonymously.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

authenticate() → Future<ProjectAccess>
Authenticates (from the cache when it's still valid, verifying in the background). Throws when it fails.
override
dispose() → void
override
hasProjectClaim(IdTokenResult? result, String projectId) → bool
Whether result's claims give access to projectId.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reauthenticate() → Future<void>
Authenticates again for the user now signed in.
override
toString() → String
A string representation of this object.
inherited
verifyProjectToken(String userToken) → Future<ProjectAccess?>
Asks the backend to grant the user the project's claim for the app's project token: the access, or null when it refused.
waitForClaim(String projectId) → Future<void>
Completes once the signed-in user's token has projectId's claim.

Operators

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

Constants

cacheKey → const String