{"id":20310938,"url":"https://github.com/progrium/javascriptd","last_synced_at":"2025-04-11T16:07:02.191Z","repository":{"id":66709102,"uuid":"65856297","full_name":"progrium/javascriptd","owner":"progrium","description":"Node.js powered script execution container","archived":false,"fork":false,"pushed_at":"2016-08-17T22:02:45.000Z","size":16,"stargazers_count":9,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T12:11:04.560Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/progrium.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-16T21:56:28.000Z","updated_at":"2024-03-07T21:41:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"b59f9cbc-9bf8-47fb-9957-02fb8a7c14f7","html_url":"https://github.com/progrium/javascriptd","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/progrium%2Fjavascriptd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/progrium%2Fjavascriptd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/progrium%2Fjavascriptd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/progrium%2Fjavascriptd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/progrium","download_url":"https://codeload.github.com/progrium/javascriptd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248438498,"owners_count":21103409,"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":"2024-11-14T17:35:04.098Z","updated_at":"2025-04-11T16:07:02.183Z","avatar_url":"https://github.com/progrium.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# javascriptd\n\nNode.js powered script execution daemon\n\n## Using as runtime base\n\nJavascriptd is typically run inside Docker. Out of the box it has nearly no Node.js\npackages available. This is usually undesirable. So make a runtime image:\n\n```\nFROM progrium/javascriptd\nRUN npm install -g github circleci bluebird\n```\n\nNow running your Javascriptd runtime image, scripts will have these packages\navailable.\n\n## Using outside of Docker\n\nYou can use Javascriptd in development without Docker. Just link and run the\nbinary. It should not be published to NPM.\n\n```\n$ npm link\n... elsewhere ...\n$ javascriptd\n```\n\nKeep in mind it will have all your global packages available.\n\n## Securing Javascriptd\n\nTo keep Javascriptd private, set environment variable `SECRET` and run it behind\nSSL. HTTP requests will then require the header `x-runtime-secret`.\n\nIn terms of sandboxing, there are two layers of isolation builtin.\n\nFirst, each script call is done in a separate V8 context via\nNode's [vm](https://nodejs.org/api/vm.html) module. \"Breaking out\" requires access\nto various modules, which can be imported by `require`. Normally `require` is not\navailable, but we add it since there is little useful JavaScript that can be\nwritten in an empty context. This [should be secured](https://github.com/progrium/javascriptd/issues/2)\nby whitelisting safe Node modules and NPM packages.\n\nSecond, Javascriptd is made to be run inside Docker by a non-root user. This,\ncombined with extra isolation levels that can be configured via Docker, provides\npretty solid isolation guarantees. Further isolation could be added around Docker\nand in the environment Docker is run as needed.\n\n## Running scripts\n\nThe Javascriptd daemon exposes a [Duplex](https://github.com/progrium/duplex) JSON-over-WebSocket endpoint.\nIt has one method:\n\n### runtime.execute(script) =\u003e results\n\n#### script\n\n```\ntype script struct {\n    code     string    // script contents\n    globals  object    // optional globals\n    call     string    // optional name of function to call\n    caller   string    // optional caller function code\n}\n```\n\n`code` is some JS you want to populate a context with and evaluate. `globals` is a object\nthat's used as the global context object. All keys of `globals` are available\nto the script. `call` is the name of a function you want to call. This function\nis not called directly, it's called with a caller.\n\nThe default caller looks like `function(callee, cb) { callee(cb); }`, where\n`cb` is the callback to return a value, and `callee` is the function identified\nby `call`. However, you can override this with `caller` so you can customize\nhow a function is called and set up more of the context for the call.\n\nFor example, this is a value for `caller` that will initialize a Github client,\nauthenticate with a token from globals, and call the callee with the Github\nobject, an event object from globals, and the callback as arguments:\n\n```\n(function(callee, cb) {\n  var github = new require(\"github\")();\n  github.authenticate({\n    type: \"token\",\n    token: secrets.token\n  });\n  callee(github, event, cb);\n})\n```\n\n#### result\n\n```\ntype result struct {\n    value     ?          // first argument of cb\n    console   []string   // output from console.log\n    time      number     // time to complete in milliseconds\n}\n```\n\n#### errors\n\nPossible Duplex errors include:\n\n* `1000` **$exception** There was an exception in the script.\n* `1001` **Not implemented** The function in `call` does not exist.\n* `1002` **Timeout** The script and call timed out.\n\nErrors may include a data object:\n\n```\ntype errorData struct {\n    stack     string     // stacktrace if available\n    console   []string   // output from console.log\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogrium%2Fjavascriptd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprogrium%2Fjavascriptd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogrium%2Fjavascriptd/lists"}