Skip to content

Commit

Permalink
Unhardcode security manager methods
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed Feb 25, 2023
1 parent 9e69ecd commit 773e1c1
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/scaffolding/scaffolding.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,19 +518,14 @@ class Scaffolding extends EventTarget {
return variable;
}

setExtensionSecurityManager ({getSandboxMode, canLoadExtensionFromProject}) {
setExtensionSecurityManager (newManager) {
const securityManager = this.vm.extensionManager.securityManager;
if (!securityManager) {
console.warn('setExtensionSecurityManager not supported: there is no security manager');
return;
}

if (typeof getSandboxMode !== 'undefined') {
securityManager.getSandboxMode = wrapAsFunctionIfNotFunction(getSandboxMode);
}

if (typeof canLoadExtensionFromProject !== 'undefined') {
securityManager.canLoadExtensionFromProject = wrapAsFunctionIfNotFunction(canLoadExtensionFromProject);
for (const [methodName, fn] of Object.entries(newManager)) {
securityManager[methodName] = wrapAsFunctionIfNotFunction(fn);
}
}

Expand Down

0 comments on commit 773e1c1

Please sign in to comment.