Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -1384,6 +1384,12 @@ <h3>
<h1>Please connect your OnlyKey</h1>
</dialog>

<dialog id="udev-dialog" class="silver-gradient-bg">
<h1>Error connecting</h1>
<h3>Do you need a UDEV rule?</h3>
<p>See the <u><a class="external" href="https://docs.onlykey.io/linux.html#udev-rule">OnlyKey for Linux docs</a></u> for more info.</p>
</dialog>

<dialog id="working-dialog" class="silver-gradient-bg">
<h1>Working...</h1>
<h2>Please wait</h2>
Expand Down
13 changes: 9 additions & 4 deletions app/scripts/external-links.js
Original file line number Diff line number Diff line change
@@ -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));
20 changes: 19 additions & 1 deletion app/scripts/onlyKey/OnlyKeyComm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1077,6 +1080,7 @@ var ui = {
lockedDialogDuo: null,
workingDialog: null,
disconnectedDialog: null,
udevDialog: null,
main: null,
};

Expand Down Expand Up @@ -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);
Expand Down