@onekeyfe/hd-core 1.2.0-alpha.53 → 1.2.0-alpha.55
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 +153 -0
- package/__tests__/kaspaSignTransaction.test.ts +3 -26
- package/__tests__/open-wallet-session.test.ts +123 -5
- package/__tests__/protocol-v2-resources.test.ts +5 -3
- package/__tests__/protocol-v2.test.ts +12 -18
- 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/kaspa/KaspaSignTransaction.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +66 -39
- package/dist/protocols/protocol-v2/features.d.ts +0 -4
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts +1 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +3 -0
- package/src/api/OpenWalletSession.ts +18 -2
- package/src/api/allnetwork/AllNetworkGetAddress.ts +21 -21
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +5 -3
- package/src/api/kaspa/KaspaSignTransaction.ts +1 -12
- package/src/data-manager/DataManager.ts +5 -2
- package/src/device/Device.ts +1 -1
- package/src/protocols/protocol-v2/features.ts +0 -4
- package/src/protocols/protocol-v2/walletSession.ts +35 -7
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import AllNetworkGetAddressBase from '../src/api/allnetwork/AllNetworkGetAddressBase';
|
|
2
|
+
import AllNetworkGetAddress from '../src/api/allnetwork/AllNetworkGetAddress';
|
|
2
3
|
import { findMethod } from '../src/api/utils';
|
|
3
4
|
import { getActiveRequestsByDeviceInstance } from '../src/utils/tracing';
|
|
4
5
|
|
|
@@ -95,6 +96,158 @@ describe('AllNetworkGetAddressBase tracing', () => {
|
|
|
95
96
|
expect(typedCall).not.toHaveBeenCalled();
|
|
96
97
|
});
|
|
97
98
|
|
|
99
|
+
test('resumes a Protocol V2 standard wallet before running a nested chain method', async () => {
|
|
100
|
+
const calls: string[] = [];
|
|
101
|
+
const checkPassphraseStateSafety = jest.fn().mockImplementation(() => {
|
|
102
|
+
calls.push('resume-standard-session');
|
|
103
|
+
return Promise.resolve(true);
|
|
104
|
+
});
|
|
105
|
+
const innerMethod = {
|
|
106
|
+
checkSafetyLevelOnTestNet: jest.fn().mockResolvedValue(false),
|
|
107
|
+
connectId: 'connect-id',
|
|
108
|
+
deviceId: 'device-id',
|
|
109
|
+
getVersionRange: jest.fn().mockReturnValue({}),
|
|
110
|
+
assertProtocolSupported: jest.fn(),
|
|
111
|
+
init: jest.fn(),
|
|
112
|
+
name: 'evmGetAddress',
|
|
113
|
+
responseID: 44,
|
|
114
|
+
unlockPolicy: 'unlock-before-run',
|
|
115
|
+
run: jest.fn().mockImplementation(() => {
|
|
116
|
+
calls.push('run-chain-method');
|
|
117
|
+
return Promise.resolve([{ address: '0xstandard' }]);
|
|
118
|
+
}),
|
|
119
|
+
setDevice: jest.fn(),
|
|
120
|
+
strictCheckDeviceSupport: false,
|
|
121
|
+
};
|
|
122
|
+
(findMethod as jest.Mock).mockReturnValue(innerMethod);
|
|
123
|
+
const method = new TestAllNetworkMethod({
|
|
124
|
+
id: 2,
|
|
125
|
+
payload: {
|
|
126
|
+
method: 'allNetworkGetAddress',
|
|
127
|
+
connectId: 'connect-id',
|
|
128
|
+
deviceId: 'device-id',
|
|
129
|
+
useEmptyPassphrase: true,
|
|
130
|
+
bundle: [],
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
method.protocolV2UnlockContext = { preflightCompleted: true };
|
|
134
|
+
const typedCall = jest.fn();
|
|
135
|
+
method.device = {
|
|
136
|
+
checkPassphraseStateSafety,
|
|
137
|
+
commands: {
|
|
138
|
+
typedCall,
|
|
139
|
+
},
|
|
140
|
+
getCurrentFirmwareType: jest.fn(),
|
|
141
|
+
getProtocol: jest.fn().mockReturnValue('V2'),
|
|
142
|
+
getCurrentFirmwareVersionString: jest.fn().mockReturnValue('1.0.0'),
|
|
143
|
+
getCurrentMethodVersionRange: jest
|
|
144
|
+
.fn()
|
|
145
|
+
.mockImplementation((getRange: (type: string) => unknown) => getRange('pro2')),
|
|
146
|
+
instanceId: 'device-instance',
|
|
147
|
+
isProtocolV2: jest.fn().mockReturnValue(true),
|
|
148
|
+
isBootloader: jest.fn().mockReturnValue(false),
|
|
149
|
+
isRomloader: jest.fn().mockReturnValue(false),
|
|
150
|
+
off: jest.fn(),
|
|
151
|
+
on: jest.fn(),
|
|
152
|
+
state: { status: { unlocked: true } },
|
|
153
|
+
updateProtocolV2Status: jest.fn(),
|
|
154
|
+
} as any;
|
|
155
|
+
|
|
156
|
+
await method.callMethod(
|
|
157
|
+
'evmGetAddress',
|
|
158
|
+
{
|
|
159
|
+
bundle: [
|
|
160
|
+
{
|
|
161
|
+
_originRequestParams: {
|
|
162
|
+
network: 'evm',
|
|
163
|
+
path: "m/44'/60'/0'/0/0",
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
0
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
expect(checkPassphraseStateSafety).toHaveBeenCalledWith(undefined, true, undefined);
|
|
172
|
+
expect(calls).toEqual(['resume-standard-session', 'run-chain-method']);
|
|
173
|
+
expect(typedCall).not.toHaveBeenCalled();
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test('runs Protocol V2 addresses one at a time so each command receives a wallet session', async () => {
|
|
177
|
+
const method = new AllNetworkGetAddress({
|
|
178
|
+
id: 3,
|
|
179
|
+
payload: {
|
|
180
|
+
method: 'allNetworkGetAddress',
|
|
181
|
+
connectId: 'connect-id',
|
|
182
|
+
deviceId: 'device-id',
|
|
183
|
+
useEmptyPassphrase: true,
|
|
184
|
+
bundle: [
|
|
185
|
+
{ network: 'evm', path: "m/44'/60'/0'/0/0" },
|
|
186
|
+
{ network: 'evm', path: "m/44'/60'/0'/0/1" },
|
|
187
|
+
],
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
method.device = {
|
|
191
|
+
isProtocolV2: jest.fn().mockReturnValue(true),
|
|
192
|
+
} as any;
|
|
193
|
+
method.postMessage = jest.fn();
|
|
194
|
+
const callMethod = jest
|
|
195
|
+
.fn()
|
|
196
|
+
.mockResolvedValueOnce([{ payload: { address: '0x1' }, success: true }])
|
|
197
|
+
.mockResolvedValueOnce([{ payload: { address: '0x2' }, success: true }]);
|
|
198
|
+
method.callMethod = callMethod;
|
|
199
|
+
|
|
200
|
+
await method.getAllNetworkAddress(7);
|
|
201
|
+
|
|
202
|
+
expect(callMethod).toHaveBeenCalledTimes(2);
|
|
203
|
+
expect(callMethod).toHaveBeenNthCalledWith(
|
|
204
|
+
1,
|
|
205
|
+
'evmGetAddress',
|
|
206
|
+
expect.objectContaining({ bundle: [expect.any(Object)] }),
|
|
207
|
+
7
|
|
208
|
+
);
|
|
209
|
+
expect(callMethod).toHaveBeenNthCalledWith(
|
|
210
|
+
2,
|
|
211
|
+
'evmGetAddress',
|
|
212
|
+
expect.objectContaining({ bundle: [expect.any(Object)] }),
|
|
213
|
+
7
|
|
214
|
+
);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
test('keeps same-method address batching for Protocol V1', async () => {
|
|
218
|
+
const method = new AllNetworkGetAddress({
|
|
219
|
+
id: 4,
|
|
220
|
+
payload: {
|
|
221
|
+
method: 'allNetworkGetAddress',
|
|
222
|
+
connectId: 'connect-id',
|
|
223
|
+
deviceId: 'device-id',
|
|
224
|
+
useEmptyPassphrase: true,
|
|
225
|
+
bundle: [
|
|
226
|
+
{ network: 'evm', path: "m/44'/60'/0'/0/0" },
|
|
227
|
+
{ network: 'evm', path: "m/44'/60'/0'/0/1" },
|
|
228
|
+
],
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
method.device = {
|
|
232
|
+
isProtocolV2: jest.fn().mockReturnValue(false),
|
|
233
|
+
} as any;
|
|
234
|
+
method.postMessage = jest.fn();
|
|
235
|
+
const callMethod = jest.fn().mockResolvedValue([
|
|
236
|
+
{ payload: { address: '0x1' }, success: true },
|
|
237
|
+
{ payload: { address: '0x2' }, success: true },
|
|
238
|
+
]);
|
|
239
|
+
method.callMethod = callMethod;
|
|
240
|
+
|
|
241
|
+
await method.getAllNetworkAddress(7);
|
|
242
|
+
|
|
243
|
+
expect(callMethod).toHaveBeenCalledTimes(1);
|
|
244
|
+
expect(callMethod).toHaveBeenCalledWith(
|
|
245
|
+
'evmGetAddress',
|
|
246
|
+
expect.objectContaining({ bundle: [expect.any(Object), expect.any(Object)] }),
|
|
247
|
+
7
|
|
248
|
+
);
|
|
249
|
+
});
|
|
250
|
+
|
|
98
251
|
test('releases the nested request context when an unhandled error escapes', async () => {
|
|
99
252
|
const deviceInstanceId = 'device-instance';
|
|
100
253
|
const innerMethod = {
|
|
@@ -465,7 +465,7 @@ describe('KaspaSignTransaction protocol negotiation', () => {
|
|
|
465
465
|
expect(mockTypedCall.mock.calls[4][0]).toBe('KaspaTxAckInput');
|
|
466
466
|
});
|
|
467
467
|
|
|
468
|
-
describe('
|
|
468
|
+
describe('streaming error propagation', () => {
|
|
469
469
|
const PREV_ID = 'aa'.repeat(32);
|
|
470
470
|
const withRefTxs = {
|
|
471
471
|
outputs: [{ satoshis: 100000, script: SCRIPT, address: ADDRESS }],
|
|
@@ -486,7 +486,7 @@ describe('KaspaSignTransaction protocol negotiation', () => {
|
|
|
486
486
|
)
|
|
487
487
|
.mockRejectedValueOnce(error);
|
|
488
488
|
|
|
489
|
-
it('
|
|
489
|
+
it('propagates a previous-transaction id mismatch without retrying', async () => {
|
|
490
490
|
streamThenReject(
|
|
491
491
|
ERRORS.TypedError(
|
|
492
492
|
HardwareErrorCode.RuntimeError,
|
|
@@ -494,32 +494,9 @@ describe('KaspaSignTransaction protocol negotiation', () => {
|
|
|
494
494
|
)
|
|
495
495
|
);
|
|
496
496
|
|
|
497
|
-
await expect(runMethod(withRefTxs)).rejects.toMatchObject({
|
|
498
|
-
errorCode: HardwareErrorCode.KaspaPrevTxIdMismatch,
|
|
499
|
-
});
|
|
500
|
-
// Never silently re-signs without refTxs.
|
|
501
|
-
expect(mockTypedCall).toHaveBeenCalledTimes(2);
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
it('leaves an unrelated device error untouched', async () => {
|
|
505
|
-
streamThenReject(
|
|
506
|
-
ERRORS.TypedError(
|
|
507
|
-
HardwareErrorCode.RuntimeError,
|
|
508
|
-
'Failure_ProcessError,some other device error'
|
|
509
|
-
)
|
|
510
|
-
);
|
|
511
|
-
|
|
512
497
|
await expect(runMethod(withRefTxs)).rejects.toMatchObject({
|
|
513
498
|
errorCode: HardwareErrorCode.RuntimeError,
|
|
514
|
-
|
|
515
|
-
expect(mockTypedCall).toHaveBeenCalledTimes(2);
|
|
516
|
-
});
|
|
517
|
-
|
|
518
|
-
it('leaves user cancellation untouched', async () => {
|
|
519
|
-
streamThenReject(ERRORS.TypedError(HardwareErrorCode.ActionCancelled));
|
|
520
|
-
|
|
521
|
-
await expect(runMethod(withRefTxs)).rejects.toMatchObject({
|
|
522
|
-
errorCode: HardwareErrorCode.ActionCancelled,
|
|
499
|
+
message: expect.stringContaining('Kaspa previous transaction id mismatch'),
|
|
523
500
|
});
|
|
524
501
|
expect(mockTypedCall).toHaveBeenCalledTimes(2);
|
|
525
502
|
});
|
|
@@ -18,10 +18,14 @@ jest.mock('../src/data/config', () => ({
|
|
|
18
18
|
|
|
19
19
|
const createDevice = ({
|
|
20
20
|
passphraseProtection = true,
|
|
21
|
+
unlockedAttachPin = false,
|
|
22
|
+
refreshedUnlockedAttachPin = unlockedAttachPin,
|
|
21
23
|
typedCall = jest.fn(),
|
|
22
24
|
promptPassphrase = jest.fn(),
|
|
23
25
|
}: {
|
|
24
26
|
passphraseProtection?: boolean;
|
|
27
|
+
unlockedAttachPin?: boolean;
|
|
28
|
+
refreshedUnlockedAttachPin?: boolean;
|
|
25
29
|
typedCall?: jest.Mock;
|
|
26
30
|
promptPassphrase?: jest.Mock;
|
|
27
31
|
} = {}) => {
|
|
@@ -30,8 +34,8 @@ const createDevice = ({
|
|
|
30
34
|
features: {
|
|
31
35
|
unlocked: true,
|
|
32
36
|
passphraseProtection,
|
|
33
|
-
attachToPinEnabled:
|
|
34
|
-
unlockedAttachPin
|
|
37
|
+
attachToPinEnabled: unlockedAttachPin,
|
|
38
|
+
unlockedAttachPin,
|
|
35
39
|
},
|
|
36
40
|
commands: {
|
|
37
41
|
typedCall: jest.fn((request: string, ...args: unknown[]) => {
|
|
@@ -40,7 +44,9 @@ const createDevice = ({
|
|
|
40
44
|
message: {
|
|
41
45
|
device_id: 'device-1',
|
|
42
46
|
unlocked: true,
|
|
43
|
-
|
|
47
|
+
attach_to_pin_enabled: unlockedAttachPin,
|
|
48
|
+
unlocked_attach_pin: refreshedUnlockedAttachPin,
|
|
49
|
+
unlocked_by_attach_to_pin: refreshedUnlockedAttachPin,
|
|
44
50
|
passphrase_enabled: passphraseProtection,
|
|
45
51
|
},
|
|
46
52
|
};
|
|
@@ -82,8 +88,12 @@ const createDevice = ({
|
|
|
82
88
|
unlockDevice: jest.fn(),
|
|
83
89
|
updateProtocolV2Status: jest.fn((status: Record<string, unknown>) => {
|
|
84
90
|
device.features.unlocked = status.unlocked ?? device.features.unlocked;
|
|
91
|
+
device.features.attachToPinEnabled =
|
|
92
|
+
status.attach_to_pin_enabled ?? device.features.attachToPinEnabled;
|
|
85
93
|
device.features.unlockedAttachPin =
|
|
86
|
-
status.
|
|
94
|
+
status.unlocked_by_attach_to_pin ??
|
|
95
|
+
status.unlocked_attach_pin ??
|
|
96
|
+
device.features.unlockedAttachPin;
|
|
87
97
|
return device.features;
|
|
88
98
|
}),
|
|
89
99
|
initialize: jest.fn(),
|
|
@@ -614,7 +624,7 @@ describe('openWalletSession', () => {
|
|
|
614
624
|
expect(promptPassphrase).not.toHaveBeenCalled();
|
|
615
625
|
});
|
|
616
626
|
|
|
617
|
-
test('rejects a
|
|
627
|
+
test('rejects before prompting for a hidden wallet when Pro2 passphrase is disabled', async () => {
|
|
618
628
|
const typedCall = jest
|
|
619
629
|
.fn()
|
|
620
630
|
.mockResolvedValueOnce({ message: { version: 2 } })
|
|
@@ -641,6 +651,114 @@ describe('openWalletSession', () => {
|
|
|
641
651
|
errorCode: HardwareErrorCode.DeviceNotOpenedPassphrase,
|
|
642
652
|
});
|
|
643
653
|
expect(device.clearInternalState).toHaveBeenCalled();
|
|
654
|
+
expect(promptPassphrase).not.toHaveBeenCalled();
|
|
655
|
+
expect(typedCall).not.toHaveBeenCalledWith(
|
|
656
|
+
'DeviceSessionAskPassphrase',
|
|
657
|
+
'Success',
|
|
658
|
+
expect.anything()
|
|
659
|
+
);
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
test('reuses the current Attach PIN session without reopening wallet selection', async () => {
|
|
663
|
+
const typedCall = jest.fn((request: string) => {
|
|
664
|
+
if (request === 'ProtocolInfoRequest') {
|
|
665
|
+
return { message: { version: 2 } };
|
|
666
|
+
}
|
|
667
|
+
if (request === 'DeviceSessionAskPassphrase') {
|
|
668
|
+
return { message: {} };
|
|
669
|
+
}
|
|
670
|
+
if (request === 'DeviceSessionGet') {
|
|
671
|
+
return {
|
|
672
|
+
message: {
|
|
673
|
+
btc_test_address: 'attach-state',
|
|
674
|
+
session_id: 'attach-session',
|
|
675
|
+
},
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
throw new Error(`Unexpected request: ${request}`);
|
|
679
|
+
});
|
|
680
|
+
const promptPassphrase = jest.fn().mockResolvedValue({ passphrase: 'must not be requested' });
|
|
681
|
+
const method = new OpenWalletSession({
|
|
682
|
+
payload: { method: 'openWalletSession', connectId: 'connect-id', mode: 'select-hidden' },
|
|
683
|
+
});
|
|
684
|
+
method.init();
|
|
685
|
+
const device = createDevice({
|
|
686
|
+
typedCall,
|
|
687
|
+
promptPassphrase,
|
|
688
|
+
unlockedAttachPin: true,
|
|
689
|
+
});
|
|
690
|
+
method.device = device as any;
|
|
691
|
+
|
|
692
|
+
await expect(method.run()).resolves.toEqual({
|
|
693
|
+
protocol: 'V2',
|
|
694
|
+
walletType: 'hidden',
|
|
695
|
+
deviceId: 'device-1',
|
|
696
|
+
passphraseState: 'attach-state',
|
|
697
|
+
resumed: false,
|
|
698
|
+
});
|
|
699
|
+
expect(promptPassphrase).not.toHaveBeenCalled();
|
|
700
|
+
expect(device.unlockDevice).not.toHaveBeenCalled();
|
|
701
|
+
expect(device.commands.typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
|
|
702
|
+
seed_domains: [],
|
|
703
|
+
});
|
|
704
|
+
expect(device.commands.typedCall).not.toHaveBeenCalledWith(
|
|
705
|
+
'DeviceSessionAskPassphrase',
|
|
706
|
+
'Success',
|
|
707
|
+
expect.anything()
|
|
708
|
+
);
|
|
709
|
+
expect(device.commands.typedCall).not.toHaveBeenCalledWith(
|
|
710
|
+
'DeviceSessionAskPin',
|
|
711
|
+
'Success',
|
|
712
|
+
expect.anything()
|
|
713
|
+
);
|
|
714
|
+
});
|
|
715
|
+
|
|
716
|
+
test('fails closed when the Attach PIN state changes before reading the current session', async () => {
|
|
717
|
+
const typedCall = jest.fn((request: string) => {
|
|
718
|
+
if (request === 'ProtocolInfoRequest') {
|
|
719
|
+
return { message: { version: 2 } };
|
|
720
|
+
}
|
|
721
|
+
if (request === 'DeviceSessionAskPassphrase') {
|
|
722
|
+
return { message: {} };
|
|
723
|
+
}
|
|
724
|
+
if (request === 'DeviceSessionGet') {
|
|
725
|
+
return {
|
|
726
|
+
message: {
|
|
727
|
+
btc_test_address: 'unexpected-state',
|
|
728
|
+
session_id: 'unexpected-session',
|
|
729
|
+
},
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
throw new Error(`Unexpected request: ${request}`);
|
|
733
|
+
});
|
|
734
|
+
const promptPassphrase = jest.fn().mockResolvedValue({ passphrase: 'must not be requested' });
|
|
735
|
+
const method = new OpenWalletSession({
|
|
736
|
+
payload: { method: 'openWalletSession', connectId: 'connect-id', mode: 'select-hidden' },
|
|
737
|
+
});
|
|
738
|
+
method.init();
|
|
739
|
+
const device = createDevice({
|
|
740
|
+
typedCall,
|
|
741
|
+
promptPassphrase,
|
|
742
|
+
unlockedAttachPin: true,
|
|
743
|
+
refreshedUnlockedAttachPin: false,
|
|
744
|
+
});
|
|
745
|
+
method.device = device as any;
|
|
746
|
+
|
|
747
|
+
await expect(method.run()).rejects.toMatchObject({
|
|
748
|
+
errorCode: HardwareErrorCode.DeviceCheckUnlockTypeError,
|
|
749
|
+
});
|
|
750
|
+
expect(device.clearInternalState).toHaveBeenCalled();
|
|
751
|
+
expect(promptPassphrase).not.toHaveBeenCalled();
|
|
752
|
+
expect(device.commands.typedCall).not.toHaveBeenCalledWith(
|
|
753
|
+
'DeviceSessionAskPassphrase',
|
|
754
|
+
'Success',
|
|
755
|
+
expect.anything()
|
|
756
|
+
);
|
|
757
|
+
expect(device.commands.typedCall).not.toHaveBeenCalledWith(
|
|
758
|
+
'DeviceSessionGet',
|
|
759
|
+
'DeviceSession',
|
|
760
|
+
expect.anything()
|
|
761
|
+
);
|
|
644
762
|
});
|
|
645
763
|
|
|
646
764
|
test('select-hidden starts a fresh hidden-wallet session on Protocol V2', async () => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import { sha256 } from '@noble/hashes/sha256';
|
|
3
|
+
import { HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
3
4
|
|
|
4
5
|
import { DataManager } from '../src/data-manager';
|
|
5
6
|
import {
|
|
@@ -276,9 +277,10 @@ describe('Pro2 resource configuration', () => {
|
|
|
276
277
|
await DataManager.checkAndReloadData();
|
|
277
278
|
|
|
278
279
|
expect(DataManager.lastCheckTimestamp).toBe(0);
|
|
279
|
-
await expect(DataManager.forceReloadData()).rejects.
|
|
280
|
-
|
|
281
|
-
|
|
280
|
+
await expect(DataManager.forceReloadData()).rejects.toMatchObject({
|
|
281
|
+
errorCode: HardwareErrorCode.NetworkError,
|
|
282
|
+
message: 'Unable to refresh the latest remote config',
|
|
283
|
+
});
|
|
282
284
|
expect(DataManager.lastCheckTimestamp).toBe(0);
|
|
283
285
|
});
|
|
284
286
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EFirmwareType, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
1
|
+
import { EFirmwareType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
2
|
import {
|
|
3
3
|
DeviceRebootType,
|
|
4
4
|
DeviceSessionPinType,
|
|
@@ -2581,7 +2581,7 @@ describe('Protocol V2 feature adapter', () => {
|
|
|
2581
2581
|
uuid: 'CACHED-SERIAL',
|
|
2582
2582
|
deviceId: null,
|
|
2583
2583
|
bleName: 'Cached BLE',
|
|
2584
|
-
name: 'Cached
|
|
2584
|
+
name: 'Cached BLE',
|
|
2585
2585
|
label: 'Cached Label',
|
|
2586
2586
|
deviceType: 'pro2',
|
|
2587
2587
|
});
|
|
@@ -2608,7 +2608,7 @@ describe('Protocol V2 feature adapter', () => {
|
|
|
2608
2608
|
expect(device.features?.label).toBeNull();
|
|
2609
2609
|
});
|
|
2610
2610
|
|
|
2611
|
-
test('
|
|
2611
|
+
test('uses the BLE name for discovery while preserving the Protocol V2 label', () => {
|
|
2612
2612
|
const device = Device.fromDescriptor({ ...descriptor, protocolType: 'V2' } as any);
|
|
2613
2613
|
(device as any).features = {
|
|
2614
2614
|
...normalizeProtocolV2Features({ ...descriptor, protocolType: 'V2' } as any),
|
|
@@ -2616,9 +2616,10 @@ describe('Protocol V2 feature adapter', () => {
|
|
|
2616
2616
|
bleName: 'Pro2 6136',
|
|
2617
2617
|
};
|
|
2618
2618
|
|
|
2619
|
+
expect(device.getCurrentDisplayName()).toBe('My Pro 2');
|
|
2619
2620
|
expect(device.toMessageObject()).toMatchObject({
|
|
2620
2621
|
bleName: 'Pro2 6136',
|
|
2621
|
-
name: '
|
|
2622
|
+
name: 'Pro2 6136',
|
|
2622
2623
|
label: 'My Pro 2',
|
|
2623
2624
|
});
|
|
2624
2625
|
});
|
|
@@ -2672,10 +2673,6 @@ describe('Protocol V2 feature adapter', () => {
|
|
|
2672
2673
|
hw: true,
|
|
2673
2674
|
fw: true,
|
|
2674
2675
|
coprocessor: true,
|
|
2675
|
-
se1: true,
|
|
2676
|
-
se2: true,
|
|
2677
|
-
se3: true,
|
|
2678
|
-
se4: true,
|
|
2679
2676
|
},
|
|
2680
2677
|
types: {
|
|
2681
2678
|
version: true,
|
|
@@ -2867,10 +2864,6 @@ describe('Protocol V2 feature adapter', () => {
|
|
|
2867
2864
|
hw: true,
|
|
2868
2865
|
fw: true,
|
|
2869
2866
|
coprocessor: true,
|
|
2870
|
-
se1: true,
|
|
2871
|
-
se2: true,
|
|
2872
|
-
se3: true,
|
|
2873
|
-
se4: true,
|
|
2874
2867
|
},
|
|
2875
2868
|
types: {
|
|
2876
2869
|
version: true,
|
|
@@ -3220,10 +3213,6 @@ describe('Protocol V2 feature adapter', () => {
|
|
|
3220
3213
|
hw: true,
|
|
3221
3214
|
fw: true,
|
|
3222
3215
|
coprocessor: true,
|
|
3223
|
-
se1: true,
|
|
3224
|
-
se2: true,
|
|
3225
|
-
se3: true,
|
|
3226
|
-
se4: true,
|
|
3227
3216
|
},
|
|
3228
3217
|
types: {
|
|
3229
3218
|
version: true,
|
|
@@ -5739,12 +5728,17 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5739
5728
|
originalDescriptor: { protocolType: 'V2' },
|
|
5740
5729
|
features: { deviceType: 'pro2', firmwareVersion: '0.0.0', capabilities: [] },
|
|
5741
5730
|
});
|
|
5742
|
-
forceReloadDataSpy.mockRejectedValue(
|
|
5731
|
+
forceReloadDataSpy.mockRejectedValue(
|
|
5732
|
+
ERRORS.TypedError(HardwareErrorCode.NetworkError, 'latest config unavailable')
|
|
5733
|
+
);
|
|
5743
5734
|
(method as any).prepareRemoteProtocolV2Binaries = jest.fn();
|
|
5744
5735
|
(method as any).enterProtocolV2BootloaderMode = jest.fn();
|
|
5745
5736
|
method.postTipMessage = jest.fn();
|
|
5746
5737
|
|
|
5747
|
-
await expect(method.run()).rejects.
|
|
5738
|
+
await expect(method.run()).rejects.toMatchObject({
|
|
5739
|
+
errorCode: HardwareErrorCode.NetworkError,
|
|
5740
|
+
message: 'latest config unavailable',
|
|
5741
|
+
});
|
|
5748
5742
|
|
|
5749
5743
|
expect((method as any).prepareRemoteProtocolV2Binaries).not.toHaveBeenCalled();
|
|
5750
5744
|
expect((method as any).enterProtocolV2BootloaderMode).not.toHaveBeenCalled();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV4.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAkB/E,OAAO,KAAK,EAAE,sBAAsB,EAA0B,MAAM,6BAA6B,CAAC;AAmUlG,eAAO,MAAM,oCAAoC,WACvC,WAAW,GAAG,UAAU,eACnB,MAAM,GAAG,SAAS,YAKhC,CAAC;AAEF,eAAO,MAAM,iCAAiC,0BACrB,MAAM,uBACR,MAAM,SAa5B,CAAC;AAUF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,wBAAwB,CAAC,sBAAsB,CAAC;IAC5F,OAAO,CAAC,8BAA8B,CAAC,CAAS;IAEhD,qBAAqB;IAIrB,IAAI;IA6DJ,OAAO,CAAC,8BAA8B;IAiBhC,GAAG;;;;;YAKK,aAAa;
|
|
1
|
+
{"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src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yB;YAQzB,8BAA8B;IAQ5C,OAAO,CAAC,0BAA0B;YAiBpB,qCAAqC;YAgDrC,yBAAyB;YA8DzB,8BAA8B;IAU5C,OAAO,CAAC,kCAAkC;YAI5B,6BAA6B;YAwB7B,wBAAwB;IAoDtC,OAAO,CAAC,sCAAsC;YAchC,cAAc;YA+Bd,6BAA6B;YAW7B,0BAA0B;YAS1B,6BAA6B;YAmB7B,gBAAgB;IAiB9B,OAAO,CAAC,qBAAqB;CAM9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenWalletSession.d.ts","sourceRoot":"","sources":["../../src/api/OpenWalletSession.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,gCAAgC,CAAC;AAkExC,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,UAAU,CAAC,uBAAuB,CAAC;IAChF,qBAAqB;IAIrB,IAAI;IAOE,GAAG,IAAI,OAAO,CAAC,wBAAwB,CAAC;CA+
|
|
1
|
+
{"version":3,"file":"OpenWalletSession.d.ts","sourceRoot":"","sources":["../../src/api/OpenWalletSession.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,gCAAgC,CAAC;AAkExC,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,UAAU,CAAC,uBAAuB,CAAC;IAChF,qBAAqB;IAIrB,IAAI;IAOE,GAAG,IAAI,OAAO,CAAC,wBAAwB,CAAC;CA+K/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AllNetworkGetAddressBase.d.ts","sourceRoot":"","sources":["../../../src/api/allnetwork/AllNetworkGetAddressBase.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,MAAM,eA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"file":"KaspaSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/api/kaspa/KaspaSignTransaction.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,EAAE,0BAA0B,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,KAAK,EAEV,cAAc,EAEd,SAAS,EACV,MAAM,wBAAwB,CAAC;AAgBhC,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,UAAU,CAAC,0BAA0B,CAAC;IACtF,qBAAqB;IAIrB,SAAS,UAAS;IAGlB,cAAc,UAAS;IAEvB,iBAAiB,UAAS;IAE1B,IAAI;IAgIJ,eAAe;;;;;;;;IAWf,uBAAuB;;;;;;;;;;;IAkBjB,gBAAgB,CACpB,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,oBAAoB,CAAC,qBAAqB,CAAC,GAAG,oBAAoB,CAAC,eAAe,CAAC,EACxF,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,cAAc,EAAE,GAC1B,OAAO,CAAC,cAAc,EAAE,CAAC;IAwCtB,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM;IA8ElF,YAAY,CAChB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,oBAAoB,CAAC,gBAAgB,CAAC,GACpD,OAAO,CAAC,cAAc,EAAE,CAAC;IAqGtB,GAAG;
|
|
1
|
+
{"version":3,"file":"KaspaSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/api/kaspa/KaspaSignTransaction.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,EAAE,0BAA0B,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,KAAK,EAEV,cAAc,EAEd,SAAS,EACV,MAAM,wBAAwB,CAAC;AAgBhC,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,UAAU,CAAC,0BAA0B,CAAC;IACtF,qBAAqB;IAIrB,SAAS,UAAS;IAGlB,cAAc,UAAS;IAEvB,iBAAiB,UAAS;IAE1B,IAAI;IAgIJ,eAAe;;;;;;;;IAWf,uBAAuB;;;;;;;;;;;IAkBjB,gBAAgB,CACpB,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,oBAAoB,CAAC,qBAAqB,CAAC,GAAG,oBAAoB,CAAC,eAAe,CAAC,EACxF,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,cAAc,EAAE,GAC1B,OAAO,CAAC,cAAc,EAAE,CAAC;IAwCtB,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM;IA8ElF,YAAY,CAChB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,oBAAoB,CAAC,gBAAgB,CAAC,GACpD,OAAO,CAAC,cAAc,EAAE,CAAC;IAqGtB,GAAG;CA4FV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataManager.d.ts","sourceRoot":"","sources":["../../src/data-manager/DataManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAe,aAAa,
|
|
1
|
+
{"version":3,"file":"DataManager.d.ts","sourceRoot":"","sources":["../../src/data-manager/DataManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAe,aAAa,EAA6B,MAAM,qBAAqB,CAAC;AAmB5F,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,aAAa,EACb,QAAQ,EACR,wBAAwB,EACxB,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EAEd,MAAM,UAAU,CAAC;AAIlB,eAAO,MAAM,eAAe,uFAMlB,CAAC;AAEX,MAAM,MAAM,cAAc,GAA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aAAc,QAAQ;;;QAalD;IAEF,MAAM,CAAC,2BAA2B,aAAc,QAAQ,4DAMtD;IAEF,MAAM,CAAC,kBAAkB,iBAAkB,MAAM,KAAG,gBAAgB,CAKlE;IAEF,MAAM,CAAC,kBAAkB;;;kBAAuC;IAEhE,OAAO,CAAC,MAAM,CAAC,yBAAyB;WA4C3B,IAAI,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IAyE9D,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC;WAalC,kBAAkB;WAUlB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAc7C,MAAM,CAAC,sBAAsB;IAI7B,MAAM,CAAC,0BAA0B;IAIjC,MAAM,CAAC,mBAAmB,CAAC,MAAM,GAAE,qBAAyC,GAAG,IAAI;IAInF,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,SAAS,GAAG,eAAe;IAEpD,MAAM,CAAC,WAAW,CAAC,CAAC,SAAS,MAAM,eAAe,EAAE,GAAG,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC;IAU/E,MAAM,CAAC,YAAY,QAAS,eAAe,CAAC,KAAK,CAAC,aAC0B;IAG5E,MAAM,CAAC,eAAe,QAAS,eAAe,CAAC,KAAK,CAAC,aAA8B;IAGnF,MAAM,CAAC,eAAe,QAAS,eAAe,CAAC,KAAK,CAAC,aAAsB;CAC5E"}
|
|
@@ -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 | 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 |
|
|
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 | 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 | 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 |
|
|
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 | 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 | 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 |
|
|
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 | 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 | 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 |
|
|
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 | 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 | 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 |
|
|
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 | 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 | 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 |
|
|
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 | 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
|
@@ -39855,7 +39855,7 @@ class DataManager {
|
|
|
39855
39855
|
}
|
|
39856
39856
|
const loaded = yield this.load(this.settings);
|
|
39857
39857
|
if (!loaded) {
|
|
39858
|
-
throw
|
|
39858
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.NetworkError, 'Unable to refresh the latest remote config');
|
|
39859
39859
|
}
|
|
39860
39860
|
this.lastCheckTimestamp = getTimeStamp();
|
|
39861
39861
|
});
|
|
@@ -40496,6 +40496,7 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
40496
40496
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
40497
40497
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40498
40498
|
const forceWalletSelection = (options === null || options === void 0 ? void 0 : options.forceWalletSelection) === true || (options === null || options === void 0 ? void 0 : options.initSession) === true;
|
|
40499
|
+
const readCurrentAttachPinSession = (options === null || options === void 0 ? void 0 : options.readCurrentAttachPinSession) === true;
|
|
40499
40500
|
if (forceWalletSelection) {
|
|
40500
40501
|
if (options.onlyMainPin) {
|
|
40501
40502
|
(_a = device.clearStandardInternalState) === null || _a === void 0 ? void 0 : _a.call(device);
|
|
@@ -40506,16 +40507,18 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
40506
40507
|
device.passphraseState = undefined;
|
|
40507
40508
|
}
|
|
40508
40509
|
yield negotiateEventlessWalletSession(device);
|
|
40509
|
-
if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
40510
|
+
if ((options === null || options === void 0 ? void 0 : options.onlyMainPin) || readCurrentAttachPinSession) {
|
|
40510
40511
|
device.passphraseState = undefined;
|
|
40511
40512
|
}
|
|
40512
|
-
let expectedPassphraseState = (options === null || options === void 0 ? void 0 : options.onlyMainPin)
|
|
40513
|
+
let expectedPassphraseState = (options === null || options === void 0 ? void 0 : options.onlyMainPin) || readCurrentAttachPinSession
|
|
40513
40514
|
? undefined
|
|
40514
40515
|
: (_b = options === null || options === void 0 ? void 0 : options.expectedPassphraseState) !== null && _b !== void 0 ? _b : device.passphraseState;
|
|
40515
40516
|
const cachedStandardSession = (options === null || options === void 0 ? void 0 : options.onlyMainPin)
|
|
40516
40517
|
? (_c = device.getStandardInternalState) === null || _c === void 0 ? void 0 : _c.call(device)
|
|
40517
40518
|
: undefined;
|
|
40518
|
-
const cachedSessionId = !(options === null || options === void 0 ? void 0 : options.onlyMainPin) &&
|
|
40519
|
+
const cachedSessionId = !(options === null || options === void 0 ? void 0 : options.onlyMainPin) &&
|
|
40520
|
+
!readCurrentAttachPinSession &&
|
|
40521
|
+
typeof device.getInternalState === 'function'
|
|
40519
40522
|
? device.getInternalState()
|
|
40520
40523
|
: undefined;
|
|
40521
40524
|
let response;
|
|
@@ -40575,7 +40578,18 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
40575
40578
|
});
|
|
40576
40579
|
}
|
|
40577
40580
|
});
|
|
40578
|
-
if (
|
|
40581
|
+
if (readCurrentAttachPinSession) {
|
|
40582
|
+
const status = yield requestProtocolV2DeviceStatus$1(device);
|
|
40583
|
+
device.updateProtocolV2Status(status);
|
|
40584
|
+
if (status.unlocked !== true ||
|
|
40585
|
+
status.passphrase_enabled !== true ||
|
|
40586
|
+
status.unlocked_by_attach_to_pin !== true) {
|
|
40587
|
+
device.clearInternalState();
|
|
40588
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckUnlockTypeError);
|
|
40589
|
+
}
|
|
40590
|
+
response = yield getDeviceSession(device, buildDeviceSessionGetRequest({ deriveCardano: options === null || options === void 0 ? void 0 : options.deriveCardano }));
|
|
40591
|
+
}
|
|
40592
|
+
else if (options === null || options === void 0 ? void 0 : options.onlyMainPin) {
|
|
40579
40593
|
expectedPassphraseState = cachedStandardSession === null || cachedStandardSession === void 0 ? void 0 : cachedStandardSession.passphraseState;
|
|
40580
40594
|
if (cachedStandardSession) {
|
|
40581
40595
|
try {
|
|
@@ -40700,10 +40714,17 @@ function getProtocolV2WalletSession(device, options) {
|
|
|
40700
40714
|
else {
|
|
40701
40715
|
device.updateInternalState(...internalStateArgs);
|
|
40702
40716
|
}
|
|
40717
|
+
let unlockedAttachPin;
|
|
40718
|
+
if (readCurrentAttachPinSession) {
|
|
40719
|
+
unlockedAttachPin = true;
|
|
40720
|
+
}
|
|
40721
|
+
else if (mainPinSelected) {
|
|
40722
|
+
unlockedAttachPin = false;
|
|
40723
|
+
}
|
|
40703
40724
|
return {
|
|
40704
40725
|
passphraseState: message.btc_test_address,
|
|
40705
40726
|
newSession: message.session_id,
|
|
40706
|
-
unlockedAttachPin
|
|
40727
|
+
unlockedAttachPin,
|
|
40707
40728
|
resumed,
|
|
40708
40729
|
};
|
|
40709
40730
|
});
|
|
@@ -43619,10 +43640,6 @@ const PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST = {
|
|
|
43619
43640
|
hw: true,
|
|
43620
43641
|
fw: true,
|
|
43621
43642
|
coprocessor: true,
|
|
43622
|
-
se1: true,
|
|
43623
|
-
se2: true,
|
|
43624
|
-
se3: true,
|
|
43625
|
-
se4: true,
|
|
43626
43643
|
},
|
|
43627
43644
|
types: {
|
|
43628
43645
|
version: true,
|
|
@@ -43788,7 +43805,7 @@ class Device extends events.exports {
|
|
|
43788
43805
|
deviceId,
|
|
43789
43806
|
path: (_a = this.originalDescriptor) === null || _a === void 0 ? void 0 : _a.path,
|
|
43790
43807
|
bleName,
|
|
43791
|
-
name:
|
|
43808
|
+
name: bleName || displayName || `OneKey ${deviceType === null || deviceType === void 0 ? void 0 : deviceType.toUpperCase()}`,
|
|
43792
43809
|
label: displayName !== null && displayName !== void 0 ? displayName : '',
|
|
43793
43810
|
status: this.getStatus(),
|
|
43794
43811
|
mode: this.getMode(),
|
|
@@ -45956,12 +45973,16 @@ class OpenWalletSession extends BaseMethod {
|
|
|
45956
45973
|
return Object.assign(Object.assign({ protocol, walletType: 'hidden', deviceId }, requireHiddenWalletResponse(session)), { resumed: wasResumed(session) || (!isProtocolV2 && session.newSession === cachedSessionId) });
|
|
45957
45974
|
}
|
|
45958
45975
|
this.device.passphraseState = undefined;
|
|
45959
|
-
yield ensureProtocolV2WalletStatus();
|
|
45976
|
+
const walletStatus = yield ensureProtocolV2WalletStatus();
|
|
45977
|
+
if (isProtocolV2 && walletStatus.status.passphraseProtection !== true) {
|
|
45978
|
+
this.device.clearInternalState();
|
|
45979
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotOpenedPassphrase);
|
|
45980
|
+
}
|
|
45981
|
+
const readCurrentAttachPinSession = isProtocolV2 && walletStatus.status.unlockedAttachPin === true;
|
|
45960
45982
|
const session = isProtocolV2
|
|
45961
|
-
? yield getProtocolV2WalletSession(this.device, {
|
|
45962
|
-
|
|
45963
|
-
deriveCardano: this.payload.deriveCardano
|
|
45964
|
-
})
|
|
45983
|
+
? yield getProtocolV2WalletSession(this.device, Object.assign(Object.assign({}, (readCurrentAttachPinSession
|
|
45984
|
+
? { readCurrentAttachPinSession: true }
|
|
45985
|
+
: { forceWalletSelection: true })), { deriveCardano: this.payload.deriveCardano }))
|
|
45965
45986
|
: yield getPassphraseStateWithRefreshDeviceInfo(this.device, { initSession: true });
|
|
45966
45987
|
const refreshedState = isProtocolV2
|
|
45967
45988
|
? requireAuthoritativeProtocolV2WalletStatus(yield refreshProtocolV2DeviceState())
|
|
@@ -45971,6 +45992,12 @@ class OpenWalletSession extends BaseMethod {
|
|
|
45971
45992
|
this.device.clearInternalState();
|
|
45972
45993
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotOpenedPassphrase);
|
|
45973
45994
|
}
|
|
45995
|
+
if (isProtocolV2 &&
|
|
45996
|
+
readCurrentAttachPinSession &&
|
|
45997
|
+
refreshedState.status.unlockedAttachPin !== true) {
|
|
45998
|
+
this.device.clearInternalState();
|
|
45999
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckUnlockTypeError);
|
|
46000
|
+
}
|
|
45974
46001
|
const responseBase = {
|
|
45975
46002
|
protocol,
|
|
45976
46003
|
deviceId,
|
|
@@ -49577,6 +49604,9 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
49577
49604
|
}
|
|
49578
49605
|
}
|
|
49579
49606
|
catch (err) {
|
|
49607
|
+
if (err instanceof hdShared.HardwareError && err.errorCode === hdShared.HardwareErrorCode.NetworkError) {
|
|
49608
|
+
throw err;
|
|
49609
|
+
}
|
|
49580
49610
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateDownloadFailed, (_e = err.message) !== null && _e !== void 0 ? _e : err);
|
|
49581
49611
|
}
|
|
49582
49612
|
if (!bootloaderBinary &&
|
|
@@ -51573,8 +51603,10 @@ class AllNetworkGetAddressBase extends BaseMethod {
|
|
|
51573
51603
|
this.temporarySafetyCheckPrompted = true;
|
|
51574
51604
|
}
|
|
51575
51605
|
}
|
|
51576
|
-
|
|
51577
|
-
|
|
51606
|
+
const useEmptyPassphrase = this.payload.useEmptyPassphrase === true;
|
|
51607
|
+
const shouldResumeWalletSession = useEmptyPassphrase || !!this.payload.passphraseState;
|
|
51608
|
+
if (this.device.isProtocolV2() && shouldResumeWalletSession) {
|
|
51609
|
+
const passphraseStateSafety = yield this.device.checkPassphraseStateSafety(this.payload.passphraseState, useEmptyPassphrase, this.payload.skipPassphraseCheck);
|
|
51578
51610
|
if (!passphraseStateSafety) {
|
|
51579
51611
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckPassphraseStateError);
|
|
51580
51612
|
}
|
|
@@ -51700,21 +51732,25 @@ class AllNetworkGetAddress extends AllNetworkGetAddressBase {
|
|
|
51700
51732
|
const responses = [];
|
|
51701
51733
|
const resultMap = {};
|
|
51702
51734
|
const { bundle } = this.payload;
|
|
51703
|
-
const
|
|
51704
|
-
.map((param, index) => this.generateMethodName({
|
|
51735
|
+
const methodParams = bundle.map((param, index) => this.generateMethodName({
|
|
51705
51736
|
network: param.network,
|
|
51706
51737
|
payload: param,
|
|
51707
51738
|
originalIndex: index,
|
|
51708
|
-
}))
|
|
51709
|
-
|
|
51710
|
-
|
|
51711
|
-
|
|
51712
|
-
|
|
51713
|
-
|
|
51714
|
-
return
|
|
51715
|
-
},
|
|
51739
|
+
}));
|
|
51740
|
+
const groupedMethodParams = methodParams.reduce((groups, param) => {
|
|
51741
|
+
var _a;
|
|
51742
|
+
const group = (_a = groups.get(param.methodName)) !== null && _a !== void 0 ? _a : [];
|
|
51743
|
+
group.push(param);
|
|
51744
|
+
groups.set(param.methodName, group);
|
|
51745
|
+
return groups;
|
|
51746
|
+
}, new Map());
|
|
51747
|
+
const requiresProtocolV2WalletHandoff = this.device.isProtocolV2() &&
|
|
51748
|
+
(this.payload.useEmptyPassphrase === true || !!this.payload.passphraseState);
|
|
51749
|
+
const methodGroups = requiresProtocolV2WalletHandoff
|
|
51750
|
+
? methodParams.map(param => [param.methodName, [param]])
|
|
51751
|
+
: Array.from(groupedMethodParams.entries());
|
|
51716
51752
|
let i = 0;
|
|
51717
|
-
for (const [methodName, params] of
|
|
51753
|
+
for (const [methodName, params] of methodGroups) {
|
|
51718
51754
|
const methodParams = {
|
|
51719
51755
|
bundle: params.map(param => (Object.assign({}, param.params))),
|
|
51720
51756
|
};
|
|
@@ -58953,16 +58989,7 @@ class KaspaSignTransaction extends BaseMethod {
|
|
|
58953
58989
|
if (!this.supportsStreaming) {
|
|
58954
58990
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, 'KaspaSignTransaction: device firmware uses the streaming protocol; every output requires address or addressN');
|
|
58955
58991
|
}
|
|
58956
|
-
|
|
58957
|
-
return yield this.signTxStream(typedCall, response);
|
|
58958
|
-
}
|
|
58959
|
-
catch (error) {
|
|
58960
|
-
if (error instanceof hdShared.HardwareError &&
|
|
58961
|
-
String(error.message).toLowerCase().includes('previous transaction id mismatch')) {
|
|
58962
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.KaspaPrevTxIdMismatch, String(error.message));
|
|
58963
|
-
}
|
|
58964
|
-
throw error;
|
|
58965
|
-
}
|
|
58992
|
+
return this.signTxStream(typedCall, response);
|
|
58966
58993
|
}
|
|
58967
58994
|
if (!this.supportsLegacy) {
|
|
58968
58995
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'KaspaSignTransaction: device chose the legacy protocol but the transaction is not legacy-signable');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../../src/protocols/protocol-v2/features.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAGlE,YAAY,EAAE,oBAAoB,EAAE,CAAC;AACrC,YAAY,EAAE,uBAAuB,IAAI,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrG,YAAY,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,w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,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,YAAY,CAAC,CAaxB;AAED,wBAAsB,2BAA2B,CAAC,EAChD,QAAQ,EACR,SAA8C,EAC9C,OAAkD,GACnD,EAAE;IACD,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAMhC;AAED,wBAAsB,6BAA6B,CAAC,EAClD,QAAQ,EACR,SAAS,GACV,EAAE;IACD,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,YAAY,CAAC,CAOxB"}
|
|
@@ -11,6 +11,7 @@ export declare function getProtocolV2WalletSession(device: Device, options?: {
|
|
|
11
11
|
selectMainWalletBeforeRestore?: boolean;
|
|
12
12
|
resumeOnly?: boolean;
|
|
13
13
|
deriveCardano?: boolean;
|
|
14
|
+
readCurrentAttachPinSession?: boolean;
|
|
14
15
|
}): Promise<{
|
|
15
16
|
passphraseState: string;
|
|
16
17
|
newSession: string;
|
|
@@ -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;AA0HD,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;
|
|
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;AA0HD,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;CACvC;;;;;GAiQF;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.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.55",
|
|
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.0-alpha.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.2.0-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.55",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.55",
|
|
30
30
|
"axios": "1.15.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"bytebuffer": "^5.0.1",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"@types/w3c-web-usb": "^1.0.10",
|
|
45
45
|
"@types/web-bluetooth": "^0.0.21"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "0a99a180062ec32fac0c5e14be3366fbfb7bc01a"
|
|
48
48
|
}
|
|
@@ -531,6 +531,9 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
531
531
|
this.postTipMessage(FirmwareUpdateTipMessage.FinishDownloadFirmware);
|
|
532
532
|
}
|
|
533
533
|
} catch (err) {
|
|
534
|
+
if (err instanceof HardwareError && err.errorCode === HardwareErrorCode.NetworkError) {
|
|
535
|
+
throw err;
|
|
536
|
+
}
|
|
534
537
|
throw ERRORS.TypedError(HardwareErrorCode.FirmwareUpdateDownloadFailed, err.message ?? err);
|
|
535
538
|
}
|
|
536
539
|
|
|
@@ -216,10 +216,18 @@ export default class OpenWalletSession extends BaseMethod<OpenWalletSessionParam
|
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
this.device.passphraseState = undefined;
|
|
219
|
-
await ensureProtocolV2WalletStatus();
|
|
219
|
+
const walletStatus = await ensureProtocolV2WalletStatus();
|
|
220
|
+
if (isProtocolV2 && walletStatus.status.passphraseProtection !== true) {
|
|
221
|
+
this.device.clearInternalState();
|
|
222
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceNotOpenedPassphrase);
|
|
223
|
+
}
|
|
224
|
+
const readCurrentAttachPinSession =
|
|
225
|
+
isProtocolV2 && walletStatus.status.unlockedAttachPin === true;
|
|
220
226
|
const session = isProtocolV2
|
|
221
227
|
? await getProtocolV2WalletSession(this.device, {
|
|
222
|
-
|
|
228
|
+
...(readCurrentAttachPinSession
|
|
229
|
+
? { readCurrentAttachPinSession: true }
|
|
230
|
+
: { forceWalletSelection: true }),
|
|
223
231
|
deriveCardano: this.payload.deriveCardano,
|
|
224
232
|
})
|
|
225
233
|
: await getPassphraseStateWithRefreshDeviceInfo(this.device, { initSession: true });
|
|
@@ -231,6 +239,14 @@ export default class OpenWalletSession extends BaseMethod<OpenWalletSessionParam
|
|
|
231
239
|
this.device.clearInternalState();
|
|
232
240
|
throw ERRORS.TypedError(HardwareErrorCode.DeviceNotOpenedPassphrase);
|
|
233
241
|
}
|
|
242
|
+
if (
|
|
243
|
+
isProtocolV2 &&
|
|
244
|
+
readCurrentAttachPinSession &&
|
|
245
|
+
refreshedState.status.unlockedAttachPin !== true
|
|
246
|
+
) {
|
|
247
|
+
this.device.clearInternalState();
|
|
248
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceCheckUnlockTypeError);
|
|
249
|
+
}
|
|
234
250
|
const responseBase = {
|
|
235
251
|
protocol,
|
|
236
252
|
deviceId,
|
|
@@ -24,24 +24,28 @@ export default class AllNetworkGetAddress extends AllNetworkGetAddressBase {
|
|
|
24
24
|
const resultMap: Record<string, AllNetworkAddress> = {};
|
|
25
25
|
const { bundle } = this.payload as AllNetworkGetAddressParams;
|
|
26
26
|
|
|
27
|
-
const
|
|
28
|
-
.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
27
|
+
const methodParams = bundle.map((param, index) =>
|
|
28
|
+
this.generateMethodName({
|
|
29
|
+
network: param.network,
|
|
30
|
+
payload: param,
|
|
31
|
+
originalIndex: index,
|
|
32
|
+
})
|
|
33
|
+
);
|
|
34
|
+
const groupedMethodParams = methodParams.reduce((groups, param) => {
|
|
35
|
+
const group = groups.get(param.methodName) ?? [];
|
|
36
|
+
group.push(param);
|
|
37
|
+
groups.set(param.methodName, group);
|
|
38
|
+
return groups;
|
|
39
|
+
}, new Map<keyof CoreApi, MethodParams[]>());
|
|
40
|
+
const requiresProtocolV2WalletHandoff =
|
|
41
|
+
this.device.isProtocolV2() &&
|
|
42
|
+
(this.payload.useEmptyPassphrase === true || !!this.payload.passphraseState);
|
|
43
|
+
const methodGroups: [keyof CoreApi, MethodParams[]][] = requiresProtocolV2WalletHandoff
|
|
44
|
+
? methodParams.map(param => [param.methodName, [param]])
|
|
45
|
+
: Array.from(groupedMethodParams.entries());
|
|
42
46
|
|
|
43
47
|
let i = 0;
|
|
44
|
-
for (const [methodName, params] of
|
|
48
|
+
for (const [methodName, params] of methodGroups) {
|
|
45
49
|
const methodParams = {
|
|
46
50
|
bundle: params.map(param => ({
|
|
47
51
|
...param.params,
|
|
@@ -52,11 +56,7 @@ export default class AllNetworkGetAddress extends AllNetworkGetAddressBase {
|
|
|
52
56
|
throw new Error(HardwareErrorCodeMessage[HardwareErrorCode.RepeatUnlocking]);
|
|
53
57
|
}
|
|
54
58
|
// call method
|
|
55
|
-
const response = await this.callMethod(
|
|
56
|
-
methodName as keyof CoreApi,
|
|
57
|
-
methodParams,
|
|
58
|
-
rootFingerprint
|
|
59
|
-
);
|
|
59
|
+
const response = await this.callMethod(methodName, methodParams, rootFingerprint);
|
|
60
60
|
|
|
61
61
|
if (this.abortController?.signal.aborted) {
|
|
62
62
|
throw new Error(HardwareErrorCodeMessage[HardwareErrorCode.RepeatUnlocking]);
|
|
@@ -391,11 +391,13 @@ export default abstract class AllNetworkGetAddressBase extends BaseMethod<
|
|
|
391
391
|
// Protocol V2 hands a wallet session to exactly one blockchain request.
|
|
392
392
|
// The parent all-network call consumes its first handoff while fetching
|
|
393
393
|
// the root fingerprint, so each nested chain method must resume the
|
|
394
|
-
// requested hidden wallet before
|
|
395
|
-
|
|
394
|
+
// requested standard or hidden wallet before sending its device command.
|
|
395
|
+
const useEmptyPassphrase = this.payload.useEmptyPassphrase === true;
|
|
396
|
+
const shouldResumeWalletSession = useEmptyPassphrase || !!this.payload.passphraseState;
|
|
397
|
+
if (this.device.isProtocolV2() && shouldResumeWalletSession) {
|
|
396
398
|
const passphraseStateSafety = await this.device.checkPassphraseStateSafety(
|
|
397
399
|
this.payload.passphraseState,
|
|
398
|
-
|
|
400
|
+
useEmptyPassphrase,
|
|
399
401
|
this.payload.skipPassphraseCheck
|
|
400
402
|
);
|
|
401
403
|
if (!passphraseStateSafety) {
|
|
@@ -506,18 +506,7 @@ export default class KaspaSignTransaction extends BaseMethod<KaspaSignTransactio
|
|
|
506
506
|
'KaspaSignTransaction: device firmware uses the streaming protocol; every output requires address or addressN'
|
|
507
507
|
);
|
|
508
508
|
}
|
|
509
|
-
|
|
510
|
-
return await this.signTxStream(typedCall, response);
|
|
511
|
-
} catch (error) {
|
|
512
|
-
// Device rejected our refTxs; the caller decides whether to sign without them.
|
|
513
|
-
if (
|
|
514
|
-
error instanceof HardwareError &&
|
|
515
|
-
String(error.message).toLowerCase().includes('previous transaction id mismatch')
|
|
516
|
-
) {
|
|
517
|
-
throw ERRORS.TypedError(HardwareErrorCode.KaspaPrevTxIdMismatch, String(error.message));
|
|
518
|
-
}
|
|
519
|
-
throw error;
|
|
520
|
-
}
|
|
509
|
+
return this.signTxStream(typedCall, response);
|
|
521
510
|
}
|
|
522
511
|
|
|
523
512
|
// Legacy answer to a streaming-only packet: no prehash material exists.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import semver from 'semver';
|
|
3
|
-
import { EDeviceType, EFirmwareType } from '@onekeyfe/hd-shared';
|
|
3
|
+
import { EDeviceType, EFirmwareType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
4
4
|
|
|
5
5
|
import MessagesJSON from '../data/messages/messages.json';
|
|
6
6
|
import MessagesLegacyV1JSON from '../data/messages/messages_legacy_v1.json';
|
|
@@ -500,7 +500,10 @@ export default class DataManager {
|
|
|
500
500
|
}
|
|
501
501
|
const loaded = await this.load(this.settings);
|
|
502
502
|
if (!loaded) {
|
|
503
|
-
throw
|
|
503
|
+
throw ERRORS.TypedError(
|
|
504
|
+
HardwareErrorCode.NetworkError,
|
|
505
|
+
'Unable to refresh the latest remote config'
|
|
506
|
+
);
|
|
504
507
|
}
|
|
505
508
|
this.lastCheckTimestamp = getTimeStamp();
|
|
506
509
|
}
|
package/src/device/Device.ts
CHANGED
|
@@ -360,7 +360,7 @@ export class Device extends EventEmitter {
|
|
|
360
360
|
deviceId,
|
|
361
361
|
path: this.originalDescriptor?.path,
|
|
362
362
|
bleName,
|
|
363
|
-
name:
|
|
363
|
+
name: bleName || displayName || `OneKey ${deviceType?.toUpperCase()}`,
|
|
364
364
|
// Keep the legacy top-level field string-compatible while preserving
|
|
365
365
|
// the canonical nullable value at state.identity.label.
|
|
366
366
|
label: displayName ?? '',
|
|
@@ -189,10 +189,13 @@ export async function getProtocolV2WalletSession(
|
|
|
189
189
|
selectMainWalletBeforeRestore?: boolean;
|
|
190
190
|
resumeOnly?: boolean;
|
|
191
191
|
deriveCardano?: boolean;
|
|
192
|
+
/** Read the wallet already selected by Attach PIN without reopening wallet selection. */
|
|
193
|
+
readCurrentAttachPinSession?: boolean;
|
|
192
194
|
}
|
|
193
195
|
) {
|
|
194
196
|
const forceWalletSelection =
|
|
195
197
|
options?.forceWalletSelection === true || options?.initSession === true;
|
|
198
|
+
const readCurrentAttachPinSession = options?.readCurrentAttachPinSession === true;
|
|
196
199
|
|
|
197
200
|
if (forceWalletSelection) {
|
|
198
201
|
if (options.onlyMainPin) {
|
|
@@ -205,18 +208,21 @@ export async function getProtocolV2WalletSession(
|
|
|
205
208
|
|
|
206
209
|
await negotiateEventlessWalletSession(device);
|
|
207
210
|
|
|
208
|
-
if (options?.onlyMainPin) {
|
|
211
|
+
if (options?.onlyMainPin || readCurrentAttachPinSession) {
|
|
209
212
|
device.passphraseState = undefined;
|
|
210
213
|
}
|
|
211
|
-
let expectedPassphraseState =
|
|
212
|
-
|
|
213
|
-
|
|
214
|
+
let expectedPassphraseState =
|
|
215
|
+
options?.onlyMainPin || readCurrentAttachPinSession
|
|
216
|
+
? undefined
|
|
217
|
+
: options?.expectedPassphraseState ?? device.passphraseState;
|
|
214
218
|
|
|
215
219
|
const cachedStandardSession = options?.onlyMainPin
|
|
216
220
|
? device.getStandardInternalState?.()
|
|
217
221
|
: undefined;
|
|
218
222
|
const cachedSessionId =
|
|
219
|
-
!options?.onlyMainPin &&
|
|
223
|
+
!options?.onlyMainPin &&
|
|
224
|
+
!readCurrentAttachPinSession &&
|
|
225
|
+
typeof device.getInternalState === 'function'
|
|
220
226
|
? device.getInternalState()
|
|
221
227
|
: undefined;
|
|
222
228
|
let response;
|
|
@@ -280,7 +286,22 @@ export async function getProtocolV2WalletSession(
|
|
|
280
286
|
}
|
|
281
287
|
};
|
|
282
288
|
|
|
283
|
-
if (
|
|
289
|
+
if (readCurrentAttachPinSession) {
|
|
290
|
+
const status = await requestProtocolV2DeviceStatus(device);
|
|
291
|
+
device.updateProtocolV2Status(status);
|
|
292
|
+
if (
|
|
293
|
+
status.unlocked !== true ||
|
|
294
|
+
status.passphrase_enabled !== true ||
|
|
295
|
+
status.unlocked_by_attach_to_pin !== true
|
|
296
|
+
) {
|
|
297
|
+
device.clearInternalState();
|
|
298
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceCheckUnlockTypeError);
|
|
299
|
+
}
|
|
300
|
+
response = await getDeviceSession(
|
|
301
|
+
device,
|
|
302
|
+
buildDeviceSessionGetRequest({ deriveCardano: options?.deriveCardano })
|
|
303
|
+
);
|
|
304
|
+
} else if (options?.onlyMainPin) {
|
|
284
305
|
expectedPassphraseState = cachedStandardSession?.passphraseState;
|
|
285
306
|
if (cachedStandardSession) {
|
|
286
307
|
try {
|
|
@@ -414,10 +435,17 @@ export async function getProtocolV2WalletSession(
|
|
|
414
435
|
device.updateInternalState(...internalStateArgs);
|
|
415
436
|
}
|
|
416
437
|
|
|
438
|
+
let unlockedAttachPin: boolean | undefined;
|
|
439
|
+
if (readCurrentAttachPinSession) {
|
|
440
|
+
unlockedAttachPin = true;
|
|
441
|
+
} else if (mainPinSelected) {
|
|
442
|
+
unlockedAttachPin = false;
|
|
443
|
+
}
|
|
444
|
+
|
|
417
445
|
return {
|
|
418
446
|
passphraseState: message.btc_test_address,
|
|
419
447
|
newSession: message.session_id,
|
|
420
|
-
unlockedAttachPin
|
|
448
|
+
unlockedAttachPin,
|
|
421
449
|
resumed,
|
|
422
450
|
};
|
|
423
451
|
}
|