@onekeyfe/hd-core 1.2.2-alpha.15 → 1.2.2-alpha.17
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__/device-lifecycle-events.test.ts +22 -14
- package/__tests__/open-wallet-session.test.ts +53 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +25 -20
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/core/index.ts +16 -9
- package/src/protocols/protocol-v2/walletSession.ts +7 -2
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
initConnector,
|
|
7
7
|
initCore,
|
|
8
8
|
isMissingDetectedProtocolV2Error,
|
|
9
|
-
isProtocolV2PeerRemovedPairingError,
|
|
10
9
|
isRetryableBleConnectionError,
|
|
11
10
|
isRetryableBleProtocolV2ProbeError,
|
|
11
|
+
isTerminalBleStaleBondError,
|
|
12
12
|
resolveBleConnectProtocol,
|
|
13
13
|
} from '../src/core';
|
|
14
14
|
import { DataManager } from '../src/data-manager';
|
|
@@ -367,6 +367,7 @@ describe('public device lifecycle events', () => {
|
|
|
367
367
|
[HardwareErrorCode.PollingTimeout, false],
|
|
368
368
|
[HardwareErrorCode.BleDeviceBondError, false],
|
|
369
369
|
[HardwareErrorCode.BlePeerRemovedPairingInformation, false],
|
|
370
|
+
[HardwareErrorCode.BleBondInvalid, false],
|
|
370
371
|
] as const)('retries a BLE connection error with error code %s: %s', (errorCode, expected) => {
|
|
371
372
|
const method = { payload: { connectProtocol: 'V2' } } as never;
|
|
372
373
|
const error = {
|
|
@@ -377,21 +378,28 @@ describe('public device lifecycle events', () => {
|
|
|
377
378
|
expect(isRetryableBleConnectionError(method, error)).toBe(expected);
|
|
378
379
|
});
|
|
379
380
|
|
|
381
|
+
test('does not retry the desktop acquire deadline fallback', () => {
|
|
382
|
+
const method = { payload: { connectProtocol: 'V2' } } as never;
|
|
383
|
+
const error = {
|
|
384
|
+
errorCode: HardwareErrorCode.BleTimeoutError,
|
|
385
|
+
params: { acquireDeadlineExceeded: true },
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
expect(isRetryableBleConnectionError(method, error)).toBe(false);
|
|
389
|
+
});
|
|
390
|
+
|
|
380
391
|
test.each([
|
|
381
|
-
[
|
|
382
|
-
[
|
|
383
|
-
[
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
errorCode: HardwareErrorCode.BlePeerRemovedPairingInformation,
|
|
390
|
-
};
|
|
392
|
+
[HardwareErrorCode.BleDeviceBondError, true],
|
|
393
|
+
[HardwareErrorCode.BlePeerRemovedPairingInformation, true],
|
|
394
|
+
[HardwareErrorCode.BleBondInvalid, true],
|
|
395
|
+
[HardwareErrorCode.DeviceNotFound, false],
|
|
396
|
+
] as const)('treats BLE stale-bond error code %s as terminal: %s', (errorCode, expected) => {
|
|
397
|
+
const error = {
|
|
398
|
+
errorCode,
|
|
399
|
+
};
|
|
391
400
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
);
|
|
401
|
+
expect(isTerminalBleStaleBondError(error)).toBe(expected);
|
|
402
|
+
});
|
|
395
403
|
|
|
396
404
|
test('converts an internal transport disconnect into a public KnownDevice snapshot', () => {
|
|
397
405
|
jest.spyOn(DataManager, 'getSettings').mockReturnValue('react-native' as never);
|
|
@@ -2080,6 +2080,59 @@ describe('openWalletSession', () => {
|
|
|
2080
2080
|
expect(deviceWalletSessionStore.get('device-1', 'hidden-state')).toBe('renewed-session');
|
|
2081
2081
|
});
|
|
2082
2082
|
|
|
2083
|
+
test('recovers the current Attach PIN wallet when the cached session is invalid', async () => {
|
|
2084
|
+
const typedCall = jest
|
|
2085
|
+
.fn()
|
|
2086
|
+
.mockResolvedValueOnce({ message: { version: 2 } })
|
|
2087
|
+
.mockRejectedValueOnce(
|
|
2088
|
+
Object.assign(new Error('Invalid session'), {
|
|
2089
|
+
errorCode: HardwareErrorCode.WalletSessionInvalid,
|
|
2090
|
+
})
|
|
2091
|
+
)
|
|
2092
|
+
.mockResolvedValueOnce({
|
|
2093
|
+
message: {
|
|
2094
|
+
btc_test_address: 'hidden-state',
|
|
2095
|
+
session_id: 'renewed-session',
|
|
2096
|
+
},
|
|
2097
|
+
});
|
|
2098
|
+
const promptPassphrase = jest.fn();
|
|
2099
|
+
const method = new OpenWalletSession({
|
|
2100
|
+
payload: {
|
|
2101
|
+
method: 'openWalletSession',
|
|
2102
|
+
connectId: 'connect-id',
|
|
2103
|
+
mode: 'resume-hidden',
|
|
2104
|
+
deviceId: 'device-1',
|
|
2105
|
+
passphraseState: 'hidden-state',
|
|
2106
|
+
},
|
|
2107
|
+
});
|
|
2108
|
+
method.init();
|
|
2109
|
+
deviceWalletSessionStore.set('device-1', 'hidden-state', 'expired-session');
|
|
2110
|
+
const device = createDevice({ unlockedAttachPin: true, typedCall, promptPassphrase });
|
|
2111
|
+
method.device = device as any;
|
|
2112
|
+
|
|
2113
|
+
await expect(method.run()).resolves.toEqual({
|
|
2114
|
+
protocol: 'V2',
|
|
2115
|
+
walletType: 'hidden',
|
|
2116
|
+
deviceId: 'device-1',
|
|
2117
|
+
passphraseState: 'hidden-state',
|
|
2118
|
+
resumed: false,
|
|
2119
|
+
});
|
|
2120
|
+
expect(typedCall.mock.calls.filter(call => call[0] === 'DeviceSessionGet')).toEqual([
|
|
2121
|
+
[
|
|
2122
|
+
'DeviceSessionGet',
|
|
2123
|
+
'DeviceSession',
|
|
2124
|
+
{
|
|
2125
|
+
session_id: 'expired-session',
|
|
2126
|
+
btc_test_address: 'hidden-state',
|
|
2127
|
+
},
|
|
2128
|
+
],
|
|
2129
|
+
['DeviceSessionGet', 'DeviceSession', {}],
|
|
2130
|
+
]);
|
|
2131
|
+
expect(promptPassphrase).not.toHaveBeenCalled();
|
|
2132
|
+
expect(device.lockDevice).not.toHaveBeenCalled();
|
|
2133
|
+
expect(deviceWalletSessionStore.get('device-1', 'hidden-state')).toBe('renewed-session');
|
|
2134
|
+
});
|
|
2135
|
+
|
|
2083
2136
|
test('selects the expected hidden wallet when Protocol V2 has no cached session', async () => {
|
|
2084
2137
|
const typedCall = jest
|
|
2085
2138
|
.fn()
|
package/dist/core/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare const callAPI: (context: CoreContext, message: CoreMessage) => Pr
|
|
|
11
11
|
export declare function isRetryableBleProtocolV2ProbeError(method: BaseMethod, error: unknown): boolean;
|
|
12
12
|
export declare function isRetryableBleConnectionError(method: BaseMethod, error: unknown): boolean;
|
|
13
13
|
export declare function isMissingDetectedProtocolV2Error(method: BaseMethod, error: unknown): boolean;
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function isTerminalBleStaleBondError(error: unknown): boolean;
|
|
15
15
|
export declare function resolveBleConnectProtocol(method: BaseMethod): ProtocolType | undefined;
|
|
16
16
|
export declare const cancel: (context: CoreContext, connectId?: string) => void;
|
|
17
17
|
export declare const onDeviceButtonHandler: (__0_0: Device, __0_1: import("../events").DeviceButtonRequestPayload) => void;
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAEL,KAAK,6BAA6B,EAElC,KAAK,YAAY,EAIlB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAEL,KAAK,6BAA6B,EAElC,KAAK,YAAY,EAIlB,MAAM,wBAAwB,CAAC;AAgChC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAsB1C,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAYxD,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,UAAU,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAmD,MAAM,WAAW,CAAC;AAI9F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAWpD,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;AA0E7D,eAAO,MAAM,OAAO,YAAmB,WAAW,WAAW,WAAW,iBAoFvE,CAAC;AAyqBF,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,WAWpF;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,WAoB/E;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,WAQlF;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,WAEzD;AA8JD,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,UAAU,GAAG,YAAY,GAAG,SAAS,CAMtF;AAwLD,eAAO,MAAM,MAAM,YAAa,WAAW,cAAc,MAAM,SA4G9D,CAAC;AA8GF,eAAO,MAAM,qBAAqB,gFAejC,CAAC;AAiLF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,YAAY;IAC5C,OAAO,CAAC,cAAc,CAAoB;IAE1C,SAAgB,aAAa,EAAE,MAAM,CAAC;IAEtC,OAAO,CAAC,YAAY,CAAsB;IAE1C,OAAO,CAAC,cAAc,CAAC,CAAgB;IAGvC,OAAO,CAAC,sBAAsB,CAAoC;IAElE,OAAO,CAAC,iBAAiB,CAAoB;;IAS7C,OAAO,CAAC,cAAc;IA6BhB,aAAa,CAAC,OAAO,EAAE,WAAW;IAuExC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAOV,gBAAgB;CAiC/B;AAED,eAAO,MAAM,QAAQ,YAIpB,CAAC;AAEF,eAAO,MAAM,aAAa,uBAYzB,CAAC;AAMF,eAAO,MAAM,IAAI,aACL,eAAe,aACd,GAAG,WACL,6BAA6B,8BAiBvC,CAAC;AAEF,eAAO,MAAM,eAAe;SAKrB,eAAe,CAAC,KAAK,CAAC;eAChB,GAAG;;UASf,CAAC"}
|
|
@@ -31,7 +31,7 @@ export declare const cancelDeviceInPrompt: (device: Device, expectResponse?: boo
|
|
|
31
31
|
};
|
|
32
32
|
} | {
|
|
33
33
|
success: boolean;
|
|
34
|
-
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902;
|
|
34
|
+
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902;
|
|
35
35
|
payload: {
|
|
36
36
|
message: string;
|
|
37
37
|
};
|
|
@@ -50,7 +50,7 @@ export declare const cancelDeviceWithInitialize: (device: Device) => Promise<{
|
|
|
50
50
|
};
|
|
51
51
|
} | {
|
|
52
52
|
success: boolean;
|
|
53
|
-
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902;
|
|
53
|
+
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902;
|
|
54
54
|
payload: {
|
|
55
55
|
message: string;
|
|
56
56
|
};
|
|
@@ -80,7 +80,7 @@ export declare class DeviceCommands {
|
|
|
80
80
|
};
|
|
81
81
|
} | {
|
|
82
82
|
success: boolean;
|
|
83
|
-
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902;
|
|
83
|
+
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902;
|
|
84
84
|
payload: {
|
|
85
85
|
message: string;
|
|
86
86
|
};
|
|
@@ -99,7 +99,7 @@ export declare class DeviceCommands {
|
|
|
99
99
|
};
|
|
100
100
|
} | {
|
|
101
101
|
success: boolean;
|
|
102
|
-
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902;
|
|
102
|
+
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902;
|
|
103
103
|
payload: {
|
|
104
104
|
message: string;
|
|
105
105
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -136,7 +136,7 @@ declare class DeviceCommands {
|
|
|
136
136
|
};
|
|
137
137
|
} | {
|
|
138
138
|
success: boolean;
|
|
139
|
-
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902;
|
|
139
|
+
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902;
|
|
140
140
|
payload: {
|
|
141
141
|
message: string;
|
|
142
142
|
};
|
|
@@ -155,7 +155,7 @@ declare class DeviceCommands {
|
|
|
155
155
|
};
|
|
156
156
|
} | {
|
|
157
157
|
success: boolean;
|
|
158
|
-
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902;
|
|
158
|
+
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902;
|
|
159
159
|
payload: {
|
|
160
160
|
message: string;
|
|
161
161
|
};
|
package/dist/index.js
CHANGED
|
@@ -41817,7 +41817,7 @@ const selectDeviceSession = (device, expectedPassphraseState, deriveCardano, onS
|
|
|
41817
41817
|
return getDeviceSession(device, buildDeviceSessionGetRequest());
|
|
41818
41818
|
});
|
|
41819
41819
|
function getProtocolV2WalletSession(device, options) {
|
|
41820
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
41820
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
41821
41821
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41822
41822
|
const forceWalletSelection = (options === null || options === void 0 ? void 0 : options.forceWalletSelection) === true || (options === null || options === void 0 ? void 0 : options.initSession) === true;
|
|
41823
41823
|
const readCurrentAttachPinSession = (options === null || options === void 0 ? void 0 : options.readCurrentAttachPinSession) === true;
|
|
@@ -41888,7 +41888,7 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
41888
41888
|
return keepAttachPin ? Object.assign(session, { viaAttachPin: true }) : session;
|
|
41889
41889
|
});
|
|
41890
41890
|
const rejectMismatchedAttachPinWallet = () => __awaiter(this, void 0, void 0, function* () {
|
|
41891
|
-
var
|
|
41891
|
+
var _o;
|
|
41892
41892
|
const features = yield refreshProtocolV2DeviceStatus(device);
|
|
41893
41893
|
markWalletStatusRefreshed();
|
|
41894
41894
|
if (features.unlockedAttachPin !== true) {
|
|
@@ -41897,10 +41897,10 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
41897
41897
|
try {
|
|
41898
41898
|
yield device.lockDevice();
|
|
41899
41899
|
}
|
|
41900
|
-
catch (
|
|
41900
|
+
catch (_p) {
|
|
41901
41901
|
}
|
|
41902
41902
|
if (options === null || options === void 0 ? void 0 : options.rejectAttachPinForMainWallet) {
|
|
41903
|
-
(
|
|
41903
|
+
(_o = device.clearStandardInternalState) === null || _o === void 0 ? void 0 : _o.call(device);
|
|
41904
41904
|
device.clearInternalState();
|
|
41905
41905
|
}
|
|
41906
41906
|
else {
|
|
@@ -41909,11 +41909,11 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
41909
41909
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckUnlockTypeError);
|
|
41910
41910
|
});
|
|
41911
41911
|
const lockAttachPinBeforePassphraseSelection = () => __awaiter(this, void 0, void 0, function* () {
|
|
41912
|
-
var
|
|
41912
|
+
var _q;
|
|
41913
41913
|
if (readCurrentAttachPinSession || (options === null || options === void 0 ? void 0 : options.onlyMainPin)) {
|
|
41914
41914
|
return;
|
|
41915
41915
|
}
|
|
41916
|
-
if (((
|
|
41916
|
+
if (((_q = device.features) === null || _q === void 0 ? void 0 : _q.unlockedAttachPin) !== true) {
|
|
41917
41917
|
return;
|
|
41918
41918
|
}
|
|
41919
41919
|
yield rejectMismatchedAttachPinWallet();
|
|
@@ -41934,8 +41934,8 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
41934
41934
|
}
|
|
41935
41935
|
});
|
|
41936
41936
|
const selectStandardWallet = (forceMainPin = false) => __awaiter(this, void 0, void 0, function* () {
|
|
41937
|
-
var
|
|
41938
|
-
if (((
|
|
41937
|
+
var _r;
|
|
41938
|
+
if (((_r = device.features) === null || _r === void 0 ? void 0 : _r.passphraseProtection) === true) {
|
|
41939
41939
|
yield selectMainPin();
|
|
41940
41940
|
yield askDevicePassphrase(device, {
|
|
41941
41941
|
passphrase: '',
|
|
@@ -42000,6 +42000,9 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
42000
42000
|
throw error;
|
|
42001
42001
|
}
|
|
42002
42002
|
resumed = false;
|
|
42003
|
+
if (((_g = device.features) === null || _g === void 0 ? void 0 : _g.unlockedAttachPin) === true) {
|
|
42004
|
+
response = yield getDeviceSession(device, sessionGetRequest());
|
|
42005
|
+
}
|
|
42003
42006
|
}
|
|
42004
42007
|
}
|
|
42005
42008
|
else if (expectedPassphraseState) {
|
|
@@ -42028,7 +42031,7 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
42028
42031
|
}
|
|
42029
42032
|
catch (error) {
|
|
42030
42033
|
if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
42031
|
-
(
|
|
42034
|
+
(_h = device.clearStandardInternalState) === null || _h === void 0 ? void 0 : _h.call(device);
|
|
42032
42035
|
}
|
|
42033
42036
|
else {
|
|
42034
42037
|
device.clearInternalState();
|
|
@@ -42043,7 +42046,7 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
42043
42046
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.WalletSessionInvalid);
|
|
42044
42047
|
}
|
|
42045
42048
|
if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
42046
|
-
(
|
|
42049
|
+
(_j = device.clearStandardInternalState) === null || _j === void 0 ? void 0 : _j.call(device);
|
|
42047
42050
|
yield selectStandardWallet(true);
|
|
42048
42051
|
response = yield getDeviceSession(device, sessionGetRequest());
|
|
42049
42052
|
}
|
|
@@ -42058,7 +42061,7 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
42058
42061
|
}
|
|
42059
42062
|
catch (error) {
|
|
42060
42063
|
if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
42061
|
-
(
|
|
42064
|
+
(_k = device.clearStandardInternalState) === null || _k === void 0 ? void 0 : _k.call(device);
|
|
42062
42065
|
}
|
|
42063
42066
|
else {
|
|
42064
42067
|
device.clearInternalState();
|
|
@@ -42081,7 +42084,7 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
42081
42084
|
if (sessionIsAttachPinWallet(response)) {
|
|
42082
42085
|
response = yield askEmptyPassphraseAndGet({ deriveCardano: true, keepAttachPin: true });
|
|
42083
42086
|
}
|
|
42084
|
-
else if (((
|
|
42087
|
+
else if (((_l = device.features) === null || _l === void 0 ? void 0 : _l.passphraseProtection) === false) {
|
|
42085
42088
|
response = yield getDeviceSession(device, buildDeviceSessionGetRequest());
|
|
42086
42089
|
}
|
|
42087
42090
|
else if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
@@ -42098,7 +42101,7 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
42098
42101
|
}
|
|
42099
42102
|
catch (error) {
|
|
42100
42103
|
if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
42101
|
-
(
|
|
42104
|
+
(_m = device.clearStandardInternalState) === null || _m === void 0 ? void 0 : _m.call(device);
|
|
42102
42105
|
}
|
|
42103
42106
|
else {
|
|
42104
42107
|
device.clearInternalState();
|
|
@@ -66369,11 +66372,15 @@ function isRetryableBleProtocolV2ProbeError(method, error) {
|
|
|
66369
66372
|
message.includes('did not respond to expected protocol'));
|
|
66370
66373
|
}
|
|
66371
66374
|
function isRetryableBleConnectionError(method, error) {
|
|
66372
|
-
var _a;
|
|
66375
|
+
var _a, _b;
|
|
66373
66376
|
if ((_a = method.device) === null || _a === void 0 ? void 0 : _a.wasInterruptedByUser()) {
|
|
66374
66377
|
return false;
|
|
66375
66378
|
}
|
|
66376
66379
|
const typedError = error;
|
|
66380
|
+
if ((typedError === null || typedError === void 0 ? void 0 : typedError.errorCode) === hdShared.HardwareErrorCode.BleTimeoutError &&
|
|
66381
|
+
((_b = typedError.params) === null || _b === void 0 ? void 0 : _b.acquireDeadlineExceeded) === true) {
|
|
66382
|
+
return false;
|
|
66383
|
+
}
|
|
66377
66384
|
return ((typedError === null || typedError === void 0 ? void 0 : typedError.errorCode) === hdShared.HardwareErrorCode.BleTimeoutError ||
|
|
66378
66385
|
(typedError === null || typedError === void 0 ? void 0 : typedError.errorCode) === hdShared.HardwareErrorCode.BleConnectedError ||
|
|
66379
66386
|
isRetryableBleProtocolV2ProbeError(method, error) ||
|
|
@@ -66386,10 +66393,8 @@ function isMissingDetectedProtocolV2Error(method, error) {
|
|
|
66386
66393
|
typeof typedError.message === 'string' &&
|
|
66387
66394
|
typedError.message.includes('Device protocol has not been detected'));
|
|
66388
66395
|
}
|
|
66389
|
-
function
|
|
66390
|
-
return (
|
|
66391
|
-
(error === null || error === void 0 ? void 0 : error.errorCode) ===
|
|
66392
|
-
hdShared.HardwareErrorCode.BlePeerRemovedPairingInformation);
|
|
66396
|
+
function isTerminalBleStaleBondError(error) {
|
|
66397
|
+
return hdShared.isBleStaleBondHardwareError(error);
|
|
66393
66398
|
}
|
|
66394
66399
|
const BLE_ACQUIRE_DEADLINE_MS = 60 * 1000;
|
|
66395
66400
|
function raceBleAcquire(acquirePromise, abortSignal) {
|
|
@@ -66404,7 +66409,7 @@ function raceBleAcquire(acquirePromise, abortSignal) {
|
|
|
66404
66409
|
fn();
|
|
66405
66410
|
};
|
|
66406
66411
|
const onAbort = () => settle(() => reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallQueueActionCancelled)));
|
|
66407
|
-
const deadline = setTimeout(() => settle(() => reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleTimeoutError, `BLE acquire exceeded ${BLE_ACQUIRE_DEADLINE_MS}ms deadline
|
|
66412
|
+
const deadline = setTimeout(() => settle(() => reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleTimeoutError, `BLE acquire exceeded ${BLE_ACQUIRE_DEADLINE_MS}ms deadline`, { acquireDeadlineExceeded: true }))), BLE_ACQUIRE_DEADLINE_MS);
|
|
66408
66413
|
acquirePromise.then(value => settle(() => resolve(value)), error => settle(() => reject(error)));
|
|
66409
66414
|
if (abortSignal) {
|
|
66410
66415
|
if (abortSignal.aborted) {
|
|
@@ -66621,7 +66626,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
66621
66626
|
hdShared.HardwareErrorCode.DeviceInterruptedFromUser,
|
|
66622
66627
|
hdShared.HardwareErrorCode.CallQueueActionCancelled,
|
|
66623
66628
|
].includes(error.errorCode) ||
|
|
66624
|
-
|
|
66629
|
+
isTerminalBleStaleBondError(error)) {
|
|
66625
66630
|
reject(error);
|
|
66626
66631
|
return;
|
|
66627
66632
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walletSession.d.ts","sourceRoot":"","sources":["../../../src/protocols/protocol-v2/walletSession.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAuBlD,wBAAsB,6BAA6B,CAAC,MAAM,EAAE,MAAM,0DAGjE;AAED,wBAAsB,6BAA6B,CAAC,MAAM,EAAE,MAAM,qCAGjE;AAED,wBAAsB,qCAAqC,CAAC,MAAM,EAAE,MAAM,oBAgBzE;AA8JD,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IACR,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,2BAA2B,CAAC,EAAE,OAAO,CAAC;IAEtC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;;;;;;
|
|
1
|
+
{"version":3,"file":"walletSession.d.ts","sourceRoot":"","sources":["../../../src/protocols/protocol-v2/walletSession.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAuBlD,wBAAsB,6BAA6B,CAAC,MAAM,EAAE,MAAM,0DAGjE;AAED,wBAAsB,6BAA6B,CAAC,MAAM,EAAE,MAAM,qCAGjE;AAED,wBAAsB,qCAAqC,CAAC,MAAM,EAAE,MAAM,oBAgBzE;AA8JD,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IACR,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,2BAA2B,CAAC,EAAE,OAAO,CAAC;IAEtC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;;;;;;GAkYF;AAED,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,MAAM,EACd,uBAAuB,EAAE,MAAM,EAC/B,aAAa,CAAC,EAAE,OAAO;;;;;;GAOxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.2.2-alpha.
|
|
3
|
+
"version": "1.2.2-alpha.17",
|
|
4
4
|
"description": "Core processes and APIs for communicating with OneKey hardware devices.",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@onekeyfe/hd-shared": "1.2.2-alpha.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.2.2-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.2.2-alpha.17",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.2-alpha.17",
|
|
30
30
|
"axios": "1.15.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"buffer": "^6.0.3",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"@types/w3c-web-usb": "^1.0.10",
|
|
47
47
|
"@types/web-bluetooth": "^0.0.21"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "b6c48b842d1c325dcd5ce42c03a07ee4377002dd"
|
|
50
50
|
}
|
package/src/core/index.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
createNeedUpgradeFirmwareHardwareError,
|
|
23
23
|
createNewFirmwareForceUpdateHardwareError,
|
|
24
24
|
createNewFirmwareUnReleaseHardwareError,
|
|
25
|
+
isBleStaleBondHardwareError,
|
|
25
26
|
} from '@onekeyfe/hd-shared';
|
|
26
27
|
|
|
27
28
|
import { LoggerNames, enableLog, getLogger, setLoggerPostMessage, wait } from '../utils';
|
|
@@ -945,7 +946,16 @@ export function isRetryableBleConnectionError(method: BaseMethod, error: unknown
|
|
|
945
946
|
if (method.device?.wasInterruptedByUser()) {
|
|
946
947
|
return false;
|
|
947
948
|
}
|
|
948
|
-
const typedError = error as {
|
|
949
|
+
const typedError = error as {
|
|
950
|
+
errorCode?: unknown;
|
|
951
|
+
params?: { acquireDeadlineExceeded?: unknown };
|
|
952
|
+
};
|
|
953
|
+
if (
|
|
954
|
+
typedError?.errorCode === HardwareErrorCode.BleTimeoutError &&
|
|
955
|
+
typedError.params?.acquireDeadlineExceeded === true
|
|
956
|
+
) {
|
|
957
|
+
return false;
|
|
958
|
+
}
|
|
949
959
|
return (
|
|
950
960
|
typedError?.errorCode === HardwareErrorCode.BleTimeoutError ||
|
|
951
961
|
typedError?.errorCode === HardwareErrorCode.BleConnectedError ||
|
|
@@ -964,12 +974,8 @@ export function isMissingDetectedProtocolV2Error(method: BaseMethod, error: unkn
|
|
|
964
974
|
);
|
|
965
975
|
}
|
|
966
976
|
|
|
967
|
-
export function
|
|
968
|
-
return (
|
|
969
|
-
method.payload.connectProtocol === 'V2' &&
|
|
970
|
-
(error as { errorCode?: unknown })?.errorCode ===
|
|
971
|
-
HardwareErrorCode.BlePeerRemovedPairingInformation
|
|
972
|
-
);
|
|
977
|
+
export function isTerminalBleStaleBondError(error: unknown) {
|
|
978
|
+
return isBleStaleBondHardwareError(error);
|
|
973
979
|
}
|
|
974
980
|
|
|
975
981
|
/**
|
|
@@ -1001,7 +1007,8 @@ function raceBleAcquire<T>(acquirePromise: Promise<T>, abortSignal?: AbortSignal
|
|
|
1001
1007
|
reject(
|
|
1002
1008
|
ERRORS.TypedError(
|
|
1003
1009
|
HardwareErrorCode.BleTimeoutError,
|
|
1004
|
-
`BLE acquire exceeded ${BLE_ACQUIRE_DEADLINE_MS}ms deadline
|
|
1010
|
+
`BLE acquire exceeded ${BLE_ACQUIRE_DEADLINE_MS}ms deadline`,
|
|
1011
|
+
{ acquireDeadlineExceeded: true }
|
|
1005
1012
|
)
|
|
1006
1013
|
)
|
|
1007
1014
|
),
|
|
@@ -1283,7 +1290,7 @@ const ensureConnected = async (
|
|
|
1283
1290
|
HardwareErrorCode.DeviceInterruptedFromUser,
|
|
1284
1291
|
HardwareErrorCode.CallQueueActionCancelled,
|
|
1285
1292
|
].includes(error.errorCode) ||
|
|
1286
|
-
|
|
1293
|
+
isTerminalBleStaleBondError(error)
|
|
1287
1294
|
) {
|
|
1288
1295
|
reject(error);
|
|
1289
1296
|
return;
|
|
@@ -234,9 +234,9 @@ export async function getProtocolV2WalletSession(
|
|
|
234
234
|
const forceWalletSelection =
|
|
235
235
|
options?.forceWalletSelection === true || options?.initSession === true;
|
|
236
236
|
const readCurrentAttachPinSession = options?.readCurrentAttachPinSession === true;
|
|
237
|
-
const sessionIsAttachPinWallet = (session?:
|
|
237
|
+
const sessionIsAttachPinWallet = (session?: unknown) =>
|
|
238
238
|
readCurrentAttachPinSession ||
|
|
239
|
-
session?.viaAttachPin === true ||
|
|
239
|
+
(session as { viaAttachPin?: boolean } | undefined)?.viaAttachPin === true ||
|
|
240
240
|
device.features?.unlockedAttachPin === true;
|
|
241
241
|
|
|
242
242
|
if (forceWalletSelection) {
|
|
@@ -455,6 +455,11 @@ export async function getProtocolV2WalletSession(
|
|
|
455
455
|
throw error;
|
|
456
456
|
}
|
|
457
457
|
resumed = false;
|
|
458
|
+
if (device.features?.unlockedAttachPin === true) {
|
|
459
|
+
// Locking invalidates the old handle, but Attach PIN already selected the wallet.
|
|
460
|
+
// Read the current session and validate its passphrase state below.
|
|
461
|
+
response = await getDeviceSession(device, sessionGetRequest());
|
|
462
|
+
}
|
|
458
463
|
}
|
|
459
464
|
} else if (expectedPassphraseState) {
|
|
460
465
|
try {
|