@onekeyfe/hd-core 1.2.0-alpha.34 → 1.2.0-alpha.36
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 +74 -0
- package/__tests__/DeviceCommands.test.ts +84 -0
- package/__tests__/DeviceEventRegistration.test.ts +6 -0
- package/__tests__/device-settings.test.ts +3 -0
- package/__tests__/device-wallet-session-store.test.ts +80 -7
- package/__tests__/evmSignTransaction.test.ts +69 -0
- package/__tests__/get-device-state.test.ts +180 -40
- package/__tests__/open-wallet-session.test.ts +314 -55
- package/__tests__/protocol-v2-ui-lifecycle.test.ts +56 -0
- package/__tests__/protocol-v2.test.ts +768 -139
- package/dist/api/FirmwareUpdateV4.d.ts +1 -0
- 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/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/evm/protocol.d.ts +3 -0
- package/dist/api/evm/protocol.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +1 -1
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -1
- package/dist/core/deviceEventRegistration.d.ts +2 -0
- package/dist/core/deviceEventRegistration.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +25 -6
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceWalletSessionStore.d.ts +0 -1
- package/dist/device/DeviceWalletSessionStore.d.ts.map +1 -1
- package/dist/events/device.d.ts +4 -0
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +27 -2
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +63 -12
- package/dist/index.js +1164 -904
- package/dist/protocols/protocol-v2/features.d.ts +17 -6
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/index.d.ts +2 -2
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts +1 -0
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +3 -3
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts +5 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/types/api/openWalletSession.d.ts +1 -1
- package/dist/types/api/openWalletSession.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +2 -2
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/device.d.ts +2 -1
- package/dist/types/device.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +2 -0
- 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/BaseMethod.ts +1 -1
- package/src/api/FirmwareUpdateV4.ts +39 -14
- package/src/api/GetPassphraseState.ts +17 -0
- package/src/api/OpenWalletSession.ts +31 -8
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +24 -2
- package/src/api/device/DeviceUnlock.ts +1 -1
- package/src/api/evm/EVMGetAddress.ts +2 -2
- package/src/api/evm/EVMGetPublicKey.ts +2 -2
- package/src/api/evm/EVMSignMessage.ts +2 -2
- package/src/api/evm/EVMSignTransaction.ts +2 -2
- package/src/api/evm/EVMSignTypedData.ts +35 -45
- package/src/api/evm/EVMVerifyMessage.ts +2 -2
- package/src/api/evm/protocol.ts +6 -0
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +2 -2
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +1 -1
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +3 -1
- package/src/core/deviceEventRegistration.ts +4 -0
- package/src/core/index.ts +46 -4
- package/src/data/messages/messages-protocol-v2.json +408 -485
- package/src/device/Device.ts +266 -43
- package/src/device/DeviceCommands.ts +12 -2
- package/src/device/DeviceWalletSessionStore.ts +0 -14
- package/src/deviceProfile/buildDeviceFeatures.ts +1 -1
- package/src/events/device.ts +4 -0
- package/src/events/ui-request.ts +32 -2
- package/src/protocols/protocol-v2/features.ts +65 -16
- package/src/protocols/protocol-v2/index.ts +5 -0
- package/src/protocols/protocol-v2/settingsUnlockPolicy.ts +8 -3
- package/src/protocols/protocol-v2/uiInteraction.ts +31 -5
- package/src/protocols/protocol-v2/unlockRetry.ts +51 -18
- package/src/protocols/protocol-v2/walletSession.ts +172 -64
- package/src/types/api/openWalletSession.ts +1 -1
- package/src/types/api/protocolV2.ts +2 -2
- package/src/types/device.ts +2 -0
- package/src/utils/deviceFeaturesUtils.ts +4 -0
|
@@ -0,0 +1,56 @@
|
|
|
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('emits a matching PIN phase completion after DeviceSessionAskPin succeeds', async () => {
|
|
13
|
+
const device = new Device({ id: 'connect-1' } as any);
|
|
14
|
+
device.isProtocolV2 = jest.fn(() => true);
|
|
15
|
+
device.updateProtocolV2Status = jest.fn(() => undefined as any);
|
|
16
|
+
device.commands = {
|
|
17
|
+
typedCall: jest.fn().mockResolvedValue({
|
|
18
|
+
message: { unlocked: true },
|
|
19
|
+
}),
|
|
20
|
+
} as any;
|
|
21
|
+
device.beginProtocolV2UiInteraction();
|
|
22
|
+
|
|
23
|
+
const starts: unknown[] = [];
|
|
24
|
+
const completions: unknown[] = [];
|
|
25
|
+
device.on(DEVICE.PIN_ON_DEVICE, (...args) => starts.push(args));
|
|
26
|
+
device.on(DEVICE.PIN_ON_DEVICE_COMPLETE, (...args) => completions.push(args));
|
|
27
|
+
|
|
28
|
+
await device.unlockDevice(DeviceSessionPinType.Main, {
|
|
29
|
+
source: 'unlock-coordinator',
|
|
30
|
+
reason: 'device-locked',
|
|
31
|
+
deviceOnly: true,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const startMetadata = (starts[0] as unknown[])[2] as Record<string, unknown>;
|
|
35
|
+
const completionMetadata = (completions[0] as unknown[])[1] as Record<string, unknown>;
|
|
36
|
+
expect(startMetadata.interaction).toMatchObject({
|
|
37
|
+
phase: 'pin',
|
|
38
|
+
transition: 'start',
|
|
39
|
+
protocol: 'V2',
|
|
40
|
+
});
|
|
41
|
+
expect(completionMetadata).toMatchObject({
|
|
42
|
+
interactionId: (startMetadata.interaction as { interactionId: string }).interactionId,
|
|
43
|
+
phaseId: (startMetadata.interaction as { phaseId: string }).phaseId,
|
|
44
|
+
phase: 'pin',
|
|
45
|
+
transition: 'complete',
|
|
46
|
+
outcome: 'succeeded',
|
|
47
|
+
protocol: 'V2',
|
|
48
|
+
});
|
|
49
|
+
expect(completionMetadata.sequence).toBeGreaterThan(
|
|
50
|
+
(startMetadata.interaction as { sequence: number }).sequence
|
|
51
|
+
);
|
|
52
|
+
expect(completionMetadata.phaseId).toBe(
|
|
53
|
+
(startMetadata.interaction as { phaseId: string }).phaseId
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
});
|