@ledgerhq/hw-transport 6.28.2 → 6.28.3-next.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/CHANGELOG.md +8 -0
- package/lib/Transport.d.ts +5 -4
- package/lib/Transport.d.ts.map +1 -1
- package/lib/Transport.js +123 -276
- package/lib/Transport.js.map +1 -1
- package/lib-es/Transport.d.ts +5 -4
- package/lib-es/Transport.d.ts.map +1 -1
- package/lib-es/Transport.js +114 -268
- package/lib-es/Transport.js.map +1 -1
- package/package.json +5 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @ledgerhq/hw-transport
|
|
2
2
|
|
|
3
|
+
## 6.28.3-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`87d2349fd8`](https://github.com/LedgerHQ/ledger-live/commit/87d2349fd835e5deb39d1ee8dfcf3539f4195472)]:
|
|
8
|
+
- @ledgerhq/errors@6.12.5-next.0
|
|
9
|
+
- @ledgerhq/devices@8.0.2-next.0
|
|
10
|
+
|
|
3
11
|
## 6.28.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/lib/Transport.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import EventEmitter from "events";
|
|
3
4
|
import type { DeviceModel } from "@ledgerhq/devices";
|
|
4
5
|
import { TransportError, StatusCodes, getAltStatusMessage, TransportStatusError } from "@ledgerhq/errors";
|
|
5
6
|
export { TransportError, TransportStatusError, StatusCodes, getAltStatusMessage, };
|
|
6
7
|
/**
|
|
7
8
|
*/
|
|
8
|
-
export
|
|
9
|
+
export type Subscription = {
|
|
9
10
|
unsubscribe: () => void;
|
|
10
11
|
};
|
|
11
12
|
/**
|
|
12
13
|
*/
|
|
13
|
-
export
|
|
14
|
-
export
|
|
14
|
+
export type Device = any;
|
|
15
|
+
export type DescriptorEventType = "add" | "remove";
|
|
15
16
|
/**
|
|
16
17
|
* A "descriptor" is a parameter that is specific to the implementation, and can be an ID, file path, or URL.
|
|
17
18
|
* type: add or remove event
|
|
@@ -28,7 +29,7 @@ export interface DescriptorEvent<Descriptor> {
|
|
|
28
29
|
/**
|
|
29
30
|
* Observer generic type, following the Observer pattern
|
|
30
31
|
*/
|
|
31
|
-
export
|
|
32
|
+
export type Observer<EventType, EventError = unknown> = Readonly<{
|
|
32
33
|
next: (event: EventType) => unknown;
|
|
33
34
|
error: (e: EventError) => unknown;
|
|
34
35
|
complete: () => unknown;
|
package/lib/Transport.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transport.d.ts","sourceRoot":"","sources":["../src/Transport.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Transport.d.ts","sourceRoot":"","sources":["../src/Transport.ts"],"names":[],"mappings":";;AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAEL,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,mBAAmB,GACpB,CAAC;AAEF;GACG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB,CAAC;AAEF;GACG;AACH,MAAM,MAAM,MAAM,GAAG,GAAG,CAAC;AAEzB,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,QAAQ,CAAC;AACnD;;;;;;GAMG;AACH,MAAM,WAAW,eAAe,CAAC,UAAU;IACzC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAA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AAoB,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,EAAE,EACrC,UAAU,EAAE,MAAM,EAClB,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,EAC7B,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,MAAM,GAClB,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC;IAuB7B,MAAM,CAAC,0BAA0B,SAAsC;IACvE,MAAM,CAAC,0BAA0B,SAA4B;CAC9D"}
|
package/lib/Transport.js
CHANGED
|
@@ -8,92 +8,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __values = (this && this.__values) || function(o) {
|
|
39
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
-
if (m) return m.call(o);
|
|
41
|
-
if (o && typeof o.length === "number") return {
|
|
42
|
-
next: function () {
|
|
43
|
-
if (o && i >= o.length) o = void 0;
|
|
44
|
-
return { value: o && o[i++], done: !o };
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
-
};
|
|
49
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
50
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
|
-
if (!m) return o;
|
|
52
|
-
var i = m.call(o), r, ar = [], e;
|
|
53
|
-
try {
|
|
54
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
55
|
-
}
|
|
56
|
-
catch (error) { e = { error: error }; }
|
|
57
|
-
finally {
|
|
58
|
-
try {
|
|
59
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
60
|
-
}
|
|
61
|
-
finally { if (e) throw e.error; }
|
|
62
|
-
}
|
|
63
|
-
return ar;
|
|
64
|
-
};
|
|
65
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
66
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
67
|
-
if (ar || !(i in from)) {
|
|
68
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
69
|
-
ar[i] = from[i];
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
73
|
-
};
|
|
74
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
75
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
76
13
|
};
|
|
77
|
-
exports
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
78
15
|
exports.getAltStatusMessage = exports.StatusCodes = exports.TransportStatusError = exports.TransportError = void 0;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
exports
|
|
82
|
-
exports
|
|
83
|
-
exports
|
|
84
|
-
exports
|
|
16
|
+
const events_1 = __importDefault(require("events"));
|
|
17
|
+
const errors_1 = require("@ledgerhq/errors");
|
|
18
|
+
Object.defineProperty(exports, "TransportError", { enumerable: true, get: function () { return errors_1.TransportError; } });
|
|
19
|
+
Object.defineProperty(exports, "StatusCodes", { enumerable: true, get: function () { return errors_1.StatusCodes; } });
|
|
20
|
+
Object.defineProperty(exports, "getAltStatusMessage", { enumerable: true, get: function () { return errors_1.getAltStatusMessage; } });
|
|
21
|
+
Object.defineProperty(exports, "TransportStatusError", { enumerable: true, get: function () { return errors_1.TransportStatusError; } });
|
|
85
22
|
/**
|
|
86
23
|
* The Transport class defines a generic interface for communicating with a Ledger hardware wallet.
|
|
87
24
|
* There are different kind of transports based on the technology (channels like U2F, HID, Bluetooth, Webusb) and environment (Node, Web,...).
|
|
88
25
|
* It is an abstract class that needs to be implemented.
|
|
89
26
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
var _this = this;
|
|
27
|
+
class Transport {
|
|
28
|
+
constructor() {
|
|
93
29
|
this.exchangeTimeout = 30000;
|
|
94
30
|
this.unresponsiveTimeout = 15000;
|
|
95
31
|
this.deviceModel = null;
|
|
96
|
-
this._events = new events_1
|
|
32
|
+
this._events = new events_1.default();
|
|
97
33
|
/**
|
|
98
34
|
* Send data to the device using the higher level API.
|
|
99
35
|
* @param {number} cla - The instruction class for the command.
|
|
@@ -104,71 +40,49 @@ var Transport = /** @class */ (function () {
|
|
|
104
40
|
* @param {Array<number>} statusList - A list of acceptable status codes for the response. Defaults to [StatusCodes.OK].
|
|
105
41
|
* @returns {Promise<Buffer>} A promise that resolves with the response data from the device.
|
|
106
42
|
*/
|
|
107
|
-
this.send =
|
|
108
|
-
if (data
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return [2 /*return*/, response];
|
|
130
|
-
}
|
|
131
|
-
});
|
|
43
|
+
this.send = (cla, ins, p1, p2, data = Buffer.alloc(0), statusList = [errors_1.StatusCodes.OK]) => __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
if (data.length >= 256) {
|
|
45
|
+
throw new errors_1.TransportError("data.length exceed 256 bytes limit. Got: " + data.length, "DataLengthTooBig");
|
|
46
|
+
}
|
|
47
|
+
const response = yield this.exchange(Buffer.concat([
|
|
48
|
+
Buffer.from([cla, ins, p1, p2]),
|
|
49
|
+
Buffer.from([data.length]),
|
|
50
|
+
data,
|
|
51
|
+
]));
|
|
52
|
+
const sw = response.readUInt16BE(response.length - 2);
|
|
53
|
+
if (!statusList.some((s) => s === sw)) {
|
|
54
|
+
throw new errors_1.TransportStatusError(sw);
|
|
55
|
+
}
|
|
56
|
+
return response;
|
|
57
|
+
});
|
|
58
|
+
this.exchangeAtomicImpl = (f) => __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
if (this.exchangeBusyPromise) {
|
|
60
|
+
throw new errors_1.TransportRaceCondition("An action was already pending on the Ledger device. Please deny or reconnect.");
|
|
61
|
+
}
|
|
62
|
+
let resolveBusy;
|
|
63
|
+
const busyPromise = new Promise((r) => {
|
|
64
|
+
resolveBusy = r;
|
|
132
65
|
});
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
busyPromise = new Promise(function (r) {
|
|
144
|
-
resolveBusy = r;
|
|
145
|
-
});
|
|
146
|
-
this.exchangeBusyPromise = busyPromise;
|
|
147
|
-
unresponsiveReached = false;
|
|
148
|
-
timeout = setTimeout(function () {
|
|
149
|
-
unresponsiveReached = true;
|
|
150
|
-
_this.emit("unresponsive");
|
|
151
|
-
}, this.unresponsiveTimeout);
|
|
152
|
-
_a.label = 1;
|
|
153
|
-
case 1:
|
|
154
|
-
_a.trys.push([1, , 3, 4]);
|
|
155
|
-
return [4 /*yield*/, f()];
|
|
156
|
-
case 2:
|
|
157
|
-
res = _a.sent();
|
|
158
|
-
if (unresponsiveReached) {
|
|
159
|
-
this.emit("responsive");
|
|
160
|
-
}
|
|
161
|
-
return [2 /*return*/, res];
|
|
162
|
-
case 3:
|
|
163
|
-
clearTimeout(timeout);
|
|
164
|
-
if (resolveBusy)
|
|
165
|
-
resolveBusy();
|
|
166
|
-
this.exchangeBusyPromise = null;
|
|
167
|
-
return [7 /*endfinally*/];
|
|
168
|
-
case 4: return [2 /*return*/];
|
|
66
|
+
this.exchangeBusyPromise = busyPromise;
|
|
67
|
+
let unresponsiveReached = false;
|
|
68
|
+
const timeout = setTimeout(() => {
|
|
69
|
+
unresponsiveReached = true;
|
|
70
|
+
this.emit("unresponsive");
|
|
71
|
+
}, this.unresponsiveTimeout);
|
|
72
|
+
try {
|
|
73
|
+
const res = yield f();
|
|
74
|
+
if (unresponsiveReached) {
|
|
75
|
+
this.emit("responsive");
|
|
169
76
|
}
|
|
170
|
-
|
|
171
|
-
|
|
77
|
+
return res;
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
clearTimeout(timeout);
|
|
81
|
+
if (resolveBusy)
|
|
82
|
+
resolveBusy();
|
|
83
|
+
this.exchangeBusyPromise = null;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
172
86
|
this._appAPIlock = null;
|
|
173
87
|
}
|
|
174
88
|
/**
|
|
@@ -177,9 +91,9 @@ var Transport = /** @class */ (function () {
|
|
|
177
91
|
* @param {Buffer} apdu - The data to send.
|
|
178
92
|
* @returns {Promise<Buffer>} A promise that resolves with the response data from the device.
|
|
179
93
|
*/
|
|
180
|
-
|
|
94
|
+
exchange(_apdu) {
|
|
181
95
|
throw new Error("exchange not implemented");
|
|
182
|
-
}
|
|
96
|
+
}
|
|
183
97
|
/**
|
|
184
98
|
* Send apdus in batch to the device using a low level API.
|
|
185
99
|
* The default implementation is to call exchange for each apdu.
|
|
@@ -187,74 +101,42 @@ var Transport = /** @class */ (function () {
|
|
|
187
101
|
* @param {Observer<Buffer>} observer - an observer that will receive the response of each apdu.
|
|
188
102
|
* @returns {Subscription} A Subscription object on which you can call ".unsubscribe()" to stop sending apdus.
|
|
189
103
|
*/
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
var unsubscribe = function () {
|
|
104
|
+
exchangeBulk(apdus, observer) {
|
|
105
|
+
let unsubscribed = false;
|
|
106
|
+
const unsubscribe = () => {
|
|
194
107
|
unsubscribed = true;
|
|
195
108
|
};
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
_b.trys.push([1, 6, 7, 8]);
|
|
207
|
-
apdus_1 = __values(apdus), apdus_1_1 = apdus_1.next();
|
|
208
|
-
_b.label = 2;
|
|
209
|
-
case 2:
|
|
210
|
-
if (!!apdus_1_1.done) return [3 /*break*/, 5];
|
|
211
|
-
apdu = apdus_1_1.value;
|
|
212
|
-
return [4 /*yield*/, this.exchange(apdu)];
|
|
213
|
-
case 3:
|
|
214
|
-
r = _b.sent();
|
|
215
|
-
if (unsubscribed)
|
|
216
|
-
return [2 /*return*/];
|
|
217
|
-
status_1 = r.readUInt16BE(r.length - 2);
|
|
218
|
-
if (status_1 !== errors_1.StatusCodes.OK) {
|
|
219
|
-
throw new errors_1.TransportStatusError(status_1);
|
|
220
|
-
}
|
|
221
|
-
observer.next(r);
|
|
222
|
-
_b.label = 4;
|
|
223
|
-
case 4:
|
|
224
|
-
apdus_1_1 = apdus_1.next();
|
|
225
|
-
return [3 /*break*/, 2];
|
|
226
|
-
case 5: return [3 /*break*/, 8];
|
|
227
|
-
case 6:
|
|
228
|
-
e_1_1 = _b.sent();
|
|
229
|
-
e_1 = { error: e_1_1 };
|
|
230
|
-
return [3 /*break*/, 8];
|
|
231
|
-
case 7:
|
|
232
|
-
try {
|
|
233
|
-
if (apdus_1_1 && !apdus_1_1.done && (_a = apdus_1["return"])) _a.call(apdus_1);
|
|
234
|
-
}
|
|
235
|
-
finally { if (e_1) throw e_1.error; }
|
|
236
|
-
return [7 /*endfinally*/];
|
|
237
|
-
case 8: return [2 /*return*/];
|
|
109
|
+
const main = () => __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
if (unsubscribed)
|
|
111
|
+
return;
|
|
112
|
+
for (const apdu of apdus) {
|
|
113
|
+
const r = yield this.exchange(apdu);
|
|
114
|
+
if (unsubscribed)
|
|
115
|
+
return;
|
|
116
|
+
const status = r.readUInt16BE(r.length - 2);
|
|
117
|
+
if (status !== errors_1.StatusCodes.OK) {
|
|
118
|
+
throw new errors_1.TransportStatusError(status);
|
|
238
119
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
120
|
+
observer.next(r);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
main().then(() => !unsubscribed && observer.complete(), (e) => !unsubscribed && observer.error(e));
|
|
124
|
+
return { unsubscribe };
|
|
125
|
+
}
|
|
244
126
|
/**
|
|
245
127
|
* Set the "scramble key" for the next data exchanges with the device.
|
|
246
128
|
* Each app can have a different scramble key and it is set internally during instantiation.
|
|
247
129
|
* @param {string} key - The scramble key to set.
|
|
248
130
|
* @deprecated This method is no longer needed for modern transports and should be migrated away from.
|
|
249
131
|
*/
|
|
250
|
-
|
|
132
|
+
setScrambleKey(_key) { }
|
|
251
133
|
/**
|
|
252
134
|
* Close the connection with the device.
|
|
253
135
|
* @returns {Promise<void>} A promise that resolves when the transport is closed.
|
|
254
136
|
*/
|
|
255
|
-
|
|
137
|
+
close() {
|
|
256
138
|
return Promise.resolve();
|
|
257
|
-
}
|
|
139
|
+
}
|
|
258
140
|
/**
|
|
259
141
|
* Listen for an event on the transport instance.
|
|
260
142
|
* Transport implementations may have specific events. Common events include:
|
|
@@ -262,41 +144,36 @@ var Transport = /** @class */ (function () {
|
|
|
262
144
|
* @param {string} eventName - The name of the event to listen for.
|
|
263
145
|
* @param {(...args: Array<any>) => any} cb - The callback function to be invoked when the event occurs.
|
|
264
146
|
*/
|
|
265
|
-
|
|
147
|
+
on(eventName, cb) {
|
|
266
148
|
this._events.on(eventName, cb);
|
|
267
|
-
}
|
|
149
|
+
}
|
|
268
150
|
/**
|
|
269
151
|
* Stop listening to an event on an instance of transport.
|
|
270
152
|
*/
|
|
271
|
-
|
|
153
|
+
off(eventName, cb) {
|
|
272
154
|
this._events.removeListener(eventName, cb);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
278
|
-
args[_i - 1] = arguments[_i];
|
|
279
|
-
}
|
|
280
|
-
(_a = this._events).emit.apply(_a, __spreadArray([event], __read(args), false));
|
|
281
|
-
};
|
|
155
|
+
}
|
|
156
|
+
emit(event, ...args) {
|
|
157
|
+
this._events.emit(event, ...args);
|
|
158
|
+
}
|
|
282
159
|
/**
|
|
283
160
|
* Enable or not logs of the binary exchange
|
|
284
161
|
*/
|
|
285
|
-
|
|
162
|
+
setDebugMode() {
|
|
286
163
|
console.warn("setDebugMode is deprecated. use @ledgerhq/logs instead. No logs are emitted in this anymore.");
|
|
287
|
-
}
|
|
164
|
+
}
|
|
288
165
|
/**
|
|
289
166
|
* Set a timeout (in milliseconds) for the exchange call. Only some transport might implement it. (e.g. U2F)
|
|
290
167
|
*/
|
|
291
|
-
|
|
168
|
+
setExchangeTimeout(exchangeTimeout) {
|
|
292
169
|
this.exchangeTimeout = exchangeTimeout;
|
|
293
|
-
}
|
|
170
|
+
}
|
|
294
171
|
/**
|
|
295
172
|
* Define the delay before emitting "unresponsive" on an exchange that does not respond
|
|
296
173
|
*/
|
|
297
|
-
|
|
174
|
+
setExchangeUnresponsiveTimeout(unresponsiveTimeout) {
|
|
298
175
|
this.unresponsiveTimeout = unresponsiveTimeout;
|
|
299
|
-
}
|
|
176
|
+
}
|
|
300
177
|
/**
|
|
301
178
|
* create() allows to open the first descriptor available or
|
|
302
179
|
* throw if there is none or if timeout is reached.
|
|
@@ -304,92 +181,62 @@ var Transport = /** @class */ (function () {
|
|
|
304
181
|
* @example
|
|
305
182
|
TransportFoo.create().then(transport => ...)
|
|
306
183
|
*/
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
var sub = _this.listen({
|
|
313
|
-
next: function (e) {
|
|
184
|
+
static create(openTimeout = 3000, listenTimeout) {
|
|
185
|
+
return new Promise((resolve, reject) => {
|
|
186
|
+
let found = false;
|
|
187
|
+
const sub = this.listen({
|
|
188
|
+
next: (e) => {
|
|
314
189
|
found = true;
|
|
315
190
|
if (sub)
|
|
316
191
|
sub.unsubscribe();
|
|
317
192
|
if (listenTimeoutId)
|
|
318
193
|
clearTimeout(listenTimeoutId);
|
|
319
|
-
|
|
194
|
+
this.open(e.descriptor, openTimeout).then(resolve, reject);
|
|
320
195
|
},
|
|
321
|
-
error:
|
|
196
|
+
error: (e) => {
|
|
322
197
|
if (listenTimeoutId)
|
|
323
198
|
clearTimeout(listenTimeoutId);
|
|
324
199
|
reject(e);
|
|
325
200
|
},
|
|
326
|
-
complete:
|
|
201
|
+
complete: () => {
|
|
327
202
|
if (listenTimeoutId)
|
|
328
203
|
clearTimeout(listenTimeoutId);
|
|
329
204
|
if (!found) {
|
|
330
|
-
reject(new errors_1.TransportError(
|
|
205
|
+
reject(new errors_1.TransportError(this.ErrorMessage_NoDeviceFound, "NoDeviceFound"));
|
|
331
206
|
}
|
|
332
|
-
}
|
|
207
|
+
},
|
|
333
208
|
});
|
|
334
|
-
|
|
335
|
-
? setTimeout(
|
|
209
|
+
const listenTimeoutId = listenTimeout
|
|
210
|
+
? setTimeout(() => {
|
|
336
211
|
sub.unsubscribe();
|
|
337
|
-
reject(new errors_1.TransportError(
|
|
212
|
+
reject(new errors_1.TransportError(this.ErrorMessage_ListenTimeout, "ListenTimeout"));
|
|
338
213
|
}, listenTimeout)
|
|
339
214
|
: null;
|
|
340
215
|
});
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
for (var methods_1 = __values(methods), methods_1_1 = methods_1.next(); !methods_1_1.done; methods_1_1 = methods_1.next()) {
|
|
346
|
-
var methodName = methods_1_1.value;
|
|
347
|
-
self[methodName] = this.decorateAppAPIMethod(methodName, self[methodName], self, scrambleKey);
|
|
348
|
-
}
|
|
216
|
+
}
|
|
217
|
+
decorateAppAPIMethods(self, methods, scrambleKey) {
|
|
218
|
+
for (const methodName of methods) {
|
|
219
|
+
self[methodName] = this.decorateAppAPIMethod(methodName, self[methodName], self, scrambleKey);
|
|
349
220
|
}
|
|
350
|
-
|
|
351
|
-
|
|
221
|
+
}
|
|
222
|
+
decorateAppAPIMethod(methodName, f, ctx, scrambleKey) {
|
|
223
|
+
return (...args) => __awaiter(this, void 0, void 0, function* () {
|
|
224
|
+
const { _appAPIlock } = this;
|
|
225
|
+
if (_appAPIlock) {
|
|
226
|
+
return Promise.reject(new errors_1.TransportError("Ledger Device is busy (lock " + _appAPIlock + ")", "TransportLocked"));
|
|
227
|
+
}
|
|
352
228
|
try {
|
|
353
|
-
|
|
229
|
+
this._appAPIlock = methodName;
|
|
230
|
+
this.setScrambleKey(scrambleKey);
|
|
231
|
+
return yield f.apply(ctx, args);
|
|
354
232
|
}
|
|
355
|
-
finally {
|
|
356
|
-
|
|
357
|
-
};
|
|
358
|
-
Transport.prototype.decorateAppAPIMethod = function (methodName, f, ctx, scrambleKey) {
|
|
359
|
-
var _this = this;
|
|
360
|
-
return function () {
|
|
361
|
-
var args = [];
|
|
362
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
363
|
-
args[_i] = arguments[_i];
|
|
233
|
+
finally {
|
|
234
|
+
this._appAPIlock = null;
|
|
364
235
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
if (_appAPIlock) {
|
|
372
|
-
return [2 /*return*/, Promise.reject(new errors_1.TransportError("Ledger Device is busy (lock " + _appAPIlock + ")", "TransportLocked"))];
|
|
373
|
-
}
|
|
374
|
-
_a.label = 1;
|
|
375
|
-
case 1:
|
|
376
|
-
_a.trys.push([1, , 3, 4]);
|
|
377
|
-
this._appAPIlock = methodName;
|
|
378
|
-
this.setScrambleKey(scrambleKey);
|
|
379
|
-
return [4 /*yield*/, f.apply(ctx, args)];
|
|
380
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
381
|
-
case 3:
|
|
382
|
-
this._appAPIlock = null;
|
|
383
|
-
return [7 /*endfinally*/];
|
|
384
|
-
case 4: return [2 /*return*/];
|
|
385
|
-
}
|
|
386
|
-
});
|
|
387
|
-
});
|
|
388
|
-
};
|
|
389
|
-
};
|
|
390
|
-
Transport.ErrorMessage_ListenTimeout = "No Ledger device found (timeout)";
|
|
391
|
-
Transport.ErrorMessage_NoDeviceFound = "No Ledger device found";
|
|
392
|
-
return Transport;
|
|
393
|
-
}());
|
|
394
|
-
exports["default"] = Transport;
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
exports.default = Transport;
|
|
240
|
+
Transport.ErrorMessage_ListenTimeout = "No Ledger device found (timeout)";
|
|
241
|
+
Transport.ErrorMessage_NoDeviceFound = "No Ledger device found";
|
|
395
242
|
//# sourceMappingURL=Transport.js.map
|
package/lib/Transport.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transport.js","sourceRoot":"","sources":["../src/Transport.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Transport.js","sourceRoot":"","sources":["../src/Transport.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAkC;AAElC,6CAM0B;AAExB,+FANA,uBAAc,OAMA;AAEd,4FAPA,oBAAW,OAOA;AACX,oGAPA,4BAAmB,OAOA;AAFnB,qGAJA,6BAAoB,OAIA;AAuCtB;;;;GAIG;AACH,MAAqB,SAAS;IAA9B;QACE,oBAAe,GAAG,KAAK,CAAC;QACxB,wBAAmB,GAAG,KAAK,CAAC;QAC5B,gBAAW,GAAmC,IAAI,CAAC;QAkHnD,YAAO,GAAG,IAAI,gBAAY,EAAE,CAAC;QA+C7B;;;;;;;;;WASG;QACH,SAAI,GAAG,CACL,GAAW,EACX,GAAW,EACX,EAAU,EACV,EAAU,EACV,OAAe,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAC9B,aAA4B,CAAC,oBAAW,CAAC,EAAE,CAAC,EAC3B,EAAE;YACnB,IAAI,IAAI,CAAC,MAAM,IAAI,GAAG,EAAE;gBACtB,MAAM,IAAI,uBAAc,CACtB,2CAA2C,GAAG,I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6B,EAC7B,GAAQ,EACR,WAAmB;QAEnB,OAAO,CAAO,GAAG,IAAI,EAAE,EAAE;YACvB,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;YAE7B,IAAI,WAAW,EAAE;gBACf,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,uBAAc,CAChB,8BAA8B,GAAG,WAAW,GAAG,GAAG,EAClD,iBAAiB,CAClB,CACF,CAAC;aACH;YAED,IAAI;gBACF,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;gBAC9B,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;gBACjC,OAAO,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;aACjC;oBAAS;gBACR,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;aACzB;QACH,CAAC,CAAA,CAAC;IACJ,CAAC;;AA/UH,4BAmVC;AAFQ,oCAA0B,GAAG,kCAAkC,CAAC;AAChE,oCAA0B,GAAG,wBAAwB,CAAC"}
|
package/lib-es/Transport.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import EventEmitter from "events";
|
|
3
4
|
import type { DeviceModel } from "@ledgerhq/devices";
|
|
4
5
|
import { TransportError, StatusCodes, getAltStatusMessage, TransportStatusError } from "@ledgerhq/errors";
|
|
5
6
|
export { TransportError, TransportStatusError, StatusCodes, getAltStatusMessage, };
|
|
6
7
|
/**
|
|
7
8
|
*/
|
|
8
|
-
export
|
|
9
|
+
export type Subscription = {
|
|
9
10
|
unsubscribe: () => void;
|
|
10
11
|
};
|
|
11
12
|
/**
|
|
12
13
|
*/
|
|
13
|
-
export
|
|
14
|
-
export
|
|
14
|
+
export type Device = any;
|
|
15
|
+
export type DescriptorEventType = "add" | "remove";
|
|
15
16
|
/**
|
|
16
17
|
* A "descriptor" is a parameter that is specific to the implementation, and can be an ID, file path, or URL.
|
|
17
18
|
* type: add or remove event
|
|
@@ -28,7 +29,7 @@ export interface DescriptorEvent<Descriptor> {
|
|
|
28
29
|
/**
|
|
29
30
|
* Observer generic type, following the Observer pattern
|
|
30
31
|
*/
|
|
31
|
-
export
|
|
32
|
+
export type Observer<EventType, EventError = unknown> = Readonly<{
|
|
32
33
|
next: (event: EventType) => unknown;
|
|
33
34
|
error: (e: EventError) => unknown;
|
|
34
35
|
complete: () => unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transport.d.ts","sourceRoot":"","sources":["../src/Transport.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Transport.d.ts","sourceRoot":"","sources":["../src/Transport.ts"],"names":[],"mappings":";;AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAEL,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,mBAAmB,GACpB,CAAC;AAEF;GACG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB,CAAC;AAEF;GACG;AACH,MAAM,MAAM,MAAM,GAAG,GAAG,CAAC;AAEzB,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,QAAQ,CAAC;AACnD;;;;;;GAMG;AACH,MAAM,WAAW,eAAe,CAAC,UAAU;IACzC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,MAAM,QAAQ,CAAC,SAAS,EAAE,UAAU,GAAG,OAAO,IAAI,QAAQ,CAAC;IAC/D,IAAI,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EAC7B,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,MAAM,GAClB,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC;IAuB7B,MAAM,CAAC,0BAA0B,SAAsC;IACvE,MAAM,CAAC,0BAA0B,SAA4B;CAC9D"}
|
package/lib-es/Transport.js
CHANGED
|
@@ -7,69 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var __values = (this && this.__values) || function(o) {
|
|
38
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
39
|
-
if (m) return m.call(o);
|
|
40
|
-
if (o && typeof o.length === "number") return {
|
|
41
|
-
next: function () {
|
|
42
|
-
if (o && i >= o.length) o = void 0;
|
|
43
|
-
return { value: o && o[i++], done: !o };
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
47
|
-
};
|
|
48
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
49
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
50
|
-
if (!m) return o;
|
|
51
|
-
var i = m.call(o), r, ar = [], e;
|
|
52
|
-
try {
|
|
53
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
54
|
-
}
|
|
55
|
-
catch (error) { e = { error: error }; }
|
|
56
|
-
finally {
|
|
57
|
-
try {
|
|
58
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
59
|
-
}
|
|
60
|
-
finally { if (e) throw e.error; }
|
|
61
|
-
}
|
|
62
|
-
return ar;
|
|
63
|
-
};
|
|
64
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
65
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
66
|
-
if (ar || !(i in from)) {
|
|
67
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
68
|
-
ar[i] = from[i];
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
72
|
-
};
|
|
73
10
|
import EventEmitter from "events";
|
|
74
11
|
import { TransportRaceCondition, TransportError, StatusCodes, getAltStatusMessage, TransportStatusError, } from "@ledgerhq/errors";
|
|
75
12
|
export { TransportError, TransportStatusError, StatusCodes, getAltStatusMessage, };
|
|
@@ -78,9 +15,8 @@ export { TransportError, TransportStatusError, StatusCodes, getAltStatusMessage,
|
|
|
78
15
|
* There are different kind of transports based on the technology (channels like U2F, HID, Bluetooth, Webusb) and environment (Node, Web,...).
|
|
79
16
|
* It is an abstract class that needs to be implemented.
|
|
80
17
|
*/
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
var _this = this;
|
|
18
|
+
export default class Transport {
|
|
19
|
+
constructor() {
|
|
84
20
|
this.exchangeTimeout = 30000;
|
|
85
21
|
this.unresponsiveTimeout = 15000;
|
|
86
22
|
this.deviceModel = null;
|
|
@@ -95,71 +31,49 @@ var Transport = /** @class */ (function () {
|
|
|
95
31
|
* @param {Array<number>} statusList - A list of acceptable status codes for the response. Defaults to [StatusCodes.OK].
|
|
96
32
|
* @returns {Promise<Buffer>} A promise that resolves with the response data from the device.
|
|
97
33
|
*/
|
|
98
|
-
this.send =
|
|
99
|
-
if (data
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return [2 /*return*/, response];
|
|
121
|
-
}
|
|
122
|
-
});
|
|
34
|
+
this.send = (cla, ins, p1, p2, data = Buffer.alloc(0), statusList = [StatusCodes.OK]) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
if (data.length >= 256) {
|
|
36
|
+
throw new TransportError("data.length exceed 256 bytes limit. Got: " + data.length, "DataLengthTooBig");
|
|
37
|
+
}
|
|
38
|
+
const response = yield this.exchange(Buffer.concat([
|
|
39
|
+
Buffer.from([cla, ins, p1, p2]),
|
|
40
|
+
Buffer.from([data.length]),
|
|
41
|
+
data,
|
|
42
|
+
]));
|
|
43
|
+
const sw = response.readUInt16BE(response.length - 2);
|
|
44
|
+
if (!statusList.some((s) => s === sw)) {
|
|
45
|
+
throw new TransportStatusError(sw);
|
|
46
|
+
}
|
|
47
|
+
return response;
|
|
48
|
+
});
|
|
49
|
+
this.exchangeAtomicImpl = (f) => __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
if (this.exchangeBusyPromise) {
|
|
51
|
+
throw new TransportRaceCondition("An action was already pending on the Ledger device. Please deny or reconnect.");
|
|
52
|
+
}
|
|
53
|
+
let resolveBusy;
|
|
54
|
+
const busyPromise = new Promise((r) => {
|
|
55
|
+
resolveBusy = r;
|
|
123
56
|
});
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
busyPromise = new Promise(function (r) {
|
|
135
|
-
resolveBusy = r;
|
|
136
|
-
});
|
|
137
|
-
this.exchangeBusyPromise = busyPromise;
|
|
138
|
-
unresponsiveReached = false;
|
|
139
|
-
timeout = setTimeout(function () {
|
|
140
|
-
unresponsiveReached = true;
|
|
141
|
-
_this.emit("unresponsive");
|
|
142
|
-
}, this.unresponsiveTimeout);
|
|
143
|
-
_a.label = 1;
|
|
144
|
-
case 1:
|
|
145
|
-
_a.trys.push([1, , 3, 4]);
|
|
146
|
-
return [4 /*yield*/, f()];
|
|
147
|
-
case 2:
|
|
148
|
-
res = _a.sent();
|
|
149
|
-
if (unresponsiveReached) {
|
|
150
|
-
this.emit("responsive");
|
|
151
|
-
}
|
|
152
|
-
return [2 /*return*/, res];
|
|
153
|
-
case 3:
|
|
154
|
-
clearTimeout(timeout);
|
|
155
|
-
if (resolveBusy)
|
|
156
|
-
resolveBusy();
|
|
157
|
-
this.exchangeBusyPromise = null;
|
|
158
|
-
return [7 /*endfinally*/];
|
|
159
|
-
case 4: return [2 /*return*/];
|
|
57
|
+
this.exchangeBusyPromise = busyPromise;
|
|
58
|
+
let unresponsiveReached = false;
|
|
59
|
+
const timeout = setTimeout(() => {
|
|
60
|
+
unresponsiveReached = true;
|
|
61
|
+
this.emit("unresponsive");
|
|
62
|
+
}, this.unresponsiveTimeout);
|
|
63
|
+
try {
|
|
64
|
+
const res = yield f();
|
|
65
|
+
if (unresponsiveReached) {
|
|
66
|
+
this.emit("responsive");
|
|
160
67
|
}
|
|
161
|
-
|
|
162
|
-
|
|
68
|
+
return res;
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
clearTimeout(timeout);
|
|
72
|
+
if (resolveBusy)
|
|
73
|
+
resolveBusy();
|
|
74
|
+
this.exchangeBusyPromise = null;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
163
77
|
this._appAPIlock = null;
|
|
164
78
|
}
|
|
165
79
|
/**
|
|
@@ -168,9 +82,9 @@ var Transport = /** @class */ (function () {
|
|
|
168
82
|
* @param {Buffer} apdu - The data to send.
|
|
169
83
|
* @returns {Promise<Buffer>} A promise that resolves with the response data from the device.
|
|
170
84
|
*/
|
|
171
|
-
|
|
85
|
+
exchange(_apdu) {
|
|
172
86
|
throw new Error("exchange not implemented");
|
|
173
|
-
}
|
|
87
|
+
}
|
|
174
88
|
/**
|
|
175
89
|
* Send apdus in batch to the device using a low level API.
|
|
176
90
|
* The default implementation is to call exchange for each apdu.
|
|
@@ -178,74 +92,42 @@ var Transport = /** @class */ (function () {
|
|
|
178
92
|
* @param {Observer<Buffer>} observer - an observer that will receive the response of each apdu.
|
|
179
93
|
* @returns {Subscription} A Subscription object on which you can call ".unsubscribe()" to stop sending apdus.
|
|
180
94
|
*/
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
var unsubscribe = function () {
|
|
95
|
+
exchangeBulk(apdus, observer) {
|
|
96
|
+
let unsubscribed = false;
|
|
97
|
+
const unsubscribe = () => {
|
|
185
98
|
unsubscribed = true;
|
|
186
99
|
};
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
_b.trys.push([1, 6, 7, 8]);
|
|
198
|
-
apdus_1 = __values(apdus), apdus_1_1 = apdus_1.next();
|
|
199
|
-
_b.label = 2;
|
|
200
|
-
case 2:
|
|
201
|
-
if (!!apdus_1_1.done) return [3 /*break*/, 5];
|
|
202
|
-
apdu = apdus_1_1.value;
|
|
203
|
-
return [4 /*yield*/, this.exchange(apdu)];
|
|
204
|
-
case 3:
|
|
205
|
-
r = _b.sent();
|
|
206
|
-
if (unsubscribed)
|
|
207
|
-
return [2 /*return*/];
|
|
208
|
-
status_1 = r.readUInt16BE(r.length - 2);
|
|
209
|
-
if (status_1 !== StatusCodes.OK) {
|
|
210
|
-
throw new TransportStatusError(status_1);
|
|
211
|
-
}
|
|
212
|
-
observer.next(r);
|
|
213
|
-
_b.label = 4;
|
|
214
|
-
case 4:
|
|
215
|
-
apdus_1_1 = apdus_1.next();
|
|
216
|
-
return [3 /*break*/, 2];
|
|
217
|
-
case 5: return [3 /*break*/, 8];
|
|
218
|
-
case 6:
|
|
219
|
-
e_1_1 = _b.sent();
|
|
220
|
-
e_1 = { error: e_1_1 };
|
|
221
|
-
return [3 /*break*/, 8];
|
|
222
|
-
case 7:
|
|
223
|
-
try {
|
|
224
|
-
if (apdus_1_1 && !apdus_1_1.done && (_a = apdus_1["return"])) _a.call(apdus_1);
|
|
225
|
-
}
|
|
226
|
-
finally { if (e_1) throw e_1.error; }
|
|
227
|
-
return [7 /*endfinally*/];
|
|
228
|
-
case 8: return [2 /*return*/];
|
|
100
|
+
const main = () => __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
if (unsubscribed)
|
|
102
|
+
return;
|
|
103
|
+
for (const apdu of apdus) {
|
|
104
|
+
const r = yield this.exchange(apdu);
|
|
105
|
+
if (unsubscribed)
|
|
106
|
+
return;
|
|
107
|
+
const status = r.readUInt16BE(r.length - 2);
|
|
108
|
+
if (status !== StatusCodes.OK) {
|
|
109
|
+
throw new TransportStatusError(status);
|
|
229
110
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
111
|
+
observer.next(r);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
main().then(() => !unsubscribed && observer.complete(), (e) => !unsubscribed && observer.error(e));
|
|
115
|
+
return { unsubscribe };
|
|
116
|
+
}
|
|
235
117
|
/**
|
|
236
118
|
* Set the "scramble key" for the next data exchanges with the device.
|
|
237
119
|
* Each app can have a different scramble key and it is set internally during instantiation.
|
|
238
120
|
* @param {string} key - The scramble key to set.
|
|
239
121
|
* @deprecated This method is no longer needed for modern transports and should be migrated away from.
|
|
240
122
|
*/
|
|
241
|
-
|
|
123
|
+
setScrambleKey(_key) { }
|
|
242
124
|
/**
|
|
243
125
|
* Close the connection with the device.
|
|
244
126
|
* @returns {Promise<void>} A promise that resolves when the transport is closed.
|
|
245
127
|
*/
|
|
246
|
-
|
|
128
|
+
close() {
|
|
247
129
|
return Promise.resolve();
|
|
248
|
-
}
|
|
130
|
+
}
|
|
249
131
|
/**
|
|
250
132
|
* Listen for an event on the transport instance.
|
|
251
133
|
* Transport implementations may have specific events. Common events include:
|
|
@@ -253,41 +135,36 @@ var Transport = /** @class */ (function () {
|
|
|
253
135
|
* @param {string} eventName - The name of the event to listen for.
|
|
254
136
|
* @param {(...args: Array<any>) => any} cb - The callback function to be invoked when the event occurs.
|
|
255
137
|
*/
|
|
256
|
-
|
|
138
|
+
on(eventName, cb) {
|
|
257
139
|
this._events.on(eventName, cb);
|
|
258
|
-
}
|
|
140
|
+
}
|
|
259
141
|
/**
|
|
260
142
|
* Stop listening to an event on an instance of transport.
|
|
261
143
|
*/
|
|
262
|
-
|
|
144
|
+
off(eventName, cb) {
|
|
263
145
|
this._events.removeListener(eventName, cb);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
269
|
-
args[_i - 1] = arguments[_i];
|
|
270
|
-
}
|
|
271
|
-
(_a = this._events).emit.apply(_a, __spreadArray([event], __read(args), false));
|
|
272
|
-
};
|
|
146
|
+
}
|
|
147
|
+
emit(event, ...args) {
|
|
148
|
+
this._events.emit(event, ...args);
|
|
149
|
+
}
|
|
273
150
|
/**
|
|
274
151
|
* Enable or not logs of the binary exchange
|
|
275
152
|
*/
|
|
276
|
-
|
|
153
|
+
setDebugMode() {
|
|
277
154
|
console.warn("setDebugMode is deprecated. use @ledgerhq/logs instead. No logs are emitted in this anymore.");
|
|
278
|
-
}
|
|
155
|
+
}
|
|
279
156
|
/**
|
|
280
157
|
* Set a timeout (in milliseconds) for the exchange call. Only some transport might implement it. (e.g. U2F)
|
|
281
158
|
*/
|
|
282
|
-
|
|
159
|
+
setExchangeTimeout(exchangeTimeout) {
|
|
283
160
|
this.exchangeTimeout = exchangeTimeout;
|
|
284
|
-
}
|
|
161
|
+
}
|
|
285
162
|
/**
|
|
286
163
|
* Define the delay before emitting "unresponsive" on an exchange that does not respond
|
|
287
164
|
*/
|
|
288
|
-
|
|
165
|
+
setExchangeUnresponsiveTimeout(unresponsiveTimeout) {
|
|
289
166
|
this.unresponsiveTimeout = unresponsiveTimeout;
|
|
290
|
-
}
|
|
167
|
+
}
|
|
291
168
|
/**
|
|
292
169
|
* create() allows to open the first descriptor available or
|
|
293
170
|
* throw if there is none or if timeout is reached.
|
|
@@ -295,92 +172,61 @@ var Transport = /** @class */ (function () {
|
|
|
295
172
|
* @example
|
|
296
173
|
TransportFoo.create().then(transport => ...)
|
|
297
174
|
*/
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
var sub = _this.listen({
|
|
304
|
-
next: function (e) {
|
|
175
|
+
static create(openTimeout = 3000, listenTimeout) {
|
|
176
|
+
return new Promise((resolve, reject) => {
|
|
177
|
+
let found = false;
|
|
178
|
+
const sub = this.listen({
|
|
179
|
+
next: (e) => {
|
|
305
180
|
found = true;
|
|
306
181
|
if (sub)
|
|
307
182
|
sub.unsubscribe();
|
|
308
183
|
if (listenTimeoutId)
|
|
309
184
|
clearTimeout(listenTimeoutId);
|
|
310
|
-
|
|
185
|
+
this.open(e.descriptor, openTimeout).then(resolve, reject);
|
|
311
186
|
},
|
|
312
|
-
error:
|
|
187
|
+
error: (e) => {
|
|
313
188
|
if (listenTimeoutId)
|
|
314
189
|
clearTimeout(listenTimeoutId);
|
|
315
190
|
reject(e);
|
|
316
191
|
},
|
|
317
|
-
complete:
|
|
192
|
+
complete: () => {
|
|
318
193
|
if (listenTimeoutId)
|
|
319
194
|
clearTimeout(listenTimeoutId);
|
|
320
195
|
if (!found) {
|
|
321
|
-
reject(new TransportError(
|
|
196
|
+
reject(new TransportError(this.ErrorMessage_NoDeviceFound, "NoDeviceFound"));
|
|
322
197
|
}
|
|
323
|
-
}
|
|
198
|
+
},
|
|
324
199
|
});
|
|
325
|
-
|
|
326
|
-
? setTimeout(
|
|
200
|
+
const listenTimeoutId = listenTimeout
|
|
201
|
+
? setTimeout(() => {
|
|
327
202
|
sub.unsubscribe();
|
|
328
|
-
reject(new TransportError(
|
|
203
|
+
reject(new TransportError(this.ErrorMessage_ListenTimeout, "ListenTimeout"));
|
|
329
204
|
}, listenTimeout)
|
|
330
205
|
: null;
|
|
331
206
|
});
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
for (var methods_1 = __values(methods), methods_1_1 = methods_1.next(); !methods_1_1.done; methods_1_1 = methods_1.next()) {
|
|
337
|
-
var methodName = methods_1_1.value;
|
|
338
|
-
self[methodName] = this.decorateAppAPIMethod(methodName, self[methodName], self, scrambleKey);
|
|
339
|
-
}
|
|
207
|
+
}
|
|
208
|
+
decorateAppAPIMethods(self, methods, scrambleKey) {
|
|
209
|
+
for (const methodName of methods) {
|
|
210
|
+
self[methodName] = this.decorateAppAPIMethod(methodName, self[methodName], self, scrambleKey);
|
|
340
211
|
}
|
|
341
|
-
|
|
342
|
-
|
|
212
|
+
}
|
|
213
|
+
decorateAppAPIMethod(methodName, f, ctx, scrambleKey) {
|
|
214
|
+
return (...args) => __awaiter(this, void 0, void 0, function* () {
|
|
215
|
+
const { _appAPIlock } = this;
|
|
216
|
+
if (_appAPIlock) {
|
|
217
|
+
return Promise.reject(new TransportError("Ledger Device is busy (lock " + _appAPIlock + ")", "TransportLocked"));
|
|
218
|
+
}
|
|
343
219
|
try {
|
|
344
|
-
|
|
220
|
+
this._appAPIlock = methodName;
|
|
221
|
+
this.setScrambleKey(scrambleKey);
|
|
222
|
+
return yield f.apply(ctx, args);
|
|
345
223
|
}
|
|
346
|
-
finally {
|
|
347
|
-
|
|
348
|
-
};
|
|
349
|
-
Transport.prototype.decorateAppAPIMethod = function (methodName, f, ctx, scrambleKey) {
|
|
350
|
-
var _this = this;
|
|
351
|
-
return function () {
|
|
352
|
-
var args = [];
|
|
353
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
354
|
-
args[_i] = arguments[_i];
|
|
224
|
+
finally {
|
|
225
|
+
this._appAPIlock = null;
|
|
355
226
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
_appAPIlock = this._appAPIlock;
|
|
362
|
-
if (_appAPIlock) {
|
|
363
|
-
return [2 /*return*/, Promise.reject(new TransportError("Ledger Device is busy (lock " + _appAPIlock + ")", "TransportLocked"))];
|
|
364
|
-
}
|
|
365
|
-
_a.label = 1;
|
|
366
|
-
case 1:
|
|
367
|
-
_a.trys.push([1, , 3, 4]);
|
|
368
|
-
this._appAPIlock = methodName;
|
|
369
|
-
this.setScrambleKey(scrambleKey);
|
|
370
|
-
return [4 /*yield*/, f.apply(ctx, args)];
|
|
371
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
372
|
-
case 3:
|
|
373
|
-
this._appAPIlock = null;
|
|
374
|
-
return [7 /*endfinally*/];
|
|
375
|
-
case 4: return [2 /*return*/];
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
});
|
|
379
|
-
};
|
|
380
|
-
};
|
|
381
|
-
Transport.ErrorMessage_ListenTimeout = "No Ledger device found (timeout)";
|
|
382
|
-
Transport.ErrorMessage_NoDeviceFound = "No Ledger device found";
|
|
383
|
-
return Transport;
|
|
384
|
-
}());
|
|
385
|
-
export default Transport;
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
Transport.ErrorMessage_ListenTimeout = "No Ledger device found (timeout)";
|
|
231
|
+
Transport.ErrorMessage_NoDeviceFound = "No Ledger device found";
|
|
386
232
|
//# sourceMappingURL=Transport.js.map
|
package/lib-es/Transport.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transport.js","sourceRoot":"","sources":["../src/Transport.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Transport.js","sourceRoot":"","sources":["../src/Transport.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAElC,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,mBAAmB,GACpB,CAAC;AAoCF;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO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B,IAAI,CAAC,0BAA0B,EAC/B,eAAe,CAChB,CACF,CAAC;gBACJ,CAAC,EAAE,aAAa,CAAC;gBACnB,CAAC,CAAC,IAAI,CAAC;QACX,CAAC,CAAC,CAAC;IACL,CAAC;IAsCD,qBAAqB,CACnB,IAAyB,EACzB,OAAsB,EACtB,WAAmB;QAEnB,KAAK,MAAM,UAAU,IAAI,OAAO,EAAE;YAChC,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,oBAAoB,CAC1C,UAAU,EACV,IAAI,CAAC,UAAU,CAAC,EAChB,IAAI,EACJ,WAAW,CACZ,CAAC;SACH;IACH,CAAC;IAID,oBAAoB,CAClB,UAAkB,EAClB,CAA6B,EAC7B,GAAQ,EACR,WAAmB;QAEnB,OAAO,CAAO,GAAG,IAAI,EAAE,EAAE;YACvB,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;YAE7B,IAAI,WAAW,EAAE;gBACf,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,cAAc,CAChB,8BAA8B,GAAG,WAAW,GAAG,GAAG,EAClD,iBAAiB,CAClB,CACF,CAAC;aACH;YAED,IAAI;gBACF,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;gBAC9B,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;gBACjC,OAAO,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;aACjC;oBAAS;gBACR,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;aACzB;QACH,CAAC,CAAA,CAAC;IACJ,CAAC;;AAEM,oCAA0B,GAAG,kCAAkC,CAAC;AAChE,oCAA0B,GAAG,wBAAwB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/hw-transport",
|
|
3
|
-
"version": "6.28.
|
|
3
|
+
"version": "6.28.3-next.0",
|
|
4
4
|
"description": "Ledger Hardware Wallet common interface of the communication layer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"license": "Apache-2.0",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"events": "^3.3.0",
|
|
29
|
-
"@ledgerhq/devices": "^8.0.
|
|
30
|
-
"@ledgerhq/errors": "^6.12.
|
|
29
|
+
"@ledgerhq/devices": "^8.0.2-next.0",
|
|
30
|
+
"@ledgerhq/errors": "^6.12.5-next.0"
|
|
31
31
|
},
|
|
32
32
|
"gitHead": "dd0dea64b58e5a9125c8a422dcffd29e5ef6abec",
|
|
33
33
|
"devDependencies": {
|
|
@@ -35,11 +35,10 @@
|
|
|
35
35
|
"@types/node": "^18.15.3",
|
|
36
36
|
"documentation": "13.2.4",
|
|
37
37
|
"jest": "^28.1.1",
|
|
38
|
-
"rimraf": "^4.1
|
|
38
|
+
"rimraf": "^4.4.1",
|
|
39
39
|
"source-map-support": "^0.5.21",
|
|
40
40
|
"ts-jest": "^28.0.5",
|
|
41
|
-
"ts-node": "^10.4.0"
|
|
42
|
-
"typescript": "^4"
|
|
41
|
+
"ts-node": "^10.4.0"
|
|
43
42
|
},
|
|
44
43
|
"scripts": {
|
|
45
44
|
"clean": "rimraf lib lib-es",
|