Skip to content
This repository has been archived by the owner on Aug 7, 2019. It is now read-only.

Add try/catch to releaseInterface in case we can't release before disconnect #21

Merged
merged 1 commit into from
Jan 30, 2019
Merged
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
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@keepkey/keepkey.js",
"version": "1.1.1",
"version": "1.1.2",
"description": "",
"keywords": [
"crypto",
Expand Down Expand Up @@ -29,9 +29,12 @@
"copy:protos": "cp ./node_modules/device-protocol/exchange.proto ./node_modules/device-protocol/types.proto ./node_modules/device-protocol/messages.proto .",
"gen:protos": "protoc --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts --js_out=import_style=commonjs,binary:./src/kkProto --ts_out=./src/kkProto exchange.proto types.proto messages.proto",
"build:json": "pbjs --keep-case -t json ./node_modules/device-protocol/types.proto ./node_modules/device-protocol/messages.proto ./node_modules/device-protocol/exchange.proto > ./src/proto.json",
"build": "tsc --module commonjs && rollup -c rollup.config.ts && rollup -c rollup.browser.ts && typedoc --out docs --target es6 --theme minimal --mode file src && cp -r src/kkProto src/proto.json ./dist/lib",
"dev": "rollup -c rollup.config.ts -w",
"build": "tsc --module commonjs && rollup -c rollup.config.ts && yarn build:browser && typedoc --out docs --target es6 --theme minimal --mode file src && cp -r src/kkProto src/proto.json ./dist/lib",
"build:browser": "rollup -c rollup.browser.ts",
"dev": "yarn build && rollup -c rollup.config.ts -w",
"dev:example": "rollup -c rollup.browser.ts -w -o example/js/vendor/keepkey.browser.js",
"dev:browser": "yarn build && rollup -c rollup.browser.ts -w",
"dev:browser:custom": "rollup -c rollup.browser.ts -w -o $OUT/keepkey.browser.js",
"test": "jest",
"test:watch": "jest --watch",
"test:prod": "npm run lint && npm run test -- --coverage --no-cache",
Expand Down
7 changes: 6 additions & 1 deletion src/webUSBDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ export default class WebUSBDevice extends Device {

public async disconnect (): Promise<void> {
if (!this.usbDevice.opened) return
return this.usbDevice.releaseInterface(0)
try {
// If the device is disconnected, this will fail and throw, which is fine.
await this.usbDevice.releaseInterface(0)
} catch (e) {
console.log(e)
keepkeyjon marked this conversation as resolved.
Show resolved Hide resolved
}
}

public getEntropy (length: number = 64): Uint8Array {
Expand Down