For the complete documentation index, see llms.txt. This page is also available as Markdown.

JWTValidate

Verifies a JWS signature and claims, returning true or false instead of throwing. Useful for simple conditional checks where you don't need the exception detail.

Method Signature

JWTValidate( token, [key], [algorithm], [options] )

Arguments

Argument
Type
Required
Description
Default

token

string

Yes

Compact JWS token string.

key

any

No

Verification key. Optional when defaultVerifyKey is configured.

null

algorithm

string

No

Expected algorithm.

null

options

struct

No

claims (expected claim values), clockSkew (seconds tolerance for exp/nbf).

{}

Returns

booleantrue if the signature is valid and all claim constraints pass, false otherwise.

Examples

if ( jwtValidate( token, secret, "HS256" ) ) {
    payload = jwtVerify( token, secret, "HS256" );
    // proceed with authenticated request
} else {
    // redirect to login / return 401
}

Last updated

Was this helpful?