@sidhujag/sysweb3-keyring 2.1.6 → 2.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/cjs/hardware-transaction-authority.js +15 -11
- package/cjs/hardware-transaction-authority.js.map +1 -1
- package/cjs/hardware-wallet-manager.js +74 -119
- package/cjs/hardware-wallet-manager.js.map +1 -1
- package/cjs/hardware-wallet-types.js +16 -0
- package/cjs/hardware-wallet-types.js.map +1 -0
- package/cjs/host-keyring.js +32 -0
- package/cjs/host-keyring.js.map +1 -0
- package/cjs/index.js +1 -0
- package/cjs/index.js.map +1 -1
- package/cjs/keyring-core.js +96 -61
- package/cjs/keyring-core.js.map +1 -1
- package/cjs/keyring-manager.js +15 -16
- package/cjs/keyring-manager.js.map +1 -1
- package/cjs/ledger/host-types.js.map +1 -1
- package/cjs/ledger/index.js +24 -4
- package/cjs/ledger/index.js.map +1 -1
- package/cjs/ledger-hardware.js +15 -0
- package/cjs/ledger-hardware.js.map +1 -0
- package/cjs/software.js +6 -25
- package/cjs/software.js.map +1 -1
- package/cjs/transactions/ethereum.js +321 -269
- package/cjs/transactions/ethereum.js.map +1 -1
- package/cjs/transactions/evm-envelope.js +186 -0
- package/cjs/transactions/evm-envelope.js.map +1 -0
- package/cjs/transactions/evm-submission.js +32 -4
- package/cjs/transactions/evm-submission.js.map +1 -1
- package/cjs/transactions/ledger-signing.js +44 -0
- package/cjs/transactions/ledger-signing.js.map +1 -0
- package/cjs/transactions/prepared-evm.js +44 -124
- package/cjs/transactions/prepared-evm.js.map +1 -1
- package/cjs/trezor/connect.js +238 -243
- package/cjs/trezor/connect.js.map +1 -1
- package/cjs/trezor/host-types.js +19 -0
- package/cjs/trezor/host-types.js.map +1 -0
- package/cjs/trezor/index.js +75 -23
- package/cjs/trezor/index.js.map +1 -1
- package/cjs/trezor/webextension-host.js +118 -0
- package/cjs/trezor/webextension-host.js.map +1 -0
- package/cjs/trezor-hardware.js +16 -0
- package/cjs/trezor-hardware.js.map +1 -0
- package/cjs/types.js.map +1 -1
- package/esm/hardware-transaction-authority.js +14 -11
- package/esm/hardware-transaction-authority.js.map +1 -1
- package/esm/hardware-wallet-manager.js +20 -32
- package/esm/hardware-wallet-manager.js.map +1 -1
- package/esm/hardware-wallet-types.js +13 -0
- package/esm/hardware-wallet-types.js.map +1 -0
- package/esm/keyring-core.js +98 -63
- package/esm/keyring-core.js.map +1 -1
- package/esm/ledger/dmk-host.js +2 -0
- package/esm/ledger/dmk-host.js.map +1 -1
- package/esm/ledger/dmk-session.js +73 -8
- package/esm/ledger/dmk-session.js.map +1 -1
- package/esm/ledger/host-types.js.map +1 -1
- package/esm/ledger/index.js +22 -2
- package/esm/ledger/index.js.map +1 -1
- package/esm/transactions/ethereum.js +322 -270
- package/esm/transactions/ethereum.js.map +1 -1
- package/esm/transactions/evm-envelope.js +179 -0
- package/esm/transactions/evm-envelope.js.map +1 -0
- package/esm/transactions/evm-submission.js +32 -4
- package/esm/transactions/evm-submission.js.map +1 -1
- package/esm/transactions/ledger-signing.js +41 -0
- package/esm/transactions/ledger-signing.js.map +1 -0
- package/esm/transactions/prepared-evm.js +43 -124
- package/esm/transactions/prepared-evm.js.map +1 -1
- package/esm/trezor/connect.js +236 -209
- package/esm/trezor/connect.js.map +1 -1
- package/esm/trezor/host-types.js +16 -0
- package/esm/trezor/host-types.js.map +1 -0
- package/esm/trezor/index.js +74 -22
- package/esm/trezor/index.js.map +1 -1
- package/esm/types.js.map +1 -1
- package/package.json +61 -1
- package/types/hardware-transaction-authority.d.ts +1 -0
- package/types/hardware-wallet-manager.d.ts +6 -22
- package/types/hardware-wallet-types.d.ts +21 -0
- package/types/host-keyring.d.ts +16 -0
- package/types/index.d.ts +1 -0
- package/types/keyring-core.d.ts +12 -4
- package/types/keyring-manager.d.ts +5 -3
- package/types/ledger/dmk-host.d.ts +2 -0
- package/types/ledger/dmk-session.d.ts +9 -0
- package/types/ledger/host-types.d.ts +2 -0
- package/types/ledger/index.d.ts +3 -1
- package/types/ledger-hardware.d.ts +5 -0
- package/types/software.d.ts +4 -17
- package/types/transactions/ethereum.d.ts +11 -1
- package/types/transactions/evm-envelope.d.ts +64 -0
- package/types/transactions/evm-submission.d.ts +7 -2
- package/types/transactions/ledger-signing.d.ts +13 -0
- package/types/transactions/prepared-evm.d.ts +14 -23
- package/types/trezor/connect.d.ts +11 -9
- package/types/trezor/host-types.d.ts +25 -0
- package/types/trezor/index.d.ts +7 -7
- package/types/trezor/webextension-host.d.ts +7 -0
- package/types/trezor-hardware.d.ts +6 -0
- package/types/types.d.ts +17 -5
package/esm/trezor/connect.js
CHANGED
|
@@ -1,223 +1,250 @@
|
|
|
1
1
|
import { captureHardwareTransactionAuthority } from '../hardware-transaction-authority';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let
|
|
18
|
-
let
|
|
19
|
-
let
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
2
|
+
import { TREZOR_METHODS } from './host-types';
|
|
3
|
+
const methods = TREZOR_METHODS.filter((method) => method !== 'ethereumSignTransaction' && method !== 'signTransaction');
|
|
4
|
+
const hostOwners = new WeakMap();
|
|
5
|
+
export function createTrezorConnection(host) {
|
|
6
|
+
if (!host ||
|
|
7
|
+
typeof host.init !== 'function' ||
|
|
8
|
+
typeof host.dispose !== 'function' ||
|
|
9
|
+
TREZOR_METHODS.some((method) => typeof host[method] !== 'function'))
|
|
10
|
+
throw new TypeError('Trezor requires explicit host capabilities');
|
|
11
|
+
const owner = {};
|
|
12
|
+
const releaseHost = () => {
|
|
13
|
+
if (hostOwners.get(host) === owner)
|
|
14
|
+
hostOwners.delete(host);
|
|
15
|
+
};
|
|
16
|
+
const listeners = new Set();
|
|
17
|
+
let clientPromise;
|
|
18
|
+
let generation = 0;
|
|
19
|
+
let initialized = false;
|
|
20
|
+
let initializing = false;
|
|
21
|
+
let cleanupPromise = Promise.resolve();
|
|
22
|
+
let cleanupPending = false;
|
|
23
|
+
const inFlight = new Set();
|
|
24
|
+
const pending = new Set();
|
|
25
|
+
const interrupted = () => Object.assign(new Error('Trezor operation cancelled'), {
|
|
26
|
+
code: 'Method_Interrupted',
|
|
27
|
+
});
|
|
28
|
+
const invalidate = () => {
|
|
29
|
+
const invalidated = ++generation;
|
|
30
|
+
initialized = false;
|
|
31
|
+
const error = interrupted();
|
|
32
|
+
for (const reject of pending)
|
|
33
|
+
reject(error);
|
|
34
|
+
pending.clear();
|
|
35
|
+
emit({ type: 'disconnected' });
|
|
36
|
+
return invalidated;
|
|
37
|
+
};
|
|
38
|
+
const subscribeTrezorEvents = (listener) => {
|
|
39
|
+
listeners.add(listener);
|
|
40
|
+
return () => listeners.delete(listener);
|
|
41
|
+
};
|
|
42
|
+
const emit = (event) => {
|
|
43
|
+
for (const listener of listeners) {
|
|
44
|
+
try {
|
|
45
|
+
listener(event);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// Status observers must not turn a completed device call into a retry.
|
|
49
|
+
}
|
|
46
50
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
return clientPromise;
|
|
74
|
-
};
|
|
75
|
-
/** Keep the SDK's established failure payload while preserving Connect 10 codes. */
|
|
76
|
-
const normalize = (response, method) => {
|
|
77
|
-
if (response?.success === false) {
|
|
78
|
-
const error = response.error;
|
|
79
|
-
const code = typeof error?.code === 'string' ? error.code : undefined;
|
|
80
|
-
if (code === 'Device_Disconnected' ||
|
|
81
|
-
code === 'Device_NotFound' ||
|
|
82
|
-
code === 'Desktop_ConnectionMissing' ||
|
|
83
|
-
code === 'Transport_Missing') {
|
|
84
|
-
invalidate();
|
|
51
|
+
};
|
|
52
|
+
const getClient = () => {
|
|
53
|
+
clientPromise ?? (clientPromise = Promise.resolve(host));
|
|
54
|
+
return clientPromise;
|
|
55
|
+
};
|
|
56
|
+
/** Keep the SDK's established failure payload while preserving Connect 10 codes. */
|
|
57
|
+
const normalize = (response, method) => {
|
|
58
|
+
if (response?.success === false) {
|
|
59
|
+
const error = response.error;
|
|
60
|
+
const code = typeof error?.code === 'string' ? error.code : undefined;
|
|
61
|
+
if (code === 'Device_Disconnected' ||
|
|
62
|
+
code === 'Device_NotFound' ||
|
|
63
|
+
code === 'Desktop_ConnectionMissing' ||
|
|
64
|
+
code === 'Transport_Missing') {
|
|
65
|
+
invalidate();
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
...response,
|
|
69
|
+
payload: {
|
|
70
|
+
error: typeof error?.message === 'string'
|
|
71
|
+
? error.message
|
|
72
|
+
: 'Trezor request failed',
|
|
73
|
+
code,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
85
76
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
? error.message
|
|
91
|
-
: 'Trezor request failed',
|
|
92
|
-
code,
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
const model = response?.device?.features?.model ??
|
|
97
|
-
(method === 'getFeatures' ? response?.payload?.model : undefined);
|
|
98
|
-
if (response?.success === true && typeof model === 'string') {
|
|
99
|
-
emit({ type: 'model', model });
|
|
100
|
-
}
|
|
101
|
-
return response;
|
|
102
|
-
};
|
|
103
|
-
const withClient = async (operation, requireInitialized = true) => {
|
|
104
|
-
const captured = generation;
|
|
105
|
-
const assertCurrent = () => {
|
|
106
|
-
if (captured !== generation)
|
|
107
|
-
throw interrupted();
|
|
108
|
-
if (requireInitialized && !initialized) {
|
|
109
|
-
throw Object.assign(new Error('TrezorConnect not initialized'), {
|
|
110
|
-
code: 'Init_NotInitialized',
|
|
111
|
-
});
|
|
77
|
+
const model = response?.device?.features?.model ??
|
|
78
|
+
(method === 'getFeatures' ? response?.payload?.model : undefined);
|
|
79
|
+
if (response?.success === true && typeof model === 'string') {
|
|
80
|
+
emit({ type: 'model', model });
|
|
112
81
|
}
|
|
82
|
+
return response;
|
|
113
83
|
};
|
|
114
|
-
|
|
115
|
-
let rejectPending;
|
|
116
|
-
const cancelled = new Promise((_resolve, reject) => {
|
|
117
|
-
rejectPending = reject;
|
|
118
|
-
});
|
|
119
|
-
pending.add(rejectPending);
|
|
120
|
-
try {
|
|
121
|
-
const result = await Promise.race([
|
|
122
|
-
(async () => {
|
|
123
|
-
await cleanupPromise;
|
|
124
|
-
assertCurrent();
|
|
125
|
-
const client = await getClient();
|
|
126
|
-
assertCurrent();
|
|
127
|
-
const request = Promise.resolve(operation(client));
|
|
128
|
-
inFlight.add(request);
|
|
129
|
-
try {
|
|
130
|
-
return await request;
|
|
131
|
-
}
|
|
132
|
-
finally {
|
|
133
|
-
inFlight.delete(request);
|
|
134
|
-
}
|
|
135
|
-
})(),
|
|
136
|
-
cancelled,
|
|
137
|
-
]);
|
|
138
|
-
// A late response must not restore a model/status or return a signature.
|
|
139
|
-
assertCurrent();
|
|
140
|
-
return result;
|
|
141
|
-
}
|
|
142
|
-
finally {
|
|
143
|
-
pending.delete(rejectPending);
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
const calls = Object.fromEntries(methods.map((method) => [
|
|
147
|
-
method,
|
|
148
|
-
async (...args) => {
|
|
84
|
+
const withClient = async (operation, requireInitialized = true) => {
|
|
149
85
|
const captured = generation;
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
86
|
+
const assertCurrent = () => {
|
|
87
|
+
if (captured !== generation)
|
|
88
|
+
throw interrupted();
|
|
89
|
+
if (requireInitialized && !initialized) {
|
|
90
|
+
throw Object.assign(new Error('TrezorConnect not initialized'), {
|
|
91
|
+
code: 'Init_NotInitialized',
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (hostOwners.get(host) !== owner)
|
|
95
|
+
throw interrupted();
|
|
96
|
+
};
|
|
160
97
|
assertCurrent();
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
98
|
+
let rejectPending;
|
|
99
|
+
const cancelled = new Promise((_resolve, reject) => {
|
|
100
|
+
rejectPending = reject;
|
|
101
|
+
});
|
|
102
|
+
pending.add(rejectPending);
|
|
103
|
+
try {
|
|
104
|
+
const result = await Promise.race([
|
|
105
|
+
(async () => {
|
|
106
|
+
await cleanupPromise;
|
|
107
|
+
assertCurrent();
|
|
108
|
+
const client = await getClient();
|
|
109
|
+
assertCurrent();
|
|
110
|
+
const request = Promise.resolve(operation(client, assertCurrent));
|
|
111
|
+
inFlight.add(request);
|
|
112
|
+
try {
|
|
113
|
+
return await request;
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
inFlight.delete(request);
|
|
117
|
+
}
|
|
118
|
+
})(),
|
|
119
|
+
cancelled,
|
|
120
|
+
]);
|
|
121
|
+
// A late response must not restore a model/status or return a signature.
|
|
122
|
+
assertCurrent();
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
finally {
|
|
126
|
+
pending.delete(rejectPending);
|
|
181
127
|
}
|
|
182
|
-
|
|
128
|
+
};
|
|
129
|
+
const calls = Object.fromEntries(methods.map((method) => [
|
|
130
|
+
method,
|
|
131
|
+
async (...args) => {
|
|
132
|
+
const captured = generation;
|
|
133
|
+
const response = await withClient((client, assertCurrent) => client[method](assertCurrent, ...args));
|
|
134
|
+
if (captured !== generation)
|
|
135
|
+
throw interrupted();
|
|
136
|
+
const normalized = normalize(response, method);
|
|
137
|
+
if (normalized?.success === true && captured !== generation)
|
|
138
|
+
throw interrupted();
|
|
139
|
+
return normalized;
|
|
140
|
+
},
|
|
141
|
+
]));
|
|
142
|
+
async function signOwned(method, authority, call) {
|
|
143
|
+
const { assertCurrent } = captureHardwareTransactionAuthority(authority);
|
|
183
144
|
const captured = generation;
|
|
184
|
-
await withClient((client) =>
|
|
145
|
+
const response = await withClient((client, assertConnectionCurrent) => {
|
|
146
|
+
assertCurrent();
|
|
147
|
+
return call(client, () => {
|
|
148
|
+
assertConnectionCurrent();
|
|
149
|
+
assertCurrent();
|
|
150
|
+
assertConnectionCurrent();
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
assertCurrent();
|
|
185
154
|
if (captured !== generation)
|
|
186
155
|
throw interrupted();
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
invalidate();
|
|
193
|
-
if (cleanupPending) {
|
|
194
|
-
return inFlight.size ? Promise.resolve() : cleanupPromise;
|
|
156
|
+
const normalized = normalize(response, method);
|
|
157
|
+
if (normalized?.success === true) {
|
|
158
|
+
assertCurrent();
|
|
159
|
+
if (captured !== generation)
|
|
160
|
+
throw interrupted();
|
|
195
161
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
.
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
162
|
+
return normalized;
|
|
163
|
+
}
|
|
164
|
+
const TrezorConnect = {
|
|
165
|
+
...calls,
|
|
166
|
+
ethereumSignTransactionOwned(request, authority) {
|
|
167
|
+
return signOwned('ethereumSignTransaction', authority, (client, assertCurrent) => client.ethereumSignTransaction(assertCurrent, request));
|
|
168
|
+
},
|
|
169
|
+
signTransactionOwned(request, authority) {
|
|
170
|
+
return signOwned('signTransaction', authority, (client, assertCurrent) => client.signTransaction(assertCurrent, request));
|
|
171
|
+
},
|
|
172
|
+
async init() {
|
|
173
|
+
if (cleanupPending || initializing) {
|
|
174
|
+
throw Object.assign(new Error('Previous Trezor request is still pending'), {
|
|
175
|
+
code: 'HARDWARE_SIGNER_BUSY',
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
const activeOwner = hostOwners.get(host);
|
|
179
|
+
if (activeOwner && activeOwner !== owner)
|
|
180
|
+
throw Object.assign(new Error('Trezor host is owned by another connection'), {
|
|
181
|
+
code: 'HARDWARE_SIGNER_BUSY',
|
|
182
|
+
});
|
|
183
|
+
hostOwners.set(host, owner);
|
|
184
|
+
initializing = true;
|
|
185
|
+
const captured = invalidate();
|
|
186
|
+
try {
|
|
187
|
+
if (captured !== generation)
|
|
188
|
+
throw interrupted();
|
|
189
|
+
await withClient((client, assertCurrent) => client.init(assertCurrent), false);
|
|
190
|
+
if (captured !== generation)
|
|
191
|
+
throw interrupted();
|
|
192
|
+
initialized = true;
|
|
193
|
+
}
|
|
194
|
+
finally {
|
|
195
|
+
initializing = false;
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
dispose() {
|
|
199
|
+
if (cleanupPending) {
|
|
200
|
+
return inFlight.size ? Promise.resolve() : cleanupPromise;
|
|
201
|
+
}
|
|
202
|
+
const loaded = clientPromise;
|
|
203
|
+
// Reserve cleanup before notifying observers, which may reenter init.
|
|
204
|
+
cleanupPending = true;
|
|
205
|
+
if (!loaded) {
|
|
206
|
+
releaseHost();
|
|
207
|
+
invalidate();
|
|
208
|
+
cleanupPending = false;
|
|
209
|
+
return Promise.resolve();
|
|
210
|
+
}
|
|
211
|
+
const outstanding = [...inFlight];
|
|
212
|
+
cleanupPromise = cleanupPromise
|
|
213
|
+
.catch(() => undefined)
|
|
214
|
+
.then(async () => {
|
|
215
|
+
const client = await loaded;
|
|
216
|
+
if (hostOwners.get(host) !== owner)
|
|
217
|
+
return;
|
|
218
|
+
await client.dispose(outstanding);
|
|
219
|
+
releaseHost();
|
|
220
|
+
})
|
|
221
|
+
.finally(() => {
|
|
222
|
+
cleanupPending = false;
|
|
223
|
+
});
|
|
224
|
+
// Deferred cleanup may outlive the caller; preserve its failure for future
|
|
225
|
+
// init while preventing an unhandled rejection when the host is locking.
|
|
226
|
+
void cleanupPromise.catch(() => undefined);
|
|
227
|
+
// Suite Web's upstream dispose is a no-op; local invalidation is required.
|
|
228
|
+
invalidate();
|
|
229
|
+
return outstanding.length ? Promise.resolve() : cleanupPromise;
|
|
230
|
+
},
|
|
231
|
+
async retire() {
|
|
232
|
+
const disposal = TrezorConnect.dispose();
|
|
233
|
+
const captured = generation;
|
|
234
|
+
await (cleanupPending ? cleanupPromise : disposal);
|
|
235
|
+
const assertRetired = () => {
|
|
236
|
+
if (captured !== generation ||
|
|
237
|
+
initialized ||
|
|
238
|
+
initializing ||
|
|
239
|
+
cleanupPending ||
|
|
240
|
+
hostOwners.has(host))
|
|
241
|
+
throw interrupted();
|
|
242
|
+
};
|
|
243
|
+
assertRetired();
|
|
244
|
+
return assertRetired;
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
return { ...TrezorConnect, subscribe: subscribeTrezorEvents };
|
|
248
|
+
}
|
|
221
249
|
export const trezorResponseError = (response, prefix = '') => Object.assign(new Error(prefix + (response.payload?.error || 'Trezor request failed')), { code: response.payload?.code });
|
|
222
|
-
export default TrezorConnect;
|
|
223
250
|
//# sourceMappingURL=connect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../../src/trezor/connect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mCAAmC,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../../src/trezor/connect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mCAAmC,EAAE,MAAM,mCAAmC,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAQ9C,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,CACnC,CAAC,MAAM,EAA6B,EAAE,CACpC,MAAM,KAAK,yBAAyB,IAAI,MAAM,KAAK,iBAAiB,CACvE,CAAC;AAkCF,MAAM,UAAU,GAAG,IAAI,OAAO,EAAsB,CAAC;AAErD,MAAM,UAAU,sBAAsB,CAAC,IAAgB;IACrD,IACE,CAAC,IAAI;QACL,OAAO,IAAI,CAAC,IAAI,KAAK,UAAU;QAC/B,OAAO,IAAI,CAAC,OAAO,KAAK,UAAU;QAClC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,UAAU,CAAC;QAEnE,MAAM,IAAI,SAAS,CAAC,4CAA4C,CAAC,CAAC;IACpE,MAAM,KAAK,GAA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,CAAC;IAEF,OAAO,EAAE,GAAG,aAAa,EAAE,SAAS,EAAE,qBAAqB,EAAE,CAAC;AAChE,CAAC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,QAAyD,EACzD,MAAM,GAAG,EAAE,EACJ,EAAE,CACT,MAAM,CAAC,MAAM,CACX,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,IAAI,uBAAuB,CAAC,CAAC,EACxE,EAAE,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,EAAE,CACjC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const TREZOR_METHODS = [
|
|
2
|
+
'getFeatures',
|
|
3
|
+
'getAccountInfo',
|
|
4
|
+
'ethereumGetAddress',
|
|
5
|
+
'ethereumGetPublicKey',
|
|
6
|
+
'getPublicKey',
|
|
7
|
+
'getAddress',
|
|
8
|
+
'signMessage',
|
|
9
|
+
'ethereumSignMessage',
|
|
10
|
+
'ethereumSignTypedData',
|
|
11
|
+
'verifyMessage',
|
|
12
|
+
'ethereumVerifyMessage',
|
|
13
|
+
'ethereumSignTransaction',
|
|
14
|
+
'signTransaction',
|
|
15
|
+
];
|
|
16
|
+
//# sourceMappingURL=host-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-types.js","sourceRoot":"","sources":["../../../src/trezor/host-types.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,aAAa;IACb,gBAAgB;IAChB,oBAAoB;IACpB,sBAAsB;IACtB,cAAc;IACd,YAAY;IACZ,aAAa;IACb,qBAAqB;IACrB,uBAAuB;IACvB,eAAe;IACf,uBAAuB;IACvB,yBAAyB;IACzB,iBAAiB;CACT,CAAC"}
|