Constructor
new Token(id, data, usesRemaining, nextReset)
Token Constructor
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string | token string |
data |
* | reserved for future use |
usesRemaining |
number | Number of uses remaining until the token is exhausted |
nextReset |
number | Time when the token can be used again even if it's exhausted (unix timestamp) |
- Source:
Methods
freeze()
Freeze the uses remaining and next reset values. Helpful for keeping stable ordering for a valid priority queue.
- Source:
invalidate()
Indicate that the token should no longer be used.
- Source:
recordFailedAttempt() → {number}
Record a failed authentication attempt (HTTP 401) for this token.
- Source:
Returns:
The number of consecutive failed attempts so far.
- Type
- number
resetFailedAttempts()
Reset the failed-attempt counter, e.g. after a successful response.
- Source:
unfreeze()
Unfreeze the uses remaining and next reset values.
- Source:
update(usesRemaining, nextReset)
Update the uses remaining and next reset time for a token.
Parameters:
| Name | Type | Description |
|---|---|---|
usesRemaining |
number | Number of uses remaining until the token is exhausted |
nextReset |
number | Time when the token can be used again even if it's exhausted (unix timestamp) |
- Source: