(target: object, blocked: string[], label: string)
| 26 | |
| 27 | // wraps `target` with a Proxy restricting access to dangerious methods within the accepted modules. |
| 28 | const blockMethods = (target: object, blocked: string[], label: string): object => |
| 29 | new Proxy(target, { |
| 30 | get(t, prop) { |
| 31 | if (typeof prop === 'string' && blocked.includes(prop)) { |
| 32 | throw new Error(`${label}.${prop} is not available in sandbox scripts`); |
| 33 | } |
| 34 | const value = (t as any)[prop]; |
| 35 | return typeof value === 'function' ? value.bind(t) : value; |
| 36 | }, |
| 37 | }); |
| 38 | |
| 39 | export const requireInterceptor = (moduleName: string): any => { |
| 40 | if (moduleName === 'timers') { |
no outgoing calls
no test coverage detected