@onekeyfe/hd-core 1.0.38-alpha.0 → 1.0.39-alpha.1
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 +27 -12
- package/dist/index.js +198 -71
- 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 +0 -2
- 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/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 +0 -3
- 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 +1 -9
- package/src/utils/deviceFeaturesUtils.ts +65 -7
- package/src/utils/logger.ts +0 -2
|
@@ -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 = (
|
package/src/utils/logger.ts
CHANGED
|
@@ -157,7 +157,6 @@ 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',
|
|
161
160
|
Connect = '@onekey/connect',
|
|
162
161
|
Iframe = 'IFrame',
|
|
163
162
|
SendMessage = '[SendMessage]',
|
|
@@ -175,7 +174,6 @@ export const LoggerMap = {
|
|
|
175
174
|
[LoggerNames.HdBleSdk]: initLog(LoggerNames.HdBleSdk),
|
|
176
175
|
[LoggerNames.HdTransportHttp]: initLog(LoggerNames.HdTransportHttp),
|
|
177
176
|
[LoggerNames.HdBleTransport]: initLog(LoggerNames.HdBleTransport),
|
|
178
|
-
[LoggerNames.HdWebBleTransport]: initLog(LoggerNames.HdWebBleTransport),
|
|
179
177
|
[LoggerNames.HdTransportLowLevel]: initLog(LoggerNames.HdTransportLowLevel),
|
|
180
178
|
[LoggerNames.Connect]: initLog(LoggerNames.Connect),
|
|
181
179
|
[LoggerNames.Iframe]: initLog(LoggerNames.Iframe),
|