@ledgerhq/hw-transport-http
Advanced tools
Comparing version 1.2.0-beta.b4ba11b7 to 1.2.0-beta.df091f88
@@ -53,3 +53,3 @@ "use strict"; | ||
exchange(apduHex, statusList) { | ||
exchange(apdu) { | ||
var _this = this; | ||
@@ -64,3 +64,3 @@ | ||
}, | ||
body: JSON.stringify({ apduHex, statusList }) | ||
body: JSON.stringify({ apduHex: apdu.toString("hex") }) | ||
}); | ||
@@ -86,5 +86,5 @@ if (response.status !== 200) { | ||
HttpTransport.discover = _observer => ({ | ||
HttpTransport.listen = _observer => ({ | ||
unsubscribe: () => {} | ||
}); | ||
//# sourceMappingURL=HttpTransport.js.map |
@@ -14,6 +14,8 @@ "use strict"; | ||
exports.default = url => { | ||
var _class, _temp; | ||
if (!url) return _HttpTransport2.default; // by default, HttpTransport don't yield anything in list/listen | ||
class StaticHttpTransport extends _HttpTransport2.default {} | ||
if (!url) return _HttpTransport2.default; // by default, HttpTransport don't yield anything in list/discover | ||
return _temp = _class = class StaticHttpTransport extends _HttpTransport2.default {}, _class.list = () => StaticHttpTransport.open(url).then(() => [url], () => []), _class.discover = observer => { | ||
StaticHttpTransport.list = () => _HttpTransport2.default.open(url).then(() => [url], () => []); | ||
StaticHttpTransport.listen = observer => { | ||
let unsubscribed = false; | ||
@@ -23,5 +25,5 @@ | ||
if (unsubscribed) return; | ||
StaticHttpTransport.open(url, 5000).then(() => { | ||
_HttpTransport2.default.open(url, 5000).then(() => { | ||
if (unsubscribed) return; | ||
observer.next(url); | ||
observer.next({ descriptor: url, type: "add" }); | ||
observer.complete(); | ||
@@ -39,4 +41,6 @@ }, () => { | ||
}; | ||
}, _temp; | ||
}; | ||
return StaticHttpTransport; | ||
}; | ||
//# sourceMappingURL=withStaticURL.js.map |
{ | ||
"name": "@ledgerhq/hw-transport-http", | ||
"version": "1.2.0-beta.b4ba11b7", | ||
"version": "1.2.0-beta.df091f88", | ||
"description": "Ledger Hardware Wallet communication layer over http", | ||
@@ -28,3 +28,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@ledgerhq/hw-transport": "^1.2.0-beta.b4ba11b7" | ||
"@ledgerhq/hw-transport": "^1.2.0-beta.df091f88" | ||
}, | ||
@@ -31,0 +31,0 @@ "devDependencies": { |
@@ -13,3 +13,3 @@ //@flow | ||
static list = (): * => Promise.resolve([]); | ||
static discover = (_observer: *) => ({ | ||
static listen = (_observer: *) => ({ | ||
unsubscribe: () => {} | ||
@@ -44,3 +44,3 @@ }); | ||
async exchange(apduHex: string, statusList: Array<number>): Promise<string> { | ||
async exchange(apdu: Buffer): Promise<Buffer> { | ||
const response = await fetch(this.url, { | ||
@@ -52,3 +52,3 @@ method: "POST", | ||
}, | ||
body: JSON.stringify({ apduHex, statusList }) | ||
body: JSON.stringify({ apduHex: apdu.toString("hex") }) | ||
}); | ||
@@ -55,0 +55,0 @@ if (response.status !== 200) { |
import HttpTransport from "./HttpTransport"; | ||
export default (url: ?string) => { | ||
if (!url) return HttpTransport; // by default, HttpTransport don't yield anything in list/discover | ||
return class StaticHttpTransport extends HttpTransport { | ||
static list = (): * => | ||
StaticHttpTransport.open(url).then(() => [url], () => []); | ||
static discover = (observer: *) => { | ||
if (!url) return HttpTransport; // by default, HttpTransport don't yield anything in list/listen | ||
class StaticHttpTransport extends HttpTransport { | ||
static list = (): * => HttpTransport.open(url).then(() => [url], () => []); | ||
static listen = (observer: *) => { | ||
let unsubscribed = false; | ||
@@ -12,6 +11,6 @@ | ||
if (unsubscribed) return; | ||
StaticHttpTransport.open(url, 5000).then( | ||
HttpTransport.open(url, 5000).then( | ||
() => { | ||
if (unsubscribed) return; | ||
observer.next(url); | ||
observer.next({ descriptor: url, type: "add" }); | ||
observer.complete(); | ||
@@ -32,3 +31,4 @@ }, | ||
}; | ||
}; | ||
} | ||
return StaticHttpTransport; | ||
}; |
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
23536
391