Class: TokenSet

TokenSet(tokens, claimsopt)

Immutable-ish holder for a token endpoint response. Serializable via toJSON()/TokenSet.from().

Constructor

new TokenSet(tokens, claimsopt)

Parameters:
Name Type Attributes Description
tokens Record.<string, any>

Token endpoint response (snake_case), optionally with expires_at (epoch seconds).

claims Record.<string, any> <optional>

Validated ID token claims, if an ID token was issued.

Source:

Classes

TokenSet

Members

access_token :string

Type:
  • string
Source:

claims

The validated ID token's claims. @type {Record<string, any>|undefined}

Source:

expires_at

Epoch seconds when the access token expires. @type {number|undefined}

Source:

id_token :string|undefined

Type:
  • string | undefined
Source:

issued_at

Epoch seconds when the tokens were issued. @type {number|undefined}

Source:

refresh_token :string|undefined

Type:
  • string | undefined
Source:

scope :string|undefined

Type:
  • string | undefined
Source:

token_type

'Bearer' or 'DPoP'. @type {string}

Source:

Methods

effectiveSkew(skewSec)

Skew to apply for early renewal, capped at half the token lifetime so short-lived tokens aren't considered expired the moment they're issued.

Parameters:
Name Type Description
skewSec number
Source:

expiresIn() → {number|undefined}

Source:
Returns:

Seconds until the access token expires.

Type
number | undefined

isExpired(skewSecopt)

Parameters:
Name Type Attributes Default Description
skewSec number <optional>
0

Treat the token as expired this many seconds early (see effectiveSkew).

Source:

toJSON() → {Record.<string, any>}

Source:
Returns:
Type
Record.<string, any>

(static) from(value) → {TokenSet}

Parameters:
Name Type Description
value TokenSet | Record.<string, any>

A TokenSet, or one as stored (toJSON()).

Source:
Returns:
Type
TokenSet