@ledgerhq/hw-transport-node-speculos-http
Advanced tools
Comparing version 6.27.14 to 6.27.15-next.0
# @ledgerhq/hw-transport-node-speculos-http | ||
## 6.27.15-next.0 | ||
### Patch Changes | ||
- Updated dependencies [[`77f990e207`](https://github.com/LedgerHQ/ledger-live/commit/77f990e2075c7c9a4be69b364e3754b449c7a546)]: | ||
- @ledgerhq/errors@6.12.6-next.0 | ||
- @ledgerhq/hw-transport@6.28.4-next.0 | ||
## 6.27.14 | ||
@@ -4,0 +12,0 @@ |
/// <reference types="node" /> | ||
import { AxiosInstance } from "axios"; | ||
import Transport from "@ledgerhq/hw-transport"; | ||
import { Subject } from "rxjs"; | ||
export type SpeculosHttpTransportOpts = { | ||
apiPort?: string; | ||
timeout?: number; | ||
baseURL?: string; | ||
timeout?: number; | ||
}; | ||
@@ -20,2 +22,3 @@ /** | ||
eventStream: any; | ||
automationEvents: Subject<Record<string, any>>; | ||
constructor(instance: AxiosInstance, opts: SpeculosHttpTransportOpts); | ||
@@ -27,2 +30,7 @@ static isSupported: () => Promise<boolean>; | ||
}; | ||
buttonTable: { | ||
LRlr: string; | ||
Rr: string; | ||
Ll: string; | ||
}; | ||
static open: (opts: SpeculosHttpTransportOpts) => Promise<SpeculosHttpTransport>; | ||
@@ -29,0 +37,0 @@ /** |
@@ -14,2 +14,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import { log } from "@ledgerhq/logs"; | ||
import { Subject } from "rxjs"; | ||
var SpeculosButton; | ||
(function (SpeculosButton) { | ||
SpeculosButton["LEFT"] = "Ll"; | ||
SpeculosButton["RIGHT"] = "Rr"; | ||
SpeculosButton["BOTH"] = "LRlr"; | ||
})(SpeculosButton || (SpeculosButton = {})); | ||
/** | ||
@@ -26,2 +33,8 @@ * Speculos TCP transport implementation | ||
super(); | ||
this.automationEvents = new Subject(); | ||
this.buttonTable = { | ||
[SpeculosButton.BOTH]: "both", | ||
[SpeculosButton.RIGHT]: "right", | ||
[SpeculosButton.LEFT]: "left", | ||
}; | ||
/** | ||
@@ -33,6 +46,7 @@ * Press and release button | ||
this.button = (but) => new Promise((resolve, reject) => { | ||
const action = { action: "press-and-release" }; | ||
log("speculos-button", "press-and-release", but); | ||
var _a; | ||
const input = (_a = this.buttonTable[but]) !== null && _a !== void 0 ? _a : but; | ||
log("speculos-button", "press-and-release", input); | ||
this.instance | ||
.post(`/button/${but}`, action) | ||
.post(`/button/${input}`, { action: "press-and-release" }) | ||
.then((response) => { | ||
@@ -75,4 +89,6 @@ resolve(response.data); | ||
SpeculosHttpTransport.open = (opts) => new Promise((resolve, reject) => { | ||
const instance = axios.create(opts); | ||
instance.defaults.baseURL = "http://localhost:5000"; | ||
const instance = axios.create({ | ||
baseURL: `http://localhost:${opts.apiPort || "5000"}`, | ||
timeout: opts.timeout, | ||
}); | ||
const transport = new SpeculosHttpTransport(instance, opts); | ||
@@ -86,4 +102,5 @@ instance({ | ||
log("speculos-event", chunk.toString()); | ||
// XXX: we could process display events here | ||
// client side automation or UI tests/checks | ||
const split = chunk.toString().replace("data: ", ""); | ||
const json = JSON.parse(split); | ||
transport.automationEvents.next(json); | ||
}); | ||
@@ -90,0 +107,0 @@ response.data.on("close", () => { |
/// <reference types="node" /> | ||
import { AxiosInstance } from "axios"; | ||
import Transport from "@ledgerhq/hw-transport"; | ||
import { Subject } from "rxjs"; | ||
export type SpeculosHttpTransportOpts = { | ||
apiPort?: string; | ||
timeout?: number; | ||
baseURL?: string; | ||
timeout?: number; | ||
}; | ||
@@ -20,2 +22,3 @@ /** | ||
eventStream: any; | ||
automationEvents: Subject<Record<string, any>>; | ||
constructor(instance: AxiosInstance, opts: SpeculosHttpTransportOpts); | ||
@@ -27,2 +30,7 @@ static isSupported: () => Promise<boolean>; | ||
}; | ||
buttonTable: { | ||
LRlr: string; | ||
Rr: string; | ||
Ll: string; | ||
}; | ||
static open: (opts: SpeculosHttpTransportOpts) => Promise<SpeculosHttpTransport>; | ||
@@ -29,0 +37,0 @@ /** |
@@ -19,2 +19,9 @@ "use strict"; | ||
const logs_1 = require("@ledgerhq/logs"); | ||
const rxjs_1 = require("rxjs"); | ||
var SpeculosButton; | ||
(function (SpeculosButton) { | ||
SpeculosButton["LEFT"] = "Ll"; | ||
SpeculosButton["RIGHT"] = "Rr"; | ||
SpeculosButton["BOTH"] = "LRlr"; | ||
})(SpeculosButton || (SpeculosButton = {})); | ||
/** | ||
@@ -31,2 +38,8 @@ * Speculos TCP transport implementation | ||
super(); | ||
this.automationEvents = new rxjs_1.Subject(); | ||
this.buttonTable = { | ||
[SpeculosButton.BOTH]: "both", | ||
[SpeculosButton.RIGHT]: "right", | ||
[SpeculosButton.LEFT]: "left", | ||
}; | ||
/** | ||
@@ -38,6 +51,7 @@ * Press and release button | ||
this.button = (but) => new Promise((resolve, reject) => { | ||
const action = { action: "press-and-release" }; | ||
(0, logs_1.log)("speculos-button", "press-and-release", but); | ||
var _a; | ||
const input = (_a = this.buttonTable[but]) !== null && _a !== void 0 ? _a : but; | ||
(0, logs_1.log)("speculos-button", "press-and-release", input); | ||
this.instance | ||
.post(`/button/${but}`, action) | ||
.post(`/button/${input}`, { action: "press-and-release" }) | ||
.then((response) => { | ||
@@ -81,4 +95,6 @@ resolve(response.data); | ||
SpeculosHttpTransport.open = (opts) => new Promise((resolve, reject) => { | ||
const instance = axios_1.default.create(opts); | ||
instance.defaults.baseURL = "http://localhost:5000"; | ||
const instance = axios_1.default.create({ | ||
baseURL: `http://localhost:${opts.apiPort || "5000"}`, | ||
timeout: opts.timeout, | ||
}); | ||
const transport = new SpeculosHttpTransport(instance, opts); | ||
@@ -92,4 +108,5 @@ instance({ | ||
(0, logs_1.log)("speculos-event", chunk.toString()); | ||
// XXX: we could process display events here | ||
// client side automation or UI tests/checks | ||
const split = chunk.toString().replace("data: ", ""); | ||
const json = JSON.parse(split); | ||
transport.automationEvents.next(json); | ||
}); | ||
@@ -96,0 +113,0 @@ response.data.on("close", () => { |
{ | ||
"name": "@ledgerhq/hw-transport-node-speculos-http", | ||
"version": "6.27.14", | ||
"version": "6.27.15-next.0", | ||
"description": "Ledger Hardware Wallet communication layer with speculos Nano simulator using the http api", | ||
@@ -32,4 +32,5 @@ "keywords": [ | ||
"axios": "^0.26.1", | ||
"@ledgerhq/errors": "^6.12.5", | ||
"@ledgerhq/hw-transport": "^6.28.3", | ||
"rxjs": "6", | ||
"@ledgerhq/errors": "^6.12.6-next.0", | ||
"@ledgerhq/hw-transport": "^6.28.4-next.0", | ||
"@ledgerhq/logs": "^6.10.1" | ||
@@ -36,0 +37,0 @@ }, |
@@ -6,8 +6,16 @@ import axios from "axios"; | ||
import { log } from "@ledgerhq/logs"; | ||
import { Subject } from "rxjs"; | ||
export type SpeculosHttpTransportOpts = { | ||
apiPort?: string; | ||
timeout?: number; | ||
baseURL?: string; | ||
timeout?: number; | ||
}; | ||
enum SpeculosButton { | ||
LEFT = "Ll", | ||
RIGHT = "Rr", | ||
BOTH = "LRlr", | ||
} | ||
/** | ||
@@ -25,2 +33,3 @@ * Speculos TCP transport implementation | ||
eventStream: any; // ReadStream? | ||
automationEvents: Subject<Record<string, any>> = new Subject(); | ||
@@ -40,2 +49,8 @@ constructor(instance: AxiosInstance, opts: SpeculosHttpTransportOpts) { | ||
buttonTable = { | ||
[SpeculosButton.BOTH]: "both", | ||
[SpeculosButton.RIGHT]: "right", | ||
[SpeculosButton.LEFT]: "left", | ||
}; | ||
static open = ( | ||
@@ -45,4 +60,6 @@ opts: SpeculosHttpTransportOpts | ||
new Promise((resolve, reject) => { | ||
const instance = axios.create(opts); | ||
instance.defaults.baseURL = "http://localhost:5000"; | ||
const instance = axios.create({ | ||
baseURL: `http://localhost:${opts.apiPort || "5000"}`, | ||
timeout: opts.timeout, | ||
}); | ||
@@ -58,4 +75,5 @@ const transport = new SpeculosHttpTransport(instance, opts); | ||
log("speculos-event", chunk.toString()); | ||
// XXX: we could process display events here | ||
// client side automation or UI tests/checks | ||
const split = chunk.toString().replace("data: ", ""); | ||
const json = JSON.parse(split); | ||
transport.automationEvents.next(json); | ||
}); | ||
@@ -85,6 +103,6 @@ response.data.on("close", () => { | ||
new Promise((resolve, reject) => { | ||
const action = { action: "press-and-release" }; | ||
log("speculos-button", "press-and-release", but); | ||
const input = this.buttonTable[but] ?? but; | ||
log("speculos-button", "press-and-release", input); | ||
this.instance | ||
.post(`/button/${but}`, action) | ||
.post(`/button/${input}`, { action: "press-and-release" }) | ||
.then((response) => { | ||
@@ -91,0 +109,0 @@ resolve(response.data); |
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
36696
444
5
1
+ Addedrxjs@6
+ Addedrxjs@6.6.7(transitive)
+ Addedtslib@1.14.1(transitive)