FirebaseMock class
A class that represents and validates claims extracted from a Firebase JWT token.
Constructors
- FirebaseMock({required String alg, required String kid, required String aud, required int exp, required int iat, required int authTime, required String iss, required String sub})
- Constructs a FirebaseMock with the decoded JWT header and payload values.
Properties
- alg → String
-
The algorithm used to sign the token (should be RS256).
final
- aud → String
-
The audience claim, usually the Firebase project ID.
final
- authTime → int
-
The authentication time (
auth_timeclaim) of the token.final - exp → int
-
The expiration time (
expclaim) of the token.final - hashCode → int
-
The hash code for this object.
no setterinherited
- iat → int
-
The issued-at time (
iatclaim) of the token.final - iss → String
-
The issuer claim (
iss), should match the Firebase issuer URL.final - kid → String
-
The key ID used to match the correct public key for signature verification.
final
- projectID → String
-
Returns the project ID from the
audclaim.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sub → String
-
The subject claim (
sub), represents the user's UID.final - validateAlg → bool
-
Validates the algorithm used in the token.
no setter
-
validateExpIatAuthTime
→ Future<
bool> -
Validates
exp,iat, andauth_timeclaims using the current accurate time. Theexpclaim must be in the future, whileiatandauth_timemust be in the past.no setter - validateIss → bool
-
Validates that the issuer matches the expected Firebase URL format.
no setter
- validateSub → bool
-
Validates that the subject claim (
sub) is not empty.no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
Returns a readable string representation of the claims.
override
-
validateKeysByKid(
List< String> keys) → bool -
Checks whether the token's
kidis present in the list of known public keys. -
validateProjectID(
List< String> projectIds) → bool -
Validates that the
audclaim matches one of the provided Firebase project IDs.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
fromValue(
Map< String, dynamic> headers, Map<String, dynamic> payload) → FirebaseMock - Creates a FirebaseMock from the token header and payload maps.
Constants
- defaultAlg → const String
- The expected algorithm for Firebase tokens.