@ledgerhq/speculos-transport 0.1.8-nightly.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +33 -0
- package/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +4 -0
- package/CHANGELOG.md +132 -0
- package/LICENSE.txt +21 -0
- package/README.md +38 -0
- package/lib/index.d.ts +69 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +280 -0
- package/lib/index.js.map +1 -0
- package/lib-es/index.d.ts +69 -0
- package/lib-es/index.d.ts.map +1 -0
- package/lib-es/index.js +270 -0
- package/lib-es/index.js.map +1 -0
- package/package.json +59 -0
- package/src/index.ts +340 -0
- package/tsconfig.json +12 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
settings: {
|
|
3
|
+
react: {
|
|
4
|
+
version: "detect",
|
|
5
|
+
},
|
|
6
|
+
},
|
|
7
|
+
env: {
|
|
8
|
+
browser: true,
|
|
9
|
+
es6: true,
|
|
10
|
+
},
|
|
11
|
+
globals: {
|
|
12
|
+
Atomics: "readonly",
|
|
13
|
+
SharedArrayBuffer: "readonly",
|
|
14
|
+
},
|
|
15
|
+
extends: ["plugin:import/typescript", "plugin:jsx-a11y/recommended"],
|
|
16
|
+
plugins: ["import", "jsx-a11y"],
|
|
17
|
+
rules: {
|
|
18
|
+
"no-console": ["error", { allow: ["warn", "error"] }],
|
|
19
|
+
"linebreak-style": ["error", "unix"],
|
|
20
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
21
|
+
"@typescript-eslint/no-namespace": ["error", { allowDeclarations: true }],
|
|
22
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
23
|
+
},
|
|
24
|
+
overrides: [
|
|
25
|
+
{
|
|
26
|
+
files: ["src/**/*.test.{ts,tsx}"],
|
|
27
|
+
env: {
|
|
28
|
+
"jest/globals": true,
|
|
29
|
+
},
|
|
30
|
+
plugins: ["jest"],
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# @ledgerhq/speculos-transport
|
|
2
|
+
|
|
3
|
+
## 0.1.8-nightly.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`5c13c7b`](https://github.com/LedgerHQ/ledger-live/commit/5c13c7bf743333f09cbfee720d275dfae7e157d2)]:
|
|
8
|
+
- @ledgerhq/live-env@2.4.1-nightly.0
|
|
9
|
+
|
|
10
|
+
## 0.1.7
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`ced792c`](https://github.com/LedgerHQ/ledger-live/commit/ced792c37b42135f2b7596228c14ccd0783a803f)]:
|
|
15
|
+
- @ledgerhq/live-env@2.4.0
|
|
16
|
+
|
|
17
|
+
## 0.1.7-next.0
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [[`ced792c`](https://github.com/LedgerHQ/ledger-live/commit/ced792c37b42135f2b7596228c14ccd0783a803f)]:
|
|
22
|
+
- @ledgerhq/live-env@2.4.0-next.0
|
|
23
|
+
|
|
24
|
+
## 0.1.6
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [[`f805d14`](https://github.com/LedgerHQ/ledger-live/commit/f805d1470f927824233f94eaba065b00d7af18cf)]:
|
|
29
|
+
- @ledgerhq/hw-transport-node-speculos-http@6.29.4
|
|
30
|
+
- @ledgerhq/devices@8.4.4
|
|
31
|
+
- @ledgerhq/hw-transport-node-speculos@6.29.4
|
|
32
|
+
|
|
33
|
+
## 0.1.6-next.1
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [[`f805d14`](https://github.com/LedgerHQ/ledger-live/commit/f805d1470f927824233f94eaba065b00d7af18cf)]:
|
|
38
|
+
- @ledgerhq/hw-transport-node-speculos-http@6.29.4-next.1
|
|
39
|
+
|
|
40
|
+
## 0.1.6-next.0
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- Updated dependencies []:
|
|
45
|
+
- @ledgerhq/devices@8.4.4-next.0
|
|
46
|
+
- @ledgerhq/hw-transport-node-speculos@6.29.4-next.0
|
|
47
|
+
- @ledgerhq/hw-transport-node-speculos-http@6.29.4-next.0
|
|
48
|
+
|
|
49
|
+
## 0.1.5
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- [#7672](https://github.com/LedgerHQ/ledger-live/pull/7672) [`fb9466a`](https://github.com/LedgerHQ/ledger-live/commit/fb9466a4d7827fd4759c726ad3ae0b43dddcacd3) Thanks [@hzheng-ledger](https://github.com/hzheng-ledger)! - Add support for jettons
|
|
54
|
+
|
|
55
|
+
- Updated dependencies [[`187293c`](https://github.com/LedgerHQ/ledger-live/commit/187293c6cf6093f15f07d5effc1ded0843a9e6ab), [`5758950`](https://github.com/LedgerHQ/ledger-live/commit/5758950841fbf8018dd848e745017484aec67333), [`4799d5d`](https://github.com/LedgerHQ/ledger-live/commit/4799d5de3fb1dcef2b01de31fe29b59e76922576), [`eb9a36f`](https://github.com/LedgerHQ/ledger-live/commit/eb9a36f6ee8487c9ffbb841c3e6c0ca84f68bb0a)]:
|
|
56
|
+
- @ledgerhq/hw-transport-node-speculos-http@6.29.3
|
|
57
|
+
- @ledgerhq/live-env@2.3.0
|
|
58
|
+
- @ledgerhq/devices@8.4.3
|
|
59
|
+
- @ledgerhq/hw-transport-node-speculos@6.29.3
|
|
60
|
+
|
|
61
|
+
## 0.1.5-next.0
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- [#7672](https://github.com/LedgerHQ/ledger-live/pull/7672) [`fb9466a`](https://github.com/LedgerHQ/ledger-live/commit/fb9466a4d7827fd4759c726ad3ae0b43dddcacd3) Thanks [@hzheng-ledger](https://github.com/hzheng-ledger)! - Add support for jettons
|
|
66
|
+
|
|
67
|
+
- Updated dependencies [[`187293c`](https://github.com/LedgerHQ/ledger-live/commit/187293c6cf6093f15f07d5effc1ded0843a9e6ab), [`5758950`](https://github.com/LedgerHQ/ledger-live/commit/5758950841fbf8018dd848e745017484aec67333), [`4799d5d`](https://github.com/LedgerHQ/ledger-live/commit/4799d5de3fb1dcef2b01de31fe29b59e76922576), [`eb9a36f`](https://github.com/LedgerHQ/ledger-live/commit/eb9a36f6ee8487c9ffbb841c3e6c0ca84f68bb0a)]:
|
|
68
|
+
- @ledgerhq/hw-transport-node-speculos-http@6.29.3-next.0
|
|
69
|
+
- @ledgerhq/live-env@2.3.0-next.0
|
|
70
|
+
- @ledgerhq/devices@8.4.3-next.0
|
|
71
|
+
- @ledgerhq/hw-transport-node-speculos@6.29.3-next.0
|
|
72
|
+
|
|
73
|
+
## 0.1.4
|
|
74
|
+
|
|
75
|
+
### Patch Changes
|
|
76
|
+
|
|
77
|
+
- Updated dependencies [[`4bd91de`](https://github.com/LedgerHQ/ledger-live/commit/4bd91de13442d12acce3ee83d5f2fd5f087570cf), [`52daa39`](https://github.com/LedgerHQ/ledger-live/commit/52daa3998709ac3538afd447fe771faa3e3441be), [`60f1b5c`](https://github.com/LedgerHQ/ledger-live/commit/60f1b5c6cab125f5281468bb3e36f1abfae2d70c)]:
|
|
78
|
+
- @ledgerhq/live-env@2.2.0
|
|
79
|
+
|
|
80
|
+
## 0.1.4-next.0
|
|
81
|
+
|
|
82
|
+
### Patch Changes
|
|
83
|
+
|
|
84
|
+
- Updated dependencies [[`4bd91de`](https://github.com/LedgerHQ/ledger-live/commit/4bd91de13442d12acce3ee83d5f2fd5f087570cf), [`52daa39`](https://github.com/LedgerHQ/ledger-live/commit/52daa3998709ac3538afd447fe771faa3e3441be), [`60f1b5c`](https://github.com/LedgerHQ/ledger-live/commit/60f1b5c6cab125f5281468bb3e36f1abfae2d70c)]:
|
|
85
|
+
- @ledgerhq/live-env@2.2.0-next.0
|
|
86
|
+
|
|
87
|
+
## 0.1.3
|
|
88
|
+
|
|
89
|
+
### Patch Changes
|
|
90
|
+
|
|
91
|
+
- Updated dependencies [[`0b12c90`](https://github.com/LedgerHQ/ledger-live/commit/0b12c9040d6ee0a326b1d5effd261ddee2db452f)]:
|
|
92
|
+
- @ledgerhq/devices@8.4.2
|
|
93
|
+
- @ledgerhq/hw-transport-node-speculos@6.29.2
|
|
94
|
+
- @ledgerhq/hw-transport-node-speculos-http@6.29.2
|
|
95
|
+
|
|
96
|
+
## 0.1.3-hotfix.0
|
|
97
|
+
|
|
98
|
+
### Patch Changes
|
|
99
|
+
|
|
100
|
+
- Updated dependencies [[`5d508e5`](https://github.com/LedgerHQ/ledger-live/commit/5d508e5cfd296e458746adf176dd292aa884f7ea)]:
|
|
101
|
+
- @ledgerhq/devices@8.4.2-hotfix.0
|
|
102
|
+
- @ledgerhq/hw-transport-node-speculos@6.29.2-hotfix.0
|
|
103
|
+
- @ledgerhq/hw-transport-node-speculos-http@6.29.2-hotfix.0
|
|
104
|
+
|
|
105
|
+
## 0.1.2
|
|
106
|
+
|
|
107
|
+
### Patch Changes
|
|
108
|
+
|
|
109
|
+
- Updated dependencies []:
|
|
110
|
+
- @ledgerhq/devices@8.4.1
|
|
111
|
+
- @ledgerhq/hw-transport-node-speculos@6.29.1
|
|
112
|
+
- @ledgerhq/hw-transport-node-speculos-http@6.29.1
|
|
113
|
+
|
|
114
|
+
## 0.1.2-next.0
|
|
115
|
+
|
|
116
|
+
### Patch Changes
|
|
117
|
+
|
|
118
|
+
- Updated dependencies []:
|
|
119
|
+
- @ledgerhq/devices@8.4.1-next.0
|
|
120
|
+
- @ledgerhq/hw-transport-node-speculos@6.29.1-next.0
|
|
121
|
+
- @ledgerhq/hw-transport-node-speculos-http@6.29.1-next.0
|
|
122
|
+
|
|
123
|
+
## 0.1.1
|
|
124
|
+
|
|
125
|
+
### Patch Changes
|
|
126
|
+
|
|
127
|
+
- Updated dependencies [[`77fa530`](https://github.com/LedgerHQ/ledger-live/commit/77fa530c8626df94fa7f9c0a8b3a99f2efa7cb11), [`6d44f25`](https://github.com/LedgerHQ/ledger-live/commit/6d44f255c5b2f453c61d0b754807db1f76d7174e), [`3b9c93c`](https://github.com/LedgerHQ/ledger-live/commit/3b9c93c0de8ceff2af96a6ee8e42b8d9c2ab7af0), [`6623cd1`](https://github.com/LedgerHQ/ledger-live/commit/6623cd13102bd8340bd7d4dfdd469934527985c3), [`f363430`](https://github.com/LedgerHQ/ledger-live/commit/f363430fe1a261f8adb79d3bf30e457cba839783), [`6552679`](https://github.com/LedgerHQ/ledger-live/commit/65526794bb4d1fbc7e286c0e1c0b6d021413fc8c)]:
|
|
128
|
+
- @ledgerhq/hw-transport-node-speculos-http@6.29.0
|
|
129
|
+
- @ledgerhq/hw-transport-node-speculos@6.29.0
|
|
130
|
+
- @ledgerhq/devices@8.4.0
|
|
131
|
+
- @ledgerhq/live-promise@0.1.0
|
|
132
|
+
- @ledgerhq/live-env@2.1.0
|
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017-present Ledger https://www.ledger.com/
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
## speculos-transport
|
|
2
|
+
|
|
3
|
+
Ledger Live speculos transport test helper
|
|
4
|
+
|
|
5
|
+
## API
|
|
6
|
+
|
|
7
|
+
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
8
|
+
|
|
9
|
+
#### Table of Contents
|
|
10
|
+
|
|
11
|
+
* [releaseSpeculosDevice](#releasespeculosdevice)
|
|
12
|
+
* [Parameters](#parameters)
|
|
13
|
+
* [closeAllSpeculosDevices](#closeallspeculosdevices)
|
|
14
|
+
* [createSpeculosDevice](#createspeculosdevice)
|
|
15
|
+
* [Parameters](#parameters-1)
|
|
16
|
+
|
|
17
|
+
### releaseSpeculosDevice
|
|
18
|
+
|
|
19
|
+
Release a speculos device
|
|
20
|
+
|
|
21
|
+
#### Parameters
|
|
22
|
+
|
|
23
|
+
* `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
|
|
24
|
+
|
|
25
|
+
### closeAllSpeculosDevices
|
|
26
|
+
|
|
27
|
+
Close all speculos devices
|
|
28
|
+
|
|
29
|
+
### createSpeculosDevice
|
|
30
|
+
|
|
31
|
+
instanciate a speculos device that runs through docker
|
|
32
|
+
|
|
33
|
+
#### Parameters
|
|
34
|
+
|
|
35
|
+
* `arg` **{model: DeviceModelId, firmware: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), appName: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), appVersion: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), dependency: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, seed: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), coinapps: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), overridesAppPath: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, onSpeculosDeviceCreated: function (device: SpeculosDevice): [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<void>?}** 
|
|
36
|
+
* `maxRetry` (optional, default `3`)
|
|
37
|
+
|
|
38
|
+
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<SpeculosDevice>** 
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ChildProcessWithoutNullStreams } from "child_process";
|
|
3
|
+
import { DeviceModelId } from "@ledgerhq/devices";
|
|
4
|
+
import SpeculosTransportHttp from "@ledgerhq/hw-transport-node-speculos-http";
|
|
5
|
+
import SpeculosTransportWebsocket from "@ledgerhq/hw-transport-node-speculos";
|
|
6
|
+
export type SpeculosDevice = {
|
|
7
|
+
transport: SpeculosTransport;
|
|
8
|
+
id: string;
|
|
9
|
+
appPath: string;
|
|
10
|
+
ports: ReturnType<typeof getPorts>;
|
|
11
|
+
};
|
|
12
|
+
export type SpeculosTransport = SpeculosTransportHttp | SpeculosTransportWebsocket;
|
|
13
|
+
export { DeviceModelId };
|
|
14
|
+
export type SpeculosDeviceInternal = {
|
|
15
|
+
process: ChildProcessWithoutNullStreams;
|
|
16
|
+
apduPort: number;
|
|
17
|
+
buttonPort: number;
|
|
18
|
+
automationPort: number;
|
|
19
|
+
transport: SpeculosTransportWebsocket;
|
|
20
|
+
destroy: () => void;
|
|
21
|
+
} | {
|
|
22
|
+
process: ChildProcessWithoutNullStreams;
|
|
23
|
+
apiPort: string | undefined;
|
|
24
|
+
transport: SpeculosTransportHttp;
|
|
25
|
+
destroy: () => void;
|
|
26
|
+
};
|
|
27
|
+
export declare function getMemorySpeculosDeviceInternal(id: string): SpeculosDeviceInternal | undefined;
|
|
28
|
+
export declare const modelMap: Record<string, DeviceModelId>;
|
|
29
|
+
/**
|
|
30
|
+
* Release a speculos device
|
|
31
|
+
*/
|
|
32
|
+
export declare function releaseSpeculosDevice(id: string): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Close all speculos devices
|
|
35
|
+
*/
|
|
36
|
+
export declare function closeAllSpeculosDevices(): Promise<void[]>;
|
|
37
|
+
declare const getPorts: (idCounter: number, isSpeculosWebsocket?: boolean) => {
|
|
38
|
+
apduPort: number;
|
|
39
|
+
vncPort: number;
|
|
40
|
+
buttonPort: number;
|
|
41
|
+
automationPort: number;
|
|
42
|
+
apiPort?: undefined;
|
|
43
|
+
} | {
|
|
44
|
+
apiPort: number;
|
|
45
|
+
vncPort: number;
|
|
46
|
+
apduPort?: undefined;
|
|
47
|
+
buttonPort?: undefined;
|
|
48
|
+
automationPort?: undefined;
|
|
49
|
+
};
|
|
50
|
+
interface Dependency {
|
|
51
|
+
name: string;
|
|
52
|
+
appVersion?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* instanciate a speculos device that runs through docker
|
|
56
|
+
*/
|
|
57
|
+
export declare function createSpeculosDevice(arg: {
|
|
58
|
+
model: DeviceModelId;
|
|
59
|
+
firmware: string;
|
|
60
|
+
appName: string;
|
|
61
|
+
appVersion: string;
|
|
62
|
+
dependency?: string;
|
|
63
|
+
dependencies?: Dependency[];
|
|
64
|
+
seed: string;
|
|
65
|
+
coinapps: string;
|
|
66
|
+
overridesAppPath?: string;
|
|
67
|
+
onSpeculosDeviceCreated?: (device: SpeculosDevice) => Promise<void>;
|
|
68
|
+
}, maxRetry?: number): Promise<SpeculosDevice>;
|
|
69
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAe,8BAA8B,EAAE,MAAM,eAAe,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,qBAAqB,MAAM,2CAA2C,CAAC;AAC9E,OAAO,0BAA0B,MAAM,sCAAsC,CAAC;AAI9E,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,GAAG,0BAA0B,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,MAAM,MAAM,sBAAsB,GAC9B;IACE,OAAO,EAAE,8BAA8B,CAAC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,0BAA0B,CAAC;IACtC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,GACD;IACE,OAAO,EAAE,8BAA8B,CAAC;IACxC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,SAAS,EAAE,qBAAqB,CAAC;IACjC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAON,wBAAgB,+BAA+B,CAAC,EAAE,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS,CAE9F;AAED,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAKlD,CAAC;AAMF;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,MAAM,iBAOrD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,oBAEtC;AAmBD,QAAA,MAAM,QAAQ,cAAe,MAAM,wBAAwB,OAAO;;;;;;;;;;;;CAcjE,CAAC;AAWF,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,EAAE;IACH,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IAEb,QAAQ,EAAE,MAAM,CAAC;IAEjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uBAAuB,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrE,EACD,QAAQ,SAAI,GACX,OAAO,CAAC,cAAc,CAAC,CAuMzB"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.createSpeculosDevice = exports.closeAllSpeculosDevices = exports.releaseSpeculosDevice = exports.modelMap = exports.getMemorySpeculosDeviceInternal = exports.DeviceModelId = void 0;
|
|
16
|
+
const child_process_1 = require("child_process");
|
|
17
|
+
const logs_1 = require("@ledgerhq/logs");
|
|
18
|
+
const devices_1 = require("@ledgerhq/devices");
|
|
19
|
+
Object.defineProperty(exports, "DeviceModelId", { enumerable: true, get: function () { return devices_1.DeviceModelId; } });
|
|
20
|
+
const hw_transport_node_speculos_http_1 = __importDefault(require("@ledgerhq/hw-transport-node-speculos-http"));
|
|
21
|
+
const hw_transport_node_speculos_1 = __importDefault(require("@ledgerhq/hw-transport-node-speculos"));
|
|
22
|
+
const live_env_1 = require("@ledgerhq/live-env");
|
|
23
|
+
const live_promise_1 = require("@ledgerhq/live-promise");
|
|
24
|
+
// FIXME we need to figure out a better system, using a filesystem file?
|
|
25
|
+
let idCounter;
|
|
26
|
+
const isSpeculosWebsocket = (0, live_env_1.getEnv)("SPECULOS_USE_WEBSOCKET");
|
|
27
|
+
const data = {};
|
|
28
|
+
function getMemorySpeculosDeviceInternal(id) {
|
|
29
|
+
return data[id];
|
|
30
|
+
}
|
|
31
|
+
exports.getMemorySpeculosDeviceInternal = getMemorySpeculosDeviceInternal;
|
|
32
|
+
exports.modelMap = {
|
|
33
|
+
nanos: devices_1.DeviceModelId.nanoS,
|
|
34
|
+
"nanos+": devices_1.DeviceModelId.nanoSP,
|
|
35
|
+
nanox: devices_1.DeviceModelId.nanoX,
|
|
36
|
+
blue: devices_1.DeviceModelId.blue,
|
|
37
|
+
};
|
|
38
|
+
const reverseModelMap = {};
|
|
39
|
+
for (const k in exports.modelMap) {
|
|
40
|
+
reverseModelMap[exports.modelMap[k]] = k;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Release a speculos device
|
|
44
|
+
*/
|
|
45
|
+
function releaseSpeculosDevice(id) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
(0, logs_1.log)("speculos", "release " + id);
|
|
48
|
+
const obj = data[id];
|
|
49
|
+
if (obj) {
|
|
50
|
+
yield obj.destroy();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.releaseSpeculosDevice = releaseSpeculosDevice;
|
|
55
|
+
/**
|
|
56
|
+
* Close all speculos devices
|
|
57
|
+
*/
|
|
58
|
+
function closeAllSpeculosDevices() {
|
|
59
|
+
return Promise.all(Object.keys(data).map(releaseSpeculosDevice));
|
|
60
|
+
}
|
|
61
|
+
exports.closeAllSpeculosDevices = closeAllSpeculosDevices;
|
|
62
|
+
// to keep in sync from https://github.com/LedgerHQ/speculos/tree/master/speculos/cxlib
|
|
63
|
+
const existingSdks = [
|
|
64
|
+
"nanos-cx-2.0.elf",
|
|
65
|
+
"nanos-cx-2.1.elf",
|
|
66
|
+
"nanosp-cx-1.0.3.elf",
|
|
67
|
+
"nanosp-cx-1.0.elf",
|
|
68
|
+
"nanox-cx-2.0.2.elf",
|
|
69
|
+
"nanox-cx-2.0.elf",
|
|
70
|
+
];
|
|
71
|
+
function inferSDK(firmware, model) {
|
|
72
|
+
const begin = `${model.toLowerCase()}-cx-`;
|
|
73
|
+
if (existingSdks.includes(begin + firmware + ".elf"))
|
|
74
|
+
return firmware;
|
|
75
|
+
const shortVersion = firmware.slice(0, 3);
|
|
76
|
+
if (existingSdks.includes(begin + shortVersion + ".elf"))
|
|
77
|
+
return shortVersion;
|
|
78
|
+
}
|
|
79
|
+
const getPorts = (idCounter, isSpeculosWebsocket) => {
|
|
80
|
+
if (isSpeculosWebsocket) {
|
|
81
|
+
const apduPort = 30000 + idCounter;
|
|
82
|
+
const vncPort = 35000 + idCounter;
|
|
83
|
+
const buttonPort = 40000 + idCounter;
|
|
84
|
+
const automationPort = 45000 + idCounter;
|
|
85
|
+
return { apduPort, vncPort, buttonPort, automationPort };
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
const apiPort = 30000 + idCounter;
|
|
89
|
+
const vncPort = 35000 + idCounter;
|
|
90
|
+
return { apiPort, vncPort };
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
function conventionalAppSubpath(model, firmware, appName, appVersion) {
|
|
94
|
+
return `${reverseModelMap[model]}/${firmware}/${appName.replace(/ /g, "")}/app_${appVersion}.elf`;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* instanciate a speculos device that runs through docker
|
|
98
|
+
*/
|
|
99
|
+
function createSpeculosDevice(arg_1) {
|
|
100
|
+
return __awaiter(this, arguments, void 0, function* (arg, maxRetry = 3) {
|
|
101
|
+
var _a, _b, _c;
|
|
102
|
+
const { overridesAppPath, model, firmware, appName, appVersion, seed, coinapps, dependency, dependencies, } = arg;
|
|
103
|
+
idCounter = idCounter !== null && idCounter !== void 0 ? idCounter : (0, live_env_1.getEnv)("SPECULOS_PID_OFFSET");
|
|
104
|
+
const speculosID = `speculosID-${++idCounter}`;
|
|
105
|
+
const ports = getPorts(idCounter, isSpeculosWebsocket);
|
|
106
|
+
const sdk = inferSDK(firmware, model);
|
|
107
|
+
const subpath = overridesAppPath || conventionalAppSubpath(model, firmware, appName, appVersion);
|
|
108
|
+
const appPath = `./apps/${subpath}`;
|
|
109
|
+
const params = [
|
|
110
|
+
"run",
|
|
111
|
+
"-v",
|
|
112
|
+
`${coinapps}:/speculos/apps`,
|
|
113
|
+
...(isSpeculosWebsocket
|
|
114
|
+
? [
|
|
115
|
+
// websocket ports
|
|
116
|
+
"-p",
|
|
117
|
+
`${ports.apduPort}:40000`,
|
|
118
|
+
"-p",
|
|
119
|
+
`${ports.vncPort}:41000`,
|
|
120
|
+
"-p",
|
|
121
|
+
`${ports.buttonPort}:42000`,
|
|
122
|
+
"-p",
|
|
123
|
+
`${ports.automationPort}:43000`,
|
|
124
|
+
]
|
|
125
|
+
: [
|
|
126
|
+
// http ports
|
|
127
|
+
"-p",
|
|
128
|
+
`${ports.apiPort}:40000`,
|
|
129
|
+
"-p",
|
|
130
|
+
`${ports.vncPort}:41000`,
|
|
131
|
+
]),
|
|
132
|
+
"-e",
|
|
133
|
+
`SPECULOS_APPNAME=${appName}:${appVersion}`,
|
|
134
|
+
"--name",
|
|
135
|
+
`${speculosID}`,
|
|
136
|
+
(_a = process.env.SPECULOS_IMAGE_TAG) !== null && _a !== void 0 ? _a : "ghcr.io/ledgerhq/speculos:sha-e262a0c",
|
|
137
|
+
"--model",
|
|
138
|
+
model.toLowerCase(),
|
|
139
|
+
appPath,
|
|
140
|
+
...(dependency
|
|
141
|
+
? [
|
|
142
|
+
"-l",
|
|
143
|
+
`${dependency}:./apps/${conventionalAppSubpath(model, firmware, dependency, appVersion)}`,
|
|
144
|
+
]
|
|
145
|
+
: []),
|
|
146
|
+
...(dependencies !== undefined
|
|
147
|
+
? dependencies.flatMap(dependency => [
|
|
148
|
+
"-l",
|
|
149
|
+
`${dependency.name}:./apps/${conventionalAppSubpath(model, firmware, dependency.name, dependency.appVersion ? dependency.appVersion : "1.0.0")}`,
|
|
150
|
+
])
|
|
151
|
+
: []),
|
|
152
|
+
...(sdk ? ["--sdk", sdk] : []),
|
|
153
|
+
"--display",
|
|
154
|
+
"headless",
|
|
155
|
+
...(process.env.CI ? ["--vnc-password", "live", "--vnc-port", "41000"] : []),
|
|
156
|
+
...(isSpeculosWebsocket
|
|
157
|
+
? [
|
|
158
|
+
// websocket ports
|
|
159
|
+
"--apdu-port",
|
|
160
|
+
"40000",
|
|
161
|
+
"--button-port",
|
|
162
|
+
"42000",
|
|
163
|
+
"--automation-port",
|
|
164
|
+
"43000",
|
|
165
|
+
]
|
|
166
|
+
: [
|
|
167
|
+
// http ports
|
|
168
|
+
"--api-port",
|
|
169
|
+
"40000",
|
|
170
|
+
]),
|
|
171
|
+
];
|
|
172
|
+
(0, logs_1.log)("speculos", `${speculosID}: spawning = ${params.join(" ")}`);
|
|
173
|
+
const p = (0, child_process_1.spawn)("docker", [...params, "--seed", `${seed}`]);
|
|
174
|
+
let resolveReady;
|
|
175
|
+
let rejectReady;
|
|
176
|
+
const ready = new Promise((resolve, reject) => {
|
|
177
|
+
resolveReady = resolve;
|
|
178
|
+
rejectReady = reject;
|
|
179
|
+
});
|
|
180
|
+
let destroyed = false;
|
|
181
|
+
const destroy = () => {
|
|
182
|
+
if (destroyed)
|
|
183
|
+
return;
|
|
184
|
+
destroyed = true;
|
|
185
|
+
new Promise((resolve, reject) => {
|
|
186
|
+
if (!data[speculosID])
|
|
187
|
+
return;
|
|
188
|
+
delete data[speculosID];
|
|
189
|
+
(0, child_process_1.exec)(`docker rm -f ${speculosID}`, (error, stdout, stderr) => {
|
|
190
|
+
if (error) {
|
|
191
|
+
(0, logs_1.log)("speculos-error", `${speculosID} not destroyed ${error} ${stderr}`);
|
|
192
|
+
reject(error);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
(0, logs_1.log)("speculos", `destroyed ${speculosID}`);
|
|
196
|
+
resolve(undefined);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
p.stdout.on("data", data => {
|
|
202
|
+
if (data) {
|
|
203
|
+
(0, logs_1.log)("speculos-stdout", `${speculosID}: ${String(data).trim()}`);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
let latestStderr;
|
|
207
|
+
p.stderr.on("data", data => {
|
|
208
|
+
if (!data)
|
|
209
|
+
return;
|
|
210
|
+
latestStderr = data;
|
|
211
|
+
if (!data.includes("apdu: ")) {
|
|
212
|
+
(0, logs_1.log)("speculos-stderr", `${speculosID}: ${String(data).trim()}`);
|
|
213
|
+
}
|
|
214
|
+
if (/using\s(?:SDK|API_LEVEL)/.test(data)) {
|
|
215
|
+
setTimeout(() => resolveReady(true), 500);
|
|
216
|
+
}
|
|
217
|
+
else if (data.includes("is already in use by container")) {
|
|
218
|
+
rejectReady(new Error("speculos already in use! Try `ledger-live cleanSpeculos` or check logs"));
|
|
219
|
+
}
|
|
220
|
+
else if (data.includes("address already in use")) {
|
|
221
|
+
if (maxRetry > 0) {
|
|
222
|
+
(0, logs_1.log)("speculos", "retrying speculos connection");
|
|
223
|
+
destroy();
|
|
224
|
+
resolveReady(false);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
p.on("close", () => {
|
|
229
|
+
(0, logs_1.log)("speculos", `${speculosID} closed`);
|
|
230
|
+
if (!destroyed) {
|
|
231
|
+
destroy();
|
|
232
|
+
rejectReady(new Error(`speculos process failure. ${latestStderr || ""}`));
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
const hasSucceed = yield ready;
|
|
236
|
+
if (!hasSucceed) {
|
|
237
|
+
yield (0, live_promise_1.delay)(1000);
|
|
238
|
+
return createSpeculosDevice(arg, maxRetry - 1);
|
|
239
|
+
}
|
|
240
|
+
let transport;
|
|
241
|
+
if (isSpeculosWebsocket) {
|
|
242
|
+
transport = yield hw_transport_node_speculos_1.default.open({
|
|
243
|
+
apduPort: ports === null || ports === void 0 ? void 0 : ports.apduPort,
|
|
244
|
+
buttonPort: ports === null || ports === void 0 ? void 0 : ports.buttonPort,
|
|
245
|
+
automationPort: ports === null || ports === void 0 ? void 0 : ports.automationPort,
|
|
246
|
+
});
|
|
247
|
+
data[speculosID] = {
|
|
248
|
+
process: p,
|
|
249
|
+
apduPort: ports.apduPort,
|
|
250
|
+
buttonPort: ports.buttonPort,
|
|
251
|
+
automationPort: ports.automationPort,
|
|
252
|
+
transport,
|
|
253
|
+
destroy,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
transport = yield hw_transport_node_speculos_http_1.default.open({
|
|
258
|
+
apiPort: (_b = ports.apiPort) === null || _b === void 0 ? void 0 : _b.toString(),
|
|
259
|
+
});
|
|
260
|
+
data[speculosID] = {
|
|
261
|
+
process: p,
|
|
262
|
+
apiPort: (_c = ports.apiPort) === null || _c === void 0 ? void 0 : _c.toString(),
|
|
263
|
+
transport,
|
|
264
|
+
destroy,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
const device = {
|
|
268
|
+
id: speculosID,
|
|
269
|
+
transport,
|
|
270
|
+
appPath,
|
|
271
|
+
ports,
|
|
272
|
+
};
|
|
273
|
+
if (arg.onSpeculosDeviceCreated != null) {
|
|
274
|
+
yield arg.onSpeculosDeviceCreated(device);
|
|
275
|
+
}
|
|
276
|
+
return device;
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
exports.createSpeculosDevice = createSpeculosDevice;
|
|
280
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iDAA4E;AAC5E,yCAAqC;AACrC,+CAAkD;AAezC,8FAfA,uBAAa,OAeA;AAdtB,gHAA8E;AAC9E,sGAA8E;AAC9E,iDAA4C;AAC5C,yDAA+C;AA6B/C,wEAAwE;AACxE,IAAI,SAAiB,CAAC;AACtB,MAAM,mBAAmB,GAAG,IAAA,iBAAM,EAAC,wBAAwB,CAAC,CAAC;AAC7D,MAAM,IAAI,GAAuD,EAAE,CAAC;AAEpE,SAAgB,+BAA+B,CAAC,EAAU;IACxD,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC;AAFD,0EAEC;AAEY,QAAA,QAAQ,GAAkC;IACrD,KAAK,EAAE,uBAAa,CAAC,KAAK;IAC1B,QAAQ,EAAE,uBAAa,CAAC,MAAM;IAC9B,KAAK,EAAE,uBAAa,CAAC,KAAK;IAC1B,IAAI,EAAE,uBAAa,CAAC,IAAI;CACzB,CAAC;AAEF,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