@onekeyfe/hd-core 1.2.0-alpha.56 → 1.2.0-alpha.62
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 +0 -231
- package/__tests__/DeviceCommands.test.ts +0 -45
- package/__tests__/DeviceEventRegistration.test.ts +0 -6
- package/__tests__/check-all-firmware-release-protocol-v2.test.ts +3 -198
- package/__tests__/connectSettings.test.ts +47 -5
- package/__tests__/device-initialize-timeout.test.ts +56 -0
- package/__tests__/device-lifecycle-events.test.ts +3 -105
- package/__tests__/device-state-contract.test.ts +0 -1
- package/__tests__/device-state-mapper.test.ts +1 -1
- package/__tests__/deviceSettings.test.ts +1 -1
- package/__tests__/firmware-update/check-all-firmware-release.test.ts +175 -0
- package/__tests__/firmware-update/firmware-artifact-source.test.ts +119 -0
- package/__tests__/firmware-update/firmware-host-binding.test.ts +70 -0
- package/__tests__/firmware-update/firmware-preparation-error.test.ts +27 -0
- package/__tests__/firmware-update/firmware-update-bootloader-poll.test.ts +200 -0
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +13 -0
- package/__tests__/firmware-update/firmware-update-plan-bootloader-identity.test.ts +294 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +593 -0
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +213 -0
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +59 -31
- package/__tests__/firmware-update/firmware-update-v3-reconnect.test.ts +58 -0
- package/__tests__/firmware-update/firmware-upload-source.test.ts +70 -0
- package/__tests__/get-device-state.test.ts +12 -132
- package/__tests__/homescreen.test.ts +1 -41
- package/__tests__/kaspaSignTransaction.test.ts +26 -3
- package/__tests__/logBlockEvent.test.ts +1 -1
- package/__tests__/method-protocol-support.test.ts +0 -19
- package/__tests__/open-wallet-session.test.ts +37 -568
- package/__tests__/protocol-v2-unlock-policy.test.ts +35 -201
- package/__tests__/protocol-v2.test.ts +1046 -1388
- package/__tests__/protocolV2FileWrite.test.ts +0 -39
- package/__tests__/protocolV2UiInteraction.test.ts +0 -63
- package/__tests__/public-pro2-api-boundary.test.ts +0 -1
- package/__tests__/search-devices.test.ts +3 -12
- package/dist/api/BaseMethod.d.ts +1 -3
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts +1 -2
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +11 -0
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +7 -3
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +25 -11
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.d.ts.map +1 -1
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts +2 -2
- package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts +5 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareArtifactSource.d.ts +25 -0
- package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts +6 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -0
- package/dist/api/firmware/FirmwarePreparationError.d.ts +3 -0
- package/dist/api/firmware/FirmwarePreparationError.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +9 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +3 -0
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +25 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +32 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/api/firmware/getBinary.d.ts +7 -0
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/progressThrottle.d.ts +3 -0
- package/dist/api/firmware/progressThrottle.d.ts.map +1 -0
- package/dist/api/firmware/updateBootloader.d.ts +2 -0
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts +9 -1
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts +0 -2
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
- package/dist/api/index.d.ts +0 -2
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -1
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
- package/dist/core/deviceEventRegistration.d.ts +0 -2
- package/dist/core/deviceEventRegistration.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +2 -4
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/Device.d.ts +6 -29
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +4 -4
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DevicePool.d.ts.map +1 -1
- package/dist/events/device.d.ts +0 -4
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/events/ui-promise.d.ts +2 -4
- package/dist/events/ui-promise.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +2 -31
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/events/ui-response.d.ts +2 -10
- package/dist/events/ui-response.d.ts.map +1 -1
- package/dist/index.d.ts +231 -214
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3530 -2634
- package/dist/inject.d.ts +1 -6
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/features.d.ts +4 -0
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/lockedError.d.ts +2 -0
- package/dist/protocols/protocol-v2/lockedError.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +4 -7
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts +3 -1
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockRetry.d.ts +10 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts +1 -6
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/topLevelInject.d.ts.map +1 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts +4 -2
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/deviceUnlock.d.ts +1 -5
- package/dist/types/api/deviceUnlock.d.ts.map +1 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts +6 -0
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +4 -2
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +70 -2
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdateCapabilities.d.ts +9 -0
- package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts +28 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +42 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/types/api/index.d.ts +10 -7
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +0 -3
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +0 -1
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +13 -22
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesCompat.d.ts +1 -0
- package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +0 -4
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/homescreen.d.ts +0 -4
- package/dist/utils/homescreen.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/dist/utils/pro2Wallpaper.d.ts +0 -10
- package/dist/utils/pro2Wallpaper.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +10 -8
- package/src/api/CheckAllFirmwareRelease.ts +57 -54
- package/src/api/FirmwareUpdate.ts +15 -7
- package/src/api/FirmwareUpdateV2.ts +316 -126
- package/src/api/FirmwareUpdateV3.ts +265 -63
- package/src/api/FirmwareUpdateV4.ts +975 -584
- package/src/api/GetPassphraseState.ts +1 -7
- package/src/api/OpenWalletSession.ts +17 -70
- package/src/api/SearchDevices.ts +1 -3
- package/src/api/allnetwork/AllNetworkGetAddress.ts +21 -21
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +11 -34
- package/src/api/device/DeviceUnlock.ts +3 -8
- package/src/api/device/DeviceUpdateBootloader.ts +122 -6
- package/src/api/firmware/FirmwareArtifactSource.ts +278 -0
- package/src/api/firmware/FirmwareHostBinding.ts +100 -0
- package/src/api/firmware/FirmwarePreparationError.ts +12 -0
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +83 -16
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +772 -0
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +415 -0
- package/src/api/firmware/progressThrottle.ts +44 -0
- package/src/api/firmware/updateBootloader.ts +19 -4
- package/src/api/firmware/uploadFirmware.ts +144 -39
- package/src/api/helpers/protocolV2FileWrite.ts +7 -27
- package/src/api/index.ts +0 -2
- package/src/api/kaspa/KaspaSignTransaction.ts +12 -1
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +1 -3
- package/src/api/protocol-v2/helpers.ts +0 -1
- package/src/core/deviceEventRegistration.ts +0 -4
- package/src/core/index.ts +83 -167
- package/src/data/messages/messages-protocol-v2.json +0 -25
- package/src/data-manager/DataManager.ts +39 -71
- package/src/data-manager/connectSettings.ts +11 -0
- package/src/device/Device.ts +43 -259
- package/src/device/DeviceCommands.ts +1 -7
- package/src/device/DevicePool.ts +2 -7
- package/src/events/device.ts +0 -4
- package/src/events/logBlockEvent.ts +0 -1
- package/src/events/ui-promise.ts +2 -4
- package/src/events/ui-request.ts +2 -36
- package/src/events/ui-response.ts +2 -12
- package/src/index.ts +5 -0
- package/src/inject.ts +24 -60
- package/src/lowLevelInject.ts +8 -7
- package/src/protocols/protocol-v2/features.ts +7 -10
- package/src/protocols/protocol-v2/firmware.ts +0 -2
- package/src/protocols/protocol-v2/lockedError.ts +10 -0
- package/src/protocols/protocol-v2/uiInteraction.ts +6 -46
- package/src/protocols/protocol-v2/unlockPolicy.ts +105 -1
- package/src/protocols/protocol-v2/unlockRetry.ts +109 -0
- package/src/protocols/protocol-v2/walletSession.ts +36 -214
- package/src/topLevelInject.ts +8 -7
- package/src/types/api/checkAllFirmwareRelease.ts +4 -2
- package/src/types/api/deviceUnlock.ts +1 -12
- package/src/types/api/deviceUpdateBootloader.ts +6 -0
- package/src/types/api/export.ts +18 -1
- package/src/types/api/firmwareUpdate.ts +76 -3
- package/src/types/api/firmwareUpdateCapabilities.ts +9 -0
- package/src/types/api/firmwareUpdatePlan.ts +38 -0
- package/src/types/api/firmwareUpdatePreparedPlan.ts +53 -0
- package/src/types/api/index.ts +14 -13
- package/src/types/api/protocolV2.ts +0 -13
- package/src/types/device.ts +0 -3
- package/src/types/params.ts +1 -7
- package/src/types/settings.ts +13 -42
- package/src/utils/deviceFeaturesCompat.ts +6 -0
- package/src/utils/deviceFeaturesUtils.ts +0 -8
- package/src/utils/homescreen.ts +6 -32
- package/src/utils/index.ts +1 -6
- package/src/utils/pro2Wallpaper.ts +8 -35
- package/__tests__/deviceUploadNft.test.ts +0 -293
- package/__tests__/pro2Nft.test.ts +0 -108
- package/__tests__/protocol-binding.test.ts +0 -89
- package/__tests__/protocol-v2-resources.test.ts +0 -286
- package/__tests__/protocol-v2-ui-lifecycle.test.ts +0 -91
- package/__tests__/uiProgressThrottle.test.ts +0 -74
- package/__tests__/uiPromiseRegistry.test.ts +0 -86
- package/dist/api/DetectDeviceConnectProtocol.d.ts +0 -7
- package/dist/api/DetectDeviceConnectProtocol.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts +0 -31
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +0 -1
- package/dist/core/uiPromiseRegistry.d.ts +0 -4
- package/dist/core/uiPromiseRegistry.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/resources.d.ts +0 -30
- package/dist/protocols/protocol-v2/resources.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts +0 -22
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts.map +0 -1
- package/dist/types/api/detectDeviceConnectProtocol.d.ts +0 -4
- package/dist/types/api/detectDeviceConnectProtocol.d.ts.map +0 -1
- package/dist/utils/pro2Nft.d.ts +0 -31
- package/dist/utils/pro2Nft.d.ts.map +0 -1
- package/dist/utils/uiProgressThrottle.d.ts +0 -3
- package/dist/utils/uiProgressThrottle.d.ts.map +0 -1
- package/src/api/DetectDeviceConnectProtocol.ts +0 -18
- package/src/api/protocol-v2/DeviceUploadNft.ts +0 -189
- package/src/core/uiPromiseRegistry.ts +0 -41
- package/src/protocols/protocol-v2/resources.ts +0 -359
- package/src/protocols/protocol-v2/unlockPolicyRunner.ts +0 -118
- package/src/types/api/detectDeviceConnectProtocol.ts +0 -6
- package/src/utils/pro2Nft.ts +0 -142
- package/src/utils/uiProgressThrottle.ts +0 -63
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
import { sha256 } from '@noble/hashes/sha256';
|
|
3
|
-
import { HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
4
|
-
|
|
5
|
-
import { DataManager } from '../src/data-manager';
|
|
6
|
-
import {
|
|
7
|
-
PROTOCOL_V2_RESOURCE_DEVICE_PATHS,
|
|
8
|
-
PROTOCOL_V2_RESOURCE_TYPES,
|
|
9
|
-
buildProtocolV2ResourceUpdatePlan,
|
|
10
|
-
isProtocolV2ResourceFileValid,
|
|
11
|
-
parseProtocolV2Resources,
|
|
12
|
-
readProtocolV2ResourceInventory,
|
|
13
|
-
} from '../src/protocols/protocol-v2/resources';
|
|
14
|
-
|
|
15
|
-
import type {
|
|
16
|
-
ConnectSettings,
|
|
17
|
-
IProtocolV2BootResources,
|
|
18
|
-
IProtocolV2Resource,
|
|
19
|
-
RemoteConfigResponse,
|
|
20
|
-
} from '../src/types';
|
|
21
|
-
|
|
22
|
-
jest.mock('axios');
|
|
23
|
-
jest.mock('../src/data/config', () => ({
|
|
24
|
-
getSDKVersion: jest.fn(() => '1.0.0-test'),
|
|
25
|
-
DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0-test/',
|
|
26
|
-
}));
|
|
27
|
-
|
|
28
|
-
const bytesToHex = (bytes: Uint8Array) =>
|
|
29
|
-
Array.from(bytes, byte => byte.toString(16).padStart(2, '0')).join('');
|
|
30
|
-
|
|
31
|
-
const PROTOCOL_V2_OKPP_HEADER_SIZE = 0x52a0;
|
|
32
|
-
|
|
33
|
-
const createResourceHeader = (headerHash: string) => {
|
|
34
|
-
const header = new Uint8Array(PROTOCOL_V2_OKPP_HEADER_SIZE);
|
|
35
|
-
const view = new DataView(header.buffer);
|
|
36
|
-
'OKPP'.split('').forEach((char, index) => {
|
|
37
|
-
header[index] = char.charCodeAt(0);
|
|
38
|
-
});
|
|
39
|
-
'RESC'.split('').forEach((char, index) => {
|
|
40
|
-
header[0x08 + index] = char.charCodeAt(0);
|
|
41
|
-
});
|
|
42
|
-
view.setUint32(0x0c, header.byteLength, true);
|
|
43
|
-
for (let index = 0; index < headerHash.length / 2; index++) {
|
|
44
|
-
header[0x240 + index] = Number.parseInt(headerHash.slice(index * 2, index * 2 + 2), 16);
|
|
45
|
-
}
|
|
46
|
-
return header;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const resources: IProtocolV2Resource[] = PROTOCOL_V2_RESOURCE_TYPES.map((type, index) => ({
|
|
50
|
-
type,
|
|
51
|
-
url: `https://example.com/${type}.okpkg`,
|
|
52
|
-
size: index + 100,
|
|
53
|
-
fileHash: index.toString(16).padStart(64, '0'),
|
|
54
|
-
headerHash: index.toString(16).padStart(128, '0'),
|
|
55
|
-
}));
|
|
56
|
-
|
|
57
|
-
const bootResources: IProtocolV2BootResources = {
|
|
58
|
-
required: false,
|
|
59
|
-
target: 'CRATE',
|
|
60
|
-
url: 'https://example.com/boot-resources.crate.okpkg',
|
|
61
|
-
size: 1234,
|
|
62
|
-
fileHash: 'ab'.repeat(32),
|
|
63
|
-
payloadHash: 'cd'.repeat(64),
|
|
64
|
-
headerHash: 'ef'.repeat(64),
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const createSettings = (configFetcher: ConnectSettings['configFetcher']): ConnectSettings =>
|
|
68
|
-
({
|
|
69
|
-
env: 'node',
|
|
70
|
-
fetchConfig: true,
|
|
71
|
-
preRelease: true,
|
|
72
|
-
configFetcher,
|
|
73
|
-
} as ConnectSettings);
|
|
74
|
-
|
|
75
|
-
const createRemoteConfig = (): RemoteConfigResponse =>
|
|
76
|
-
({
|
|
77
|
-
classic: { firmware: [], ble: [] },
|
|
78
|
-
classic1s: { firmware: [], ble: [] },
|
|
79
|
-
classicpure: { firmware: [], ble: [] },
|
|
80
|
-
mini: { firmware: [], ble: [] },
|
|
81
|
-
touch: { firmware: [], ble: [] },
|
|
82
|
-
pro: { firmware: [], ble: [] },
|
|
83
|
-
pro2: { firmware: [], ble: [], resources: { stable: resources, boot: bootResources } },
|
|
84
|
-
bridge: {},
|
|
85
|
-
} as unknown as RemoteConfigResponse);
|
|
86
|
-
|
|
87
|
-
describe('Pro2 resource configuration', () => {
|
|
88
|
-
beforeEach(() => {
|
|
89
|
-
jest.clearAllMocks();
|
|
90
|
-
DataManager.lastCheckTimestamp = 0;
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
test('accepts exactly six resources and normalizes their deterministic order', () => {
|
|
94
|
-
const parsed = parseProtocolV2Resources({
|
|
95
|
-
stable: [...resources].reverse(),
|
|
96
|
-
boot: bootResources,
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
expect(parsed?.stable.map(item => item.type)).toEqual(PROTOCOL_V2_RESOURCE_TYPES);
|
|
100
|
-
expect(parsed?.boot).toEqual(bootResources);
|
|
101
|
-
expect(PROTOCOL_V2_RESOURCE_DEVICE_PATHS.translations).toBe(
|
|
102
|
-
'vol0:/bundles/translations/translations.okpkg'
|
|
103
|
-
);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
test('rejects incomplete, duplicate, or malformed stable sets', () => {
|
|
107
|
-
expect(() => parseProtocolV2Resources({ stable: resources.slice(1) })).toThrow(
|
|
108
|
-
'six unique resource types'
|
|
109
|
-
);
|
|
110
|
-
expect(() =>
|
|
111
|
-
parseProtocolV2Resources({ stable: [...resources.slice(0, 5), resources[0]] })
|
|
112
|
-
).toThrow('six unique resource types');
|
|
113
|
-
expect(() =>
|
|
114
|
-
parseProtocolV2Resources({
|
|
115
|
-
stable: resources.map((resource, index) =>
|
|
116
|
-
index === 0 ? { ...resource, headerHash: 'bad' } : resource
|
|
117
|
-
),
|
|
118
|
-
})
|
|
119
|
-
).toThrow('headerHash');
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
test('requires boot resources to remain optional and use a CRATE package', () => {
|
|
123
|
-
expect(() =>
|
|
124
|
-
parseProtocolV2Resources({
|
|
125
|
-
stable: resources,
|
|
126
|
-
boot: { ...bootResources, required: true },
|
|
127
|
-
})
|
|
128
|
-
).toThrow('required flag');
|
|
129
|
-
expect(() =>
|
|
130
|
-
parseProtocolV2Resources({
|
|
131
|
-
stable: resources,
|
|
132
|
-
boot: { ...bootResources, target: 'RESC' },
|
|
133
|
-
})
|
|
134
|
-
).toThrow('expected CRATE');
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
test('downloads nothing when all resource identities match', () => {
|
|
138
|
-
const inventory = resources.map(({ type, size, headerHash }) => ({ type, size, headerHash }));
|
|
139
|
-
|
|
140
|
-
expect(
|
|
141
|
-
buildProtocolV2ResourceUpdatePlan({ resources, inventory, mode: 'application' })
|
|
142
|
-
).toEqual({ status: 'valid', resources: [] });
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
test('builds inventory from existing filesystem calls without ResourceInventoryGet', async () => {
|
|
146
|
-
const installedResources = resources.map((resource, index) => ({
|
|
147
|
-
...resource,
|
|
148
|
-
size: PROTOCOL_V2_OKPP_HEADER_SIZE + index + 1,
|
|
149
|
-
}));
|
|
150
|
-
const resourceByPath = new Map(
|
|
151
|
-
installedResources.map(resource => [
|
|
152
|
-
PROTOCOL_V2_RESOURCE_DEVICE_PATHS[resource.type],
|
|
153
|
-
resource,
|
|
154
|
-
])
|
|
155
|
-
);
|
|
156
|
-
const typedCall = jest.fn(
|
|
157
|
-
(requestType: string, _responseType: string, payload: Record<string, any>) => {
|
|
158
|
-
if (requestType === 'ResourceInventoryGet') {
|
|
159
|
-
throw new Error('ResourceInventoryGet is unavailable on released firmware');
|
|
160
|
-
}
|
|
161
|
-
if (requestType === 'FilesystemPathInfoQuery') {
|
|
162
|
-
const resource = resourceByPath.get(payload.path);
|
|
163
|
-
return {
|
|
164
|
-
message: {
|
|
165
|
-
exist: Boolean(resource),
|
|
166
|
-
directory: false,
|
|
167
|
-
size: resource?.size ?? 0,
|
|
168
|
-
},
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
if (requestType === 'FilesystemFileRead') {
|
|
172
|
-
const resource = resourceByPath.get(payload.file.path);
|
|
173
|
-
if (!resource) throw new Error('missing resource');
|
|
174
|
-
const header = createResourceHeader(resource.headerHash);
|
|
175
|
-
const offset = Number(payload.file.offset);
|
|
176
|
-
const chunkLength = Number(payload.chunk_len);
|
|
177
|
-
return {
|
|
178
|
-
message: {
|
|
179
|
-
data: header.slice(offset, offset + chunkLength),
|
|
180
|
-
},
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
throw new Error(`Unexpected request: ${requestType}`);
|
|
184
|
-
}
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
await expect(
|
|
188
|
-
readProtocolV2ResourceInventory({
|
|
189
|
-
commands: { typedCall },
|
|
190
|
-
resources: installedResources,
|
|
191
|
-
chunkSize: 4000,
|
|
192
|
-
})
|
|
193
|
-
).resolves.toEqual(
|
|
194
|
-
installedResources.map(({ type, size, headerHash }) => ({ type, size, headerHash }))
|
|
195
|
-
);
|
|
196
|
-
expect(typedCall.mock.calls.some(call => call[0] === 'ResourceInventoryGet')).toBe(false);
|
|
197
|
-
expect(typedCall.mock.calls.filter(call => call[0] === 'FilesystemPathInfoQuery')).toHaveLength(
|
|
198
|
-
6
|
|
199
|
-
);
|
|
200
|
-
expect(typedCall.mock.calls.some(call => call[0] === 'FilesystemFileRead')).toBe(true);
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
test('selects only the changed or missing resource in application mode', () => {
|
|
204
|
-
const inventory = resources
|
|
205
|
-
.filter(resource => resource.type !== 'noto')
|
|
206
|
-
.map(({ type, size, headerHash }) => ({
|
|
207
|
-
type,
|
|
208
|
-
size: type === 'images' ? size + 1 : size,
|
|
209
|
-
headerHash,
|
|
210
|
-
}));
|
|
211
|
-
|
|
212
|
-
const result = buildProtocolV2ResourceUpdatePlan({
|
|
213
|
-
resources,
|
|
214
|
-
inventory,
|
|
215
|
-
mode: 'application',
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
expect(result.status).toBe('outdated');
|
|
219
|
-
expect(result.resources.map(resource => resource.type)).toEqual(['images', 'noto']);
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
test('reports unknown without an application inventory and selects all in recovery mode', () => {
|
|
223
|
-
expect(buildProtocolV2ResourceUpdatePlan({ resources, mode: 'application' })).toEqual({
|
|
224
|
-
status: 'unknown',
|
|
225
|
-
resources: [],
|
|
226
|
-
});
|
|
227
|
-
expect(
|
|
228
|
-
buildProtocolV2ResourceUpdatePlan({ resources, mode: 'bootloader-recovery' }).resources
|
|
229
|
-
).toHaveLength(6);
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
test('uses a filesystem inventory for incremental recovery mode updates', () => {
|
|
233
|
-
const inventory = resources.slice(1).map(({ type, size, headerHash }) => ({
|
|
234
|
-
type,
|
|
235
|
-
size,
|
|
236
|
-
headerHash,
|
|
237
|
-
}));
|
|
238
|
-
|
|
239
|
-
expect(
|
|
240
|
-
buildProtocolV2ResourceUpdatePlan({
|
|
241
|
-
resources,
|
|
242
|
-
inventory,
|
|
243
|
-
mode: 'bootloader-recovery',
|
|
244
|
-
}).resources.map(resource => resource.type)
|
|
245
|
-
).toEqual(['images']);
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
test('verifies both full file size and SHA-256 before transfer', () => {
|
|
249
|
-
const bytes = new Uint8Array([1, 2, 3]);
|
|
250
|
-
const binary = bytes.buffer;
|
|
251
|
-
const identity = { size: bytes.byteLength, fileHash: bytesToHex(sha256(bytes)) };
|
|
252
|
-
|
|
253
|
-
expect(isProtocolV2ResourceFileValid(binary, identity)).toBe(true);
|
|
254
|
-
expect(isProtocolV2ResourceFileValid(binary, { ...identity, size: 4 })).toBe(false);
|
|
255
|
-
expect(isProtocolV2ResourceFileValid(binary, { ...identity, fileHash: '0'.repeat(64) })).toBe(
|
|
256
|
-
false
|
|
257
|
-
);
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
test('applies a validated pre-release config and exposes the stable resource set', async () => {
|
|
261
|
-
const configFetcher = jest.fn().mockResolvedValue(createRemoteConfig());
|
|
262
|
-
|
|
263
|
-
await expect(DataManager.load(createSettings(configFetcher))).resolves.toBe(true);
|
|
264
|
-
|
|
265
|
-
expect(configFetcher).toHaveBeenCalledWith(
|
|
266
|
-
expect.stringMatching(/^https:\/\/data\.onekey\.so\/pre-config\.json\?noCache=/)
|
|
267
|
-
);
|
|
268
|
-
expect(DataManager.getProtocolV2Resources()).toEqual(resources);
|
|
269
|
-
expect(DataManager.getProtocolV2BootResources()).toEqual(bootResources);
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
test('does not advance the cache timestamp when refresh fails', async () => {
|
|
273
|
-
jest.spyOn(axios, 'get').mockRejectedValue(new Error('offline'));
|
|
274
|
-
const settings = createSettings(jest.fn().mockResolvedValue(null));
|
|
275
|
-
DataManager.settings = settings;
|
|
276
|
-
|
|
277
|
-
await DataManager.checkAndReloadData();
|
|
278
|
-
|
|
279
|
-
expect(DataManager.lastCheckTimestamp).toBe(0);
|
|
280
|
-
await expect(DataManager.forceReloadData()).rejects.toMatchObject({
|
|
281
|
-
errorCode: HardwareErrorCode.NetworkError,
|
|
282
|
-
message: 'Unable to refresh the latest remote config',
|
|
283
|
-
});
|
|
284
|
-
expect(DataManager.lastCheckTimestamp).toBe(0);
|
|
285
|
-
});
|
|
286
|
-
});
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { DeviceSessionPinType } from '@onekeyfe/hd-transport';
|
|
2
|
-
|
|
3
|
-
import { DEVICE } from '../src/events';
|
|
4
|
-
import { Device } from '../src/device/Device';
|
|
5
|
-
|
|
6
|
-
jest.mock('../src/data/config', () => ({
|
|
7
|
-
getSDKVersion: jest.fn(() => '1.0.0-test'),
|
|
8
|
-
DEFAULT_DOMAIN: 'https://example.com/',
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
describe('Protocol V2 UI interaction lifecycle', () => {
|
|
12
|
-
test('synthesizes finish metadata for a progress-only operation', () => {
|
|
13
|
-
const device = new Device({ id: 'connect-progress' } as any);
|
|
14
|
-
device.isProtocolV2 = jest.fn(() => true);
|
|
15
|
-
device.beginProtocolV2UiInteraction();
|
|
16
|
-
|
|
17
|
-
const metadata = device.finishProtocolV2UiInteraction('succeeded', {
|
|
18
|
-
ensureMetadata: true,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
expect(metadata).toMatchObject({
|
|
22
|
-
phase: 'processing',
|
|
23
|
-
transition: 'finish',
|
|
24
|
-
outcome: 'succeeded',
|
|
25
|
-
protocol: 'V2',
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test('keeps finish metadata after the Protocol V2 transport is released', () => {
|
|
30
|
-
const device = new Device({ id: 'connect-released' } as any);
|
|
31
|
-
const isProtocolV2 = jest.fn().mockReturnValueOnce(true).mockReturnValue(false);
|
|
32
|
-
device.isProtocolV2 = isProtocolV2;
|
|
33
|
-
device.beginProtocolV2UiInteraction();
|
|
34
|
-
|
|
35
|
-
const metadata = device.finishProtocolV2UiInteraction('succeeded', {
|
|
36
|
-
ensureMetadata: true,
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
expect(metadata).toMatchObject({
|
|
40
|
-
phase: 'processing',
|
|
41
|
-
transition: 'finish',
|
|
42
|
-
outcome: 'succeeded',
|
|
43
|
-
protocol: 'V2',
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test('emits a matching PIN phase completion after DeviceSessionAskPin succeeds', async () => {
|
|
48
|
-
const device = new Device({ id: 'connect-1' } as any);
|
|
49
|
-
device.isProtocolV2 = jest.fn(() => true);
|
|
50
|
-
device.updateProtocolV2Status = jest.fn(() => undefined as any);
|
|
51
|
-
device.commands = {
|
|
52
|
-
typedCall: jest.fn().mockResolvedValue({
|
|
53
|
-
message: { unlocked: true },
|
|
54
|
-
}),
|
|
55
|
-
} as any;
|
|
56
|
-
device.beginProtocolV2UiInteraction();
|
|
57
|
-
|
|
58
|
-
const starts: unknown[] = [];
|
|
59
|
-
const completions: unknown[] = [];
|
|
60
|
-
device.on(DEVICE.PIN_ON_DEVICE, (...args) => starts.push(args));
|
|
61
|
-
device.on(DEVICE.PIN_ON_DEVICE_COMPLETE, (...args) => completions.push(args));
|
|
62
|
-
|
|
63
|
-
await device.unlockDevice(DeviceSessionPinType.Main, {
|
|
64
|
-
source: 'unlock-coordinator',
|
|
65
|
-
reason: 'device-locked',
|
|
66
|
-
deviceOnly: true,
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
const startMetadata = (starts[0] as unknown[])[2] as Record<string, unknown>;
|
|
70
|
-
const completionMetadata = (completions[0] as unknown[])[1] as Record<string, unknown>;
|
|
71
|
-
expect(startMetadata.interaction).toMatchObject({
|
|
72
|
-
phase: 'pin',
|
|
73
|
-
transition: 'start',
|
|
74
|
-
protocol: 'V2',
|
|
75
|
-
});
|
|
76
|
-
expect(completionMetadata).toMatchObject({
|
|
77
|
-
interactionId: (startMetadata.interaction as { interactionId: string }).interactionId,
|
|
78
|
-
phaseId: (startMetadata.interaction as { phaseId: string }).phaseId,
|
|
79
|
-
phase: 'pin',
|
|
80
|
-
transition: 'complete',
|
|
81
|
-
outcome: 'succeeded',
|
|
82
|
-
protocol: 'V2',
|
|
83
|
-
});
|
|
84
|
-
expect(completionMetadata.sequence).toBeGreaterThan(
|
|
85
|
-
(startMetadata.interaction as { sequence: number }).sequence
|
|
86
|
-
);
|
|
87
|
-
expect(completionMetadata.phaseId).toBe(
|
|
88
|
-
(startMetadata.interaction as { phaseId: string }).phaseId
|
|
89
|
-
);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { createUiMessage } from '../src/events';
|
|
2
|
-
import { UI_REQUEST } from '../src/events/ui-request';
|
|
3
|
-
import { createUiProgressMessageFilter } from '../src/utils/uiProgressThrottle';
|
|
4
|
-
|
|
5
|
-
import type { KnownDevice } from '../src/types';
|
|
6
|
-
|
|
7
|
-
describe('createUiProgressMessageFilter', () => {
|
|
8
|
-
let currentTime: number;
|
|
9
|
-
let shouldPostMessage: ReturnType<typeof createUiProgressMessageFilter>;
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
currentTime = 1_000;
|
|
13
|
-
shouldPostMessage = createUiProgressMessageFilter(250, () => currentTime);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
const firmwareProgress = (
|
|
17
|
-
progress: number,
|
|
18
|
-
progressType: 'transferData' | 'installingFirmware' = 'transferData'
|
|
19
|
-
) =>
|
|
20
|
-
createUiMessage(UI_REQUEST.FIRMWARE_PROGRESS, {
|
|
21
|
-
device: {} as KnownDevice,
|
|
22
|
-
progress,
|
|
23
|
-
progressType,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test('limits firmware progress to one event per interval', () => {
|
|
27
|
-
expect(shouldPostMessage(firmwareProgress(1))).toBe(true);
|
|
28
|
-
|
|
29
|
-
currentTime += 100;
|
|
30
|
-
expect(shouldPostMessage(firmwareProgress(1))).toBe(false);
|
|
31
|
-
|
|
32
|
-
currentTime += 150;
|
|
33
|
-
expect(shouldPostMessage(firmwareProgress(1))).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test('limits transfer and install progress independently', () => {
|
|
37
|
-
expect(shouldPostMessage(firmwareProgress(1, 'transferData'))).toBe(true);
|
|
38
|
-
expect(shouldPostMessage(firmwareProgress(1, 'installingFirmware'))).toBe(true);
|
|
39
|
-
|
|
40
|
-
currentTime += 10;
|
|
41
|
-
expect(shouldPostMessage(firmwareProgress(2, 'transferData'))).toBe(false);
|
|
42
|
-
expect(shouldPostMessage(firmwareProgress(2, 'installingFirmware'))).toBe(false);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test('emits phase boundaries immediately and suppresses duplicate boundaries', () => {
|
|
46
|
-
expect(shouldPostMessage(firmwareProgress(0))).toBe(true);
|
|
47
|
-
expect(shouldPostMessage(firmwareProgress(0))).toBe(false);
|
|
48
|
-
|
|
49
|
-
currentTime += 10;
|
|
50
|
-
expect(shouldPostMessage(firmwareProgress(50))).toBe(false);
|
|
51
|
-
expect(shouldPostMessage(firmwareProgress(100))).toBe(true);
|
|
52
|
-
expect(shouldPostMessage(firmwareProgress(100))).toBe(false);
|
|
53
|
-
|
|
54
|
-
expect(shouldPostMessage(firmwareProgress(0))).toBe(true);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test('treats decreasing progress as a new phase', () => {
|
|
58
|
-
expect(shouldPostMessage(firmwareProgress(80))).toBe(true);
|
|
59
|
-
|
|
60
|
-
currentTime += 10;
|
|
61
|
-
expect(shouldPostMessage(firmwareProgress(20))).toBe(true);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test('also limits device progress and leaves other UI events unchanged', () => {
|
|
65
|
-
const deviceProgress = (progress: number) =>
|
|
66
|
-
createUiMessage(UI_REQUEST.DEVICE_PROGRESS, { progress });
|
|
67
|
-
|
|
68
|
-
expect(shouldPostMessage(deviceProgress(1))).toBe(true);
|
|
69
|
-
currentTime += 10;
|
|
70
|
-
expect(shouldPostMessage(deviceProgress(2))).toBe(false);
|
|
71
|
-
|
|
72
|
-
expect(shouldPostMessage(createUiMessage(UI_REQUEST.CLOSE_UI_WINDOW))).toBe(true);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { createDeferred } from '@onekeyfe/hd-shared';
|
|
2
|
-
|
|
3
|
-
import { findUiPromiseForResponse } from '../src/core/uiPromiseRegistry';
|
|
4
|
-
import { UI_RESPONSE } from '../src/events';
|
|
5
|
-
|
|
6
|
-
import type { UiPromise, UiPromiseResponse } from '../src/events';
|
|
7
|
-
|
|
8
|
-
const createPinPromise = (interactionId: string, deviceId: string) => {
|
|
9
|
-
const promise = createDeferred(UI_RESPONSE.RECEIVE_PIN) as UiPromise<
|
|
10
|
-
typeof UI_RESPONSE.RECEIVE_PIN
|
|
11
|
-
>;
|
|
12
|
-
promise.responseCorrelation = { interactionId, deviceId };
|
|
13
|
-
return promise;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const asRegistry = (promises: UiPromise<typeof UI_RESPONSE.RECEIVE_PIN>[]) =>
|
|
17
|
-
promises as UiPromise<UiPromiseResponse['type']>[];
|
|
18
|
-
|
|
19
|
-
describe('UI response promise correlation', () => {
|
|
20
|
-
test('matches a sensitive response by type, interactionId and deviceId', () => {
|
|
21
|
-
const deviceA = createPinPromise('interaction-a', 'device-a');
|
|
22
|
-
const deviceB = createPinPromise('interaction-b', 'device-b');
|
|
23
|
-
|
|
24
|
-
expect(
|
|
25
|
-
findUiPromiseForResponse(asRegistry([deviceA, deviceB]), {
|
|
26
|
-
type: UI_RESPONSE.RECEIVE_PIN,
|
|
27
|
-
payload: '123',
|
|
28
|
-
interactionId: 'interaction-b',
|
|
29
|
-
deviceId: 'device-b',
|
|
30
|
-
})
|
|
31
|
-
).toBe(deviceB);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('does not match incomplete or incorrect correlation metadata', () => {
|
|
35
|
-
const pending = createPinPromise('interaction-a', 'device-a');
|
|
36
|
-
|
|
37
|
-
expect(
|
|
38
|
-
findUiPromiseForResponse(asRegistry([pending]), {
|
|
39
|
-
type: UI_RESPONSE.RECEIVE_PIN,
|
|
40
|
-
payload: '123',
|
|
41
|
-
interactionId: 'interaction-a',
|
|
42
|
-
})
|
|
43
|
-
).toBeUndefined();
|
|
44
|
-
expect(
|
|
45
|
-
findUiPromiseForResponse(asRegistry([pending]), {
|
|
46
|
-
type: UI_RESPONSE.RECEIVE_PIN,
|
|
47
|
-
payload: '123',
|
|
48
|
-
interactionId: 'interaction-a',
|
|
49
|
-
deviceId: 'device-b',
|
|
50
|
-
})
|
|
51
|
-
).toBeUndefined();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test('keeps legacy responses only when the sensitive candidate is unique', () => {
|
|
55
|
-
const deviceA = createPinPromise('interaction-a', 'device-a');
|
|
56
|
-
const deviceB = createPinPromise('interaction-b', 'device-b');
|
|
57
|
-
const legacyResponse = {
|
|
58
|
-
type: UI_RESPONSE.RECEIVE_PIN,
|
|
59
|
-
payload: '123',
|
|
60
|
-
} as const;
|
|
61
|
-
|
|
62
|
-
expect(findUiPromiseForResponse(asRegistry([deviceA]), legacyResponse)).toBe(deviceA);
|
|
63
|
-
expect(
|
|
64
|
-
findUiPromiseForResponse(asRegistry([deviceA, deviceB]), legacyResponse)
|
|
65
|
-
).toBeUndefined();
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test('applies the same exact matching to passphrase responses', () => {
|
|
69
|
-
const promise = createDeferred(UI_RESPONSE.RECEIVE_PASSPHRASE) as UiPromise<
|
|
70
|
-
typeof UI_RESPONSE.RECEIVE_PASSPHRASE
|
|
71
|
-
>;
|
|
72
|
-
promise.responseCorrelation = {
|
|
73
|
-
interactionId: 'passphrase-interaction',
|
|
74
|
-
deviceId: 'device-a',
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
expect(
|
|
78
|
-
findUiPromiseForResponse([promise] as UiPromise<UiPromiseResponse['type']>[], {
|
|
79
|
-
type: UI_RESPONSE.RECEIVE_PASSPHRASE,
|
|
80
|
-
payload: { value: 'redacted' },
|
|
81
|
-
interactionId: 'passphrase-interaction',
|
|
82
|
-
deviceId: 'device-a',
|
|
83
|
-
})
|
|
84
|
-
).toBe(promise);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from './BaseMethod';
|
|
2
|
-
export default class DetectDeviceConnectProtocol extends BaseMethod {
|
|
3
|
-
init(): void;
|
|
4
|
-
getSupportedProtocols(): readonly ["V1", "V2"];
|
|
5
|
-
run(): Promise<"V1" | "V2">;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=DetectDeviceConnectProtocol.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DetectDeviceConnectProtocol.d.ts","sourceRoot":"","sources":["../../src/api/DetectDeviceConnectProtocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,CAAC,OAAO,OAAO,2BAA4B,SAAQ,UAAU;IACjE,IAAI;IAOJ,qBAAqB;IAIrB,GAAG;CAGJ"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type Pro2NftImage } from '../../utils/pro2Nft';
|
|
2
|
-
import { BaseMethod } from '../BaseMethod';
|
|
3
|
-
export type DeviceUploadNftParams = {
|
|
4
|
-
image: Pro2NftImage;
|
|
5
|
-
thumbnail: Pro2NftImage;
|
|
6
|
-
title: string;
|
|
7
|
-
subtitle: string;
|
|
8
|
-
timestampMs?: number;
|
|
9
|
-
chunkSize?: number;
|
|
10
|
-
paceMs?: number;
|
|
11
|
-
timeoutMs?: number;
|
|
12
|
-
};
|
|
13
|
-
export type DeviceUploadNftResponse = {
|
|
14
|
-
basename: string;
|
|
15
|
-
imagePath: string;
|
|
16
|
-
thumbnailPath: string;
|
|
17
|
-
metadataPath: string;
|
|
18
|
-
totalSize: number;
|
|
19
|
-
nftUpdated: true;
|
|
20
|
-
message?: string;
|
|
21
|
-
};
|
|
22
|
-
export default class DeviceUploadNft extends BaseMethod<DeviceUploadNftParams> {
|
|
23
|
-
private bundle?;
|
|
24
|
-
getSupportedProtocols(): readonly ["V2"];
|
|
25
|
-
init(): void;
|
|
26
|
-
private assertCapabilities;
|
|
27
|
-
private assertStorageCapacity;
|
|
28
|
-
private updateNft;
|
|
29
|
-
run(): Promise<DeviceUploadNftResponse>;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=DeviceUploadNft.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceUploadNft.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/DeviceUploadNft.ts"],"names":[],"mappings":"AAIA,OAAO,EASL,KAAK,YAAY,EAGlB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,EAAE,YAAY,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,IAAI,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAMF,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,UAAU,CAAC,qBAAqB,CAAC;IAC5E,OAAO,CAAC,MAAM,CAAC,CAAgB;IAE/B,qBAAqB;IAIrB,IAAI;YAkCU,kBAAkB;YAalB,qBAAqB;YAgBrB,SAAS;IAcjB,GAAG,IAAI,OAAO,CAAC,uBAAuB,CAAC;CA0D9C"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { UiPromise, UiPromiseResponse } from '../events/ui-promise';
|
|
2
|
-
import type { UiResponseEvent } from '../events/ui-response';
|
|
3
|
-
export declare const findUiPromiseForResponse: (uiPromises: UiPromise<UiPromiseResponse['type']>[], response: UiResponseEvent) => UiPromise<"ui-receive_pin" | "ui-receive_passphrase" | "ui-receive_select-device-in-bootloader-for-web-device" | "ui-receive_select-device-for-switch-firmware-web-device" | "device-disconnect"> | undefined;
|
|
4
|
-
//# sourceMappingURL=uiPromiseRegistry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uiPromiseRegistry.d.ts","sourceRoot":"","sources":["../../src/core/uiPromiseRegistry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAS7D,eAAO,MAAM,wBAAwB,eACvB,UAAU,iBAAiB,CAAC,MAAM,CAAC,CAAC,EAAE,YACxC,eAAe,kNA0B1B,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { IProtocolV2Resource, IProtocolV2ResourceType, IProtocolV2Resources } from '../../types';
|
|
2
|
-
import type { DeviceCommands } from '../../device/DeviceCommands';
|
|
3
|
-
export declare const PROTOCOL_V2_RESOURCE_TYPES: readonly ["images", "animation", "wallpaper", "translations", "roobert", "noto"];
|
|
4
|
-
export declare const PROTOCOL_V2_RESOURCE_DEVICE_PATHS: Readonly<Record<IProtocolV2ResourceType, string>>;
|
|
5
|
-
export declare const PROTOCOL_V2_RESOURCE_INVENTORY_TIMEOUT_MS: number;
|
|
6
|
-
export type ProtocolV2ResourceInventoryItem = {
|
|
7
|
-
type: IProtocolV2ResourceType;
|
|
8
|
-
size: number;
|
|
9
|
-
headerHash: string;
|
|
10
|
-
};
|
|
11
|
-
export type ProtocolV2ResourceUpdateMode = 'application' | 'bootloader-recovery';
|
|
12
|
-
export type ProtocolV2ResourceUpdatePlan = {
|
|
13
|
-
status: 'valid' | 'outdated' | 'unknown';
|
|
14
|
-
resources: IProtocolV2Resource[];
|
|
15
|
-
};
|
|
16
|
-
export declare function readProtocolV2ResourceInventory({ commands, resources, chunkSize, timeoutMs, }: {
|
|
17
|
-
commands: Pick<DeviceCommands, 'typedCall'>;
|
|
18
|
-
resources: readonly IProtocolV2Resource[];
|
|
19
|
-
chunkSize?: number;
|
|
20
|
-
timeoutMs?: number;
|
|
21
|
-
}): Promise<ProtocolV2ResourceInventoryItem[]>;
|
|
22
|
-
export declare function parseProtocolV2Resources(value: unknown): IProtocolV2Resources | undefined;
|
|
23
|
-
export declare function buildProtocolV2ResourceUpdatePlan({ resources, inventory, mode, forced, }: {
|
|
24
|
-
resources: readonly IProtocolV2Resource[];
|
|
25
|
-
inventory?: readonly ProtocolV2ResourceInventoryItem[];
|
|
26
|
-
mode: ProtocolV2ResourceUpdateMode;
|
|
27
|
-
forced?: boolean;
|
|
28
|
-
}): ProtocolV2ResourceUpdatePlan;
|
|
29
|
-
export declare function isProtocolV2ResourceFileValid(binary: ArrayBuffer, resource: Pick<IProtocolV2Resource, 'size' | 'fileHash'>): boolean;
|
|
30
|
-
//# sourceMappingURL=resources.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/protocols/protocol-v2/resources.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,eAAO,MAAM,0BAA0B,kFAOgB,CAAC;AAExD,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,MAAM,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAQ7F,CAAC;AAaJ,eAAO,MAAM,yCAAyC,QAAW,CAAC;AAElE,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,uBAAuB,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,aAAa,GAAG,qBAAqB,CAAC;AAEjF,MAAM,MAAM,4BAA4B,GAAG;IACzC,MAAM,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;IACzC,SAAS,EAAE,mBAAmB,EAAE,CAAC;CAClC,CAAC;AAwHF,wBAAsB,+BAA+B,CAAC,EACpD,QAAQ,EACR,SAAS,EACT,SAAgD,EAChD,SAAqD,GACtD,EAAE;IACD,QAAQ,EAAE,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IAC5C,SAAS,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,+BAA+B,EAAE,CAAC,CAmB7C;AAmED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS,CAgCzF;AAGD,wBAAgB,iCAAiC,CAAC,EAChD,SAAS,EACT,SAAS,EACT,IAAI,EACJ,MAAc,GACf,EAAE;IACD,SAAS,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAC1C,SAAS,CAAC,EAAE,SAAS,+BAA+B,EAAE,CAAC;IACvD,IAAI,EAAE,4BAA4B,CAAC;IACnC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,GAAG,4BAA4B,CA8B/B;AAOD,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,IAAI,CAAC,mBAAmB,EAAE,MAAM,GAAG,UAAU,CAAC,GACvD,OAAO,CAGT"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { BaseMethod } from '../../api/BaseMethod';
|
|
2
|
-
import type { Device } from '../../device/Device';
|
|
3
|
-
import type { ProtocolV2UiInteractionCoordinator } from './uiInteraction';
|
|
4
|
-
export type ProtocolV2UnlockContext = {
|
|
5
|
-
preflightCompleted: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare const createProtocolV2UnlockContext: () => ProtocolV2UnlockContext;
|
|
8
|
-
type RunnableMethod = Pick<BaseMethod, 'run' | 'unlockPolicy' | 'useDevicePassphraseState' | 'protocolV2UiInteraction' | 'protocolV2UiMode' | 'params' | 'payload'> & {
|
|
9
|
-
name?: string;
|
|
10
|
-
protocolV2UnlockContext?: ProtocolV2UnlockContext;
|
|
11
|
-
};
|
|
12
|
-
type UiInteractionCoordinator = Pick<ProtocolV2UiInteractionCoordinator, 'enterMethodInteraction' | 'enterUnlockInteraction'>;
|
|
13
|
-
type RunMethodWithUnlockPolicyOptions<T> = {
|
|
14
|
-
context?: ProtocolV2UnlockContext;
|
|
15
|
-
uiCoordinator?: UiInteractionCoordinator;
|
|
16
|
-
afterStatusBeforeUnlock?: () => void | Promise<void>;
|
|
17
|
-
prepare?: () => Promise<void>;
|
|
18
|
-
run?: () => Promise<T>;
|
|
19
|
-
};
|
|
20
|
-
export declare function runMethodWithUnlockPolicy<T = unknown>(method: RunnableMethod, device: Device, options?: RunMethodWithUnlockPolicyOptions<T>): Promise<T>;
|
|
21
|
-
export {};
|
|
22
|
-
//# sourceMappingURL=unlockPolicyRunner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unlockPolicyRunner.d.ts","sourceRoot":"","sources":["../../../src/protocols/protocol-v2/unlockPolicyRunner.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,iBAAiB,CAAC;AAI1E,MAAM,MAAM,uBAAuB,GAAG;IACpC,kBAAkB,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,6BAA6B,QAAO,uBAE/C,CAAC;AAEH,KAAK,cAAc,GAAG,IAAI,CACxB,UAAU,EACR,KAAK,GACL,cAAc,GACd,0BAA0B,GAC1B,yBAAyB,GACzB,kBAAkB,GAClB,QAAQ,GACR,SAAS,CACZ,GAAG;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;CACnD,CAAC;AAEF,KAAK,wBAAwB,GAAG,IAAI,CAClC,kCAAkC,EAClC,wBAAwB,GAAG,wBAAwB,CACpD,CAAC;AAEF,KAAK,gCAAgC,CAAC,CAAC,IAAI;IACzC,OAAO,CAAC,EAAE,uBAAuB,CAAC;IAClC,aAAa,CAAC,EAAE,wBAAwB,CAAC;IACzC,uBAAuB,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,GAAG,CAAC,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;CACxB,CAAC;AAEF,wBAAsB,yBAAyB,CAAC,CAAC,GAAG,OAAO,EACzD,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,gCAAgC,CAAC,CAAC,CAAM,GAChD,OAAO,CAAC,CAAC,CAAC,CAgEZ"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { HardwareConnectProtocol } from '@onekeyfe/hd-shared';
|
|
2
|
-
import type { Response } from '../params';
|
|
3
|
-
export declare function detectDeviceConnectProtocol(connectId: string): Response<HardwareConnectProtocol>;
|
|
4
|
-
//# sourceMappingURL=detectDeviceConnectProtocol.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"detectDeviceConnectProtocol.d.ts","sourceRoot":"","sources":["../../../src/types/api/detectDeviceConnectProtocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,CAAC,OAAO,UAAU,2BAA2B,CACjD,SAAS,EAAE,MAAM,GAChB,QAAQ,CAAC,uBAAuB,CAAC,CAAC"}
|