/** * sandbox.js - create a single sandbox object with exposed functions and services * * by yoz@lindenlab.com * * **/ // Started doing this with proper constructors and stuff. Javascript Patterns // book has a good Sandbox pattern. However, didn't have time to do that // properly here. Next time. var LIBS_ROOT = '/local/node/'; var ES5_PATH = LIBS_ROOT+"es5-shim/es5-shim.js"; var ORBDB_PATH = '/local/node/orbital/orbdb/'; var request_fields = [ 'method', 'params', 'body', 'headers', 'scriptName', 'projectName', 'scriptID']; var http = require('http'), fs = require('fs'), url = require('url'), oauth = require('oauth'), path = require('path'), querystring = require("querystring"), request = require('request'), Script = process.binding('evals').Script, OrbDB = require('./orbdb').OrbDB; ; /** * makeBasicSandbox() - creates a basic sandbox for use by require()'d scripts * and is the basis for the main sandbox **/ var makeBasicSandbox = function(req, project_path) { var projectname = req.projectName; var sandbox = { MODULES: { http: { createClient: http.createClient }, url: url, JSON: JSON, oauth: oauth, querystring: querystring, request: request // the library called "request" }, setTimeout: setTimeout, REQUEST: {} }; // populate the REQUEST object for (var i=0; i