@@ -34,7 +34,8 @@ class Application extends events.EventEmitter {
34
34
35
35
createSandbox ( ) {
36
36
const introspection = async ( ) => [ ...this . api . keys ( ) ] ;
37
- const application = { security, api : { introspection } } ;
37
+ const context = Object . freeze ( { } ) ;
38
+ const application = { security, api : { introspection } , context } ;
38
39
for ( const name of this . namespaces ) application [ name ] = this [ name ] ;
39
40
const sandbox = { console : this . logger , application, Buffer, api } ;
40
41
sandbox . global = sandbox ;
@@ -51,7 +52,7 @@ class Application extends events.EventEmitter {
51
52
const data = await fsp . readFile ( fileName , 'utf8' ) ;
52
53
const code = data . startsWith ( '({' ) ? data :
53
54
`({ access: 'logged', method: ${ data . trim ( ) . slice ( 0 , - 1 ) } });` ;
54
- const src = `'use strict';\ncontext => ${ code } ` ;
55
+ const src = `'use strict';\n ${ code } ` ;
55
56
const options = { filename : fileName , lineOffset : - 1 } ;
56
57
try {
57
58
return new vm . Script ( src , options ) ;
@@ -61,7 +62,8 @@ class Application extends events.EventEmitter {
61
62
}
62
63
}
63
64
64
- runScript ( methodName , sandbox = this . sandbox ) {
65
+ runScript ( methodName , session ) {
66
+ const sandbox = session ? session . sandbox : this . sandbox ;
65
67
const script = this . api . get ( methodName ) ;
66
68
if ( ! script ) return null ;
67
69
return script . runInContext ( sandbox , SCRIPT_OPTIONS ) ;
0 commit comments