@ledgerhq/hw-transport-webusb
Advanced tools
Comparing version 6.27.15 to 6.27.16-nightly.0
# @ledgerhq/hw-transport-webusb | ||
## 6.27.16-nightly.0 | ||
### Patch Changes | ||
- Updated dependencies [[`9adc1862dd`](https://github.com/LedgerHQ/ledger-live/commit/9adc1862dda605a722d19f3b6895bd324834c914)]: | ||
- @ledgerhq/errors@6.12.7-nightly.0 | ||
- @ledgerhq/devices@8.0.4-nightly.0 | ||
- @ledgerhq/hw-transport@6.28.5-nightly.0 | ||
## 6.27.15 | ||
@@ -4,0 +13,0 @@ |
@@ -15,3 +15,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import { TransportOpenUserCancelled, TransportInterfaceNotAvailable, TransportWebUSBGestureRequired, DisconnectedDeviceDuringOperation, DisconnectedDevice, } from "@ledgerhq/errors"; | ||
import { getLedgerDevices, getFirstLedgerDevice, requestLedgerDevice, isSupported, } from "./webusb"; | ||
import { getLedgerDevices, getFirstLedgerDevice, requestLedgerDevice, isSupported } from "./webusb"; | ||
const configurationValue = 1; | ||
@@ -72,3 +72,3 @@ const endpointNumber = 3; | ||
yield gracefullyResetDevice(device); | ||
const iface = device.configurations[0].interfaces.find(({ alternates }) => alternates.some((a) => a.interfaceClass === 255)); | ||
const iface = device.configurations[0].interfaces.find(({ alternates }) => alternates.some(a => a.interfaceClass === 255)); | ||
if (!iface) { | ||
@@ -86,3 +86,3 @@ throw new TransportInterfaceNotAvailable("No WebUSB interface found for your Ledger device. Please upgrade firmware or contact techsupport."); | ||
const transport = new TransportWebUSB(device, interfaceNumber); | ||
const onDisconnect = (e) => { | ||
const onDisconnect = e => { | ||
if (device === e.device) { | ||
@@ -138,3 +138,3 @@ // $FlowFixMe | ||
return result; | ||
})).catch((e) => { | ||
})).catch(e => { | ||
if (e && e.message && e.message.includes("disconnected")) { | ||
@@ -167,3 +167,3 @@ this._emitDisconnect(e); | ||
let unsubscribed = false; | ||
getFirstLedgerDevice().then((device) => { | ||
getFirstLedgerDevice().then(device => { | ||
if (!unsubscribed) { | ||
@@ -178,6 +178,4 @@ const deviceModel = identifyUSBProductId(device.productId); | ||
} | ||
}, (error) => { | ||
if (window.DOMException && | ||
error instanceof window.DOMException && | ||
error.code === 18) { | ||
}, error => { | ||
if (window.DOMException && error instanceof window.DOMException && error.code === 18) { | ||
observer.error(new TransportWebUSBGestureRequired(error.message)); | ||
@@ -184,0 +182,0 @@ } |
@@ -27,3 +27,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
const devices = yield navigator.usb.getDevices(); | ||
return devices.filter((d) => d.vendorId === ledgerUSBVendorId); | ||
return devices.filter(d => d.vendorId === ledgerUSBVendorId); | ||
}); | ||
@@ -39,5 +39,3 @@ } | ||
} | ||
export const isSupported = () => Promise.resolve(!!navigator && | ||
!!navigator.usb && | ||
typeof navigator.usb.getDevices === "function"); | ||
export const isSupported = () => Promise.resolve(!!navigator && !!navigator.usb && typeof navigator.usb.getDevices === "function"); | ||
//# sourceMappingURL=webusb.js.map |
@@ -76,3 +76,3 @@ "use strict"; | ||
yield gracefullyResetDevice(device); | ||
const iface = device.configurations[0].interfaces.find(({ alternates }) => alternates.some((a) => a.interfaceClass === 255)); | ||
const iface = device.configurations[0].interfaces.find(({ alternates }) => alternates.some(a => a.interfaceClass === 255)); | ||
if (!iface) { | ||
@@ -90,3 +90,3 @@ throw new errors_1.TransportInterfaceNotAvailable("No WebUSB interface found for your Ledger device. Please upgrade firmware or contact techsupport."); | ||
const transport = new TransportWebUSB(device, interfaceNumber); | ||
const onDisconnect = (e) => { | ||
const onDisconnect = e => { | ||
if (device === e.device) { | ||
@@ -142,3 +142,3 @@ // $FlowFixMe | ||
return result; | ||
})).catch((e) => { | ||
})).catch(e => { | ||
if (e && e.message && e.message.includes("disconnected")) { | ||
@@ -172,3 +172,3 @@ this._emitDisconnect(e); | ||
let unsubscribed = false; | ||
(0, webusb_1.getFirstLedgerDevice)().then((device) => { | ||
(0, webusb_1.getFirstLedgerDevice)().then(device => { | ||
if (!unsubscribed) { | ||
@@ -183,6 +183,4 @@ const deviceModel = (0, devices_1.identifyUSBProductId)(device.productId); | ||
} | ||
}, (error) => { | ||
if (window.DOMException && | ||
error instanceof window.DOMException && | ||
error.code === 18) { | ||
}, error => { | ||
if (window.DOMException && error instanceof window.DOMException && error.code === 18) { | ||
observer.error(new errors_1.TransportWebUSBGestureRequired(error.message)); | ||
@@ -189,0 +187,0 @@ } |
@@ -31,3 +31,3 @@ "use strict"; | ||
const devices = yield navigator.usb.getDevices(); | ||
return devices.filter((d) => d.vendorId === devices_1.ledgerUSBVendorId); | ||
return devices.filter(d => d.vendorId === devices_1.ledgerUSBVendorId); | ||
}); | ||
@@ -45,6 +45,4 @@ } | ||
exports.getFirstLedgerDevice = getFirstLedgerDevice; | ||
const isSupported = () => Promise.resolve(!!navigator && | ||
!!navigator.usb && | ||
typeof navigator.usb.getDevices === "function"); | ||
const isSupported = () => Promise.resolve(!!navigator && !!navigator.usb && typeof navigator.usb.getDevices === "function"); | ||
exports.isSupported = isSupported; | ||
//# sourceMappingURL=webusb.js.map |
{ | ||
"name": "@ledgerhq/hw-transport-webusb", | ||
"version": "6.27.15", | ||
"version": "6.27.16-nightly.0", | ||
"description": "Ledger Hardware Wallet WebUSB implementation of the communication layer", | ||
@@ -29,5 +29,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@ledgerhq/devices": "^8.0.3", | ||
"@ledgerhq/errors": "^6.12.6", | ||
"@ledgerhq/hw-transport": "^6.28.4", | ||
"@ledgerhq/devices": "^8.0.4-nightly.0", | ||
"@ledgerhq/errors": "^6.12.7-nightly.0", | ||
"@ledgerhq/hw-transport": "^6.28.5-nightly.0", | ||
"@ledgerhq/logs": "^6.10.1" | ||
@@ -54,3 +54,3 @@ }, | ||
"doc": "documentation readme src/** --section=API --pe ts --re ts --re d.ts", | ||
"lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx", | ||
"lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache", | ||
"lint:fix": "pnpm lint --fix", | ||
@@ -57,0 +57,0 @@ "test": "jest" |
import Transport from "@ledgerhq/hw-transport"; | ||
import type { | ||
Observer, | ||
DescriptorEvent, | ||
Subscription, | ||
} from "@ledgerhq/hw-transport"; | ||
import type { Observer, DescriptorEvent, Subscription } from "@ledgerhq/hw-transport"; | ||
import hidFraming from "@ledgerhq/devices/hid-framing"; | ||
@@ -18,8 +14,3 @@ import { identifyUSBProductId } from "@ledgerhq/devices"; | ||
} from "@ledgerhq/errors"; | ||
import { | ||
getLedgerDevices, | ||
getFirstLedgerDevice, | ||
requestLedgerDevice, | ||
isSupported, | ||
} from "./webusb"; | ||
import { getLedgerDevices, getFirstLedgerDevice, requestLedgerDevice, isSupported } from "./webusb"; | ||
@@ -66,8 +57,6 @@ const configurationValue = 1; | ||
*/ | ||
static listen = ( | ||
observer: Observer<DescriptorEvent<USBDevice>> | ||
): Subscription => { | ||
static listen = (observer: Observer<DescriptorEvent<USBDevice>>): Subscription => { | ||
let unsubscribed = false; | ||
getFirstLedgerDevice().then( | ||
(device) => { | ||
device => { | ||
if (!unsubscribed) { | ||
@@ -83,8 +72,4 @@ const deviceModel = identifyUSBProductId(device.productId); | ||
}, | ||
(error) => { | ||
if ( | ||
window.DOMException && | ||
error instanceof window.DOMException && | ||
error.code === 18 | ||
) { | ||
error => { | ||
if (window.DOMException && error instanceof window.DOMException && error.code === 18) { | ||
observer.error(new TransportWebUSBGestureRequired(error.message)); | ||
@@ -94,3 +79,3 @@ } else { | ||
} | ||
} | ||
}, | ||
); | ||
@@ -136,3 +121,3 @@ | ||
const iface = device.configurations[0].interfaces.find(({ alternates }) => | ||
alternates.some((a) => a.interfaceClass === 255) | ||
alternates.some(a => a.interfaceClass === 255), | ||
); | ||
@@ -142,3 +127,3 @@ | ||
throw new TransportInterfaceNotAvailable( | ||
"No WebUSB interface found for your Ledger device. Please upgrade firmware or contact techsupport." | ||
"No WebUSB interface found for your Ledger device. Please upgrade firmware or contact techsupport.", | ||
); | ||
@@ -158,3 +143,3 @@ } | ||
const onDisconnect = (e) => { | ||
const onDisconnect = e => { | ||
if (device === e.device) { | ||
@@ -221,3 +206,3 @@ // $FlowFixMe | ||
return result; | ||
}).catch((e) => { | ||
}).catch(e => { | ||
if (e && e.message && e.message.includes("disconnected")) { | ||
@@ -224,0 +209,0 @@ this._emitDisconnect(e); |
@@ -18,3 +18,3 @@ import { ledgerUSBVendorId } from "@ledgerhq/devices"; | ||
const devices = await navigator.usb.getDevices(); | ||
return devices.filter((d) => d.vendorId === ledgerUSBVendorId); | ||
return devices.filter(d => d.vendorId === ledgerUSBVendorId); | ||
} | ||
@@ -29,6 +29,2 @@ | ||
export const isSupported = (): Promise<boolean> => | ||
Promise.resolve( | ||
!!navigator && | ||
!!navigator.usb && | ||
typeof navigator.usb.getDevices === "function" | ||
); | ||
Promise.resolve(!!navigator && !!navigator.usb && typeof navigator.usb.getDevices === "function"); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67214
840
1