> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usebruno.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Inbuilt Libraries

Bruno supports **CommonJS** syntax `require` for importing libraries. ES Modules `import/export` are not supported at this time.

Here's an example demonstrating how to use the **chai** library in Bruno:

```js copy theme={null}
const chai = require('chai');

const { expect } = chai;

function add(a, b) {
  return a + b;
}

const result = add(2, 3);

expect(result).to.equal(5);

console.log('Test passed!');
```

You can include this code in the pre-request script section of Bruno to test it out.

## jsonwebtoken

[jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken) lets you create signed JWTs with `jwt.sign`. In a **Pre Request** script you might sign only a sensitive field (here the `token` string), then put that JWT back on your payload and send it as JSON.

```js copy theme={null}
const jwt = require('jsonwebtoken');

const payload = {
  name: 'usebruno',
  id: 100,
  token: 'abc1234'
};

const secret = 'your-secret';

// Sign only the token value (claims embedded in the JWT)
const signedToken = jwt.sign({ token: payload.token }, secret);

// Send the rest of the fields unchanged, with `token` replaced by the JWT
const updatedPayload = {
  ...payload,
  token: signedToken
};

req.setHeader('Content-Type', 'application/json');
req.setBody(updatedPayload);
```

Use a real secret from your environment or collection variables in practice and never commit secrets in scripts.

Below is the list of inbuilt libraries supported by Bruno.

* [axios](https://www.npmjs.com/package/axios) - Promise based HTTP client for the browser and node.js
* [atob](https://www.npmjs.com/package/atob) -  Turn base64-encoded ascii data back to binary.
* [btoa](https://www.npmjs.com/package/btoa) -  Turn binary data to base64-encoded ascii.
* [chai](https://www.npmjs.com/package/chai) -  BDD/TDD assertion library for node.js and the browser.
* [moment](https://momentjs.com) -  Parse, validate, manipulate, and display dates and times in JavaScript.
* [uuid](https://www.npmjs.com/package/uuid) -  For the creation of RFC4122 UUIDs.
* [nanoid](https://www.npmjs.com/package/nanoid) - A tiny, secure, URL-friendly, unique string ID generator for JavaScript.
* [crypto-js](https://www.npmjs.com/package/crypto-js) - JavaScript library of crypto standards.
* [tv4](https://www.npmjs.com/package/tv4) - Tiny Validator for JSON Schema v4.
* [jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken) - An implementation of JSON Web Tokens.

<Warning>
  To use below inbuilt libraries in Bruno, you must be in **Developer Mode**. When using Bruno CLI (v3.0.0+), pass the `--sandbox=developer` flag.
</Warning>

* [node-fetch](https://www.npmjs.com/package/node-fetch) - A light-weight module that brings Fetch API to Node.js.
* [lodash](https://lodash.com) -  A modern JavaScript utility library delivering modularity, performance & extras.
* [ajv](https://www.npmjs.com/package/ajv) - Ajv JSON schema validator.
* [cheerio](https://www.npmjs.com/package/cheerio) - Library for parsing and manipulating HTML and XML.
* [xml2js](https://www.npmjs.com/package/xml2js) - Simple XML to JavaScript object converter for Node.js.
