@onekeyfe/hd-core 1.2.2-alpha.1 → 1.2.2-alpha.100
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/__tests__/AllNetworkGetAddressBase.tracing.test.ts +4 -20
- package/__tests__/DeviceCommands.test.ts +0 -13
- package/__tests__/check-all-firmware-release-protocol-v2.test.ts +2 -0
- package/__tests__/check-firmware-release-protocol-v2.test.ts +2 -0
- package/__tests__/device-lifecycle-events.test.ts +0 -19
- package/__tests__/deviceUploadNft.test.ts +0 -68
- package/__tests__/evmSignTypedData.test.ts +0 -42
- package/__tests__/firmware-update/firmware-update-v4-install-poll.test.ts +12 -825
- package/__tests__/open-wallet-session.test.ts +1 -127
- package/__tests__/protocol-v2-resources.test.ts +4 -7
- package/__tests__/protocol-v2-unlock-policy.test.ts +1 -35
- package/__tests__/protocol-v2.test.ts +27 -710
- package/dist/api/FirmwareUpdateV4.d.ts +0 -4
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +2 -2
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +2 -2
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
- package/dist/core/index.d.ts +0 -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/device/DeviceConnector.d.ts +1 -1
- package/dist/device/DeviceConnector.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +0 -3
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +5 -21
- package/dist/index.js +402 -1136
- package/dist/protocols/protocol-v2/resources.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts +0 -2
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts +0 -3
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/types/settings.d.ts +2 -2
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +0 -3
- package/dist/utils/deviceFeaturesUtils.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/FirmwareUpdateV4.ts +75 -434
- package/src/api/OpenWalletSession.ts +9 -39
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +1 -2
- package/src/api/evm/EVMSignTypedData.ts +0 -1
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +3 -9
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +1 -7
- package/src/api/protocol-v2/DeviceUploadNft.ts +8 -31
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +8 -27
- package/src/api/protocol-v2/helpers.ts +0 -8
- package/src/core/index.ts +10 -121
- package/src/data/messages/messages-protocol-v2.json +1 -111
- package/src/device/Device.ts +1 -3
- package/src/device/DeviceConnector.ts +3 -7
- package/src/events/ui-request.ts +0 -3
- package/src/protocols/protocol-v2/resources.ts +1 -9
- package/src/protocols/protocol-v2/unlockPolicyRunner.ts +1 -8
- package/src/protocols/protocol-v2/walletSession.ts +22 -65
- package/src/types/settings.ts +2 -4
- package/src/utils/deviceFeaturesUtils.ts +0 -4
- package/__tests__/pro2HostAssetPackage.test.ts +0 -58
- package/dist/utils/pro2HostAssetPackage.d.ts +0 -8
- package/dist/utils/pro2HostAssetPackage.d.ts.map +0 -1
- package/src/utils/pro2HostAssetPackage.ts +0 -354
|
@@ -148,7 +148,7 @@ describe('openWalletSession', () => {
|
|
|
148
148
|
});
|
|
149
149
|
});
|
|
150
150
|
|
|
151
|
-
test('
|
|
151
|
+
test('opens the standard wallet directly when passphrase is disabled', async () => {
|
|
152
152
|
const typedCall = jest.fn((request: string) => {
|
|
153
153
|
if (request === 'ProtocolInfoRequest') {
|
|
154
154
|
return { message: { version: 2 } };
|
|
@@ -167,11 +167,6 @@ describe('openWalletSession', () => {
|
|
|
167
167
|
|
|
168
168
|
await getProtocolV2WalletSession(device as any, { onlyMainPin: true });
|
|
169
169
|
|
|
170
|
-
expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main, {
|
|
171
|
-
source: 'wallet-session-coordinator',
|
|
172
|
-
reason: 'open-wallet',
|
|
173
|
-
deviceOnly: true,
|
|
174
|
-
});
|
|
175
170
|
expect(typedCall).not.toHaveBeenCalledWith(
|
|
176
171
|
'DeviceSessionAskPassphrase',
|
|
177
172
|
'Success',
|
|
@@ -182,34 +177,6 @@ describe('openWalletSession', () => {
|
|
|
182
177
|
});
|
|
183
178
|
});
|
|
184
179
|
|
|
185
|
-
test('reuses a Main PIN selected by the current preflight when passphrase is disabled', async () => {
|
|
186
|
-
const typedCall = jest.fn((request: string) => {
|
|
187
|
-
if (request === 'ProtocolInfoRequest') {
|
|
188
|
-
return { message: { version: 2 } };
|
|
189
|
-
}
|
|
190
|
-
if (request === 'DeviceSessionGet') {
|
|
191
|
-
return {
|
|
192
|
-
message: {
|
|
193
|
-
btc_test_address: 'standard-state',
|
|
194
|
-
session_id: 'standard-session',
|
|
195
|
-
},
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
throw new Error(`Unexpected request: ${request}`);
|
|
199
|
-
});
|
|
200
|
-
const device = createDevice({ passphraseProtection: false, typedCall });
|
|
201
|
-
|
|
202
|
-
await getProtocolV2WalletSession(device as any, {
|
|
203
|
-
onlyMainPin: true,
|
|
204
|
-
mainPinSelected: true,
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
expect(device.unlockDevice).not.toHaveBeenCalled();
|
|
208
|
-
expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
|
|
209
|
-
seed_domains: [],
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
|
|
213
180
|
test('does not treat an Attach PIN DeviceStatus as the Main wallet', async () => {
|
|
214
181
|
const typedCall = jest.fn((request: string) => {
|
|
215
182
|
if (request === 'ProtocolInfoRequest') {
|
|
@@ -1147,68 +1114,6 @@ describe('openWalletSession', () => {
|
|
|
1147
1114
|
expect(device.getDeviceState).toHaveBeenCalledTimes(2);
|
|
1148
1115
|
});
|
|
1149
1116
|
|
|
1150
|
-
test('does not restrict a locked hidden-wallet selection to the Main PIN', async () => {
|
|
1151
|
-
const typedCall = jest
|
|
1152
|
-
.fn()
|
|
1153
|
-
.mockResolvedValueOnce({ message: { version: 2 } })
|
|
1154
|
-
.mockResolvedValueOnce({ message: {} })
|
|
1155
|
-
.mockResolvedValueOnce({
|
|
1156
|
-
message: {
|
|
1157
|
-
btc_test_address: 'hidden-state',
|
|
1158
|
-
session_id: 'hidden-session',
|
|
1159
|
-
},
|
|
1160
|
-
});
|
|
1161
|
-
const promptPassphrase = jest.fn().mockResolvedValue({ passphrase: 'host hidden wallet' });
|
|
1162
|
-
const method = new OpenWalletSession({
|
|
1163
|
-
payload: { method: 'openWalletSession', connectId: 'connect-id', mode: 'select-hidden' },
|
|
1164
|
-
});
|
|
1165
|
-
method.init();
|
|
1166
|
-
const device = createDevice({ typedCall, promptPassphrase });
|
|
1167
|
-
device.features.unlocked = false;
|
|
1168
|
-
device.getDeviceState = jest
|
|
1169
|
-
.fn()
|
|
1170
|
-
.mockResolvedValueOnce({
|
|
1171
|
-
identity: { deviceId: undefined },
|
|
1172
|
-
status: { unlocked: false, passphraseProtection: true },
|
|
1173
|
-
})
|
|
1174
|
-
.mockResolvedValueOnce({
|
|
1175
|
-
identity: { deviceId: 'device-1' },
|
|
1176
|
-
status: {
|
|
1177
|
-
unlocked: true,
|
|
1178
|
-
passphraseProtection: true,
|
|
1179
|
-
unlockedAttachPin: false,
|
|
1180
|
-
},
|
|
1181
|
-
})
|
|
1182
|
-
.mockResolvedValueOnce({
|
|
1183
|
-
identity: { deviceId: 'device-1' },
|
|
1184
|
-
status: {
|
|
1185
|
-
unlocked: true,
|
|
1186
|
-
passphraseProtection: true,
|
|
1187
|
-
unlockedAttachPin: false,
|
|
1188
|
-
},
|
|
1189
|
-
});
|
|
1190
|
-
device.unlockDevice = jest.fn().mockImplementation(() => {
|
|
1191
|
-
device.features.unlocked = true;
|
|
1192
|
-
return Promise.resolve(device.features);
|
|
1193
|
-
});
|
|
1194
|
-
method.device = device as any;
|
|
1195
|
-
|
|
1196
|
-
await expect(method.run()).resolves.toMatchObject({
|
|
1197
|
-
walletType: 'hidden',
|
|
1198
|
-
passphraseState: 'hidden-state',
|
|
1199
|
-
});
|
|
1200
|
-
expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Any, {
|
|
1201
|
-
source: 'unlock-coordinator',
|
|
1202
|
-
reason: 'device-locked',
|
|
1203
|
-
deviceOnly: true,
|
|
1204
|
-
method: 'openWalletSession',
|
|
1205
|
-
});
|
|
1206
|
-
expect(device.unlockDevice).not.toHaveBeenCalledWith(
|
|
1207
|
-
DeviceSessionPinType.Main,
|
|
1208
|
-
expect.anything()
|
|
1209
|
-
);
|
|
1210
|
-
});
|
|
1211
|
-
|
|
1212
1117
|
test('switches from Attach PIN to Main PIN before opening the standard wallet', async () => {
|
|
1213
1118
|
const typedCall = jest
|
|
1214
1119
|
.fn()
|
|
@@ -1303,37 +1208,6 @@ describe('openWalletSession', () => {
|
|
|
1303
1208
|
expect(deviceWalletSessionStore.get('device-1', 'hidden-state')).toBe('hidden-session');
|
|
1304
1209
|
});
|
|
1305
1210
|
|
|
1306
|
-
test('reuses the fresh unlock and wallet-selection statuses', async () => {
|
|
1307
|
-
const typedCall = jest
|
|
1308
|
-
.fn()
|
|
1309
|
-
.mockResolvedValueOnce({ message: { version: 2 } })
|
|
1310
|
-
.mockResolvedValueOnce({ message: {} })
|
|
1311
|
-
.mockResolvedValueOnce({
|
|
1312
|
-
message: {
|
|
1313
|
-
btc_test_address: 'hidden-state',
|
|
1314
|
-
session_id: 'hidden-session',
|
|
1315
|
-
},
|
|
1316
|
-
});
|
|
1317
|
-
const promptPassphrase = jest.fn().mockResolvedValue({ passphrase: 'host hidden wallet' });
|
|
1318
|
-
const method = new OpenWalletSession({
|
|
1319
|
-
payload: { method: 'openWalletSession', connectId: 'connect-id', mode: 'select-hidden' },
|
|
1320
|
-
});
|
|
1321
|
-
method.init();
|
|
1322
|
-
method.protocolV2UnlockContext = {
|
|
1323
|
-
preflightCompleted: true,
|
|
1324
|
-
preflightStatusRefreshed: true,
|
|
1325
|
-
};
|
|
1326
|
-
const device = createDevice({ typedCall, promptPassphrase });
|
|
1327
|
-
method.device = device as any;
|
|
1328
|
-
|
|
1329
|
-
await expect(method.run()).resolves.toMatchObject({
|
|
1330
|
-
walletType: 'hidden',
|
|
1331
|
-
passphraseState: 'hidden-state',
|
|
1332
|
-
});
|
|
1333
|
-
|
|
1334
|
-
expect(device.getDeviceState.mock.calls).toEqual([[], []]);
|
|
1335
|
-
});
|
|
1336
|
-
|
|
1337
1211
|
test('gets the prepared session after host passphrase entry', async () => {
|
|
1338
1212
|
const typedCall = jest
|
|
1339
1213
|
.fn()
|
|
@@ -66,6 +66,8 @@ const createRemoteConfig = (): RemoteConfigResponse =>
|
|
|
66
66
|
{
|
|
67
67
|
required: false,
|
|
68
68
|
version: [1, 0, 0],
|
|
69
|
+
url: 'https://example.com/pro2.okpkg',
|
|
70
|
+
fingerprint: 'a'.repeat(64),
|
|
69
71
|
changelog: { 'zh-CN': 'Pro2', 'en-US': 'Pro2' },
|
|
70
72
|
resources: { source: resourceSource },
|
|
71
73
|
},
|
|
@@ -77,6 +79,8 @@ const createRemoteConfig = (): RemoteConfigResponse =>
|
|
|
77
79
|
{
|
|
78
80
|
required: false,
|
|
79
81
|
version: [1, 0, 0],
|
|
82
|
+
url: 'https://example.com/neo.okpkg',
|
|
83
|
+
fingerprint: 'b'.repeat(64),
|
|
80
84
|
changelog: { 'zh-CN': 'Neo', 'en-US': 'Neo' },
|
|
81
85
|
resources: { source: neoResourceSource },
|
|
82
86
|
},
|
|
@@ -105,11 +109,6 @@ describe('Pro2 resource configuration', () => {
|
|
|
105
109
|
expect(
|
|
106
110
|
isProtocolV2ResourceArchiveEntryName('bundles/firmware_logo-pro2-prod_resource-signed.okpkg')
|
|
107
111
|
).toBe(true);
|
|
108
|
-
expect(
|
|
109
|
-
isProtocolV2ResourceArchiveEntryName(
|
|
110
|
-
'pro2-prod_resource/bundles/firmware_logo-pro2-prod_resource-signed.okpkg'
|
|
111
|
-
)
|
|
112
|
-
).toBe(true);
|
|
113
112
|
expect(
|
|
114
113
|
isProtocolV2ResourceArchiveEntryName(
|
|
115
114
|
'__MACOSX/pro2-prod_resource 2/bundles/._firmware_logo-pro2-prod_resource-signed.okpkg'
|
|
@@ -120,8 +119,6 @@ describe('Pro2 resource configuration', () => {
|
|
|
120
119
|
'bundles/._firmware_logo-pro2-prod_resource-signed.okpkg'
|
|
121
120
|
)
|
|
122
121
|
).toBe(false);
|
|
123
|
-
expect(isProtocolV2ResourceArchiveEntryName('pro2-prod_resource/manifest.json')).toBe(false);
|
|
124
|
-
expect(isProtocolV2ResourceArchiveEntryName('pro2-prod_resource/.DS_Store')).toBe(false);
|
|
125
122
|
});
|
|
126
123
|
|
|
127
124
|
test('reads the version, hashes, and direct device path from a RESC package', () => {
|
|
@@ -151,42 +151,8 @@ describe('Protocol V2 unlock semantics', () => {
|
|
|
151
151
|
});
|
|
152
152
|
|
|
153
153
|
expect(method.unlockPolicy).toBe('unlock-before-run');
|
|
154
|
-
expect(device.unlockDevice).
|
|
154
|
+
expect(device.unlockDevice).toHaveBeenCalledTimes(1);
|
|
155
155
|
expect(run).toHaveBeenCalledTimes(1);
|
|
156
|
-
expect(method.protocolV2UnlockContext).toMatchObject({
|
|
157
|
-
preflightCompleted: true,
|
|
158
|
-
preflightStatusRefreshed: true,
|
|
159
|
-
preflightMainPinSelected: true,
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
test('allows either PIN type when pre-unlocking hidden-wallet selection', async () => {
|
|
164
|
-
const method = new OpenWalletSession({
|
|
165
|
-
id: 1,
|
|
166
|
-
payload: { method: 'openWalletSession', mode: 'select-hidden' },
|
|
167
|
-
});
|
|
168
|
-
method.init();
|
|
169
|
-
method.run = jest.fn().mockResolvedValue({ walletType: 'hidden' }) as any;
|
|
170
|
-
const features = { unlocked: false };
|
|
171
|
-
const device = {
|
|
172
|
-
features,
|
|
173
|
-
commands: {
|
|
174
|
-
typedCall: jest.fn().mockResolvedValue({ message: { unlocked: false } }),
|
|
175
|
-
},
|
|
176
|
-
isProtocolV2: () => true,
|
|
177
|
-
isBootloader: () => false,
|
|
178
|
-
isRomloader: () => false,
|
|
179
|
-
updateProtocolV2Status: jest.fn(() => features),
|
|
180
|
-
unlockDevice: jest.fn().mockImplementation(() => {
|
|
181
|
-
features.unlocked = true;
|
|
182
|
-
return Promise.resolve(features);
|
|
183
|
-
}),
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
await runMethodWithUnlockPolicy(method, device as any);
|
|
187
|
-
|
|
188
|
-
expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Any, expect.any(Object));
|
|
189
|
-
expect(method.protocolV2UnlockContext?.preflightMainPinSelected).toBe(false);
|
|
190
156
|
});
|
|
191
157
|
|
|
192
158
|
test('pre-unlocks an unregistered wallet business method', async () => {
|