Skip to main content

Function: signJwt()

signJwt(args): string

Defined in: jwt.ts:47

Signs a JWT with HMAC-SHA256 (HS256).

For Amazon Cognito tokens, use @ttoss/auth-core/amazon-cognito instead — this helper is meant for self-hosted authentication where the application owns the signing secret.

Parameters

ParameterTypeDescription
args{ expiresInSeconds?: number; payload: JwtPayload; secret: string; }-
args.expiresInSeconds?numberToken lifetime in seconds, e.g. 60 * 60 * 24 * 7 for 7 days. When omitted, the token never expires.
args.payloadJwtPayload-
args.secretstring-

Returns

string