mirror of https://github.com/keeweb/keeweb.git
up modules; prettier
This commit is contained in:
parent
09fd37820b
commit
e0b65bbebf
|
@ -1,14 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta charset="UTF-8" />
|
||||
<title>Not Found</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: -apple-system, "BlinkMacSystemFont", "Raleway", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
|
||||
font-feature-settings: "liga" 0;
|
||||
font-family: -apple-system, 'BlinkMacSystemFont', 'Raleway', 'Helvetica Neue',
|
||||
'Helvetica', 'Arial', sans-serif;
|
||||
font-feature-settings: 'liga' 0;
|
||||
text-align: center;
|
||||
background: #F5F5F5;
|
||||
background: #f5f5f5;
|
||||
font-weight: 300;
|
||||
}
|
||||
h1 {
|
||||
|
|
|
@ -46,7 +46,7 @@ ready(() => {
|
|||
.then(initStorage)
|
||||
.then(showApp)
|
||||
.then(postInit)
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
appModel.appLogger.error('Error starting app', e);
|
||||
});
|
||||
|
||||
|
@ -57,7 +57,7 @@ ready(() => {
|
|||
);
|
||||
}
|
||||
return FeatureTester.test()
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
Alerts.error({
|
||||
header: Locale.appSettingsError,
|
||||
body: Locale.appNotSupportedError,
|
||||
|
@ -119,7 +119,7 @@ ready(() => {
|
|||
.then(() => {
|
||||
SettingsManager.setBySettings(appModel.settings);
|
||||
})
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
if (!appModel.settings.cacheConfigSettings) {
|
||||
showSettingsLoadError();
|
||||
throw e;
|
||||
|
@ -146,7 +146,7 @@ ready(() => {
|
|||
const protocolIsInsecure = ['https:', 'file:', 'app:'].indexOf(location.protocol) < 0;
|
||||
const hostIsInsecure = location.hostname !== 'localhost';
|
||||
if (protocolIsInsecure && hostIsInsecure && !skipHttpsWarning) {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve) => {
|
||||
Alerts.error({
|
||||
header: Locale.appSecWarn,
|
||||
icon: 'user-secret',
|
||||
|
@ -163,7 +163,7 @@ ready(() => {
|
|||
});
|
||||
} else {
|
||||
showView();
|
||||
return new Promise(resolve => requestAnimationFrame(resolve));
|
||||
return new Promise((resolve) => requestAnimationFrame(resolve));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,14 +17,14 @@ AutoTypeFilter.prototype.getEntries = function() {
|
|||
autoType: true
|
||||
};
|
||||
this.prepareFilter();
|
||||
let entries = this.appModel.getEntriesByFilter(filter).map(e => [e, this.getEntryRank(e)]);
|
||||
let entries = this.appModel.getEntriesByFilter(filter).map((e) => [e, this.getEntryRank(e)]);
|
||||
if (!this.ignoreWindowInfo) {
|
||||
entries = entries.filter(e => e[1]);
|
||||
entries = entries.filter((e) => e[1]);
|
||||
}
|
||||
entries = entries.sort((x, y) =>
|
||||
x[1] === y[1] ? x[0].title.localeCompare(y[0].title) : y[1] - x[1]
|
||||
);
|
||||
entries = entries.map(p => p[0]);
|
||||
entries = entries.map((p) => p[0]);
|
||||
return new SearchResultCollection(entries, { comparator: 'none' });
|
||||
};
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ AutoTypeObfuscator.prototype.step = function() {
|
|||
this.stepReal();
|
||||
}
|
||||
if (logger.getLevel() >= Logger.Level.Debug) {
|
||||
logger.debug('value', this.inputChars.map(ic => ic.ch).join(''));
|
||||
logger.debug('value', this.inputChars.map((ic) => ic.ch).join(''));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -274,7 +274,7 @@ AutoTypeRunner.prototype.getEntryFieldKeys = function(field, op) {
|
|||
if (value.isProtected) {
|
||||
op.type = 'group';
|
||||
const ops = [];
|
||||
value.forEachChar(ch => {
|
||||
value.forEachChar((ch) => {
|
||||
if (ch === 10 || ch === 13) {
|
||||
ops.push({ type: 'key', value: 'enter' });
|
||||
} else {
|
||||
|
@ -289,7 +289,7 @@ AutoTypeRunner.prototype.getEntryFieldKeys = function(field, op) {
|
|||
}
|
||||
op.type = 'group';
|
||||
const partsOps = [];
|
||||
parts.forEach(part => {
|
||||
parts.forEach((part) => {
|
||||
if (partsOps.length) {
|
||||
partsOps.push({ type: 'key', value: 'enter' });
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ AutoTypeRunner.prototype.obfuscateOps = function(ops) {
|
|||
if (op.type === 'text') {
|
||||
this.obfuscateOp(op);
|
||||
} else if (op.type === 'group') {
|
||||
const onlyText = op.value.every(grOp => grOp.type === 'text' && !grOp.mod);
|
||||
const onlyText = op.value.every((grOp) => grOp.type === 'text' && !grOp.mod);
|
||||
if (onlyText) {
|
||||
this.obfuscateOp(op);
|
||||
} else {
|
||||
|
@ -421,7 +421,7 @@ AutoTypeRunner.prototype.obfuscateOp = function(op) {
|
|||
}
|
||||
letters = op.value.split('');
|
||||
} else {
|
||||
op.value.forEach(grOp => letters.push(...grOp.value.split('')));
|
||||
op.value.forEach((grOp) => letters.push(...grOp.value.split('')));
|
||||
}
|
||||
if (letters.length <= 1) {
|
||||
return;
|
||||
|
|
|
@ -80,15 +80,15 @@ AutoTypeEmitter.prototype.setMod = function(mod, enabled) {
|
|||
|
||||
AutoTypeEmitter.prototype.text = function (text) {
|
||||
this.pendingScript.push('keyup ctrl alt shift t');
|
||||
Object.keys(this.mod).forEach(mod => {
|
||||
Object.keys(this.mod).forEach((mod) => {
|
||||
this.pendingScript.push('keydown ' + this.windowParameter + ModMap[mod]);
|
||||
});
|
||||
text.split('').forEach(char => {
|
||||
text.split('').forEach((char) => {
|
||||
this.pendingScript.push(
|
||||
'key ' + this.windowParameter + 'U' + char.charCodeAt(0).toString(16)
|
||||
);
|
||||
});
|
||||
Object.keys(this.mod).forEach(mod => {
|
||||
Object.keys(this.mod).forEach((mod) => {
|
||||
this.pendingScript.push('keyup ' + this.windowParameter + ModMap[mod]);
|
||||
});
|
||||
this.waitComplete();
|
||||
|
@ -137,7 +137,7 @@ AutoTypeEmitter.prototype.waitComplete = function(callback) {
|
|||
|
||||
AutoTypeEmitter.prototype.modString = function () {
|
||||
let mod = '';
|
||||
Object.keys(this.mod).forEach(key => {
|
||||
Object.keys(this.mod).forEach((key) => {
|
||||
mod += key + '+';
|
||||
});
|
||||
return mod;
|
||||
|
|
|
@ -26,11 +26,11 @@ const AutoType = {
|
|||
if (!this.enabled) {
|
||||
return;
|
||||
}
|
||||
Events.on('auto-type', e => this.handleEvent(e));
|
||||
Events.on('main-window-blur', e => this.mainWindowBlur(e));
|
||||
Events.on('main-window-focus', e => this.mainWindowFocus(e));
|
||||
Events.on('main-window-will-close', e => this.mainWindowWillClose(e));
|
||||
Events.on('closed-open-view', e => this.processPendingEvent(e));
|
||||
Events.on('auto-type', (e) => this.handleEvent(e));
|
||||
Events.on('main-window-blur', (e) => this.mainWindowBlur(e));
|
||||
Events.on('main-window-focus', (e) => this.mainWindowFocus(e));
|
||||
Events.on('main-window-will-close', (e) => this.mainWindowWillClose(e));
|
||||
Events.on('closed-open-view', (e) => this.processPendingEvent(e));
|
||||
},
|
||||
|
||||
handleEvent(e) {
|
||||
|
@ -62,7 +62,7 @@ const AutoType = {
|
|||
},
|
||||
|
||||
runAndHandleResult(result, windowId) {
|
||||
this.run(result, windowId, err => {
|
||||
this.run(result, windowId, (err) => {
|
||||
if (err) {
|
||||
Alerts.error({
|
||||
header: Locale.autoTypeError,
|
||||
|
@ -86,7 +86,7 @@ const AutoType = {
|
|||
const parser = new AutoTypeParser(sequence);
|
||||
const runner = parser.parse();
|
||||
logger.debug('Parsed', this.printOps(runner.ops));
|
||||
runner.resolve(result.entry, context, err => {
|
||||
runner.resolve(result.entry, context, (err) => {
|
||||
if (err) {
|
||||
this.running = false;
|
||||
logger.error('Resolve error', err);
|
||||
|
@ -103,7 +103,7 @@ const AutoType = {
|
|||
}
|
||||
logger.debug('Obfuscated');
|
||||
}
|
||||
runner.run(err => {
|
||||
runner.run((err) => {
|
||||
this.running = false;
|
||||
if (err) {
|
||||
logger.error('Run error', err);
|
||||
|
@ -237,7 +237,7 @@ const AutoType = {
|
|||
this.focusMainWindow();
|
||||
evt.filter.ignoreWindowInfo = true;
|
||||
this.selectEntryView = new AutoTypeSelectView({ filter: evt.filter });
|
||||
this.selectEntryView.on('result', result => {
|
||||
this.selectEntryView.on('result', (result) => {
|
||||
logger.debug('Entry selected', result);
|
||||
this.selectEntryView.off('result');
|
||||
this.selectEntryView.remove();
|
||||
|
|
|
@ -5,19 +5,19 @@ class FileCollection extends Collection {
|
|||
static model = Model;
|
||||
|
||||
hasOpenFiles() {
|
||||
return this.some(file => file.active);
|
||||
return this.some((file) => file.active);
|
||||
}
|
||||
|
||||
hasUnsavedFiles() {
|
||||
return this.some(file => file.modified);
|
||||
return this.some((file) => file.modified);
|
||||
}
|
||||
|
||||
hasDirtyFiles() {
|
||||
return this.some(file => file.dirty);
|
||||
return this.some((file) => file.dirty);
|
||||
}
|
||||
|
||||
getByName(name) {
|
||||
return this.find(file => file.name.toLowerCase() === name.toLowerCase());
|
||||
return this.find((file) => file.name.toLowerCase() === name.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ class FileInfoCollection extends Collection {
|
|||
static model = FileInfoModel;
|
||||
|
||||
load() {
|
||||
return SettingsStore.load('file-info').then(data => {
|
||||
return SettingsStore.load('file-info').then((data) => {
|
||||
if (data) {
|
||||
for (const item of data) {
|
||||
this.push(new FileInfoModel(item));
|
||||
|
@ -20,7 +20,7 @@ class FileInfoCollection extends Collection {
|
|||
}
|
||||
|
||||
getMatch(storage, name, path) {
|
||||
return this.find(fi => {
|
||||
return this.find((fi) => {
|
||||
return (
|
||||
(fi.storage || '') === (storage || '') &&
|
||||
(fi.name || '') === (name || '') &&
|
||||
|
@ -30,7 +30,7 @@ class FileInfoCollection extends Collection {
|
|||
}
|
||||
|
||||
getByName(name) {
|
||||
return this.find(file => file.name.toLowerCase() === name.toLowerCase());
|
||||
return this.find((file) => file.name.toLowerCase() === name.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ const AppRightsChecker = {
|
|||
if (!Launcher.getAppPath().startsWith(this.AppPath)) {
|
||||
return;
|
||||
}
|
||||
this.needRunInstaller(needRun => {
|
||||
this.needRunInstaller((needRun) => {
|
||||
if (needRun) {
|
||||
this.showAlert();
|
||||
this.runInstaller();
|
||||
|
@ -26,7 +26,7 @@ const AppRightsChecker = {
|
|||
},
|
||||
|
||||
needRunInstaller(callback) {
|
||||
Launcher.statFile(this.AppPath, stat => {
|
||||
Launcher.statFile(this.AppPath, (stat) => {
|
||||
const folderIsRoot = stat && stat.uid === 0;
|
||||
callback(!folderIsRoot);
|
||||
});
|
||||
|
@ -46,7 +46,7 @@ const AppRightsChecker = {
|
|||
{ result: 'skip', title: Locale.alertDoNotAsk, error: true },
|
||||
Alerts.buttons.ok
|
||||
],
|
||||
success: result => {
|
||||
success: (result) => {
|
||||
if (result === 'skip') {
|
||||
this.dontAskAnymore();
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ const AppRightsChecker = {
|
|||
Launcher.spawn({
|
||||
cmd: this.AppPath + '/Contents/Installer/KeeWeb Installer.app/Contents/MacOS/applet',
|
||||
complete: () => {
|
||||
this.needRunInstaller(needRun => {
|
||||
this.needRunInstaller((needRun) => {
|
||||
if (this.alert && !needRun) {
|
||||
this.alert.closeWithResult('cancel');
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ const AppRightsChecker = {
|
|||
},
|
||||
|
||||
dontAskAnymore() {
|
||||
this.needRunInstaller(needRun => {
|
||||
this.needRunInstaller((needRun) => {
|
||||
if (needRun) {
|
||||
AppSettingsModel.skipFolderRightsWarning = true;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ const ChalRespCalculator = {
|
|||
if (!params) {
|
||||
return null;
|
||||
}
|
||||
return challenge => {
|
||||
return (challenge) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
challenge = Buffer.from(challenge);
|
||||
const hexChallenge = challenge.toString('hex');
|
||||
|
@ -60,7 +60,7 @@ const ChalRespCalculator = {
|
|||
if (err) {
|
||||
if (err.noKey) {
|
||||
logger.info('YubiKey ChalResp: no key');
|
||||
this._showNoKeyAlert(params.serial, err => {
|
||||
this._showNoKeyAlert(params.serial, (err) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ const ChalRespCalculator = {
|
|||
return;
|
||||
} else if (err.touchRequested) {
|
||||
logger.info('YubiKey ChalResp: touch requested');
|
||||
touchAlert = this._showTouchAlert(params.serial, err => {
|
||||
touchAlert = this._showTouchAlert(params.serial, (err) => {
|
||||
touchAlert = null;
|
||||
userCanceled = true;
|
||||
|
||||
|
@ -114,7 +114,7 @@ const ChalRespCalculator = {
|
|||
logger.error('YubiKey list error', err);
|
||||
return;
|
||||
}
|
||||
const isAttached = list.some(yk => yk.serial === serial);
|
||||
const isAttached = list.some((yk) => yk.serial === serial);
|
||||
logger.info(isAttached ? 'YubiKey found' : 'YubiKey not found');
|
||||
if (isAttached) {
|
||||
Events.off('usb-devices-changed', onUsbDevicesChanged);
|
||||
|
|
|
@ -67,16 +67,16 @@ const GeneratorPresets = {
|
|||
|
||||
get all() {
|
||||
let presets = this.builtIn;
|
||||
presets.forEach(preset => {
|
||||
presets.forEach((preset) => {
|
||||
preset.builtIn = true;
|
||||
});
|
||||
const setting = AppSettingsModel.generatorPresets;
|
||||
if (setting) {
|
||||
if (setting.user) {
|
||||
presets = presets.concat(setting.user.map(item => ({ ...item })));
|
||||
presets = presets.concat(setting.user.map((item) => ({ ...item })));
|
||||
}
|
||||
let hasDefault = false;
|
||||
presets.forEach(preset => {
|
||||
presets.forEach((preset) => {
|
||||
if (setting.disabled && setting.disabled[preset.name]) {
|
||||
preset.disabled = true;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ const GeneratorPresets = {
|
|||
},
|
||||
|
||||
get enabled() {
|
||||
const allPresets = this.all.filter(preset => !preset.disabled);
|
||||
const allPresets = this.all.filter((preset) => !preset.disabled);
|
||||
if (!allPresets.length) {
|
||||
allPresets.push(this.defaultPreset);
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ const GeneratorPresets = {
|
|||
|
||||
add(preset) {
|
||||
const setting = this.getOrCreateSetting();
|
||||
if (preset.name && !setting.user.filter(p => p.name === preset.name).length) {
|
||||
if (preset.name && !setting.user.filter((p) => p.name === preset.name).length) {
|
||||
setting.user.push(preset);
|
||||
this.save(setting);
|
||||
}
|
||||
|
@ -118,13 +118,13 @@ const GeneratorPresets = {
|
|||
|
||||
remove(name) {
|
||||
const setting = this.getOrCreateSetting();
|
||||
setting.user = setting.user.filter(p => p.name !== name);
|
||||
setting.user = setting.user.filter((p) => p.name !== name);
|
||||
this.save(setting);
|
||||
},
|
||||
|
||||
setPreset(name, props) {
|
||||
const setting = this.getOrCreateSetting();
|
||||
const preset = setting.user.filter(p => p.name === name)[0];
|
||||
const preset = setting.user.filter((p) => p.name === name)[0];
|
||||
if (preset) {
|
||||
Object.assign(preset, props);
|
||||
this.save(setting);
|
||||
|
|
|
@ -56,7 +56,7 @@ const Shortcuts = {
|
|||
}
|
||||
return shortcutValue
|
||||
.split(/\+/g)
|
||||
.map(part => {
|
||||
.map((part) => {
|
||||
switch (part) {
|
||||
case 'Ctrl':
|
||||
return this.ctrlShortcutSymbol(formatting);
|
||||
|
|
|
@ -30,7 +30,7 @@ const StartProfiler = {
|
|||
printReport(name, operations, totalTime) {
|
||||
const message =
|
||||
`${name} started in ${totalTime}ms: ` +
|
||||
operations.map(op => `${op.name}=${Math.round(op.elapsed)}ms`).join(', ');
|
||||
operations.map((op) => `${op.name}=${Math.round(op.elapsed)}ms`).join(', ');
|
||||
|
||||
logger.info(message);
|
||||
},
|
||||
|
|
|
@ -43,7 +43,7 @@ const Updater = {
|
|||
if (!Launcher && navigator.serviceWorker && !RuntimeInfo.beta && !RuntimeInfo.devMode) {
|
||||
navigator.serviceWorker
|
||||
.register('service-worker.js')
|
||||
.then(reg => {
|
||||
.then((reg) => {
|
||||
logger.info('Service worker registered');
|
||||
reg.addEventListener('updatefound', () => {
|
||||
if (reg.active) {
|
||||
|
@ -52,7 +52,7 @@ const Updater = {
|
|||
}
|
||||
});
|
||||
})
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
logger.error('Failed to register a service worker', e);
|
||||
});
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ const Updater = {
|
|||
Transport.httpGet({
|
||||
url: Links.Manifest,
|
||||
utf8: true,
|
||||
success: data => {
|
||||
success: (data) => {
|
||||
const dt = new Date();
|
||||
const match = data.match(/#\s*(\d+\-\d+\-\d+):v([\d+\.\w]+)/);
|
||||
logger.info('Update check: ' + (match ? match[0] : 'unknown'));
|
||||
|
@ -145,7 +145,7 @@ const Updater = {
|
|||
UpdateModel.set({ updateStatus: 'found' });
|
||||
}
|
||||
},
|
||||
error: e => {
|
||||
error: (e) => {
|
||||
logger.error('Update check error', e);
|
||||
UpdateModel.set({
|
||||
status: 'error',
|
||||
|
@ -186,10 +186,10 @@ const Updater = {
|
|||
url: Links.UpdateDesktop.replace('{ver}', ver),
|
||||
file: 'KeeWeb-' + ver + '.zip',
|
||||
cache: !startedByUser,
|
||||
success: filePath => {
|
||||
success: (filePath) => {
|
||||
UpdateModel.set({ updateStatus: 'extracting' });
|
||||
logger.info('Extracting update file', this.UpdateCheckFiles, filePath);
|
||||
this.extractAppUpdate(filePath, err => {
|
||||
this.extractAppUpdate(filePath, (err) => {
|
||||
if (err) {
|
||||
logger.error('Error extracting update', err);
|
||||
UpdateModel.set({
|
||||
|
@ -225,7 +225,7 @@ const Updater = {
|
|||
const zip = new StreamZip({ file: updateFile, storeEntries: true });
|
||||
zip.on('error', cb);
|
||||
zip.on('ready', () => {
|
||||
const containsAll = expectedFiles.every(expFile => {
|
||||
const containsAll = expectedFiles.every((expFile) => {
|
||||
const entry = zip.entry(expFile);
|
||||
return entry && entry.isFile;
|
||||
});
|
||||
|
@ -234,7 +234,7 @@ const Updater = {
|
|||
}
|
||||
this.validateArchiveSignature(updateFile, zip)
|
||||
.then(() => {
|
||||
zip.extract(null, appPath, err => {
|
||||
zip.extract(null, appPath, (err) => {
|
||||
zip.close();
|
||||
if (err) {
|
||||
return cb(err);
|
||||
|
@ -243,7 +243,7 @@ const Updater = {
|
|||
cb();
|
||||
});
|
||||
})
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
return cb('Invalid archive: ' + e);
|
||||
});
|
||||
});
|
||||
|
@ -264,7 +264,7 @@ const Updater = {
|
|||
.catch(() => {
|
||||
throw new Error('Error verifying signature');
|
||||
})
|
||||
.then(isValid => {
|
||||
.then((isValid) => {
|
||||
if (!isValid) {
|
||||
throw new Error('Invalid signature');
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ const UsbListener = {
|
|||
this.attachedYubiKeys = this.usb
|
||||
.getDeviceList()
|
||||
.filter(this.isYubiKey)
|
||||
.map(device => ({ device }));
|
||||
.map((device) => ({ device }));
|
||||
|
||||
if (this.attachedYubiKeys.length > 0) {
|
||||
logger.info(`${this.attachedYubiKeys.length} YubiKey(s) found`, logger.ts(ts));
|
||||
|
@ -89,7 +89,7 @@ const UsbListener = {
|
|||
deviceDetached(device) {
|
||||
if (UsbListener.isYubiKey(device)) {
|
||||
const index = UsbListener.attachedYubiKeys.findIndex(
|
||||
yk => yk.device.deviceAddress === device.deviceAddress
|
||||
(yk) => yk.device.deviceAddress === device.deviceAddress
|
||||
);
|
||||
if (index >= 0) {
|
||||
UsbListener.attachedYubiKeys.splice(index, 1);
|
||||
|
|
|
@ -25,7 +25,7 @@ const YubiKey = {
|
|||
if (this.ykmanStatus === 'ok') {
|
||||
return Promise.resolve(this.ykmanStatus);
|
||||
}
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve) => {
|
||||
this.ykmanStatus = 'checking';
|
||||
Launcher.spawn({
|
||||
cmd: 'ykman',
|
||||
|
@ -121,13 +121,13 @@ const YubiKey = {
|
|||
const yubiKeysIncludingEmpty = stdout
|
||||
.trim()
|
||||
.split(/\n/g)
|
||||
.map(line => {
|
||||
.map((line) => {
|
||||
const fullName = line;
|
||||
const serial = (line.match(/\d{5,}$/g) || [])[0];
|
||||
return { fullName, serial };
|
||||
});
|
||||
|
||||
const yubiKeys = yubiKeysIncludingEmpty.filter(s => s.serial);
|
||||
const yubiKeys = yubiKeysIncludingEmpty.filter((s) => s.serial);
|
||||
|
||||
if (
|
||||
yubiKeysIncludingEmpty.length === 1 &&
|
||||
|
@ -176,7 +176,7 @@ const YubiKey = {
|
|||
cmd: 'ykman',
|
||||
args: ['config', 'usb', '-e', 'oath', '-f'],
|
||||
noStdOutLogging: true,
|
||||
complete: err => {
|
||||
complete: (err) => {
|
||||
logger.info('Repair complete', err ? 'with error' : 'OK');
|
||||
if (err) {
|
||||
Events.off('usb-devices-changed', onDevicesChangedDuringRepair);
|
||||
|
|
|
@ -44,7 +44,7 @@ class KeyHandler {
|
|||
offKey(key, handler, thisArg) {
|
||||
if (this.shortcuts[key]) {
|
||||
this.shortcuts[key] = this.shortcuts[key].filter(
|
||||
sh => sh.handler !== handler || sh.thisArg !== thisArg
|
||||
(sh) => sh.handler !== handler || sh.thisArg !== thisArg
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ const Transport = {
|
|||
logger.info('GET ' + config.url);
|
||||
const opts = Launcher.req('url').parse(config.url);
|
||||
opts.headers = { 'User-Agent': navigator.userAgent };
|
||||
Launcher.resolveProxy(config.url, proxy => {
|
||||
Launcher.resolveProxy(config.url, (proxy) => {
|
||||
logger.info(
|
||||
'Request to ' +
|
||||
config.url +
|
||||
|
@ -41,7 +41,7 @@ const Transport = {
|
|||
opts.path = config.url;
|
||||
}
|
||||
Launcher.req(proto)
|
||||
.get(opts, res => {
|
||||
.get(opts, (res) => {
|
||||
logger.info('Response from ' + config.url + ': ' + res.statusCode);
|
||||
if (res.statusCode === 200) {
|
||||
if (config.file) {
|
||||
|
@ -52,12 +52,12 @@ const Transport = {
|
|||
config.success(tmpFile);
|
||||
});
|
||||
});
|
||||
file.on('error', err => {
|
||||
file.on('error', (err) => {
|
||||
config.error(err);
|
||||
});
|
||||
} else {
|
||||
let data = [];
|
||||
res.on('data', chunk => {
|
||||
res.on('data', (chunk) => {
|
||||
data.push(chunk);
|
||||
});
|
||||
res.on('end', () => {
|
||||
|
@ -79,7 +79,7 @@ const Transport = {
|
|||
config.error('HTTP status ' + res.statusCode);
|
||||
}
|
||||
})
|
||||
.on('error', e => {
|
||||
.on('error', (e) => {
|
||||
logger.error('Cannot GET ' + config.url, e);
|
||||
if (tmpFile) {
|
||||
fs.unlink(tmpFile, noop);
|
||||
|
|
|
@ -31,13 +31,15 @@ function walkGroup(db, group, parents) {
|
|||
) {
|
||||
return '';
|
||||
}
|
||||
const self = group.entries.map(entry => walkEntry(db, entry, parents)).join('\n');
|
||||
const children = group.groups.map(childGroup => walkGroup(db, childGroup, parents)).join('\n');
|
||||
const self = group.entries.map((entry) => walkEntry(db, entry, parents)).join('\n');
|
||||
const children = group.groups
|
||||
.map((childGroup) => walkGroup(db, childGroup, parents))
|
||||
.join('\n');
|
||||
return self + children;
|
||||
}
|
||||
|
||||
function walkEntry(db, entry, parents) {
|
||||
const path = parents.map(group => group.name).join(' / ');
|
||||
const path = parents.map((group) => group.name).join(' / ');
|
||||
const fields = [];
|
||||
for (const field of FieldMapping) {
|
||||
const value = entryField(entry, field.name);
|
||||
|
@ -78,7 +80,7 @@ function walkEntry(db, entry, parents) {
|
|||
}
|
||||
return { name, data };
|
||||
})
|
||||
.filter(att => att.name && att.data);
|
||||
.filter((att) => att.name && att.data);
|
||||
|
||||
return Templates.entry({
|
||||
path,
|
||||
|
@ -99,7 +101,7 @@ function entryField(entry, fieldName) {
|
|||
|
||||
const KdbxToHtml = {
|
||||
convert(db, options) {
|
||||
const content = db.groups.map(group => walkGroup(db, group, [])).join('\n');
|
||||
const content = db.groups.map((group) => walkGroup(db, group, [])).join('\n');
|
||||
return Templates.db({
|
||||
name: options.name,
|
||||
date: DateFormat.dtStr(Date.now()),
|
||||
|
|
|
@ -51,7 +51,7 @@ class OtpQrReader {
|
|||
click: '',
|
||||
enter: '',
|
||||
buttons,
|
||||
complete: res => {
|
||||
complete: (res) => {
|
||||
this.alert = null;
|
||||
this.stopListenClipboard();
|
||||
if (res === 'select') {
|
||||
|
@ -94,7 +94,7 @@ class OtpQrReader {
|
|||
|
||||
pasteEvent(e) {
|
||||
const item = [...e.clipboardData.items].find(
|
||||
item => item.kind === 'file' && item.type.indexOf('image') !== -1
|
||||
(item) => item.kind === 'file' && item.type.indexOf('image') !== -1
|
||||
);
|
||||
if (!item) {
|
||||
logger.debug('Paste without file');
|
||||
|
|
|
@ -31,7 +31,7 @@ const Launcher = {
|
|||
},
|
||||
getDataPath(...args) {
|
||||
const storagePath = window.cordova.file.externalDataDirectory;
|
||||
return [storagePath].concat(Array.from(args)).filter(s => !!s);
|
||||
return [storagePath].concat(Array.from(args)).filter((s) => !!s);
|
||||
},
|
||||
getUserDataPath(fileName) {
|
||||
return this.getDataPath('userdata', fileName).join('/');
|
||||
|
@ -52,10 +52,10 @@ const Launcher = {
|
|||
return [...parts].join('/');
|
||||
},
|
||||
writeFile(path, data, callback) {
|
||||
const createFile = filePath => {
|
||||
const createFile = (filePath) => {
|
||||
window.resolveLocalFileSystemURL(
|
||||
filePath.dir,
|
||||
dir => {
|
||||
(dir) => {
|
||||
dir.getFile(filePath.file, { create: true }, writeFile);
|
||||
},
|
||||
callback,
|
||||
|
@ -63,8 +63,8 @@ const Launcher = {
|
|||
);
|
||||
};
|
||||
|
||||
const writeFile = fileEntry => {
|
||||
fileEntry.createWriter(fileWriter => {
|
||||
const writeFile = (fileEntry) => {
|
||||
fileEntry.createWriter((fileWriter) => {
|
||||
fileWriter.onerror = callback;
|
||||
fileWriter.onwriteend = () => callback();
|
||||
fileWriter.write(data);
|
||||
|
@ -85,9 +85,9 @@ const Launcher = {
|
|||
readFile(path, encoding, callback) {
|
||||
window.resolveLocalFileSystemURL(
|
||||
path,
|
||||
fileEntry => {
|
||||
(fileEntry) => {
|
||||
fileEntry.file(
|
||||
file => {
|
||||
(file) => {
|
||||
const reader = new FileReader();
|
||||
reader.onerror = callback;
|
||||
reader.onloadend = () => {
|
||||
|
@ -98,23 +98,23 @@ const Launcher = {
|
|||
};
|
||||
reader.readAsArrayBuffer(file);
|
||||
},
|
||||
err => callback(undefined, err)
|
||||
(err) => callback(undefined, err)
|
||||
);
|
||||
},
|
||||
err => callback(undefined, err)
|
||||
(err) => callback(undefined, err)
|
||||
);
|
||||
},
|
||||
fileExists(path, callback) {
|
||||
window.resolveLocalFileSystemURL(
|
||||
path,
|
||||
fileEntry => callback(true),
|
||||
(fileEntry) => callback(true),
|
||||
() => callback(false)
|
||||
);
|
||||
},
|
||||
deleteFile(path, callback) {
|
||||
window.resolveLocalFileSystemURL(
|
||||
path,
|
||||
fileEntry => {
|
||||
(fileEntry) => {
|
||||
fileEntry.remove(callback, callback, callback);
|
||||
},
|
||||
callback
|
||||
|
@ -123,18 +123,18 @@ const Launcher = {
|
|||
statFile(path, callback) {
|
||||
window.resolveLocalFileSystemURL(
|
||||
path,
|
||||
fileEntry => {
|
||||
(fileEntry) => {
|
||||
fileEntry.file(
|
||||
file => {
|
||||
(file) => {
|
||||
callback({
|
||||
ctime: new Date(file.lastModified),
|
||||
mtime: new Date(file.lastModified)
|
||||
});
|
||||
},
|
||||
err => callback(undefined, err)
|
||||
(err) => callback(undefined, err)
|
||||
);
|
||||
},
|
||||
err => callback(undefined, err)
|
||||
(err) => callback(undefined, err)
|
||||
);
|
||||
},
|
||||
mkdir(dir, callback) {
|
||||
|
@ -144,7 +144,7 @@ const Launcher = {
|
|||
dirEntry.getDirectory(
|
||||
name,
|
||||
{ create: true },
|
||||
dirEntry => {
|
||||
(dirEntry) => {
|
||||
if (path.length) {
|
||||
// there is more to create
|
||||
createDir(dirEntry, path, callback);
|
||||
|
@ -159,12 +159,12 @@ const Launcher = {
|
|||
const localPath = dir
|
||||
.replace(basePath, '')
|
||||
.split('/')
|
||||
.filter(s => !!s);
|
||||
.filter((s) => !!s);
|
||||
|
||||
if (localPath.length) {
|
||||
window.resolveLocalFileSystemURL(
|
||||
basePath,
|
||||
dirEntry => {
|
||||
(dirEntry) => {
|
||||
createDir(dirEntry, localPath, callback);
|
||||
},
|
||||
callback
|
||||
|
@ -230,8 +230,8 @@ const Launcher = {
|
|||
// spawn(config) {},
|
||||
openFileChooser(callback) {
|
||||
const onFileSelected = function (selected) {
|
||||
window.resolveLocalFileSystemURL(selected.uri, fileEntry => {
|
||||
fileEntry.file(file => {
|
||||
window.resolveLocalFileSystemURL(selected.uri, (fileEntry) => {
|
||||
fileEntry.file((file) => {
|
||||
file.path = file.localURL;
|
||||
file.name = selected.name;
|
||||
callback(null, file);
|
||||
|
@ -249,7 +249,7 @@ const Launcher = {
|
|||
},
|
||||
|
||||
register(fileId, password, callback) {
|
||||
FingerprintAuth.isAvailable(result => {
|
||||
FingerprintAuth.isAvailable((result) => {
|
||||
if (!result.isAvailable) {
|
||||
return;
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ const Launcher = {
|
|||
password: password.getText()
|
||||
};
|
||||
|
||||
FingerprintAuth.encrypt(encryptConfig, result => {
|
||||
FingerprintAuth.encrypt(encryptConfig, (result) => {
|
||||
callback(result.token);
|
||||
});
|
||||
});
|
||||
|
@ -273,7 +273,7 @@ const Launcher = {
|
|||
|
||||
const decryptConfig = { ...this.config, username: fileId, token };
|
||||
|
||||
FingerprintAuth.decrypt(decryptConfig, result => {
|
||||
FingerprintAuth.decrypt(decryptConfig, (result) => {
|
||||
callback(result.password);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -36,9 +36,7 @@ const Launcher = {
|
|||
},
|
||||
devTools: true,
|
||||
openDevTools() {
|
||||
this.electron()
|
||||
.remote.getCurrentWindow()
|
||||
.webContents.openDevTools({ mode: 'bottom' });
|
||||
this.electron().remote.getCurrentWindow().webContents.openDevTools({ mode: 'bottom' });
|
||||
},
|
||||
getSaveFileName(defaultPath, callback) {
|
||||
if (defaultPath) {
|
||||
|
@ -51,7 +49,7 @@ const Launcher = {
|
|||
defaultPath,
|
||||
filters: [{ name: Locale.launcherFileFilter, extensions: ['kdbx'] }]
|
||||
})
|
||||
.then(res => callback(res.filePath));
|
||||
.then((res) => callback(res.filePath));
|
||||
},
|
||||
getUserDataPath(fileName) {
|
||||
if (!this.userDataPath) {
|
||||
|
@ -100,7 +98,7 @@ const Launcher = {
|
|||
const stack = [];
|
||||
|
||||
const collect = function (dir, stack, callback) {
|
||||
fs.exists(dir, exists => {
|
||||
fs.exists(dir, (exists) => {
|
||||
if (exists) {
|
||||
return callback();
|
||||
}
|
||||
|
@ -120,7 +118,7 @@ const Launcher = {
|
|||
return callback();
|
||||
}
|
||||
|
||||
fs.mkdir(stack.shift(), err => (err ? callback(err) : create(stack, callback)));
|
||||
fs.mkdir(stack.shift(), (err) => (err ? callback(err) : create(stack, callback)));
|
||||
};
|
||||
|
||||
collect(dir, stack, () => create(stack, callback));
|
||||
|
@ -211,7 +209,7 @@ const Launcher = {
|
|||
resolveProxy(url, callback) {
|
||||
const window = this.getMainWindow();
|
||||
const session = window.webContents.session;
|
||||
session.resolveProxy(url).then(proxy => {
|
||||
session.resolveProxy(url).then((proxy) => {
|
||||
const match = /^proxy\s+([\w\.]+):(\d+)+\s*/i.exec(proxy);
|
||||
proxy = match && match[1] ? { host: match[1], port: +match[2] } : null;
|
||||
callback(proxy);
|
||||
|
@ -235,10 +233,10 @@ const Launcher = {
|
|||
const ts = logger.ts();
|
||||
let complete = config.complete;
|
||||
const ps = this.req('child_process').spawn(config.cmd, config.args);
|
||||
[ps.stdin, ps.stdout, ps.stderr].forEach(s => s.setEncoding('utf-8'));
|
||||
[ps.stdin, ps.stdout, ps.stderr].forEach((s) => s.setEncoding('utf-8'));
|
||||
let stderr = '';
|
||||
let stdout = '';
|
||||
ps.stderr.on('data', d => {
|
||||
ps.stderr.on('data', (d) => {
|
||||
stderr += d.toString('utf-8');
|
||||
if (config.throwOnStdErr) {
|
||||
try {
|
||||
|
@ -246,10 +244,10 @@ const Launcher = {
|
|||
} catch {}
|
||||
}
|
||||
});
|
||||
ps.stdout.on('data', d => {
|
||||
ps.stdout.on('data', (d) => {
|
||||
stdout += d.toString('utf-8');
|
||||
});
|
||||
ps.on('close', code => {
|
||||
ps.on('close', (code) => {
|
||||
stdout = stdout.trim();
|
||||
stderr = stderr.trim();
|
||||
const msg = 'spawn ' + config.cmd + ': ' + code + ', ' + logger.ts(ts);
|
||||
|
@ -263,7 +261,7 @@ const Launcher = {
|
|||
complete = null;
|
||||
}
|
||||
});
|
||||
ps.on('error', err => {
|
||||
ps.on('error', (err) => {
|
||||
logger.error('spawn error: ' + config.cmd + ', ' + logger.ts(ts), err);
|
||||
if (complete) {
|
||||
complete(err);
|
||||
|
@ -309,10 +307,10 @@ Events.on('launcher-exit-request', () => {
|
|||
});
|
||||
Events.on('launcher-minimize', () => setTimeout(() => Events.emit('app-minimized'), 0));
|
||||
Events.on('launcher-started-minimized', () => setTimeout(() => Launcher.minimizeApp(), 0));
|
||||
Events.on('start-profile', data => StartProfiler.reportAppProfile(data));
|
||||
Events.on('log', e => new Logger(e.category || 'remote-app')[e.method || 'info'](e.message));
|
||||
Events.on('start-profile', (data) => StartProfiler.reportAppProfile(data));
|
||||
Events.on('log', (e) => new Logger(e.category || 'remote-app')[e.method || 'info'](e.message));
|
||||
|
||||
window.launcherOpen = file => Launcher.openFile(file);
|
||||
window.launcherOpen = (file) => Launcher.openFile(file);
|
||||
if (window.launcherOpenedFile) {
|
||||
logger.info('Open file request', window.launcherOpenedFile);
|
||||
Launcher.openFile(window.launcherOpenedFile);
|
||||
|
@ -328,7 +326,7 @@ Events.on('app-ready', () =>
|
|||
}, 0)
|
||||
);
|
||||
|
||||
Launcher.remoteApp().on('remote-app-event', e => {
|
||||
Launcher.remoteApp().on('remote-app-event', (e) => {
|
||||
if (window.debugRemoteAppEvents) {
|
||||
logger.debug('remote-app-event', e.name);
|
||||
}
|
||||
|
|
|
@ -15,15 +15,15 @@ const SettingsStore = {
|
|||
});
|
||||
}
|
||||
return loadPromise
|
||||
.then(data => (data ? JSON.parse(data) : null))
|
||||
.catch(err => {
|
||||
.then((data) => (data ? JSON.parse(data) : null))
|
||||
.catch((err) => {
|
||||
logger.error(`Error loading ${key}`, err);
|
||||
});
|
||||
},
|
||||
|
||||
save(key, data) {
|
||||
if (Launcher) {
|
||||
return Launcher.saveConfig(key, JSON.stringify(data)).catch(err => {
|
||||
return Launcher.saveConfig(key, JSON.stringify(data)).catch((err) => {
|
||||
logger.error(`Error saving ${key}`, err);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ class Collection {
|
|||
}
|
||||
|
||||
get(id) {
|
||||
return this.find(model => model.id === id);
|
||||
return this.find((model) => model.id === id);
|
||||
}
|
||||
|
||||
remove(idOrModel) {
|
||||
|
|
|
@ -130,7 +130,7 @@ class View extends EventEmitter {
|
|||
}
|
||||
for (const [event, handlers] of Object.entries(eventsMap)) {
|
||||
this.debugLogger?.debug('Bind', 'view', event, handlers);
|
||||
const listener = e => this.eventListener(e, handlers);
|
||||
const listener = (e) => this.eventListener(e, handlers);
|
||||
this.eventListeners[event] = listener;
|
||||
this.el.addEventListener(event, listener);
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ class View extends EventEmitter {
|
|||
for (const cfg of this.elementEventListeners) {
|
||||
const els = this.el.querySelectorAll(cfg.selector);
|
||||
this.debugLogger?.debug('Bind', 'element', cfg.event, cfg.selector, els.length);
|
||||
cfg.listener = e => this.eventListener(e, [cfg]);
|
||||
cfg.listener = (e) => this.eventListener(e, [cfg]);
|
||||
for (const el of els) {
|
||||
el.addEventListener(cfg.event, cfg.listener);
|
||||
cfg.els.push(el);
|
||||
|
@ -209,7 +209,7 @@ class View extends EventEmitter {
|
|||
for (const view of Object.values(this.views)) {
|
||||
if (view) {
|
||||
if (view instanceof Array) {
|
||||
view.forEach(v => v.remove());
|
||||
view.forEach((v) => v.remove());
|
||||
} else {
|
||||
view.remove();
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ Handlebars.registerHelper('res', function(key, options) {
|
|||
return value;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('Res', key => {
|
||||
Handlebars.registerHelper('Res', (key) => {
|
||||
let value = Locale[key];
|
||||
if (value) {
|
||||
value = value[0].toUpperCase() + value.substr(1);
|
||||
|
|
|
@ -91,7 +91,7 @@ class AppModel {
|
|||
this.appLogger.error('Error loading app config', xhr.statusText, xhr.status);
|
||||
reject('Error loading app config');
|
||||
});
|
||||
}).then(config => {
|
||||
}).then((config) => {
|
||||
return this.applyUserConfig(config);
|
||||
});
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ class AppModel {
|
|||
}
|
||||
config.files
|
||||
.filter(
|
||||
file =>
|
||||
(file) =>
|
||||
file &&
|
||||
file.storage &&
|
||||
file.name &&
|
||||
|
@ -124,7 +124,7 @@ class AppModel {
|
|||
!this.fileInfos.getMatch(file.storage, file.name, file.path)
|
||||
)
|
||||
.map(
|
||||
file =>
|
||||
(file) =>
|
||||
new FileInfoModel({
|
||||
id: IdGenerator.uuid(),
|
||||
name: file.name,
|
||||
|
@ -134,10 +134,10 @@ class AppModel {
|
|||
})
|
||||
)
|
||||
.reverse()
|
||||
.forEach(fi => this.fileInfos.unshift(fi));
|
||||
.forEach((fi) => this.fileInfos.unshift(fi));
|
||||
}
|
||||
if (config.plugins) {
|
||||
const pluginsPromises = config.plugins.map(plugin =>
|
||||
const pluginsPromises = config.plugins.map((plugin) =>
|
||||
PluginManager.installIfNew(plugin.url, plugin.manifest, true)
|
||||
);
|
||||
return Promise.all(pluginsPromises).then(() => {
|
||||
|
@ -180,10 +180,10 @@ class AppModel {
|
|||
|
||||
_addTags(file) {
|
||||
const tagsHash = {};
|
||||
this.tags.forEach(tag => {
|
||||
this.tags.forEach((tag) => {
|
||||
tagsHash[tag.toLowerCase()] = true;
|
||||
});
|
||||
file.forEachEntry({}, entry => {
|
||||
file.forEachEntry({}, (entry) => {
|
||||
for (const tag of entry.tags) {
|
||||
if (!tagsHash[tag.toLowerCase()]) {
|
||||
tagsHash[tag.toLowerCase()] = true;
|
||||
|
@ -198,7 +198,7 @@ class AppModel {
|
|||
if (this.tags.length) {
|
||||
this.menu.tagsSection.scrollable = true;
|
||||
this.menu.tagsSection.setItems(
|
||||
this.tags.map(tag => {
|
||||
this.tags.map((tag) => {
|
||||
return {
|
||||
title: tag,
|
||||
icon: 'tag',
|
||||
|
@ -226,7 +226,7 @@ class AppModel {
|
|||
}
|
||||
|
||||
renameTag(from, to) {
|
||||
this.files.forEach(file => file.renameTag && file.renameTag(from, to));
|
||||
this.files.forEach((file) => file.renameTag && file.renameTag(from, to));
|
||||
this.updateTags();
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ class AppModel {
|
|||
}
|
||||
|
||||
emptyTrash() {
|
||||
this.files.forEach(file => file.emptyTrash && file.emptyTrash());
|
||||
this.files.forEach((file) => file.emptyTrash && file.emptyTrash());
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
|
@ -306,14 +306,14 @@ class AppModel {
|
|||
const preparedFilter = this.prepareFilter(filter);
|
||||
const entries = new SearchResultCollection();
|
||||
|
||||
const devicesToMatchOtpEntries = this.files.filter(file => file.external);
|
||||
const devicesToMatchOtpEntries = this.files.filter((file) => file.external);
|
||||
|
||||
const matchedOtpEntrySet = this.settings.yubiKeyMatchEntries ? new Set() : undefined;
|
||||
|
||||
this.files
|
||||
.filter(file => !file.external)
|
||||
.forEach(file => {
|
||||
file.forEachEntry(preparedFilter, entry => {
|
||||
.filter((file) => !file.external)
|
||||
.forEach((file) => {
|
||||
file.forEachEntry(preparedFilter, (entry) => {
|
||||
if (matchedOtpEntrySet) {
|
||||
for (const device of devicesToMatchOtpEntries) {
|
||||
const matchingEntry = device.getMatchingEntry(entry);
|
||||
|
@ -328,7 +328,7 @@ class AppModel {
|
|||
|
||||
if (devicesToMatchOtpEntries.length) {
|
||||
for (const device of devicesToMatchOtpEntries) {
|
||||
device.forEachEntry(preparedFilter, entry => {
|
||||
device.forEachEntry(preparedFilter, (entry) => {
|
||||
if (!matchedOtpEntrySet || !matchedOtpEntrySet.has(entry)) {
|
||||
entries.push(entry);
|
||||
}
|
||||
|
@ -340,10 +340,10 @@ class AppModel {
|
|||
}
|
||||
|
||||
addTrashGroups(collection) {
|
||||
this.files.forEach(file => {
|
||||
this.files.forEach((file) => {
|
||||
const trashGroup = file.getTrashGroup && file.getTrashGroup();
|
||||
if (trashGroup) {
|
||||
trashGroup.getOwnSubGroups().forEach(group => {
|
||||
trashGroup.getOwnSubGroups().forEach((group) => {
|
||||
collection.unshift(GroupModel.fromGroup(group, file, trashGroup));
|
||||
});
|
||||
}
|
||||
|
@ -359,10 +359,10 @@ class AppModel {
|
|||
|
||||
const exact = filter.advanced && filter.advanced.exact;
|
||||
if (!exact && filter.text) {
|
||||
const textParts = filter.text.split(/\s+/).filter(s => s);
|
||||
const textParts = filter.text.split(/\s+/).filter((s) => s);
|
||||
if (textParts.length) {
|
||||
filter.textParts = textParts;
|
||||
filter.textLowerParts = filter.textLower.split(/\s+/).filter(s => s);
|
||||
filter.textLowerParts = filter.textLower.split(/\s+/).filter((s) => s);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -375,14 +375,14 @@ class AppModel {
|
|||
const selGroupId = this.filter.group;
|
||||
let file, group;
|
||||
if (selGroupId) {
|
||||
this.files.some(f => {
|
||||
this.files.some((f) => {
|
||||
file = f;
|
||||
group = f.getGroup(selGroupId);
|
||||
return group;
|
||||
});
|
||||
}
|
||||
if (!group) {
|
||||
file = this.files.find(f => f.active && !f.readOnly);
|
||||
file = this.files.find((f) => f.active && !f.readOnly);
|
||||
group = file.groups[0];
|
||||
}
|
||||
return { group, file };
|
||||
|
@ -390,10 +390,10 @@ class AppModel {
|
|||
|
||||
completeUserNames(part) {
|
||||
const userNames = {};
|
||||
this.files.forEach(file => {
|
||||
this.files.forEach((file) => {
|
||||
file.forEachEntry(
|
||||
{ text: part, textLower: part.toLowerCase(), advanced: { user: true } },
|
||||
entry => {
|
||||
(entry) => {
|
||||
const userName = entry.user;
|
||||
if (userName) {
|
||||
userNames[userName] = (userNames[userName] || 0) + 1;
|
||||
|
@ -407,13 +407,13 @@ class AppModel {
|
|||
if (matches.length > maxResults) {
|
||||
matches.length = maxResults;
|
||||
}
|
||||
return matches.map(m => m[0]);
|
||||
return matches.map((m) => m[0]);
|
||||
}
|
||||
|
||||
getEntryTemplates() {
|
||||
const entryTemplates = [];
|
||||
this.files.forEach(file => {
|
||||
file.forEachEntryTemplate?.(entry => {
|
||||
this.files.forEach((file) => {
|
||||
file.forEachEntryTemplate?.((entry) => {
|
||||
entryTemplates.push({ file, entry });
|
||||
});
|
||||
});
|
||||
|
@ -421,7 +421,7 @@ class AppModel {
|
|||
}
|
||||
|
||||
canCreateEntries() {
|
||||
return this.files.some(f => f.active && !f.readOnly);
|
||||
return this.files.some((f) => f.active && !f.readOnly);
|
||||
}
|
||||
|
||||
createNewEntry(args) {
|
||||
|
@ -667,7 +667,7 @@ class AppModel {
|
|||
fingerprint: (fileInfo && fileInfo.fingerprint) || null,
|
||||
chalResp: params.chalResp
|
||||
});
|
||||
const openComplete = err => {
|
||||
const openComplete = (err) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
@ -723,7 +723,7 @@ class AppModel {
|
|||
storage: params.storage,
|
||||
path: params.path
|
||||
});
|
||||
file.importWithXml(params.fileXml, err => {
|
||||
file.importWithXml(params.fileXml, (err) => {
|
||||
logger.info('Import xml complete ' + (err ? 'with error' : ''), err);
|
||||
if (err) {
|
||||
return callback(err);
|
||||
|
@ -812,7 +812,7 @@ class AppModel {
|
|||
this.saveFileFingerprint(file, params.password);
|
||||
}
|
||||
if (this.settings.yubiKeyAutoOpen) {
|
||||
if (this.attachedYubiKeysCount > 0 && !this.files.some(f => f.external)) {
|
||||
if (this.attachedYubiKeysCount > 0 && !this.files.some((f) => f.external)) {
|
||||
this.tryOpenOtpDeviceInBackground();
|
||||
}
|
||||
}
|
||||
|
@ -882,7 +882,7 @@ class AppModel {
|
|||
});
|
||||
}
|
||||
file.setSyncProgress();
|
||||
const complete = err => {
|
||||
const complete = (err) => {
|
||||
if (!file.active) {
|
||||
return callback && callback('File is closed');
|
||||
}
|
||||
|
@ -922,7 +922,7 @@ class AppModel {
|
|||
if (err) {
|
||||
return complete(err);
|
||||
}
|
||||
Storage.cache.save(fileInfo.id, null, data, err => {
|
||||
Storage.cache.save(fileInfo.id, null, data, (err) => {
|
||||
logger.info('Saved to cache', err || 'no error');
|
||||
complete(err);
|
||||
if (!err) {
|
||||
|
@ -946,7 +946,7 @@ class AppModel {
|
|||
if (err) {
|
||||
return complete(err);
|
||||
}
|
||||
file.mergeOrUpdate(data, options.remoteKey, err => {
|
||||
file.mergeOrUpdate(data, options.remoteKey, (err) => {
|
||||
logger.info('Merge complete', err || 'no error');
|
||||
this.refresh();
|
||||
if (err) {
|
||||
|
@ -966,7 +966,7 @@ class AppModel {
|
|||
saveToCacheAndStorage();
|
||||
} else if (file.dirty) {
|
||||
logger.info('Saving not modified dirty file to cache');
|
||||
Storage.cache.save(fileInfo.id, null, data, err => {
|
||||
Storage.cache.save(fileInfo.id, null, data, (err) => {
|
||||
if (err) {
|
||||
return complete(err);
|
||||
}
|
||||
|
@ -981,7 +981,7 @@ class AppModel {
|
|||
});
|
||||
});
|
||||
};
|
||||
const saveToStorage = data => {
|
||||
const saveToStorage = (data) => {
|
||||
logger.info('Save data to storage');
|
||||
const storageRev = fileInfo.storage === storage ? fileInfo.rev : undefined;
|
||||
Storage[storage].save(
|
||||
|
@ -1029,7 +1029,7 @@ class AppModel {
|
|||
saveToStorage(data);
|
||||
} else {
|
||||
logger.info('Saving to cache');
|
||||
Storage.cache.save(fileInfo.id, null, data, err => {
|
||||
Storage.cache.save(fileInfo.id, null, data, (err) => {
|
||||
if (err) {
|
||||
return complete(err);
|
||||
}
|
||||
|
@ -1056,7 +1056,7 @@ class AppModel {
|
|||
logger.error('Error getting file data', e);
|
||||
return complete(err);
|
||||
}
|
||||
Storage.cache.save(fileInfo.id, null, data, e => {
|
||||
Storage.cache.save(fileInfo.id, null, data, (e) => {
|
||||
if (e) {
|
||||
logger.error('Error saving to cache', e);
|
||||
}
|
||||
|
@ -1129,7 +1129,7 @@ class AppModel {
|
|||
if (Storage[backup.storage].getPathForName) {
|
||||
path = Storage[backup.storage].getPathForName(path);
|
||||
}
|
||||
Storage[backup.storage].save(path, opts, data, err => {
|
||||
Storage[backup.storage].save(path, opts, data, (err) => {
|
||||
if (err) {
|
||||
logger.error('Backup error', err);
|
||||
} else {
|
||||
|
@ -1147,14 +1147,14 @@ class AppModel {
|
|||
if (Storage[backup.storage].getPathForName) {
|
||||
folderPath = Storage[backup.storage].getPathForName(folderPath).replace('.kdbx', '');
|
||||
}
|
||||
Storage[backup.storage].stat(folderPath, opts, err => {
|
||||
Storage[backup.storage].stat(folderPath, opts, (err) => {
|
||||
if (err) {
|
||||
if (err.notFound) {
|
||||
logger.info('Backup folder does not exist');
|
||||
if (!Storage[backup.storage].mkdir) {
|
||||
return callback('Mkdir not supported by ' + backup.storage);
|
||||
}
|
||||
Storage[backup.storage].mkdir(folderPath, err => {
|
||||
Storage[backup.storage].mkdir(folderPath, (err) => {
|
||||
if (err) {
|
||||
logger.error('Error creating backup folder', err);
|
||||
callback('Error creating backup folder');
|
||||
|
@ -1227,7 +1227,7 @@ class AppModel {
|
|||
saveFileFingerprint(file, password) {
|
||||
if (Launcher && Launcher.fingerprints && !file.fingerprint) {
|
||||
const fileInfo = this.fileInfos.get(file.id);
|
||||
Launcher.fingerprints.register(file.id, password, token => {
|
||||
Launcher.fingerprints.register(file.id, password, (token) => {
|
||||
if (token) {
|
||||
fileInfo.fingerprint = token;
|
||||
this.fileInfos.save();
|
||||
|
@ -1246,7 +1246,7 @@ class AppModel {
|
|||
}
|
||||
|
||||
const isNewYubiKey = UsbListener.attachedYubiKeys.length > attachedYubiKeysCount;
|
||||
const hasOpenFiles = this.files.some(file => file.active && !file.external);
|
||||
const hasOpenFiles = this.files.some((file) => file.active && !file.external);
|
||||
|
||||
if (isNewYubiKey && hasOpenFiles && !this.openingOtpDevice) {
|
||||
this.tryOpenOtpDeviceInBackground();
|
||||
|
@ -1255,7 +1255,7 @@ class AppModel {
|
|||
|
||||
tryOpenOtpDeviceInBackground() {
|
||||
this.appLogger.debug('Auto-opening a YubiKey');
|
||||
this.openOtpDevice(err => {
|
||||
this.openOtpDevice((err) => {
|
||||
this.appLogger.debug('YubiKey auto-open complete', err);
|
||||
});
|
||||
}
|
||||
|
@ -1263,7 +1263,7 @@ class AppModel {
|
|||
openOtpDevice(callback) {
|
||||
this.openingOtpDevice = true;
|
||||
const device = new YubiKeyOtpModel();
|
||||
device.open(err => {
|
||||
device.open((err) => {
|
||||
this.openingOtpDevice = false;
|
||||
if (!err) {
|
||||
this.addFile(device);
|
||||
|
|
|
@ -9,7 +9,7 @@ class AppSettingsModel extends Model {
|
|||
}
|
||||
|
||||
load() {
|
||||
return SettingsStore.load('app-settings').then(data => {
|
||||
return SettingsStore.load('app-settings').then((data) => {
|
||||
if (data) {
|
||||
this.upgrade(data);
|
||||
this.set(data, { silent: true });
|
||||
|
|
|
@ -107,10 +107,10 @@ class EntryModel extends Model {
|
|||
text += value.toLowerCase() + '\n';
|
||||
}
|
||||
}
|
||||
this.entry.tags.forEach(tag => {
|
||||
this.entry.tags.forEach((tag) => {
|
||||
text += tag.toLowerCase() + '\n';
|
||||
});
|
||||
this.attachments.forEach(att => {
|
||||
this.attachments.forEach((att) => {
|
||||
text += att.title.toLowerCase() + '\n';
|
||||
});
|
||||
this.searchText = text;
|
||||
|
@ -128,7 +128,7 @@ class EntryModel extends Model {
|
|||
}
|
||||
|
||||
_buildSearchTags() {
|
||||
this.searchTags = this.entry.tags.map(tag => tag.toLowerCase());
|
||||
this.searchTags = this.entry.tags.map((tag) => tag.toLowerCase());
|
||||
}
|
||||
|
||||
_buildSearchColor() {
|
||||
|
@ -217,7 +217,7 @@ class EntryModel extends Model {
|
|||
|
||||
resolveFieldReferences() {
|
||||
this.hasFieldRefs = false;
|
||||
FieldRefFields.forEach(field => {
|
||||
FieldRefFields.forEach((field) => {
|
||||
const fieldValue = this[field];
|
||||
const refValue = this._resolveFieldReference(fieldValue);
|
||||
if (refValue !== undefined) {
|
||||
|
@ -230,7 +230,7 @@ class EntryModel extends Model {
|
|||
getFieldValue(field) {
|
||||
field = field.toLowerCase();
|
||||
let resolvedField;
|
||||
Object.keys(this.entry.fields).some(entryField => {
|
||||
Object.keys(this.entry.fields).some((entryField) => {
|
||||
if (entryField.toLowerCase() === field) {
|
||||
resolvedField = entryField;
|
||||
return true;
|
||||
|
@ -310,7 +310,7 @@ class EntryModel extends Model {
|
|||
}
|
||||
|
||||
renameTag(from, to) {
|
||||
const ix = this.entry.tags.findIndex(tag => tag.toLowerCase() === from.toLowerCase());
|
||||
const ix = this.entry.tags.findIndex((tag) => tag.toLowerCase() === from.toLowerCase());
|
||||
if (ix < 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ class EntryModel extends Model {
|
|||
|
||||
addAttachment(name, data) {
|
||||
this._entryModified();
|
||||
return this.file.db.createBinary(data).then(binaryRef => {
|
||||
return this.file.db.createBinary(data).then((binaryRef) => {
|
||||
this.entry.binaries[name] = binaryRef;
|
||||
this._fillByEntry();
|
||||
});
|
||||
|
@ -466,7 +466,7 @@ class EntryModel extends Model {
|
|||
} else if (otpUrl.toLowerCase().lastIndexOf('otpauth:', 0) !== 0) {
|
||||
// KeeOTP plugin format
|
||||
const args = {};
|
||||
otpUrl.split('&').forEach(part => {
|
||||
otpUrl.split('&').forEach((part) => {
|
||||
const parts = part.split('=', 2);
|
||||
args[parts[0]] = decodeURIComponent(parts[1]).replace(/=/g, '');
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@ class ExternalOtpEntryModel extends ExternalEntryModel {
|
|||
return;
|
||||
}
|
||||
const gen = {
|
||||
next: callback => {
|
||||
next: (callback) => {
|
||||
if (gen.otp && gen.expires) {
|
||||
const timeLeft = gen.expires - Date.now();
|
||||
if (timeLeft > 0) {
|
||||
|
@ -26,7 +26,7 @@ class ExternalOtpEntryModel extends ExternalEntryModel {
|
|||
});
|
||||
return;
|
||||
}
|
||||
gen.promise = new Promise(resolve => {
|
||||
gen.promise = new Promise((resolve) => {
|
||||
gen.otpState = this.device.getOtp(this, (err, otp, timeLeft) => {
|
||||
gen.otpState = null;
|
||||
gen.promise = null;
|
||||
|
|
|
@ -34,7 +34,7 @@ class YubiKeyOtpModel extends ExternalOtpDeviceModel {
|
|||
const openErrors = [];
|
||||
const openNextYubiKey = () => {
|
||||
const yubiKey = yubiKeys.shift();
|
||||
this._addYubiKey(yubiKey.serial, err => {
|
||||
this._addYubiKey(yubiKey.serial, (err) => {
|
||||
if (YubiKey.aborted) {
|
||||
return callback('Aborted');
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class FileModel extends Model {
|
|||
const ts = logger.ts();
|
||||
|
||||
kdbxweb.Kdbx.load(fileData, credentials)
|
||||
.then(db => {
|
||||
.then((db) => {
|
||||
this.db = db;
|
||||
this.readModel();
|
||||
this.setOpenFile({ passwordLength: password ? password.textLength : 0 });
|
||||
|
@ -50,7 +50,7 @@ class FileModel extends Model {
|
|||
);
|
||||
callback();
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
if (
|
||||
err.code === kdbxweb.Consts.ErrorCodes.InvalidKey &&
|
||||
password &&
|
||||
|
@ -74,14 +74,14 @@ class FileModel extends Model {
|
|||
if (header.kdfParameters) {
|
||||
return header.kdfParameters
|
||||
.keys()
|
||||
.map(key => {
|
||||
.map((key) => {
|
||||
const val = header.kdfParameters.get(key);
|
||||
if (val instanceof ArrayBuffer) {
|
||||
return undefined;
|
||||
}
|
||||
return key + '=' + val;
|
||||
})
|
||||
.filter(p => p)
|
||||
.filter((p) => p)
|
||||
.join('&');
|
||||
} else if (header.keyEncryptionRounds) {
|
||||
return header.keyEncryptionRounds + ' rounds';
|
||||
|
@ -105,14 +105,14 @@ class FileModel extends Model {
|
|||
const password = kdbxweb.ProtectedValue.fromString('');
|
||||
const credentials = new kdbxweb.Credentials(password);
|
||||
kdbxweb.Kdbx.loadXml(fileXml, credentials)
|
||||
.then(db => {
|
||||
.then((db) => {
|
||||
this.db = db;
|
||||
this.readModel();
|
||||
this.set({ active: true, created: true });
|
||||
logger.info('Imported file ' + this.name + ': ' + logger.ts(ts));
|
||||
callback();
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
logger.error('Error importing file', err.code, err.message, err);
|
||||
callback(err);
|
||||
});
|
||||
|
@ -128,7 +128,7 @@ class FileModel extends Model {
|
|||
const demoFile = kdbxweb.ByteUtils.arrayToBuffer(
|
||||
kdbxweb.ByteUtils.base64ToBytes(demoFileData)
|
||||
);
|
||||
kdbxweb.Kdbx.load(demoFile, credentials).then(db => {
|
||||
kdbxweb.Kdbx.load(demoFile, credentials).then((db) => {
|
||||
this.db = db;
|
||||
this.name = 'Demo';
|
||||
this.readModel();
|
||||
|
@ -235,9 +235,9 @@ class FileModel extends Model {
|
|||
const entryMap = {};
|
||||
const groupMap = {};
|
||||
this.forEachGroup(
|
||||
group => {
|
||||
(group) => {
|
||||
groupMap[group.id] = group;
|
||||
group.forEachOwnEntry(null, entry => {
|
||||
group.forEachOwnEntry(null, (entry) => {
|
||||
entryMap[entry.id] = entry;
|
||||
});
|
||||
},
|
||||
|
@ -249,7 +249,7 @@ class FileModel extends Model {
|
|||
|
||||
resolveFieldReferences() {
|
||||
const entryMap = this.entryMap;
|
||||
Object.keys(entryMap).forEach(e => {
|
||||
Object.keys(entryMap).forEach((e) => {
|
||||
entryMap[e].resolveFieldReferences();
|
||||
});
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ class FileModel extends Model {
|
|||
}
|
||||
credentialsPromise.then(() => {
|
||||
kdbxweb.Kdbx.load(fileData, credentials)
|
||||
.then(remoteDb => {
|
||||
.then((remoteDb) => {
|
||||
if (this.modified) {
|
||||
try {
|
||||
if (remoteKey && remoteDb.meta.keyChanged > this.db.meta.keyChanged) {
|
||||
|
@ -319,7 +319,7 @@ class FileModel extends Model {
|
|||
this.reload();
|
||||
callback();
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
logger.error('Error opening file to merge', err.code, err.message, err);
|
||||
callback(err);
|
||||
});
|
||||
|
@ -374,7 +374,7 @@ class FileModel extends Model {
|
|||
top.forEachOwnEntry(filter, callback);
|
||||
}
|
||||
if (!filter.group || filter.subGroups) {
|
||||
top.forEachGroup(group => {
|
||||
top.forEachGroup((group) => {
|
||||
group.forEachOwnEntry(filter, callback);
|
||||
}, filter);
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ class FileModel extends Model {
|
|||
}
|
||||
|
||||
forEachGroup(callback, filter) {
|
||||
this.groups.forEach(group => {
|
||||
this.groups.forEach((group) => {
|
||||
if (callback(group) !== false) {
|
||||
group.forEachGroup(callback, filter);
|
||||
}
|
||||
|
@ -426,17 +426,17 @@ class FileModel extends Model {
|
|||
this.db.cleanup({ binaries: true });
|
||||
this.db
|
||||
.save()
|
||||
.then(data => {
|
||||
.then((data) => {
|
||||
cb(data);
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
logger.error('Error saving file', this.name, err);
|
||||
cb(undefined, err);
|
||||
});
|
||||
}
|
||||
|
||||
getXml(cb) {
|
||||
this.db.saveXml(true).then(xml => {
|
||||
this.db.saveXml(true).then((xml) => {
|
||||
cb(xml);
|
||||
});
|
||||
}
|
||||
|
@ -493,7 +493,7 @@ class FileModel extends Model {
|
|||
return;
|
||||
}
|
||||
this.setOpenFile({ passwordLength: this.passwordLength });
|
||||
this.forEachEntry({ includeDisabled: true }, entry => entry.setSaved());
|
||||
this.forEachEntry({ includeDisabled: true }, (entry) => entry.setSaved());
|
||||
}
|
||||
|
||||
setPassword(password) {
|
||||
|
@ -666,7 +666,7 @@ class FileModel extends Model {
|
|||
}
|
||||
|
||||
getCustomIcons() {
|
||||
return mapObject(this.db.meta.customIcons, customIcon =>
|
||||
return mapObject(this.db.meta.customIcons, (customIcon) =>
|
||||
IconUrlFormat.toDataUrl(customIcon)
|
||||
);
|
||||
}
|
||||
|
@ -680,7 +680,7 @@ class FileModel extends Model {
|
|||
}
|
||||
|
||||
renameTag(from, to) {
|
||||
this.forEachEntry({}, entry => entry.renameTag(from, to));
|
||||
this.forEachEntry({}, (entry) => entry.renameTag(from, to));
|
||||
}
|
||||
|
||||
setFormatVersion(version) {
|
||||
|
|
|
@ -39,7 +39,7 @@ class GroupModel extends MenuItemModel {
|
|||
const items = this.items;
|
||||
const entries = this.entries;
|
||||
|
||||
const itemsArray = group.groups.map(subGroup => {
|
||||
const itemsArray = group.groups.map((subGroup) => {
|
||||
let g = file.getGroup(file.subId(subGroup.uuid.id));
|
||||
if (g) {
|
||||
g.setGroup(subGroup, file, this);
|
||||
|
@ -50,7 +50,7 @@ class GroupModel extends MenuItemModel {
|
|||
}, this);
|
||||
items.push(...itemsArray);
|
||||
|
||||
const entriesArray = group.entries.map(entry => {
|
||||
const entriesArray = group.entries.map((entry) => {
|
||||
let e = file.getEntry(file.subId(entry.uuid.id));
|
||||
if (e) {
|
||||
e.setEntry(entry, this, file);
|
||||
|
@ -101,7 +101,7 @@ class GroupModel extends MenuItemModel {
|
|||
|
||||
forEachGroup(callback, filter) {
|
||||
let result = true;
|
||||
this.items.forEach(group => {
|
||||
this.items.forEach((group) => {
|
||||
if (group.matches(filter)) {
|
||||
result =
|
||||
callback(group) !== false && group.forEachGroup(callback, filter) !== false;
|
||||
|
|
|
@ -49,7 +49,7 @@ class MenuModel extends Model {
|
|||
drop: true
|
||||
}
|
||||
]);
|
||||
Colors.AllColors.forEach(color => {
|
||||
Colors.AllColors.forEach((color) => {
|
||||
const option = {
|
||||
cls: 'fa ' + color + '-color',
|
||||
value: color,
|
||||
|
@ -96,7 +96,7 @@ class MenuModel extends Model {
|
|||
this.aboutSection,
|
||||
this.helpSection,
|
||||
this.filesSection
|
||||
].filter(s => s)
|
||||
].filter((s) => s)
|
||||
);
|
||||
this.sections = this.menus.app;
|
||||
|
||||
|
@ -113,7 +113,7 @@ class MenuModel extends Model {
|
|||
this._select(section, sel.item);
|
||||
}
|
||||
if (sections === this.menus.app) {
|
||||
this.colorsItem.options.forEach(opt => {
|
||||
this.colorsItem.options.forEach((opt) => {
|
||||
opt.active = opt === sel.option;
|
||||
});
|
||||
const selColor =
|
||||
|
@ -135,7 +135,7 @@ class MenuModel extends Model {
|
|||
_selectPrevious() {
|
||||
let previousItem = null;
|
||||
|
||||
const processSection = section => {
|
||||
const processSection = (section) => {
|
||||
if (section.visible === false) {
|
||||
return true;
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ class MenuModel extends Model {
|
|||
}
|
||||
const items = section.items;
|
||||
if (items) {
|
||||
items.forEach(it => {
|
||||
items.forEach((it) => {
|
||||
if (it.active && previousItem) {
|
||||
this.select({ item: previousItem });
|
||||
return false;
|
||||
|
@ -155,13 +155,13 @@ class MenuModel extends Model {
|
|||
};
|
||||
|
||||
const sections = this.sections;
|
||||
sections.forEach(section => processSection(section));
|
||||
sections.forEach((section) => processSection(section));
|
||||
}
|
||||
|
||||
_selectNext() {
|
||||
let activeItem = null;
|
||||
|
||||
const processSection = section => {
|
||||
const processSection = (section) => {
|
||||
if (section.visible === false) {
|
||||
return true;
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ class MenuModel extends Model {
|
|||
}
|
||||
const items = section.items;
|
||||
if (items) {
|
||||
items.forEach(it => {
|
||||
items.forEach((it) => {
|
||||
if (it.active) {
|
||||
activeItem = it;
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ class MenuModel extends Model {
|
|||
};
|
||||
|
||||
const sections = this.sections;
|
||||
sections.forEach(section => processSection(section));
|
||||
sections.forEach((section) => processSection(section));
|
||||
}
|
||||
|
||||
_select(item, selectedItem) {
|
||||
|
|
|
@ -19,14 +19,14 @@ class MenuSectionModel extends Model {
|
|||
removeAllItems() {
|
||||
this.items.length = 0;
|
||||
if (this.defaultItems) {
|
||||
this.items.push(...this.defaultItems.map(item => new MenuItemModel(item)));
|
||||
this.items.push(...this.defaultItems.map((item) => new MenuItemModel(item)));
|
||||
}
|
||||
this.emit('change-items');
|
||||
}
|
||||
|
||||
removeByFile(file) {
|
||||
const items = this.items;
|
||||
items.find(item => {
|
||||
items.find((item) => {
|
||||
if (item.file === file || item.file === file) {
|
||||
items.remove(item);
|
||||
return true;
|
||||
|
|
|
@ -8,7 +8,7 @@ class RuntimeDataModel extends Model {
|
|||
}
|
||||
|
||||
load() {
|
||||
return SettingsStore.load('runtime-data').then(data => {
|
||||
return SettingsStore.load('runtime-data').then((data) => {
|
||||
if (data) {
|
||||
this.set(data, { silent: true });
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import { SettingsStore } from 'comp/settings/settings-store';
|
|||
|
||||
class UpdateModel extends Model {
|
||||
load() {
|
||||
return SettingsStore.load('update-info').then(data => {
|
||||
return SettingsStore.load('update-info').then((data) => {
|
||||
if (data) {
|
||||
try {
|
||||
for (const [key, val] of Object.entries(data)) {
|
||||
|
|
|
@ -19,7 +19,7 @@ const PluginGallery = {
|
|||
this.loading = true;
|
||||
this.loadError = false;
|
||||
const ts = this.logger.ts();
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve) => {
|
||||
this.logger.debug('Loading plugins...');
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', Links.Plugins + '/plugins.json');
|
||||
|
@ -34,14 +34,14 @@ const PluginGallery = {
|
|||
resolve();
|
||||
});
|
||||
})
|
||||
.then(data => {
|
||||
.then((data) => {
|
||||
this.loading = false;
|
||||
if (!data) {
|
||||
this.loadError = true;
|
||||
Events.emit('plugin-gallery-load-complete');
|
||||
return;
|
||||
}
|
||||
return this.verifySignature(data).then(gallery => {
|
||||
return this.verifySignature(data).then((gallery) => {
|
||||
this.loadError = !gallery;
|
||||
if (gallery) {
|
||||
this.logger.debug(
|
||||
|
@ -55,7 +55,7 @@ const PluginGallery = {
|
|||
return gallery;
|
||||
});
|
||||
})
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
this.loadError = true;
|
||||
this.logger.error('Error loading plugin gallery', e);
|
||||
Events.emit('plugin-gallery-load-complete');
|
||||
|
@ -68,22 +68,22 @@ const PluginGallery = {
|
|||
kdbxweb.ByteUtils.stringToBytes(dataToVerify),
|
||||
gallery.signature
|
||||
)
|
||||
.then(isValid => {
|
||||
.then((isValid) => {
|
||||
if (isValid) {
|
||||
return gallery;
|
||||
}
|
||||
this.logger.error('JSON signature invalid');
|
||||
})
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
this.logger.error('Error verifying plugins signature', e);
|
||||
});
|
||||
},
|
||||
|
||||
getCachedGallery() {
|
||||
const ts = this.logger.ts();
|
||||
return SettingsStore.load('plugin-gallery').then(data => {
|
||||
return SettingsStore.load('plugin-gallery').then((data) => {
|
||||
if (data) {
|
||||
return this.verifySignature(data).then(gallery => {
|
||||
return this.verifySignature(data).then((gallery) => {
|
||||
this.logger.debug(`Loaded cached plugin gallery`, this.logger.ts(ts));
|
||||
return gallery;
|
||||
});
|
||||
|
|
|
@ -21,7 +21,7 @@ class PluginManager extends Model {
|
|||
|
||||
init() {
|
||||
const ts = logger.ts();
|
||||
return SettingsStore.load('plugins').then(state => {
|
||||
return SettingsStore.load('plugins').then((state) => {
|
||||
if (!state) {
|
||||
return;
|
||||
}
|
||||
|
@ -32,10 +32,10 @@ class PluginManager extends Model {
|
|||
if (!state || !state.plugins || !state.plugins.length) {
|
||||
return;
|
||||
}
|
||||
return PluginGallery.getCachedGallery().then(gallery => {
|
||||
const promises = state.plugins.map(plugin => this.loadPlugin(plugin, gallery));
|
||||
return Promise.all(promises).then(loadedPlugins => {
|
||||
this.plugins.push(...loadedPlugins.filter(plugin => plugin));
|
||||
return PluginGallery.getCachedGallery().then((gallery) => {
|
||||
const promises = state.plugins.map((plugin) => this.loadPlugin(plugin, gallery));
|
||||
return Promise.all(promises).then((loadedPlugins) => {
|
||||
this.plugins.push(...loadedPlugins.filter((plugin) => plugin));
|
||||
logger.info(`Loaded ${this.plugins.length} plugins`, logger.ts(ts));
|
||||
});
|
||||
});
|
||||
|
@ -45,7 +45,7 @@ class PluginManager extends Model {
|
|||
install(url, expectedManifest, skipSignatureValidation) {
|
||||
this.emit('change');
|
||||
return Plugin.loadFromUrl(url, expectedManifest)
|
||||
.then(plugin => {
|
||||
.then((plugin) => {
|
||||
return this.uninstall(plugin.id).then(() => {
|
||||
if (skipSignatureValidation) {
|
||||
plugin.skipSignatureValidation = true;
|
||||
|
@ -57,14 +57,14 @@ class PluginManager extends Model {
|
|||
});
|
||||
});
|
||||
})
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
this.emit('change');
|
||||
throw e;
|
||||
});
|
||||
}
|
||||
|
||||
installIfNew(url, expectedManifest, skipSignatureValidation) {
|
||||
const plugin = this.plugins.find(p => p.url === url);
|
||||
const plugin = this.plugins.find((p) => p.url === url);
|
||||
if (plugin && plugin.status !== 'invalid') {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
@ -123,19 +123,19 @@ class PluginManager extends Model {
|
|||
const url = oldPlugin.url;
|
||||
this.emit('change');
|
||||
return Plugin.loadFromUrl(url)
|
||||
.then(newPlugin => {
|
||||
.then((newPlugin) => {
|
||||
return oldPlugin
|
||||
.update(newPlugin)
|
||||
.then(() => {
|
||||
this.emit('change');
|
||||
this.saveState();
|
||||
})
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
this.emit('change');
|
||||
throw e;
|
||||
});
|
||||
})
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
this.emit('change');
|
||||
throw e;
|
||||
});
|
||||
|
@ -152,7 +152,7 @@ class PluginManager extends Model {
|
|||
}
|
||||
|
||||
runAutoUpdate() {
|
||||
const queue = this.plugins.filter(p => p.autoUpdate).map(p => p.id);
|
||||
const queue = this.plugins.filter((p) => p.autoUpdate).map((p) => p.id);
|
||||
if (!queue.length) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
@ -172,9 +172,7 @@ class PluginManager extends Model {
|
|||
const updateNext = () => {
|
||||
const pluginId = queue.shift();
|
||||
if (pluginId) {
|
||||
return this.update(pluginId)
|
||||
.catch(noop)
|
||||
.then(updateNext);
|
||||
return this.update(pluginId).catch(noop).then(updateNext);
|
||||
}
|
||||
};
|
||||
return updateNext();
|
||||
|
@ -189,7 +187,7 @@ class PluginManager extends Model {
|
|||
let enabled = desc.enabled;
|
||||
if (enabled) {
|
||||
const galleryPlugin = gallery
|
||||
? gallery.plugins.find(pl => pl.manifest.name === desc.manifest.name)
|
||||
? gallery.plugins.find((pl) => pl.manifest.name === desc.manifest.name)
|
||||
: null;
|
||||
const expectedPublicKeys = galleryPlugin
|
||||
? [galleryPlugin.manifest.publicKey]
|
||||
|
@ -206,7 +204,7 @@ class PluginManager extends Model {
|
|||
SettingsStore.save('plugins', {
|
||||
autoUpdateAppVersion: this.autoUpdateAppVersion,
|
||||
autoUpdateDate: this.autoUpdateDate,
|
||||
plugins: this.plugins.map(plugin => ({
|
||||
plugins: this.plugins.map((plugin) => ({
|
||||
manifest: plugin.manifest,
|
||||
url: plugin.url,
|
||||
enabled: plugin.status === 'active',
|
||||
|
|
|
@ -64,7 +64,7 @@ class Plugin extends Model {
|
|||
.then(() => {
|
||||
this.installTime = this.logger.ts() - ts;
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
this.logger.error('Error installing plugin', err);
|
||||
this.set({
|
||||
status: PluginStatus.STATUS_ERROR,
|
||||
|
@ -166,7 +166,7 @@ class Plugin extends Model {
|
|||
);
|
||||
this.resources = {};
|
||||
const ts = this.logger.ts();
|
||||
const results = Object.keys(manifest.resources).map(res =>
|
||||
const results = Object.keys(manifest.resources).map((res) =>
|
||||
this.loadResource(res, local, manifest)
|
||||
);
|
||||
return Promise.all(results)
|
||||
|
@ -209,9 +209,9 @@ class Plugin extends Model {
|
|||
const url = this.url + this.getResourcePath(type) + '?v=' + manifest.version;
|
||||
res = httpGet(url, true);
|
||||
}
|
||||
return res.then(data => {
|
||||
return res.then((data) => {
|
||||
this.logger.debug('Resource data loaded', type, this.logger.ts(ts));
|
||||
return this.verifyResource(data, type).then(data => {
|
||||
return this.verifyResource(data, type).then((data) => {
|
||||
this.resources[type] = data;
|
||||
});
|
||||
});
|
||||
|
@ -222,7 +222,7 @@ class Plugin extends Model {
|
|||
const manifest = this.manifest;
|
||||
const signature = manifest.resources[type];
|
||||
return SignatureVerifier.verify(data, signature, manifest.publicKey)
|
||||
.then(valid => {
|
||||
.then((valid) => {
|
||||
if (valid) {
|
||||
this.logger.debug('Resource signature validated', type, this.logger.ts(ts));
|
||||
return data;
|
||||
|
@ -254,7 +254,7 @@ class Plugin extends Model {
|
|||
.then(() => {
|
||||
this.status = PluginStatus.STATUS_ACTIVE;
|
||||
})
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
this.logger.info('Install error', e);
|
||||
this.status = PluginStatus.STATUS_ERROR;
|
||||
return this.disable().then(() => {
|
||||
|
@ -268,7 +268,7 @@ class Plugin extends Model {
|
|||
for (const key of Object.keys(this.resources)) {
|
||||
resourceSavePromises.push(this.saveResource(key, this.resources[key]));
|
||||
}
|
||||
return Promise.all(resourceSavePromises).catch(e => {
|
||||
return Promise.all(resourceSavePromises).catch((e) => {
|
||||
this.logger.debug('Error saving plugin resources', e);
|
||||
return this.uninstall().then(() => {
|
||||
throw 'Error saving plugin resources';
|
||||
|
@ -279,7 +279,7 @@ class Plugin extends Model {
|
|||
saveResource(key, value) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const storageKey = this.getStorageResourcePath(key);
|
||||
io.save(storageKey, value, e => {
|
||||
io.save(storageKey, value, (e) => {
|
||||
if (e) {
|
||||
reject(e);
|
||||
} else {
|
||||
|
@ -298,7 +298,7 @@ class Plugin extends Model {
|
|||
}
|
||||
|
||||
deleteResource(key) {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve) => {
|
||||
const storageKey = this.getStorageResourcePath(key);
|
||||
io.remove(storageKey, () => resolve());
|
||||
});
|
||||
|
@ -567,7 +567,7 @@ class Plugin extends Model {
|
|||
});
|
||||
this.logger.info('Update complete', this.logger.ts(ts));
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
this.logger.error('Error updating plugin', err);
|
||||
if (prevStatus === PluginStatus.STATUS_ACTIVE) {
|
||||
this.logger.info('Activating previous version');
|
||||
|
@ -606,7 +606,7 @@ class Plugin extends Model {
|
|||
const settings = this.module.exports.getSettings();
|
||||
const settingsPrefix = this.getSettingPrefix();
|
||||
if (settings instanceof Array) {
|
||||
return settings.map(setting => {
|
||||
return settings.map((setting) => {
|
||||
setting = { ...setting };
|
||||
const value = AppSettingsModel[settingsPrefix + setting.name];
|
||||
if (value !== undefined) {
|
||||
|
@ -642,11 +642,11 @@ class Plugin extends Model {
|
|||
commonLogger.info('Installing plugin from url', url);
|
||||
const manifestUrl = url + 'manifest.json';
|
||||
return httpGet(manifestUrl)
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
commonLogger.error('Error loading plugin manifest', e);
|
||||
throw 'Error loading plugin manifest';
|
||||
})
|
||||
.then(manifest => {
|
||||
.then((manifest) => {
|
||||
try {
|
||||
manifest = JSON.parse(manifest);
|
||||
} catch (e) {
|
||||
|
|
|
@ -41,14 +41,14 @@ const ThemeVars = {
|
|||
const locals = [];
|
||||
while (replaced) {
|
||||
replaced = false;
|
||||
result = result.replace(/([\w\-]+)\([^()]+\)/, fnText => {
|
||||
result = result.replace(/([\w\-]+)\([^()]+\)/, (fnText) => {
|
||||
replaced = true;
|
||||
const [, name, argsStr] = fnText.match(/([\w\-]+)\((.*)\)/);
|
||||
const args = argsStr
|
||||
.trim()
|
||||
.split(/\s*,\s*/)
|
||||
.filter(arg => arg)
|
||||
.map(arg => this.resolveArg(arg, cssStyle, locals));
|
||||
.filter((arg) => arg)
|
||||
.map((arg) => this.resolveArg(arg, cssStyle, locals));
|
||||
locals.push(this.fn[name](...args));
|
||||
return 'L' + (locals.length - 1);
|
||||
});
|
||||
|
|
|
@ -85,7 +85,7 @@ EntryPresenter.prototype = {
|
|||
return this.updated;
|
||||
case 'attachments':
|
||||
return (
|
||||
this.entry.attachments.map(a => a.title).join(', ') ||
|
||||
this.entry.attachments.map((a) => a.title).join(', ') ||
|
||||
'(' + Locale.listNoAttachments + ')'
|
||||
);
|
||||
default:
|
||||
|
|
|
@ -236,12 +236,12 @@ class StorageDropbox extends StorageBase {
|
|||
_encodeJsonHttpHeader(json) {
|
||||
return json.replace(
|
||||
/[\u007f-\uffff]/g,
|
||||
c => '\\u' + ('000' + c.charCodeAt(0).toString(16)).slice(-4)
|
||||
(c) => '\\u' + ('000' + c.charCodeAt(0).toString(16)).slice(-4)
|
||||
);
|
||||
}
|
||||
|
||||
_apiCall(args) {
|
||||
this._oauthAuthorize(err => {
|
||||
this._oauthAuthorize((err) => {
|
||||
if (err) {
|
||||
return args.error(err);
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ class StorageDropbox extends StorageBase {
|
|||
this._apiCall({
|
||||
method: 'files/get_metadata',
|
||||
data: { path },
|
||||
success: stat => {
|
||||
success: (stat) => {
|
||||
if (stat['.tag'] === 'file') {
|
||||
stat = { rev: stat.rev };
|
||||
} else if (stat['.tag'] === 'folder') {
|
||||
|
@ -341,7 +341,7 @@ class StorageDropbox extends StorageBase {
|
|||
apiArg: arg,
|
||||
data,
|
||||
responseType: 'json',
|
||||
success: stat => {
|
||||
success: (stat) => {
|
||||
this.logger.debug('Saved', path, stat.rev, this.logger.ts(ts));
|
||||
callback(null, { rev: stat.rev });
|
||||
},
|
||||
|
@ -358,9 +358,9 @@ class StorageDropbox extends StorageBase {
|
|||
path: this._toFullPath(dir || ''),
|
||||
recursive: false
|
||||
},
|
||||
success: data => {
|
||||
success: (data) => {
|
||||
this.logger.debug('Listed', this.logger.ts(ts));
|
||||
const fileList = data.entries.map(f => ({
|
||||
const fileList = data.entries.map((f) => ({
|
||||
name: f.name,
|
||||
path: this._toRelPath(f.path_display),
|
||||
rev: f.rev,
|
||||
|
|
|
@ -19,7 +19,7 @@ class StorageFileCache extends StorageBase {
|
|||
|
||||
const path = Launcher.getUserDataPath('OfflineFiles');
|
||||
|
||||
const setPath = err => {
|
||||
const setPath = (err) => {
|
||||
this.path = err ? null : path;
|
||||
if (err) {
|
||||
this.logger.error('Error opening local offline storage', err);
|
||||
|
@ -27,7 +27,7 @@ class StorageFileCache extends StorageBase {
|
|||
return callback && callback(err);
|
||||
};
|
||||
|
||||
Launcher.fileExists(path, exists => {
|
||||
Launcher.fileExists(path, (exists) => {
|
||||
if (exists) {
|
||||
setPath();
|
||||
} else {
|
||||
|
@ -38,12 +38,12 @@ class StorageFileCache extends StorageBase {
|
|||
|
||||
save(id, opts, data, callback) {
|
||||
this.logger.debug('Save', id);
|
||||
this.initFs(err => {
|
||||
this.initFs((err) => {
|
||||
if (err) {
|
||||
return callback && callback(err);
|
||||
}
|
||||
const ts = this.logger.ts();
|
||||
Launcher.writeFile(this.getPath(id), data, err => {
|
||||
Launcher.writeFile(this.getPath(id), data, (err) => {
|
||||
if (err) {
|
||||
this.logger.error('Error saving to cache', id, err);
|
||||
return callback && callback(err);
|
||||
|
@ -58,7 +58,7 @@ class StorageFileCache extends StorageBase {
|
|||
|
||||
load(id, opts, callback) {
|
||||
this.logger.debug('Load', id);
|
||||
this.initFs(err => {
|
||||
this.initFs((err) => {
|
||||
if (err) {
|
||||
return callback && callback(null, err);
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class StorageFileCache extends StorageBase {
|
|||
|
||||
remove(id, opts, callback) {
|
||||
this.logger.debug('Remove', id);
|
||||
this.initFs(err => {
|
||||
this.initFs((err) => {
|
||||
if (err) {
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
@ -86,9 +86,9 @@ class StorageFileCache extends StorageBase {
|
|||
const ts = this.logger.ts();
|
||||
const path = this.getPath(id);
|
||||
|
||||
Launcher.fileExists(path, exists => {
|
||||
Launcher.fileExists(path, (exists) => {
|
||||
if (exists) {
|
||||
Launcher.deleteFile(path, err => {
|
||||
Launcher.deleteFile(path, (err) => {
|
||||
if (err) {
|
||||
this.logger.error('Error removing from cache', id, err);
|
||||
} else {
|
||||
|
|
|
@ -14,7 +14,7 @@ class StorageFile extends StorageBase {
|
|||
this.logger.debug('Load', path);
|
||||
const ts = this.logger.ts();
|
||||
|
||||
const onError = e => {
|
||||
const onError = (e) => {
|
||||
this.logger.error('Error reading local file', path, e);
|
||||
if (callback) {
|
||||
callback(e, null);
|
||||
|
@ -62,7 +62,7 @@ class StorageFile extends StorageBase {
|
|||
this.logger.debug('Save', path, rev);
|
||||
const ts = this.logger.ts();
|
||||
|
||||
const onError = e => {
|
||||
const onError = (e) => {
|
||||
if (Object.prototype.hasOwnProperty.call(e, 'code') && e.code === 'EISDIR') {
|
||||
e.isDir = true;
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ class StorageFile extends StorageBase {
|
|||
};
|
||||
|
||||
const write = () => {
|
||||
Launcher.writeFile(path, data, err => {
|
||||
Launcher.writeFile(path, data, (err) => {
|
||||
if (err) {
|
||||
return onError(err);
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ class StorageFile extends StorageBase {
|
|||
this.logger.debug('Make dir', path);
|
||||
const ts = this.logger.ts();
|
||||
|
||||
Launcher.mkdir(path, err => {
|
||||
Launcher.mkdir(path, (err) => {
|
||||
if (err) {
|
||||
this.logger.error('Error making local dir', path, err);
|
||||
if (callback) {
|
||||
|
@ -158,7 +158,7 @@ class StorageFile extends StorageBase {
|
|||
const names = Launcher.parsePath(path);
|
||||
const watcher = fileWatchers[names.dir];
|
||||
if (watcher) {
|
||||
const ix = watcher.callbacks.findIndex(cb => cb.file === names.file);
|
||||
const ix = watcher.callbacks.findIndex((cb) => cb.file === names.file);
|
||||
if (ix >= 0) {
|
||||
watcher.callbacks.splice(ix, 1);
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ class StorageFile extends StorageBase {
|
|||
fsWatcherChange(dirname, evt, fileName) {
|
||||
const watcher = fileWatchers[dirname];
|
||||
if (watcher) {
|
||||
watcher.callbacks.forEach(cb => {
|
||||
watcher.callbacks.forEach((cb) => {
|
||||
if (cb.file === fileName && typeof cb.callback === 'function') {
|
||||
this.logger.debug('File changed', dirname, evt, fileName);
|
||||
cb.callback();
|
||||
|
|
|
@ -35,11 +35,11 @@ class StorageGDrive extends StorageBase {
|
|||
this._xhr({
|
||||
url,
|
||||
responseType: 'arraybuffer',
|
||||
success: response => {
|
||||
success: (response) => {
|
||||
this.logger.debug('Loaded', path, stat.rev, this.logger.ts(ts));
|
||||
return callback && callback(null, response, { rev: stat.rev });
|
||||
},
|
||||
error: err => {
|
||||
error: (err) => {
|
||||
this.logger.error('Load error', path, err, this.logger.ts(ts));
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class StorageGDrive extends StorageBase {
|
|||
if (path.lastIndexOf(NewFileIdPrefix, 0) === 0) {
|
||||
return callback && callback({ notFound: true });
|
||||
}
|
||||
this._oauthAuthorize(err => {
|
||||
this._oauthAuthorize((err) => {
|
||||
if (err) {
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
@ -61,12 +61,12 @@ class StorageGDrive extends StorageBase {
|
|||
this._xhr({
|
||||
url,
|
||||
responseType: 'json',
|
||||
success: response => {
|
||||
success: (response) => {
|
||||
const rev = response.headRevisionId;
|
||||
this.logger.debug('Stated', path, rev, this.logger.ts(ts));
|
||||
return callback && callback(null, { rev });
|
||||
},
|
||||
error: err => {
|
||||
error: (err) => {
|
||||
this.logger.error('Stat error', this.logger.ts(ts), err);
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ class StorageGDrive extends StorageBase {
|
|||
}
|
||||
|
||||
save(path, opts, data, callback, rev) {
|
||||
this._oauthAuthorize(err => {
|
||||
this._oauthAuthorize((err) => {
|
||||
if (err) {
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ class StorageGDrive extends StorageBase {
|
|||
data,
|
||||
dataType,
|
||||
dataIsMultipart,
|
||||
success: response => {
|
||||
success: (response) => {
|
||||
this.logger.debug('Saved', path, this.logger.ts(ts));
|
||||
const newRev = response.headRevisionId;
|
||||
if (!newRev) {
|
||||
|
@ -145,7 +145,7 @@ class StorageGDrive extends StorageBase {
|
|||
callback(null, { rev: newRev, path: isNew ? response.id : null })
|
||||
);
|
||||
},
|
||||
error: err => {
|
||||
error: (err) => {
|
||||
this.logger.error('Save error', path, err, this.logger.ts(ts));
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ class StorageGDrive extends StorageBase {
|
|||
}
|
||||
|
||||
list(dir, callback) {
|
||||
this._oauthAuthorize(err => {
|
||||
this._oauthAuthorize((err) => {
|
||||
if (err) {
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
@ -179,13 +179,13 @@ class StorageGDrive extends StorageBase {
|
|||
this._xhr({
|
||||
url,
|
||||
responseType: 'json',
|
||||
success: response => {
|
||||
success: (response) => {
|
||||
if (!response) {
|
||||
this.logger.error('List error', this.logger.ts(ts));
|
||||
return callback && callback('list error');
|
||||
}
|
||||
this.logger.debug('Listed', this.logger.ts(ts));
|
||||
const fileList = response.files.map(f => ({
|
||||
const fileList = response.files.map((f) => ({
|
||||
name: f.name,
|
||||
path: f.id,
|
||||
rev: f.headRevisionId,
|
||||
|
@ -201,7 +201,7 @@ class StorageGDrive extends StorageBase {
|
|||
}
|
||||
return callback && callback(null, fileList);
|
||||
},
|
||||
error: err => {
|
||||
error: (err) => {
|
||||
this.logger.error('List error', this.logger.ts(ts), err);
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ class StorageGDrive extends StorageBase {
|
|||
this.logger.debug('Removed', path, this.logger.ts(ts));
|
||||
return callback && callback();
|
||||
},
|
||||
error: err => {
|
||||
error: (err) => {
|
||||
this.logger.error('Remove error', path, err, this.logger.ts(ts));
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ class StorageOneDrive extends StorageBase {
|
|||
}
|
||||
|
||||
load(path, opts, callback) {
|
||||
this._oauthAuthorize(err => {
|
||||
this._oauthAuthorize((err) => {
|
||||
if (err) {
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class StorageOneDrive extends StorageBase {
|
|||
this._xhr({
|
||||
url,
|
||||
responseType: 'json',
|
||||
success: response => {
|
||||
success: (response) => {
|
||||
const downloadUrl = response['@microsoft.graph.downloadUrl'];
|
||||
let rev = response.eTag;
|
||||
if (!downloadUrl || !response.eTag) {
|
||||
|
@ -49,13 +49,13 @@ class StorageOneDrive extends StorageBase {
|
|||
this.logger.debug('Loaded', path, rev, this.logger.ts(ts));
|
||||
return callback && callback(null, response, { rev });
|
||||
},
|
||||
error: err => {
|
||||
error: (err) => {
|
||||
this.logger.error('Load error', path, err, this.logger.ts(ts));
|
||||
return callback && callback(err);
|
||||
}
|
||||
});
|
||||
},
|
||||
error: err => {
|
||||
error: (err) => {
|
||||
this.logger.error('Load error', path, err, this.logger.ts(ts));
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class StorageOneDrive extends StorageBase {
|
|||
}
|
||||
|
||||
stat(path, opts, callback) {
|
||||
this._oauthAuthorize(err => {
|
||||
this._oauthAuthorize((err) => {
|
||||
if (err) {
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ class StorageOneDrive extends StorageBase {
|
|||
this._xhr({
|
||||
url,
|
||||
responseType: 'json',
|
||||
success: response => {
|
||||
success: (response) => {
|
||||
const rev = response.eTag;
|
||||
if (!rev) {
|
||||
this.logger.error('Stat error', path, 'no eTag', this.logger.ts(ts));
|
||||
|
@ -96,7 +96,7 @@ class StorageOneDrive extends StorageBase {
|
|||
}
|
||||
|
||||
save(path, opts, data, callback, rev) {
|
||||
this._oauthAuthorize(err => {
|
||||
this._oauthAuthorize((err) => {
|
||||
if (err) {
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ class StorageOneDrive extends StorageBase {
|
|||
this.logger.debug('Saved', path, rev, this.logger.ts(ts));
|
||||
return callback && callback(null, { rev });
|
||||
},
|
||||
error: err => {
|
||||
error: (err) => {
|
||||
this.logger.error('Save error', path, err, this.logger.ts(ts));
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ class StorageOneDrive extends StorageBase {
|
|||
}
|
||||
|
||||
list(dir, callback) {
|
||||
this._oauthAuthorize(err => {
|
||||
this._oauthAuthorize((err) => {
|
||||
if (err) {
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
@ -142,15 +142,15 @@ class StorageOneDrive extends StorageBase {
|
|||
this._xhr({
|
||||
url,
|
||||
responseType: 'json',
|
||||
success: response => {
|
||||
success: (response) => {
|
||||
if (!response || !response.value) {
|
||||
this.logger.error('List error', this.logger.ts(ts), response);
|
||||
return callback && callback('list error');
|
||||
}
|
||||
this.logger.debug('Listed', this.logger.ts(ts));
|
||||
const fileList = response.value
|
||||
.filter(f => f.name)
|
||||
.map(f => ({
|
||||
.filter((f) => f.name)
|
||||
.map((f) => ({
|
||||
name: f.name,
|
||||
path: f.parentReference.path + '/' + f.name,
|
||||
rev: f.eTag,
|
||||
|
@ -158,7 +158,7 @@ class StorageOneDrive extends StorageBase {
|
|||
}));
|
||||
return callback && callback(null, fileList);
|
||||
},
|
||||
error: err => {
|
||||
error: (err) => {
|
||||
this.logger.error('List error', this.logger.ts(ts), err);
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ class StorageOneDrive extends StorageBase {
|
|||
this.logger.debug('Removed', path, this.logger.ts(ts));
|
||||
return callback && callback();
|
||||
},
|
||||
error: err => {
|
||||
error: (err) => {
|
||||
this.logger.error('Remove error', path, err, this.logger.ts(ts));
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ class StorageOneDrive extends StorageBase {
|
|||
}
|
||||
|
||||
mkdir(path, callback) {
|
||||
this._oauthAuthorize(err => {
|
||||
this._oauthAuthorize((err) => {
|
||||
if (err) {
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ class StorageOneDrive extends StorageBase {
|
|||
this.logger.debug('Made dir', path, this.logger.ts(ts));
|
||||
return callback && callback();
|
||||
},
|
||||
error: err => {
|
||||
error: (err) => {
|
||||
this.logger.error('Make dir error', path, err, this.logger.ts(ts));
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ class StorageWebDav extends StorageBase {
|
|||
callback = null;
|
||||
}
|
||||
};
|
||||
const tmpPath = path.replace(/[^\/]+$/, m => '.' + m) + '.' + Date.now();
|
||||
const tmpPath = path.replace(/[^\/]+$/, (m) => '.' + m) + '.' + Date.now();
|
||||
const saveOpts = {
|
||||
path,
|
||||
user: opts ? opts.user : null,
|
||||
|
@ -134,7 +134,7 @@ class StorageWebDav extends StorageBase {
|
|||
data,
|
||||
nostat: true
|
||||
},
|
||||
err => {
|
||||
(err) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ class StorageWebDav extends StorageBase {
|
|||
'Overwrite': 'T'
|
||||
}
|
||||
},
|
||||
err => {
|
||||
(err) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ class StorageWebDav extends StorageBase {
|
|||
data,
|
||||
nostat: true
|
||||
},
|
||||
err => {
|
||||
(err) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
|
|
@ -13,19 +13,19 @@ Object.assign(IoBrowserCache.prototype, {
|
|||
}
|
||||
try {
|
||||
const req = idb.open(this.cacheName);
|
||||
req.onerror = e => {
|
||||
req.onerror = (e) => {
|
||||
this.logger.error('Error opening indexed db', e);
|
||||
if (callback) {
|
||||
callback(e);
|
||||
}
|
||||
};
|
||||
req.onsuccess = e => {
|
||||
req.onsuccess = (e) => {
|
||||
this.db = e.target.result;
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
req.onupgradeneeded = e => {
|
||||
req.onupgradeneeded = (e) => {
|
||||
const db = e.target.result;
|
||||
db.createObjectStore('files');
|
||||
};
|
||||
|
@ -39,7 +39,7 @@ Object.assign(IoBrowserCache.prototype, {
|
|||
|
||||
save(id, data, callback) {
|
||||
this.logger.debug('Save', id);
|
||||
this.initDb(err => {
|
||||
this.initDb((err) => {
|
||||
if (err) {
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
@ -72,16 +72,13 @@ Object.assign(IoBrowserCache.prototype, {
|
|||
|
||||
load(id, callback) {
|
||||
this.logger.debug('Load', id);
|
||||
this.initDb(err => {
|
||||
this.initDb((err) => {
|
||||
if (err) {
|
||||
return callback && callback(err, null);
|
||||
}
|
||||
try {
|
||||
const ts = this.logger.ts();
|
||||
const req = this.db
|
||||
.transaction(['files'], 'readonly')
|
||||
.objectStore('files')
|
||||
.get(id);
|
||||
const req = this.db.transaction(['files'], 'readonly').objectStore('files').get(id);
|
||||
req.onsuccess = () => {
|
||||
this.logger.debug('Loaded', id, this.logger.ts(ts));
|
||||
if (callback) {
|
||||
|
@ -105,7 +102,7 @@ Object.assign(IoBrowserCache.prototype, {
|
|||
|
||||
remove(id, callback) {
|
||||
this.logger.debug('Remove', id);
|
||||
this.initDb(err => {
|
||||
this.initDb((err) => {
|
||||
if (err) {
|
||||
return callback && callback(err);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ Object.assign(IoFileCache.prototype, {
|
|||
return callback();
|
||||
}
|
||||
const basePath = Launcher.getUserDataPath(this.cacheName);
|
||||
Launcher.mkdir(basePath, err => {
|
||||
Launcher.mkdir(basePath, (err) => {
|
||||
if (err) {
|
||||
this.logger.error('Error creating plugin folder');
|
||||
} else {
|
||||
|
@ -27,14 +27,14 @@ Object.assign(IoFileCache.prototype, {
|
|||
},
|
||||
|
||||
save(id, data, callback) {
|
||||
this.initFs(err => {
|
||||
this.initFs((err) => {
|
||||
if (err) {
|
||||
return callback && callback(err, null);
|
||||
}
|
||||
this.logger.debug('Save', id);
|
||||
const ts = this.logger.ts();
|
||||
const path = this.resolvePath(id);
|
||||
Launcher.writeFile(path, data, err => {
|
||||
Launcher.writeFile(path, data, (err) => {
|
||||
if (err) {
|
||||
this.logger.error('Error saving file', id, err);
|
||||
if (callback) {
|
||||
|
@ -51,7 +51,7 @@ Object.assign(IoFileCache.prototype, {
|
|||
},
|
||||
|
||||
load(id, callback) {
|
||||
this.initFs(err => {
|
||||
this.initFs((err) => {
|
||||
if (err) {
|
||||
return callback && callback(err, null);
|
||||
}
|
||||
|
@ -75,14 +75,14 @@ Object.assign(IoFileCache.prototype, {
|
|||
},
|
||||
|
||||
remove(id, callback) {
|
||||
this.initFs(err => {
|
||||
this.initFs((err) => {
|
||||
if (err) {
|
||||
return callback && callback(err, null);
|
||||
}
|
||||
this.logger.debug('Remove', id);
|
||||
const ts = this.logger.ts();
|
||||
const path = this.resolvePath(id);
|
||||
Launcher.deleteFile(path, err => {
|
||||
Launcher.deleteFile(path, (err) => {
|
||||
if (err) {
|
||||
this.logger.error('Error removing file', id, err);
|
||||
if (callback) {
|
||||
|
|
|
@ -11,7 +11,7 @@ function createOAuthSession() {
|
|||
const codeVerifierBytes = kdbxweb.ByteUtils.arrayToBuffer(
|
||||
kdbxweb.ByteUtils.stringToBytes(codeVerifier)
|
||||
);
|
||||
kdbxweb.CryptoEngine.sha256(codeVerifierBytes).then(hash => {
|
||||
kdbxweb.CryptoEngine.sha256(codeVerifierBytes).then((hash) => {
|
||||
const codeChallenge = kdbxweb.ByteUtils.bytesToBase64(hash)
|
||||
.replace(/\+/g, '-')
|
||||
.replace(/\//g, '_')
|
||||
|
|
|
@ -69,14 +69,14 @@ class StorageBase {
|
|||
'Authorization': 'Bearer ' + this._oauthToken.accessToken
|
||||
};
|
||||
}
|
||||
this._httpRequest(config, response => {
|
||||
this._httpRequest(config, (response) => {
|
||||
this.logger.info('HTTP response', response.status);
|
||||
const statuses = config.statuses || [200];
|
||||
if (statuses.indexOf(response.status) >= 0) {
|
||||
return config.success && config.success(response.response, response);
|
||||
}
|
||||
if (response.status === 401 && this._oauthToken) {
|
||||
this._oauthGetNewToken(err => {
|
||||
this._oauthGetNewToken((err) => {
|
||||
if (err) {
|
||||
return config.error && config.error('unauthorized', response);
|
||||
} else {
|
||||
|
@ -112,7 +112,7 @@ class StorageBase {
|
|||
onLoad({
|
||||
status: xhr.status,
|
||||
response: xhr.response,
|
||||
getResponseHeader: name => xhr.getResponseHeader(name)
|
||||
getResponseHeader: (name) => xhr.getResponseHeader(name)
|
||||
});
|
||||
});
|
||||
xhr.addEventListener('error', () => {
|
||||
|
@ -152,7 +152,7 @@ class StorageBase {
|
|||
let data;
|
||||
if (config.data) {
|
||||
if (config.dataIsMultipart) {
|
||||
data = Buffer.concat(config.data.map(chunk => Buffer.from(chunk)));
|
||||
data = Buffer.concat(config.data.map((chunk) => Buffer.from(chunk)));
|
||||
} else {
|
||||
data = Buffer.from(config.data);
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ class StorageBase {
|
|||
closed = true;
|
||||
});
|
||||
|
||||
req.on('response', res => {
|
||||
req.on('response', (res) => {
|
||||
const chunks = [];
|
||||
const onClose = () => {
|
||||
this.logger.debug(
|
||||
|
@ -194,10 +194,10 @@ class StorageBase {
|
|||
onLoad({
|
||||
status: res.statusCode,
|
||||
response,
|
||||
getResponseHeader: name => res.headers[name.toLowerCase()]
|
||||
getResponseHeader: (name) => res.headers[name.toLowerCase()]
|
||||
});
|
||||
};
|
||||
res.on('data', chunk => {
|
||||
res.on('data', (chunk) => {
|
||||
chunks.push(chunk);
|
||||
if (closed && !res.readable) {
|
||||
// sometimes 'close' event arrives faster in Electron
|
||||
|
@ -207,7 +207,7 @@ class StorageBase {
|
|||
// in Electron it's not res.on('end'), like in node.js, which is a bit weird
|
||||
req.on('close', onClose);
|
||||
});
|
||||
req.on('error', e => {
|
||||
req.on('error', (e) => {
|
||||
this.logger.error('HTTP error', opts.method, config.url, e);
|
||||
return config.error && config.error('network error', {});
|
||||
});
|
||||
|
@ -250,7 +250,7 @@ class StorageBase {
|
|||
location: 'yes'
|
||||
};
|
||||
settings = Object.keys(settings)
|
||||
.map(key => key + '=' + settings[key])
|
||||
.map((key) => key + '=' + settings[key])
|
||||
.join(',');
|
||||
|
||||
return window.open(url, title, settings, extras);
|
||||
|
@ -310,8 +310,8 @@ class StorageBase {
|
|||
Launcher.openLink(url);
|
||||
callback('browser-auth-started');
|
||||
});
|
||||
listener.on('error', err => callback(err));
|
||||
listener.on('result', result => this._oauthCodeReceived(result, session));
|
||||
listener.on('error', (err) => callback(err));
|
||||
listener.on('result', (result) => this._oauthCodeReceived(result, session));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -329,7 +329,7 @@ class StorageBase {
|
|||
callback('OAuth: popup closed');
|
||||
};
|
||||
|
||||
const windowMessage = e => {
|
||||
const windowMessage = (e) => {
|
||||
if (e.origin !== location.origin) {
|
||||
return;
|
||||
}
|
||||
|
@ -462,7 +462,7 @@ class StorageBase {
|
|||
...pkceParams
|
||||
}),
|
||||
dataType: 'application/x-www-form-urlencoded',
|
||||
success: response => {
|
||||
success: (response) => {
|
||||
this.logger.debug('OAuth code exchanged', response);
|
||||
const token = this._oauthProcessReturn(response);
|
||||
if (token && token.error) {
|
||||
|
@ -470,7 +470,7 @@ class StorageBase {
|
|||
}
|
||||
callback?.();
|
||||
},
|
||||
error: err => {
|
||||
error: (err) => {
|
||||
this.logger.error('Error exchanging OAuth code', err);
|
||||
callback?.('OAuth code exchange error: ' + err);
|
||||
}
|
||||
|
@ -493,7 +493,7 @@ class StorageBase {
|
|||
'refresh_token': refreshToken
|
||||
}),
|
||||
dataType: 'application/x-www-form-urlencoded',
|
||||
success: response => {
|
||||
success: (response) => {
|
||||
this.logger.debug('Refresh token exchanged');
|
||||
this._oauthProcessReturn({
|
||||
'refresh_token': refreshToken,
|
||||
|
|
|
@ -15,7 +15,7 @@ const StorageOAuthListener = {
|
|||
}
|
||||
|
||||
const listener = {};
|
||||
Object.keys(EventEmitter.prototype).forEach(key => {
|
||||
Object.keys(EventEmitter.prototype).forEach((key) => {
|
||||
listener[key] = EventEmitter.prototype[key];
|
||||
});
|
||||
|
||||
|
@ -38,7 +38,7 @@ const StorageOAuthListener = {
|
|||
logger.info(`Starting OAuth listener on port ${port}...`);
|
||||
server.listen(port);
|
||||
|
||||
server.on('error', err => {
|
||||
server.on('error', (err) => {
|
||||
logger.error('Failed to start OAuth listener', err);
|
||||
listener.emit('error', 'Failed to start OAuth listener: ' + err);
|
||||
server.close();
|
||||
|
|
|
@ -76,17 +76,17 @@ Otp.prototype.hmac = function(data, callback) {
|
|||
const algo = { name: 'HMAC', hash: { name: this.algorithm.replace('SHA', 'SHA-') } };
|
||||
subtle
|
||||
.importKey('raw', this.key, algo, false, ['sign'])
|
||||
.then(key => {
|
||||
.then((key) => {
|
||||
subtle
|
||||
.sign(algo, key, data)
|
||||
.then(sig => {
|
||||
.then((sig) => {
|
||||
callback(sig);
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
callback(null, err);
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
callback(null, err);
|
||||
});
|
||||
};
|
||||
|
@ -149,7 +149,7 @@ Otp.parseUrl = function(url) {
|
|||
}
|
||||
}
|
||||
params.type = match[1].toLowerCase();
|
||||
match[3].split('&').forEach(part => {
|
||||
match[3].split('&').forEach((part) => {
|
||||
const parts = part.split('=', 2);
|
||||
params[parts[0].toLowerCase()] = decodeURIComponent(parts[1]);
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@ const SignatureVerifier = {
|
|||
verify(data, signature, pk) {
|
||||
if (!pk) {
|
||||
const pks = this.getPublicKeys();
|
||||
return this.verify(data, signature, pks[0]).then(isValid => {
|
||||
return this.verify(data, signature, pks[0]).then((isValid) => {
|
||||
if (isValid || !pks[1]) {
|
||||
return isValid;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ const SignatureVerifier = {
|
|||
pk = kdbxweb.ByteUtils.base64ToBytes(pk);
|
||||
subtle
|
||||
.importKey(keyFormat, pk, algo, false, ['verify'])
|
||||
.then(cryptoKey => {
|
||||
.then((cryptoKey) => {
|
||||
try {
|
||||
subtle
|
||||
.verify(
|
||||
|
@ -38,10 +38,10 @@ const SignatureVerifier = {
|
|||
kdbxweb.ByteUtils.arrayToBuffer(signature),
|
||||
kdbxweb.ByteUtils.arrayToBuffer(data)
|
||||
)
|
||||
.then(isValid => {
|
||||
.then((isValid) => {
|
||||
resolve(isValid);
|
||||
})
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
this.logger.error('Verify error', e);
|
||||
reject(e);
|
||||
});
|
||||
|
@ -50,7 +50,7 @@ const SignatureVerifier = {
|
|||
reject(e);
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
this.logger.error('ImportKey error', e);
|
||||
reject(e);
|
||||
});
|
||||
|
@ -63,7 +63,7 @@ const SignatureVerifier = {
|
|||
|
||||
getPublicKeys() {
|
||||
if (!this.publicKeys) {
|
||||
this.publicKeys = [publicKeyData, publicKeyDataNew].map(pk =>
|
||||
this.publicKeys = [publicKeyData, publicKeyDataNew].map((pk) =>
|
||||
pk.match(/-+BEGIN PUBLIC KEY-+([\s\S]+?)-+END PUBLIC KEY-+/)[1].replace(/\s+/g, '')
|
||||
);
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ class EntrySearch {
|
|||
let matches = false;
|
||||
if (adv.other || adv.protect) {
|
||||
const fieldNames = Object.keys(fields);
|
||||
matches = fieldNames.some(field => {
|
||||
matches = fieldNames.some((field) => {
|
||||
if (BuiltInFields.indexOf(field) >= 0) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ const PasswordPresenter = {
|
|||
return '';
|
||||
}
|
||||
let result = '';
|
||||
value.forEachChar(ch => {
|
||||
value.forEachChar((ch) => {
|
||||
result += ch === 10 ? '\n' : '•';
|
||||
});
|
||||
return result;
|
||||
|
@ -33,7 +33,7 @@ const PasswordPresenter = {
|
|||
const gen = new RandomNameGenerator();
|
||||
|
||||
let ix = 0;
|
||||
value.forEachChar(char => {
|
||||
value.forEachChar((char) => {
|
||||
const charHtml = charCodeToHtml(char);
|
||||
items.push({ html: charHtml, order: ix });
|
||||
|
||||
|
|
|
@ -24,11 +24,11 @@ const StringFormat = {
|
|||
},
|
||||
|
||||
camelCase(str) {
|
||||
return str.replace(this.camelCaseRegex, match => match[1].toUpperCase());
|
||||
return str.replace(this.camelCaseRegex, (match) => match[1].toUpperCase());
|
||||
},
|
||||
|
||||
pascalCase(str) {
|
||||
return this.capFirst(str.replace(this.camelCaseRegex, match => match[1].toUpperCase()));
|
||||
return this.capFirst(str.replace(this.camelCaseRegex, (match) => match[1].toUpperCase()));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ const PasswordGenerator = {
|
|||
return this.generatePronounceable(opts);
|
||||
}
|
||||
const ranges = Object.keys(CharRanges)
|
||||
.filter(r => opts[r])
|
||||
.map(r => CharRanges[r]);
|
||||
.filter((r) => opts[r])
|
||||
.map((r) => CharRanges[r]);
|
||||
if (opts.include && opts.include.length) {
|
||||
ranges.push(opts.include);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ const PasswordGenerator = {
|
|||
let length = 0;
|
||||
if (password) {
|
||||
const charRanges = CharRanges;
|
||||
password.forEachChar(ch => {
|
||||
password.forEachChar((ch) => {
|
||||
length++;
|
||||
ch = String.fromCharCode(ch);
|
||||
for (const [range, chars] of Object.entries(charRanges)) {
|
||||
|
|
|
@ -13,9 +13,9 @@ const KdbxwebInit = {
|
|||
|
||||
argon2(password, salt, memory, iterations, length, parallelism, type, version) {
|
||||
const args = { password, salt, memory, iterations, length, parallelism, type, version };
|
||||
return this.loadRuntime(memory).then(runtime => {
|
||||
return this.loadRuntime(memory).then((runtime) => {
|
||||
const ts = logger.ts();
|
||||
return runtime.hash(args).then(hash => {
|
||||
return runtime.hash(args).then((hash) => {
|
||||
logger.debug('Hash computed', logger.ts(ts));
|
||||
return hash;
|
||||
});
|
||||
|
@ -108,7 +108,7 @@ const KdbxwebInit = {
|
|||
const blob = new Blob([script], { type: 'application/javascript' });
|
||||
const objectUrl = URL.createObjectURL(blob);
|
||||
const worker = new Worker(objectUrl);
|
||||
const onMessage = e => {
|
||||
const onMessage = (e) => {
|
||||
switch (e.data.op) {
|
||||
case 'log':
|
||||
logger.debug(...e.data.args);
|
||||
|
@ -125,7 +125,7 @@ const KdbxwebInit = {
|
|||
hash(args) {
|
||||
return new Promise((resolve, reject) => {
|
||||
worker.postMessage(args);
|
||||
const onHashMessage = e => {
|
||||
const onHashMessage = (e) => {
|
||||
worker.removeEventListener(
|
||||
'message',
|
||||
onHashMessage
|
||||
|
@ -164,7 +164,7 @@ const KdbxwebInit = {
|
|||
});
|
||||
global.Module = {
|
||||
wasmJSMethod: 'native-wasm',
|
||||
wasmBinary: Uint8Array.from(atob(wasmBinaryBase64), c => c.charCodeAt(0)),
|
||||
wasmBinary: Uint8Array.from(atob(wasmBinaryBase64), (c) => c.charCodeAt(0)),
|
||||
print(...args) {
|
||||
logger.debug(...args);
|
||||
},
|
||||
|
@ -175,7 +175,7 @@ const KdbxwebInit = {
|
|||
logger.debug('WebAssembly runtime loaded (main thread)', logger.ts(ts));
|
||||
clearTimeout(loadTimeout);
|
||||
resolve({
|
||||
hash: args => {
|
||||
hash: (args) => {
|
||||
const hash = this.calcHash(global.Module, args);
|
||||
global.Module.unloadRuntime();
|
||||
global.Module = undefined;
|
||||
|
@ -193,7 +193,7 @@ const KdbxwebInit = {
|
|||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
}).catch(err => {
|
||||
}).catch((err) => {
|
||||
logger.warn('WebAssembly error', err);
|
||||
throw new Error('WebAssembly error');
|
||||
});
|
||||
|
@ -202,7 +202,7 @@ const KdbxwebInit = {
|
|||
// eslint-disable-next-line object-shorthand
|
||||
workerPostRun: function () {
|
||||
self.postMessage({ op: 'postRun' });
|
||||
self.onmessage = e => {
|
||||
self.onmessage = (e) => {
|
||||
try {
|
||||
/* eslint-disable-next-line no-undef */
|
||||
const hash = Module.calcHash(Module, e.data);
|
||||
|
|
|
@ -88,7 +88,7 @@ kdbxweb.ProtectedValue.prototype.indexOfLower = function(findLower) {
|
|||
const foundSeqs = [];
|
||||
const len = findLower.length;
|
||||
let chIndex = -1;
|
||||
this.forEachChar(ch => {
|
||||
this.forEachChar((ch) => {
|
||||
chIndex++;
|
||||
ch = String.fromCharCode(ch).toLowerCase();
|
||||
if (index !== -1) {
|
||||
|
@ -122,7 +122,7 @@ kdbxweb.ProtectedValue.prototype.indexOfSelfInLower = function(targetLower) {
|
|||
let found = false;
|
||||
do {
|
||||
let chIndex = -1;
|
||||
this.forEachChar(ch => {
|
||||
this.forEachChar((ch) => {
|
||||
chIndex++;
|
||||
ch = String.fromCharCode(ch).toLowerCase();
|
||||
if (chIndex === 0) {
|
||||
|
@ -168,7 +168,7 @@ kdbxweb.ProtectedValue.prototype.isFieldReference = function() {
|
|||
return false;
|
||||
}
|
||||
let ix = 0;
|
||||
this.forEachChar(ch => {
|
||||
this.forEachChar((ch) => {
|
||||
const expected = ExpectedFieldRefChars[ix++];
|
||||
if (expected !== '0' && ch !== expected) {
|
||||
return false;
|
||||
|
|
|
@ -41,10 +41,7 @@ Tip.prototype.show = function() {
|
|||
this.hideTimeout = null;
|
||||
}
|
||||
}
|
||||
const tipEl = (this.tipEl = $('<div></div>')
|
||||
.addClass('tip')
|
||||
.appendTo('body')
|
||||
.text(this.title));
|
||||
const tipEl = (this.tipEl = $('<div></div>').addClass('tip').appendTo('body').text(this.title));
|
||||
const rect = this.el[0].getBoundingClientRect();
|
||||
const tipRect = this.tipEl[0].getBoundingClientRect();
|
||||
const placement = this.placement || this.getAutoPlacement(rect, tipRect);
|
||||
|
|
|
@ -314,7 +314,9 @@ class AppView extends View {
|
|||
}
|
||||
|
||||
showFileSettings(e) {
|
||||
const menuItem = this.model.menu.filesSection.items.find(item => item.file.id === e.fileId);
|
||||
const menuItem = this.model.menu.filesSection.items.find(
|
||||
(item) => item.file.id === e.fileId
|
||||
);
|
||||
if (this.views.settings) {
|
||||
if (this.views.settings.file === menuItem.file) {
|
||||
this.showEntries();
|
||||
|
@ -380,7 +382,7 @@ class AppView extends View {
|
|||
if (Launcher) {
|
||||
if (!this.exitAlertShown) {
|
||||
if (this.model.settings.autoSave) {
|
||||
this.saveAndLock(result => {
|
||||
this.saveAndLock((result) => {
|
||||
if (result) {
|
||||
exit();
|
||||
}
|
||||
|
@ -396,9 +398,9 @@ class AppView extends View {
|
|||
{ result: 'exit', title: Locale.discardChanges, error: true },
|
||||
{ result: '', title: Locale.appDontExitBtn }
|
||||
],
|
||||
success: result => {
|
||||
success: (result) => {
|
||||
if (result === 'save') {
|
||||
this.saveAndLock(result => {
|
||||
this.saveAndLock((result) => {
|
||||
if (result) {
|
||||
exit();
|
||||
}
|
||||
|
@ -573,7 +575,7 @@ class AppView extends View {
|
|||
|
||||
closeAllFilesAndShowFirst() {
|
||||
let fileToShow = this.model.files.find(
|
||||
file => !file.demo && !file.created && !file.external
|
||||
(file) => !file.demo && !file.created && !file.external
|
||||
);
|
||||
this.model.closeAllFiles();
|
||||
if (!fileToShow) {
|
||||
|
@ -729,8 +731,8 @@ class AppView extends View {
|
|||
position: { left: e.pageX, top: e.pageY },
|
||||
options: e.options
|
||||
});
|
||||
menu.on('cancel', e => this.hideContextMenu());
|
||||
menu.on('select', e => this.contextMenuSelect(e));
|
||||
menu.on('cancel', (e) => this.hideContextMenu());
|
||||
menu.on('select', (e) => this.contextMenuSelect(e));
|
||||
this.views.contextMenu = menu;
|
||||
}
|
||||
}
|
||||
|
@ -801,7 +803,7 @@ class AppView extends View {
|
|||
const reader = new FileReader();
|
||||
const logger = new Logger('import-csv');
|
||||
logger.info('Reading CSV...');
|
||||
reader.onload = e => {
|
||||
reader.onload = (e) => {
|
||||
logger.info('Parsing CSV...');
|
||||
const ts = logger.ts();
|
||||
const parser = new CsvParser();
|
||||
|
|
|
@ -75,7 +75,7 @@ class AutoTypeSelectView extends View {
|
|||
const presenter = new EntryPresenter(null, noColor, this.result && this.result.id);
|
||||
let itemsHtml = '';
|
||||
const itemTemplate = this.itemTemplate;
|
||||
this.entries.forEach(entry => {
|
||||
this.entries.forEach((entry) => {
|
||||
presenter.present(entry);
|
||||
itemsHtml += itemTemplate(presenter, DefaultTemplateOptions);
|
||||
});
|
||||
|
|
|
@ -23,18 +23,14 @@ class DetailsAttachmentView extends View {
|
|||
case 'text': {
|
||||
const reader = new FileReader();
|
||||
reader.addEventListener('loadend', () => {
|
||||
$('<pre/>')
|
||||
.text(reader.result)
|
||||
.appendTo(dataEl);
|
||||
$('<pre/>').text(reader.result).appendTo(dataEl);
|
||||
complete();
|
||||
});
|
||||
reader.readAsText(blob);
|
||||
return;
|
||||
}
|
||||
case 'image':
|
||||
$('<img/>')
|
||||
.attr('src', URL.createObjectURL(blob))
|
||||
.appendTo(dataEl);
|
||||
$('<img/>').attr('src', URL.createObjectURL(blob)).appendTo(dataEl);
|
||||
complete();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ class DetailsAutoTypeView extends View {
|
|||
seqInput(e) {
|
||||
const el = e.target;
|
||||
const seq = el.value.trim();
|
||||
AutoType.validate(this.model, seq, err => {
|
||||
AutoType.validate(this.model, seq, (err) => {
|
||||
$(el).toggleClass('input--error', !!err);
|
||||
if (!err) {
|
||||
this.model.setAutoTypeSeq(seq);
|
||||
|
|
|
@ -57,10 +57,10 @@ function createDetailsFields(detailsView) {
|
|||
);
|
||||
} else {
|
||||
const writeableFiles = AppModel.instance.files.filter(
|
||||
file => file.active && !file.readOnly
|
||||
(file) => file.active && !file.readOnly
|
||||
);
|
||||
if (model.isJustCreated && writeableFiles.length > 1) {
|
||||
const fileNames = writeableFiles.map(file => {
|
||||
const fileNames = writeableFiles.map((file) => {
|
||||
return { id: file.id, value: file.name, selected: file === model.file };
|
||||
});
|
||||
fieldViews.push(
|
||||
|
|
|
@ -115,7 +115,7 @@ class DetailsHistoryView extends View {
|
|||
}
|
||||
|
||||
removeFieldViews() {
|
||||
this.fieldViews.forEach(fieldView => fieldView.remove());
|
||||
this.fieldViews.forEach((fieldView) => fieldView.remove());
|
||||
this.fieldViews = [];
|
||||
}
|
||||
|
||||
|
@ -209,11 +209,11 @@ class DetailsHistoryView extends View {
|
|||
new FieldViewReadOnly({
|
||||
name: 'Attachments',
|
||||
title: Locale.detAttachments,
|
||||
value: this.record.attachments.map(att => att.title).join(', ')
|
||||
value: this.record.attachments.map((att) => att.title).join(', ')
|
||||
})
|
||||
);
|
||||
}
|
||||
this.fieldViews.forEach(fieldView => {
|
||||
this.fieldViews.forEach((fieldView) => {
|
||||
fieldView.parent = this.bodyEl[0];
|
||||
fieldView.render();
|
||||
fieldView.on('copy', this.fieldCopied.bind(this));
|
||||
|
@ -232,9 +232,7 @@ class DetailsHistoryView extends View {
|
|||
}
|
||||
|
||||
timelineItemClick(e) {
|
||||
const id = $(e.target)
|
||||
.closest('.details__history-timeline-item')
|
||||
.data('id');
|
||||
const id = $(e.target).closest('.details__history-timeline-item').data('id');
|
||||
this.showRecord(id);
|
||||
}
|
||||
|
||||
|
@ -253,7 +251,7 @@ class DetailsHistoryView extends View {
|
|||
buildTimeline() {
|
||||
const firstRec = this.history[0];
|
||||
const lastRec = this.history[this.history.length - 1];
|
||||
this.timeline = this.history.map(rec => ({
|
||||
this.timeline = this.history.map((rec) => ({
|
||||
pos: (rec.updated - firstRec.updated) / (lastRec.updated - firstRec.updated),
|
||||
rec
|
||||
}));
|
||||
|
@ -263,7 +261,7 @@ class DetailsHistoryView extends View {
|
|||
firstRec.updated.getTime(),
|
||||
lastRec.updated.getTime(),
|
||||
format.round
|
||||
).map(label => ({
|
||||
).map((label) => ({
|
||||
pos: (label - firstRec.updated) / (lastRec.updated - firstRec.updated),
|
||||
val: label,
|
||||
text: format.format(new Date(label))
|
||||
|
|
|
@ -96,7 +96,7 @@ class DetailsView extends View {
|
|||
}
|
||||
|
||||
removeFieldViews() {
|
||||
this.fieldViews.forEach(fieldView => fieldView.remove());
|
||||
this.fieldViews.forEach((fieldView) => fieldView.remove());
|
||||
this.fieldViews = [];
|
||||
this.hideFieldCopyTip();
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ class DetailsView extends View {
|
|||
}
|
||||
|
||||
getFieldView(name) {
|
||||
return this.fieldViews.find(fv => fv.model.name === name);
|
||||
return this.fieldViews.find((fv) => fv.model.name === name);
|
||||
}
|
||||
|
||||
addFieldViews() {
|
||||
|
@ -152,7 +152,7 @@ class DetailsView extends View {
|
|||
fieldView.render();
|
||||
fieldView.on('change', this.fieldChanged.bind(this));
|
||||
fieldView.on('copy', this.fieldCopied.bind(this));
|
||||
fieldView.on('autotype', e => this.autoType(e.source.model.sequence));
|
||||
fieldView.on('autotype', (e) => this.autoType(e.source.model.sequence));
|
||||
if (hideEmptyFields) {
|
||||
const value = fieldView.model.value();
|
||||
if (!value || value.length === 0 || value.byteLength === 0) {
|
||||
|
@ -223,7 +223,7 @@ class DetailsView extends View {
|
|||
const hideEmptyFields = AppSettingsModel.hideEmptyFields;
|
||||
const moreOptions = [];
|
||||
if (hideEmptyFields) {
|
||||
this.fieldViews.forEach(fieldView => {
|
||||
this.fieldViews.forEach((fieldView) => {
|
||||
if (fieldView.isHidden()) {
|
||||
moreOptions.push({
|
||||
value: 'add:' + fieldView.model.name,
|
||||
|
@ -306,7 +306,7 @@ class DetailsView extends View {
|
|||
default:
|
||||
if (e.item.lastIndexOf('add:', 0) === 0) {
|
||||
const fieldName = e.item.substr(4);
|
||||
const fieldView = this.fieldViews.find(f => f.model.name === fieldName);
|
||||
const fieldView = this.fieldViews.find((f) => f.model.name === fieldName);
|
||||
fieldView.show();
|
||||
fieldView.edit();
|
||||
}
|
||||
|
@ -336,9 +336,7 @@ class DetailsView extends View {
|
|||
}
|
||||
|
||||
selectColor(e) {
|
||||
let color = $(e.target)
|
||||
.closest('.details__colors-popup-item')
|
||||
.data('color');
|
||||
let color = $(e.target).closest('.details__colors-popup-item').data('color');
|
||||
if (!color) {
|
||||
return;
|
||||
}
|
||||
|
@ -927,7 +925,7 @@ class DetailsView extends View {
|
|||
|
||||
otpEnterManually() {
|
||||
if (this.model.fields.otp) {
|
||||
const otpField = this.fieldViews.find(f => f.model.name === '$otp');
|
||||
const otpField = this.fieldViews.find((f) => f.model.name === '$otp');
|
||||
if (otpField) {
|
||||
otpField.edit();
|
||||
}
|
||||
|
@ -967,7 +965,7 @@ class DetailsView extends View {
|
|||
const hasOtp = sequence?.includes('{TOTP}') || (entry.external && !sequence);
|
||||
if (hasOtp) {
|
||||
const otpField = this.getFieldView('$otp');
|
||||
otpField.refreshOtp(err => {
|
||||
otpField.refreshOtp((err) => {
|
||||
if (!err) {
|
||||
Events.emit('auto-type', {
|
||||
entry,
|
||||
|
|
|
@ -153,7 +153,7 @@ class FieldViewOtp extends FieldViewText {
|
|||
}
|
||||
|
||||
copyValue() {
|
||||
this.refreshOtp(err => {
|
||||
this.refreshOtp((err) => {
|
||||
if (!err) {
|
||||
super.copyValue();
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ class FieldViewSelect extends FieldView {
|
|||
return (
|
||||
'<select>' +
|
||||
value
|
||||
.map(opt => {
|
||||
.map((opt) => {
|
||||
return (
|
||||
'<option ' +
|
||||
'value="' +
|
||||
|
@ -28,7 +28,7 @@ class FieldViewSelect extends FieldView {
|
|||
render() {
|
||||
super.render();
|
||||
this.valueEl.addClass('details__field-value--select');
|
||||
this.valueEl.find('select:first').change(e => {
|
||||
this.valueEl.find('select:first').change((e) => {
|
||||
this.triggerChange({ val: e.target.value, field: this.model.name });
|
||||
});
|
||||
}
|
||||
|
|
|
@ -19,14 +19,14 @@ class FieldViewTags extends FieldViewText {
|
|||
|
||||
valueToTags(val) {
|
||||
const allTags = {};
|
||||
this.model.tags.forEach(tag => {
|
||||
this.model.tags.forEach((tag) => {
|
||||
allTags[tag.toLowerCase()] = tag;
|
||||
});
|
||||
const valueTags = {};
|
||||
val.split(/\s*[;,:]\s*/)
|
||||
.filter(tag => tag)
|
||||
.map(tag => allTags[tag.toLowerCase()] || tag)
|
||||
.forEach(tag => {
|
||||
.filter((tag) => tag)
|
||||
.map((tag) => allTags[tag.toLowerCase()] || tag)
|
||||
.forEach((tag) => {
|
||||
valueTags[tag] = tag;
|
||||
});
|
||||
return Object.keys(valueTags);
|
||||
|
@ -69,7 +69,7 @@ class FieldViewTags extends FieldViewText {
|
|||
const tags = this.valueToTags(this.input.val());
|
||||
const last = tags[tags.length - 1];
|
||||
const isLastPart = last && this.model.tags.indexOf(last) < 0;
|
||||
return this.model.tags.filter(tag => {
|
||||
return this.model.tags.filter((tag) => {
|
||||
return (
|
||||
tags.indexOf(tag) < 0 &&
|
||||
(!isLastPart || tag.toLowerCase().indexOf(last.toLowerCase()) >= 0)
|
||||
|
|
|
@ -57,7 +57,7 @@ class FieldViewText extends FieldView {
|
|||
click: this.fieldValueInputClick.bind(this),
|
||||
mousedown: this.fieldValueInputMouseDown.bind(this)
|
||||
});
|
||||
const fieldValueBlurBound = e => this.fieldValueBlur(e);
|
||||
const fieldValueBlurBound = (e) => this.fieldValueBlur(e);
|
||||
Events.on('click', fieldValueBlurBound);
|
||||
this.stopBlurListener = () => Events.off('click', fieldValueBlurBound);
|
||||
this.listenTo(Events, 'main-window-will-close', this.externalEndEdit);
|
||||
|
@ -82,7 +82,7 @@ class FieldViewText extends FieldView {
|
|||
|
||||
createMobileControls() {
|
||||
this.mobileControls = {};
|
||||
['cancel', 'apply'].forEach(action => {
|
||||
['cancel', 'apply'].forEach((action) => {
|
||||
this.mobileControls[action] = $('<div/>')
|
||||
.addClass('details__field-value-btn details__field-value-btn-' + action)
|
||||
.appendTo(this.labelEl)
|
||||
|
|
|
@ -77,9 +77,7 @@ class FooterView extends View {
|
|||
}
|
||||
|
||||
showFile(e) {
|
||||
const fileId = $(e.target)
|
||||
.closest('.footer__db-item')
|
||||
.data('file-id');
|
||||
const fileId = $(e.target).closest('.footer__db-item').data('file-id');
|
||||
if (fileId) {
|
||||
Events.emit('show-file', { fileId });
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@ class GeneratorPresetsView extends View {
|
|||
|
||||
render() {
|
||||
this.presets = GeneratorPresets.all;
|
||||
if (!this.selected || !this.presets.some(p => p.name === this.selected)) {
|
||||
this.selected = (this.presets.filter(p => p.default)[0] || this.presets[0]).name;
|
||||
if (!this.selected || !this.presets.some((p) => p.name === this.selected)) {
|
||||
this.selected = (this.presets.filter((p) => p.default)[0] || this.presets[0]).name;
|
||||
}
|
||||
super.render({
|
||||
presets: this.presets,
|
||||
|
@ -61,7 +61,7 @@ class GeneratorPresetsView extends View {
|
|||
high: '¡¢£¤¥¦§©ª«¬®¯°±¹²´µ¶»¼÷¿ÀÖîü...'
|
||||
};
|
||||
return ['Upper', 'Lower', 'Digits', 'Special', 'Brackets', 'High', 'Ambiguous'].map(
|
||||
name => {
|
||||
(name) => {
|
||||
const nameLower = name.toLowerCase();
|
||||
return {
|
||||
name: nameLower,
|
||||
|
@ -74,7 +74,7 @@ class GeneratorPresetsView extends View {
|
|||
}
|
||||
|
||||
getPreset(name) {
|
||||
return this.presets.filter(p => p.name === name)[0];
|
||||
return this.presets.filter((p) => p.name === name)[0];
|
||||
}
|
||||
|
||||
returnToApp() {
|
||||
|
@ -92,7 +92,7 @@ class GeneratorPresetsView extends View {
|
|||
for (let i = 1; ; i++) {
|
||||
const newName = 'Custom' + i;
|
||||
const newTitle = Locale.genPsNew + ' ' + i;
|
||||
if (!this.presets.filter(p => p.name === newName || p.title === newTitle).length) {
|
||||
if (!this.presets.filter((p) => p.name === newName || p.title === newTitle).length) {
|
||||
name = newName;
|
||||
title = newTitle;
|
||||
break;
|
||||
|
@ -128,9 +128,11 @@ class GeneratorPresetsView extends View {
|
|||
changeTitle(e) {
|
||||
const title = $.trim(e.target.value);
|
||||
if (title && title !== this.getPreset(this.selected).title) {
|
||||
let duplicate = this.presets.some(p => p.title.toLowerCase() === title.toLowerCase());
|
||||
let duplicate = this.presets.some((p) => p.title.toLowerCase() === title.toLowerCase());
|
||||
if (!duplicate) {
|
||||
duplicate = this.reservedTitles.some(p => p.toLowerCase() === title.toLowerCase());
|
||||
duplicate = this.reservedTitles.some(
|
||||
(p) => p.toLowerCase() === title.toLowerCase()
|
||||
);
|
||||
}
|
||||
if (duplicate) {
|
||||
$(e.target).addClass('input--error');
|
||||
|
|
|
@ -62,7 +62,7 @@ class GeneratorView extends View {
|
|||
super(model);
|
||||
this.createPresets();
|
||||
const preset = this.preset;
|
||||
this.gen = { ...this.presets.find(pr => pr.name === preset) };
|
||||
this.gen = { ...this.presets.find((pr) => pr.name === preset) };
|
||||
this.hide = AppSettingsModel.generatorHidePassword;
|
||||
$('body').one('click', this.remove.bind(this));
|
||||
this.listenTo(Events, 'lock-workspace', this.remove.bind(this));
|
||||
|
@ -100,10 +100,10 @@ class GeneratorView extends View {
|
|||
this.presets.splice(0, 0, derivedPreset);
|
||||
this.preset = 'Derived';
|
||||
} else {
|
||||
const defaultPreset = this.presets.filter(p => p.default)[0] || this.presets[0];
|
||||
const defaultPreset = this.presets.filter((p) => p.default)[0] || this.presets[0];
|
||||
this.preset = defaultPreset.name;
|
||||
}
|
||||
this.presets.forEach(pr => {
|
||||
this.presets.forEach((pr) => {
|
||||
pr.pseudoLength = this.lengthToPseudoValue(pr.length);
|
||||
});
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ class GeneratorView extends View {
|
|||
return;
|
||||
}
|
||||
this.preset = name;
|
||||
const preset = this.presets.find(t => t.name === name);
|
||||
const preset = this.presets.find((t) => t.name === name);
|
||||
this.gen = { ...preset };
|
||||
this.render();
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ class GrpView extends View {
|
|||
changeAutoTypeSeq(e) {
|
||||
const el = e.target;
|
||||
const seq = $.trim(el.value);
|
||||
AutoType.validate(null, seq, err => {
|
||||
AutoType.validate(null, seq, (err) => {
|
||||
$(e.target).toggleClass('input--error', !!err);
|
||||
if (!err) {
|
||||
this.model.setAutoTypeSeq(seq);
|
||||
|
|
|
@ -69,7 +69,7 @@ class IconSelectView extends View {
|
|||
.append(img);
|
||||
this.downloadingFavicon = false;
|
||||
};
|
||||
img.onerror = e => {
|
||||
img.onerror = (e) => {
|
||||
logger.error('Favicon download error: ' + url, e);
|
||||
this.$el.find('.icon-select__icon-download>i').removeClass('fa-spinner fa-spin');
|
||||
this.$el
|
||||
|
@ -86,7 +86,7 @@ class IconSelectView extends View {
|
|||
}
|
||||
let url = this.model.url.replace(
|
||||
/([^\/:]\/.*)?$/,
|
||||
match => (match && match[0]) + '/favicon.ico'
|
||||
(match) => (match && match[0]) + '/favicon.ico'
|
||||
);
|
||||
if (url.indexOf('://') < 0) {
|
||||
url = 'http://' + url;
|
||||
|
@ -108,7 +108,7 @@ class IconSelectView extends View {
|
|||
const file = e.target.files[0];
|
||||
if (file) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = e => {
|
||||
reader.onload = (e) => {
|
||||
const img = document.createElement('img');
|
||||
img.onload = () => {
|
||||
this.setSpecialImage(img, 'select');
|
||||
|
|
|
@ -69,7 +69,7 @@ class ImportCsvView extends View {
|
|||
const col = +e.target.dataset.col;
|
||||
const field = e.target.value;
|
||||
|
||||
const isBuiltIn = this.knownFields.some(f => f.field === field);
|
||||
const isBuiltIn = this.knownFields.some((f) => f.field === field);
|
||||
const mapping = field ? (isBuiltIn ? 'builtin' : 'custom') : 'ignore';
|
||||
|
||||
this.fieldMapping[col] = {
|
||||
|
@ -96,7 +96,7 @@ class ImportCsvView extends View {
|
|||
guessFieldMapping() {
|
||||
const usedFields = {};
|
||||
|
||||
for (const fieldName of this.model.headers.map(f => f.trim())) {
|
||||
for (const fieldName of this.model.headers.map((f) => f.trim())) {
|
||||
if (!fieldName || /^(group|grouping)$/i.test(fieldName)) {
|
||||
this.fieldMapping.push({ type: 'ignore' });
|
||||
continue;
|
||||
|
@ -121,7 +121,7 @@ class ImportCsvView extends View {
|
|||
fillGroups() {
|
||||
this.groups = [];
|
||||
for (const file of this.appModel.files) {
|
||||
file.forEachGroup(group => {
|
||||
file.forEachGroup((group) => {
|
||||
const title = group.title;
|
||||
const spaces = [];
|
||||
for (let parent = group; parent.parentGroup; parent = parent.parentGroup) {
|
||||
|
|
|
@ -68,10 +68,7 @@ class KeyChangeView extends View {
|
|||
this.keyFile = null;
|
||||
this.$el.find('.key-change__keyfile-name').empty();
|
||||
}
|
||||
this.$el
|
||||
.find('.key-change__file')
|
||||
.val(null)
|
||||
.click();
|
||||
this.$el.find('.key-change__file').val(null).click();
|
||||
this.inputEl.focus();
|
||||
}
|
||||
|
||||
|
@ -79,7 +76,7 @@ class KeyChangeView extends View {
|
|||
const file = e.target.files[0];
|
||||
if (file) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = e => {
|
||||
reader.onload = (e) => {
|
||||
this.keyFileName = file.name;
|
||||
this.keyFileData = e.target.result;
|
||||
this.$el.find('.key-change__keyfile-name').text(': ' + this.keyFileName);
|
||||
|
|
|
@ -99,7 +99,7 @@ class ListSearchView extends View {
|
|||
{ value: '-rank', icon: 'sort-amount-desc', loc: () => Locale.searchRank }
|
||||
];
|
||||
this.sortIcons = {};
|
||||
this.sortOptions.forEach(opt => {
|
||||
this.sortOptions.forEach((opt) => {
|
||||
this.sortIcons[opt.value] = opt.icon;
|
||||
});
|
||||
this.advancedSearch = {
|
||||
|
@ -135,7 +135,7 @@ class ListSearchView extends View {
|
|||
}
|
||||
|
||||
setLocale() {
|
||||
this.sortOptions.forEach(opt => {
|
||||
this.sortOptions.forEach((opt) => {
|
||||
opt.text = opt.loc();
|
||||
});
|
||||
this.createOptions = [
|
||||
|
@ -161,7 +161,7 @@ class ListSearchView extends View {
|
|||
removeKeypressHandler() {}
|
||||
|
||||
viewShown() {
|
||||
const keypressHandler = e => this.documentKeyPress(e);
|
||||
const keypressHandler = (e) => this.documentKeyPress(e);
|
||||
Events.on('keypress', keypressHandler);
|
||||
this.removeKeypressHandler = () => Events.off('keypress', keypressHandler);
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ class ListSearchView extends View {
|
|||
const hasMultipleFiles = this.model.files.length > 1;
|
||||
this.entryTemplates = {};
|
||||
const options = [];
|
||||
entryTemplates.forEach(tmpl => {
|
||||
entryTemplates.forEach((tmpl) => {
|
||||
const id = 'tmpl:' + tmpl.entry.id;
|
||||
options.push({
|
||||
value: id,
|
||||
|
|
|
@ -93,14 +93,14 @@ class ListView extends View {
|
|||
this.model.activeEntryId
|
||||
);
|
||||
const columns = {};
|
||||
this.tableColumns.forEach(col => {
|
||||
this.tableColumns.forEach((col) => {
|
||||
if (col.enabled) {
|
||||
columns[col.val] = true;
|
||||
}
|
||||
});
|
||||
presenter.columns = columns;
|
||||
let itemsHtml = '';
|
||||
this.items.forEach(item => {
|
||||
this.items.forEach((item) => {
|
||||
presenter.present(item);
|
||||
itemsHtml += itemTemplate(presenter, DefaultTemplateOptions);
|
||||
}, this);
|
||||
|
@ -250,7 +250,7 @@ class ListView extends View {
|
|||
this.throttleSetViewSizeSetting(size);
|
||||
}
|
||||
|
||||
throttleSetViewSizeSetting = throttle(size => {
|
||||
throttleSetViewSizeSetting = throttle((size) => {
|
||||
AppSettingsModel.listViewWidth = size;
|
||||
}, 1000);
|
||||
|
||||
|
@ -267,9 +267,7 @@ class ListView extends View {
|
|||
|
||||
itemDragStart(e) {
|
||||
e.stopPropagation();
|
||||
const id = $(e.target)
|
||||
.closest('.list__item')
|
||||
.attr('id');
|
||||
const id = $(e.target).closest('.list__item').attr('id');
|
||||
e.dataTransfer.setData('text/entry', id);
|
||||
e.dataTransfer.effectAllowed = 'move';
|
||||
DragDropInfo.dragObject = this.items.get(id);
|
||||
|
@ -285,7 +283,7 @@ class ListView extends View {
|
|||
this.listenTo(view, 'cancel', this.hideOptionsDropdown);
|
||||
this.listenTo(view, 'select', this.optionsDropdownSelect);
|
||||
const targetElRect = this.$el.find('.list__table-options')[0].getBoundingClientRect();
|
||||
const options = this.tableColumns.map(col => ({
|
||||
const options = this.tableColumns.map((col) => ({
|
||||
value: col.val,
|
||||
icon: col.enabled ? 'check-square-o' : 'square-o',
|
||||
text: StringFormat.capFirst(Locale[col.name])
|
||||
|
@ -308,7 +306,7 @@ class ListView extends View {
|
|||
}
|
||||
|
||||
optionsDropdownSelect(e) {
|
||||
const col = this.tableColumns.find(c => c.val === e.item);
|
||||
const col = this.tableColumns.find((c) => c.val === e.item);
|
||||
col.enabled = !col.enabled;
|
||||
e.el.find('i:first').toggleClass('fa-check-square-o fa-square-o');
|
||||
this.render();
|
||||
|
@ -318,7 +316,7 @@ class ListView extends View {
|
|||
readTableColumnsEnabled() {
|
||||
const tableViewColumns = AppSettingsModel.tableViewColumns;
|
||||
if (tableViewColumns && tableViewColumns.length) {
|
||||
this.tableColumns.forEach(col => {
|
||||
this.tableColumns.forEach((col) => {
|
||||
col.enabled = tableViewColumns.indexOf(col.name) >= 0;
|
||||
});
|
||||
}
|
||||
|
@ -326,8 +324,8 @@ class ListView extends View {
|
|||
|
||||
saveTableColumnsEnabled() {
|
||||
const tableViewColumns = this.tableColumns
|
||||
.filter(column => column.enabled)
|
||||
.map(column => column.name);
|
||||
.filter((column) => column.enabled)
|
||||
.map((column) => column.name);
|
||||
AppSettingsModel.tableViewColumns = tableViewColumns;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ class MenuItemView extends View {
|
|||
this.iconEl = this.$el.find('.menu__item-icon');
|
||||
const items = this.model.items;
|
||||
if (items) {
|
||||
items.forEach(item => {
|
||||
items.forEach((item) => {
|
||||
if (item.visible) {
|
||||
this.insertItem(item);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ class MenuItemView extends View {
|
|||
}
|
||||
|
||||
removeInnerViews() {
|
||||
this.itemViews.forEach(itemView => itemView.remove());
|
||||
this.itemViews.forEach((itemView) => itemView.remove());
|
||||
this.itemViews = [];
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ class MenuItemView extends View {
|
|||
const options = this.model.options;
|
||||
const value = $(e.target).data('value');
|
||||
if (options && options.length) {
|
||||
const option = options.find(op => op.value === value);
|
||||
const option = options.find((op) => op.value === value);
|
||||
if (option) {
|
||||
Events.emit('menu-select', { item: this.model, option });
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class MenuSectionView extends View {
|
|||
} else {
|
||||
this.removeInnerViews();
|
||||
}
|
||||
this.model.items.forEach(item => {
|
||||
this.model.items.forEach((item) => {
|
||||
const itemView = new MenuItemView(item, { parent: this.itemsEl[0] });
|
||||
itemView.render();
|
||||
this.itemViews.push(itemView);
|
||||
|
@ -63,7 +63,7 @@ class MenuSectionView extends View {
|
|||
}
|
||||
|
||||
removeInnerViews() {
|
||||
this.itemViews.forEach(itemView => itemView.remove());
|
||||
this.itemViews.forEach((itemView) => itemView.remove());
|
||||
this.itemViews = [];
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ class MenuSectionView extends View {
|
|||
this.saveViewHeight(size);
|
||||
}
|
||||
|
||||
saveViewHeight = throttle(size => {
|
||||
saveViewHeight = throttle((size) => {
|
||||
AppSettingsModel.tagsViewHeight = size;
|
||||
}, 1000);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class MenuView extends View {
|
|||
KeyHandler.SHORTCUT_ACTION + KeyHandler.SHORTCUT_OPT
|
||||
);
|
||||
this.once('remove', () => {
|
||||
this.sectionViews.forEach(sectionView => sectionView.remove());
|
||||
this.sectionViews.forEach((sectionView) => sectionView.remove());
|
||||
this.sectionViews = [];
|
||||
});
|
||||
}
|
||||
|
@ -49,9 +49,7 @@ class MenuView extends View {
|
|||
const sectionView = new MenuSectionView(section, { parent: sectionsEl[0] });
|
||||
sectionView.render();
|
||||
if (section.drag) {
|
||||
const dragEl = $('<div/>')
|
||||
.addClass('menu__drag-section')
|
||||
.appendTo(sectionsEl);
|
||||
const dragEl = $('<div/>').addClass('menu__drag-section').appendTo(sectionsEl);
|
||||
const dragView = new DragView('y', { parent: dragEl[0] });
|
||||
sectionView.listenDrag(dragView);
|
||||
dragView.render();
|
||||
|
@ -68,7 +66,7 @@ class MenuView extends View {
|
|||
this.render();
|
||||
}
|
||||
|
||||
viewResized = throttle(size => {
|
||||
viewResized = throttle((size) => {
|
||||
AppSettingsModel.menuViewWidth = size;
|
||||
}, 1000);
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ class OpenChalRespView extends View {
|
|||
this.yubiKeys = [];
|
||||
if (yubiKeys) {
|
||||
for (const { fullName, vid, pid, serial, slot1, slot2 } of yubiKeys) {
|
||||
for (const slot of [slot1 ? 1 : 0, slot2 ? 2 : 0].filter(s => s)) {
|
||||
for (const slot of [slot1 ? 1 : 0, slot2 ? 2 : 0].filter((s) => s)) {
|
||||
this.yubiKeys.push({
|
||||
fullName,
|
||||
vid,
|
||||
|
|
|
@ -89,7 +89,7 @@ class OpenView extends View {
|
|||
}
|
||||
const storageProviders = [];
|
||||
if (this.model.settings.canOpenStorage) {
|
||||
Object.keys(Storage).forEach(name => {
|
||||
Object.keys(Storage).forEach((name) => {
|
||||
const prv = Storage[name];
|
||||
if (!prv.system && prv.enabled) {
|
||||
storageProviders.push(prv);
|
||||
|
@ -161,7 +161,7 @@ class OpenView extends View {
|
|||
}
|
||||
|
||||
getLastOpenFiles() {
|
||||
return this.model.fileInfos.map(fileInfo => {
|
||||
return this.model.fileInfos.map((fileInfo) => {
|
||||
let icon = 'file-text';
|
||||
const storage = Storage[fileInfo.storage];
|
||||
if (storage && storage.icon) {
|
||||
|
@ -203,7 +203,7 @@ class OpenView extends View {
|
|||
click: '',
|
||||
esc: '',
|
||||
enter: '',
|
||||
success: res => {
|
||||
success: (res) => {
|
||||
this.focusInput();
|
||||
if (res === 'skip') {
|
||||
this.model.settings.skipOpenLocalWarn = true;
|
||||
|
@ -215,7 +215,7 @@ class OpenView extends View {
|
|||
fileSelected(e) {
|
||||
const file = e.target.files[0];
|
||||
if (file) {
|
||||
this.processFile(file, success => {
|
||||
this.processFile(file, (success) => {
|
||||
if (success && !file.path && this.reading === 'fileData') {
|
||||
this.showLocalFileAlert();
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ class OpenView extends View {
|
|||
|
||||
processFile(file, complete) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = e => {
|
||||
reader.onload = (e) => {
|
||||
let success = false;
|
||||
switch (this.reading) {
|
||||
case 'fileData': {
|
||||
|
@ -347,7 +347,7 @@ class OpenView extends View {
|
|||
|
||||
setFile(file, keyFile, fileReadyCallback) {
|
||||
this.reading = 'fileData';
|
||||
this.processFile(file, success => {
|
||||
this.processFile(file, (success) => {
|
||||
if (success && keyFile) {
|
||||
this.reading = 'keyFileData';
|
||||
this.processFile(keyFile);
|
||||
|
@ -423,10 +423,7 @@ class OpenView extends View {
|
|||
if (this.busy) {
|
||||
return;
|
||||
}
|
||||
const id = $(e.target)
|
||||
.closest('.open__last-item')
|
||||
.data('id')
|
||||
.toString();
|
||||
const id = $(e.target).closest('.open__last-item').data('id').toString();
|
||||
if ($(e.target).is('.open__last-item-icon-del')) {
|
||||
const fileInfo = this.model.fileInfos.get(id);
|
||||
if (!fileInfo.storage || fileInfo.modified) {
|
||||
|
@ -539,8 +536,8 @@ class OpenView extends View {
|
|||
this.closeConfig();
|
||||
this.$el.removeClass('open--drag');
|
||||
const files = [...(e.target.files || e.dataTransfer.files)];
|
||||
const dataFile = files.find(file => /\.kdbx$/i.test(file.name));
|
||||
const keyFile = files.find(file => /\.key$/i.test(file.name));
|
||||
const dataFile = files.find((file) => /\.kdbx$/i.test(file.name));
|
||||
const keyFile = files.find((file) => /\.key$/i.test(file.name));
|
||||
if (dataFile) {
|
||||
this.setFile(
|
||||
dataFile,
|
||||
|
@ -550,14 +547,14 @@ class OpenView extends View {
|
|||
return;
|
||||
}
|
||||
if (this.model.settings.canImportXml) {
|
||||
const xmlFile = files.find(file => /\.xml$/i.test(file.name));
|
||||
const xmlFile = files.find((file) => /\.xml$/i.test(file.name));
|
||||
if (xmlFile) {
|
||||
this.setFile(xmlFile, null, this.showLocalFileAlert.bind(this));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.model.settings.canImportCsv) {
|
||||
const csvFile = files.find(file => /\.csv$/i.test(file.name));
|
||||
const csvFile = files.find((file) => /\.csv$/i.test(file.name));
|
||||
if (csvFile) {
|
||||
Events.emit('import-csv-requested', csvFile);
|
||||
}
|
||||
|
@ -631,7 +628,7 @@ class OpenView extends View {
|
|||
}
|
||||
|
||||
if (Launcher && Launcher.fingerprints) {
|
||||
Launcher.fingerprints.auth(fileInfo.id, fileInfo.fingerprint, password => {
|
||||
Launcher.fingerprints.auth(fileInfo.id, fileInfo.fingerprint, (password) => {
|
||||
this.inputEl.val(password);
|
||||
this.inputEl.trigger('input');
|
||||
this.openDb();
|
||||
|
@ -670,7 +667,7 @@ class OpenView extends View {
|
|||
this.busy = true;
|
||||
this.params.password = this.passwordInput.value;
|
||||
this.afterPaint(() => {
|
||||
this.model.openFile(this.params, err => this.openDbComplete(err));
|
||||
this.model.openFile(this.params, (err) => this.openDbComplete(err));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -710,7 +707,7 @@ class OpenView extends View {
|
|||
this.inputEl.attr('disabled', 'disabled');
|
||||
this.busy = true;
|
||||
this.afterPaint(() =>
|
||||
this.model.importFileWithXml(this.params, err => {
|
||||
this.model.importFileWithXml(this.params, (err) => {
|
||||
if (err) {
|
||||
this.params.name = '';
|
||||
this.params.fileXml = null;
|
||||
|
@ -736,12 +733,7 @@ class OpenView extends View {
|
|||
if (this.busy) {
|
||||
return;
|
||||
}
|
||||
const storage =
|
||||
Storage[
|
||||
$(e.target)
|
||||
.closest('.open__icon')
|
||||
.data('storage')
|
||||
];
|
||||
const storage = Storage[$(e.target).closest('.open__icon').data('storage')];
|
||||
if (!storage) {
|
||||
return;
|
||||
}
|
||||
|
@ -805,7 +797,7 @@ class OpenView extends View {
|
|||
files,
|
||||
showHiddenFiles: config && config.showHiddenFiles
|
||||
});
|
||||
listView.on('selected', file => {
|
||||
listView.on('selected', (file) => {
|
||||
if (file.dir) {
|
||||
this.listStorage(storage, {
|
||||
dir: file.path,
|
||||
|
@ -1027,14 +1019,14 @@ class OpenView extends View {
|
|||
const icon = this.$el.find('.open__icon-yubikey');
|
||||
icon.toggleClass('flip3d', true);
|
||||
|
||||
YubiKey.checkToolStatus().then(status => {
|
||||
YubiKey.checkToolStatus().then((status) => {
|
||||
if (status !== 'ok') {
|
||||
icon.toggleClass('flip3d', false);
|
||||
this.inputEl.removeAttr('disabled');
|
||||
this.busy = false;
|
||||
return Events.emit('toggle-settings', 'devices');
|
||||
}
|
||||
this.otpDevice = this.model.openOtpDevice(err => {
|
||||
this.otpDevice = this.model.openOtpDevice((err) => {
|
||||
if (err && !YubiKey.aborted) {
|
||||
Alerts.error({
|
||||
header: Locale.openError,
|
||||
|
|
|
@ -76,7 +76,7 @@ class SettingsFileView extends View {
|
|||
const storageProviders = [];
|
||||
const fileStorage = this.model.storage;
|
||||
let canBackup = false;
|
||||
Object.keys(Storage).forEach(name => {
|
||||
Object.keys(Storage).forEach((name) => {
|
||||
const prv = Storage[name];
|
||||
if (!canBackup && prv.backup && prv.enabled) {
|
||||
canBackup = true;
|
||||
|
@ -103,7 +103,7 @@ class SettingsFileView extends View {
|
|||
const yubiKeys = [];
|
||||
if (showYubiKeyBlock) {
|
||||
for (const yk of this.yubiKeys) {
|
||||
for (const slot of [yk.slot1 ? 1 : 0, yk.slot2 ? 2 : 0].filter(s => s)) {
|
||||
for (const slot of [yk.slot1 ? 1 : 0, yk.slot2 ? 2 : 0].filter((s) => s)) {
|
||||
yubiKeys.push({
|
||||
value: `${yk.serial}:${slot}`,
|
||||
fullName: yk.fullName,
|
||||
|
@ -114,7 +114,7 @@ class SettingsFileView extends View {
|
|||
});
|
||||
}
|
||||
}
|
||||
if (selectedYubiKey && !yubiKeys.some(yk => yk.value === selectedYubiKey)) {
|
||||
if (selectedYubiKey && !yubiKeys.some((yk) => yk.value === selectedYubiKey)) {
|
||||
yubiKeys.push({
|
||||
value: selectedYubiKey,
|
||||
fullName: `YubiKey ${this.model.chalResp.serial}`,
|
||||
|
@ -186,28 +186,16 @@ class SettingsFileView extends View {
|
|||
keyFileName !== 'Generated'
|
||||
? Locale.setFileUseKeyFile + ' ' + keyFileName
|
||||
: Locale.setFileUseGenKeyFile;
|
||||
$('<option/>')
|
||||
.val('ex')
|
||||
.text(text)
|
||||
.appendTo(sel);
|
||||
$('<option/>').val('ex').text(text).appendTo(sel);
|
||||
}
|
||||
if (oldKeyFileName) {
|
||||
const useText = keyFileChanged
|
||||
? Locale.setFileUseOldKeyFile
|
||||
: Locale.setFileUseKeyFile + ' ' + oldKeyFileName;
|
||||
$('<option/>')
|
||||
.val('old')
|
||||
.text(useText)
|
||||
.appendTo(sel);
|
||||
$('<option/>').val('old').text(useText).appendTo(sel);
|
||||
}
|
||||
$('<option/>')
|
||||
.val('gen')
|
||||
.text(Locale.setFileGenKeyFile)
|
||||
.appendTo(sel);
|
||||
$('<option/>')
|
||||
.val('none')
|
||||
.text(Locale.setFileDontUseKeyFile)
|
||||
.appendTo(sel);
|
||||
$('<option/>').val('gen').text(Locale.setFileGenKeyFile).appendTo(sel);
|
||||
$('<option/>').val('none').text(Locale.setFileDontUseKeyFile).appendTo(sel);
|
||||
if (keyFileName && keyFileChanged) {
|
||||
sel.val('ex');
|
||||
} else if (!keyFileName) {
|
||||
|
@ -266,20 +254,20 @@ class SettingsFileView extends View {
|
|||
}
|
||||
const fileName = this.model.name + '.kdbx';
|
||||
if (Launcher && !this.model.storage) {
|
||||
Launcher.getSaveFileName(fileName, path => {
|
||||
Launcher.getSaveFileName(fileName, (path) => {
|
||||
if (path) {
|
||||
this.save({ storage: 'file', path });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.model.getData(data => {
|
||||
this.model.getData((data) => {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
if (Launcher) {
|
||||
Launcher.getSaveFileName(fileName, path => {
|
||||
Launcher.getSaveFileName(fileName, (path) => {
|
||||
if (path) {
|
||||
Storage.file.save(path, null, data, err => {
|
||||
Storage.file.save(path, null, data, (err) => {
|
||||
if (err) {
|
||||
Alerts.error({
|
||||
header: Locale.setFileSaveError,
|
||||
|
@ -303,7 +291,7 @@ class SettingsFileView extends View {
|
|||
header: Locale.setFileExportRaw,
|
||||
body: Locale.setFileExportRawBody,
|
||||
success: () => {
|
||||
this.model.getXml(xml => {
|
||||
this.model.getXml((xml) => {
|
||||
const blob = new Blob([xml], { type: 'text/xml' });
|
||||
FileSaver.saveAs(blob, this.model.name + '.xml');
|
||||
});
|
||||
|
@ -316,7 +304,7 @@ class SettingsFileView extends View {
|
|||
header: Locale.setFileExportRaw,
|
||||
body: Locale.setFileExportRawBody,
|
||||
success: () => {
|
||||
this.model.getHtml(html => {
|
||||
this.model.getHtml((html) => {
|
||||
const blob = new Blob([html], { type: 'text/html' });
|
||||
FileSaver.saveAs(blob, this.model.name + '.html');
|
||||
});
|
||||
|
@ -328,9 +316,7 @@ class SettingsFileView extends View {
|
|||
if (this.model.syncing || this.model.demo) {
|
||||
return;
|
||||
}
|
||||
const storageName = $(e.target)
|
||||
.closest('.settings__file-save-to-storage')
|
||||
.data('storage');
|
||||
const storageName = $(e.target).closest('.settings__file-save-to-storage').data('storage');
|
||||
const storage = Storage[storageName];
|
||||
if (!storage) {
|
||||
return;
|
||||
|
@ -381,7 +367,7 @@ class SettingsFileView extends View {
|
|||
}
|
||||
const expName = this.model.name.toLowerCase();
|
||||
const existingFile = [...files].find(
|
||||
file =>
|
||||
(file) =>
|
||||
!file.dir && UrlFormat.getDataFileName(file.name).toLowerCase() === expName
|
||||
);
|
||||
if (existingFile) {
|
||||
|
@ -390,7 +376,7 @@ class SettingsFileView extends View {
|
|||
body: Locale.setFileAlreadyExistsBody.replace('{}', this.model.name),
|
||||
success: () => {
|
||||
this.model.syncing = true;
|
||||
storage.remove(existingFile.path, err => {
|
||||
storage.remove(existingFile.path, (err) => {
|
||||
this.model.syncing = false;
|
||||
if (!err) {
|
||||
this.save({ storage: storageName });
|
||||
|
@ -414,7 +400,7 @@ class SettingsFileView extends View {
|
|||
{ result: 'close', title: Locale.setFileCloseNoSave, error: true },
|
||||
{ result: '', title: Locale.setFileDontClose }
|
||||
],
|
||||
success: result => {
|
||||
success: (result) => {
|
||||
if (result === 'close') {
|
||||
this.closeFileNoCheck();
|
||||
}
|
||||
|
@ -467,7 +453,7 @@ class SettingsFileView extends View {
|
|||
fileSelected(e) {
|
||||
const file = e.target.files[0];
|
||||
const reader = new FileReader();
|
||||
reader.onload = e => {
|
||||
reader.onload = (e) => {
|
||||
const res = e.target.result;
|
||||
this.model.setKeyFile(res, file.name);
|
||||
this.renderKeyFileSelect();
|
||||
|
@ -618,13 +604,13 @@ class SettingsFileView extends View {
|
|||
}
|
||||
const backupButton = this.$el.find('.settings__file-button-backup');
|
||||
backupButton.text(Locale.setFileBackupNowWorking);
|
||||
this.model.getData(data => {
|
||||
this.model.getData((data) => {
|
||||
if (!data) {
|
||||
this.backupInProgress = false;
|
||||
backupButton.text(Locale.setFileBackupNow);
|
||||
return;
|
||||
}
|
||||
this.appModel.backupFile(this.model, data, err => {
|
||||
this.appModel.backupFile(this.model, data, (err) => {
|
||||
this.backupInProgress = false;
|
||||
backupButton.text(Locale.setFileBackupNow);
|
||||
if (err) {
|
||||
|
|
|
@ -72,7 +72,7 @@ class SettingsGeneralView extends View {
|
|||
const storageProviders = this.getStorageProviders();
|
||||
|
||||
super.render({
|
||||
themes: mapObject(SettingsManager.allThemes, theme => Locale[theme]),
|
||||
themes: mapObject(SettingsManager.allThemes, (theme) => Locale[theme]),
|
||||
activeTheme: SettingsManager.activeTheme,
|
||||
locales: SettingsManager.allLocales,
|
||||
activeLocale: SettingsManager.activeLocale,
|
||||
|
@ -189,14 +189,14 @@ class SettingsGeneralView extends View {
|
|||
|
||||
getStorageProviders() {
|
||||
const storageProviders = [];
|
||||
Object.keys(Storage).forEach(name => {
|
||||
Object.keys(Storage).forEach((name) => {
|
||||
const prv = Storage[name];
|
||||
if (!prv.system) {
|
||||
storageProviders.push(prv);
|
||||
}
|
||||
});
|
||||
storageProviders.sort((x, y) => (x.uipos || Infinity) - (y.uipos || Infinity));
|
||||
return storageProviders.map(sp => ({
|
||||
return storageProviders.map((sp) => ({
|
||||
name: sp.name,
|
||||
enabled: sp.enabled,
|
||||
hasConfig: !!sp.getSettingsConfig,
|
||||
|
|
|
@ -8,13 +8,13 @@ class SettingsLogsView extends View {
|
|||
template = template;
|
||||
|
||||
render() {
|
||||
const logs = Logger.getLast().map(item => ({
|
||||
const logs = Logger.getLast().map((item) => ({
|
||||
level: item.level,
|
||||
msg:
|
||||
'[' +
|
||||
StringFormat.padStr(item.level.toUpperCase(), 5) +
|
||||
'] ' +
|
||||
item.args.map(arg => this.mapArg(arg)).join(' ')
|
||||
item.args.map((arg) => this.mapArg(arg)).join(' ')
|
||||
}));
|
||||
super.render({ logs });
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class SettingsLogsView extends View {
|
|||
return arg ? arg.toString() : arg;
|
||||
}
|
||||
if (arg instanceof Array) {
|
||||
return '[' + arg.map(item => this.mapArg(item)).join(', ') + ']';
|
||||
return '[' + arg.map((item) => this.mapArg(item)).join(', ') + ']';
|
||||
}
|
||||
let str = arg.toString();
|
||||
if (str === '[object Object]') {
|
||||
|
|
|
@ -52,7 +52,7 @@ class SettingsPluginsView extends View {
|
|||
render() {
|
||||
super.render({
|
||||
plugins: PluginManager.plugins
|
||||
.map(plugin => ({
|
||||
.map((plugin) => ({
|
||||
id: plugin.id,
|
||||
manifest: plugin.manifest,
|
||||
status: plugin.status,
|
||||
|
@ -92,14 +92,14 @@ class SettingsPluginsView extends View {
|
|||
}
|
||||
const plugins = PluginManager.plugins;
|
||||
return PluginGallery.gallery.plugins
|
||||
.map(pl => ({
|
||||
.map((pl) => ({
|
||||
url: pl.url,
|
||||
manifest: pl.manifest,
|
||||
installing: this.installing[pl.url],
|
||||
installError: this.installErrors[pl.url],
|
||||
official: pl.official
|
||||
}))
|
||||
.filter(pl => !plugins.get(pl.manifest.name) && this.canInstallPlugin(pl))
|
||||
.filter((pl) => !plugins.get(pl.manifest.name) && this.canInstallPlugin(pl))
|
||||
.sort((x, y) => x.manifest.name.localeCompare(y.manifest.name));
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ class SettingsPluginsView extends View {
|
|||
this.render();
|
||||
this.$el.closest('.scroller').scrollTop(0);
|
||||
})
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
this.installFinished();
|
||||
this.installFromUrl.error = e;
|
||||
this.$el.find('.settings__plugins-install-error').text(e.toString());
|
||||
|
@ -200,12 +200,12 @@ class SettingsPluginsView extends View {
|
|||
galleryInstallClick(e) {
|
||||
const installBtn = $(e.target);
|
||||
const pluginId = installBtn.data('plugin');
|
||||
const plugin = PluginGallery.gallery.plugins.find(pl => pl.manifest.name === pluginId);
|
||||
const plugin = PluginGallery.gallery.plugins.find((pl) => pl.manifest.name === pluginId);
|
||||
installBtn.text(Locale.setPlInstallBtnProgress + '...').prop('disabled', true);
|
||||
this.installing[plugin.url] = true;
|
||||
delete this.installErrors[plugin.url];
|
||||
PluginManager.install(plugin.url, plugin.manifest)
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
this.installErrors[plugin.url] = e;
|
||||
delete this.installing[plugin.url];
|
||||
this.render();
|
||||
|
|
|
@ -62,9 +62,7 @@ class SettingsShortcutsView extends View {
|
|||
const shortcutEditor = $('<div/>')
|
||||
.addClass('shortcut__editor')
|
||||
.attr('data-shortcut', globalShortcutType);
|
||||
$('<div/>')
|
||||
.text(Locale.setShEdit)
|
||||
.appendTo(shortcutEditor);
|
||||
$('<div/>').text(Locale.setShEdit).appendTo(shortcutEditor);
|
||||
const shortcutEditorInput = $('<input/>')
|
||||
.addClass('shortcut__editor-input')
|
||||
.val(Shortcuts.globalShortcutText(globalShortcutType))
|
||||
|
@ -75,8 +73,8 @@ class SettingsShortcutsView extends View {
|
|||
|
||||
shortcutEditor.insertAfter($(e.target).parent());
|
||||
shortcutEditorInput.focus();
|
||||
shortcutEditorInput.on('keypress', e => e.preventDefault());
|
||||
shortcutEditorInput.on('keydown', e => {
|
||||
shortcutEditorInput.on('keypress', (e) => e.preventDefault());
|
||||
shortcutEditorInput.on('keydown', (e) => {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ class StorageFileListView extends View {
|
|||
}
|
||||
|
||||
render() {
|
||||
let files = this.model.files.map(file => {
|
||||
let files = this.model.files.map((file) => {
|
||||
this.allStorageFiles[file.path] = file;
|
||||
return {
|
||||
path: file.path,
|
||||
|
@ -27,7 +27,7 @@ class StorageFileListView extends View {
|
|||
dir: file.dir
|
||||
};
|
||||
});
|
||||
const visibleFiles = files.filter(f => !f.dir && f.kdbx);
|
||||
const visibleFiles = files.filter((f) => !f.dir && f.kdbx);
|
||||
const canShowHiddenFiles = visibleFiles.length && files.length > visibleFiles.length;
|
||||
if (!this.showHiddenFiles) {
|
||||
if (visibleFiles.length > 0) {
|
||||
|
@ -46,9 +46,7 @@ class StorageFileListView extends View {
|
|||
}
|
||||
|
||||
fileClick(e) {
|
||||
const result = $(e.target)
|
||||
.closest('.open-list__file')
|
||||
.data('path');
|
||||
const result = $(e.target).closest('.open-list__file').data('path');
|
||||
const file = this.allStorageFiles[result];
|
||||
this.emit('selected', file);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class TagView extends View {
|
|||
});
|
||||
return;
|
||||
}
|
||||
if (this.model.tags.some(t => t.toLowerCase() === title.toLowerCase())) {
|
||||
if (this.model.tags.some((t) => t.toLowerCase() === title.toLowerCase())) {
|
||||
Alerts.error({ header: Locale.tagExists, body: Locale.tagExistsBody });
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
const VERSION = '0.0.0';
|
||||
|
||||
self.addEventListener('install', event =>
|
||||
self.addEventListener('install', (event) =>
|
||||
event.waitUntil(
|
||||
caches.open('v1').then(cache =>
|
||||
fetch('.?v=' + VERSION).then(response => {
|
||||
caches.open('v1').then((cache) =>
|
||||
fetch('.?v=' + VERSION).then((response) => {
|
||||
if (response.ok) {
|
||||
return cache.put('.', response);
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ self.addEventListener('install', event =>
|
|||
)
|
||||
);
|
||||
|
||||
self.addEventListener('fetch', event => {
|
||||
self.addEventListener('fetch', (event) => {
|
||||
event.respondWith(
|
||||
caches.match(event.request.url).then(response => response || fetch(event.request))
|
||||
caches.match(event.request.url).then((response) => response || fetch(event.request))
|
||||
);
|
||||
});
|
||||
|
|
|
@ -293,6 +293,6 @@
|
|||
}
|
||||
|
||||
&__head-icon {
|
||||
margin-right: .2em;
|
||||
margin-right: 0.2em;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Typography
|
||||
$base-font-family: -apple-system, 'BlinkMacSystemFont', 'Segoe UI', 'Helvetica Neue', 'Helvetica', 'Roboto',
|
||||
'Arial', 'Microsoft YaHei', '微软雅黑', 'PingFang SC', 'Hiragino Sans GB', 'STXihei', '华文细黑',
|
||||
sans-serif;
|
||||
$base-font-family: -apple-system, 'BlinkMacSystemFont', 'Segoe UI', 'Helvetica Neue', 'Helvetica',
|
||||
'Roboto', 'Arial', 'Microsoft YaHei', '微软雅黑', 'PingFang SC', 'Hiragino Sans GB', 'STXihei',
|
||||
'华文细黑', sans-serif;
|
||||
$heading-font-family: $base-font-family;
|
||||
$monospace-font-family: 'SFMono-Regular', Monaco, Consolas, 'Lucida Console', monospace;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ module.exports = function(grunt) {
|
|||
if (cspIndex < 0) {
|
||||
grunt.warn(`Not found: ${type}-src`);
|
||||
}
|
||||
const digestsList = digests.map(digest => `'${algo}-${digest}'`).join(' ');
|
||||
const digestsList = digests.map((digest) => `'${algo}-${digest}'`).join(' ');
|
||||
htmlStr = htmlStr.replace(`${type}-src`, `${type}-src ${digestsList}`);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ module.exports = function(grunt) {
|
|||
targets: Platform[opt.targets.toUpperCase()].createTarget()
|
||||
})
|
||||
.then(done)
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
return grunt.warn('electron-builder returned an error: \n' + error);
|
||||
});
|
||||
});
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue