{"id":19908956,"url":"https://github.com/Lokomojo/duktype","last_synced_at":"2025-09-19T01:32:59.905Z","repository":{"id":42833085,"uuid":"262664505","full_name":"CasperTech/duktype","owner":"CasperTech","description":"Duktape for NodeJS/Typescript","archived":false,"fork":false,"pushed_at":"2022-12-30T20:25:04.000Z","size":2802,"stargazers_count":3,"open_issues_count":8,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-18T07:40:32.456Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","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/CasperTech.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":"2020-05-09T21:45:47.000Z","updated_at":"2024-08-15T02:51:47.000Z","dependencies_parsed_at":"2023-01-31T16:01:03.693Z","dependency_job_id":null,"html_url":"https://github.com/CasperTech/duktype","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/CasperTech%2Fduktype","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CasperTech%2Fduktype/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CasperTech%2Fduktype/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CasperTech%2Fduktype/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CasperTech","download_url":"https://codeload.github.com/CasperTech/duktype/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233542893,"owners_count":18691739,"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-12T21:13:59.315Z","updated_at":"2025-09-19T01:32:53.720Z","avatar_url":"https://github.com/CasperTech.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Duktype\r\n\r\n\u003e Duktape for Typescript/Node.JS\r\n\r\n[![npm version](https://badge.fury.io/js/%40caspertech%2Fduktype.svg)](https://badge.fury.io/js/%40caspertech%2Fduktype)\r\n[![Build Status](https://travis-ci.org/CasperTech/duktype.svg?branch=master)](https://travis-ci.org/CasperTech/duktype)\r\n[![Known Vulnerabilities](https://snyk.io/test/npm/@caspertech/duktype/badge.svg)](https://snyk.io/test/npm/@caspertech/duktype)\r\n[![Dependencies](https://david-dm.org/CasperTech/duktype.svg)](https://david-dm.org/CasperTech/duktype.svg)\r\n\r\n## About\r\n\r\nDuktype (Duktape + Typescript) aims to be a complete node.js binding for the Duktape Javascript engine, complete with Typescript typings.\r\n\r\nThis allows you to run user scripts in a completely isolated environment.\r\n\r\nThis is a native C++ module, with no dependencies - it *should* compile on any platform.\r\n\r\n## Security\r\n\r\nDuktape and V8 don't share memory, so as long as Duktape itself remains secure ([exploits have existed](https://elakkod.se/blog/write-up-sec-t-2019-mirc2077/) in the past), it should not be possible for user scripts to escape their sandbox.\r\n\r\nNote: The vulnerability flagged on the badge above is internal to node-cmake, the build system, and doesn't affect this package.\r\n\r\n## Install\r\n\r\n```bash\r\nnpm install --save @caspertech/duktype\r\n```\r\n\r\n## Usage\r\n\r\n```typescript\r\nimport * as duktype from '@caspertech/duktype';\r\n\r\n// Create a context which everything runs in\r\nconst ctx = new duktype.Context();\r\n\r\n// Get the global object\r\nconst glob = ctx.getGlobalObject();\r\n\r\n// Add a method to the global object\r\nglob.setProperty('print', (any: any, number: any, of: any, args: any) =\u003e\r\n{\r\n    console.log(any);\r\n});\r\n\r\n// Run some code which calls the method\r\nctx.eval(`print(\"I'm calling from Duktape!\");`);\r\n\r\n// Now maybe you want a console.log - let's add a console object\r\nconst obj = glob.createObject('console');\r\n\r\n// Let's set another string property which is the tag to use for logging\r\nobj.setProperty('tag', 'QUACK');\r\n\r\n// Add a log method to console. You can pass parameters of almost any type, let's try a Date..\r\nobj.setProperty('log', (date: Date, message: string) =\u003e\r\n{\r\n    const tag = obj.getProperty('tag');\r\n    console.log(date.toISOString() + ': [' + tag + '] ' + message);\r\n});\r\n\r\n// Let's run this thing\r\nctx.eval(`\r\nprint('Tag is: ' + console.tag);\r\nconsole.log(new Date(), 'Console.log works!');\r\n`);\r\n```\r\n\r\n## License\r\n\r\n[MIT](http://vjpr.mit-license.org)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLokomojo%2Fduktype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLokomojo%2Fduktype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLokomojo%2Fduktype/lists"}