@ledgerhq/hw-transport-http
Advanced tools
Comparing version 2.0.5 to 2.1.0
@@ -33,3 +33,3 @@ "use strict"; | ||
if (response.status !== 200) { | ||
throw new Error("failed to access HttpTransport(" + url + "): status " + response.status); | ||
throw new _hwTransport.TransportError("failed to access HttpTransport(" + url + "): status " + response.status, "HttpTransportNotAccessible"); | ||
} | ||
@@ -67,3 +67,3 @@ return new HttpTransport(url); | ||
if (response.status !== 200) { | ||
throw "failed to communicate to server. code=" + response.status; | ||
throw new _hwTransport.TransportError("failed to communicate to server. code=" + response.status, "HttpTransportStatus" + response.status); | ||
} | ||
@@ -70,0 +70,0 @@ const body = yield response.json(); |
@@ -26,3 +26,2 @@ "use strict"; | ||
if (unsubscribed) return; | ||
// $FlowFixMe wtf flow | ||
observer.next({ type: "add", descriptor: url }); | ||
@@ -29,0 +28,0 @@ observer.complete(); |
{ | ||
"name": "@ledgerhq/hw-transport-http", | ||
"version": "2.0.5", | ||
"version": "2.1.0", | ||
"description": "Ledger Hardware Wallet communication layer over http", | ||
@@ -28,3 +28,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@ledgerhq/hw-transport": "^2.0.5" | ||
"@ledgerhq/hw-transport": "^2.1.0" | ||
}, | ||
@@ -31,0 +31,0 @@ "devDependencies": { |
//@flow | ||
import Transport from "@ledgerhq/hw-transport"; | ||
import Transport, { TransportError } from "@ledgerhq/hw-transport"; | ||
import withStaticURL from "./withStaticURL"; | ||
@@ -20,4 +20,8 @@ export { withStaticURL }; | ||
if (response.status !== 200) { | ||
throw new Error( | ||
"failed to access HttpTransport(" + url + "): status " + response.status | ||
throw new TransportError( | ||
"failed to access HttpTransport(" + | ||
url + | ||
"): status " + | ||
response.status, | ||
"HttpTransportNotAccessible" | ||
); | ||
@@ -54,3 +58,6 @@ } | ||
if (response.status !== 200) { | ||
throw "failed to communicate to server. code=" + response.status; | ||
throw new TransportError( | ||
"failed to communicate to server. code=" + response.status, | ||
"HttpTransportStatus" + response.status | ||
); | ||
} | ||
@@ -57,0 +64,0 @@ const body = await response.json(); |
// @flow | ||
import HttpTransport from "./HttpTransport"; | ||
import type { | ||
Observer, | ||
DescriptorEvent, | ||
Subscription | ||
} from "@ledgerhq/hw-transport"; | ||
export default (urlArg: ?string): Class<HttpTransport> => { | ||
@@ -7,4 +13,8 @@ const url = urlArg; | ||
class StaticHttpTransport extends HttpTransport { | ||
static list = (): * => HttpTransport.open(url).then(() => [url], () => []); | ||
static listen = (observer: *) => { | ||
static list = (): Promise<string[]> => | ||
HttpTransport.open(url).then(() => [url], () => []); | ||
static listen = ( | ||
observer: Observer<DescriptorEvent<string>> | ||
): Subscription => { | ||
let unsubscribed = false; | ||
@@ -16,3 +26,2 @@ function attemptToConnect() { | ||
if (unsubscribed) return; | ||
// $FlowFixMe wtf flow | ||
observer.next({ type: "add", descriptor: url }); | ||
@@ -19,0 +28,0 @@ observer.complete(); |
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
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
25038
14
409