AuthApiKeyRecord class final

The persisted representation of an API key.

secretHash is the digest of the client-held key. The raw API key is never persisted and is only returned by AuthApiKeyIssued at creation or rotation time.

Constructors

AuthApiKeyRecord({required String id, required String userId, required String name, required String keyPrefix, required String secretHash, required List<String> scopes, required DateTime createdAt, required DateTime updatedAt, DateTime? expiresAt, DateTime? lastUsedAt, DateTime? revokedAt})
Creates a persisted API-key record.

Properties

createdAt DateTime
Time at which the key was created.
final
expiresAt DateTime?
Time after which the key is inactive, if configured.
final
hashCode int
The hash code for this object.
no setterinherited
id String
Stable identifier for this key.
final
keyPrefix String
Non-secret prefix used to identify the key family.
final
lastUsedAt DateTime?
Time at which the key was last used, if known.
final
name String
Human-readable key name.
final
revokedAt DateTime?
Time at which the key was revoked, if revoked.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scopes List<String>
Scopes granted to this key.
final
secretHash String
Digest of the raw key used during authentication.
final
updatedAt DateTime
Time at which the record was last changed.
final
userId String
Identifier of the owning user.
final

Methods

copyWith({String? id, String? userId, String? name, String? keyPrefix, String? secretHash, List<String>? scopes, DateTime? createdAt, DateTime? updatedAt, DateTime? expiresAt, DateTime? lastUsedAt, DateTime? revokedAt, bool clearExpiresAt = false, bool clearLastUsedAt = false, bool clearRevokedAt = false}) AuthApiKeyRecord
Returns a copy with selected record fields replaced.
isActive({DateTime? now}) bool
Returns whether the key is usable at now.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toPublic({DateTime? now}) AuthApiKey
Returns the safe public projection of this key.
toStorageJson() Map<String, dynamic>
Serializes persistence fields, including the non-reversible secret hash.
toString() String
A string representation of this object.
inherited

Operators

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