@onekeyfe/hd-core 1.0.36-alpha.1 → 1.0.37-alpha.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.
- package/dist/api/GetPassphraseState.d.ts +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddress.d.ts +3 -1
- package/dist/api/allnetwork/AllNetworkGetAddress.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts +7 -0
- package/dist/api/device/DeviceUnlock.d.ts.map +1 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/device/Device.d.ts +9 -4
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +7 -5
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/events/device.d.ts +3 -0
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +2 -1
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/events/ui-response.d.ts +1 -0
- package/dist/events/ui-response.d.ts.map +1 -1
- package/dist/index.d.ts +28 -11
- package/dist/index.js +213 -68
- package/dist/inject.d.ts.map +1 -1
- package/dist/types/api/deviceUnlock.d.ts +4 -0
- package/dist/types/api/deviceUnlock.d.ts.map +1 -0
- package/dist/types/api/index.d.ts +2 -0
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/params.d.ts +1 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +1 -1
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +16 -2
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/logger.d.ts +2 -0
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdate.ts +1 -1
- package/src/api/GetPassphraseState.ts +4 -4
- package/src/api/allnetwork/AllNetworkGetAddress.ts +18 -20
- package/src/api/device/DeviceUnlock.ts +26 -0
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +2 -2
- package/src/api/index.ts +1 -0
- package/src/api/stellar/StellarSignTransaction.ts +0 -3
- package/src/core/index.ts +17 -8
- package/src/data/messages/messages.json +49 -2
- package/src/data-manager/DataManager.ts +1 -1
- package/src/data-manager/TransportManager.ts +3 -0
- package/src/device/Device.ts +92 -20
- package/src/device/DeviceCommands.ts +15 -5
- package/src/events/device.ts +4 -0
- package/src/events/ui-request.ts +2 -1
- package/src/events/ui-response.ts +1 -0
- package/src/inject.ts +2 -0
- package/src/types/api/deviceUnlock.ts +4 -0
- package/src/types/api/index.ts +2 -0
- package/src/types/params.ts +5 -0
- package/src/types/settings.ts +10 -1
- package/src/utils/deviceFeaturesUtils.ts +72 -8
- package/src/utils/logger.ts +2 -0
|
@@ -73,11 +73,24 @@ export const supportNewPassphrase = (features?: Features): SupportFeatureType =>
|
|
|
73
73
|
return { support: semver.gte(currentVersion, '2.4.0'), require: '2.4.0' };
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
76
|
+
export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
77
|
+
device: Device,
|
|
78
|
+
options?: {
|
|
79
|
+
expectPassphraseState?: string;
|
|
80
|
+
onlyMainPin?: boolean;
|
|
81
|
+
}
|
|
82
|
+
) => {
|
|
77
83
|
const { features, commands } = device;
|
|
78
84
|
const locked = features?.unlocked === false;
|
|
79
85
|
|
|
80
|
-
const passphraseState = await getPassphraseState(
|
|
86
|
+
const { passphraseState, newSession, unlockedAttachPin } = await getPassphraseState(
|
|
87
|
+
features,
|
|
88
|
+
commands,
|
|
89
|
+
{
|
|
90
|
+
...options,
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
|
|
81
94
|
const isModeT =
|
|
82
95
|
getDeviceType(features) === EDeviceType.Touch || getDeviceType(features) === EDeviceType.Pro;
|
|
83
96
|
|
|
@@ -93,14 +106,55 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (device: Device) =>
|
|
|
93
106
|
await device.getFeatures();
|
|
94
107
|
}
|
|
95
108
|
|
|
96
|
-
|
|
109
|
+
// Attach to pin try to fix internal state
|
|
110
|
+
if (features?.device_id) {
|
|
111
|
+
device.updateInternalState(
|
|
112
|
+
device.features?.passphrase_protection ?? false,
|
|
113
|
+
passphraseState,
|
|
114
|
+
device.features?.device_id ?? '',
|
|
115
|
+
newSession,
|
|
116
|
+
device.features?.session_id
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return { passphraseState, newSession, unlockedAttachPin };
|
|
97
121
|
};
|
|
98
122
|
|
|
99
123
|
export const getPassphraseState = async (
|
|
100
124
|
features: Features | undefined,
|
|
101
|
-
commands: DeviceCommands
|
|
102
|
-
|
|
103
|
-
|
|
125
|
+
commands: DeviceCommands,
|
|
126
|
+
options?: {
|
|
127
|
+
expectPassphraseState?: string;
|
|
128
|
+
onlyMainPin?: boolean;
|
|
129
|
+
}
|
|
130
|
+
): Promise<{
|
|
131
|
+
passphraseState: string | undefined;
|
|
132
|
+
newSession: string | undefined;
|
|
133
|
+
unlockedAttachPin: boolean | undefined;
|
|
134
|
+
}> => {
|
|
135
|
+
if (!features)
|
|
136
|
+
return { passphraseState: undefined, newSession: undefined, unlockedAttachPin: undefined };
|
|
137
|
+
|
|
138
|
+
const firmwareVersion = getDeviceFirmwareVersion(features);
|
|
139
|
+
const deviceType = getDeviceType(features);
|
|
140
|
+
|
|
141
|
+
if (deviceType === EDeviceType.Pro && semver.gte(firmwareVersion.join('.'), '4.15.0')) {
|
|
142
|
+
const { message, type } = await commands.typedCall('GetPassphraseState', 'PassphraseState', {
|
|
143
|
+
passphrase_state: options?.onlyMainPin ? undefined : options?.expectPassphraseState,
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// @ts-expect-error
|
|
147
|
+
if (type === 'CallMethodError') {
|
|
148
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Get the passphrase state error');
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
passphraseState: message.passphrase_state,
|
|
153
|
+
newSession: message.session_id,
|
|
154
|
+
unlockedAttachPin: message.unlocked_attach_pin,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
104
158
|
const { message, type } = await commands.typedCall('GetAddress', 'Address', {
|
|
105
159
|
address_n: [toHardened(44), toHardened(1), toHardened(0), 0, 0],
|
|
106
160
|
coin_name: 'Testnet',
|
|
@@ -113,7 +167,11 @@ export const getPassphraseState = async (
|
|
|
113
167
|
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Get the passphrase state error');
|
|
114
168
|
}
|
|
115
169
|
|
|
116
|
-
return
|
|
170
|
+
return {
|
|
171
|
+
passphraseState: message.address,
|
|
172
|
+
newSession: undefined,
|
|
173
|
+
unlockedAttachPin: undefined,
|
|
174
|
+
};
|
|
117
175
|
};
|
|
118
176
|
|
|
119
177
|
export const supportBatchPublicKey = (
|
|
@@ -130,12 +188,18 @@ export const supportBatchPublicKey = (
|
|
|
130
188
|
if (!!options?.includeNode && deviceType === EDeviceType.Pro) {
|
|
131
189
|
return semver.gte(currentVersion, '4.14.0');
|
|
132
190
|
}
|
|
191
|
+
if (!!options?.includeNode && deviceType === EDeviceType.Touch) {
|
|
192
|
+
return semver.gte(currentVersion, '4.11.0');
|
|
193
|
+
}
|
|
133
194
|
if (!!options?.includeNode && DeviceModelToTypes.model_classic1s.includes(deviceType)) {
|
|
134
195
|
return semver.gte(currentVersion, '3.12.0');
|
|
135
196
|
}
|
|
136
|
-
if (!!options?.includeNode && deviceType
|
|
197
|
+
if (!!options?.includeNode && DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
137
198
|
return semver.gte(currentVersion, '3.10.0');
|
|
138
199
|
}
|
|
200
|
+
if (options?.includeNode) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
139
203
|
|
|
140
204
|
// support batch get public key
|
|
141
205
|
if (deviceType === EDeviceType.Touch || deviceType === EDeviceType.Pro) {
|
package/src/utils/logger.ts
CHANGED
|
@@ -157,6 +157,7 @@ export enum LoggerNames {
|
|
|
157
157
|
HdTransportHttp = '@onekey/hd-transport-http',
|
|
158
158
|
HdTransportLowLevel = '@onekey/hd-transport-lowlevel',
|
|
159
159
|
HdBleTransport = '@onekey/hd-ble-transport',
|
|
160
|
+
HdWebBleTransport = '@onekey/hd-web-ble-transport',
|
|
160
161
|
Connect = '@onekey/connect',
|
|
161
162
|
Iframe = 'IFrame',
|
|
162
163
|
SendMessage = '[SendMessage]',
|
|
@@ -174,6 +175,7 @@ export const LoggerMap = {
|
|
|
174
175
|
[LoggerNames.HdBleSdk]: initLog(LoggerNames.HdBleSdk),
|
|
175
176
|
[LoggerNames.HdTransportHttp]: initLog(LoggerNames.HdTransportHttp),
|
|
176
177
|
[LoggerNames.HdBleTransport]: initLog(LoggerNames.HdBleTransport),
|
|
178
|
+
[LoggerNames.HdWebBleTransport]: initLog(LoggerNames.HdWebBleTransport),
|
|
177
179
|
[LoggerNames.HdTransportLowLevel]: initLog(LoggerNames.HdTransportLowLevel),
|
|
178
180
|
[LoggerNames.Connect]: initLog(LoggerNames.Connect),
|
|
179
181
|
[LoggerNames.Iframe]: initLog(LoggerNames.Iframe),
|