@onekeyfe/hwk-adapter-core 1.1.26-alpha.100
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.d.mts +1010 -0
- package/dist/index.d.ts +1010 -0
- package/dist/index.js +447 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +398 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +51 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
// src/types/errors.ts
|
|
2
|
+
var HardwareErrorCode = /* @__PURE__ */ ((HardwareErrorCode2) => {
|
|
3
|
+
HardwareErrorCode2[HardwareErrorCode2["UnknownError"] = 0] = "UnknownError";
|
|
4
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceNotFound"] = 1] = "DeviceNotFound";
|
|
5
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceDisconnected"] = 2] = "DeviceDisconnected";
|
|
6
|
+
HardwareErrorCode2[HardwareErrorCode2["UserRejected"] = 3] = "UserRejected";
|
|
7
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceBusy"] = 4] = "DeviceBusy";
|
|
8
|
+
HardwareErrorCode2[HardwareErrorCode2["FirmwareUpdateRequired"] = 5] = "FirmwareUpdateRequired";
|
|
9
|
+
HardwareErrorCode2[HardwareErrorCode2["AppNotOpen"] = 6] = "AppNotOpen";
|
|
10
|
+
HardwareErrorCode2[HardwareErrorCode2["InvalidParams"] = 7] = "InvalidParams";
|
|
11
|
+
HardwareErrorCode2[HardwareErrorCode2["TransportError"] = 8] = "TransportError";
|
|
12
|
+
HardwareErrorCode2[HardwareErrorCode2["OperationTimeout"] = 9] = "OperationTimeout";
|
|
13
|
+
HardwareErrorCode2[HardwareErrorCode2["MethodNotSupported"] = 10] = "MethodNotSupported";
|
|
14
|
+
HardwareErrorCode2[HardwareErrorCode2["PinInvalid"] = 5520] = "PinInvalid";
|
|
15
|
+
HardwareErrorCode2[HardwareErrorCode2["PinCancelled"] = 5521] = "PinCancelled";
|
|
16
|
+
HardwareErrorCode2[HardwareErrorCode2["PassphraseRejected"] = 5522] = "PassphraseRejected";
|
|
17
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceLocked"] = 5530] = "DeviceLocked";
|
|
18
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceNotInitialized"] = 5531] = "DeviceNotInitialized";
|
|
19
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceInBootloader"] = 5532] = "DeviceInBootloader";
|
|
20
|
+
HardwareErrorCode2[HardwareErrorCode2["FirmwareTooOld"] = 5533] = "FirmwareTooOld";
|
|
21
|
+
HardwareErrorCode2[HardwareErrorCode2["WrongApp"] = 5540] = "WrongApp";
|
|
22
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceMismatch"] = 5560] = "DeviceMismatch";
|
|
23
|
+
HardwareErrorCode2[HardwareErrorCode2["BridgeNotFound"] = 5550] = "BridgeNotFound";
|
|
24
|
+
HardwareErrorCode2[HardwareErrorCode2["TransportNotAvailable"] = 5551] = "TransportNotAvailable";
|
|
25
|
+
return HardwareErrorCode2;
|
|
26
|
+
})(HardwareErrorCode || {});
|
|
27
|
+
|
|
28
|
+
// src/types/response.ts
|
|
29
|
+
function success(payload) {
|
|
30
|
+
return { success: true, payload };
|
|
31
|
+
}
|
|
32
|
+
function failure(code, error) {
|
|
33
|
+
return { success: false, payload: { error, code } };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/types/fingerprint.ts
|
|
37
|
+
var CHAIN_FINGERPRINT_PATHS = {
|
|
38
|
+
evm: "m/44'/60'/0'/0/0",
|
|
39
|
+
// BTC: account-level path (3 levels), mainnet cointype 0.
|
|
40
|
+
// Cointype 1 (testnet) is rejected by some Ledger BTC App configurations.
|
|
41
|
+
btc: "m/44'/0'/0'",
|
|
42
|
+
sol: "m/44'/501'/0'",
|
|
43
|
+
tron: "m/44'/195'/0'/0/0"
|
|
44
|
+
};
|
|
45
|
+
function deriveDeviceFingerprint(address) {
|
|
46
|
+
let h1 = 2166136261;
|
|
47
|
+
let h2 = 16777619;
|
|
48
|
+
for (let i = 0; i < address.length; i++) {
|
|
49
|
+
const c = address.charCodeAt(i);
|
|
50
|
+
h1 = Math.imul(h1 ^ c, h2);
|
|
51
|
+
h2 = Math.imul(h2 ^ c >>> 4, 16777619);
|
|
52
|
+
}
|
|
53
|
+
h1 = Math.imul(h1 ^ h1 >>> 16, 73244475);
|
|
54
|
+
h2 = Math.imul(h2 ^ h2 >>> 16, 73244475);
|
|
55
|
+
const hex1 = (h1 >>> 0).toString(16).padStart(8, "0");
|
|
56
|
+
const hex2 = (h2 >>> 0).toString(16).padStart(8, "0");
|
|
57
|
+
return `${hex1}${hex2}`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// src/events/device.ts
|
|
61
|
+
var DEVICE_EVENT = "DEVICE_EVENT";
|
|
62
|
+
var DEVICE = {
|
|
63
|
+
CONNECT: "device-connect",
|
|
64
|
+
DISCONNECT: "device-disconnect",
|
|
65
|
+
CHANGED: "device-changed",
|
|
66
|
+
ACQUIRE: "device-acquire",
|
|
67
|
+
RELEASE: "device-release",
|
|
68
|
+
FEATURES: "features",
|
|
69
|
+
SUPPORT_FEATURES: "support_features"
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// src/events/ui-request.ts
|
|
73
|
+
var UI_EVENT = "UI_EVENT";
|
|
74
|
+
var UI_REQUEST = {
|
|
75
|
+
REQUEST_PIN: "ui-request-pin",
|
|
76
|
+
REQUEST_PASSPHRASE: "ui-request-passphrase",
|
|
77
|
+
REQUEST_PASSPHRASE_ON_DEVICE: "ui-request-passphrase-on-device",
|
|
78
|
+
REQUEST_BUTTON: "ui-request-button",
|
|
79
|
+
REQUEST_QR_DISPLAY: "ui-request-qr-display",
|
|
80
|
+
REQUEST_QR_SCAN: "ui-request-qr-scan",
|
|
81
|
+
REQUEST_DEVICE_PERMISSION: "ui-request-device-permission",
|
|
82
|
+
REQUEST_SELECT_DEVICE: "ui-request-select-device",
|
|
83
|
+
REQUEST_DEVICE_CONNECT: "ui-request-device-connect",
|
|
84
|
+
CLOSE_UI_WINDOW: "ui-close",
|
|
85
|
+
DEVICE_PROGRESS: "ui-device_progress",
|
|
86
|
+
FIRMWARE_PROGRESS: "ui-firmware-progress",
|
|
87
|
+
FIRMWARE_TIP: "ui-firmware-tip"
|
|
88
|
+
};
|
|
89
|
+
var UI_RESPONSE = {
|
|
90
|
+
RECEIVE_PIN: "receive-pin",
|
|
91
|
+
RECEIVE_PASSPHRASE: "receive-passphrase",
|
|
92
|
+
RECEIVE_PASSPHRASE_ON_DEVICE: "receive-passphrase-on-device",
|
|
93
|
+
RECEIVE_QR_RESPONSE: "receive-qr-response",
|
|
94
|
+
RECEIVE_SELECT_DEVICE: "receive-select-device",
|
|
95
|
+
CANCEL: "cancel"
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// src/events/sdk.ts
|
|
99
|
+
var SDK = {
|
|
100
|
+
DEVICE_STUCK: "device-stuck",
|
|
101
|
+
DEVICE_UNRESPONSIVE: "device-unresponsive",
|
|
102
|
+
DEVICE_RECOVERED: "device-recovered",
|
|
103
|
+
DEVICE_INTERACTION: "device-interaction"
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// src/utils/DeviceJobQueue.ts
|
|
107
|
+
var DeviceJobQueue = class {
|
|
108
|
+
constructor() {
|
|
109
|
+
this._queues = /* @__PURE__ */ new Map();
|
|
110
|
+
this._active = /* @__PURE__ */ new Map();
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Enqueue a job for a specific device.
|
|
114
|
+
* If a job is already running for this device, behavior depends on interruptibility:
|
|
115
|
+
* - 'none': new job queues silently (no preemption possible)
|
|
116
|
+
* - 'safe': current job is auto-cancelled, new job runs immediately after
|
|
117
|
+
* - 'confirm': onPreemptionRequest is called to ask user
|
|
118
|
+
*/
|
|
119
|
+
async enqueue(deviceId, job, options = {}) {
|
|
120
|
+
const interruptibility = options.interruptibility ?? "confirm";
|
|
121
|
+
const active = this._active.get(deviceId);
|
|
122
|
+
if (active) {
|
|
123
|
+
switch (active.options.interruptibility) {
|
|
124
|
+
case "none":
|
|
125
|
+
break;
|
|
126
|
+
case "safe":
|
|
127
|
+
active.abortController.abort(new Error("Preempted by new operation"));
|
|
128
|
+
break;
|
|
129
|
+
case "confirm": {
|
|
130
|
+
if (this.onPreemptionRequest) {
|
|
131
|
+
const decision = await this.onPreemptionRequest({
|
|
132
|
+
deviceId,
|
|
133
|
+
currentJob: {
|
|
134
|
+
label: active.options.label,
|
|
135
|
+
interruptibility: active.options.interruptibility,
|
|
136
|
+
startedAt: active.startedAt
|
|
137
|
+
},
|
|
138
|
+
newJob: {
|
|
139
|
+
label: options.label,
|
|
140
|
+
interruptibility
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
switch (decision) {
|
|
144
|
+
case "cancel-current":
|
|
145
|
+
active.abortController.abort(new Error("Cancelled by user via preemption"));
|
|
146
|
+
break;
|
|
147
|
+
case "reject-new":
|
|
148
|
+
throw Object.assign(
|
|
149
|
+
new Error(`Device busy: ${active.options.label ?? "unknown operation"}`),
|
|
150
|
+
{ hardwareErrorCode: "DEVICE_BUSY" }
|
|
151
|
+
);
|
|
152
|
+
case "wait":
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const ac = new AbortController();
|
|
161
|
+
const prev = this._queues.get(deviceId) ?? Promise.resolve();
|
|
162
|
+
const next = prev.catch(() => {
|
|
163
|
+
}).then(async () => {
|
|
164
|
+
this._active.set(deviceId, {
|
|
165
|
+
options: { interruptibility, label: options.label },
|
|
166
|
+
abortController: ac,
|
|
167
|
+
startedAt: Date.now()
|
|
168
|
+
});
|
|
169
|
+
try {
|
|
170
|
+
return await job(ac.signal);
|
|
171
|
+
} finally {
|
|
172
|
+
this._active.delete(deviceId);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
const tail = next.catch(() => {
|
|
176
|
+
});
|
|
177
|
+
this._queues.set(deviceId, tail);
|
|
178
|
+
tail.then(() => {
|
|
179
|
+
if (this._queues.get(deviceId) === tail) {
|
|
180
|
+
this._queues.delete(deviceId);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
return next;
|
|
184
|
+
}
|
|
185
|
+
/** Manually cancel the active job on a device. Returns false if job is non-interruptible. */
|
|
186
|
+
cancelActive(deviceId) {
|
|
187
|
+
const active = this._active.get(deviceId);
|
|
188
|
+
if (!active) return false;
|
|
189
|
+
if (active.options.interruptibility === "none") return false;
|
|
190
|
+
active.abortController.abort(new Error("Manually cancelled"));
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
/** Force cancel regardless of interruptibility. Use for device stuck recovery. */
|
|
194
|
+
forceCancelActive(deviceId) {
|
|
195
|
+
const active = this._active.get(deviceId);
|
|
196
|
+
if (!active) return false;
|
|
197
|
+
active.abortController.abort(new Error("Force cancelled for recovery"));
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
/** Get info about the currently active job for a device, or null if idle. */
|
|
201
|
+
getActiveJob(deviceId) {
|
|
202
|
+
const active = this._active.get(deviceId);
|
|
203
|
+
if (!active) return null;
|
|
204
|
+
return {
|
|
205
|
+
label: active.options.label,
|
|
206
|
+
interruptibility: active.options.interruptibility,
|
|
207
|
+
startedAt: active.startedAt
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
clear() {
|
|
211
|
+
for (const active of this._active.values()) {
|
|
212
|
+
active.abortController.abort(new Error("Queue cleared"));
|
|
213
|
+
}
|
|
214
|
+
this._active.clear();
|
|
215
|
+
this._queues.clear();
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// src/types/connector.ts
|
|
220
|
+
var EConnectorInteraction = /* @__PURE__ */ ((EConnectorInteraction2) => {
|
|
221
|
+
EConnectorInteraction2["ConfirmOpenApp"] = "confirm-open-app";
|
|
222
|
+
EConnectorInteraction2["UnlockDevice"] = "unlock-device";
|
|
223
|
+
EConnectorInteraction2["ConfirmOnDevice"] = "confirm-on-device";
|
|
224
|
+
EConnectorInteraction2["InteractionComplete"] = "interaction-complete";
|
|
225
|
+
return EConnectorInteraction2;
|
|
226
|
+
})(EConnectorInteraction || {});
|
|
227
|
+
function createBridgedConnector(vendor, bridge) {
|
|
228
|
+
const handlerMap = /* @__PURE__ */ new Map();
|
|
229
|
+
return {
|
|
230
|
+
searchDevices: () => bridge.searchDevices({ vendor }),
|
|
231
|
+
connect: (deviceId) => bridge.connect({ vendor, deviceId }),
|
|
232
|
+
disconnect: (sessionId) => bridge.disconnect({ vendor, sessionId }),
|
|
233
|
+
call: (sessionId, method, callParams) => bridge.call({ vendor, sessionId, method, callParams }),
|
|
234
|
+
cancel: (sessionId) => bridge.cancel({ vendor, sessionId }),
|
|
235
|
+
uiResponse: (response) => bridge.uiResponse({ vendor, response }),
|
|
236
|
+
on: (event, handler) => {
|
|
237
|
+
const bridgeHandler = (e) => {
|
|
238
|
+
if (e.type === event) {
|
|
239
|
+
handler(e.data);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
handlerMap.set(
|
|
243
|
+
handler,
|
|
244
|
+
bridgeHandler
|
|
245
|
+
);
|
|
246
|
+
bridge.onEvent({ vendor }, bridgeHandler);
|
|
247
|
+
},
|
|
248
|
+
off: (_event, handler) => {
|
|
249
|
+
const bridgeHandler = handlerMap.get(
|
|
250
|
+
handler
|
|
251
|
+
);
|
|
252
|
+
if (bridgeHandler) {
|
|
253
|
+
bridge.offEvent({ vendor }, bridgeHandler);
|
|
254
|
+
handlerMap.delete(handler);
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
reset: () => bridge.reset({ vendor })
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// src/utils/TypedEventEmitter.ts
|
|
262
|
+
var TypedEventEmitter = class {
|
|
263
|
+
constructor() {
|
|
264
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
265
|
+
this._listeners = /* @__PURE__ */ new Map();
|
|
266
|
+
}
|
|
267
|
+
on(event, listener) {
|
|
268
|
+
let set = this._listeners.get(event);
|
|
269
|
+
if (!set) {
|
|
270
|
+
set = /* @__PURE__ */ new Set();
|
|
271
|
+
this._listeners.set(event, set);
|
|
272
|
+
}
|
|
273
|
+
set.add(listener);
|
|
274
|
+
}
|
|
275
|
+
off(event, listener) {
|
|
276
|
+
const set = this._listeners.get(event);
|
|
277
|
+
if (set) {
|
|
278
|
+
set.delete(listener);
|
|
279
|
+
if (set.size === 0) this._listeners.delete(event);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
emit(event, data) {
|
|
283
|
+
const set = this._listeners.get(event);
|
|
284
|
+
if (set) {
|
|
285
|
+
for (const listener of set) listener(data);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
removeAllListeners() {
|
|
289
|
+
this._listeners.clear();
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
// src/utils/semver.ts
|
|
294
|
+
function compareSemver(a, b) {
|
|
295
|
+
const pa = a.split(".").map(Number);
|
|
296
|
+
const pb = b.split(".").map(Number);
|
|
297
|
+
for (let i = 0; i < 3; i++) {
|
|
298
|
+
const va = pa[i] ?? 0;
|
|
299
|
+
const vb = pb[i] ?? 0;
|
|
300
|
+
if (va < vb) return -1;
|
|
301
|
+
if (va > vb) return 1;
|
|
302
|
+
}
|
|
303
|
+
return 0;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// src/utils/hex.ts
|
|
307
|
+
function ensure0x(hex) {
|
|
308
|
+
return hex.startsWith("0x") ? hex : `0x${hex}`;
|
|
309
|
+
}
|
|
310
|
+
function stripHex(hex) {
|
|
311
|
+
return hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
312
|
+
}
|
|
313
|
+
function padHex64(hex) {
|
|
314
|
+
return `0x${stripHex(hex).padStart(64, "0")}`;
|
|
315
|
+
}
|
|
316
|
+
function hexToBytes(hex) {
|
|
317
|
+
const clean = stripHex(hex);
|
|
318
|
+
const bytes = new Uint8Array(clean.length / 2);
|
|
319
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
320
|
+
bytes[i] = parseInt(clean.slice(i * 2, i * 2 + 2), 16);
|
|
321
|
+
}
|
|
322
|
+
return bytes;
|
|
323
|
+
}
|
|
324
|
+
function bytesToHex(bytes) {
|
|
325
|
+
return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// src/utils/errorMessages.ts
|
|
329
|
+
function enrichErrorMessage(code, originalMessage) {
|
|
330
|
+
switch (code) {
|
|
331
|
+
case 5520 /* PinInvalid */:
|
|
332
|
+
return `${originalMessage}. Please re-enter your PIN.`;
|
|
333
|
+
case 5521 /* PinCancelled */:
|
|
334
|
+
return `${originalMessage}. PIN entry was cancelled.`;
|
|
335
|
+
case 4 /* DeviceBusy */:
|
|
336
|
+
return `${originalMessage}. The device is in use by another application. Close other wallet apps and try again.`;
|
|
337
|
+
case 2 /* DeviceDisconnected */:
|
|
338
|
+
return `${originalMessage}. Please reconnect the device and try again.`;
|
|
339
|
+
case 5530 /* DeviceLocked */:
|
|
340
|
+
return `${originalMessage}. Please unlock your device and try again.`;
|
|
341
|
+
case 3 /* UserRejected */:
|
|
342
|
+
return `${originalMessage}. The request was rejected on the device.`;
|
|
343
|
+
case 5540 /* WrongApp */:
|
|
344
|
+
return `${originalMessage}. Please open the correct app on your device.`;
|
|
345
|
+
case 6 /* AppNotOpen */:
|
|
346
|
+
return `${originalMessage}. The required app is not installed on the device.`;
|
|
347
|
+
case 5551 /* TransportNotAvailable */:
|
|
348
|
+
return `${originalMessage}. Ensure the device bridge/transport is available and running.`;
|
|
349
|
+
case 5533 /* FirmwareTooOld */:
|
|
350
|
+
return `${originalMessage}. Please update your device firmware.`;
|
|
351
|
+
case 5531 /* DeviceNotInitialized */:
|
|
352
|
+
return `${originalMessage}. The device may need to be set up first.`;
|
|
353
|
+
case 9 /* OperationTimeout */:
|
|
354
|
+
return `${originalMessage}. The operation timed out. Please try again.`;
|
|
355
|
+
default:
|
|
356
|
+
return originalMessage;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// src/utils/batchCall.ts
|
|
361
|
+
async function batchCall(params, callFn, onProgress) {
|
|
362
|
+
const results = [];
|
|
363
|
+
for (let i = 0; i < params.length; i++) {
|
|
364
|
+
const result = await callFn(params[i]);
|
|
365
|
+
if (!result.success) {
|
|
366
|
+
return result;
|
|
367
|
+
}
|
|
368
|
+
results.push(result.payload);
|
|
369
|
+
onProgress?.({ index: i, total: params.length });
|
|
370
|
+
}
|
|
371
|
+
return { success: true, payload: results };
|
|
372
|
+
}
|
|
373
|
+
export {
|
|
374
|
+
CHAIN_FINGERPRINT_PATHS,
|
|
375
|
+
DEVICE,
|
|
376
|
+
DEVICE_EVENT,
|
|
377
|
+
DeviceJobQueue,
|
|
378
|
+
EConnectorInteraction,
|
|
379
|
+
HardwareErrorCode,
|
|
380
|
+
SDK,
|
|
381
|
+
TypedEventEmitter,
|
|
382
|
+
UI_EVENT,
|
|
383
|
+
UI_REQUEST,
|
|
384
|
+
UI_RESPONSE,
|
|
385
|
+
batchCall,
|
|
386
|
+
bytesToHex,
|
|
387
|
+
compareSemver,
|
|
388
|
+
createBridgedConnector,
|
|
389
|
+
deriveDeviceFingerprint,
|
|
390
|
+
enrichErrorMessage,
|
|
391
|
+
ensure0x,
|
|
392
|
+
failure,
|
|
393
|
+
hexToBytes,
|
|
394
|
+
padHex64,
|
|
395
|
+
stripHex,
|
|
396
|
+
success
|
|
397
|
+
};
|
|
398
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types/errors.ts","../src/types/response.ts","../src/types/fingerprint.ts","../src/events/device.ts","../src/events/ui-request.ts","../src/events/sdk.ts","../src/utils/DeviceJobQueue.ts","../src/types/connector.ts","../src/utils/TypedEventEmitter.ts","../src/utils/semver.ts","../src/utils/hex.ts","../src/utils/errorMessages.ts","../src/utils/batchCall.ts"],"sourcesContent":["export enum HardwareErrorCode {\n UnknownError = 0,\n DeviceNotFound = 1,\n DeviceDisconnected = 2,\n UserRejected = 3,\n DeviceBusy = 4,\n FirmwareUpdateRequired = 5,\n AppNotOpen = 6,\n InvalidParams = 7,\n TransportError = 8,\n OperationTimeout = 9,\n MethodNotSupported = 10,\n\n // PIN / Passphrase\n PinInvalid = 5520,\n PinCancelled = 5521,\n PassphraseRejected = 5522,\n\n // Device state\n DeviceLocked = 5530,\n DeviceNotInitialized = 5531,\n DeviceInBootloader = 5532,\n FirmwareTooOld = 5533,\n\n // Ledger specific\n WrongApp = 5540,\n\n // Device identity\n DeviceMismatch = 5560,\n\n // Transport\n BridgeNotFound = 5550,\n TransportNotAvailable = 5551,\n}\n","import { HardwareErrorCode } from './errors';\n\nexport interface Success<T> {\n success: true;\n payload: T;\n}\n\nexport interface Failure {\n success: false;\n payload: {\n error: string;\n code: HardwareErrorCode;\n };\n}\n\nexport type Response<T> = Success<T> | Failure;\n\nexport function success<T>(payload: T): Success<T> {\n return { success: true, payload };\n}\n\nexport function failure(code: HardwareErrorCode, error: string): Failure {\n return { success: false, payload: { error, code } };\n}\n","/**\n * Chain fingerprint utilities for device identity verification.\n *\n * Ledger devices have ephemeral IDs that change every session.\n * To verify that the same seed/device is connected, we derive an address\n * at a fixed path (account 0, index 0) and hash it into a stable \"chain fingerprint\".\n */\n\n/**\n * Fixed derivation paths used to generate chain fingerprints.\n * Uses standard index 0 — Ledger firmware shows device confirmation for\n * non-standard paths (e.g., index=100), which would interrupt wallet creation.\n * The address is hashed into a 16-char fingerprint, not exposed directly.\n * - EVM: cointype 60 (Ledger ETH App only supports 60)\n * - BTC: cointype 1 (testnet)\n * - SOL: cointype 501, standard 3-level hardened\n */\nexport const CHAIN_FINGERPRINT_PATHS: Record<ChainForFingerprint, string> = {\n evm: \"m/44'/60'/0'/0/0\",\n // BTC: account-level path (3 levels), mainnet cointype 0.\n // Cointype 1 (testnet) is rejected by some Ledger BTC App configurations.\n btc: \"m/44'/0'/0'\",\n sol: \"m/44'/501'/0'\",\n tron: \"m/44'/195'/0'/0/0\",\n};\n\nexport type ChainForFingerprint = 'evm' | 'btc' | 'sol' | 'tron';\n\n/**\n * Hash an address string into a 16-character hex fingerprint.\n *\n * Uses a simple non-cryptographic hash (FNV-1a based) to avoid\n * pulling in a SHA-256 dependency. This is NOT used for security —\n * only for device identity matching.\n */\nexport function deriveDeviceFingerprint(address: string): string {\n // FNV-1a 64-bit constants (split into two 32-bit halves for JS)\n let h1 = 0x811c9dc5;\n let h2 = 0x01000193;\n\n for (let i = 0; i < address.length; i++) {\n const c = address.charCodeAt(i);\n h1 = Math.imul(h1 ^ c, h2);\n h2 = Math.imul(h2 ^ (c >>> 4), 0x01000193);\n }\n\n // Mix the two halves for better distribution\n h1 = Math.imul(h1 ^ (h1 >>> 16), 0x45d9f3b);\n h2 = Math.imul(h2 ^ (h2 >>> 16), 0x45d9f3b);\n\n const hex1 = (h1 >>> 0).toString(16).padStart(8, '0');\n const hex2 = (h2 >>> 0).toString(16).padStart(8, '0');\n\n return `${hex1}${hex2}`;\n}\n","export const DEVICE_EVENT = 'DEVICE_EVENT';\n\n/** Events originating from the hardware device. */\nexport const DEVICE = {\n CONNECT: 'device-connect',\n DISCONNECT: 'device-disconnect',\n CHANGED: 'device-changed',\n ACQUIRE: 'device-acquire',\n RELEASE: 'device-release',\n FEATURES: 'features',\n SUPPORT_FEATURES: 'support_features',\n} as const;\n","export const UI_EVENT = 'UI_EVENT';\n\nexport const UI_REQUEST = {\n REQUEST_PIN: 'ui-request-pin',\n REQUEST_PASSPHRASE: 'ui-request-passphrase',\n REQUEST_PASSPHRASE_ON_DEVICE: 'ui-request-passphrase-on-device',\n REQUEST_BUTTON: 'ui-request-button',\n REQUEST_QR_DISPLAY: 'ui-request-qr-display',\n REQUEST_QR_SCAN: 'ui-request-qr-scan',\n REQUEST_DEVICE_PERMISSION: 'ui-request-device-permission',\n REQUEST_SELECT_DEVICE: 'ui-request-select-device',\n REQUEST_DEVICE_CONNECT: 'ui-request-device-connect',\n CLOSE_UI_WINDOW: 'ui-close',\n DEVICE_PROGRESS: 'ui-device_progress',\n FIRMWARE_PROGRESS: 'ui-firmware-progress',\n FIRMWARE_TIP: 'ui-firmware-tip',\n} as const;\n\nexport const UI_RESPONSE = {\n RECEIVE_PIN: 'receive-pin',\n RECEIVE_PASSPHRASE: 'receive-passphrase',\n RECEIVE_PASSPHRASE_ON_DEVICE: 'receive-passphrase-on-device',\n RECEIVE_QR_RESPONSE: 'receive-qr-response',\n RECEIVE_SELECT_DEVICE: 'receive-select-device',\n CANCEL: 'cancel',\n} as const;\n","/** Events generated by SDK internal detection (not from hardware directly). */\nexport const SDK = {\n DEVICE_STUCK: 'device-stuck',\n DEVICE_UNRESPONSIVE: 'device-unresponsive',\n DEVICE_RECOVERED: 'device-recovered',\n DEVICE_INTERACTION: 'device-interaction',\n} as const;\n","/**\n * Per-device serial job queue with preemption support and stuck recovery.\n * Ensures that only one operation runs at a time per device, with intelligent\n * handling of conflicting operations.\n */\n\nexport type Interruptibility = 'none' | 'safe' | 'confirm';\n\nexport type PreemptionDecision = 'cancel-current' | 'wait' | 'reject-new';\n\nexport interface JobOptions {\n interruptibility?: Interruptibility;\n label?: string;\n}\n\nexport interface ActiveJobInfo {\n label?: string;\n interruptibility: Interruptibility;\n startedAt: number;\n}\n\nexport interface PreemptionEvent {\n deviceId: string;\n currentJob: ActiveJobInfo;\n newJob: { label?: string; interruptibility: Interruptibility };\n}\n\ninterface ActiveJob {\n options: Required<Pick<JobOptions, 'interruptibility'>> & Pick<JobOptions, 'label'>;\n abortController: AbortController;\n startedAt: number;\n}\n\nexport class DeviceJobQueue {\n private readonly _queues = new Map<string, Promise<unknown>>();\n private readonly _active = new Map<string, ActiveJob>();\n\n /**\n * Called when a new job conflicts with an active 'confirm'-level job.\n * UI should show a dialog and return the user's decision.\n * If not set, defaults to 'wait' (queue behind current job).\n */\n onPreemptionRequest?: (event: PreemptionEvent) => Promise<PreemptionDecision>;\n\n /**\n * Enqueue a job for a specific device.\n * If a job is already running for this device, behavior depends on interruptibility:\n * - 'none': new job queues silently (no preemption possible)\n * - 'safe': current job is auto-cancelled, new job runs immediately after\n * - 'confirm': onPreemptionRequest is called to ask user\n */\n async enqueue<T>(\n deviceId: string,\n job: (signal: AbortSignal) => Promise<T>,\n options: JobOptions = {}\n ): Promise<T> {\n const interruptibility = options.interruptibility ?? 'confirm';\n const active = this._active.get(deviceId);\n\n if (active) {\n switch (active.options.interruptibility) {\n case 'none':\n // Cannot interrupt, just queue behind\n break;\n case 'safe':\n // Auto-cancel current safe operation\n active.abortController.abort(new Error('Preempted by new operation'));\n break;\n case 'confirm': {\n if (this.onPreemptionRequest) {\n const decision = await this.onPreemptionRequest({\n deviceId,\n currentJob: {\n label: active.options.label,\n interruptibility: active.options.interruptibility,\n startedAt: active.startedAt,\n },\n newJob: {\n label: options.label,\n interruptibility,\n },\n });\n switch (decision) {\n case 'cancel-current':\n active.abortController.abort(new Error('Cancelled by user via preemption'));\n break;\n case 'reject-new':\n throw Object.assign(\n new Error(`Device busy: ${active.options.label ?? 'unknown operation'}`),\n { hardwareErrorCode: 'DEVICE_BUSY' }\n );\n case 'wait':\n break;\n }\n }\n break;\n }\n }\n }\n\n const ac = new AbortController();\n const prev = this._queues.get(deviceId) ?? Promise.resolve();\n\n const next = prev\n .catch(() => {})\n .then(async () => {\n this._active.set(deviceId, {\n options: { interruptibility, label: options.label },\n abortController: ac,\n startedAt: Date.now(),\n });\n try {\n return await job(ac.signal);\n } finally {\n this._active.delete(deviceId);\n }\n });\n\n const tail = next.catch(() => {});\n this._queues.set(deviceId, tail);\n tail.then(() => {\n if (this._queues.get(deviceId) === tail) {\n this._queues.delete(deviceId);\n }\n });\n return next;\n }\n\n /** Manually cancel the active job on a device. Returns false if job is non-interruptible. */\n cancelActive(deviceId: string): boolean {\n const active = this._active.get(deviceId);\n if (!active) return false;\n if (active.options.interruptibility === 'none') return false;\n active.abortController.abort(new Error('Manually cancelled'));\n return true;\n }\n\n /** Force cancel regardless of interruptibility. Use for device stuck recovery. */\n forceCancelActive(deviceId: string): boolean {\n const active = this._active.get(deviceId);\n if (!active) return false;\n active.abortController.abort(new Error('Force cancelled for recovery'));\n return true;\n }\n\n /** Get info about the currently active job for a device, or null if idle. */\n getActiveJob(deviceId: string): ActiveJobInfo | null {\n const active = this._active.get(deviceId);\n if (!active) return null;\n return {\n label: active.options.label,\n interruptibility: active.options.interruptibility,\n startedAt: active.startedAt,\n };\n }\n\n clear(): void {\n // Abort all active jobs\n for (const active of this._active.values()) {\n active.abortController.abort(new Error('Queue cleared'));\n }\n this._active.clear();\n this._queues.clear();\n }\n}\n","import type { DeviceCapabilities, DeviceInfo, VendorType } from './device';\n\n// =====================================================================\n// Connector types — transport-level abstraction for device communication\n// =====================================================================\n\n/**\n * Minimal device info returned during discovery (searchDevices).\n * At scan time, full DeviceInfo fields like firmwareVersion are not yet available.\n */\nexport interface ConnectorDevice {\n connectId: string;\n deviceId: string;\n name: string;\n model?: string;\n\n /** Device capabilities — available from scan time */\n capabilities?: DeviceCapabilities;\n}\n\nexport interface ConnectorSession {\n sessionId: string;\n deviceInfo: DeviceInfo;\n}\n\nexport type ConnectorEventType = 'device-connect' | 'device-disconnect' | 'ui-request' | 'ui-event';\n\n/**\n * Interaction event types emitted via 'ui-event'.\n * These map to user-facing prompts (confirm on device, open app, etc.).\n */\nexport enum EConnectorInteraction {\n /** Device requires user to open a specific app */\n ConfirmOpenApp = 'confirm-open-app',\n /** Device requires user to unlock */\n UnlockDevice = 'unlock-device',\n /** Device needs user to confirm on device (sign, verify, etc.) */\n ConfirmOnDevice = 'confirm-on-device',\n /** Previous interaction completed — clear UI prompt */\n InteractionComplete = 'interaction-complete',\n}\n\nexport type ConnectorUiEvent =\n | { type: EConnectorInteraction.ConfirmOpenApp; payload: { sessionId: string } }\n | { type: EConnectorInteraction.UnlockDevice; payload: { sessionId: string } }\n | { type: EConnectorInteraction.ConfirmOnDevice; payload: { sessionId: string } }\n | { type: EConnectorInteraction.InteractionComplete; payload: { sessionId: string } };\n\nexport interface ConnectorEventMap {\n 'device-connect': { device: ConnectorDevice };\n 'device-disconnect': { connectId: string };\n 'ui-request': { type: string; payload?: unknown };\n 'ui-event': ConnectorUiEvent;\n}\n\nexport interface IConnector {\n searchDevices(): Promise<ConnectorDevice[]>;\n connect(deviceId?: string): Promise<ConnectorSession>;\n disconnect(sessionId: string): Promise<void>;\n call(sessionId: string, method: string, params: unknown): Promise<unknown>;\n cancel(sessionId: string): Promise<void>;\n\n /** Send a UI response (e.g. PIN, passphrase) to the device. */\n uiResponse(response: { type: string; payload: unknown }): void;\n\n on<K extends ConnectorEventType>(event: K, handler: (data: ConnectorEventMap[K]) => void): void;\n off<K extends ConnectorEventType>(event: K, handler: (data: ConnectorEventMap[K]) => void): void;\n\n reset(): void;\n}\n\n// =====================================================================\n// Hardware bridge — generic forwarding interface for cross-boundary IConnector\n//\n// The same shape works across any process / context boundary that needs to\n// expose a multi-vendor backend behind a single-vendor IConnector facade:\n// - Electron (renderer ↔ preload/main via contextBridge)\n// - Browser Extension (popup/content ↔ background/offscreen via chrome.runtime)\n// - React Native (JS ↔ native module via NativeModules)\n// - Web Worker / iframe (postMessage)\n//\n// Each method takes a `vendor` discriminator so a single bridge implementation\n// can multiplex across vendors (ledger, trezor, ...).\n// =====================================================================\n\nexport interface IHardwareBridge {\n searchDevices(params: { vendor: VendorType }): Promise<ConnectorDevice[]>;\n connect(params: { vendor: VendorType; deviceId?: string }): Promise<ConnectorSession>;\n disconnect(params: { vendor: VendorType; sessionId: string }): Promise<void>;\n call(params: {\n vendor: VendorType;\n sessionId: string;\n method: string;\n callParams: unknown;\n }): Promise<unknown>;\n cancel(params: { vendor: VendorType; sessionId: string }): Promise<void>;\n uiResponse(params: { vendor: VendorType; response: { type: string; payload: unknown } }): void;\n reset(params: { vendor: VendorType }): void;\n\n /** Register an event handler for connector events forwarded across the bridge. */\n onEvent(\n params: { vendor: VendorType },\n handler: (event: { type: ConnectorEventType; data: unknown }) => void\n ): void;\n\n /** Unregister a previously registered event handler. */\n offEvent(\n params: { vendor: VendorType },\n handler: (event: { type: ConnectorEventType; data: unknown }) => void\n ): void;\n}\n\n/**\n * Adapt an IHardwareBridge (multi-vendor backend) into a single-vendor IConnector.\n * Every IConnector method becomes a transparent forward to bridge.<method>({ vendor, ... }).\n * Events are forwarded via bridge.onEvent / offEvent.\n *\n * Use this anywhere the actual hardware lives behind a process / context boundary\n * (Electron main, extension background, native module, worker, iframe).\n */\nexport function createBridgedConnector(\n vendor: VendorType,\n bridge: IHardwareBridge\n): IConnector {\n // Map from typed IConnector handlers to the bridge handler so we can\n // unregister them correctly via off().\n const handlerMap = new Map<\n (data: ConnectorEventMap[ConnectorEventType]) => void,\n (event: { type: ConnectorEventType; data: unknown }) => void\n >();\n\n return {\n searchDevices: () => bridge.searchDevices({ vendor }),\n connect: deviceId => bridge.connect({ vendor, deviceId }),\n disconnect: sessionId => bridge.disconnect({ vendor, sessionId }),\n call: (sessionId, method, callParams) => bridge.call({ vendor, sessionId, method, callParams }),\n cancel: sessionId => bridge.cancel({ vendor, sessionId }),\n uiResponse: response => bridge.uiResponse({ vendor, response }),\n on: (event, handler) => {\n const bridgeHandler = (e: { type: ConnectorEventType; data: unknown }) => {\n if (e.type === event) {\n handler(e.data as ConnectorEventMap[typeof event]);\n }\n };\n handlerMap.set(\n handler as (data: ConnectorEventMap[ConnectorEventType]) => void,\n bridgeHandler\n );\n bridge.onEvent({ vendor }, bridgeHandler);\n },\n off: (_event, handler) => {\n const bridgeHandler = handlerMap.get(\n handler as (data: ConnectorEventMap[ConnectorEventType]) => void\n );\n if (bridgeHandler) {\n bridge.offEvent({ vendor }, bridgeHandler);\n handlerMap.delete(handler as (data: ConnectorEventMap[ConnectorEventType]) => void);\n }\n },\n reset: () => bridge.reset({ vendor }),\n };\n}\n","/**\n * Minimal typed event emitter using Map<string, Set<listener>>.\n * Each adapter uses this for device events (connect, disconnect, pin, etc.).\n *\n * TMap is a record mapping event name strings to their payload types.\n * Example:\n * type MyEvents = { 'connect': { id: string }; 'disconnect': { id: string } };\n * const emitter = new TypedEventEmitter<MyEvents>();\n * emitter.on('connect', (data) => { data.id }); // data is { id: string }\n *\n * For backward compatibility, TMap defaults to Record<string, any> so that\n * existing code using `new TypedEventEmitter<SomeUnionType>()` still compiles.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class TypedEventEmitter<TMap extends Record<string, any> = Record<string, any>> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private readonly _listeners = new Map<string, Set<(event: any) => void>>();\n\n on<K extends keyof TMap & string>(event: K, listener: (event: TMap[K]) => void): void;\n on(event: string, listener: (event: any) => void): void;\n on(event: string, listener: (event: any) => void): void {\n let set = this._listeners.get(event);\n if (!set) {\n set = new Set();\n this._listeners.set(event, set);\n }\n set.add(listener);\n }\n\n off<K extends keyof TMap & string>(event: K, listener: (event: TMap[K]) => void): void;\n off(event: string, listener: (event: any) => void): void;\n off(event: string, listener: (event: any) => void): void {\n const set = this._listeners.get(event);\n if (set) {\n set.delete(listener);\n if (set.size === 0) this._listeners.delete(event);\n }\n }\n\n emit<K extends keyof TMap & string>(event: K, data: TMap[K]): void;\n emit(event: string, data: unknown): void;\n emit(event: string, data: unknown): void {\n const set = this._listeners.get(event);\n if (set) {\n for (const listener of set) listener(data);\n }\n }\n\n removeAllListeners(): void {\n this._listeners.clear();\n }\n}\n","/**\n * Compare two semver strings (e.g. \"2.1.0\" vs \"2.3.1\").\n * Returns -1 if a < b, 0 if equal, 1 if a > b.\n */\nexport function compareSemver(a: string, b: string): number {\n const pa = a.split('.').map(Number);\n const pb = b.split('.').map(Number);\n for (let i = 0; i < 3; i++) {\n const va = pa[i] ?? 0;\n const vb = pb[i] ?? 0;\n if (va < vb) return -1;\n if (va > vb) return 1;\n }\n return 0;\n}\n","/** Ensure hex string has 0x prefix */\nexport function ensure0x(hex: string): string {\n return hex.startsWith('0x') ? hex : `0x${hex}`;\n}\n\n/** Strip 0x prefix from hex string */\nexport function stripHex(hex: string): string {\n return hex.startsWith('0x') ? hex.slice(2) : hex;\n}\n\n/** Pad hex to 64 chars (32 bytes) with 0x prefix */\nexport function padHex64(hex: string): string {\n return `0x${stripHex(hex).padStart(64, '0')}`;\n}\n\n/** Convert a hex string (with or without 0x prefix) to a Uint8Array. */\nexport function hexToBytes(hex: string): Uint8Array {\n const clean = stripHex(hex);\n const bytes = new Uint8Array(clean.length / 2);\n for (let i = 0; i < bytes.length; i++) {\n bytes[i] = parseInt(clean.slice(i * 2, i * 2 + 2), 16);\n }\n return bytes;\n}\n\n/** Convert a Uint8Array to a hex string (no 0x prefix). */\nexport function bytesToHex(bytes: Uint8Array): string {\n return Array.from(bytes)\n .map(b => b.toString(16).padStart(2, '0'))\n .join('');\n}\n","import { HardwareErrorCode } from '../types/errors';\n\n/**\n * Enrich a hardware error message with actionable recovery hints.\n * Shared across adapters (Ledger, Trezor, etc.).\n */\nexport function enrichErrorMessage(code: HardwareErrorCode, originalMessage: string): string {\n switch (code) {\n case HardwareErrorCode.PinInvalid:\n return `${originalMessage}. Please re-enter your PIN.`;\n case HardwareErrorCode.PinCancelled:\n return `${originalMessage}. PIN entry was cancelled.`;\n case HardwareErrorCode.DeviceBusy:\n return `${originalMessage}. The device is in use by another application. Close other wallet apps and try again.`;\n case HardwareErrorCode.DeviceDisconnected:\n return `${originalMessage}. Please reconnect the device and try again.`;\n case HardwareErrorCode.DeviceLocked:\n return `${originalMessage}. Please unlock your device and try again.`;\n case HardwareErrorCode.UserRejected:\n return `${originalMessage}. The request was rejected on the device.`;\n case HardwareErrorCode.WrongApp:\n return `${originalMessage}. Please open the correct app on your device.`;\n case HardwareErrorCode.AppNotOpen:\n return `${originalMessage}. The required app is not installed on the device.`;\n case HardwareErrorCode.TransportNotAvailable:\n return `${originalMessage}. Ensure the device bridge/transport is available and running.`;\n case HardwareErrorCode.FirmwareTooOld:\n return `${originalMessage}. Please update your device firmware.`;\n case HardwareErrorCode.DeviceNotInitialized:\n return `${originalMessage}. The device may need to be set up first.`;\n case HardwareErrorCode.OperationTimeout:\n return `${originalMessage}. The operation timed out. Please try again.`;\n default:\n return originalMessage;\n }\n}\n","import type { Response } from '../types/response';\n\n/**\n * Generic batch call with progress reporting.\n * If any single call fails, returns the failure immediately.\n */\nexport async function batchCall<TParam, TResult>(\n params: TParam[],\n callFn: (p: TParam) => Promise<Response<TResult>>,\n onProgress?: (progress: { index: number; total: number }) => void\n): Promise<Response<TResult[]>> {\n const results: TResult[] = [];\n for (let i = 0; i < params.length; i++) {\n const result = await callFn(params[i]);\n if (!result.success) {\n return result;\n }\n results.push(result.payload);\n onProgress?.({ index: i, total: params.length });\n }\n return { success: true, payload: results };\n}\n"],"mappings":";AAAO,IAAK,oBAAL,kBAAKA,uBAAL;AACL,EAAAA,sCAAA,kBAAe,KAAf;AACA,EAAAA,sCAAA,oBAAiB,KAAjB;AACA,EAAAA,sCAAA,wBAAqB,KAArB;AACA,EAAAA,sCAAA,kBAAe,KAAf;AACA,EAAAA,sCAAA,gBAAa,KAAb;AACA,EAAAA,sCAAA,4BAAyB,KAAzB;AACA,EAAAA,sCAAA,gBAAa,KAAb;AACA,EAAAA,sCAAA,mBAAgB,KAAhB;AACA,EAAAA,sCAAA,oBAAiB,KAAjB;AACA,EAAAA,sCAAA,sBAAmB,KAAnB;AACA,EAAAA,sCAAA,wBAAqB,MAArB;AAGA,EAAAA,sCAAA,gBAAa,QAAb;AACA,EAAAA,sCAAA,kBAAe,QAAf;AACA,EAAAA,sCAAA,wBAAqB,QAArB;AAGA,EAAAA,sCAAA,kBAAe,QAAf;AACA,EAAAA,sCAAA,0BAAuB,QAAvB;A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AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO;AAAA,EACX;AACF;;;AC7BA,eAAsB,UACpB,QACA,QACA,YAC8B;AAC9B,QAAM,UAAqB,CAAC;AAC5B,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,UAAM,SAAS,MAAM,OAAO,OAAO,CAAC,CAAC;AACrC,QAAI,CAAC,OAAO,SAAS;AACnB,aAAO;AAAA,IACT;AACA,YAAQ,KAAK,OAAO,OAAO;AAC3B,iBAAa,EAAE,OAAO,GAAG,OAAO,OAAO,OAAO,CAAC;AAAA,EACjD;AACA,SAAO,EAAE,SAAS,MAAM,SAAS,QAAQ;AAC3C;","names":["HardwareErrorCode","EConnectorInteraction"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@onekeyfe/hwk-adapter-core",
|
|
3
|
+
"version": "1.1.26-alpha.100",
|
|
4
|
+
"description": "Shared types and utilities for OneKey hardware wallet kit",
|
|
5
|
+
"author": "OneKey",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"module": "dist/index.mjs",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./dist/index.d.mts",
|
|
14
|
+
"default": "./dist/index.mjs"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup",
|
|
27
|
+
"dev": "tsup --watch",
|
|
28
|
+
"clean": "rimraf dist",
|
|
29
|
+
"test": "vitest run"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/OneKeyHQ/hardware-wallet-kit.git",
|
|
37
|
+
"directory": "packages/hwk-adapter-core"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"hardware-wallet",
|
|
41
|
+
"onekey",
|
|
42
|
+
"crypto",
|
|
43
|
+
"types"
|
|
44
|
+
],
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"rimraf": "^5.0.0",
|
|
47
|
+
"tsup": "^8.0.0",
|
|
48
|
+
"typescript": "^5.4.0"
|
|
49
|
+
},
|
|
50
|
+
"gitHead": "02e9376cb38df57b5743b674326c742fa74d1e8b"
|
|
51
|
+
}
|