@onekeyfe/hd-core 1.2.2-alpha.10 → 1.2.2-alpha.101
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 +30 -14
- package/__tests__/logBlockEvent.test.ts +45 -122
- package/__tests__/open-wallet-session.test.ts +53 -0
- package/__tests__/protocol-v2.test.ts +35 -0
- package/__tests__/sol-sign-offchain-message.test.ts +70 -0
- package/dist/api/UploadPortfolio.d.ts +1 -0
- package/dist/api/UploadPortfolio.d.ts.map +1 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/uiPromiseRegistry.d.ts +1 -1
- package/dist/device/DeviceCommands.d.ts +4 -4
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/index.d.ts +19 -12
- package/dist/index.js +87 -97
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +3 -4
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/api/solSignOffchainMessage.d.ts +2 -0
- package/dist/types/api/solSignOffchainMessage.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/package.json +4 -4
- package/src/api/UploadPortfolio.ts +5 -4
- package/src/api/solana/SolSignOffchainMessage.ts +57 -4
- package/src/core/index.ts +21 -7
- package/src/data/messages/messages-protocol-v2.json +8 -5
- package/src/data/messages/messages.json +8 -5
- package/src/events/logBlockEvent.ts +6 -75
- package/src/protocols/protocol-v2/walletSession.ts +7 -2
- package/src/types/api/protocolV2.ts +3 -4
- package/src/types/api/solSignOffchainMessage.ts +3 -0
|
@@ -5,10 +5,11 @@ import {
|
|
|
5
5
|
cancel,
|
|
6
6
|
initConnector,
|
|
7
7
|
initCore,
|
|
8
|
+
isDeviceIdentityMismatchError,
|
|
8
9
|
isMissingDetectedProtocolV2Error,
|
|
9
|
-
isProtocolV2PeerRemovedPairingError,
|
|
10
10
|
isRetryableBleConnectionError,
|
|
11
11
|
isRetryableBleProtocolV2ProbeError,
|
|
12
|
+
isTerminalBleStaleBondError,
|
|
12
13
|
resolveBleConnectProtocol,
|
|
13
14
|
} from '../src/core';
|
|
14
15
|
import { DataManager } from '../src/data-manager';
|
|
@@ -367,6 +368,7 @@ describe('public device lifecycle events', () => {
|
|
|
367
368
|
[HardwareErrorCode.PollingTimeout, false],
|
|
368
369
|
[HardwareErrorCode.BleDeviceBondError, false],
|
|
369
370
|
[HardwareErrorCode.BlePeerRemovedPairingInformation, false],
|
|
371
|
+
[HardwareErrorCode.BleBondInvalid, false],
|
|
370
372
|
] as const)('retries a BLE connection error with error code %s: %s', (errorCode, expected) => {
|
|
371
373
|
const method = { payload: { connectProtocol: 'V2' } } as never;
|
|
372
374
|
const error = {
|
|
@@ -377,21 +379,35 @@ describe('public device lifecycle events', () => {
|
|
|
377
379
|
expect(isRetryableBleConnectionError(method, error)).toBe(expected);
|
|
378
380
|
});
|
|
379
381
|
|
|
382
|
+
test('does not retry the desktop acquire deadline fallback', () => {
|
|
383
|
+
const method = { payload: { connectProtocol: 'V2' } } as never;
|
|
384
|
+
const error = {
|
|
385
|
+
errorCode: HardwareErrorCode.BleTimeoutError,
|
|
386
|
+
params: { acquireDeadlineExceeded: true },
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
expect(isRetryableBleConnectionError(method, error)).toBe(false);
|
|
390
|
+
});
|
|
391
|
+
|
|
380
392
|
test.each([
|
|
381
|
-
[
|
|
382
|
-
[
|
|
383
|
-
[
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
errorCode: HardwareErrorCode.BlePeerRemovedPairingInformation,
|
|
390
|
-
};
|
|
393
|
+
[HardwareErrorCode.BleDeviceBondError, true],
|
|
394
|
+
[HardwareErrorCode.BlePeerRemovedPairingInformation, true],
|
|
395
|
+
[HardwareErrorCode.BleBondInvalid, true],
|
|
396
|
+
[HardwareErrorCode.DeviceNotFound, false],
|
|
397
|
+
] as const)('treats BLE stale-bond error code %s as terminal: %s', (errorCode, expected) => {
|
|
398
|
+
const error = {
|
|
399
|
+
errorCode,
|
|
400
|
+
};
|
|
391
401
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
402
|
+
expect(isTerminalBleStaleBondError(error)).toBe(expected);
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
test.each([
|
|
406
|
+
[HardwareErrorCode.DeviceCheckDeviceIdError, true],
|
|
407
|
+
[HardwareErrorCode.DeviceNotFound, false],
|
|
408
|
+
] as const)('treats device identity error code %s as a mismatch: %s', (errorCode, expected) => {
|
|
409
|
+
expect(isDeviceIdentityMismatchError({ errorCode })).toBe(expected);
|
|
410
|
+
});
|
|
395
411
|
|
|
396
412
|
test('converts an internal transport disconnect into a public KnownDevice snapshot', () => {
|
|
397
413
|
jest.spyOn(DataManager, 'getSettings').mockReturnValue('react-native' as never);
|
|
@@ -7,36 +7,6 @@ import {
|
|
|
7
7
|
} from '../src/events';
|
|
8
8
|
|
|
9
9
|
describe('getLogBlockLabel', () => {
|
|
10
|
-
it('blocks evmSignTypedData params before logging large typed data', () => {
|
|
11
|
-
expect(
|
|
12
|
-
getLogBlockLabel({
|
|
13
|
-
method: 'evmSignTypedData',
|
|
14
|
-
data: {
|
|
15
|
-
message: {
|
|
16
|
-
data: `0x${'ab'.repeat(4096)}`,
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
})
|
|
20
|
-
).toBe('evmSignTypedData');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('blocks evmSignTypedData iframe call payload before bridge logging', () => {
|
|
24
|
-
expect(
|
|
25
|
-
getLogBlockLabel({
|
|
26
|
-
event: 'iframe-call',
|
|
27
|
-
type: 'iframe-call',
|
|
28
|
-
payload: {
|
|
29
|
-
method: 'evmSignTypedData',
|
|
30
|
-
data: {
|
|
31
|
-
message: {
|
|
32
|
-
data: `0x${'ab'.repeat(4096)}`,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
})
|
|
37
|
-
).toBe('evmSignTypedData');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
10
|
it('keeps existing sensitive UI response blocking', () => {
|
|
41
11
|
expect(getLogBlockLabel({ type: UI_RESPONSE.RECEIVE_PIN })).toBe(UI_RESPONSE.RECEIVE_PIN);
|
|
42
12
|
});
|
|
@@ -53,119 +23,72 @@ describe('getLogBlockLabel', () => {
|
|
|
53
23
|
},
|
|
54
24
|
})
|
|
55
25
|
).toBe(type);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
expect(
|
|
69
|
-
getLogBlockLabel({
|
|
70
|
-
event: 'iframe-call',
|
|
71
|
-
type: 'iframe-call',
|
|
72
|
-
payload,
|
|
73
|
-
})
|
|
74
|
-
).toBe('openWalletSession');
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('keeps openWalletSession metadata while redacting wallet session identifiers', () => {
|
|
78
|
-
const safeResponse = getSafeLogPayload(
|
|
79
|
-
{
|
|
80
|
-
success: true,
|
|
81
|
-
payload: {
|
|
82
|
-
protocol: 'V2',
|
|
83
|
-
walletType: 'hidden',
|
|
84
|
-
deviceId: 'device-id',
|
|
85
|
-
passphraseState: 'wallet-identifier',
|
|
86
|
-
sessionId: 'wallet-session-id',
|
|
87
|
-
resumed: false,
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
'openWalletSession'
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
expect(safeResponse).toEqual({
|
|
94
|
-
method: 'openWalletSession',
|
|
95
|
-
success: true,
|
|
96
|
-
payload: {
|
|
97
|
-
protocol: 'V2',
|
|
98
|
-
walletType: 'hidden',
|
|
99
|
-
deviceId: 'device-id',
|
|
100
|
-
passphraseState: '[REDACTED]',
|
|
101
|
-
sessionId: '[REDACTED]',
|
|
102
|
-
resumed: false,
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it.each(['deviceUploadNft', 'deviceUploadWallpaper', 'uploadPortfolio'])(
|
|
108
|
-
'skips large Base64 resource payload logging for %s',
|
|
109
|
-
method => {
|
|
110
|
-
const request = { method, path: 'resource.bin', data: 'A'.repeat(1024 * 1024) };
|
|
111
|
-
expect(getLogBlockLabel(request)).toBe(method);
|
|
112
|
-
expect(getSafeLogPayload(request, method)).toEqual({
|
|
113
|
-
method,
|
|
26
|
+
expect(
|
|
27
|
+
getSafeLogPayload(
|
|
28
|
+
{
|
|
29
|
+
type,
|
|
30
|
+
payload: {
|
|
31
|
+
passphraseState: 'wallet-identifier',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
type
|
|
35
|
+
)
|
|
36
|
+
).toEqual({
|
|
37
|
+
method: type,
|
|
114
38
|
payload: '[REDACTED]',
|
|
115
39
|
});
|
|
116
40
|
}
|
|
117
41
|
);
|
|
118
42
|
|
|
119
|
-
it.each(['fileWrite', 'fileRead'])(
|
|
120
|
-
'
|
|
43
|
+
it.each(['deviceUploadNft', 'deviceUploadWallpaper', 'uploadPortfolio', 'fileWrite', 'fileRead'])(
|
|
44
|
+
'skips large resource or binary payload logging for %s',
|
|
121
45
|
method => {
|
|
122
|
-
const request = { method, path: 'resource.bin', data:
|
|
46
|
+
const request = { method, path: 'resource.bin', data: 'A'.repeat(1024) };
|
|
123
47
|
expect(getLogBlockLabel(request)).toBe(method);
|
|
124
48
|
expect(getSafeLogPayload(request, method)).toEqual({
|
|
125
49
|
method,
|
|
126
|
-
|
|
127
|
-
data: '[BINARY:1024]',
|
|
50
|
+
payload: '[REDACTED]',
|
|
128
51
|
});
|
|
129
52
|
}
|
|
130
53
|
);
|
|
131
54
|
|
|
132
|
-
it
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
55
|
+
it('logs signing requests and responses as-is', () => {
|
|
56
|
+
const request = {
|
|
57
|
+
method: 'btcSignMessage',
|
|
58
|
+
path: "m/44'/0'/0'/0/0",
|
|
59
|
+
messageHex: '68656c6c6f',
|
|
60
|
+
coin: 'Bitcoin',
|
|
61
|
+
};
|
|
62
|
+
const iframeRequest = {
|
|
63
|
+
event: 'iframe-call',
|
|
64
|
+
payload: request,
|
|
65
|
+
};
|
|
66
|
+
const response = {
|
|
67
|
+
success: true,
|
|
68
|
+
payload: {
|
|
69
|
+
signature: 'signature-bytes',
|
|
70
|
+
address: 'bc1qexample',
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
expect(getLogBlockLabel(request)).toBeUndefined();
|
|
75
|
+
expect(getLogBlockLabel(iframeRequest)).toBeUndefined();
|
|
76
|
+
expect(getSafeLogPayload(request)).toBe(request);
|
|
77
|
+
expect(getSafeLogPayload(response)).toBe(response);
|
|
78
|
+
});
|
|
144
79
|
|
|
145
80
|
it('keeps ordinary API requests and responses visible', () => {
|
|
146
81
|
const request = { method: 'getDeviceState', connectId: 'connect-id', scope: 'runtime' };
|
|
147
82
|
const response = { success: true, payload: { protocol: 'V2', initialized: true } };
|
|
148
83
|
|
|
149
84
|
expect(getLogBlockLabel(request)).toBeUndefined();
|
|
150
|
-
expect(getSafeLogPayload(request)).
|
|
151
|
-
expect(getSafeLogPayload(response)).
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it('redacts sensitive keys even for ordinary API payloads', () => {
|
|
155
|
-
expect(
|
|
156
|
-
getSafeLogPayload({
|
|
157
|
-
method: 'ordinaryMethod',
|
|
158
|
-
payload: { session_id: 'session-secret', nested: { pin: '1234' } },
|
|
159
|
-
})
|
|
160
|
-
).toEqual({
|
|
161
|
-
method: 'ordinaryMethod',
|
|
162
|
-
payload: { session_id: '[REDACTED]', nested: { pin: '[REDACTED]' } },
|
|
163
|
-
});
|
|
85
|
+
expect(getSafeLogPayload(request)).toBe(request);
|
|
86
|
+
expect(getSafeLogPayload(response)).toBe(response);
|
|
164
87
|
});
|
|
165
88
|
|
|
166
|
-
it('puts
|
|
167
|
-
expect(formatLogMethodLabel('response:', '
|
|
168
|
-
'response: [
|
|
89
|
+
it('puts blocked method names in the log label', () => {
|
|
90
|
+
expect(formatLogMethodLabel('response:', 'deviceUploadNft')).toBe(
|
|
91
|
+
'response: [deviceUploadNft]'
|
|
169
92
|
);
|
|
170
93
|
expect(formatLogMethodLabel('response:')).toBe('response:');
|
|
171
94
|
});
|
|
@@ -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()
|
|
@@ -536,6 +536,41 @@ describe('UploadPortfolio', () => {
|
|
|
536
536
|
});
|
|
537
537
|
});
|
|
538
538
|
|
|
539
|
+
test('emits transfer progress when progress UI is requested', async () => {
|
|
540
|
+
const typedCall = jest
|
|
541
|
+
.fn()
|
|
542
|
+
.mockResolvedValueOnce({ message: { processed_byte: 3 } })
|
|
543
|
+
.mockResolvedValueOnce({ message: { message: 'Portfolio updated' } });
|
|
544
|
+
const method = new UploadPortfolio({
|
|
545
|
+
id: 1,
|
|
546
|
+
payload: {
|
|
547
|
+
method: 'uploadPortfolio',
|
|
548
|
+
packageBase64: 'AQID',
|
|
549
|
+
uiMode: 'progress',
|
|
550
|
+
},
|
|
551
|
+
});
|
|
552
|
+
(method as any).device = stubPortfolioDevice({ commands: { typedCall } });
|
|
553
|
+
method.postMessage = jest.fn();
|
|
554
|
+
|
|
555
|
+
method.init();
|
|
556
|
+
await method.run();
|
|
557
|
+
|
|
558
|
+
expect(method.unlockPolicy).toBe('none');
|
|
559
|
+
expect(method.protocolV2UiMode).toBe('auto');
|
|
560
|
+
expect(method.protocolV2UiInteraction).toBeUndefined();
|
|
561
|
+
expect(method.payload.emitProgress).toBe(true);
|
|
562
|
+
expect(method.postMessage).toHaveBeenCalledWith({
|
|
563
|
+
event: 'UI_EVENT',
|
|
564
|
+
type: UI_REQUEST.DEVICE_PROGRESS,
|
|
565
|
+
payload: expect.objectContaining({
|
|
566
|
+
progress: 100,
|
|
567
|
+
transferredBytes: 3,
|
|
568
|
+
totalBytes: 3,
|
|
569
|
+
elapsedMs: expect.any(Number),
|
|
570
|
+
}),
|
|
571
|
+
});
|
|
572
|
+
});
|
|
573
|
+
|
|
539
574
|
test('does not apply PortfolioUpdate when staging fails', async () => {
|
|
540
575
|
const typedCall = jest.fn().mockRejectedValue(new Error('write failed'));
|
|
541
576
|
const method = new UploadPortfolio({
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { SolanaOffChainMessageFormat, SolanaOffChainMessageVersion } from '@onekeyfe/hd-transport';
|
|
2
|
+
|
|
3
|
+
import SolSignOffchainMessage from '../src/api/solana/SolSignOffchainMessage';
|
|
4
|
+
|
|
5
|
+
import type { Device } from '../src/device/Device';
|
|
6
|
+
|
|
7
|
+
jest.mock('../src/data/config', () => ({
|
|
8
|
+
getSDKVersion: jest.fn(() => '1.0.0'),
|
|
9
|
+
DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0/',
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
const signerA = '11'.repeat(32);
|
|
13
|
+
const signerB = '22'.repeat(32);
|
|
14
|
+
const requiredSigners = Array.from({ length: 11 }, (_, index) =>
|
|
15
|
+
index.toString(16).padStart(64, '0')
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const createMethod = (overrides: Record<string, unknown> = {}) =>
|
|
19
|
+
new SolSignOffchainMessage({
|
|
20
|
+
id: 1,
|
|
21
|
+
payload: {
|
|
22
|
+
method: 'solSignOffchainMessage',
|
|
23
|
+
path: "m/44'/501'/0'/0'",
|
|
24
|
+
messageHex: '48656c6c6f',
|
|
25
|
+
messageVersion: SolanaOffChainMessageVersion.MESSAGE_VERSION_1,
|
|
26
|
+
messageFormat: SolanaOffChainMessageFormat.V0_LIMITED_UTF8,
|
|
27
|
+
applicationDomainHex: `0x${'aa'.repeat(32)}`,
|
|
28
|
+
sourceFingerprint: 0x12345678,
|
|
29
|
+
requiredSigners,
|
|
30
|
+
...overrides,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('SolSignOffchainMessage', () => {
|
|
35
|
+
test('maps V1 parameters without imposing a host-side signer count limit', async () => {
|
|
36
|
+
const method = createMethod();
|
|
37
|
+
method.init();
|
|
38
|
+
|
|
39
|
+
const typedCall = jest.fn().mockResolvedValue({
|
|
40
|
+
message: { signature: 'signature', public_key: signerA },
|
|
41
|
+
});
|
|
42
|
+
method.device = { commands: { typedCall } } as unknown as Device;
|
|
43
|
+
|
|
44
|
+
await expect(method.run()).resolves.toEqual({ signature: 'signature', pub: signerA });
|
|
45
|
+
expect(typedCall).toHaveBeenCalledWith('SolanaSignOffChainMessage', 'SolanaMessageSignature', {
|
|
46
|
+
address_n: [2147483692, 2147484149, 2147483648, 2147483648],
|
|
47
|
+
message: '48656c6c6f',
|
|
48
|
+
message_version: SolanaOffChainMessageVersion.MESSAGE_VERSION_1,
|
|
49
|
+
message_format: SolanaOffChainMessageFormat.V0_LIMITED_UTF8,
|
|
50
|
+
application_domain: 'aa'.repeat(32),
|
|
51
|
+
source_fingerprint: 0x12345678,
|
|
52
|
+
required_signers: requiredSigners,
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test.each([
|
|
57
|
+
{ requiredSigners: ['11'], error: '32-byte hex public key' },
|
|
58
|
+
{ requiredSigners: [signerB, signerA], error: 'strictly sorted and unique' },
|
|
59
|
+
{ requiredSigners: [signerA, signerA], error: 'strictly sorted and unique' },
|
|
60
|
+
])('rejects invalid required signers: $error', ({ requiredSigners, error }) => {
|
|
61
|
+
expect(() => createMethod({ requiredSigners }).init()).toThrow(error);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test.each([-1, 0x100000000, 1.5])(
|
|
65
|
+
'rejects an invalid source fingerprint: %s',
|
|
66
|
+
sourceFingerprint => {
|
|
67
|
+
expect(() => createMethod({ sourceFingerprint }).init()).toThrow('uint32');
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadPortfolio.d.ts","sourceRoot":"","sources":["../../src/api/UploadPortfolio.ts"],"names":[],"mappings":"AAIA,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,MAAM,MAAM,qBAAqB,GAAG;IAClC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"UploadPortfolio.d.ts","sourceRoot":"","sources":["../../src/api/UploadPortfolio.ts"],"names":[],"mappings":"AAIA,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,MAAM,MAAM,qBAAqB,GAAG;IAClC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE5B,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;CAChC,CAAC;AAQF,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,SAAS;IACpD,IAAI;IAuBE,GAAG;;;;;;;;CAsBV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolSignOffchainMessage.d.ts","sourceRoot":"","sources":["../../../src/api/solana/SolSignOffchainMessage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,OAAO,KAAK,EAAE,yBAAyB,IAAI,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"SolSignOffchainMessage.d.ts","sourceRoot":"","sources":["../../../src/api/solana/SolSignOffchainMessage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,OAAO,KAAK,EAAE,yBAAyB,IAAI,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AA6B1G,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,UAAU,CAAC,8BAA8B,CAAC;IAC5F,qBAAqB;IAIrB,IAAI;IAqDJ,eAAe;;;;;;;;;;;IAcT,GAAG;;;;CAcV"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -11,7 +11,8 @@ 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
|
+
export declare function isDeviceIdentityMismatchError(error: unknown): boolean;
|
|
15
16
|
export declare function resolveBleConnectProtocol(method: BaseMethod): ProtocolType | undefined;
|
|
16
17
|
export declare const cancel: (context: CoreContext, connectId?: string) => void;
|
|
17
18
|
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;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO,WAI3D;AA8JD,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,UAAU,GAAG,YAAY,GAAG,SAAS,CAMtF;AAyLD,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"}
|
|
@@ -2,5 +2,5 @@ import type { UiPromise, UiPromiseResponse } from '../events/ui-promise';
|
|
|
2
2
|
import type { UiResponseEvent } from '../events/ui-response';
|
|
3
3
|
export declare const consumeUiPromise: <T>(promise: Promise<T>, onFulfilled: (value: T) => void, onRejected: (error: Error) => void) => void;
|
|
4
4
|
export declare const rejectUiPromises: (uiPromises: UiPromise<UiPromiseResponse['type']>[], error: Error) => void;
|
|
5
|
-
export declare const findUiPromiseForResponse: (uiPromises: UiPromise<UiPromiseResponse['type']>[], response: UiResponseEvent) => UiPromise<"ui-receive_pin" | "ui-receive_passphrase" | "ui-receive_select-device-in-bootloader-for-web-device" | "ui-receive_select-device-for-switch-firmware-web-device"
|
|
5
|
+
export declare const findUiPromiseForResponse: (uiPromises: UiPromise<UiPromiseResponse['type']>[], response: UiResponseEvent) => UiPromise<"device-disconnect" | "ui-receive_pin" | "ui-receive_passphrase" | "ui-receive_select-device-in-bootloader-for-web-device" | "ui-receive_select-device-for-switch-firmware-web-device"> | undefined;
|
|
6
6
|
//# sourceMappingURL=uiPromiseRegistry.d.ts.map
|
|
@@ -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
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logBlockEvent.d.ts","sourceRoot":"","sources":["../../src/events/logBlockEvent.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,EAAE,GAAG,CAAC,MAAM,CAKpC,CAAC;
|
|
1
|
+
{"version":3,"file":"logBlockEvent.d.ts","sourceRoot":"","sources":["../../src/events/logBlockEvent.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,EAAE,GAAG,CAAC,MAAM,CAKpC,CAAC;AAYH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAmBrE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAK9E;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/E"}
|