@ledgerhq/wallet-api-simulator 0.6.4 → 0.7.2
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/lib/profiles/device/index.d.ts +3 -0
- package/lib/profiles/device/index.d.ts.map +1 -0
- package/lib/profiles/device/index.js +58 -0
- package/lib/profiles/index.d.ts +1 -0
- package/lib/profiles/index.d.ts.map +1 -1
- package/lib/profiles/index.js +2 -0
- package/lib-es/profiles/device/index.d.ts +3 -0
- package/lib-es/profiles/device/index.d.ts.map +1 -0
- package/lib-es/profiles/device/index.js +52 -0
- package/lib-es/profiles/index.d.ts +1 -0
- package/lib-es/profiles/index.d.ts.map +1 -1
- package/lib-es/profiles/index.js +2 -0
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/profiles/device/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AASpD,eAAO,MAAM,aAAa,EAAE,gBA8C3B,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.deviceProfile = void 0;
|
|
7
|
+
const hw_transport_http_1 = __importDefault(require("@ledgerhq/hw-transport-http"));
|
|
8
|
+
const standard_1 = require("../standard");
|
|
9
|
+
const deviceProxyUrl = process.env["DEVICE_PROXY_URL"];
|
|
10
|
+
const httpTransport = deviceProxyUrl
|
|
11
|
+
? (0, hw_transport_http_1.default)(deviceProxyUrl.split("|"))
|
|
12
|
+
: undefined;
|
|
13
|
+
let transport;
|
|
14
|
+
exports.deviceProfile = {
|
|
15
|
+
...standard_1.standardProfile,
|
|
16
|
+
permissions: {
|
|
17
|
+
...standard_1.standardProfile.permissions,
|
|
18
|
+
methodIds: [
|
|
19
|
+
...standard_1.standardProfile.permissions.methodIds,
|
|
20
|
+
"device.transport",
|
|
21
|
+
"device.exchange",
|
|
22
|
+
"device.close",
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
methods: {
|
|
26
|
+
...standard_1.standardProfile.methods,
|
|
27
|
+
"device.transport": async () => {
|
|
28
|
+
if (!httpTransport) {
|
|
29
|
+
throw new Error("Proxy not setup");
|
|
30
|
+
}
|
|
31
|
+
if (transport) {
|
|
32
|
+
throw new Error("Transport already opened");
|
|
33
|
+
}
|
|
34
|
+
transport = await httpTransport.create(3000, 5000);
|
|
35
|
+
return "1";
|
|
36
|
+
},
|
|
37
|
+
"device.exchange": async ({ apduHex, transportId }) => {
|
|
38
|
+
if (!transport) {
|
|
39
|
+
throw new Error("No open transport to close");
|
|
40
|
+
}
|
|
41
|
+
if (transportId !== "1") {
|
|
42
|
+
throw new Error("No transport open with this transportId");
|
|
43
|
+
}
|
|
44
|
+
return (await transport.exchange(Buffer.from(apduHex, "hex"))).toString("hex");
|
|
45
|
+
},
|
|
46
|
+
"device.close": async ({ transportId }) => {
|
|
47
|
+
if (!transport) {
|
|
48
|
+
throw new Error("No open transport to close");
|
|
49
|
+
}
|
|
50
|
+
if (transportId !== "1") {
|
|
51
|
+
throw new Error("No transport open with this transportId");
|
|
52
|
+
}
|
|
53
|
+
await transport.close();
|
|
54
|
+
transport = undefined;
|
|
55
|
+
return "1";
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|
package/lib/profiles/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/profiles/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/profiles/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ;;;CAGpB,CAAC"}
|
package/lib/profiles/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.profiles = void 0;
|
|
4
|
+
const device_1 = require("./device");
|
|
4
5
|
const standard_1 = require("./standard");
|
|
5
6
|
exports.profiles = {
|
|
6
7
|
STANDARD: standard_1.standardProfile,
|
|
8
|
+
DEVICE: device_1.deviceProfile,
|
|
7
9
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/profiles/device/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AASpD,eAAO,MAAM,aAAa,EAAE,gBA8C3B,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import TransportHttp from "@ledgerhq/hw-transport-http";
|
|
2
|
+
import { standardProfile } from "../standard";
|
|
3
|
+
const deviceProxyUrl = process.env["DEVICE_PROXY_URL"];
|
|
4
|
+
const httpTransport = deviceProxyUrl
|
|
5
|
+
? TransportHttp(deviceProxyUrl.split("|"))
|
|
6
|
+
: undefined;
|
|
7
|
+
let transport;
|
|
8
|
+
export const deviceProfile = {
|
|
9
|
+
...standardProfile,
|
|
10
|
+
permissions: {
|
|
11
|
+
...standardProfile.permissions,
|
|
12
|
+
methodIds: [
|
|
13
|
+
...standardProfile.permissions.methodIds,
|
|
14
|
+
"device.transport",
|
|
15
|
+
"device.exchange",
|
|
16
|
+
"device.close",
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
methods: {
|
|
20
|
+
...standardProfile.methods,
|
|
21
|
+
"device.transport": async () => {
|
|
22
|
+
if (!httpTransport) {
|
|
23
|
+
throw new Error("Proxy not setup");
|
|
24
|
+
}
|
|
25
|
+
if (transport) {
|
|
26
|
+
throw new Error("Transport already opened");
|
|
27
|
+
}
|
|
28
|
+
transport = await httpTransport.create(3000, 5000);
|
|
29
|
+
return "1";
|
|
30
|
+
},
|
|
31
|
+
"device.exchange": async ({ apduHex, transportId }) => {
|
|
32
|
+
if (!transport) {
|
|
33
|
+
throw new Error("No open transport to close");
|
|
34
|
+
}
|
|
35
|
+
if (transportId !== "1") {
|
|
36
|
+
throw new Error("No transport open with this transportId");
|
|
37
|
+
}
|
|
38
|
+
return (await transport.exchange(Buffer.from(apduHex, "hex"))).toString("hex");
|
|
39
|
+
},
|
|
40
|
+
"device.close": async ({ transportId }) => {
|
|
41
|
+
if (!transport) {
|
|
42
|
+
throw new Error("No open transport to close");
|
|
43
|
+
}
|
|
44
|
+
if (transportId !== "1") {
|
|
45
|
+
throw new Error("No transport open with this transportId");
|
|
46
|
+
}
|
|
47
|
+
await transport.close();
|
|
48
|
+
transport = undefined;
|
|
49
|
+
return "1";
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/profiles/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/profiles/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ;;;CAGpB,CAAC"}
|
package/lib-es/profiles/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/wallet-api-simulator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"jest-shared-config": "0.1.0"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
+
"@ledgerhq/hw-transport-http": "^6.27.7",
|
|
26
27
|
"rxjs": "^7.5.7",
|
|
27
28
|
"ws": "^8.10.0",
|
|
28
29
|
"@ledgerhq/wallet-api-client": "0.8.0",
|