diff --git a/app/app.html b/app/app.html index dd1038f..c8b659d 100644 --- a/app/app.html +++ b/app/app.html @@ -1384,6 +1384,12 @@

Please connect your OnlyKey

+ +

Error connecting

+

Do you need a UDEV rule?

+

See the OnlyKey for Linux docs for more info.

+
+

Working...

Please wait

diff --git a/app/scripts/external-links.js b/app/scripts/external-links.js index edbed9f..12b0be1 100644 --- a/app/scripts/external-links.js +++ b/app/scripts/external-links.js @@ -1,14 +1,19 @@ const openMethod = typeof nw === 'undefined' ? window.open : nw.Shell.openExternal; -// Formerly checked for 'external' in classList. Now fires for all https:// links. -document.querySelector('#main').addEventListener('click', evt => { +const handler = evt => { let href = evt.target && evt.target.href; if (!href) href = evt.target && evt.target.offsetParent && evt.target.offsetParent.href; if (!href) href = evt.path && evt.path[1] && evt.path[1].href; - + + // Formerly checked for 'external' in classList. Now fires for all https:// links. if (!!href && href.indexOf('https://') == 0) { openMethod(href); evt.preventDefault && evt.preventDefault(); evt.stopPropgation && evt.stopPropagation(); } -}); +}; + +[ + '#main', + '#udev-dialog', +].forEach(sel => document.querySelector(sel).addEventListener('click', handler)); diff --git a/app/scripts/onlyKey/OnlyKeyComm.js b/app/scripts/onlyKey/OnlyKeyComm.js index b112210..79c8d99 100644 --- a/app/scripts/onlyKey/OnlyKeyComm.js +++ b/app/scripts/onlyKey/OnlyKeyComm.js @@ -6,6 +6,9 @@ if (desktopApp) { request = require("request"); } +const os = require('os'); +const linux = os.platform() === 'linux'; + let backupsigFlag = -1; let fwchecked = false; let dialog; @@ -1077,6 +1080,7 @@ var ui = { lockedDialogDuo: null, workingDialog: null, disconnectedDialog: null, + udevDialog: null, main: null, }; @@ -1267,9 +1271,23 @@ var connectDevice = async function (device) { chromeHid.connect(deviceId, async function (connectInfo) { if (chrome.runtime.lastError) { - console.error("ERROR CONNECTING:", chrome.runtime.lastError); + console.error(`ERROR CONNECTING: ${chrome.runtime.lastError.message}`, device); + if (linux) { + dialog.open(ui.udevDialog); + } else { + if (confirm(`ERROR: ${chrome.runtime.lastError.message}\n\nRetry?`)) { + return await connectDevice(device); + } + } } else if (!connectInfo) { console.warn("Unable to connect to device."); + if (confirm(`ERROR: Unable to read device info.\n\nRetry?`)) { + return await connectDevice(device); + } + } + + if (!connectInfo) { + return; } myOnlyKey.setConnection(connectInfo.connectionId);