# 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)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ondiagram.com/nodes/jwt.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
