DecodedJWT๏
Inherits: RefCounted < Object
An object-oriented wrapper for parsed JSON Web Tokens.
Description๏
Returned by JWT.parse(jwt_str), this wrapper caches the decoded header and payload, and provides explicit type checking methods to extract claims.
var t = JWT.parse(jwt_string)
if not t.is_expired():
var roles = t.get_claim_as_array('roles')
Methods๏
get_algorithm() const |
|
get_audience() const |
|
get_claim_as_array(key: String) const |
|
get_claim_as_bool(key: String) const |
|
get_claim_as_dictionary(key: String) const |
|
get_claim_as_int(key: String) const |
|
get_claim_as_string(key: String) const |
|
get_expiration_time() const |
|
get_header() const |
|
get_header_claim(key: String) const |
|
get_header_claim_as_string(key: String) const |
|
get_issued_at() const |
|
get_issuer() const |
|
get_jwt_id() const |
|
get_kid() const |
|
get_not_before() const |
|
get_payload() const |
|
get_signature() const |
|
get_subject() const |
|
has_header_claim(key: String) const |
|
is_expired() const |
|
void |
Method Descriptions๏
String get_algorithm() const ๐
Returns the algorithm (alg) specified in the token's header.
Variant get_audience() const ๐
Extracts the audience (aud) claim. May return a String or an Array depending on the token.
Variant get_claim(key: String) const ๐
Extracts a claim from the payload as an untyped Variant.
Array get_claim_as_array(key: String) const ๐
Extracts a claim from the payload and casts it to an Array. Returns an empty Array if the claim does not exist or is not an array.
bool get_claim_as_bool(key: String) const ๐
Extracts a claim from the payload and casts it to a boolean. Returns false if the claim does not exist.
Dictionary get_claim_as_dictionary(key: String) const ๐
Extracts a claim from the payload and casts it to a Dictionary.
int get_claim_as_int(key: String) const ๐
Extracts a claim from the payload and casts it to an integer.
String get_claim_as_string(key: String) const ๐
Extracts a claim from the payload and casts it to a String.
float get_expiration_time() const ๐
Returns the expiration time (exp) claim as a float representing UNIX time in seconds.
Dictionary get_header() const ๐
Returns the entire decoded JWT header as a dictionary.
Variant get_header_claim(key: String) const ๐
Extracts a specific claim from the JWT header.
String get_header_claim_as_string(key: String) const ๐
Extracts a specific claim from the JWT header and casts it to a String.
float get_issued_at() const ๐
Returns the issued at (iat) claim as a float representing UNIX time in seconds.
String get_issuer() const ๐
Returns the issuer (iss) claim as a String.
String get_jwt_id() const ๐
Returns the JWT ID (jti) claim as a String.
Returns the Key ID (kid) from the header.
float get_not_before() const ๐
Returns the not before (nbf) claim as a float representing UNIX time in seconds.
Dictionary get_payload() const ๐
Returns the entire decoded JWT payload as a dictionary.
String get_signature() const ๐
Returns the trailing Base64Url-encoded signature portion of the token.
String get_subject() const ๐
Returns the subject (sub) claim as a String.
bool has_claim(key: String) const ๐
Returns true if the payload contains the specified claim.
bool has_header_claim(key: String) const ๐
Returns true if the header contains the specified claim.
Checks whether the JWT is expired based on the exp claim against the current system time.
Parses the given JWT string and caches its header and payload. Internal use mostly, prefer JWT.parse(jwt).