Class Overview
SIMPLE_JWT provides JWT creation, verification, and decoding using the HS256 (HMAC-SHA256) algorithm.
Creation
Initialize JWT handler with a secret key for HMAC signing.
Contracts
Token Creation
create_token (a_claims: JSON_OBJECT): STRING
Create a JWT with the given claims as payload.
Contracts
create_token_with_claims (a_subject, a_issuer: detachable STRING; a_expiration_seconds: INTEGER; a_custom_claims: detachable JSON_OBJECT): STRING
Create a JWT with standard claims. Set a_expiration_seconds to 0 for no expiration.
Automatically sets iat (issued at) to current time.
Contracts
Token Verification
verify (a_token: STRING): BOOLEAN
Verify the token's signature is valid. Does NOT check expiration.
Contracts
verify_with_expiration (a_token: STRING): BOOLEAN
Verify the token's signature AND check that it hasn't expired.
Contracts
is_expired (a_token: STRING): BOOLEAN
Check if the token has expired. Returns False if no exp claim exists.
Contracts
Token Decoding
decode_claims (a_token: STRING): detachable JSON_OBJECT
Decode and return the payload claims as a JSON object. Returns Void if malformed.
Contracts
decode_header (a_token: STRING): detachable JSON_OBJECT
Decode and return the header as a JSON object.
Contracts
get_claim (a_token, a_claim_name: STRING): detachable JSON_VALUE
Get a specific claim as a JSON value.
Contracts
get_string_claim (a_token, a_claim_name: STRING): detachable STRING
Get a string claim. Returns Void if claim doesn't exist or isn't a string.
Contracts
get_integer_claim (a_token, a_claim_name: STRING): INTEGER_64
Get an integer claim. Returns 0 if claim doesn't exist or isn't a number.
Contracts
Token Parts
extract_header (a_token: STRING): STRING
Extract the Base64URL-encoded header from the token.
extract_payload (a_token: STRING): STRING
Extract the Base64URL-encoded payload from the token.
extract_signature (a_token: STRING): STRING
Extract the Base64URL-encoded signature from the token.