@trezor/connect 9.0.1 → 9.0.3

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.
Files changed (58) hide show
  1. package/README.md +5 -5
  2. package/lib/api/bitcoin/TransactionComposer.js +2 -1
  3. package/lib/api/bitcoin/outputs.js +2 -4
  4. package/lib/api/bitcoin/signtxVerify.d.ts +3 -3
  5. package/lib/api/bitcoin/signtxVerify.js +16 -15
  6. package/lib/api/getAddress.d.ts +2 -1
  7. package/lib/api/getAddress.js +12 -1
  8. package/lib/api/getPublicKey.d.ts +1 -0
  9. package/lib/api/getPublicKey.js +22 -7
  10. package/lib/api/index.d.ts +1 -0
  11. package/lib/api/index.js +3 -1
  12. package/lib/api/signTransaction.d.ts +1 -0
  13. package/lib/api/signTransaction.js +14 -2
  14. package/lib/api/unlockPath.d.ts +10 -0
  15. package/lib/api/unlockPath.js +35 -0
  16. package/lib/core/index.d.ts +1 -1
  17. package/lib/core/method.d.ts +1 -1
  18. package/lib/data/config.js +1 -1
  19. package/lib/data/version.d.ts +1 -1
  20. package/lib/data/version.js +1 -1
  21. package/lib/device/DeviceCommands.d.ts +7 -2
  22. package/lib/device/DeviceCommands.js +37 -25
  23. package/lib/events/ui-request.d.ts +40 -4
  24. package/lib/factory.js +1 -0
  25. package/lib/types/api/bitcoin/index.d.ts +1 -0
  26. package/lib/types/api/cardano/index.d.ts +3 -7
  27. package/lib/types/api/eos/index.d.ts +0 -4
  28. package/lib/types/api/eosGetPublicKey.d.ts +4 -4
  29. package/lib/types/api/getAddress.d.ts +1 -0
  30. package/lib/types/api/getPublicKey.d.ts +5 -0
  31. package/lib/types/api/index.d.ts +2 -0
  32. package/lib/types/api/unlockPath.d.ts +8 -0
  33. package/lib/types/api/unlockPath.js +3 -0
  34. package/lib/utils/assets.d.ts +1 -1
  35. package/lib/utils/assets.js +2 -2
  36. package/lib/utils/pathUtils.d.ts +2 -3
  37. package/lib/utils/pathUtils.js +42 -15
  38. package/package.json +12 -2
  39. package/lib/api/bitcoin/__fixtures__/inputs.d.ts +0 -112
  40. package/lib/api/bitcoin/__fixtures__/inputs.js +0 -102
  41. package/lib/api/bitcoin/__fixtures__/signtxVerify.d.ts +0 -147
  42. package/lib/api/bitcoin/__fixtures__/signtxVerify.js +0 -216
  43. package/lib/api/common/__fixtures__/paramsValidator.d.ts +0 -596
  44. package/lib/api/common/__fixtures__/paramsValidator.js +0 -355
  45. package/lib/api/ethereum/__fixtures__/ethereumSignTypedData.d.ts +0 -225
  46. package/lib/api/ethereum/__fixtures__/ethereumSignTypedData.js +0 -341
  47. package/lib/utils/__fixtures__/accountUtils.d.ts +0 -4
  48. package/lib/utils/__fixtures__/accountUtils.js +0 -32
  49. package/lib/utils/__fixtures__/addressUtils.d.ts +0 -10
  50. package/lib/utils/__fixtures__/addressUtils.js +0 -214
  51. package/lib/utils/__fixtures__/ethereumUtils.d.ts +0 -3
  52. package/lib/utils/__fixtures__/ethereumUtils.js +0 -20
  53. package/lib/utils/__fixtures__/formatUtils.d.ts +0 -3
  54. package/lib/utils/__fixtures__/formatUtils.js +0 -15
  55. package/lib/utils/__fixtures__/hdnodeUtils.d.ts +0 -186
  56. package/lib/utils/__fixtures__/hdnodeUtils.js +0 -206
  57. package/lib/utils/bip39.d.ts +0 -3
  58. package/lib/utils/bip39.js +0 -2053
@@ -1,355 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFirmwareRange = exports.validateParams = void 0;
4
- exports.validateParams = [
5
- {
6
- description: 'array',
7
- type: 'array',
8
- value: [],
9
- success: true,
10
- allowEmpty: true,
11
- },
12
- {
13
- description: 'array invalid (empty)',
14
- type: 'array',
15
- value: [],
16
- },
17
- {
18
- description: 'array-buffer',
19
- type: 'array-buffer',
20
- value: new ArrayBuffer(0),
21
- success: true,
22
- },
23
- {
24
- description: 'array-buffer invalid',
25
- type: 'array-buffer',
26
- value: Buffer.from('foo'),
27
- },
28
- {
29
- description: 'array-buffer invalid',
30
- type: 'array-buffer',
31
- value: [],
32
- },
33
- {
34
- description: 'array-buffer invalid',
35
- type: 'array-buffer',
36
- value: 'foo',
37
- },
38
- {
39
- description: 'array-buffer invalid',
40
- type: 'array-buffer',
41
- value: 0,
42
- },
43
- {
44
- description: 'uint valid (zero string)',
45
- type: 'uint',
46
- value: '0',
47
- success: true,
48
- },
49
- {
50
- description: 'uint valid (zero number)',
51
- type: 'uint',
52
- value: 0,
53
- success: true,
54
- },
55
- {
56
- description: 'uint valid (positive string)',
57
- type: 'uint',
58
- value: '10',
59
- success: true,
60
- },
61
- {
62
- description: 'uint valid (positive number)',
63
- type: 'uint',
64
- value: 10,
65
- success: true,
66
- },
67
- {
68
- description: 'negative string uint valid (allowNegative)',
69
- type: 'uint',
70
- allowNegative: true,
71
- value: '-1',
72
- success: true,
73
- },
74
- {
75
- description: 'negative number uint valid (allowNegative)',
76
- type: 'uint',
77
- allowNegative: true,
78
- value: -1,
79
- success: true,
80
- },
81
- {
82
- description: 'uint invalid (decimal number)',
83
- type: 'uint',
84
- value: 10.1,
85
- },
86
- {
87
- description: 'uint invalid (decimal string)',
88
- type: 'uint',
89
- value: '10.1',
90
- },
91
- {
92
- description: 'uint invalid (negative number)',
93
- type: 'uint',
94
- value: -1,
95
- },
96
- {
97
- description: 'uint invalid (negative string)',
98
- type: 'uint',
99
- value: '-1',
100
- },
101
- {
102
- description: 'uint invalid not safe integer',
103
- type: 'uint',
104
- value: Number.MAX_SAFE_INTEGER + 2,
105
- },
106
- {
107
- description: 'uint invalid leading zeros',
108
- type: 'uint',
109
- value: '01',
110
- },
111
- {
112
- description: 'uint invalid digits',
113
- type: 'uint',
114
- value: '123f',
115
- },
116
- {
117
- description: 'uint invalid type',
118
- type: 'uint',
119
- value: true,
120
- },
121
- {
122
- description: 'not required param without value (null)',
123
- type: 'number',
124
- value: null,
125
- success: true,
126
- },
127
- {
128
- description: 'not required param without value (undefined)',
129
- type: 'string',
130
- value: null,
131
- success: true,
132
- },
133
- {
134
- description: 'required param without type and false negative value (0)',
135
- required: true,
136
- value: 0,
137
- success: true,
138
- },
139
- {
140
- description: 'required param without type and false negative value (false)',
141
- required: true,
142
- value: false,
143
- success: true,
144
- },
145
- {
146
- description: 'required param without value (null)',
147
- required: true,
148
- value: null,
149
- },
150
- {
151
- description: 'required param without value (undefined)',
152
- required: true,
153
- value: undefined,
154
- },
155
- {
156
- description: 'param with union of types (string)',
157
- type: ['string', 'boolean', 'number'],
158
- value: 'true',
159
- success: true,
160
- },
161
- {
162
- description: 'param with union of types (boolean)',
163
- type: ['string', 'boolean', 'number'],
164
- value: true,
165
- success: true,
166
- },
167
- {
168
- description: 'param with union of types (invalid value)',
169
- type: ['string', 'boolean', 'number', 'array', 'array-buffer'],
170
- value: Buffer.from('00'),
171
- },
172
- ];
173
- const DEFAULT_RANGE = {
174
- 1: { min: '1.0.0', max: '0' },
175
- 2: { min: '2.0.0', max: '0' },
176
- };
177
- const DEFAULT_COIN_INFO = {
178
- support: { trezor1: '1.6.2', trezor2: '2.1.0' },
179
- shortcut: 'btc',
180
- type: 'bitcoin',
181
- };
182
- const EMPTY_CONFIG = {
183
- supportedFirmware: [],
184
- };
185
- exports.getFirmwareRange = [
186
- {
187
- description: 'default range. coinInfo and config.json data not found',
188
- config: EMPTY_CONFIG,
189
- params: ['signTransaction', null, DEFAULT_RANGE],
190
- result: DEFAULT_RANGE,
191
- },
192
- {
193
- description: 'range from coinInfo',
194
- config: EMPTY_CONFIG,
195
- params: ['signTransaction', DEFAULT_COIN_INFO, DEFAULT_RANGE],
196
- result: { 1: { min: '1.6.2', max: '0' }, 2: { min: '2.1.0', max: '0' } },
197
- },
198
- {
199
- description: 'coinInfo without support',
200
- config: EMPTY_CONFIG,
201
- params: ['signTransaction', { shortcut: 'btc', type: 'bitcoin' }, DEFAULT_RANGE],
202
- result: { 1: { min: '0', max: '0' }, 2: { min: '0', max: '0' } },
203
- },
204
- {
205
- description: 'coinInfo without T1 support',
206
- config: EMPTY_CONFIG,
207
- params: [
208
- 'signTransaction',
209
- { support: { trezor1: null, trezor2: '2.1.0' }, shortcut: 'btc', type: 'bitcoin' },
210
- DEFAULT_RANGE,
211
- ],
212
- result: { 1: { min: '0', max: '0' }, 2: { min: '2.1.0', max: '0' } },
213
- },
214
- {
215
- description: 'coinInfo without T2 support',
216
- config: EMPTY_CONFIG,
217
- params: [
218
- 'signTransaction',
219
- { support: { trezor1: '1.6.2', trezor2: null }, shortcut: 'btc', type: 'bitcoin' },
220
- DEFAULT_RANGE,
221
- ],
222
- result: { 1: { min: '1.6.2', max: '0' }, 2: { min: '0', max: '0' } },
223
- },
224
- {
225
- description: 'coinInfo support is lower than default',
226
- config: EMPTY_CONFIG,
227
- params: [
228
- 'signTransaction',
229
- DEFAULT_COIN_INFO,
230
- { 1: { min: '1.10.0', max: '0' }, 2: { min: '2.4.0', max: '0' } },
231
- ],
232
- result: { 1: { min: '1.10.0', max: '0' }, 2: { min: '2.4.0', max: '0' } },
233
- },
234
- {
235
- description: 'range from config.json (by coinType and coin as string)',
236
- config: {
237
- supportedFirmware: [
238
- { coinType: 'bitcoin', methods: ['showAddress'], min: ['1.12.0', '2.6.0'] },
239
- { coinType: 'bitcoin', min: ['1.10.0', '2.5.0'] },
240
- { coin: 'btc', min: ['1.11.0', '2.4.0'] },
241
- ],
242
- },
243
- params: ['signTransaction', DEFAULT_COIN_INFO, DEFAULT_RANGE],
244
- result: { 1: { min: '1.11.0', max: '0' }, 2: { min: '2.5.0', max: '0' } },
245
- },
246
- {
247
- description: 'range from config.json (by coin as string)',
248
- config: {
249
- supportedFirmware: [
250
- { coin: 'btc', methods: ['showAddress'], min: ['1.11.0', '2.5.0'] },
251
- { coin: 'btc', min: ['1.10.0', '2.4.0'] },
252
- ],
253
- },
254
- params: ['signTransaction', DEFAULT_COIN_INFO, DEFAULT_RANGE],
255
- result: { 1: { min: '1.10.0', max: '0' }, 2: { min: '2.4.0', max: '0' } },
256
- },
257
- {
258
- description: 'range from config.json (by coin as array)',
259
- config: {
260
- supportedFirmware: [
261
- { coin: ['btc'], methods: ['showAddress'], min: ['1.11.0', '2.5.0'] },
262
- { coin: ['btc'], min: ['1.10.0', '2.4.0'] },
263
- ],
264
- },
265
- params: ['signTransaction', DEFAULT_COIN_INFO, DEFAULT_RANGE],
266
- result: { 1: { min: '1.10.0', max: '0' }, 2: { min: '2.4.0', max: '0' } },
267
- },
268
- {
269
- description: 'range from config.json (by methods)',
270
- config: {
271
- supportedFirmware: [
272
- { min: ['1.11.0', '2.5.0'] },
273
- { coin: ['btc'], methods: ['showAddress'], min: ['1.11.0', '2.5.0'] },
274
- { coin: ['ltc'], methods: ['signTransaction'], min: ['1.11.0', '2.5.0'] },
275
- { coinType: 'bitcoin', methods: ['showAddress'], min: ['1.11.0', '2.5.0'] },
276
- { methods: ['signTransaction'], min: ['1.10.0', '2.4.0'] },
277
- ],
278
- },
279
- params: ['signTransaction', DEFAULT_COIN_INFO, DEFAULT_RANGE],
280
- result: { 1: { min: '1.10.0', max: '0' }, 2: { min: '2.4.0', max: '0' } },
281
- },
282
- {
283
- description: 'range from config.json (by capabilities)',
284
- config: {
285
- supportedFirmware: [
286
- { min: ['1.11.0', '2.5.0'] },
287
- { coin: ['btc'], methods: ['showAddress'], min: ['1.11.0', '2.5.0'] },
288
- { coin: ['ltc'], methods: ['signTransaction'], min: ['1.11.0', '2.5.0'] },
289
- { coinType: 'bitcoin', methods: ['showAddress'], min: ['1.11.0', '2.5.0'] },
290
- { capabilities: ['decreaseOutput'], min: ['1.10.0', '2.4.0'] },
291
- ],
292
- },
293
- params: ['decreaseOutput', DEFAULT_COIN_INFO, DEFAULT_RANGE],
294
- result: { 1: { min: '1.10.0', max: '0' }, 2: { min: '2.4.0', max: '0' } },
295
- },
296
- {
297
- description: 'range from config.json is lower than coinInfo',
298
- config: {
299
- supportedFirmware: [{ methods: ['signTransaction'], min: ['1.6.2', '2.1.0'] }],
300
- },
301
- params: [
302
- 'signTransaction',
303
- { support: { trezor1: '1.10.0', trezor2: '2.4.0' }, shortcut: 'btc', type: 'bitcoin' },
304
- DEFAULT_RANGE,
305
- ],
306
- result: { 1: { min: '1.10.0', max: '0' }, 2: { min: '2.4.0', max: '0' } },
307
- },
308
- {
309
- description: 'range from config.json using max',
310
- config: {
311
- supportedFirmware: [{ methods: ['signTransaction'], max: ['1.10.0', '2.4.0'] }],
312
- },
313
- params: ['signTransaction', DEFAULT_COIN_INFO, DEFAULT_RANGE],
314
- result: { 1: { min: '1.6.2', max: '1.10.0' }, 2: { min: '2.1.0', max: '2.4.0' } },
315
- },
316
- {
317
- description: 'range from config.json using max (values lower than default)',
318
- config: {
319
- supportedFirmware: [{ methods: ['signTransaction'], max: ['1.0.1', '2.0.1'] }],
320
- },
321
- params: [
322
- 'signTransaction',
323
- DEFAULT_COIN_INFO,
324
- {
325
- 1: { min: '1.0.0', max: '1.10.0' },
326
- 2: { min: '1.0.0', max: '2.10.0' },
327
- },
328
- ],
329
- result: { 1: { min: '1.6.2', max: '1.10.0' }, 2: { min: '2.1.0', max: '2.10.0' } },
330
- },
331
- {
332
- description: 'xrp + getAccountInfo: coinInfo range IS replaced by config.json range',
333
- params: [
334
- 'getAccountInfo',
335
- { support: { trezor1: '1.0.1', trezor2: '2.0.1' }, shortcut: 'xrp', type: 'ripple' },
336
- DEFAULT_RANGE,
337
- ],
338
- result: { 1: { min: '0', max: '0' }, 2: { min: '2.1.0', max: '0' } },
339
- },
340
- {
341
- description: 'btc + getAccountInfo: coinInfo range IS NOT replaced by config.json range',
342
- params: ['getAccountInfo', null, DEFAULT_RANGE],
343
- result: DEFAULT_RANGE,
344
- },
345
- {
346
- description: 'eip1559: coinInfo range is replaced by config.json range',
347
- params: [
348
- 'eip1559',
349
- { support: { trezor1: '1.6.2', trezor2: '2.1.0' }, shortcut: 'eth', type: 'ethereum' },
350
- DEFAULT_RANGE,
351
- ],
352
- result: { 1: { min: '1.10.4', max: '0' }, 2: { min: '2.4.2', max: '0' } },
353
- },
354
- ];
355
- //# sourceMappingURL=paramsValidator.js.map
@@ -1,225 +0,0 @@
1
- import BigNumber from 'bignumber.js';
2
- import { TrezorError } from '../../../constants/errors';
3
- import { PROTO } from '../../../constants';
4
- export declare const parseArrayType: ({
5
- description: string;
6
- input: string;
7
- output: {
8
- entryTypeName: string;
9
- arraySize: number;
10
- };
11
- error?: undefined;
12
- } | {
13
- description: string;
14
- input: string;
15
- output: {
16
- entryTypeName: string;
17
- arraySize: null;
18
- };
19
- error?: undefined;
20
- } | {
21
- description: string;
22
- input: string;
23
- error: (string | typeof TrezorError)[];
24
- output?: undefined;
25
- })[];
26
- export declare const getFieldType: ({
27
- description: string;
28
- input: {
29
- typeName: string;
30
- types: {
31
- ExampleStruct?: undefined;
32
- };
33
- };
34
- output: {
35
- data_type: PROTO.EthereumDataType;
36
- size: number;
37
- entry_type?: undefined;
38
- struct_name?: undefined;
39
- };
40
- error?: undefined;
41
- } | {
42
- description: string;
43
- input: {
44
- typeName: string;
45
- types: {
46
- ExampleStruct?: undefined;
47
- };
48
- };
49
- output: {
50
- data_type: PROTO.EthereumDataType;
51
- size?: undefined;
52
- entry_type?: undefined;
53
- struct_name?: undefined;
54
- };
55
- error?: undefined;
56
- } | {
57
- description: string;
58
- input: {
59
- typeName: string;
60
- types: {
61
- ExampleStruct?: undefined;
62
- };
63
- };
64
- output: {
65
- data_type: PROTO.EthereumDataType;
66
- size: undefined;
67
- entry_type?: undefined;
68
- struct_name?: undefined;
69
- };
70
- error?: undefined;
71
- } | {
72
- description: string;
73
- input: {
74
- typeName: string;
75
- types: {
76
- ExampleStruct?: undefined;
77
- };
78
- };
79
- output: {
80
- data_type: PROTO.EthereumDataType;
81
- size: number;
82
- entry_type: {
83
- data_type: PROTO.EthereumDataType;
84
- size: number;
85
- entry_type?: undefined;
86
- };
87
- struct_name?: undefined;
88
- };
89
- error?: undefined;
90
- } | {
91
- description: string;
92
- input: {
93
- typeName: string;
94
- types: {
95
- ExampleStruct?: undefined;
96
- };
97
- };
98
- output: {
99
- data_type: PROTO.EthereumDataType;
100
- size: undefined;
101
- entry_type: {
102
- data_type: PROTO.EthereumDataType;
103
- size: number;
104
- entry_type?: undefined;
105
- };
106
- struct_name?: undefined;
107
- };
108
- error?: undefined;
109
- } | {
110
- description: string;
111
- input: {
112
- typeName: string;
113
- types: {
114
- ExampleStruct?: undefined;
115
- };
116
- };
117
- output: {
118
- data_type: PROTO.EthereumDataType;
119
- size: number;
120
- entry_type: {
121
- data_type: PROTO.EthereumDataType;
122
- size: number;
123
- entry_type: {
124
- data_type: PROTO.EthereumDataType;
125
- size: number;
126
- };
127
- };
128
- struct_name?: undefined;
129
- };
130
- error?: undefined;
131
- } | {
132
- description: string;
133
- input: {
134
- typeName: string;
135
- types: {
136
- ExampleStruct: {
137
- name: string;
138
- type: string;
139
- }[];
140
- };
141
- };
142
- output: {
143
- data_type: PROTO.EthereumDataType;
144
- size: number;
145
- struct_name: string;
146
- entry_type?: undefined;
147
- };
148
- error?: undefined;
149
- } | {
150
- description: string;
151
- input: {
152
- typeName: string;
153
- types: {
154
- ExampleStruct?: undefined;
155
- };
156
- };
157
- error: (string | typeof TrezorError)[];
158
- output?: undefined;
159
- })[];
160
- export declare const encodeData: ({
161
- description: string;
162
- input: {
163
- typeName: string;
164
- data: string;
165
- };
166
- output: string;
167
- error?: undefined;
168
- } | {
169
- description: string;
170
- input: {
171
- typeName: string;
172
- data: ArrayBufferLike;
173
- };
174
- output: string;
175
- error?: undefined;
176
- } | {
177
- description: string;
178
- input: {
179
- typeName: string;
180
- data: number;
181
- };
182
- output: string;
183
- error?: undefined;
184
- } | {
185
- description: string;
186
- input: {
187
- typeName: string;
188
- data: bigint;
189
- };
190
- output: string;
191
- error?: undefined;
192
- } | {
193
- description: string;
194
- input: {
195
- typeName: string;
196
- data: BigNumber;
197
- };
198
- output: string;
199
- error?: undefined;
200
- } | {
201
- description: string;
202
- input: {
203
- typeName: string;
204
- data: number;
205
- };
206
- error: (string | typeof TrezorError)[];
207
- output?: undefined;
208
- } | {
209
- description: string;
210
- input: {
211
- typeName: string;
212
- data: boolean;
213
- };
214
- output: string;
215
- error?: undefined;
216
- } | {
217
- description: string;
218
- input: {
219
- typeName: string;
220
- data: boolean[];
221
- };
222
- error: (string | typeof TrezorError)[];
223
- output?: undefined;
224
- })[];
225
- //# sourceMappingURL=ethereumSignTypedData.d.ts.map