Created
March 13, 2018 11:46
-
-
Save alenaksu/26c5edc49e62463a9df06a87bf747c3d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const trusted = [], | |
untrusted = [ | |
'eval', | |
...Object.keys(window) | |
].filter(k => trusted.indexOf(k) !== -1); | |
export default function createSecureScript(script, ...args) { | |
return new Function( | |
...untrusted, | |
...args, | |
`return ${script}` | |
).bind(undefined, ...Array(untrusted.length)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment