{"id":13611839,"url":"https://github.com/sebastianwessel/quickjs","last_synced_at":"2025-05-14T18:06:08.831Z","repository":{"id":246781098,"uuid":"822144221","full_name":"sebastianwessel/quickjs","owner":"sebastianwessel","description":"A typescript package to execute JavaScript and TypeScript code in a webassembly quickjs sandbox","archived":false,"fork":false,"pushed_at":"2025-04-30T12:01:55.000Z","size":4031,"stargazers_count":723,"open_issues_count":2,"forks_count":22,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-30T13:05:36.461Z","etag":null,"topics":["example","javascript","module","package","quickjs","quickjs-emscripten","quickjs-runtime","sandbox","sandbox-environment","typescript","wasm","webassembly","worker","worker-pool","worker-threads"],"latest_commit_sha":null,"homepage":"https://sebastianwessel.github.io/quickjs/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sebastianwessel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-06-30T11:58:26.000Z","updated_at":"2025-04-30T12:01:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"1c90b680-7e0e-40c7-8750-9002b7593d75","html_url":"https://github.com/sebastianwessel/quickjs","commit_stats":{"total_commits":58,"total_committers":1,"mean_commits":58.0,"dds":0.0,"last_synced_commit":"a7e3d37ebf3991027f16adb4ee515be74916735f"},"previous_names":["sebastianwessel/quickjs"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastianwessel%2Fquickjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastianwessel%2Fquickjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastianwessel%2Fquickjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastianwessel%2Fquickjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sebastianwessel","download_url":"https://codeload.github.com/sebastianwessel/quickjs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254198514,"owners_count":22030965,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["example","javascript","module","package","quickjs","quickjs-emscripten","quickjs-runtime","sandbox","sandbox-environment","typescript","wasm","webassembly","worker","worker-pool","worker-threads"],"created_at":"2024-08-01T19:02:13.052Z","updated_at":"2025-05-14T18:06:03.806Z","avatar_url":"https://github.com/sebastianwessel.png","language":"TypeScript","readme":"# QuickJS - Execute JavaScript and TypeScript in a WebAssembly QuickJS Sandbox\n\nThis TypeScript package allows you to safely execute **JavaScript AND TypeScript code** within a WebAssembly sandbox using the QuickJS engine. Perfect for isolating and running untrusted code securely, it leverages the lightweight and fast QuickJS engine compiled to WebAssembly, providing a robust environment for code execution.\n\n**[View the full documentation](https://sebastianwessel.github.io/quickjs/)** | **[Find examples in the repository](https://github.com/sebastianwessel/quickjs/tree/main/example)** | **[Online Playground](https://sebastianwessel.github.io/quickjs/playground.html)**\n\n## Features\n\n- **Security**: Run untrusted JavaScript and TypeScript code in a safe, isolated environment.\n- **Basic Node.js modules**: Provides basic standard Node.js module support for common use cases.\n- **File System**: Can mount a virtual file system.\n- **Custom Node Modules**: Custom node modules are mountable.\n- **Fetch Client**: Can provide a fetch client to make http(s) calls.\n- **Test-Runner**: Includes a test runner and chai based `expect`.\n- **Performance**: Benefit from the lightweight and efficient QuickJS engine.\n- **Versatility**: Easily integrate with existing TypeScript projects.\n- **Simplicity**: User-friendly API for executing and managing JavaScript and TypeScript code in the sandbox.\n\n## Basic Usage\n\nHere's a simple example of how to use the package:\n\n```typescript\nimport { type SandboxOptions, loadQuickJs } from '@sebastianwessel/quickjs'\n\n// General setup like loading and init of the QuickJS wasm\n// It is a ressource intensive job and should be done only once if possible\nconst { runSandboxed } = await loadQuickJs()\n\nconst options: SandboxOptions = {\n  allowFetch: true, // inject fetch and allow the code to fetch data\n  allowFs: true, // mount a virtual file system and provide node:fs module\n  env: {\n    MY_ENV_VAR: 'env var value',\n  },\n}\n\nconst code = `\nimport { join } from 'path'\n\nconst fn = async ()=\u003e{\n  console.log(join('src','dist')) // logs \"src/dist\" on host system\n\n  console.log(env.MY_ENV_VAR) // logs \"env var value\" on host system\n\n  const url = new URL('https://example.com')\n\n  const f = await fetch(url)\n\n  return f.text()\n}\n  \nexport default await fn()\n`\n\nconst result = await runSandboxed(async ({ evalCode }) =\u003e evalCode(code), options)\n\nconsole.log(result) // { ok: true, data: '\u003c!doctype html\u003e\\n\u003chtml\u003e\\n[....]\u003c/html\u003e\\n' }\n```\n\n**[View the full documentation](https://sebastianwessel.github.io/quickjs/)**\n\n**[Find examples in the repository](https://github.com/sebastianwessel/quickjs/tree/main/example)**\n\n## Credits\n\nThis lib is based on:\n\n- [quickjs-emscripten](https://github.com/justjake/quickjs-emscripten)\n- [quickjs-emscripten-sync](https://github.com/reearth/quickjs-emscripten-sync)\n- [memfs](https://github.com/streamich/memfs)\n- [Chai](https://www.chaijs.com)\n\nTools used:\n\n- [Bun](https://bun.sh)\n- [Biome](https://biomejs.dev)\n- [Hono](https://hono.dev)\n- [poolifier-web-worker](https://github.com/poolifier/poolifier-web-worker)\n- [tshy](https://github.com/isaacs/tshy)\n- [autocannon](https://github.com/mcollina/autocannon)\n\n## License\n\nThis project is licensed under the MIT License.\n\n---\n\nThis package is ideal for developers looking to execute JavaScript code securely within a TypeScript application, ensuring both performance and safety with the QuickJS WebAssembly sandbox.\n","funding_links":[],"categories":["TypeScript","webassembly"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebastianwessel%2Fquickjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebastianwessel%2Fquickjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebastianwessel%2Fquickjs/lists"}