{"id":28766188,"url":"https://github.com/amorgaut/jssandbox","last_synced_at":"2026-02-02T14:05:38.626Z","repository":{"id":6367408,"uuid":"7604733","full_name":"AMorgaut/jsSandbox","owner":"AMorgaut","description":"Simple ECMAScript execution Sandbox","archived":false,"fork":false,"pushed_at":"2014-03-11T15:38:51.000Z","size":172,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-04-18T16:10:54.604Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AMorgaut.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-01-14T13:29:49.000Z","updated_at":"2014-03-11T15:38:51.000Z","dependencies_parsed_at":"2022-09-09T21:12:16.527Z","dependency_job_id":null,"html_url":"https://github.com/AMorgaut/jsSandbox","commit_stats":null,"previous_names":[],"tags_count":1,"template":null,"template_full_name":null,"purl":"pkg:github/AMorgaut/jsSandbox","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AMorgaut%2FjsSandbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AMorgaut%2FjsSandbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AMorgaut%2FjsSandbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AMorgaut%2FjsSandbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AMorgaut","download_url":"https://codeload.github.com/AMorgaut/jsSandbox/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AMorgaut%2FjsSandbox/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260351270,"owners_count":22995932,"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":[],"created_at":"2025-06-17T11:41:34.652Z","updated_at":"2026-02-02T14:05:38.621Z","avatar_url":"https://github.com/AMorgaut.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# jsSandbox CommonJS module #\r\rThis module provides an ECMAScript execution sandbox.\r\rIt creates a proxy over the global object allowing by default only access to the native ECMAScript API.\rIt allows to open more the sandbox with whitelisted APIs.\rAll unauthorized property/method return \"access restricted\".\reval() is still usable but it can only access to the whitelisted APIs.\r\r## Getting Started ##\r\r###1. Create a Sandbox instance\n\r\rThe module provides the `Sandbox` constructor which expects 2 parameters:\n\r- `globalObject`: the global object to sandbox (window, application, ...)\n\r- `allowedProperties`: the APIs you want to let accessible\n\rNote that you can propose your own object references to replace the properties originaly accessible through the global scope.\n\n###2. Call the `run()` method\n\nIt can receive 2 parameters:\n\n- `jsCode` (string): the JavaScript code to execute \r- `timeout` (number): a timeout to prevent from evil usage with infinite loops\r\rThe result of this method is the value of the last expression.\n\rIf the timeout expires, an exception is thrown\r\r\r```javascript\r\r    var\r        Sandbox,\r        sandbox,\r        timeout;\r\r    // on node.js and some compliant platforms, \"/index\" is not mandatory\n\r    timeout = 4242;\r    Sandbox = require('jsSandbox/index').Sandbox;\r    sandbox = new Sandbox(\r        globalObject,\r        {\r            // some HTML5 properties\r            'Blob': true,\r            'XMLHttpRequest': true,\r            'sessionStorage': true,\r            // some specific API\r            'sensibleAPI': sandboxedAPI\r        }\r    );\r\r    result = sandbox.run(jsCode, timeout);\r    \r```\r\r## License (MIT License) ##\r\rCopyright (c) 2012-2013 Alexandre Morgaut\r\rPermission is hereby granted, free of charge, to any person obtaining a copy\rof this software and associated documentation files (the \"Software\"), to deal\rin the Software without restriction, including without limitation the rights\rto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\rcopies of the Software, and to permit persons to whom the Software is\rfurnished to do so, subject to the following conditions:\r\rThe above copyright notice and this permission notice shall be included in\rall copies or substantial portions of the Software.\r\rTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\rIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\rFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\rAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\rLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\rOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\rTHE SOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famorgaut%2Fjssandbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famorgaut%2Fjssandbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famorgaut%2Fjssandbox/lists"}