{"id":15012339,"url":"https://github.com/postmanlabs/uniscope","last_synced_at":"2026-03-02T17:33:44.730Z","repository":{"id":11481418,"uuid":"69803955","full_name":"postmanlabs/uniscope","owner":"postmanlabs","description":"Evaluate a code within a controlled environment","archived":false,"fork":false,"pushed_at":"2025-05-02T22:28:47.000Z","size":1765,"stargazers_count":15,"open_issues_count":9,"forks_count":13,"subscribers_count":14,"default_branch":"develop","last_synced_at":"2025-05-07T04:07:32.032Z","etag":null,"topics":["eval","nodejs","postman","scope"],"latest_commit_sha":null,"homepage":"https://www.postmanlabs.com/uniscope","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/postmanlabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.yaml","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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}},"created_at":"2016-10-02T15:11:55.000Z","updated_at":"2025-04-16T11:22:13.000Z","dependencies_parsed_at":"2024-02-05T10:43:54.628Z","dependency_job_id":"bbc8805e-e40c-4cc0-a3ac-4fbba33ee8e3","html_url":"https://github.com/postmanlabs/uniscope","commit_stats":{"total_commits":480,"total_committers":20,"mean_commits":24.0,"dds":"0.44999999999999996","last_synced_commit":"487260c7913018bfbf782b13d599d619283c9df7"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postmanlabs%2Funiscope","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postmanlabs%2Funiscope/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postmanlabs%2Funiscope/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postmanlabs%2Funiscope/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/postmanlabs","download_url":"https://codeload.github.com/postmanlabs/uniscope/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252810273,"owners_count":21807759,"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":["eval","nodejs","postman","scope"],"created_at":"2024-09-24T19:42:29.620Z","updated_at":"2026-03-02T17:33:39.692Z","avatar_url":"https://github.com/postmanlabs.png","language":"JavaScript","readme":"# Uniscope [![CI](https://github.com/postmanlabs/uniscope/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/postmanlabs/uniscope/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/postmanlabs/uniscope/branch/develop/graph/badge.svg)](https://codecov.io/gh/postmanlabs/uniscope)\n\nThe goal of this module is to provide a uniform execution environment to a JavaScript code between browser and NodeJS.\u003cbr/\u003e\nFor example, global functions and objects in NodeJS such as `setImmediate` and `global` are not easily available to the script. And on the other hand, browser-specific global properties such as `requestAnimationFrame` and `window` is not available as well.\n\n## Installation\nUniscope can be installed using NPM or directly from the git repository within your NodeJS projects. If installing from NPM, the following command installs the module and saves in your `package.json`\n\n```console\n$ npm install uniscope --save\n```\n\n## What this module does NOT do\n\nPlease read this carefully to avoid any ambiguity during adopting this module.\n\n- This is not a module that converts NodeJS codes to browser or vice versa; that is the work of transformation tools such as browserify.\n- This tool is not a security sandbox since it is easy to break out from this scope. This module simply provides uniformity to the scripts.\n\n## Usage\n\n```javascript\n// sample inside NodeJS\nlet Scope = require('uniscope'), // use browserify or requireJS in browser!\n    myscope;\n\n// create a new scope\nmyscope = new Scope({\n    eval: false, // specify whether eval is available inside sandbox\n    console: false, // specify whether native console is available\n    strict: false, // specify whether to run the script in strict mode\n    ignore: ['require'], // specify a list of global variables to ignore and pass-through to the script\n    block: ['process'] // specify a list of variables that should be blocked from being accessed\n}, { // provide an object with globals to be made available to the scripts\n    myGlobalVarName: \"sample\"\n});\n\n// set a specific variable as global\nmyscope.set('logger', function (msg) {\n    console.log(msg);\n});\n\n// now run a script\nmyscope.exec('logger(myGlobalVarName)', function (err) {\n    err ? console.error(err.stack || err) : console.log('execution complete');\n});\n```\n\n### Running an asynchronous script\n\nAn asynchronous script will require an explicit call of a global function `__exitscope`. Note that `setTimeout` and `setInterval` are not injected by default. You can easily do it yourself.\n\n```javascript\nmyscope.set('setTimeout', global.setTimeout); // inject setTimeout\n\n// note the 2nd parameter is set to `{ async: true }`\nmyscope.exec('setTimeout(function () { __exitscope(null); }, 1000)', { async: true }, function (err) {\n    err ? console.error(err.stack || err) : console.log('execution complete');\n});\n```\n\n## List of allowed Globals\n\nThese are the list of globals available to scripts in the scope\n\n### Standard Built-ins:\n\n```json\n[\n    \"Array\",               \"ArrayBuffer\",        \"Atomics\",\n    \"BigInt\",              \"Boolean\",            \"DataView\",\n    \"Date\",                \"Function\",           \"Infinity\",\n    \"Intl\"                 \"JSON\",               \"Map\",\n    \"Math\",                \"NaN\",                \"Number\",\n    \"Object\",              \"Promise\",            \"Proxy\",\n    \"Reflect\",             \"RegExp\",             \"Set\",\n    \"SharedArrayBuffer\",   \"String\",             \"Symbol\",\n    \"WeakMap\",             \"WeakSet\",            \"decodeURI\",\n    \"decodeURIComponent\",  \"encodeURI\",          \"encodeURIComponent\",\n    \"escape\",              \"isFinite\",           \"isNaN\",\n    \"queueMicrotask\",      \"parseFloat\",         \"parseInt\",\n    \"structuredClone\",     \"undefined\",          \"unescape\"\n]\n```\n### Errors:\n\n```json\n[\n    \"AggregateError\"     \"Error\",           \"EvalError\",\n    \"RangeError\",        \"ReferenceError\",  \"SyntaxError\",\n    \"TypeError\",         \"URIError\"\n]\n```\n\n### Typed Arrays:\n\n```json\n[\n    \"BigInt64Array\",   \"BigUint64Array\",     \"Float32Array\",\n    \"Float64Array\",    \"Int16Array\",         \"Int32Array\",\n    \"Int8Array\",       \"Uint16Array\",        \"Uint32Array\",\n    \"Uint8Array\",      \"Uint8ClampedArray\"\n]\n```\n\n### URL:\n\n```json\n[\n    \"URL\", \"URLSearchParams\"\n]\n```\n\n### Encoding:\n```json\n[\n    \"atob\",           \"btoa\",\n    \"TextDecoder\",    \"TextDecoderStream\",\n    \"TextEncoder\",    \"TextEncoderStream\"\n]\n```\n\n### File:\n```json\n[\n    \"Blob\"\n]\n```\n\n### Cryptography:\n```json\n[\n    \"Crypto\",   \"CryptoKey\",\n    \"crypto\",   \"SubtleCrypto\"\n]\n```\n\n### Stream:\n```json\n[\n    \"ByteLengthQueuingStrategy\",         \"CountQueuingStrategy\",\n    \"CompressionStream\",                 \"DecompressionStream\",\n    \"ReadableByteStreamController\",      \"ReadableStream\",\n    \"ReadableStreamBYOBReader\",          \"ReadableStreamBYOBRequest\",\n    \"ReadableStreamDefaultController\",   \"ReadableStreamDefaultReader\",\n    \"TransformStream\",                   \"TransformStreamDefaultController\",\n    \"WritableStream\",                    \"WritableStreamDefaultController\",\n    \"WritableStreamDefaultWriter\"\n]\n```\n\n### Events\n```json\n[\n    \"DOMException\",    \"Event\",    \"EventTarget\"\n]\n```\n\n### Fetch\n```json\n[\n    \"AbortController\",    \"AbortSignal\"\n]\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostmanlabs%2Funiscope","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpostmanlabs%2Funiscope","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostmanlabs%2Funiscope/lists"}