fix #1744, fix #1743: fixed crashes in the USB module on Windows

pull/1769/head
antelle 2 years ago
parent f74b054f01
commit b8dd7b0f71
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C

@ -38,7 +38,7 @@
<h3>Desktop modules</h3>
<ul>
<li><a href="https://github.com/ranisalt/node-argon2" target="_blank">node-argon2</a><span class="muted-color">, node.js bindings for Argon2 hashing algorithm, &copy; 2015 Ranieri Althoff</span></li>
<li><a href="https://github.com/tessel/node-usb" target="_blank">node-usb</a><span class="muted-color">, improved USB library for Node.js, &copy; 2012 Nonolith Labs, LLC</span></li>
<li><a href="https://github.com/MadLittleMods/node-usb-detectoin" target="_blank">node-usb-detection</a><span class="muted-color">, list USB devices in system and detect changes on them, &copy; 2013 Kaba AG</span></li>
<li><a href="https://github.com/atom/node-keytar" target="_blank">node-keytar</a><span class="muted-color">, native password node module, &copy; 2013 GitHub Inc.</span></li>
<li><a href="https://github.com/antelle/node-yubikey-chalresp" target="_blank">node-yubikey-chalresp</a><span class="muted-color">, YubiKey challenge-response API for node.js, &copy; 2020 Antelle</span></li>
<li><a href="https://github.com/antelle/node-secure-enclave" target="_blank">node-secure-enclave</a><span class="muted-color">, Secure Enclave module for node.js and Electron, &copy; 2020 Antelle</span></li>

@ -15,14 +15,14 @@ const messageHandlers = {
return;
}
const usb = reqNative('usb');
const usbDetection = reqNative('usb-detection');
fillAttachedYubiKeys();
usb.on('attach', usbDeviceAttached);
usb.on('detach', usbDeviceDetached);
usbDetection.registerAdded(usbDeviceAttached);
usbDetection.registerRemoved(usbDeviceDetached);
usb._enableHotplugEvents();
usbDetection.startMonitoring();
usbListenerRunning = true;
},
@ -32,12 +32,9 @@ const messageHandlers = {
return;
}
const usb = reqNative('usb');
const usbDetection = reqNative('usb-detection');
usb.off('attach', usbDeviceAttached);
usb.off('detach', usbDeviceDetached);
usb._disableHotplugEvents();
usbDetection.stopMonitoring();
usbListenerRunning = false;
attachedYubiKeys.length = 0;
@ -149,7 +146,7 @@ const messageHandlers = {
};
function isYubiKey(device) {
return YubiKeyVendorIds.includes(device.deviceDescriptor.idVendor);
return YubiKeyVendorIds.includes(device.vendorId);
}
function usbDeviceAttached(device) {
@ -170,9 +167,14 @@ function usbDeviceDetached(device) {
}
function fillAttachedYubiKeys() {
const usb = reqNative('usb');
attachedYubiKeys.push(...usb.getDeviceList().filter(isYubiKey));
reportYubiKeys();
const usbDetection = reqNative('usb-detection');
usbDetection.find((err, devices) => {
if (!err && devices) {
attachedYubiKeys.push(...devices.filter(isYubiKey));
reportYubiKeys();
}
return undefined;
});
}
function reportYubiKeys() {
@ -291,6 +293,11 @@ function startInMain(channel) {
callback = (cmd, ...args) => {
channel.emit('message', { cmd, args });
};
const { app } = require('electron');
app.on('will-quit', () => {
messageHandlers.stopUsbListener();
});
}
module.exports = { startInOwnProcess, startInMain };

75340
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -16,7 +16,7 @@
"@babel/plugin-proposal-optional-chaining": "^7.13.8",
"@babel/preset-env": "^7.13.9",
"@fortawesome/fontawesome-free": "^5.15.2",
"@keeweb/keeweb-native-modules": "https://github.com/keeweb/keeweb-native-modules/releases/download/0.9.3/keeweb-native-modules.tgz",
"@keeweb/keeweb-native-modules": "https://github.com/keeweb/keeweb-native-modules/releases/download/0.10.2/keeweb-native-modules.tgz",
"adm-zip": "^0.5.3",
"argon2-browser": "1.15.3",
"autoprefixer": "^10.2.5",

@ -1,5 +1,8 @@
Release notes
-------------
##### v1.17.2 (TBD)
`-` fixed crashes in the USB module on Windows
##### v1.17.1 (2021-03-10)
`-` fix #1735: issue with auto-typing some characters on Windows

Loading…
Cancel
Save