tooling check

This commit is contained in:
antelle 2020-04-19 20:42:55 +02:00
parent 4591268063
commit f79bb90b69
No known key found for this signature in database
GPG Key ID: 094A2F2D6136A4EE
5 changed files with 55 additions and 2 deletions

View File

@ -15,7 +15,8 @@ const Links = {
Donation: 'https://opencollective.com/keeweb#support',
Plugins: 'https://plugins.keeweb.info',
PluginDevelopStart: 'https://github.com/keeweb/keeweb/wiki/Plugins',
YubiKeyManual: 'https://github.com/keeweb/keeweb/wiki/YubiKey'
YubiKeyManual: 'https://github.com/keeweb/keeweb/wiki/YubiKey',
YubiKeyManagerInstall: 'https://github.com/Yubico/yubikey-manager#installation'
};
export { Links };

View File

@ -584,6 +584,13 @@
"setDevicesEnableUsb": "Enable interaction with USB devices",
"setDevicesYubiKeyIntro": "It's recommended to read {} before using YubiKey.",
"setDevicesYubiKeyIntroLink": "this document",
"setDevicesYubiKeyToolsTitle": "Tools",
"setDevicesYubiKeyToolsDesc": "To be able to use YubiKey integration, you need to install a tool called {}.",
"setDevicesYubiKeyToolsDesc2": "{} to get more information about this tool.",
"setDevicesYubiKeyToolsDescLink": "Click here",
"setDevicesYubiKeyToolsStatusChecking": "Checking if {} is installed",
"setDevicesYubiKeyToolsStatusOk": "{} is installed",
"setDevicesYubiKeyToolsStatusError": "{} is not installed or not working",
"setDevicesYubiKeyOtpTitle": "One-time codes",
"setDevicesYubiKeyOtpDesc": "YubiKey can be used to generate one-time codes for different services.",
"setDevicesYubiKeyOtpShowIcon": "Show the icon on the start screen",

View File

@ -3,6 +3,8 @@ import { ExternalOtpEntryModel } from 'models/external/external-otp-entry-model'
import { Launcher } from 'comp/launcher';
class YubiKeyOtpModel extends ExternalOtpDeviceModel {
ykmanStatus = null;
constructor(props) {
super({
shortName: 'YubiKey',
@ -73,6 +75,25 @@ class YubiKeyOtpModel extends ExternalOtpDeviceModel {
ps.kill();
}
}
static checkToolStatus() {
return new Promise(resolve => {
YubiKeyOtpModel.ykmanStatus = 'checking';
Launcher.spawn({
cmd: 'ykman',
args: ['-v'],
noStdOutLogging: true,
complete: (err, stdout, code) => {
if (err || code !== 0) {
YubiKeyOtpModel.ykmanStatus = 'error';
} else {
YubiKeyOtpModel.ykmanStatus = 'ok';
}
resolve();
}
});
});
}
}
YubiKeyOtpModel.defineModelProperties({

View File

@ -1,5 +1,6 @@
import { View } from 'framework/views/view';
import { AppSettingsModel } from 'models/app-settings-model';
import { YubiKeyOtpModel } from 'models/external/yubikey-otp-model';
import template from 'templates/settings/settings-devices.hbs';
import { Links } from 'const/links';
@ -14,14 +15,27 @@ class SettingsDevicesView extends View {
'change .settings__yubikey-chalresp-show': 'changeYubiKeyShowChalResp'
};
constructor(...args) {
super(...args);
if (!['ok', 'checking'].includes(YubiKeyOtpModel.ykmanStatus)) {
this.toolCheckPromise = YubiKeyOtpModel.checkToolStatus();
}
}
render() {
if (this.toolCheckPromise) {
this.toolCheckPromise.then(() => this.render());
this.toolCheckPromise = undefined;
}
super.render({
enableUsb: AppSettingsModel.enableUsb,
ykmanStatus: YubiKeyOtpModel.ykmanStatus,
yubiKeyShowIcon: AppSettingsModel.yubiKeyShowIcon,
yubiKeyAutoOpen: AppSettingsModel.yubiKeyAutoOpen,
yubiKeyMatchEntries: AppSettingsModel.yubiKeyMatchEntries,
yubiKeyShowChalResp: AppSettingsModel.yubiKeyShowChalResp,
yubiKeyManualLink: Links.YubiKeyManual
yubiKeyManualLink: Links.YubiKeyManual,
ykmanInstallLink: Links.YubiKeyManagerInstall
});
}

View File

@ -9,6 +9,16 @@
{{#if enableUsb}}
<h2>YubiKey</h2>
<p>{{#res 'setDevicesYubiKeyIntro'}}<a href="{{yubiKeyManualLink}}" target="_blank">{{res 'setDevicesYubiKeyIntroLink'}}</a>{{/res}}</p>
<h3>{{res 'setDevicesYubiKeyToolsTitle'}}</h3>
<p>
{{#res 'setDevicesYubiKeyToolsDesc'}}<code>ykman</code>{{/res}}
{{#res 'setDevicesYubiKeyToolsDesc2'}}<a href="{{ykmanInstallLink}}" target="_blank">{{res 'setDevicesYubiKeyToolsDescLink'}}</a>{{/res}}
</p>
<div>
{{#ifeq ykmanStatus 'checking'}}{{#res 'setDevicesYubiKeyToolsStatusChecking'}}<code>ykman</code>{{/res}}...{{/ifeq}}
{{#ifeq ykmanStatus 'ok'}}{{#res 'setDevicesYubiKeyToolsStatusOk'}}<code>ykman</code>{{/res}}{{/ifeq}}
{{#ifeq ykmanStatus 'error'}}{{#res 'setDevicesYubiKeyToolsStatusError'}}<code>ykman</code>{{/res}}{{/ifeq}}
</div>
<h3>{{res 'setDevicesYubiKeyOtpTitle'}}</h3>
<p>{{res 'setDevicesYubiKeyOtpDesc'}}</p>
<div>