Files
jose/docs/classes/jwt_produce.ProduceJWT.md
2023-04-12 18:54:17 +02:00

3.8 KiB

Class: ProduceJWT

💗 Help the project

Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by becoming a sponsor.


Generic class for JWT producing.

Table of contents

Constructors

Methods

Constructors

constructor

• new ProduceJWT(payload)

Parameters

Name Type Description
payload JWTPayload The JWT Claims Set object.

Methods

setAudience

â–¸ setAudience(audience): ProduceJWT

Set "aud" (Audience) Claim.

Parameters

Name Type Description
audience string | string[] "aud" (Audience) Claim value to set on the JWT Claims Set.

Returns

ProduceJWT


setExpirationTime

â–¸ setExpirationTime(input): ProduceJWT

Set "exp" (Expiration Time) Claim.

Parameters

Name Type Description
input string | number "exp" (Expiration Time) Claim value to set on the JWT Claims Set. When number is passed that is used as a value, when string is passed it is resolved to a time span and added to the current timestamp.

Returns

ProduceJWT


setIssuedAt

â–¸ setIssuedAt(input?): ProduceJWT

Set "iat" (Issued At) Claim.

Parameters

Name Type Description
input? number "iat" (Issued At) Claim value to set on the JWT Claims Set. Default is current timestamp.

Returns

ProduceJWT


setIssuer

â–¸ setIssuer(issuer): ProduceJWT

Set "iss" (Issuer) Claim.

Parameters

Name Type Description
issuer string "Issuer" Claim value to set on the JWT Claims Set.

Returns

ProduceJWT


setJti

â–¸ setJti(jwtId): ProduceJWT

Set "jti" (JWT ID) Claim.

Parameters

Name Type Description
jwtId string "jti" (JWT ID) Claim value to set on the JWT Claims Set.

Returns

ProduceJWT


setNotBefore

â–¸ setNotBefore(input): ProduceJWT

Set "nbf" (Not Before) Claim.

Parameters

Name Type Description
input string | number "nbf" (Not Before) Claim value to set on the JWT Claims Set. When number is passed that is used as a value, when string is passed it is resolved to a time span and added to the current timestamp.

Returns

ProduceJWT


setSubject

â–¸ setSubject(subject): ProduceJWT

Set "sub" (Subject) Claim.

Parameters

Name Type Description
subject string "sub" (Subject) Claim value to set on the JWT Claims Set.

Returns

ProduceJWT