Files
bruno/packages/bruno-electron/src/store/collection-security.js
Anoop M D 753a576c3c Feat/safe mode quickjs (#2848)
Safe Mode Sandbox using QuickJS
Co-authored-by: Anoop M D <anoop.md1421@gmail.com>
Co-authored-by: lohit <lohit.jiddimani@gmail.com>
2024-08-21 12:52:49 +05:30

40 lines
1.1 KiB
JavaScript

const _ = require('lodash');
const Store = require('electron-store');
class CollectionSecurityStore {
constructor() {
this.store = new Store({
name: 'collection-security',
clearInvalidConfig: true
});
}
setSecurityConfigForCollection(collectionPathname, securityConfig) {
const collections = this.store.get('collections') || [];
const collection = _.find(collections, (c) => c.path === collectionPathname);
if (!collection) {
collections.push({
path: collectionPathname,
securityConfig: {
jsSandboxMode: securityConfig.jsSandboxMode
}
});
this.store.set('collections', collections);
return;
}
collection.securityConfig = securityConfig || {};
this.store.set('collections', collections);
}
getSecurityConfigForCollection(collectionPathname) {
const collections = this.store.get('collections') || [];
const collection = _.find(collections, (c) => c.path === collectionPathname);
return collection?.securityConfig || {};
}
}
module.exports = CollectionSecurityStore;