StoredToken class

A bearer token for the pub client.

The value handed out is inpub_<id>.<secret>: the prefix makes it recognisable to a leak scanner, the id turns verification into one indexed lookup, and only a hash of the secret is stored, so a database dump yields nothing usable.

Constructors

StoredToken({required String id, required String secretHash, required TokenKind kind, required String email, required String displayName, required String name, required String createdBy, required DateTime createdAt, String? userId, DateTime? expiresAt, DateTime? lastUsedAt, String? lastUsedIp, DateTime? revokedAt, String? revokedReason})
const

Properties

createdAt DateTime
final
createdBy String
Who issued it. For a personal token, the owner themselves.
final
displayName String
final
email String
The identity recorded against anything published with this token. For a personal token it mirrors the owner; for a service token an administrator chooses it.
final
expiresAt DateTime?
final
hashCode int
The hash code for this object.
no setterinherited
id String
final
isRevoked bool
no setter
kind TokenKind
final
lastUsedAt DateTime?
final
lastUsedIp String?
final
name String
Human-readable label, so a list of tokens can be reasoned about.
final
revokedAt DateTime?
final
revokedReason String?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
secretHash String
final
userId String?
The account this belongs to. Null for a service token, which is exactly what makes it survive its creator leaving.
final

Methods

isExpired(DateTime now) bool
isUsable(DateTime now) bool
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toAuthenticatedUser({List<String> groups = const []}) AuthenticatedUser
toJson() Map<String, dynamic>
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

fromJson(Map<String, dynamic> json) StoredToken