Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let acceptCertDomains = {}
let errorCerts = {}
// Don't show the keytar prompt more than once per 24 hours
let throttleKeytar = false
// Map of password notification bar messages to their callbacks
const passwordCallbacks = {}
const prefsRestartCallbacks = {}
const prefsRestartLastValue = {}
const unsafeTestMasterKey = 'c66af15fc6555ebecf7cee3a5b82c108fd3cb4b587ab0b299d28e39c79ecc708'
const defaultProtocols = ['http', 'https']
const sessionStoreQueue = async.queue((task, callback) => {
task(callback)
}, 1)
/**
* Gets the master key for encrypting login credentials from the OS keyring.
*/
const getMasterKey = () => {
if (throttleKeytar) {
return null
}
if (process.env.NODE_ENV === 'test') {
// workaround for https://travis-ci.org/brave/browser-laptop/builds/132700770
return (new Buffer(unsafeTestMasterKey, 'hex')).toString('binary')
}
module.exports = function(file, new_path, cb) {
var error,
result,
zip = new DecompressZip(file);
var done = function(err, res) {
if (err || q.length() == 0)
return cb && cb(err, res);
debug('Done. Found ' + q.length() + ' elements in queue!');
result = res; // store result so we can return it when queue finishes
q.resume();
}
var q = queue(function (task, callback) {
var file = path.join(new_path, task.file);
debug('Chmodding ' + file + ' to ' + task.mode);
chmod(file, task.mode, function(err) {
if (err) debug(err);
callback();
});
}, 2);
// called when the queue reaches zero, meaning all the work is done
q.drain = function() {
return cb && cb(error, result);
}
q.pause(); // the queue will begin when the files are extracted, not before
zip.on('file', function(file) {
function profileUpdater(child, callback) {
var i;
var childInsert = {
"module": child._id,
"access": {
"del": true,
"editWrite": true,
"read": true
}
};
var q = async.queue(function (profile, callback) {
if (profile) {
console.log('profile = ' + profile._id);
profiles.findOneAndUpdate({ _id: profile._id }, { $push: { profileAccess: { $each: [childInsert] } } }, callback);
}
}, 1000);
q.drain = function () {
callback(null, 'done');
};
var cursor = profiles.find()
cursor.each(function (err, profile) {
if (err) {
return callback(err);
function addData (dataset, data, callback) {
var errs = [];
var q = async.queue(function(item, cb) {
var object = (item.obj) ? item : {obj: item};
if (object.obj) {
if(object.obj.id === null || object.obj.id === undefined) {
errs.push({"message":"no value for primary key", "obj": object.obj});
return cb();
}
if (object.type === 'delete') {
levents.fireEvent(lutil.idrNew(dataset, 'push', object.obj.id), 'delete');
datastore.removeObject(dataset, object.obj["id"], {timeStamp: object.timestamp}, cb);
} else {
datastore.addObject(dataset, object.obj, {timeStamp: object.timestamp}, function(err, type, doc) {
if (type === 'same') return cb();
levents.fireEvent(lutil.idrNew(dataset, 'push', object.obj.id), type, doc);
return cb();
});
}
return new Promise(function(resolve, reject) {
var docs = []
var queue = async.queue(function(result, next) {
if (!result) {
return checkpointer
.set(change.seq)
.then(next.bind({}, null))
.catch(next)
}
db
.bulkDocs({ docs: result })
.then(function(response) {
return checkpointer.set(change.seq)
})
.then(next.bind({}, null))
.catch(next)
}, 1)
downloadImageUrls(imageKeys?: string[], imageProviders?: string[]) {
if (!this.appSettings.offlineMode) {
let allImagesRetrieved = true;
let imageQueue = queue((task, callback) => callback());
if (imageKeys === undefined || imageKeys.length === 0) {
imageKeys = Object.keys(this.appImages);
}
for (let i = 0; i < imageKeys.length; i++) {
let image = this.appImages[imageKeys[i]];
let imageProvidersForKey: string[] = imageProviders === undefined || imageProviders.length === 0 ? image.defaultImageProviders : imageProviders;
imageProvidersForKey = _.intersection(this.appSettings.enabledProviders, imageProvidersForKey);
if (image !== undefined && !image.retrieving) {
let numberOfQueriesForImageKey = image.searchQueries.length * imageProvidersForKey.length;
if (numberOfQueriesForImageKey > 0) {
image.retrieving = true;
//res.send('Trigger DB loading');
}
module.getNumConfiguredCustomers = function (req, res) {
res.contentType("text/plain");
res.send(loaderSettings.MAX_CUSTOMERS.toString());
}
var customerQueue = async.queue(insertCustomer, DATABASE_PARALLELISM);
customerQueue.drain = function() {
logger.info('all customers loaded');
airportCodeMappingQueue.push(airportCodeMappings);
}
var airportCodeMappingQueue = async.queue(insertAirportCodeMapping, DATABASE_PARALLELISM);
airportCodeMappingQueue.drain = function() {
logger.info('all airportMappings loaded');
flightSegmentsQueue.push(flightSegments);
}
var flightSegmentsQueue = async.queue(insertFlightSegment, DATABASE_PARALLELISM);
flightSegmentsQueue.drain = function() {
logger.info('all flightSegments loaded');
flightQueue.push(flights);
}
var flightQueue = async.queue(insertFlight, DATABASE_PARALLELISM);
//flightQueue.drain = function() {
// logger.info('all flights loaded');
// logger.info('ending loading database');
//}
fs.readdir(basedir, function(err, files) {
var filesToDelete = [];
var q = async.queue((file, callback) => {
if(file.match(/.json$/)) {
fs.readFile(path.join(basedir, file), 'utf8', function(err, data) {
var context = JSON.parse(data);
if(context.expires) {
var expires = new Date(context.expires);
if(Date.compare(expires, new Date()) < 0) {
filesToDelete.push(context.path, context.jsonPath);
callback();
} else {
callback();
}
} else {
callback();
}
});
} else {
airportCodeMappingQueue.push(airportCodeMappings);
}
var airportCodeMappingQueue = async.queue(insertAirportCodeMapping, DATABASE_PARALLELISM);
airportCodeMappingQueue.drain = function() {
logger.info('all airportMappings loaded');
flightSegmentsQueue.push(flightSegments);
}
var flightSegmentsQueue = async.queue(insertFlightSegment, DATABASE_PARALLELISM);
flightSegmentsQueue.drain = function() {
logger.info('all flightSegments loaded');
flightQueue.push(flights);
}
var flightQueue = async.queue(insertFlight, DATABASE_PARALLELISM);
//flightQueue.drain = function() {
// logger.info('all flights loaded');
// logger.info('ending loading database');
//}
var customers = new Array();
var airportCodeMappings = new Array();
var flightSegments = new Array();
var flights = new Array();
function createCustomers(numCustomers) {
for (var ii = 0; ii < numCustomers; ii++) {
var customer = cloneObjectThroughSerialization(customerTemplate);
customer._id = "uid" + ii + "@email.com";
customers.push(customer);