I'm designing a game and have a somewhat unique problem.
To play the game, players each write a simple javascript program that continually makes a request of my backend for the game state and then decides what to do and posts their move (also to my backend).
I want to store the user scripts on my end though, so I've given them the option to upload their scripts with the standard HTML5 input type="file". Then I use FileReader to read in the raw binary, and associate that binary input as a "bot" for the user in Mongo. (My backend is written in Go)
Docs for FileReader:
https://developer.mozilla.org/en-US/docs/Web/API/FileReader
So far, I've found a resource for converting the binary back to ascii:
Converting Binary to text using javascript
I found a javascript interpreter that I can allegedly execute javascript from: https://github.com/jterrace/js.js
In this situation, is there a better way to run the uploaded code, perhaps as an executable? Is a javascript sandbox solution like JSJS overkill?