AbstractIdentifer is a unique sequence to identify the token within database. It should be the primary/unique key
Reference to the user id for whom the token is generated.
Hash is computed from the seed to later verify the validity of seed
Timestamp at which the token will expire
OptionalvalueThe value is a public representation of a token. It is created by combining the "identifier"."secret" via the "computeValue" method
StaticdecodeDecodes a publicly shared token and return the series and the token value from it.
Returns null when unable to decode the token because of invalid format or encoding.
The token string to decode
StaticcreateCreates a transient token that can be shared with the persistence layer.
The user ID for whom the token is being created
The size of the random token seed
Token expiration time (string like '2h' or number in seconds)
StaticseedCreates a secret opaque token and its hash.
The length of the random token to generate
Check if the token has been expired. Verifies the "expiresAt" timestamp with the current date.
Verifies the value of a token against the pre-defined hash
The secret to verify against the stored hash
Verification token class can be used to create tokens publicly shareable tokens while storing the token hash within the database.
This class is used by the Auth and the Persona packages to manage tokens for authentication and authorization purposes.
Example