{"id":13527492,"url":"https://github.com/Houfeng/safeify","last_synced_at":"2025-04-01T09:31:35.167Z","repository":{"id":41152246,"uuid":"129997230","full_name":"Houfeng/safeify","owner":"Houfeng","description":"📦 Safe sandbox that can be used to execute untrusted code.","archived":false,"fork":false,"pushed_at":"2023-01-23T21:55:52.000Z","size":2979,"stargazers_count":491,"open_issues_count":32,"forks_count":30,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-29T21:05:37.376Z","etag":null,"topics":["sandbox"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/Houfeng.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-18T03:15:01.000Z","updated_at":"2025-02-10T02:23:55.000Z","dependencies_parsed_at":"2023-01-25T09:15:27.616Z","dependency_job_id":null,"html_url":"https://github.com/Houfeng/safeify","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Houfeng%2Fsafeify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Houfeng%2Fsafeify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Houfeng%2Fsafeify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Houfeng%2Fsafeify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Houfeng","download_url":"https://codeload.github.com/Houfeng/safeify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246616145,"owners_count":20806064,"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":["sandbox"],"created_at":"2024-08-01T06:01:49.243Z","updated_at":"2025-04-01T09:31:34.593Z","avatar_url":"https://github.com/Houfeng.png","language":"TypeScript","readme":"# Safeify\n\n\u003cdiv align=\"center\"\u003e\n\n[![npm](https://img.shields.io/npm/l/safeify.svg)](LICENSE.md)\n[![NPM Version](https://img.shields.io/npm/v/safeify.svg)](https://www.npmjs.com/package/safeify)\n[![Build Status](https://www.travis-ci.org/Houfeng/safeify.svg?branch=master)](https://www.travis-ci.org/Houfeng/safeify)\n[![Coverage Status](https://coveralls.io/repos/github/Houfeng/safeify/badge.svg?branch=master)](https://coveralls.io/github/Houfeng/safeify?branch=master)\n[![npm](https://img.shields.io/npm/dt/safeify.svg)](https://www.npmjs.com/package/safeify)\n\n\u003c/div\u003e\n\n# 说明\n\nSafeify 可让 Node 应用安全的隔离执行非信任的用户自定义代码，[了解详细](//github.com/Houfeng/safeify/blob/master/DOC.md)\n\n# 安装\n\n```sh\nnpm install safeify -S\n```\n\n# 使用\n\n```ts\nimport { Safeify } from \"safeify\";\n\n(async ()=\u003e{\n\n  // 创建 safeify 实例\n  const safeVm = new Safeify({\n    timeout: 3000,\n    asyncTimeout: 60000\n  });\n\n  // 定义 context\n  const context = {\n    a: 1,\n    b: 2,\n    system: {\n      add(a: number, b: number) {\n        return (a + b) * 2;\n      }\n    }\n  };\n\n  // 执行动态代码\n  const result= await safeVm.run(`return system.add(1,2)`, context);\n  console.log('result', result);\n\n  // 释放资源\n  safeVm.destroy();\n  \n})();\n```","funding_links":[],"categories":["Repository","TypeScript"],"sub_categories":["Sandbox"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHoufeng%2Fsafeify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHoufeng%2Fsafeify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHoufeng%2Fsafeify/lists"}