GithubHelp home page GithubHelp logo

louischan-oursky / authgear-deno Goto Github PK

View Code? Open in Web Editor NEW

This project forked from authgear/authgear-deno

0.0 0.0 0.0 62 KB

License: Apache License 2.0

Go 95.04% TypeScript 1.04% Makefile 2.21% Dockerfile 1.71%

authgear-deno's Introduction

authgear-deno

authgear-deno is a HTTP server that takes a JavaScript / TypeScript file and an JSON value. The file is expected to have a default export of a function taking one argument, and return a value. The function can be async or sync.

authgear-deno takes care of granting permission as the script runs. Only network access to remote is granted.

Setup

Install Deno according to .tool-versions.

Run

$ make start

Examples

Evaluate a pure function

$ curl --request POST \
  --url http://localhost:8090/ \
  --header 'Content-Type: application/json' \
  --data '{
	"script": "export default async function addOne(a) { return a + 1; }",
	"input": 42
}'
{"output":43}

Evaluate a function with side-effects

$ curl --request POST \
  --url http://localhost:8090/ \
  --header 'Content-Type: application/json' \
  --data '{
	"script": "export default async function addOne(a) { console.log('\''hello'\''); return a + 1; }",
	"input": 42
}'
{"output":43,"stdout":"hello\n"}

Evaluate a malicious function

$ curl --request POST \
  --url http://localhost:8090/ \
  --header 'Content-Type: application/json' \
  --data '{
	"script": "export default async function malicious() { Deno.remove('\''/'\'', { recursive: true}) }",
	"input": 42
}'
{"error":"exit status 1","stderr":"⚠️  ┌ Deno requests write access to \"/\".\r\n   ├ Requested by `Deno.remove()` API\r\n   ├ Run again with --allow-write to bypass this prompt.\r\n   └ Allow? [y/n] (y = yes, allow; n = no, deny) \u003e n\r\n\u001b[4A\u001b[0J❌ Denied write access to \"/\".\r\nerror: Uncaught (in promise) PermissionDenied: Requires write access to \"/\", run again with the --allow-write flag\r\n    at async Object.remove (deno:runtime/js/30_fs.js:167:5)\r\n"}

authgear-deno's People

Contributors

louischan-oursky avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.