@bytezhang/hardware-trezor-adapter 0.0.29 → 0.0.32

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.mjs CHANGED
@@ -1,727 +1,12 @@
1
- // src/TrezorAdapter.ts
2
- import {
3
- HardwareErrorCode,
4
- success,
5
- failure,
6
- DEVICE,
7
- UI_REQUEST,
8
- TypedEventEmitter
9
- } from "@bytezhang/hardware-wallet-core";
10
- var TrezorAdapter = class {
11
- constructor(connector) {
12
- this.vendor = "trezor";
13
- this.emitter = new TypedEventEmitter();
14
- this._uiHandler = null;
15
- // Device cache: tracks discovered devices from connector events
16
- this._discoveredDevices = /* @__PURE__ */ new Map();
17
- // Session tracking: maps connectId -> sessionId
18
- this._sessions = /* @__PURE__ */ new Map();
19
- // ─── Event translation ────────────────────────────────────
20
- this.deviceConnectHandler = (data) => {
21
- const deviceInfo = this.connectorDeviceToDeviceInfo(data.device);
22
- this._discoveredDevices.set(deviceInfo.connectId, deviceInfo);
23
- this.emitter.emit(DEVICE.CONNECT, {
24
- type: DEVICE.CONNECT,
25
- payload: deviceInfo
26
- });
27
- };
28
- this.deviceDisconnectHandler = (data) => {
29
- this._discoveredDevices.delete(data.connectId);
30
- this.emitter.emit(DEVICE.DISCONNECT, {
31
- type: DEVICE.DISCONNECT,
32
- payload: { connectId: data.connectId }
33
- });
34
- };
35
- this.uiRequestHandler = (data) => {
36
- this.handleUiEvent(data);
37
- };
38
- this.uiEventHandler = (data) => {
39
- this.handleUiEvent(data);
40
- };
41
- this.connector = connector;
42
- this.registerEventListeners();
43
- }
44
- // ─── Transport ──────────────────────────────────────────
45
- // Transport is decided at connector creation time. These methods
46
- // satisfy the IHardwareWallet interface with sensible defaults.
47
- get activeTransport() {
48
- return "usb";
49
- }
50
- getAvailableTransports() {
51
- return ["usb"];
52
- }
53
- async switchTransport(_type) {
54
- }
55
- // ─── UI handler ────────────────────────────────────────────
56
- setUiHandler(handler) {
57
- this._uiHandler = handler;
58
- }
59
- // ─── Lifecycle ────────────────────────────────────────────
60
- async init(_config) {
61
- }
62
- async dispose() {
63
- this.unregisterEventListeners();
64
- this.connector.reset();
65
- this._uiHandler = null;
66
- this._discoveredDevices.clear();
67
- this._sessions.clear();
68
- this.emitter.removeAllListeners();
69
- }
70
- // ─── Device management ────────────────────────────────────
71
- async searchDevices() {
72
- await this._ensureDevicePermission();
73
- const devices = await this.connector.searchDevices();
74
- for (const d of devices) {
75
- if (d.connectId && !this._discoveredDevices.has(d.connectId)) {
76
- this._discoveredDevices.set(d.connectId, this.connectorDeviceToDeviceInfo(d));
77
- }
78
- }
79
- if (this._discoveredDevices.size === 0) {
80
- await this._ensureDevicePermission();
81
- }
82
- return Array.from(this._discoveredDevices.values());
83
- }
84
- async connectDevice(connectId) {
85
- try {
86
- const session = await this.connector.connect(connectId);
87
- this._sessions.set(connectId, session.sessionId);
88
- if (session.deviceInfo) {
89
- this._discoveredDevices.set(connectId, session.deviceInfo);
90
- }
91
- return success(connectId);
92
- } catch (err) {
93
- return this.errorToFailure(err);
94
- }
95
- }
96
- async disconnectDevice(connectId) {
97
- const sessionId = this._sessions.get(connectId);
98
- if (sessionId) {
99
- await this.connector.disconnect(sessionId);
100
- this._sessions.delete(connectId);
101
- }
102
- }
103
- async getDeviceInfo(connectId, deviceId) {
104
- await this._ensureDevicePermission(connectId, deviceId);
105
- const cached = this._discoveredDevices.get(connectId) ?? Array.from(this._discoveredDevices.values()).find(
106
- (d) => d.deviceId === deviceId
107
- );
108
- if (cached) {
109
- return success(cached);
110
- }
111
- return failure(
112
- HardwareErrorCode.DeviceNotFound,
113
- "Device not found in cache. Call searchDevices() or wait for a device-connected event first."
114
- );
115
- }
116
- getSupportedChains() {
117
- return ["evm", "btc", "sol"];
118
- }
119
- on(event, listener) {
120
- this.emitter.on(event, listener);
121
- }
122
- off(event, listener) {
123
- this.emitter.off(event, listener);
124
- }
125
- cancel(connectId) {
126
- const sessionId = this._sessions.get(connectId) ?? connectId;
127
- void this.connector.cancel(sessionId);
128
- }
129
- // ─── Chain fingerprint ────────────────────────────────────
130
- /**
131
- * For Trezor, the chain fingerprint is the hardware device_id from firmware.
132
- * Trezor has a persistent device identity, so no address derivation is needed.
133
- */
134
- async getChainFingerprint(connectId, deviceId, _chain) {
135
- await this._ensureDevicePermission(connectId, deviceId);
136
- const cached = this._discoveredDevices.get(connectId) ?? Array.from(this._discoveredDevices.values()).find(
137
- (d) => d.deviceId === deviceId
138
- );
139
- if (cached?.deviceId) {
140
- return success(cached.deviceId);
141
- }
142
- try {
143
- const result = await this.connectorCall(connectId, "getFeatures", {});
144
- if (result.device_id) {
145
- return success(result.device_id);
146
- }
147
- } catch {
148
- }
149
- return failure(
150
- HardwareErrorCode.DeviceNotFound,
151
- "Could not determine Trezor device identity. Ensure the device is connected."
152
- );
153
- }
154
- // ─── EVM methods ──────────────────────────────────────────
155
- async evmGetAddress(connectId, _deviceId, params) {
156
- await this._ensureDevicePermission(connectId, _deviceId);
157
- try {
158
- const result = await this.connectorCall(connectId, "evmGetAddress", {
159
- path: params.path,
160
- showOnDevice: params.showOnDevice,
161
- chainId: params.chainId
162
- });
163
- return success({
164
- address: result.address,
165
- path: params.path
166
- });
167
- } catch (err) {
168
- return this.errorToFailure(err);
169
- }
170
- }
171
- async evmGetAddresses(connectId, deviceId, params, onProgress) {
172
- return this.batchCall(
173
- params,
174
- (p) => this.evmGetAddress(connectId, deviceId, p),
175
- onProgress
176
- );
177
- }
178
- async evmGetPublicKey(connectId, _deviceId, params) {
179
- await this._ensureDevicePermission(connectId, _deviceId);
180
- try {
181
- const result = await this.connectorCall(connectId, "evmGetPublicKey", {
182
- path: params.path,
183
- showOnDevice: params.showOnDevice
184
- });
185
- return success({
186
- publicKey: result.publicKey,
187
- path: params.path
188
- });
189
- } catch (err) {
190
- return this.errorToFailure(err);
191
- }
192
- }
193
- async evmSignTransaction(connectId, _deviceId, params) {
194
- await this._ensureDevicePermission(connectId, _deviceId);
195
- try {
196
- const result = await this.connectorCall(connectId, "evmSignTransaction", {
197
- path: params.path,
198
- transaction: {
199
- to: params.to,
200
- value: params.value,
201
- chainId: params.chainId,
202
- nonce: params.nonce,
203
- gasLimit: params.gasLimit,
204
- gasPrice: params.gasPrice,
205
- maxFeePerGas: params.maxFeePerGas,
206
- maxPriorityFeePerGas: params.maxPriorityFeePerGas,
207
- accessList: params.accessList,
208
- data: params.data
209
- }
210
- });
211
- return success({
212
- v: this.ensure0x(result.v),
213
- r: this.padHex64(result.r),
214
- s: this.padHex64(result.s),
215
- serializedTx: result.serializedTx
216
- });
217
- } catch (err) {
218
- return this.errorToFailure(err);
219
- }
220
- }
221
- async evmSignMessage(connectId, _deviceId, params) {
222
- await this._ensureDevicePermission(connectId, _deviceId);
223
- try {
224
- const result = await this.connectorCall(connectId, "evmSignMessage", {
225
- path: params.path,
226
- message: params.message,
227
- hex: params.hex
228
- });
229
- return success({
230
- signature: this.ensure0x(result.signature),
231
- address: result.address
232
- });
233
- } catch (err) {
234
- return this.errorToFailure(err);
235
- }
236
- }
237
- async evmSignTypedData(connectId, _deviceId, params) {
238
- await this._ensureDevicePermission(connectId, _deviceId);
239
- try {
240
- const callParams = {
241
- path: params.path
242
- };
243
- if (params.mode !== "hash") {
244
- callParams["mode"] = params.mode ?? "full";
245
- callParams["data"] = params.data;
246
- callParams["metamaskV4Compat"] = params.metamaskV4Compat ?? true;
247
- } else {
248
- callParams["mode"] = "hash";
249
- callParams["domainSeparatorHash"] = params.domainSeparatorHash;
250
- callParams["messageHash"] = params.messageHash;
251
- }
252
- const result = await this.connectorCall(connectId, "evmSignTypedData", callParams);
253
- return success({
254
- signature: this.ensure0x(result.signature),
255
- address: result.address
256
- });
257
- } catch (err) {
258
- return this.errorToFailure(err);
259
- }
260
- }
261
- // ─── BTC methods ──────────────────────────────────────────
262
- async btcGetAddress(connectId, _deviceId, params) {
263
- await this._ensureDevicePermission(connectId, _deviceId);
264
- try {
265
- const result = await this.connectorCall(connectId, "btcGetAddress", {
266
- path: params.path,
267
- coin: params.coin,
268
- showOnDevice: params.showOnDevice,
269
- scriptType: params.scriptType
270
- });
271
- return success({
272
- address: result.address,
273
- path: params.path
274
- });
275
- } catch (err) {
276
- return this.errorToFailure(err);
277
- }
278
- }
279
- async btcGetAddresses(connectId, deviceId, params, onProgress) {
280
- return this.batchCall(
281
- params,
282
- (p) => this.btcGetAddress(connectId, deviceId, p),
283
- onProgress
284
- );
285
- }
286
- async btcGetPublicKey(connectId, _deviceId, params) {
287
- await this._ensureDevicePermission(connectId, _deviceId);
288
- try {
289
- const result = await this.connectorCall(connectId, "btcGetPublicKey", {
290
- path: params.path,
291
- coin: params.coin,
292
- showOnDevice: params.showOnDevice
293
- });
294
- return success({
295
- xpub: result.xpub,
296
- publicKey: result.publicKey,
297
- fingerprint: result.fingerprint,
298
- chainCode: result.chainCode,
299
- path: params.path,
300
- depth: result.depth
301
- });
302
- } catch (err) {
303
- return this.errorToFailure(err);
304
- }
305
- }
306
- async btcSignTransaction(connectId, _deviceId, params) {
307
- await this._ensureDevicePermission(connectId, _deviceId);
308
- try {
309
- const result = await this.connectorCall(connectId, "btcSignTransaction", {
310
- inputs: params.inputs ?? [],
311
- outputs: params.outputs ?? [],
312
- refTxs: params.refTxs,
313
- coin: params.coin,
314
- locktime: params.locktime,
315
- version: params.version
316
- });
317
- return success({
318
- signatures: result.signatures,
319
- serializedTx: result.serializedTx,
320
- txid: result.txid
321
- });
322
- } catch (err) {
323
- return this.errorToFailure(err);
324
- }
325
- }
326
- async btcSignMessage(connectId, _deviceId, params) {
327
- await this._ensureDevicePermission(connectId, _deviceId);
328
- try {
329
- const result = await this.connectorCall(connectId, "btcSignMessage", {
330
- path: params.path,
331
- message: params.message,
332
- coin: params.coin
333
- });
334
- return success({
335
- signature: result.signature,
336
- address: result.address
337
- });
338
- } catch (err) {
339
- return this.errorToFailure(err);
340
- }
341
- }
342
- async btcGetMasterFingerprint(connectId, _deviceId) {
343
- await this._ensureDevicePermission(connectId, _deviceId);
344
- try {
345
- const result = await this.connectorCall(connectId, "btcGetPublicKey", {
346
- path: "m/0'"
347
- });
348
- const fp = result.fingerprint >>> 0;
349
- const hex = fp.toString(16).padStart(8, "0");
350
- return success({ masterFingerprint: hex });
351
- } catch (err) {
352
- return this.errorToFailure(err);
353
- }
354
- }
355
- // ─── Solana methods ───────────────────────────────────────
356
- async solGetAddress(connectId, _deviceId, params) {
357
- await this._ensureDevicePermission(connectId, _deviceId);
358
- try {
359
- const result = await this.connectorCall(connectId, "solGetAddress", {
360
- path: params.path,
361
- showOnDevice: params.showOnDevice
362
- });
363
- return success({
364
- address: result.address,
365
- path: params.path
366
- });
367
- } catch (err) {
368
- return this.errorToFailure(err);
369
- }
370
- }
371
- async solGetAddresses(connectId, deviceId, params, onProgress) {
372
- return this.batchCall(
373
- params,
374
- (p) => this.solGetAddress(connectId, deviceId, p),
375
- onProgress
376
- );
377
- }
378
- async solGetPublicKey(connectId, _deviceId, params) {
379
- await this._ensureDevicePermission(connectId, _deviceId);
380
- try {
381
- const result = await this.connectorCall(connectId, "solGetAddress", {
382
- path: params.path,
383
- showOnDevice: params.showOnDevice
384
- });
385
- return success({
386
- publicKey: result.address,
387
- path: params.path
388
- });
389
- } catch (err) {
390
- return this.errorToFailure(err);
391
- }
392
- }
393
- async solSignTransaction(connectId, _deviceId, params) {
394
- await this._ensureDevicePermission(connectId, _deviceId);
395
- try {
396
- const result = await this.connectorCall(connectId, "solSignTransaction", {
397
- path: params.path,
398
- serializedTx: params.serializedTx,
399
- additionalInfo: params.additionalInfo
400
- });
401
- return success({
402
- signature: result.signature
403
- });
404
- } catch (err) {
405
- return this.errorToFailure(err);
406
- }
407
- }
408
- async solSignMessage(_connectId, _deviceId, _params) {
409
- return failure(
410
- HardwareErrorCode.MethodNotSupported,
411
- "Solana signMessage is not supported by Trezor Connect"
412
- );
413
- }
414
- // ─── TRON methods ─────────────────────────────────────────
415
- // TRON is not supported by Trezor. All methods return MethodNotSupported.
416
- async tronGetAddress(_connectId, _deviceId, _params) {
417
- return failure(
418
- HardwareErrorCode.MethodNotSupported,
419
- "TRON is not supported by Trezor"
420
- );
421
- }
422
- async tronGetAddresses(_connectId, _deviceId, _params, _onProgress) {
423
- return failure(
424
- HardwareErrorCode.MethodNotSupported,
425
- "TRON is not supported by Trezor"
426
- );
427
- }
428
- async tronSignTransaction(_connectId, _deviceId, _params) {
429
- return failure(
430
- HardwareErrorCode.MethodNotSupported,
431
- "TRON is not supported by Trezor"
432
- );
433
- }
434
- async tronSignMessage(_connectId, _deviceId, _params) {
435
- return failure(
436
- HardwareErrorCode.MethodNotSupported,
437
- "TRON is not supported by Trezor"
438
- );
439
- }
440
- // ─── Private helpers ──────────────────────────────────────
441
- /**
442
- * Call the connector with session resolution.
443
- * Looks up sessionId from connectId, falls back to connectId itself.
444
- */
445
- async connectorCall(connectId, method, params) {
446
- const sessionId = this._sessions.get(connectId) ?? connectId;
447
- return this.connector.call(sessionId, method, params);
448
- }
449
- /**
450
- * Ensure device permission before proceeding.
451
- * - No connectId (searchDevices): check environment-level permission
452
- * - With connectId (business methods): check device-level permission
453
- * If not granted, calls onDevicePermission so the consumer can request access.
454
- */
455
- async _ensureDevicePermission(connectId, deviceId) {
456
- const transportType = "usb";
457
- let granted = false;
458
- let context;
459
- if (this._uiHandler?.checkDevicePermission) {
460
- try {
461
- const result = await this._uiHandler.checkDevicePermission({ transportType, connectId, deviceId });
462
- granted = result.granted;
463
- context = result.context;
464
- } catch {
465
- granted = false;
466
- }
467
- }
468
- if (!granted) {
469
- try {
470
- await this._uiHandler?.onDevicePermission?.({ transportType, context });
471
- } catch {
472
- }
473
- }
474
- }
475
- /**
476
- * Convert a thrown error to a Response failure.
477
- * Parses TrezorConnect error strings to map to HardwareErrorCode values.
478
- */
479
- errorToFailure(err) {
480
- const message = err instanceof Error ? err.message : String(err);
481
- const code = this.parseErrorCode(message);
482
- const enriched = this.enrichErrorMessage(code, message);
483
- return failure(code, enriched);
484
- }
485
- /**
486
- * Parse TrezorConnect error codes from error message strings.
487
- * The connector throws errors with messages like "Trezor ethereumGetAddress failed: <error>".
488
- * We also check for embedded code patterns.
489
- */
490
- parseErrorCode(message) {
491
- if (message.includes("Failure_ActionCancelled") || message.includes("Failure_Cancel")) {
492
- return HardwareErrorCode.UserRejected;
493
- }
494
- if (message.includes("Failure_PinInvalid") || message.includes("Failure_PinMismatch")) {
495
- return HardwareErrorCode.PinInvalid;
496
- }
497
- if (message.includes("Failure_PinCancelled")) {
498
- return HardwareErrorCode.PinCancelled;
499
- }
500
- if (message.includes("Failure_PassphraseRejected")) {
501
- return HardwareErrorCode.PassphraseRejected;
502
- }
503
- if (message.includes("Device_UsedElsewhere")) {
504
- return HardwareErrorCode.DeviceBusy;
505
- }
506
- if (message.includes("Device_NotFound")) {
507
- return HardwareErrorCode.DeviceNotFound;
508
- }
509
- if (message.includes("Device_InvalidState")) {
510
- return HardwareErrorCode.DeviceNotInitialized;
511
- }
512
- if (message.includes("Transport_Missing")) {
513
- return HardwareErrorCode.TransportNotAvailable;
514
- }
515
- if (message.includes("Transport_DeviceDisconnected")) {
516
- return HardwareErrorCode.DeviceDisconnected;
517
- }
518
- if (message.includes("Failure_FirmwareError")) {
519
- return HardwareErrorCode.FirmwareTooOld;
520
- }
521
- if (message.includes("Method_InvalidParameter") || message.includes("Method_InvalidParams")) {
522
- return HardwareErrorCode.InvalidParams;
523
- }
524
- if (message.includes("Method_NotAllowed")) {
525
- return HardwareErrorCode.MethodNotSupported;
526
- }
527
- return HardwareErrorCode.UnknownError;
528
- }
529
- /**
530
- * Enrich error messages with actionable recovery info for the caller.
531
- */
532
- enrichErrorMessage(code, originalMessage) {
533
- switch (code) {
534
- case HardwareErrorCode.PinInvalid:
535
- return `${originalMessage}. Please re-enter your PIN.`;
536
- case HardwareErrorCode.PinCancelled:
537
- return `${originalMessage}. PIN entry was cancelled.`;
538
- case HardwareErrorCode.DeviceBusy:
539
- return `${originalMessage}. The device is in use by another application. Close other wallet apps and try again.`;
540
- case HardwareErrorCode.DeviceDisconnected:
541
- return `${originalMessage}. Please reconnect the device and try again.`;
542
- case HardwareErrorCode.TransportNotAvailable:
543
- return `${originalMessage}. Ensure Trezor Bridge is installed and running, or connect via USB.`;
544
- case HardwareErrorCode.FirmwareTooOld:
545
- return `${originalMessage}. Please update your Trezor firmware via Trezor Suite.`;
546
- case HardwareErrorCode.DeviceNotInitialized:
547
- return `${originalMessage}. The device may need to be set up first via Trezor Suite.`;
548
- default:
549
- return originalMessage;
550
- }
551
- }
552
- /**
553
- * Generic batch call with progress reporting.
554
- * If any single call fails, returns the failure immediately.
555
- */
556
- async batchCall(params, callFn, onProgress) {
557
- const results = [];
558
- for (let i = 0; i < params.length; i++) {
559
- const result = await callFn(params[i]);
560
- if (!result.success) {
561
- return result;
562
- }
563
- results.push(result.payload);
564
- onProgress?.({ index: i, total: params.length });
565
- }
566
- return success(results);
567
- }
568
- // ─── Hex formatting ──────────────────────────────────────
569
- /** Ensure a hex string has the `0x` prefix. */
570
- ensure0x(hex) {
571
- return hex.startsWith("0x") ? hex : `0x${hex}`;
572
- }
573
- /** Ensure a hex string is `0x`-prefixed and zero-padded to 64 hex chars (32 bytes). */
574
- padHex64(hex) {
575
- const stripped = hex.startsWith("0x") ? hex.slice(2) : hex;
576
- return `0x${stripped.padStart(64, "0")}`;
577
- }
578
- registerEventListeners() {
579
- this.connector.on("device-connect", this.deviceConnectHandler);
580
- this.connector.on("device-disconnect", this.deviceDisconnectHandler);
581
- this.connector.on("ui-request", this.uiRequestHandler);
582
- this.connector.on("ui-event", this.uiEventHandler);
583
- }
584
- unregisterEventListeners() {
585
- this.connector.off("device-connect", this.deviceConnectHandler);
586
- this.connector.off("device-disconnect", this.deviceDisconnectHandler);
587
- this.connector.off("ui-request", this.uiRequestHandler);
588
- this.connector.off("ui-event", this.uiEventHandler);
589
- }
590
- handleUiEvent(event) {
591
- if (!event.type) return;
592
- const payload = event.payload;
593
- const devicePayload = payload?.["device"] ?? payload;
594
- const deviceInfo = devicePayload ? this.extractDeviceInfoFromPayload(devicePayload) : this.unknownDevice();
595
- switch (event.type) {
596
- case "ui-request_pin":
597
- this.emitter.emit(UI_REQUEST.REQUEST_PIN, {
598
- type: UI_REQUEST.REQUEST_PIN,
599
- payload: { device: deviceInfo }
600
- });
601
- if (this._uiHandler?.onPinRequest) {
602
- this._uiHandler.onPinRequest(deviceInfo).then((pin) => {
603
- this.connector.uiResponse({
604
- type: "receive-pin",
605
- payload: pin
606
- });
607
- }).catch(() => {
608
- });
609
- }
610
- break;
611
- case "ui-request_passphrase":
612
- this.emitter.emit(UI_REQUEST.REQUEST_PASSPHRASE, {
613
- type: UI_REQUEST.REQUEST_PASSPHRASE,
614
- payload: { device: deviceInfo }
615
- });
616
- if (this._uiHandler?.onPassphraseRequest) {
617
- this._uiHandler.onPassphraseRequest(deviceInfo).then((result) => {
618
- const response = typeof result === "string" ? { passphrase: result, onDevice: false } : result ?? { passphrase: "", onDevice: false };
619
- if (response.onDevice) {
620
- this.connector.uiResponse({
621
- type: "receive-passphrase",
622
- payload: {
623
- value: "",
624
- passphraseOnDevice: true,
625
- save: false
626
- }
627
- });
628
- } else {
629
- this.connector.uiResponse({
630
- type: "receive-passphrase",
631
- payload: {
632
- value: response.passphrase,
633
- passphraseOnDevice: false,
634
- save: false
635
- }
636
- });
637
- }
638
- }).catch(() => {
639
- });
640
- }
641
- break;
642
- case "ui-request_confirmation":
643
- this.emitter.emit(UI_REQUEST.REQUEST_BUTTON, {
644
- type: UI_REQUEST.REQUEST_BUTTON,
645
- payload: { device: deviceInfo }
646
- });
647
- break;
648
- }
649
- }
650
- connectorDeviceToDeviceInfo(device) {
651
- return {
652
- vendor: "trezor",
653
- model: device.model ?? "unknown",
654
- firmwareVersion: "",
655
- deviceId: device.deviceId,
656
- connectId: device.connectId,
657
- label: device.name,
658
- connectionType: "usb"
659
- };
660
- }
661
- extractDeviceInfoFromPayload(payload) {
662
- const features = payload["features"];
663
- return {
664
- vendor: "trezor",
665
- model: features?.["model"] ?? payload["model"] ?? "unknown",
666
- firmwareVersion: features ? `${features["major_version"] ?? 0}.${features["minor_version"] ?? 0}.${features["patch_version"] ?? 0}` : "",
667
- deviceId: features?.["device_id"] ?? payload["id"] ?? "",
668
- connectId: payload["path"] ?? "",
669
- label: features?.["label"] ?? payload["label"],
670
- connectionType: "usb"
671
- };
672
- }
673
- unknownDevice() {
674
- return {
675
- vendor: "trezor",
676
- model: "unknown",
677
- firmwareVersion: "",
678
- deviceId: "",
679
- connectId: "",
680
- connectionType: "usb"
681
- };
682
- }
683
- };
684
-
685
- // src/TrezorProxyClient.ts
686
- import { AbstractProxyClient } from "@bytezhang/hardware-transport-core";
687
- var TrezorProxyClient = class extends AbstractProxyClient {
688
- // ─── TrezorConnect method stubs — all delegate to call() ────
689
- ethereumGetAddress(params) {
690
- return this.call("ethereumGetAddress", params);
691
- }
692
- ethereumGetPublicKey(params) {
693
- return this.call("ethereumGetPublicKey", params);
694
- }
695
- ethereumSignTransaction(params) {
696
- return this.call("ethereumSignTransaction", params);
697
- }
698
- ethereumSignMessage(params) {
699
- return this.call("ethereumSignMessage", params);
700
- }
701
- ethereumSignTypedData(params) {
702
- return this.call("ethereumSignTypedData", params);
703
- }
704
- getAddress(params) {
705
- return this.call("getAddress", params);
706
- }
707
- getPublicKey(params) {
708
- return this.call("getPublicKey", params);
709
- }
710
- signTransaction(params) {
711
- return this.call("signTransaction", params);
712
- }
713
- signMessage(params) {
714
- return this.call("signMessage", params);
715
- }
716
- solanaGetAddress(params) {
717
- return this.call("solanaGetAddress", params);
718
- }
719
- solanaSignTransaction(params) {
720
- return this.call("solanaSignTransaction", params);
1
+ // src/index.ts
2
+ var VERSION = "0.0.1";
3
+ var TrezorService = class {
4
+ constructor() {
5
+ throw new Error("TrezorService not yet implemented");
721
6
  }
722
7
  };
723
8
  export {
724
- TrezorAdapter,
725
- TrezorProxyClient
9
+ TrezorService,
10
+ VERSION
726
11
  };
727
12
  //# sourceMappingURL=index.mjs.map