Class: GrantSet

GrantSet(fields, claimsopt)

What a GNAP grant gave this client: one access token, how to manage it, how to continue the grant, and who the resource owner is. Serializable with toJSON() / GrantSet.from().

The access token is bound to the client key (it is presented as Authorization: GNAP <value> with an HTTP message signature) unless bearer is true.

Constructor

new GrantSet(fields, claimsopt)

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

Snake-case fields, optionally with expires_in (seconds).

claims Record.<string, any> <optional>

The validated identity of the resource owner.

Source:

Classes

GrantSet

Members

access

The access rights the token carries (RFC 9635 section 8). @type {Array<string|Record<string, any>>|undefined}

Source:

access_token

The access token's value. @type {string}

Source:

bearer

The token was issued with the bearer flag: no key proof is sent with it. @type {boolean|undefined}

Source:

claims

Who the resource owner is, as this client validated it: iss and sub from an iss_sub subject identifier (or an opaque one, with the grant endpoint as iss), uid (their username) and account from an account one, and the profile claims of an id_token assertion when one was verified. @type {Record<string, any>|undefined}

Source:

continue

Continuation (section 5): { uri, access_token: { value }, wait? }. @type {Object} (TypeScript: { uri: string, access_token: { value: string }, wait?: number }|undefined)

Source:

expires_at

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

Source:

flags

The access token's flags (RFC 9635 section 3.2.1). @type {string[]|undefined}

Source:

grant_endpoint

The grant endpoint that issued it. @type {string|undefined}

Source:

grant_id

The grant's id: the last path segment of the continuation URI. @type {string|undefined}

Source:

instance_id

The instance_id the AS handed this client instance (section 3.5), if any. @type {string|undefined}

Source:

issued_at

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

Source:

key_thumbprint

The thumbprint of the client key the token is bound to. @type {string|undefined}

Source:

label

The token's label, when a multiple-token request named one. @type {string|undefined}

Source:

manage

Token management (section 6): { uri, access_token: { value } }. @type {{ uri: string, access_token: { value: string } }|undefined}

Source:

subject

The subject information as the AS returned it: sub_ids, assertions, updated_at. @type {Record<string, any>|undefined}

Source:

token_type

Always "GNAP": the Authorization scheme the token is presented with. @type {string}

Source:

Methods

canRotate()

Whether the access token can be rotated (it carries a management URI).

Source:

effectiveSkew(skewSec)

Skew to apply for early rotation, 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:

sessionIds() → {Array.<string>}

The session ids iya-sts names this grant by in a CAEP session-revoked: gnap-grant:<grant id>, and gnap-token:<jti> when the access token is a JWT. The jti is read from the token without verifying it; it is only ever compared with the session named in a SET whose signature was verified.

Source:
Returns:
Type
Array.<string>

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

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

(static) from(value) → {GrantSet}

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

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

Source:
Returns:
Type
GrantSet