@onekeyfe/hd-core 0.1.6 → 0.1.9
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/api/CipherKeyValue.d.ts +1 -1
- package/dist/api/CipherKeyValue.d.ts.map +1 -1
- package/dist/api/FirmwareUpdate.d.ts +1 -3
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/GetFeatures.d.ts +1 -47
- package/dist/api/GetFeatures.d.ts.map +1 -1
- package/dist/api/btc/BTCGetAddress.d.ts +1 -1
- package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts +1 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
- package/dist/api/btc/BTCSignMessage.d.ts +2 -5
- package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
- package/dist/api/btc/BTCSignTransaction.d.ts +1 -1
- package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCVerifyMessage.d.ts +2 -4
- package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
- package/dist/api/btc/helpers/signtx.d.ts +1 -1
- package/dist/api/btc/helpers/signtx.d.ts.map +1 -1
- package/dist/api/btc/helpers/signtxLegacy.d.ts +1 -1
- package/dist/api/btc/helpers/signtxLegacy.d.ts.map +1 -1
- package/dist/api/device/DeviceBackup.d.ts +2 -4
- package/dist/api/device/DeviceBackup.d.ts.map +1 -1
- package/dist/api/device/DeviceChangePin.d.ts +2 -4
- package/dist/api/device/DeviceChangePin.d.ts.map +1 -1
- package/dist/api/device/DeviceFlags.d.ts +2 -4
- package/dist/api/device/DeviceFlags.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBootloader.d.ts +2 -4
- package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceRecovery.d.ts +2 -4
- package/dist/api/device/DeviceRecovery.d.ts.map +1 -1
- package/dist/api/device/DeviceReset.d.ts +2 -4
- package/dist/api/device/DeviceReset.d.ts.map +1 -1
- package/dist/api/device/DeviceSettings.d.ts +2 -4
- package/dist/api/device/DeviceSettings.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateReboot.d.ts +2 -4
- package/dist/api/device/DeviceUpdateReboot.d.ts.map +1 -1
- package/dist/api/device/DeviceVerify.d.ts +8 -0
- package/dist/api/device/DeviceVerify.d.ts.map +1 -0
- package/dist/api/device/DeviceWipe.d.ts +2 -4
- package/dist/api/device/DeviceWipe.d.ts.map +1 -1
- package/dist/api/evm/EVMGetAddress.d.ts +1 -1
- package/dist/api/evm/EVMGetAddress.d.ts.map +1 -1
- package/dist/api/evm/EVMGetPublicKey.d.ts +1 -1
- package/dist/api/evm/EVMGetPublicKey.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessage.d.ts +2 -5
- package/dist/api/evm/EVMSignMessage.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessageEIP712.d.ts +2 -5
- package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTransaction.d.ts +1 -1
- package/dist/api/evm/EVMSignTransaction.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts +6 -5
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/evm/EVMVerifyMessage.d.ts +2 -4
- package/dist/api/evm/EVMVerifyMessage.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts +1 -3
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/helpers/pathUtils.d.ts +1 -1
- package/dist/api/helpers/pathUtils.d.ts.map +1 -1
- package/dist/api/helpers/typeNameUtils.d.ts +1 -1
- package/dist/api/helpers/typeNameUtils.d.ts.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/nem/NEMGetAddress.d.ts +1 -1
- package/dist/api/nem/NEMGetAddress.d.ts.map +1 -1
- package/dist/api/nem/NEMSignTransaction.d.ts +1 -1
- package/dist/api/nem/NEMSignTransaction.d.ts.map +1 -1
- package/dist/api/solana/SolGetAddress.d.ts +1 -1
- package/dist/api/solana/SolGetAddress.d.ts.map +1 -1
- package/dist/api/solana/SolSignTransaction.d.ts +1 -1
- package/dist/api/solana/SolSignTransaction.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinGetAddress.d.ts +1 -1
- package/dist/api/starcoin/StarcoinGetAddress.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinGetPublicKey.d.ts +1 -1
- package/dist/api/starcoin/StarcoinGetPublicKey.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinSignMessage.d.ts +2 -5
- package/dist/api/starcoin/StarcoinSignMessage.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinSignTransaction.d.ts +2 -5
- package/dist/api/starcoin/StarcoinSignTransaction.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinVerifyMessage.d.ts +2 -4
- package/dist/api/starcoin/StarcoinVerifyMessage.d.ts.map +1 -1
- package/dist/api/stellar/StellarGetAddress.d.ts +1 -1
- package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +1 -1
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +1 -0
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +16 -51
- package/dist/index.js +244 -2
- package/dist/inject.d.ts.map +1 -1
- package/dist/types/api/btcGetAddress.d.ts +1 -1
- package/dist/types/api/btcGetAddress.d.ts.map +1 -1
- package/dist/types/api/btcGetPublicKey.d.ts +1 -1
- package/dist/types/api/btcGetPublicKey.d.ts.map +1 -1
- package/dist/types/api/btcSignMessage.d.ts +1 -1
- package/dist/types/api/btcSignMessage.d.ts.map +1 -1
- package/dist/types/api/btcSignTransaction.d.ts +1 -1
- package/dist/types/api/btcSignTransaction.d.ts.map +1 -1
- package/dist/types/api/btcVerifyMessage.d.ts +1 -1
- package/dist/types/api/btcVerifyMessage.d.ts.map +1 -1
- package/dist/types/api/cipherKeyValue.d.ts +1 -1
- package/dist/types/api/cipherKeyValue.d.ts.map +1 -1
- package/dist/types/api/deviceBackup.d.ts +1 -1
- package/dist/types/api/deviceBackup.d.ts.map +1 -1
- package/dist/types/api/deviceChangePin.d.ts +1 -1
- package/dist/types/api/deviceChangePin.d.ts.map +1 -1
- package/dist/types/api/deviceFlags.d.ts +1 -1
- package/dist/types/api/deviceFlags.d.ts.map +1 -1
- package/dist/types/api/deviceRebootToBootloader.d.ts +1 -1
- package/dist/types/api/deviceRebootToBootloader.d.ts.map +1 -1
- package/dist/types/api/deviceRecovery.d.ts +1 -1
- package/dist/types/api/deviceRecovery.d.ts.map +1 -1
- package/dist/types/api/deviceReset.d.ts +1 -1
- package/dist/types/api/deviceReset.d.ts.map +1 -1
- package/dist/types/api/deviceSettings.d.ts +1 -1
- package/dist/types/api/deviceSettings.d.ts.map +1 -1
- package/dist/types/api/deviceUpdateReboot.d.ts +1 -1
- package/dist/types/api/deviceUpdateReboot.d.ts.map +1 -1
- package/dist/types/api/deviceVerify.d.ts +11 -0
- package/dist/types/api/deviceVerify.d.ts.map +1 -0
- package/dist/types/api/deviceWipe.d.ts +1 -1
- package/dist/types/api/deviceWipe.d.ts.map +1 -1
- package/dist/types/api/evmGetPublicKey.d.ts +1 -1
- package/dist/types/api/evmGetPublicKey.d.ts.map +1 -1
- package/dist/types/api/evmSignMessage.d.ts +1 -1
- package/dist/types/api/evmSignMessage.d.ts.map +1 -1
- package/dist/types/api/evmSignMessageEIP712.d.ts +1 -1
- package/dist/types/api/evmSignMessageEIP712.d.ts.map +1 -1
- package/dist/types/api/evmSignTypedData.d.ts +1 -1
- package/dist/types/api/evmSignTypedData.d.ts.map +1 -1
- package/dist/types/api/evmVerifyMessage.d.ts +1 -1
- package/dist/types/api/evmVerifyMessage.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +1 -0
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +2 -0
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/nemGetAddress.d.ts +1 -1
- package/dist/types/api/nemGetAddress.d.ts.map +1 -1
- package/dist/types/api/nemSignTransaction.d.ts +1 -1
- package/dist/types/api/nemSignTransaction.d.ts.map +1 -1
- package/dist/types/api/solGetAddress.d.ts +1 -1
- package/dist/types/api/solGetAddress.d.ts.map +1 -1
- package/dist/types/api/solSignTransaction.d.ts +1 -1
- package/dist/types/api/solSignTransaction.d.ts.map +1 -1
- package/dist/types/api/starcoinGetAddress.d.ts +1 -1
- package/dist/types/api/starcoinGetAddress.d.ts.map +1 -1
- package/dist/types/api/starcoinGetPublicKey.d.ts +1 -1
- package/dist/types/api/starcoinGetPublicKey.d.ts.map +1 -1
- package/dist/types/api/starcoinSignMessage.d.ts +1 -1
- package/dist/types/api/starcoinSignMessage.d.ts.map +1 -1
- package/dist/types/api/starcoinSignTransaction.d.ts +1 -1
- package/dist/types/api/starcoinSignTransaction.d.ts.map +1 -1
- package/dist/types/api/starcoinVerifyMessage.d.ts +1 -1
- package/dist/types/api/starcoinVerifyMessage.d.ts.map +1 -1
- package/dist/types/api/stellarGetAddress.d.ts +1 -1
- package/dist/types/api/stellarGetAddress.d.ts.map +1 -1
- package/dist/types/api/stellarSignTransaction.d.ts +1 -1
- package/dist/types/api/stellarSignTransaction.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +3 -94
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/CipherKeyValue.ts +1 -1
- package/src/api/btc/BTCGetAddress.ts +1 -1
- package/src/api/btc/BTCGetPublicKey.ts +1 -1
- package/src/api/btc/BTCSignMessage.ts +1 -1
- package/src/api/btc/BTCSignTransaction.ts +1 -1
- package/src/api/btc/BTCVerifyMessage.ts +1 -1
- package/src/api/btc/helpers/signtx.ts +1 -1
- package/src/api/btc/helpers/signtxLegacy.ts +1 -1
- package/src/api/device/DeviceBackup.ts +1 -1
- package/src/api/device/DeviceChangePin.ts +1 -1
- package/src/api/device/DeviceFlags.ts +1 -1
- package/src/api/device/DeviceRebootToBootloader.ts +1 -1
- package/src/api/device/DeviceRecovery.ts +1 -1
- package/src/api/device/DeviceReset.ts +1 -1
- package/src/api/device/DeviceSettings.ts +1 -1
- package/src/api/device/DeviceUpdateReboot.ts +1 -1
- package/src/api/device/DeviceVerify.ts +55 -0
- package/src/api/device/DeviceWipe.ts +1 -1
- package/src/api/evm/EVMGetAddress.ts +1 -1
- package/src/api/evm/EVMGetPublicKey.ts +1 -1
- package/src/api/evm/EVMSignMessage.ts +1 -1
- package/src/api/evm/EVMSignMessageEIP712.ts +1 -1
- package/src/api/evm/EVMSignTransaction.ts +1 -5
- package/src/api/evm/EVMSignTypedData.ts +119 -124
- package/src/api/evm/EVMVerifyMessage.ts +1 -1
- package/src/api/helpers/pathUtils.ts +1 -1
- package/src/api/helpers/typeNameUtils.ts +1 -1
- package/src/api/index.ts +1 -0
- package/src/api/nem/NEMGetAddress.ts +1 -1
- package/src/api/nem/NEMSignTransaction.ts +1 -1
- package/src/api/solana/SolGetAddress.ts +3 -1
- package/src/api/solana/SolSignTransaction.ts +3 -1
- package/src/api/starcoin/StarcoinGetAddress.ts +1 -1
- package/src/api/starcoin/StarcoinGetPublicKey.ts +1 -1
- package/src/api/starcoin/StarcoinSignMessage.ts +1 -1
- package/src/api/starcoin/StarcoinSignTransaction.ts +1 -1
- package/src/api/starcoin/StarcoinVerifyMessage.ts +1 -1
- package/src/api/stellar/StellarGetAddress.ts +1 -1
- package/src/api/stellar/StellarSignTransaction.ts +1 -1
- package/src/core/index.ts +5 -0
- package/src/device/Device.ts +4 -1
- package/src/events/ui-request.ts +2 -0
- package/src/inject.ts +1 -0
- package/src/types/api/btcGetAddress.ts +1 -1
- package/src/types/api/btcGetPublicKey.ts +1 -1
- package/src/types/api/btcSignMessage.ts +1 -1
- package/src/types/api/btcSignTransaction.ts +1 -1
- package/src/types/api/btcVerifyMessage.ts +1 -1
- package/src/types/api/cipherKeyValue.ts +1 -1
- package/src/types/api/deviceBackup.ts +1 -1
- package/src/types/api/deviceChangePin.ts +1 -1
- package/src/types/api/deviceFlags.ts +1 -1
- package/src/types/api/deviceRebootToBootloader.ts +1 -1
- package/src/types/api/deviceRecovery.ts +1 -1
- package/src/types/api/deviceReset.ts +1 -1
- package/src/types/api/deviceSettings.ts +1 -1
- package/src/types/api/deviceUpdateReboot.ts +1 -1
- package/src/types/api/deviceVerify.ts +15 -0
- package/src/types/api/deviceWipe.ts +1 -1
- package/src/types/api/evmGetPublicKey.ts +1 -1
- package/src/types/api/evmSignMessage.ts +1 -1
- package/src/types/api/evmSignMessageEIP712.ts +1 -1
- package/src/types/api/evmSignTypedData.ts +1 -1
- package/src/types/api/evmVerifyMessage.ts +1 -1
- package/src/types/api/export.ts +1 -0
- package/src/types/api/index.ts +2 -0
- package/src/types/api/nemGetAddress.ts +1 -1
- package/src/types/api/nemSignTransaction.ts +1 -1
- package/src/types/api/solGetAddress.ts +1 -1
- package/src/types/api/solSignTransaction.ts +1 -1
- package/src/types/api/starcoinGetAddress.ts +1 -1
- package/src/types/api/starcoinGetPublicKey.ts +1 -1
- package/src/types/api/starcoinSignMessage.ts +1 -1
- package/src/types/api/starcoinSignTransaction.ts +1 -1
- package/src/types/api/starcoinVerifyMessage.ts +1 -1
- package/src/types/api/stellarGetAddress.ts +1 -1
- package/src/types/api/stellarSignTransaction.ts +1 -1
- package/src/utils/deviceFeaturesUtils.ts +11 -0
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
3
|
+
import type {
|
|
4
4
|
EthereumTypedDataSignature,
|
|
5
5
|
EthereumTypedDataStructAck,
|
|
6
|
-
|
|
7
|
-
} from '@onekeyfe/hd-transport/src/types/messages';
|
|
8
|
-
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
6
|
+
} from '@onekeyfe/hd-transport';
|
|
9
7
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
10
8
|
import { validatePath } from '../helpers/pathUtils';
|
|
11
9
|
import { BaseMethod } from '../BaseMethod';
|
|
12
10
|
import { validateParams } from '../helpers/paramsValidator';
|
|
13
11
|
import { formatAnyHex } from '../helpers/hexUtils';
|
|
14
12
|
import { encodeData, getFieldType, parseArrayType } from '../helpers/typeNameUtils';
|
|
15
|
-
import {
|
|
13
|
+
import { getDeviceFirmwareVersion, getDeviceType } from '../../utils/deviceFeaturesUtils';
|
|
14
|
+
import type {
|
|
16
15
|
EthereumSignTypedDataMessage,
|
|
17
16
|
EthereumSignTypedDataTypes,
|
|
18
17
|
} from '../../types/api/evmSignTypedData';
|
|
19
|
-
import { getDeviceFirmwareVersion, getDeviceType } from '../../utils/deviceFeaturesUtils';
|
|
20
|
-
import { TypedResponseMessage } from '../../device/DeviceCommands';
|
|
21
18
|
|
|
22
19
|
export type EVMSignTypedDataParams = {
|
|
23
20
|
addressN: number[];
|
|
@@ -62,120 +59,119 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
62
59
|
}
|
|
63
60
|
}
|
|
64
61
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
// }
|
|
62
|
+
async signTypedData() {
|
|
63
|
+
const { commands } = this.device;
|
|
64
|
+
const { addressN, data, metamaskV4Compat } = this.params;
|
|
65
|
+
|
|
66
|
+
const {
|
|
67
|
+
types,
|
|
68
|
+
primaryType,
|
|
69
|
+
domain,
|
|
70
|
+
message,
|
|
71
|
+
}: EthereumSignTypedDataMessage<EthereumSignTypedDataTypes> = data;
|
|
72
|
+
|
|
73
|
+
let response = await commands.typedCall(
|
|
74
|
+
'EthereumSignTypedData',
|
|
75
|
+
[
|
|
76
|
+
'EthereumTypedDataStructRequest',
|
|
77
|
+
'EthereumTypedDataValueRequest',
|
|
78
|
+
'EthereumTypedDataSignature',
|
|
79
|
+
],
|
|
80
|
+
{
|
|
81
|
+
address_n: addressN,
|
|
82
|
+
primary_type: primaryType as string,
|
|
83
|
+
metamask_v4_compat: metamaskV4Compat,
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
while (response.type === 'EthereumTypedDataStructRequest') {
|
|
88
|
+
const { name: typeDefinitionName } = response.message;
|
|
89
|
+
const typeDefinition = types[typeDefinitionName];
|
|
90
|
+
if (typeDefinition === undefined) {
|
|
91
|
+
throw ERRORS.TypedError(
|
|
92
|
+
'Runtime',
|
|
93
|
+
`Type ${typeDefinitionName} was not defined in types object`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const dataStruckAck: EthereumTypedDataStructAck = {
|
|
98
|
+
members: typeDefinition.map(({ name, type: typeName }) => ({
|
|
99
|
+
name,
|
|
100
|
+
type: getFieldType(typeName, types),
|
|
101
|
+
})),
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
response = await commands.typedCall(
|
|
105
|
+
'EthereumTypedDataStructAck',
|
|
106
|
+
[
|
|
107
|
+
'EthereumTypedDataStructRequest',
|
|
108
|
+
'EthereumTypedDataValueRequest',
|
|
109
|
+
'EthereumTypedDataSignature',
|
|
110
|
+
],
|
|
111
|
+
dataStruckAck
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
while (response.type === 'EthereumTypedDataValueRequest') {
|
|
116
|
+
const { member_path } = response.message;
|
|
117
|
+
|
|
118
|
+
let memberData;
|
|
119
|
+
let memberTypeName: string;
|
|
120
|
+
|
|
121
|
+
const [rootIndex, ...nestedMemberPath] = member_path;
|
|
122
|
+
switch (rootIndex) {
|
|
123
|
+
case 0:
|
|
124
|
+
memberData = domain;
|
|
125
|
+
memberTypeName = 'EIP712Domain';
|
|
126
|
+
break;
|
|
127
|
+
case 1:
|
|
128
|
+
memberData = message;
|
|
129
|
+
memberTypeName = primaryType as string;
|
|
130
|
+
break;
|
|
131
|
+
default:
|
|
132
|
+
throw ERRORS.TypedError('Runtime', 'Root index can only be 0 or 1');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
for (const index of nestedMemberPath) {
|
|
136
|
+
if (Array.isArray(memberData)) {
|
|
137
|
+
memberTypeName = parseArrayType(memberTypeName).entryTypeName;
|
|
138
|
+
memberData = memberData[index];
|
|
139
|
+
} else if (typeof memberData === 'object' && memberData !== null) {
|
|
140
|
+
const memberTypeDefinition = types[memberTypeName][index];
|
|
141
|
+
memberTypeName = memberTypeDefinition.type;
|
|
142
|
+
memberData = memberData[memberTypeDefinition.name];
|
|
143
|
+
} else {
|
|
144
|
+
// TODO
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
let encodedData;
|
|
149
|
+
if (Array.isArray(memberData)) {
|
|
150
|
+
// Sending the length as uint16
|
|
151
|
+
encodedData = encodeData('uint16', memberData.length);
|
|
152
|
+
} else {
|
|
153
|
+
encodedData = encodeData(memberTypeName, memberData);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
response = await commands.typedCall(
|
|
157
|
+
'EthereumTypedDataValueAck',
|
|
158
|
+
['EthereumTypedDataValueRequest', 'EthereumTypedDataSignature'],
|
|
159
|
+
{
|
|
160
|
+
value: encodedData,
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (response.type !== 'EthereumTypedDataSignature') {
|
|
166
|
+
throw ERRORS.TypedError('Runtime', 'Unexpected response type');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const { address, signature }: EthereumTypedDataSignature = response.message;
|
|
170
|
+
return {
|
|
171
|
+
address,
|
|
172
|
+
signature,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
179
175
|
|
|
180
176
|
getVersionRange() {
|
|
181
177
|
return {
|
|
@@ -246,7 +242,6 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
246
242
|
}
|
|
247
243
|
|
|
248
244
|
// For Touch、Pro we use EthereumSignTypedData
|
|
249
|
-
|
|
250
|
-
return Promise.resolve(ERRORS.TypedError('Runtime', 'Not implemented'));
|
|
245
|
+
return this.signTypedData();
|
|
251
246
|
}
|
|
252
247
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EthereumVerifyMessage } from '@onekeyfe/hd-transport
|
|
1
|
+
import { EthereumVerifyMessage } from '@onekeyfe/hd-transport';
|
|
2
2
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
3
3
|
import { BaseMethod } from '../BaseMethod';
|
|
4
4
|
import { validateParams } from '../helpers/paramsValidator';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-bitwise */
|
|
2
2
|
|
|
3
|
-
import { ChangeOutputScriptType, InputScriptType } from '@onekeyfe/hd-transport
|
|
3
|
+
import { ChangeOutputScriptType, InputScriptType } from '@onekeyfe/hd-transport';
|
|
4
4
|
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
5
5
|
|
|
6
6
|
const HD_HARDENED = 0x80000000;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable prefer-regex-literals */
|
|
2
2
|
|
|
3
|
-
import { EthereumDataType, EthereumFieldType } from '@onekeyfe/hd-transport
|
|
3
|
+
import { EthereumDataType, EthereumFieldType } from '@onekeyfe/hd-transport';
|
|
4
4
|
|
|
5
5
|
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
6
6
|
import { EthereumSignTypedDataTypes } from '../../types/api/evmSignTypedData';
|
package/src/api/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ export { default as deviceRecovery } from './device/DeviceRecovery';
|
|
|
17
17
|
export { default as deviceReset } from './device/DeviceReset';
|
|
18
18
|
export { default as deviceSettings } from './device/DeviceSettings';
|
|
19
19
|
export { default as deviceUpdateReboot } from './device/DeviceUpdateReboot';
|
|
20
|
+
export { default as deviceVerify } from './device/DeviceVerify';
|
|
20
21
|
export { default as deviceWipe } from './device/DeviceWipe';
|
|
21
22
|
export { default as evmGetAddress } from './evm/EVMGetAddress';
|
|
22
23
|
export { default as evmGetPublicKey } from './evm/EVMGetPublicKey';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NEMGetAddress as HardwareNEMGetAddress } from '@onekeyfe/hd-transport
|
|
1
|
+
import { NEMGetAddress as HardwareNEMGetAddress } from '@onekeyfe/hd-transport';
|
|
2
2
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
3
3
|
import { validatePath, serializedPath } from '../helpers/pathUtils';
|
|
4
4
|
import { BaseMethod } from '../BaseMethod';
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
NEMSignTx,
|
|
9
9
|
NEMTransactionCommon,
|
|
10
10
|
NEMTransfer,
|
|
11
|
-
} from '@onekeyfe/hd-transport
|
|
11
|
+
} from '@onekeyfe/hd-transport';
|
|
12
12
|
|
|
13
13
|
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
14
14
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SolanaGetAddress } from '@onekeyfe/hd-transport
|
|
1
|
+
import { SolanaGetAddress } from '@onekeyfe/hd-transport';
|
|
2
2
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
3
3
|
import { serializedPath, validatePath } from '../helpers/pathUtils';
|
|
4
4
|
import { BaseMethod } from '../BaseMethod';
|
|
@@ -42,10 +42,12 @@ export default class SolGetAddress extends BaseMethod<SolanaGetAddress[]> {
|
|
|
42
42
|
for (let i = 0; i < this.params.length; i++) {
|
|
43
43
|
const param = this.params[i];
|
|
44
44
|
|
|
45
|
+
// @ts-expect-error
|
|
45
46
|
const res = await this.device.commands.typedCall('SolanaGetAddress', 'SolanaAddress', {
|
|
46
47
|
...param,
|
|
47
48
|
});
|
|
48
49
|
|
|
50
|
+
// @ts-expect-error
|
|
49
51
|
const { address } = res.message;
|
|
50
52
|
|
|
51
53
|
responses.push({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SolanaSignTx as HardwareSolanaSignTx } from '@onekeyfe/hd-transport
|
|
1
|
+
import { SolanaSignTx as HardwareSolanaSignTx } from '@onekeyfe/hd-transport';
|
|
2
2
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
3
3
|
import { serializedPath, validatePath } from '../helpers/pathUtils';
|
|
4
4
|
import { BaseMethod } from '../BaseMethod';
|
|
@@ -52,10 +52,12 @@ export default class SolSignTransaction extends BaseMethod<HardwareSolanaSignTx[
|
|
|
52
52
|
for (let i = 0; i < this.params.length; i++) {
|
|
53
53
|
const param = this.params[i];
|
|
54
54
|
|
|
55
|
+
// @ts-expect-error
|
|
55
56
|
const res = await this.device.commands.typedCall('SolanaSignTx', 'SolanaSignedTx', {
|
|
56
57
|
...param,
|
|
57
58
|
});
|
|
58
59
|
|
|
60
|
+
// @ts-expect-error
|
|
59
61
|
const { signature } = res.message;
|
|
60
62
|
|
|
61
63
|
responses.push({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StarcoinGetAddress as HardwareStarcoinGetAddress } from '@onekeyfe/hd-transport
|
|
1
|
+
import { StarcoinGetAddress as HardwareStarcoinGetAddress } from '@onekeyfe/hd-transport';
|
|
2
2
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
3
3
|
import { validatePath, serializedPath } from '../helpers/pathUtils';
|
|
4
4
|
import { BaseMethod } from '../BaseMethod';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StarcoinGetPublicKey as HardwareStarcoinGetPublicKey } from '@onekeyfe/hd-transport
|
|
1
|
+
import { StarcoinGetPublicKey as HardwareStarcoinGetPublicKey } from '@onekeyfe/hd-transport';
|
|
2
2
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
3
3
|
import { validatePath, serializedPath } from '../helpers/pathUtils';
|
|
4
4
|
import { BaseMethod } from '../BaseMethod';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StarcoinSignMessage as HardwareStarcoinSignMessage } from '@onekeyfe/hd-transport
|
|
1
|
+
import { StarcoinSignMessage as HardwareStarcoinSignMessage } from '@onekeyfe/hd-transport';
|
|
2
2
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
3
3
|
import { validatePath } from '../helpers/pathUtils';
|
|
4
4
|
import { BaseMethod } from '../BaseMethod';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StarcoinSignTx } from '@onekeyfe/hd-transport
|
|
1
|
+
import { StarcoinSignTx } from '@onekeyfe/hd-transport';
|
|
2
2
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
3
3
|
import { validatePath } from '../helpers/pathUtils';
|
|
4
4
|
import { BaseMethod } from '../BaseMethod';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StarcoinVerifyMessage as HardwareStarcoinVerifyMessage } from '@onekeyfe/hd-transport
|
|
1
|
+
import { StarcoinVerifyMessage as HardwareStarcoinVerifyMessage } from '@onekeyfe/hd-transport';
|
|
2
2
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
3
3
|
import { BaseMethod } from '../BaseMethod';
|
|
4
4
|
import { validateParams } from '../helpers/paramsValidator';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StellarGetAddress as HardwareStellarGetAddress } from '@onekeyfe/hd-transport
|
|
1
|
+
import { StellarGetAddress as HardwareStellarGetAddress } from '@onekeyfe/hd-transport';
|
|
2
2
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
3
3
|
import { serializedPath, validatePath } from '../helpers/pathUtils';
|
|
4
4
|
import { BaseMethod } from '../BaseMethod';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
StellarSignedTx,
|
|
3
3
|
StellarSignTx as HardwareStellarSignTx,
|
|
4
|
-
} from '@onekeyfe/hd-transport
|
|
4
|
+
} from '@onekeyfe/hd-transport';
|
|
5
5
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
6
6
|
import { validatePath } from '../helpers/pathUtils';
|
|
7
7
|
import { BaseMethod } from '../BaseMethod';
|
package/src/core/index.ts
CHANGED
|
@@ -140,6 +140,11 @@ export const callAPI = async (message: CoreMessage) => {
|
|
|
140
140
|
method.requireDeviceMode
|
|
141
141
|
);
|
|
142
142
|
if (unexpectedMode) {
|
|
143
|
+
if (unexpectedMode === UI_REQUEST.NOT_IN_BOOTLOADER) {
|
|
144
|
+
return Promise.reject(
|
|
145
|
+
ERRORS.TypedError(HardwareErrorCode.DeviceUnexpectedBootloaderMode)
|
|
146
|
+
);
|
|
147
|
+
}
|
|
143
148
|
return Promise.reject(
|
|
144
149
|
ERRORS.TypedError(HardwareErrorCode.DeviceUnexpectedMode, unexpectedMode)
|
|
145
150
|
);
|
package/src/device/Device.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
getDeviceType,
|
|
13
13
|
getDeviceUUID,
|
|
14
14
|
getDeviceBLEFirmwareVersion,
|
|
15
|
+
getDeviceTypeOnBootloader,
|
|
15
16
|
} from '../utils/deviceFeaturesUtils';
|
|
16
17
|
import type { Features, Device as DeviceTyped, UnavailableCapabilities } from '../types';
|
|
17
18
|
import { DEVICE, DeviceButtonRequestPayload } from '../events';
|
|
@@ -114,7 +115,9 @@ export class Device extends EventEmitter {
|
|
|
114
115
|
connectId: env === 'react-native' ? this.mainId || null : getDeviceUUID(this.features),
|
|
115
116
|
/** Hardware ID, will not change at any time */
|
|
116
117
|
uuid: getDeviceUUID(this.features),
|
|
117
|
-
deviceType:
|
|
118
|
+
deviceType: this.features.bootloader_mode
|
|
119
|
+
? getDeviceTypeOnBootloader(this.features)
|
|
120
|
+
: getDeviceType(this.features),
|
|
118
121
|
/** ID for current seeds, will clear after replace a new seed at device */
|
|
119
122
|
deviceId: this.features.device_id || null,
|
|
120
123
|
path: this.originalDescriptor.path,
|
package/src/events/ui-request.ts
CHANGED
package/src/inject.ts
CHANGED
|
@@ -77,6 +77,7 @@ export const inject = ({
|
|
|
77
77
|
deviceReset: (connectId, params) => call({ ...params, connectId, method: 'deviceReset' }),
|
|
78
78
|
deviceSettings: (connectId, params) => call({ ...params, connectId, method: 'deviceSettings' }),
|
|
79
79
|
deviceUpdateReboot: connectId => call({ connectId, method: 'deviceUpdateReboot' }),
|
|
80
|
+
deviceVerify: (connectId, params) => call({ ...params, connectId, method: 'deviceVerify' }),
|
|
80
81
|
deviceWipe: connectId => call({ connectId, method: 'deviceWipe' }),
|
|
81
82
|
|
|
82
83
|
evmGetAddress: (connectId, params) => call({ ...params, connectId, method: 'evmGetAddress' }),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CipheredKeyValue as HardwareCipheredKeyValue } from '@onekeyfe/hd-transport
|
|
1
|
+
import { CipheredKeyValue as HardwareCipheredKeyValue } from '@onekeyfe/hd-transport';
|
|
2
2
|
import type { CommonParams, Response } from '../params';
|
|
3
3
|
|
|
4
4
|
export type CipheredKeyValue = {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CommonParams, Response } from '../params';
|
|
2
|
+
|
|
3
|
+
export type DeviceVerifyParams = {
|
|
4
|
+
dataHex: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type DeviceVerifySignature = {
|
|
8
|
+
cert: Buffer;
|
|
9
|
+
signature: Buffer;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export declare function deviceVerify(
|
|
13
|
+
connectId: string,
|
|
14
|
+
params: CommonParams & DeviceVerifyParams
|
|
15
|
+
): Response<DeviceVerifySignature>;
|