@ledgerhq/react-native-hid 6.29.1-recover-beta.0 → 6.29.2-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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +22 -4
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +84 -171
- package/lib/index.js.map +1 -1
- package/lib-es/index.d.ts +1 -1
- package/lib-es/index.d.ts.map +1 -1
- package/lib-es/index.js +75 -163
- package/lib-es/index.js.map +1 -1
- package/package.json +5 -6
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @ledgerhq/react-native-hid@6.29.
|
|
2
|
+
> @ledgerhq/react-native-hid@6.29.2-nightly.0 build /home/runner/work/ledger-live/ledger-live/libs/ledgerjs/packages/react-native-hid
|
|
3
3
|
> tsc && tsc -m ES6 --outDir lib-es
|
|
4
4
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
# @ledgerhq/react-native-hid
|
|
2
2
|
|
|
3
|
-
## 6.29.
|
|
3
|
+
## 6.29.2-nightly.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`87d2349fd8`](https://github.com/LedgerHQ/ledger-live/commit/87d2349fd835e5deb39d1ee8dfcf3539f4195472)]:
|
|
8
|
+
- @ledgerhq/errors@6.12.5-nightly.0
|
|
9
|
+
- @ledgerhq/devices@8.0.2-nightly.0
|
|
10
|
+
- @ledgerhq/hw-transport@6.28.3-nightly.0
|
|
11
|
+
|
|
12
|
+
## 6.29.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [[`1d0b2d19eb`](https://github.com/LedgerHQ/ledger-live/commit/1d0b2d19ebc5acd058930b842c6d37f8daf2a5a3), [`ef945b05c0`](https://github.com/LedgerHQ/ledger-live/commit/ef945b05c01a791281687abb28e639e1bcc4e472), [`5fa68510b4`](https://github.com/LedgerHQ/ledger-live/commit/5fa68510b49334cfd80c30793dfe68900f1b9b3b)]:
|
|
17
|
+
- @ledgerhq/errors@6.12.4
|
|
18
|
+
- @ledgerhq/devices@8.0.1
|
|
19
|
+
- @ledgerhq/hw-transport@6.28.2
|
|
20
|
+
|
|
21
|
+
## 6.29.1-next.0
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
6
24
|
|
|
7
25
|
- Updated dependencies [[`1d0b2d19eb`](https://github.com/LedgerHQ/ledger-live/commit/1d0b2d19ebc5acd058930b842c6d37f8daf2a5a3), [`ef945b05c0`](https://github.com/LedgerHQ/ledger-live/commit/ef945b05c01a791281687abb28e639e1bcc4e472), [`5fa68510b4`](https://github.com/LedgerHQ/ledger-live/commit/5fa68510b49334cfd80c30793dfe68900f1b9b3b)]:
|
|
8
|
-
- @ledgerhq/errors@6.12.4-
|
|
9
|
-
- @ledgerhq/devices@8.0.1-
|
|
10
|
-
- @ledgerhq/hw-transport@6.28.2-
|
|
26
|
+
- @ledgerhq/errors@6.12.4-next.0
|
|
27
|
+
- @ledgerhq/devices@8.0.1-next.0
|
|
28
|
+
- @ledgerhq/hw-transport@6.28.2-next.0
|
|
11
29
|
|
|
12
30
|
## 6.29.0
|
|
13
31
|
|
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMrD,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAI/C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMrD,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAI/C,KAAK,SAAS,GAAG;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAiCF;;;;;;GAMG;AAEH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,SAAS;IACjD,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;gBAEhC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAM/C;;OAEG;IACH,MAAM,CAAC,WAAW,QAAO,QAAQ,OAAO,CAAC,CACF;IAEvC;;;OAGG;WACU,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAKnC;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG;IAqBjC;;OAEG;WACU,IAAI,CAAC,SAAS,EAAE,SAAS;IAatC;;;OAGG;IACG,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAoB1C;;;OAGG;IACG,KAAK;IAKX,cAAc;CACf"}
|
package/lib/index.js
CHANGED
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -23,83 +8,49 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
23
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
9
|
});
|
|
25
10
|
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
33
|
-
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;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
13
|
};
|
|
56
|
-
exports
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const react_native_1 = require("react-native");
|
|
16
|
+
const devices_1 = require("@ledgerhq/devices");
|
|
17
|
+
const errors_1 = require("@ledgerhq/errors");
|
|
18
|
+
const logs_1 = require("@ledgerhq/logs");
|
|
19
|
+
const hw_transport_1 = __importDefault(require("@ledgerhq/hw-transport"));
|
|
20
|
+
const rxjs_1 = require("rxjs");
|
|
21
|
+
const operators_1 = require("rxjs/operators");
|
|
22
|
+
const disconnectedErrors = [
|
|
65
23
|
"I/O error",
|
|
66
24
|
"Attempt to invoke virtual method 'int android.hardware.usb.UsbDevice.getDeviceClass()' on a null object reference",
|
|
67
25
|
"Invalid channel",
|
|
68
26
|
"Permission denied by user for device",
|
|
69
27
|
];
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
devices = _a.sent();
|
|
77
|
-
return [2 /*return*/, devices.filter(function (d) { return d.vendorId === devices_1.ledgerUSBVendorId; })];
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}); };
|
|
81
|
-
var liveDeviceEventsSubject = new rxjs_1.Subject();
|
|
82
|
-
react_native_1.DeviceEventEmitter.addListener("onDeviceConnect", function (device) {
|
|
28
|
+
const listLedgerDevices = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
+
const devices = yield react_native_1.NativeModules.HID.getDeviceList();
|
|
30
|
+
return devices.filter((d) => d.vendorId === devices_1.ledgerUSBVendorId);
|
|
31
|
+
});
|
|
32
|
+
const liveDeviceEventsSubject = new rxjs_1.Subject();
|
|
33
|
+
react_native_1.DeviceEventEmitter.addListener("onDeviceConnect", (device) => {
|
|
83
34
|
if (device.vendorId !== devices_1.ledgerUSBVendorId)
|
|
84
35
|
return;
|
|
85
|
-
|
|
36
|
+
const deviceModel = (0, devices_1.identifyUSBProductId)(device.productId);
|
|
86
37
|
liveDeviceEventsSubject.next({
|
|
87
38
|
type: "add",
|
|
88
39
|
descriptor: device,
|
|
89
|
-
deviceModel
|
|
40
|
+
deviceModel,
|
|
90
41
|
});
|
|
91
42
|
});
|
|
92
|
-
react_native_1.DeviceEventEmitter.addListener("onDeviceDisconnect",
|
|
43
|
+
react_native_1.DeviceEventEmitter.addListener("onDeviceDisconnect", (device) => {
|
|
93
44
|
if (device.vendorId !== devices_1.ledgerUSBVendorId)
|
|
94
45
|
return;
|
|
95
|
-
|
|
46
|
+
const deviceModel = (0, devices_1.identifyUSBProductId)(device.productId);
|
|
96
47
|
liveDeviceEventsSubject.next({
|
|
97
48
|
type: "remove",
|
|
98
49
|
descriptor: device,
|
|
99
|
-
deviceModel
|
|
50
|
+
deviceModel,
|
|
100
51
|
});
|
|
101
52
|
});
|
|
102
|
-
|
|
53
|
+
const liveDeviceEvents = liveDeviceEventsSubject;
|
|
103
54
|
/**
|
|
104
55
|
* Ledger's React Native HID Transport implementation
|
|
105
56
|
* @example
|
|
@@ -107,132 +58,94 @@ var liveDeviceEvents = liveDeviceEventsSubject;
|
|
|
107
58
|
* ...
|
|
108
59
|
* TransportHID.create().then(transport => ...)
|
|
109
60
|
*/
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
_this.deviceModel = (0, devices_1.identifyUSBProductId)(productId);
|
|
116
|
-
return _this;
|
|
61
|
+
class HIDTransport extends hw_transport_1.default {
|
|
62
|
+
constructor(nativeId, productId) {
|
|
63
|
+
super();
|
|
64
|
+
this.id = nativeId;
|
|
65
|
+
this.deviceModel = (0, devices_1.identifyUSBProductId)(productId);
|
|
117
66
|
}
|
|
118
67
|
/**
|
|
119
68
|
* List currently connected devices.
|
|
120
69
|
* @returns Promise of devices
|
|
121
70
|
*/
|
|
122
|
-
|
|
123
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (!react_native_1.NativeModules.HID)
|
|
128
|
-
return [2 /*return*/, Promise.resolve([])];
|
|
129
|
-
return [4 /*yield*/, listLedgerDevices()];
|
|
130
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
131
|
-
}
|
|
132
|
-
});
|
|
71
|
+
static list() {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
if (!react_native_1.NativeModules.HID)
|
|
74
|
+
return Promise.resolve([]);
|
|
75
|
+
return yield listLedgerDevices();
|
|
133
76
|
});
|
|
134
|
-
}
|
|
77
|
+
}
|
|
135
78
|
/**
|
|
136
79
|
* Listen to ledger devices events
|
|
137
80
|
*/
|
|
138
|
-
|
|
81
|
+
static listen(observer) {
|
|
139
82
|
if (!react_native_1.NativeModules.HID)
|
|
140
83
|
return {
|
|
141
|
-
unsubscribe:
|
|
84
|
+
unsubscribe: () => { },
|
|
142
85
|
};
|
|
143
|
-
return (0, rxjs_1.concat)((0, rxjs_1.from)(listLedgerDevices()).pipe((0, operators_1.mergeMap)(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
})), liveDeviceEvents).subscribe(observer);
|
|
150
|
-
};
|
|
86
|
+
return (0, rxjs_1.concat)((0, rxjs_1.from)(listLedgerDevices()).pipe((0, operators_1.mergeMap)((devices) => (0, rxjs_1.from)(devices.map((device) => ({
|
|
87
|
+
type: "add",
|
|
88
|
+
descriptor: device,
|
|
89
|
+
deviceModel: (0, devices_1.identifyUSBProductId)(device.productId),
|
|
90
|
+
}))))), liveDeviceEvents).subscribe(observer);
|
|
91
|
+
}
|
|
151
92
|
/**
|
|
152
93
|
* Open a the transport with a Ledger device
|
|
153
94
|
*/
|
|
154
|
-
|
|
155
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
nativeObj = _a.sent();
|
|
164
|
-
return [2 /*return*/, new HIDTransport(nativeObj.id, deviceObj.productId)];
|
|
165
|
-
case 2:
|
|
166
|
-
error_1 = _a.sent();
|
|
167
|
-
if (disconnectedErrors.includes(error_1.message)) {
|
|
168
|
-
throw new errors_1.DisconnectedDevice(error_1.message);
|
|
169
|
-
}
|
|
170
|
-
throw error_1;
|
|
171
|
-
case 3: return [2 /*return*/];
|
|
95
|
+
static open(deviceObj) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
try {
|
|
98
|
+
const nativeObj = yield react_native_1.NativeModules.HID.openDevice(deviceObj);
|
|
99
|
+
return new HIDTransport(nativeObj.id, deviceObj.productId);
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
if (disconnectedErrors.includes(error.message)) {
|
|
103
|
+
throw new errors_1.DisconnectedDevice(error.message);
|
|
172
104
|
}
|
|
173
|
-
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
174
107
|
});
|
|
175
|
-
}
|
|
108
|
+
}
|
|
176
109
|
/**
|
|
177
110
|
* @param {*} apdu input value
|
|
178
111
|
* @returns Promise of apdu response
|
|
179
112
|
*/
|
|
180
|
-
|
|
181
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
error_2 = _a.sent();
|
|
200
|
-
if (disconnectedErrors.includes(error_2.message)) {
|
|
201
|
-
this.emit("disconnect", error_2);
|
|
202
|
-
throw new errors_1.DisconnectedDeviceDuringOperation(error_2.message);
|
|
203
|
-
}
|
|
204
|
-
throw error_2;
|
|
205
|
-
case 3: return [2 /*return*/];
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
}); })];
|
|
209
|
-
});
|
|
113
|
+
exchange(apdu) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
return this.exchangeAtomicImpl(() => __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
try {
|
|
117
|
+
const apduHex = apdu.toString("hex");
|
|
118
|
+
(0, logs_1.log)("apdu", "=> " + apduHex);
|
|
119
|
+
const resultHex = yield react_native_1.NativeModules.HID.exchange(this.id, apduHex);
|
|
120
|
+
const res = Buffer.from(resultHex, "hex");
|
|
121
|
+
(0, logs_1.log)("apdu", "<= " + resultHex);
|
|
122
|
+
return res;
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
if (disconnectedErrors.includes(error.message)) {
|
|
126
|
+
this.emit("disconnect", error);
|
|
127
|
+
throw new errors_1.DisconnectedDeviceDuringOperation(error.message);
|
|
128
|
+
}
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
}));
|
|
210
132
|
});
|
|
211
|
-
}
|
|
133
|
+
}
|
|
212
134
|
/**
|
|
213
135
|
* Close the transport
|
|
214
136
|
* @returns Promise
|
|
215
137
|
*/
|
|
216
|
-
|
|
217
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
case 0: return [4 /*yield*/, this.exchangeBusyPromise];
|
|
221
|
-
case 1:
|
|
222
|
-
_a.sent();
|
|
223
|
-
return [2 /*return*/, react_native_1.NativeModules.HID.closeDevice(this.id)];
|
|
224
|
-
}
|
|
225
|
-
});
|
|
138
|
+
close() {
|
|
139
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
yield this.exchangeBusyPromise;
|
|
141
|
+
return react_native_1.NativeModules.HID.closeDevice(this.id);
|
|
226
142
|
});
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
return HIDTransport;
|
|
236
|
-
}(hw_transport_1["default"]));
|
|
237
|
-
exports["default"] = HIDTransport;
|
|
143
|
+
}
|
|
144
|
+
setScrambleKey() { }
|
|
145
|
+
}
|
|
146
|
+
exports.default = HIDTransport;
|
|
147
|
+
/**
|
|
148
|
+
* Check if the transport is supported (basically true on Android)
|
|
149
|
+
*/
|
|
150
|
+
HIDTransport.isSupported = () => Promise.resolve(!!react_native_1.NativeModules.HID);
|
|
238
151
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+CAAiE;AACjE,+CAA4E;AAE5E,6CAG0B;AAC1B,yCAAqC;AACrC,0EAA+C;AAE/C,+BAA6C;AAC7C,8CAA0C;AAK1C,MAAM,kBAAkB,GAAG;IACzB,WAAW;IACX,mHAAmH;IACnH,iBAAiB;IACjB,sCAAsC;CACvC,CAAC;AAEF,MAAM,iBA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
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMrD,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAI/C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMrD,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAI/C,KAAK,SAAS,GAAG;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAiCF;;;;;;GAMG;AAEH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,SAAS;IACjD,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;gBAEhC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAM/C;;OAEG;IACH,MAAM,CAAC,WAAW,QAAO,QAAQ,OAAO,CAAC,CACF;IAEvC;;;OAGG;WACU,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAKnC;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG;IAqBjC;;OAEG;WACU,IAAI,CAAC,SAAS,EAAE,SAAS;IAatC;;;OAGG;IACG,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAoB1C;;;OAGG;IACG,KAAK;IAKX,cAAc;CACf"}
|
package/lib-es/index.js
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2
|
-
var extendStatics = function (d, b) {
|
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
-
return extendStatics(d, b);
|
|
7
|
-
};
|
|
8
|
-
return function (d, b) {
|
|
9
|
-
if (typeof b !== "function" && b !== null)
|
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
-
extendStatics(d, b);
|
|
12
|
-
function __() { this.constructor = d; }
|
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -22,33 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
22
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
8
|
});
|
|
24
9
|
};
|
|
25
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
27
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
-
function step(op) {
|
|
30
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
-
while (_) try {
|
|
32
|
-
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;
|
|
33
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
-
switch (op[0]) {
|
|
35
|
-
case 0: case 1: t = op; break;
|
|
36
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
-
default:
|
|
40
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
-
if (t[2]) _.ops.pop();
|
|
45
|
-
_.trys.pop(); continue;
|
|
46
|
-
}
|
|
47
|
-
op = body.call(thisArg, _);
|
|
48
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
10
|
import { NativeModules, DeviceEventEmitter } from "react-native";
|
|
53
11
|
import { ledgerUSBVendorId, identifyUSBProductId } from "@ledgerhq/devices";
|
|
54
12
|
import { DisconnectedDeviceDuringOperation, DisconnectedDevice, } from "@ledgerhq/errors";
|
|
@@ -56,45 +14,38 @@ import { log } from "@ledgerhq/logs";
|
|
|
56
14
|
import Transport from "@ledgerhq/hw-transport";
|
|
57
15
|
import { Subject, from, concat } from "rxjs";
|
|
58
16
|
import { mergeMap } from "rxjs/operators";
|
|
59
|
-
|
|
17
|
+
const disconnectedErrors = [
|
|
60
18
|
"I/O error",
|
|
61
19
|
"Attempt to invoke virtual method 'int android.hardware.usb.UsbDevice.getDeviceClass()' on a null object reference",
|
|
62
20
|
"Invalid channel",
|
|
63
21
|
"Permission denied by user for device",
|
|
64
22
|
];
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
devices = _a.sent();
|
|
72
|
-
return [2 /*return*/, devices.filter(function (d) { return d.vendorId === ledgerUSBVendorId; })];
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}); };
|
|
76
|
-
var liveDeviceEventsSubject = new Subject();
|
|
77
|
-
DeviceEventEmitter.addListener("onDeviceConnect", function (device) {
|
|
23
|
+
const listLedgerDevices = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
const devices = yield NativeModules.HID.getDeviceList();
|
|
25
|
+
return devices.filter((d) => d.vendorId === ledgerUSBVendorId);
|
|
26
|
+
});
|
|
27
|
+
const liveDeviceEventsSubject = new Subject();
|
|
28
|
+
DeviceEventEmitter.addListener("onDeviceConnect", (device) => {
|
|
78
29
|
if (device.vendorId !== ledgerUSBVendorId)
|
|
79
30
|
return;
|
|
80
|
-
|
|
31
|
+
const deviceModel = identifyUSBProductId(device.productId);
|
|
81
32
|
liveDeviceEventsSubject.next({
|
|
82
33
|
type: "add",
|
|
83
34
|
descriptor: device,
|
|
84
|
-
deviceModel
|
|
35
|
+
deviceModel,
|
|
85
36
|
});
|
|
86
37
|
});
|
|
87
|
-
DeviceEventEmitter.addListener("onDeviceDisconnect",
|
|
38
|
+
DeviceEventEmitter.addListener("onDeviceDisconnect", (device) => {
|
|
88
39
|
if (device.vendorId !== ledgerUSBVendorId)
|
|
89
40
|
return;
|
|
90
|
-
|
|
41
|
+
const deviceModel = identifyUSBProductId(device.productId);
|
|
91
42
|
liveDeviceEventsSubject.next({
|
|
92
43
|
type: "remove",
|
|
93
44
|
descriptor: device,
|
|
94
|
-
deviceModel
|
|
45
|
+
deviceModel,
|
|
95
46
|
});
|
|
96
47
|
});
|
|
97
|
-
|
|
48
|
+
const liveDeviceEvents = liveDeviceEventsSubject;
|
|
98
49
|
/**
|
|
99
50
|
* Ledger's React Native HID Transport implementation
|
|
100
51
|
* @example
|
|
@@ -102,132 +53,93 @@ var liveDeviceEvents = liveDeviceEventsSubject;
|
|
|
102
53
|
* ...
|
|
103
54
|
* TransportHID.create().then(transport => ...)
|
|
104
55
|
*/
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
_this.deviceModel = identifyUSBProductId(productId);
|
|
111
|
-
return _this;
|
|
56
|
+
export default class HIDTransport extends Transport {
|
|
57
|
+
constructor(nativeId, productId) {
|
|
58
|
+
super();
|
|
59
|
+
this.id = nativeId;
|
|
60
|
+
this.deviceModel = identifyUSBProductId(productId);
|
|
112
61
|
}
|
|
113
62
|
/**
|
|
114
63
|
* List currently connected devices.
|
|
115
64
|
* @returns Promise of devices
|
|
116
65
|
*/
|
|
117
|
-
|
|
118
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (!NativeModules.HID)
|
|
123
|
-
return [2 /*return*/, Promise.resolve([])];
|
|
124
|
-
return [4 /*yield*/, listLedgerDevices()];
|
|
125
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
126
|
-
}
|
|
127
|
-
});
|
|
66
|
+
static list() {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
if (!NativeModules.HID)
|
|
69
|
+
return Promise.resolve([]);
|
|
70
|
+
return yield listLedgerDevices();
|
|
128
71
|
});
|
|
129
|
-
}
|
|
72
|
+
}
|
|
130
73
|
/**
|
|
131
74
|
* Listen to ledger devices events
|
|
132
75
|
*/
|
|
133
|
-
|
|
76
|
+
static listen(observer) {
|
|
134
77
|
if (!NativeModules.HID)
|
|
135
78
|
return {
|
|
136
|
-
unsubscribe:
|
|
79
|
+
unsubscribe: () => { },
|
|
137
80
|
};
|
|
138
|
-
return concat(from(listLedgerDevices()).pipe(mergeMap(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
})), liveDeviceEvents).subscribe(observer);
|
|
145
|
-
};
|
|
81
|
+
return concat(from(listLedgerDevices()).pipe(mergeMap((devices) => from(devices.map((device) => ({
|
|
82
|
+
type: "add",
|
|
83
|
+
descriptor: device,
|
|
84
|
+
deviceModel: identifyUSBProductId(device.productId),
|
|
85
|
+
}))))), liveDeviceEvents).subscribe(observer);
|
|
86
|
+
}
|
|
146
87
|
/**
|
|
147
88
|
* Open a the transport with a Ledger device
|
|
148
89
|
*/
|
|
149
|
-
|
|
150
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
nativeObj = _a.sent();
|
|
159
|
-
return [2 /*return*/, new HIDTransport(nativeObj.id, deviceObj.productId)];
|
|
160
|
-
case 2:
|
|
161
|
-
error_1 = _a.sent();
|
|
162
|
-
if (disconnectedErrors.includes(error_1.message)) {
|
|
163
|
-
throw new DisconnectedDevice(error_1.message);
|
|
164
|
-
}
|
|
165
|
-
throw error_1;
|
|
166
|
-
case 3: return [2 /*return*/];
|
|
90
|
+
static open(deviceObj) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
try {
|
|
93
|
+
const nativeObj = yield NativeModules.HID.openDevice(deviceObj);
|
|
94
|
+
return new HIDTransport(nativeObj.id, deviceObj.productId);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
if (disconnectedErrors.includes(error.message)) {
|
|
98
|
+
throw new DisconnectedDevice(error.message);
|
|
167
99
|
}
|
|
168
|
-
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
169
102
|
});
|
|
170
|
-
}
|
|
103
|
+
}
|
|
171
104
|
/**
|
|
172
105
|
* @param {*} apdu input value
|
|
173
106
|
* @returns Promise of apdu response
|
|
174
107
|
*/
|
|
175
|
-
|
|
176
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
error_2 = _a.sent();
|
|
195
|
-
if (disconnectedErrors.includes(error_2.message)) {
|
|
196
|
-
this.emit("disconnect", error_2);
|
|
197
|
-
throw new DisconnectedDeviceDuringOperation(error_2.message);
|
|
198
|
-
}
|
|
199
|
-
throw error_2;
|
|
200
|
-
case 3: return [2 /*return*/];
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
}); })];
|
|
204
|
-
});
|
|
108
|
+
exchange(apdu) {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
return this.exchangeAtomicImpl(() => __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
try {
|
|
112
|
+
const apduHex = apdu.toString("hex");
|
|
113
|
+
log("apdu", "=> " + apduHex);
|
|
114
|
+
const resultHex = yield NativeModules.HID.exchange(this.id, apduHex);
|
|
115
|
+
const res = Buffer.from(resultHex, "hex");
|
|
116
|
+
log("apdu", "<= " + resultHex);
|
|
117
|
+
return res;
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
if (disconnectedErrors.includes(error.message)) {
|
|
121
|
+
this.emit("disconnect", error);
|
|
122
|
+
throw new DisconnectedDeviceDuringOperation(error.message);
|
|
123
|
+
}
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
}));
|
|
205
127
|
});
|
|
206
|
-
}
|
|
128
|
+
}
|
|
207
129
|
/**
|
|
208
130
|
* Close the transport
|
|
209
131
|
* @returns Promise
|
|
210
132
|
*/
|
|
211
|
-
|
|
212
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
case 0: return [4 /*yield*/, this.exchangeBusyPromise];
|
|
216
|
-
case 1:
|
|
217
|
-
_a.sent();
|
|
218
|
-
return [2 /*return*/, NativeModules.HID.closeDevice(this.id)];
|
|
219
|
-
}
|
|
220
|
-
});
|
|
133
|
+
close() {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
yield this.exchangeBusyPromise;
|
|
136
|
+
return NativeModules.HID.closeDevice(this.id);
|
|
221
137
|
});
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
};
|
|
230
|
-
return HIDTransport;
|
|
231
|
-
}(Transport));
|
|
232
|
-
export default HIDTransport;
|
|
138
|
+
}
|
|
139
|
+
setScrambleKey() { }
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Check if the transport is supported (basically true on Android)
|
|
143
|
+
*/
|
|
144
|
+
HIDTransport.isSupported = () => Promise.resolve(!!NativeModules.HID);
|
|
233
145
|
//# sourceMappingURL=index.js.map
|
package/lib-es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE5E,OAAO,EACL,iCAAiC,EACjC,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAK1C,MAAM,kBAAkB,GAAG;IACzB,WAAW;IACX,mHAAmH;IACnH,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
-
"version": "6.29.
|
|
3
|
+
"version": "6.29.2-nightly.0",
|
|
4
4
|
"nativePackage": true,
|
|
5
5
|
"description": "Ledger Hardware Wallet Web implementation of the communication layer, using U2F api",
|
|
6
6
|
"keywords": [
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"license": "Apache-2.0",
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"rxjs": "6",
|
|
33
|
-
"@ledgerhq/devices": "^8.0.
|
|
34
|
-
"@ledgerhq/errors": "^6.12.
|
|
35
|
-
"@ledgerhq/hw-transport": "^6.28.
|
|
33
|
+
"@ledgerhq/devices": "^8.0.2-nightly.0",
|
|
34
|
+
"@ledgerhq/errors": "^6.12.5-nightly.0",
|
|
35
|
+
"@ledgerhq/hw-transport": "^6.28.3-nightly.0",
|
|
36
36
|
"@ledgerhq/logs": "^6.10.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
@@ -41,11 +41,10 @@
|
|
|
41
41
|
"@types/react-native": "^0.66.24",
|
|
42
42
|
"documentation": "13.2.4",
|
|
43
43
|
"jest": "^28.1.1",
|
|
44
|
-
"rimraf": "^4.1
|
|
44
|
+
"rimraf": "^4.4.1",
|
|
45
45
|
"source-map-support": "^0.5.21",
|
|
46
46
|
"ts-jest": "^28.0.5",
|
|
47
47
|
"ts-node": "^10.4.0",
|
|
48
|
-
"typescript": "^4",
|
|
49
48
|
"yarn-add-no-save": "^1.0.3"
|
|
50
49
|
},
|
|
51
50
|
"peerDependencies": {
|