@ledgerhq/wallet-api-simulator 1.1.8 → 1.1.9
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 +1 -1
- package/lib/profiles/device/index.d.ts.map +1 -1
- package/lib/profiles/device/index.js +62 -60
- package/lib/profiles/device/index.js.map +1 -1
- package/lib/profiles/index.d.ts +1 -1
- package/lib-es/profiles/device/index.d.ts +1 -1
- package/lib-es/profiles/device/index.d.ts.map +1 -1
- package/lib-es/profiles/device/index.js +61 -60
- package/lib-es/profiles/device/index.js.map +1 -1
- package/lib-es/profiles/index.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1 +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;
|
|
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;AAGpD,eAAO,MAAM,aAAa,EAAE,CAAC,cAAc,CAAC,EAAE,MAAM,KAAK,gBAqExD,CAAC"}
|
|
@@ -6,67 +6,69 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.deviceProfile = void 0;
|
|
7
7
|
const hw_transport_http_1 = __importDefault(require("@ledgerhq/hw-transport-http"));
|
|
8
8
|
const standard_1 = require("../standard");
|
|
9
|
-
const
|
|
10
|
-
const httpTransport = deviceProxyUrl
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
let transport;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
methods: {
|
|
28
|
-
...standard_1.standardProfile.methods,
|
|
29
|
-
"device.transport": async () => {
|
|
30
|
-
if (!httpTransport) {
|
|
31
|
-
throw new Error("Proxy not setup");
|
|
32
|
-
}
|
|
33
|
-
if (transport) {
|
|
34
|
-
throw new Error("Transport already opened");
|
|
35
|
-
}
|
|
36
|
-
transport = await httpTransport.create(3000, 5000);
|
|
37
|
-
return "1";
|
|
9
|
+
const deviceProfile = (deviceProxyUrl) => {
|
|
10
|
+
const httpTransport = deviceProxyUrl
|
|
11
|
+
? (0, hw_transport_http_1.default)(deviceProxyUrl.split("|"))
|
|
12
|
+
: undefined;
|
|
13
|
+
let transport;
|
|
14
|
+
return {
|
|
15
|
+
...standard_1.standardProfile,
|
|
16
|
+
permissions: {
|
|
17
|
+
...standard_1.standardProfile.permissions,
|
|
18
|
+
methodIds: [
|
|
19
|
+
...standard_1.standardProfile.permissions.methodIds,
|
|
20
|
+
"device.transport",
|
|
21
|
+
"device.select",
|
|
22
|
+
"device.open",
|
|
23
|
+
"device.exchange",
|
|
24
|
+
"device.close",
|
|
25
|
+
],
|
|
38
26
|
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
27
|
+
methods: {
|
|
28
|
+
...standard_1.standardProfile.methods,
|
|
29
|
+
"device.transport": async () => {
|
|
30
|
+
if (!httpTransport) {
|
|
31
|
+
throw new Error("Proxy not setup");
|
|
32
|
+
}
|
|
33
|
+
if (transport) {
|
|
34
|
+
throw new Error("Transport already opened");
|
|
35
|
+
}
|
|
36
|
+
transport = await httpTransport.create(3000, 5000);
|
|
37
|
+
return "1";
|
|
38
|
+
},
|
|
39
|
+
"device.select": () => "",
|
|
40
|
+
"device.open": async () => {
|
|
41
|
+
if (!httpTransport) {
|
|
42
|
+
throw new Error("Proxy not setup");
|
|
43
|
+
}
|
|
44
|
+
if (transport) {
|
|
45
|
+
throw new Error("Transport already opened");
|
|
46
|
+
}
|
|
47
|
+
transport = await httpTransport.create(3000, 5000);
|
|
48
|
+
return "1";
|
|
49
|
+
},
|
|
50
|
+
"device.exchange": async ({ apduHex, transportId }) => {
|
|
51
|
+
if (!transport) {
|
|
52
|
+
throw new Error("No open transport to close");
|
|
53
|
+
}
|
|
54
|
+
if (transportId !== "1") {
|
|
55
|
+
throw new Error("No transport open with this transportId");
|
|
56
|
+
}
|
|
57
|
+
return (await transport.exchange(Buffer.from(apduHex, "hex"))).toString("hex");
|
|
58
|
+
},
|
|
59
|
+
"device.close": async ({ transportId }) => {
|
|
60
|
+
if (!transport) {
|
|
61
|
+
throw new Error("No open transport to close");
|
|
62
|
+
}
|
|
63
|
+
if (transportId !== "1") {
|
|
64
|
+
throw new Error("No transport open with this transportId");
|
|
65
|
+
}
|
|
66
|
+
await transport.close();
|
|
67
|
+
transport = undefined;
|
|
68
|
+
return "1";
|
|
69
|
+
},
|
|
49
70
|
},
|
|
50
|
-
|
|
51
|
-
if (!transport) {
|
|
52
|
-
throw new Error("No open transport to close");
|
|
53
|
-
}
|
|
54
|
-
if (transportId !== "1") {
|
|
55
|
-
throw new Error("No transport open with this transportId");
|
|
56
|
-
}
|
|
57
|
-
return (await transport.exchange(Buffer.from(apduHex, "hex"))).toString("hex");
|
|
58
|
-
},
|
|
59
|
-
"device.close": async ({ transportId }) => {
|
|
60
|
-
if (!transport) {
|
|
61
|
-
throw new Error("No open transport to close");
|
|
62
|
-
}
|
|
63
|
-
if (transportId !== "1") {
|
|
64
|
-
throw new Error("No transport open with this transportId");
|
|
65
|
-
}
|
|
66
|
-
await transport.close();
|
|
67
|
-
transport = undefined;
|
|
68
|
-
return "1";
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
+
};
|
|
71
72
|
};
|
|
73
|
+
exports.deviceProfile = deviceProfile;
|
|
72
74
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/profiles/device/index.ts"],"names":[],"mappings":";;;;;;AACA,oFAAwD;AAExD,0CAA8C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/profiles/device/index.ts"],"names":[],"mappings":";;;;;;AACA,oFAAwD;AAExD,0CAA8C;AAEvC,MAAM,aAAa,GAAkD,CAC1E,cAAc,EACd,EAAE;IACF,MAAM,aAAa,GAAG,cAAc;QAClC,CAAC,CAAC,IAAA,2BAAa,EAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC1C,CAAC,CAAC,SAAS,CAAC;IAEd,IAAI,SAAkC,CAAC;IAEvC,OAAO;QACL,GAAG,0BAAe;QAClB,WAAW,EAAE;YACX,GAAG,0BAAe,CAAC,WAAW;YAC9B,SAAS,EAAE;gBACT,GAAG,0BAAe,CAAC,WAAW,CAAC,SAAS;gBACxC,kBAAkB;gBAClB,eAAe;gBACf,aAAa;gBACb,iBAAiB;gBACjB,cAAc;aACf;SACF;QACD,OAAO,EAAE;YACP,GAAG,0BAAe,CAAC,OAAO;YAC1B,kBAAkB,EAAE,KAAK,IAAI,EAAE;gBAC7B,IAAI,CAAC,aAAa,EAAE;oBAClB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;iBACpC;gBACD,IAAI,SAAS,EAAE;oBACb,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;iBAC7C;gBACD,SAAS,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACnD,OAAO,GAAG,CAAC;YACb,CAAC;YACD,eAAe,EAAE,GAAG,EAAE,CAAC,EAAE;YACzB,aAAa,EAAE,KAAK,IAAI,EAAE;gBACxB,IAAI,CAAC,aAAa,EAAE;oBAClB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;iBACpC;gBACD,IAAI,SAAS,EAAE;oBACb,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;iBAC7C;gBACD,SAAS,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACnD,OAAO,GAAG,CAAC;YACb,CAAC;YACD,iBAAiB,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE;gBACpD,IAAI,CAAC,SAAS,EAAE;oBACd,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;iBAC/C;gBACD,IAAI,WAAW,KAAK,GAAG,EAAE;oBACvB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;iBAC5D;gBACD,OAAO,CAAC,MAAM,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CACrE,KAAK,CACN,CAAC;YACJ,CAAC;YACD,cAAc,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;gBACxC,IAAI,CAAC,SAAS,EAAE;oBACd,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;iBAC/C;gBACD,IAAI,WAAW,KAAK,GAAG,EAAE;oBACvB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;iBAC5D;gBACD,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;gBACxB,SAAS,GAAG,SAAS,CAAC;gBACtB,OAAO,GAAG,CAAC;YACb,CAAC;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AArEW,QAAA,aAAa,iBAqExB"}
|
package/lib/profiles/index.d.ts
CHANGED
|
@@ -1 +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;
|
|
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;AAGpD,eAAO,MAAM,aAAa,EAAE,CAAC,cAAc,CAAC,EAAE,MAAM,KAAK,gBAqExD,CAAC"}
|
|
@@ -1,66 +1,67 @@
|
|
|
1
1
|
import TransportHttp from "@ledgerhq/hw-transport-http";
|
|
2
2
|
import { standardProfile } from "../standard";
|
|
3
|
-
const
|
|
4
|
-
const httpTransport = deviceProxyUrl
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
let transport;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
methods: {
|
|
22
|
-
...standardProfile.methods,
|
|
23
|
-
"device.transport": async () => {
|
|
24
|
-
if (!httpTransport) {
|
|
25
|
-
throw new Error("Proxy not setup");
|
|
26
|
-
}
|
|
27
|
-
if (transport) {
|
|
28
|
-
throw new Error("Transport already opened");
|
|
29
|
-
}
|
|
30
|
-
transport = await httpTransport.create(3000, 5000);
|
|
31
|
-
return "1";
|
|
3
|
+
export const deviceProfile = (deviceProxyUrl) => {
|
|
4
|
+
const httpTransport = deviceProxyUrl
|
|
5
|
+
? TransportHttp(deviceProxyUrl.split("|"))
|
|
6
|
+
: undefined;
|
|
7
|
+
let transport;
|
|
8
|
+
return {
|
|
9
|
+
...standardProfile,
|
|
10
|
+
permissions: {
|
|
11
|
+
...standardProfile.permissions,
|
|
12
|
+
methodIds: [
|
|
13
|
+
...standardProfile.permissions.methodIds,
|
|
14
|
+
"device.transport",
|
|
15
|
+
"device.select",
|
|
16
|
+
"device.open",
|
|
17
|
+
"device.exchange",
|
|
18
|
+
"device.close",
|
|
19
|
+
],
|
|
32
20
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
21
|
+
methods: {
|
|
22
|
+
...standardProfile.methods,
|
|
23
|
+
"device.transport": async () => {
|
|
24
|
+
if (!httpTransport) {
|
|
25
|
+
throw new Error("Proxy not setup");
|
|
26
|
+
}
|
|
27
|
+
if (transport) {
|
|
28
|
+
throw new Error("Transport already opened");
|
|
29
|
+
}
|
|
30
|
+
transport = await httpTransport.create(3000, 5000);
|
|
31
|
+
return "1";
|
|
32
|
+
},
|
|
33
|
+
"device.select": () => "",
|
|
34
|
+
"device.open": async () => {
|
|
35
|
+
if (!httpTransport) {
|
|
36
|
+
throw new Error("Proxy not setup");
|
|
37
|
+
}
|
|
38
|
+
if (transport) {
|
|
39
|
+
throw new Error("Transport already opened");
|
|
40
|
+
}
|
|
41
|
+
transport = await httpTransport.create(3000, 5000);
|
|
42
|
+
return "1";
|
|
43
|
+
},
|
|
44
|
+
"device.exchange": async ({ apduHex, transportId }) => {
|
|
45
|
+
if (!transport) {
|
|
46
|
+
throw new Error("No open transport to close");
|
|
47
|
+
}
|
|
48
|
+
if (transportId !== "1") {
|
|
49
|
+
throw new Error("No transport open with this transportId");
|
|
50
|
+
}
|
|
51
|
+
return (await transport.exchange(Buffer.from(apduHex, "hex"))).toString("hex");
|
|
52
|
+
},
|
|
53
|
+
"device.close": async ({ transportId }) => {
|
|
54
|
+
if (!transport) {
|
|
55
|
+
throw new Error("No open transport to close");
|
|
56
|
+
}
|
|
57
|
+
if (transportId !== "1") {
|
|
58
|
+
throw new Error("No transport open with this transportId");
|
|
59
|
+
}
|
|
60
|
+
await transport.close();
|
|
61
|
+
transport = undefined;
|
|
62
|
+
return "1";
|
|
63
|
+
},
|
|
43
64
|
},
|
|
44
|
-
|
|
45
|
-
if (!transport) {
|
|
46
|
-
throw new Error("No open transport to close");
|
|
47
|
-
}
|
|
48
|
-
if (transportId !== "1") {
|
|
49
|
-
throw new Error("No transport open with this transportId");
|
|
50
|
-
}
|
|
51
|
-
return (await transport.exchange(Buffer.from(apduHex, "hex"))).toString("hex");
|
|
52
|
-
},
|
|
53
|
-
"device.close": async ({ transportId }) => {
|
|
54
|
-
if (!transport) {
|
|
55
|
-
throw new Error("No open transport to close");
|
|
56
|
-
}
|
|
57
|
-
if (transportId !== "1") {
|
|
58
|
-
throw new Error("No transport open with this transportId");
|
|
59
|
-
}
|
|
60
|
-
await transport.close();
|
|
61
|
-
transport = undefined;
|
|
62
|
-
return "1";
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
+
};
|
|
65
66
|
};
|
|
66
67
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/profiles/device/index.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,6BAA6B,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/profiles/device/index.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,6BAA6B,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,CAAC,MAAM,aAAa,GAAkD,CAC1E,cAAc,EACd,EAAE;IACF,MAAM,aAAa,GAAG,cAAc;QAClC,CAAC,CAAC,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC1C,CAAC,CAAC,SAAS,CAAC;IAEd,IAAI,SAAkC,CAAC;IAEvC,OAAO;QACL,GAAG,eAAe;QAClB,WAAW,EAAE;YACX,GAAG,eAAe,CAAC,WAAW;YAC9B,SAAS,EAAE;gBACT,GAAG,eAAe,CAAC,WAAW,CAAC,SAAS;gBACxC,kBAAkB;gBAClB,eAAe;gBACf,aAAa;gBACb,iBAAiB;gBACjB,cAAc;aACf;SACF;QACD,OAAO,EAAE;Y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d,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;iBAC/C;gBACD,IAAI,WAAW,KAAK,GAAG,EAAE;oBACvB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;iBAC5D;gBACD,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;gBACxB,SAAS,GAAG,SAAS,CAAC;gBACtB,OAAO,GAAG,CAAC;YACb,CAAC;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/wallet-api-simulator",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"ws": "^8.13.0",
|
|
30
30
|
"@ledgerhq/wallet-api-client": "1.5.4",
|
|
31
31
|
"@ledgerhq/wallet-api-core": "1.7.1",
|
|
32
|
-
"@ledgerhq/wallet-api-server": "1.5.
|
|
32
|
+
"@ledgerhq/wallet-api-server": "1.5.5"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"format:check": "prettier --check \"src\"",
|