> For the complete documentation index, see [llms.txt](https://docs.ondiagram.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ondiagram.com/nodes/jwt.md).

# JWT

## General

The `Jwt` node can be used to encrypt an object to JSON web token or similarly to decrypt one to an object.

## Input

Case: SIGN

* **Source:** Receives an `Object` with the values to encrypt. Learn more on [jwt.sign](https://www.npmjs.com/package/jsonwebtoken#jwtsignpayload-secretorprivatekey-options-callback).

Case: VERIFY

* **Source:** Receives the JSON web token as `String`. Learn more on [jwt.sign](https://www.npmjs.com/package/jsonwebtoken#jwtsignpayload-secretorprivatekey-options-callback).

Environment variables:

* **jwt:** Requires *JWT PRIVATE KEY* to be set.

## Output

Case: SIGN

* **Out:** Returns a `String` with the encrypted JWT. Learn more on [jwt.sign](https://www.npmjs.com/package/jsonwebtoken#jwtsignpayload-secretorprivatekey-options-callback).

Case: VERIFY

* **Out:** Returns a `Boolean` true if the token is valid and false if it's invalid. Learn more on [jwt.sign](https://www.npmjs.com/package/jsonwebtoken#jwtsignpayload-secretorprivatekey-options-callback).

## Use Cases

Register a user to a database.

* Request (Post) ➡ Jwt (Sign) ➡ Database (Add) ➡ Response (200)

Return a user's profile.

* Request (Get) ➡ Jwt (verify) ➡ Database (Get) ➡ Response (200)
