@pioneer-platform/pioneer-react 0.2.47 → 0.2.49
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/dist/index.js +198340 -146844
- package/dist/{index_0e37f5ff.js → index_0652205a.js} +6 -6
- package/dist/{index_f9d1a3bf.js → index_096371b1.js} +3 -1
- package/dist/{index_ae6c3b10.js → index_0a5ed442.js} +3 -3
- package/dist/{index_e233a036.js → index_0a6e5811.js} +1 -1
- package/dist/{index_547d2868.js → index_0b5f5f6a.js} +4 -4
- package/dist/index_10812439.js +25 -0
- package/dist/{index_4a548214.js → index_1093b1b4.js} +8 -8
- package/dist/{index_3a6b0cd3.js → index_169417bf.js} +3 -3
- package/dist/{index_e168f4c0.js → index_1d5f0f00.js} +7 -7
- package/dist/{index_e57ba5a5.js → index_278505c5.js} +3 -3
- package/dist/{index_a4f5a15a.js → index_2845411a.js} +19 -19
- package/dist/{index_003befba.js → index_29be6ff5.js} +1122 -1312
- package/dist/{index_a6b45215.js → index_2dc95f2a.js} +7 -3
- package/dist/{index_6d2a3e5c.js → index_3402bab8.js} +6 -2
- package/dist/{index_310b7772.js → index_3c54e5ec.js} +9 -9
- package/dist/{index_f9d461d1.js → index_423ea09e.js} +3 -3
- package/dist/{index_37894947.js → index_4425b278.js} +3 -3
- package/dist/{index_61a33920.js → index_514c608b.js} +6 -6
- package/dist/index_51b338c1.js +121 -0
- package/dist/{index_0364269a.js → index_5d8426fb.js} +3 -3
- package/dist/index_628b22bc.js +11003 -0
- package/dist/index_63a883f7.js +446 -0
- package/dist/{index_d8e757ba.js → index_654fef3a.js} +3 -3
- package/dist/index_691fd636.js +12913 -0
- package/dist/{index_674ffbfa.js → index_69b0f47b.js} +9 -9
- package/dist/{index_a682c1a8.js → index_6cd7bc1a.js} +3 -1
- package/dist/{index_c8ebd6e3.js → index_6ebe4744.js} +900 -900
- package/dist/{index_7382dec1.js → index_7f735685.js} +5 -5
- package/dist/{index_b3022c1a.js → index_82348f63.js} +5 -5
- package/dist/index_849386d3.js +1115 -0
- package/dist/{index_85b01410.js → index_8610c3c4.js} +6 -6
- package/dist/index_8d6422b9.js +112 -0
- package/dist/{index_167c5f7a.js → index_8fd2c24a.js} +3 -3
- package/dist/{index_1990afbf.js → index_942c3b80.js} +4 -4
- package/dist/index_94b7968d.js +22872 -0
- package/dist/index_94d38802.js +2856 -0
- package/dist/{index_bd7e0d56.js → index_a5ca5cc4.js} +2 -2
- package/dist/{index_f80541a0.js → index_aa71379e.js} +307 -267
- package/dist/{index_354cce52.js → index_aa773d39.js} +3 -3
- package/dist/{index_29e62962.js → index_b022faaa.js} +4 -4
- package/dist/index_b1028d5f.js +65 -0
- package/dist/index_c232ca43.js +25 -0
- package/dist/{index_f19b5fe5.js → index_c9105338.js} +3 -3
- package/dist/{index_7c12bb44.js → index_cebbd50e.js} +1 -1
- package/dist/{index_ca633a1c.js → index_d477606a.js} +7 -7
- package/dist/index_d8a5e2ef.js +116 -0
- package/dist/{index_542dbb9a.js → index_de4af619.js} +4 -4
- package/dist/{index_7a1bb0b1.js → index_df47a9c6.js} +8 -8
- package/dist/{index_8b9255eb.js → index_e0b32f2f.js} +10 -10
- package/dist/{index_b21f58b7.js → index_e2794130.js} +4 -4
- package/dist/{index_2cbf1530.js → index_ecce7b22.js} +6 -6
- package/dist/{index_3891b298.js → index_f2d68730.js} +1 -1
- package/dist/index_f66728ba.js +130 -0
- package/dist/{index_f3922fc1.js → index_f8bc80e1.js} +3 -3
- package/package.json +19 -18
- package/src/lib/context/Pioneer/sdk/connect.ts +11 -11
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
import { d as dist, E as EventEmitter$1 } from "./index_94b7968d.js";
|
|
2
|
+
import { TransportInterfaceNotAvailable as A, DisconnectedDeviceDuringOperation as N, TransportWebUSBGestureRequired as u, TransportOpenUserCancelled as C$1, TransportError as U, TransportStatusError as I, StatusCodes as E, TransportRaceCondition as d$1, DisconnectedDevice as x } from "./index_d8a5e2ef.js";
|
|
3
|
+
import { identifyUSBProductId as z$1, ledgerUSBVendorId as k } from "./index_8d6422b9.js";
|
|
4
|
+
import { d } from "./index_10812439.js";
|
|
5
|
+
import "./index_3402bab8.js";
|
|
6
|
+
import "./index_2dc95f2a.js";
|
|
7
|
+
import "./index_a5ca5cc4.js";
|
|
8
|
+
import "./index_f8bc80e1.js";
|
|
9
|
+
import "./index_0652205a.js";
|
|
10
|
+
import "./index_096371b1.js";
|
|
11
|
+
import "./index_29be6ff5.js";
|
|
12
|
+
import "./index_6cd7bc1a.js";
|
|
13
|
+
import "./index_849386d3.js";
|
|
14
|
+
import "./index_aa71379e.js";
|
|
15
|
+
import "react";
|
|
16
|
+
import "@chakra-ui/react";
|
|
17
|
+
import "react-dom";
|
|
18
|
+
import "./index_0a6e5811.js";
|
|
19
|
+
import "./index_aa773d39.js";
|
|
20
|
+
var g = globalThis && globalThis.__awaiter || function(u2, e, n, t) {
|
|
21
|
+
function s(o) {
|
|
22
|
+
return o instanceof n ? o : new n(function(i) {
|
|
23
|
+
i(o);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return new (n || (n = Promise))(function(o, i) {
|
|
27
|
+
function r(c) {
|
|
28
|
+
try {
|
|
29
|
+
d2(t.next(c));
|
|
30
|
+
} catch (f) {
|
|
31
|
+
i(f);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function a(c) {
|
|
35
|
+
try {
|
|
36
|
+
d2(t.throw(c));
|
|
37
|
+
} catch (f) {
|
|
38
|
+
i(f);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function d2(c) {
|
|
42
|
+
c.done ? o(c.value) : s(c.value).then(r, a);
|
|
43
|
+
}
|
|
44
|
+
d2((t = t.apply(u2, e || [])).next());
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
class v {
|
|
48
|
+
constructor() {
|
|
49
|
+
this.exchangeTimeout = 3e4, this.unresponsiveTimeout = 15e3, this.deviceModel = null, this._events = new EventEmitter$1(), this.send = (e, n, t, s, o = dist.Buffer.alloc(0), i = [E.OK]) => g(this, void 0, void 0, function* () {
|
|
50
|
+
if (o.length >= 256)
|
|
51
|
+
throw new U("data.length exceed 256 bytes limit. Got: " + o.length, "DataLengthTooBig");
|
|
52
|
+
const r = yield this.exchange(dist.Buffer.concat([dist.Buffer.from([e, n, t, s]), dist.Buffer.from([o.length]), o])), a = r.readUInt16BE(r.length - 2);
|
|
53
|
+
if (!i.some((d2) => d2 === a))
|
|
54
|
+
throw new I(a);
|
|
55
|
+
return r;
|
|
56
|
+
}), this.exchangeAtomicImpl = (e) => g(this, void 0, void 0, function* () {
|
|
57
|
+
if (this.exchangeBusyPromise)
|
|
58
|
+
throw new d$1("An action was already pending on the Ledger device. Please deny or reconnect.");
|
|
59
|
+
let n;
|
|
60
|
+
const t = new Promise((i) => {
|
|
61
|
+
n = i;
|
|
62
|
+
});
|
|
63
|
+
this.exchangeBusyPromise = t;
|
|
64
|
+
let s = false;
|
|
65
|
+
const o = setTimeout(() => {
|
|
66
|
+
s = true, this.emit("unresponsive");
|
|
67
|
+
}, this.unresponsiveTimeout);
|
|
68
|
+
try {
|
|
69
|
+
const i = yield e();
|
|
70
|
+
return s && this.emit("responsive"), i;
|
|
71
|
+
} finally {
|
|
72
|
+
clearTimeout(o), n && n(), this.exchangeBusyPromise = null;
|
|
73
|
+
}
|
|
74
|
+
}), this._appAPIlock = null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Send data to the device using a low level API.
|
|
78
|
+
* It's recommended to use the "send" method for a higher level API.
|
|
79
|
+
* @param {Buffer} apdu - The data to send.
|
|
80
|
+
* @returns {Promise<Buffer>} A promise that resolves with the response data from the device.
|
|
81
|
+
*/
|
|
82
|
+
exchange(e) {
|
|
83
|
+
throw new Error("exchange not implemented");
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Send apdus in batch to the device using a low level API.
|
|
87
|
+
* The default implementation is to call exchange for each apdu.
|
|
88
|
+
* @param {Array<Buffer>} apdus - array of apdus to send.
|
|
89
|
+
* @param {Observer<Buffer>} observer - an observer that will receive the response of each apdu.
|
|
90
|
+
* @returns {Subscription} A Subscription object on which you can call ".unsubscribe()" to stop sending apdus.
|
|
91
|
+
*/
|
|
92
|
+
exchangeBulk(e, n) {
|
|
93
|
+
let t = false;
|
|
94
|
+
const s = () => {
|
|
95
|
+
t = true;
|
|
96
|
+
};
|
|
97
|
+
return (() => g(this, void 0, void 0, function* () {
|
|
98
|
+
if (!t)
|
|
99
|
+
for (const i of e) {
|
|
100
|
+
const r = yield this.exchange(i);
|
|
101
|
+
if (t)
|
|
102
|
+
return;
|
|
103
|
+
const a = r.readUInt16BE(r.length - 2);
|
|
104
|
+
if (a !== E.OK)
|
|
105
|
+
throw new I(a);
|
|
106
|
+
n.next(r);
|
|
107
|
+
}
|
|
108
|
+
}))().then(() => !t && n.complete(), (i) => !t && n.error(i)), { unsubscribe: s };
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Set the "scramble key" for the next data exchanges with the device.
|
|
112
|
+
* Each app can have a different scramble key and it is set internally during instantiation.
|
|
113
|
+
* @param {string} key - The scramble key to set.
|
|
114
|
+
* @deprecated This method is no longer needed for modern transports and should be migrated away from.
|
|
115
|
+
*/
|
|
116
|
+
setScrambleKey(e) {
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Close the connection with the device.
|
|
120
|
+
* @returns {Promise<void>} A promise that resolves when the transport is closed.
|
|
121
|
+
*/
|
|
122
|
+
close() {
|
|
123
|
+
return Promise.resolve();
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Listen for an event on the transport instance.
|
|
127
|
+
* Transport implementations may have specific events. Common events include:
|
|
128
|
+
* "disconnect" : triggered when the transport is disconnected.
|
|
129
|
+
* @param {string} eventName - The name of the event to listen for.
|
|
130
|
+
* @param {(...args: Array<any>) => any} cb - The callback function to be invoked when the event occurs.
|
|
131
|
+
*/
|
|
132
|
+
on(e, n) {
|
|
133
|
+
this._events.on(e, n);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Stop listening to an event on an instance of transport.
|
|
137
|
+
*/
|
|
138
|
+
off(e, n) {
|
|
139
|
+
this._events.removeListener(e, n);
|
|
140
|
+
}
|
|
141
|
+
emit(e, ...n) {
|
|
142
|
+
this._events.emit(e, ...n);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Enable or not logs of the binary exchange
|
|
146
|
+
*/
|
|
147
|
+
setDebugMode() {
|
|
148
|
+
console.warn("setDebugMode is deprecated. use @ledgerhq/logs instead. No logs are emitted in this anymore.");
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Set a timeout (in milliseconds) for the exchange call. Only some transport might implement it. (e.g. U2F)
|
|
152
|
+
*/
|
|
153
|
+
setExchangeTimeout(e) {
|
|
154
|
+
this.exchangeTimeout = e;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Define the delay before emitting "unresponsive" on an exchange that does not respond
|
|
158
|
+
*/
|
|
159
|
+
setExchangeUnresponsiveTimeout(e) {
|
|
160
|
+
this.unresponsiveTimeout = e;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* create() allows to open the first descriptor available or
|
|
164
|
+
* throw if there is none or if timeout is reached.
|
|
165
|
+
* This is a light helper, alternative to using listen() and open() (that you may need for any more advanced usecase)
|
|
166
|
+
* @example
|
|
167
|
+
TransportFoo.create().then(transport => ...)
|
|
168
|
+
*/
|
|
169
|
+
static create(e = 3e3, n) {
|
|
170
|
+
return new Promise((t, s) => {
|
|
171
|
+
let o = false;
|
|
172
|
+
const i = this.listen({
|
|
173
|
+
next: (a) => {
|
|
174
|
+
o = true, i && i.unsubscribe(), r && clearTimeout(r), this.open(a.descriptor, e).then(t, s);
|
|
175
|
+
},
|
|
176
|
+
error: (a) => {
|
|
177
|
+
r && clearTimeout(r), s(a);
|
|
178
|
+
},
|
|
179
|
+
complete: () => {
|
|
180
|
+
r && clearTimeout(r), o || s(new U(this.ErrorMessage_NoDeviceFound, "NoDeviceFound"));
|
|
181
|
+
}
|
|
182
|
+
}), r = n ? setTimeout(() => {
|
|
183
|
+
i.unsubscribe(), s(new U(this.ErrorMessage_ListenTimeout, "ListenTimeout"));
|
|
184
|
+
}, n) : null;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
decorateAppAPIMethods(e, n, t) {
|
|
188
|
+
for (const s of n)
|
|
189
|
+
e[s] = this.decorateAppAPIMethod(s, e[s], e, t);
|
|
190
|
+
}
|
|
191
|
+
decorateAppAPIMethod(e, n, t, s) {
|
|
192
|
+
return (...o) => g(this, void 0, void 0, function* () {
|
|
193
|
+
const { _appAPIlock: i } = this;
|
|
194
|
+
if (i)
|
|
195
|
+
return Promise.reject(new U("Ledger Device is busy (lock " + i + ")", "TransportLocked"));
|
|
196
|
+
try {
|
|
197
|
+
return this._appAPIlock = e, this.setScrambleKey(s), yield n.apply(t, o);
|
|
198
|
+
} finally {
|
|
199
|
+
this._appAPIlock = null;
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
v.ErrorMessage_ListenTimeout = "No Ledger device found (timeout)";
|
|
205
|
+
v.ErrorMessage_NoDeviceFound = "No Ledger device found";
|
|
206
|
+
const T = 5;
|
|
207
|
+
function R(u2) {
|
|
208
|
+
const e = dist.Buffer.alloc(2);
|
|
209
|
+
return e.writeUInt16BE(u2, 0), e;
|
|
210
|
+
}
|
|
211
|
+
const q = {
|
|
212
|
+
data: dist.Buffer.alloc(0),
|
|
213
|
+
dataLength: 0,
|
|
214
|
+
sequence: 0
|
|
215
|
+
}, C = (u2, e) => ({
|
|
216
|
+
makeBlocks(n) {
|
|
217
|
+
let t = dist.Buffer.concat([R(n.length), n]);
|
|
218
|
+
const s = e - 5, o = Math.ceil(t.length / s);
|
|
219
|
+
t = dist.Buffer.concat([
|
|
220
|
+
t,
|
|
221
|
+
dist.Buffer.alloc(o * s - t.length + 1).fill(0)
|
|
222
|
+
]);
|
|
223
|
+
const i = [];
|
|
224
|
+
for (let r = 0; r < o; r++) {
|
|
225
|
+
const a = dist.Buffer.alloc(5);
|
|
226
|
+
a.writeUInt16BE(u2, 0), a.writeUInt8(T, 2), a.writeUInt16BE(r, 3);
|
|
227
|
+
const d2 = t.slice(r * s, (r + 1) * s);
|
|
228
|
+
i.push(dist.Buffer.concat([a, d2]));
|
|
229
|
+
}
|
|
230
|
+
return i;
|
|
231
|
+
},
|
|
232
|
+
reduceResponse(n, t) {
|
|
233
|
+
let { data: s, dataLength: o, sequence: i } = n || q;
|
|
234
|
+
if (t.readUInt16BE(0) !== u2)
|
|
235
|
+
throw new U("Invalid channel", "InvalidChannel");
|
|
236
|
+
if (t.readUInt8(2) !== T)
|
|
237
|
+
throw new U("Invalid tag", "InvalidTag");
|
|
238
|
+
if (t.readUInt16BE(3) !== i)
|
|
239
|
+
throw new U("Invalid sequence", "InvalidSequence");
|
|
240
|
+
n || (o = t.readUInt16BE(5)), i++;
|
|
241
|
+
const r = t.slice(n ? 5 : 7);
|
|
242
|
+
return s = dist.Buffer.concat([s, r]), s.length > o && (s = s.slice(0, o)), {
|
|
243
|
+
data: s,
|
|
244
|
+
dataLength: o,
|
|
245
|
+
sequence: i
|
|
246
|
+
};
|
|
247
|
+
},
|
|
248
|
+
getReducedResult(n) {
|
|
249
|
+
if (n && n.dataLength === n.data.length)
|
|
250
|
+
return n.data;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
var w = globalThis && globalThis.__awaiter || function(u2, e, n, t) {
|
|
254
|
+
function s(o) {
|
|
255
|
+
return o instanceof n ? o : new n(function(i) {
|
|
256
|
+
i(o);
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
return new (n || (n = Promise))(function(o, i) {
|
|
260
|
+
function r(c) {
|
|
261
|
+
try {
|
|
262
|
+
d2(t.next(c));
|
|
263
|
+
} catch (f) {
|
|
264
|
+
i(f);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function a(c) {
|
|
268
|
+
try {
|
|
269
|
+
d2(t.throw(c));
|
|
270
|
+
} catch (f) {
|
|
271
|
+
i(f);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function d2(c) {
|
|
275
|
+
c.done ? o(c.value) : s(c.value).then(r, a);
|
|
276
|
+
}
|
|
277
|
+
d2((t = t.apply(u2, e || [])).next());
|
|
278
|
+
});
|
|
279
|
+
};
|
|
280
|
+
const O = [
|
|
281
|
+
{
|
|
282
|
+
vendorId: k
|
|
283
|
+
}
|
|
284
|
+
];
|
|
285
|
+
function M() {
|
|
286
|
+
return w(this, void 0, void 0, function* () {
|
|
287
|
+
return yield navigator.usb.requestDevice({
|
|
288
|
+
filters: O
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
function y() {
|
|
293
|
+
return w(this, void 0, void 0, function* () {
|
|
294
|
+
return (yield navigator.usb.getDevices()).filter((e) => e.vendorId === k);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
function K() {
|
|
298
|
+
return w(this, void 0, void 0, function* () {
|
|
299
|
+
const u2 = yield y();
|
|
300
|
+
return u2.length > 0 ? u2[0] : M();
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
const F = () => Promise.resolve(!!navigator && !!navigator.usb && typeof navigator.usb.getDevices == "function");
|
|
304
|
+
var h = globalThis && globalThis.__awaiter || function(u2, e, n, t) {
|
|
305
|
+
function s(o) {
|
|
306
|
+
return o instanceof n ? o : new n(function(i) {
|
|
307
|
+
i(o);
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
return new (n || (n = Promise))(function(o, i) {
|
|
311
|
+
function r(c) {
|
|
312
|
+
try {
|
|
313
|
+
d2(t.next(c));
|
|
314
|
+
} catch (f) {
|
|
315
|
+
i(f);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
function a(c) {
|
|
319
|
+
try {
|
|
320
|
+
d2(t.throw(c));
|
|
321
|
+
} catch (f) {
|
|
322
|
+
i(f);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
function d2(c) {
|
|
326
|
+
c.done ? o(c.value) : s(c.value).then(r, a);
|
|
327
|
+
}
|
|
328
|
+
d2((t = t.apply(u2, e || [])).next());
|
|
329
|
+
});
|
|
330
|
+
};
|
|
331
|
+
const z = 1, D = 3;
|
|
332
|
+
class p extends v {
|
|
333
|
+
constructor(e, n) {
|
|
334
|
+
super(), this.channel = Math.floor(Math.random() * 65535), this.packetSize = 64, this._disconnectEmitted = false, this._emitDisconnect = (t) => {
|
|
335
|
+
this._disconnectEmitted || (this._disconnectEmitted = true, this.emit("disconnect", t));
|
|
336
|
+
}, this.device = e, this.interfaceNumber = n, this.deviceModel = z$1(e.productId);
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Similar to create() except it will always display the device permission (even if some devices are already accepted).
|
|
340
|
+
*/
|
|
341
|
+
static request() {
|
|
342
|
+
return h(this, void 0, void 0, function* () {
|
|
343
|
+
const e = yield M();
|
|
344
|
+
return p.open(e);
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Similar to create() except it will never display the device permission (it returns a Promise<?Transport>, null if it fails to find a device).
|
|
349
|
+
*/
|
|
350
|
+
static openConnected() {
|
|
351
|
+
return h(this, void 0, void 0, function* () {
|
|
352
|
+
const e = yield y();
|
|
353
|
+
return e.length === 0 ? null : p.open(e[0]);
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Create a Ledger transport with a USBDevice
|
|
358
|
+
*/
|
|
359
|
+
static open(e) {
|
|
360
|
+
return h(this, void 0, void 0, function* () {
|
|
361
|
+
yield e.open(), e.configuration === null && (yield e.selectConfiguration(z)), yield _(e);
|
|
362
|
+
const n = e.configurations[0].interfaces.find(({ alternates: i }) => i.some((r) => r.interfaceClass === 255));
|
|
363
|
+
if (!n)
|
|
364
|
+
throw new A("No WebUSB interface found for your Ledger device. Please upgrade firmware or contact techsupport.");
|
|
365
|
+
const t = n.interfaceNumber;
|
|
366
|
+
try {
|
|
367
|
+
yield e.claimInterface(t);
|
|
368
|
+
} catch (i) {
|
|
369
|
+
throw yield e.close(), new A(i.message);
|
|
370
|
+
}
|
|
371
|
+
const s = new p(e, t), o = (i) => {
|
|
372
|
+
e === i.device && (navigator.usb.removeEventListener("disconnect", o), s._emitDisconnect(new x()));
|
|
373
|
+
};
|
|
374
|
+
return navigator.usb.addEventListener("disconnect", o), s;
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Release the transport device
|
|
379
|
+
*/
|
|
380
|
+
close() {
|
|
381
|
+
return h(this, void 0, void 0, function* () {
|
|
382
|
+
yield this.exchangeBusyPromise, yield this.device.releaseInterface(this.interfaceNumber), yield _(this.device), yield this.device.close();
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Exchange with the device using APDU protocol.
|
|
387
|
+
* @param apdu
|
|
388
|
+
* @returns a promise of apdu response
|
|
389
|
+
*/
|
|
390
|
+
exchange(e) {
|
|
391
|
+
return h(this, void 0, void 0, function* () {
|
|
392
|
+
return yield this.exchangeAtomicImpl(() => h(this, void 0, void 0, function* () {
|
|
393
|
+
const { channel: t, packetSize: s } = this;
|
|
394
|
+
d("apdu", "=> " + e.toString("hex"));
|
|
395
|
+
const o = C(t, s), i = o.makeBlocks(e);
|
|
396
|
+
for (let d2 = 0; d2 < i.length; d2++)
|
|
397
|
+
yield this.device.transferOut(D, i[d2]);
|
|
398
|
+
let r, a;
|
|
399
|
+
for (; !(r = o.getReducedResult(a)); ) {
|
|
400
|
+
const d2 = yield this.device.transferIn(D, s), c = dist.Buffer.from(d2.data.buffer);
|
|
401
|
+
a = o.reduceResponse(a, c);
|
|
402
|
+
}
|
|
403
|
+
return d("apdu", "<= " + r.toString("hex")), r;
|
|
404
|
+
})).catch((t) => {
|
|
405
|
+
throw t && t.message && t.message.includes("disconnected") ? (this._emitDisconnect(t), new N(t.message)) : t;
|
|
406
|
+
});
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
setScrambleKey() {
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
p.isSupported = F;
|
|
413
|
+
p.list = y;
|
|
414
|
+
p.listen = (u$1) => {
|
|
415
|
+
let e = false;
|
|
416
|
+
K().then((t) => {
|
|
417
|
+
if (!e) {
|
|
418
|
+
const s = z$1(t.productId);
|
|
419
|
+
u$1.next({
|
|
420
|
+
type: "add",
|
|
421
|
+
descriptor: t,
|
|
422
|
+
deviceModel: s
|
|
423
|
+
}), u$1.complete();
|
|
424
|
+
}
|
|
425
|
+
}, (t) => {
|
|
426
|
+
window.DOMException && t instanceof window.DOMException && t.code === 18 ? u$1.error(new u(t.message)) : u$1.error(new C$1(t.message));
|
|
427
|
+
});
|
|
428
|
+
function n() {
|
|
429
|
+
e = true;
|
|
430
|
+
}
|
|
431
|
+
return {
|
|
432
|
+
unsubscribe: n
|
|
433
|
+
};
|
|
434
|
+
};
|
|
435
|
+
function _(u2) {
|
|
436
|
+
return h(this, void 0, void 0, function* () {
|
|
437
|
+
try {
|
|
438
|
+
yield u2.reset();
|
|
439
|
+
} catch (e) {
|
|
440
|
+
console.warn(e);
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
export {
|
|
445
|
+
p as default
|
|
446
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { g as ar$1, h as Or$1, i as N, o as ot$1, j as Mv, l as dg, u as ub, n as ov, q as Re, G as Gg, L as Ll, X as Xg, $ as $k, J as Jg, s as sb } from "./
|
|
2
|
-
import "./
|
|
1
|
+
import { g as ar$1, h as Or$1, i as N, o as ot$1, j as Mv, l as dg, u as ub, n as ov, q as Re, G as Gg, L as Ll, X as Xg, $ as $k, J as Jg, s as sb } from "./index_e2794130.js";
|
|
2
|
+
import "./index_aa71379e.js";
|
|
3
3
|
import "react";
|
|
4
4
|
import "@chakra-ui/react";
|
|
5
5
|
import "react-dom";
|
|
6
|
-
import "./
|
|
6
|
+
import "./index_0652205a.js";
|
|
7
7
|
function E0(f, t) {
|
|
8
8
|
for (var n = 0; n < t.length; n++) {
|
|
9
9
|
const i = t[n];
|