cwt
This module is available to use in your EdgeWorkers code bundles to verify CWT tokens. For more information, refer to the CBOR Web Token format specification and the CBOR Object Signing and Encryption (COSE) documents.
Go to the the EdgeWorkers GitHub repo for access to the CWT module, the main helper class you need to import into your main.js file and the TypeScript definition file. You can also find examples to help you learn more about how to use the cwt module .
📘 Currently the module only supports verification for CWT tokens using the HS256 (HMAC SHA256) and ES256 (ECDSA w/ SHA-256) algorithms.
CWTValidator
Constructor for new CWTValidator Object. It performs type checks on the cwtOptions Object fields.
CWTOptions Object
CWTJSON Object
Holds cwt header and payload in JSON format.
Header
Payload
The set of claims from the CWT token as a JSON object. Refer to the Claims section in the CWT spec for more information.
async validate()
Performs the CBOR decoding of the CWT token and validates the signature. Returns a promise<CWTJSON> if the signature validation is successful, otherwise throws an error.
CWTUtil
claimsTranslate()
Translates the payload with integer keys to map with string keys using the labelsMaps mapping and translators functions. Returns an instance of a JSON object where keys are string.