Skip to content

feat(playground): support safe-mode script libraries in the quickjs sandbox - #56

Open
sundram-bruno wants to merge 11 commits into
usebruno:mainfrom
sundram-bruno:feat/playground-script-libraries
Open

feat(playground): support safe-mode script libraries in the quickjs sandbox#56
sundram-bruno wants to merge 11 commits into
usebruno:mainfrom
sundram-bruno:feat/playground-script-libraries

Conversation

@sundram-bruno

@sundram-bruno sundram-bruno commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Jira: BRU-3838

Description

The docs playground runs collection scripts in a QuickJS sandbox, but the inbuilt script libraries available in the Bruno app were not supported there. Only chai was available, so any script using moment, crypto-js, axios or the other libraries worked in the app but failed in the playground.

Solution

The playground sandbox now supports the same safe mode library set as the Bruno app: axios, moment, crypto-js, jsonwebtoken, uuid, nanoid, chai, tv4, ajv, ajv-formats, buffer, path, btoa and atob. Scripts can use them through require() or the matching globals, exactly like in the app.

Libraries that are only available in the app's developer mode now fail with a clear message instead of a generic one. Pre-request scripts that set their own Authorization header now win over the request's auth config, matching the app. The scripting engine and libraries are lazy loaded, so docs readers who never use the playground do not download any of it.

Bundle size

The scripting engine and the library bundle are loaded only on the first Send in the playground, so pages that only read docs download none of it.

Chunk Raw Gzipped Loaded
Docs entry 1,820 KB 572 KB on page load (no scripting code)
Scripting + all 14 libraries 534 KB 164 KB first Send only
QuickJS engine (wasm) 503 KB 234 KB first Send only

First Send is a one time cost of roughly 398 KB gzipped, then served from cache. The single file standalone build cannot code split, so it inlines this instead.

@sundram-bruno
sundram-bruno force-pushed the feat/playground-script-libraries branch from 32064b1 to 7ddd5c0 Compare August 23, 2026 19:00
@sundram-bruno sundram-bruno changed the title feat(playground): support safe-mode script libraries in the quickjs sandbox (BRU-3838) feat(playground): support safe-mode script libraries in the quickjs sandbox Aug 23, 2026
@sundram-bruno
sundram-bruno marked this pull request as draft August 24, 2026 10:43
- require absolute http(s) urls and omit credentials in the axios shim
- reject asymmetric keys and missing secrets in the jwt helper
- keep the crypto shim working under minified builds
- replace local-file require with a clear error and remove the unused loader
- strip __proto__ when marshalling host values into the sandbox
- add jwt guard, marshalling and node: builtin parity cases
- rewrite the script-execution e2e to a self-contained tests script
- drop the now-unused sample collection script
…ipt-libraries

# Conflicts:
#	package-lock.json
#	packages/bruno-api-docs/package.json
… callbacks

- omit typ and reject claim options for string payloads
- invoke the callback at most once
- add node crypto interop tests for HS signatures
@sundram-bruno
sundram-bruno marked this pull request as ready for review August 26, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant