JWS.VERIFY

JWS.VERIFY will verify the signature of a JWT and extract the payload as a string, wrapping it in a data envelope.

Function category: JWT

We currently support the HS256, HS384, HS512 algorithms

Syntax

JWS.VERIFY(arg1, arg2, arg3, [args...])

Arguments

Description

arg1

String denoting the algorithm to be used.

arg2

String of the input data to verify

arg3

String of the expected signature

[args...]

Additional set of arguments for usage with certain subsets of algorithms

Examples

Example 1: Verify sender and extract payload

If we receive a signed JWT that we want to verify, we can simply use the JWS.VERIFY token to verify the sender and extract the payload.

Let's say we have the following JWT:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.
EpM5XBzTJZ4J8AfoJEcJrjth8pfH28LWdjLo90sYb9g

By calling JWS.VERIFY on the above JWT, we can ensure that it was signed with the password provided:

JWS.VERIFY('HS256',
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.EpM5XBzTJZ4J8AfoJEcJrjth8pfH28LWdjLo90sYb9g',
'password')

In this case, it would return the following:

{ payload: "{\"foo\" 1 \"bar\" [4 5 \"qwe\"] }" }

Notes

If JWS.VERIFY encounters an error, it will return a response with the following structure:

{ error: error_description }

error_description will be a string describing the nature of the error encountered.

‚Äč