@onekeyfe/hd-core 1.2.2-alpha.8 → 1.2.2
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/README.md +1 -1
- package/__tests__/AllNetworkGetAddressBase.tracing.test.ts +503 -10
- package/__tests__/DeviceCommands.test.ts +254 -1
- package/__tests__/core-error-output.test.ts +169 -1
- package/__tests__/device-lifecycle-events.test.ts +432 -15
- package/__tests__/logBlockEvent.test.ts +45 -122
- package/__tests__/open-wallet-session-error-response.test.ts +2 -2
- package/__tests__/open-wallet-session.test.ts +94 -363
- package/__tests__/protocol-v2.test.ts +132 -2
- package/__tests__/public-device-state-api.test.ts +2 -7
- package/__tests__/search-devices.test.ts +196 -8
- package/__tests__/sol-sign-offchain-message.test.ts +64 -0
- package/dist/api/FirmwareUpdateV4.d.ts +1 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetFeatures.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.d.ts.map +1 -1
- package/dist/api/SearchDevices.d.ts +2 -15
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/UploadPortfolio.d.ts +1 -0
- package/dist/api/UploadPortfolio.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddress.d.ts +2 -0
- package/dist/api/allnetwork/AllNetworkGetAddress.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts +7 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressByLoop.d.ts.map +1 -1
- package/dist/api/device/DeviceVerify.d.ts.map +1 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
- package/dist/core/RequestQueue.d.ts +3 -0
- package/dist/core/RequestQueue.d.ts.map +1 -1
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/uiPromiseRegistry.d.ts +1 -1
- package/dist/data-manager/TransportManager.d.ts +2 -0
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/device/Device.d.ts +2 -0
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +5 -4
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/index.d.ts +35 -30
- package/dist/index.js +620 -325
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/types/api/getFeatures.d.ts.map +1 -1
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/openWalletSession.d.ts +1 -10
- package/dist/types/api/openWalletSession.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 +1 -0
- package/dist/types/api/solSignOffchainMessage.d.ts.map +1 -1
- package/dist/types/params.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +9 -4
- package/src/api/GetFeatures.ts +1 -0
- package/src/api/GetPassphraseState.ts +1 -0
- package/src/api/OpenWalletSession.ts +7 -77
- package/src/api/SearchDevices.ts +121 -27
- package/src/api/UploadPortfolio.ts +5 -4
- package/src/api/allnetwork/AllNetworkGetAddress.ts +79 -45
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +95 -24
- package/src/api/allnetwork/AllNetworkGetAddressByLoop.ts +3 -0
- package/src/api/device/DeviceVerify.ts +8 -0
- package/src/api/solana/SolSignOffchainMessage.ts +44 -4
- package/src/core/RequestQueue.ts +36 -1
- package/src/core/index.ts +178 -63
- package/src/data/messages/messages-protocol-v2.json +49 -33
- package/src/data/messages/messages.json +8 -5
- package/src/data-manager/TransportManager.ts +14 -3
- package/src/device/Device.ts +58 -27
- package/src/device/DeviceCommands.ts +29 -2
- package/src/events/logBlockEvent.ts +6 -75
- package/src/protocols/protocol-v2/walletSession.ts +18 -2
- package/src/types/api/getFeatures.ts +2 -1
- package/src/types/api/getPassphraseState.ts +2 -5
- package/src/types/api/openWalletSession.ts +7 -19
- package/src/types/api/protocolV2.ts +3 -4
- package/src/types/api/solSignOffchainMessage.ts +2 -0
- package/src/types/params.ts +7 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Buffer } from 'buffer';
|
|
2
|
+
import { randomBytes } from 'crypto';
|
|
2
3
|
import { EDeviceType, EFirmwareType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
3
4
|
import { sha256 } from '@noble/hashes/sha256';
|
|
4
5
|
import { bytesToHex } from '@noble/hashes/utils';
|
|
@@ -536,6 +537,41 @@ describe('UploadPortfolio', () => {
|
|
|
536
537
|
});
|
|
537
538
|
});
|
|
538
539
|
|
|
540
|
+
test('emits transfer progress when progress UI is requested', async () => {
|
|
541
|
+
const typedCall = jest
|
|
542
|
+
.fn()
|
|
543
|
+
.mockResolvedValueOnce({ message: { processed_byte: 3 } })
|
|
544
|
+
.mockResolvedValueOnce({ message: { message: 'Portfolio updated' } });
|
|
545
|
+
const method = new UploadPortfolio({
|
|
546
|
+
id: 1,
|
|
547
|
+
payload: {
|
|
548
|
+
method: 'uploadPortfolio',
|
|
549
|
+
packageBase64: 'AQID',
|
|
550
|
+
uiMode: 'progress',
|
|
551
|
+
},
|
|
552
|
+
});
|
|
553
|
+
(method as any).device = stubPortfolioDevice({ commands: { typedCall } });
|
|
554
|
+
method.postMessage = jest.fn();
|
|
555
|
+
|
|
556
|
+
method.init();
|
|
557
|
+
await method.run();
|
|
558
|
+
|
|
559
|
+
expect(method.unlockPolicy).toBe('none');
|
|
560
|
+
expect(method.protocolV2UiMode).toBe('auto');
|
|
561
|
+
expect(method.protocolV2UiInteraction).toBeUndefined();
|
|
562
|
+
expect(method.payload.emitProgress).toBe(true);
|
|
563
|
+
expect(method.postMessage).toHaveBeenCalledWith({
|
|
564
|
+
event: 'UI_EVENT',
|
|
565
|
+
type: UI_REQUEST.DEVICE_PROGRESS,
|
|
566
|
+
payload: expect.objectContaining({
|
|
567
|
+
progress: 100,
|
|
568
|
+
transferredBytes: 3,
|
|
569
|
+
totalBytes: 3,
|
|
570
|
+
elapsedMs: expect.any(Number),
|
|
571
|
+
}),
|
|
572
|
+
});
|
|
573
|
+
});
|
|
574
|
+
|
|
539
575
|
test('does not apply PortfolioUpdate when staging fails', async () => {
|
|
540
576
|
const typedCall = jest.fn().mockRejectedValue(new Error('write failed'));
|
|
541
577
|
const method = new UploadPortfolio({
|
|
@@ -1789,6 +1825,56 @@ describe('Protocol V2 feature adapter', () => {
|
|
|
1789
1825
|
]);
|
|
1790
1826
|
});
|
|
1791
1827
|
|
|
1828
|
+
test.each([false, true])(
|
|
1829
|
+
'rejects the first incorrect passphrase after a missing or expired session (cached: %s)',
|
|
1830
|
+
async cached => {
|
|
1831
|
+
const deviceId = `first-passphrase-error-${String(cached)}`;
|
|
1832
|
+
const device = Device.fromDescriptor({
|
|
1833
|
+
id: deviceId,
|
|
1834
|
+
path: deviceId,
|
|
1835
|
+
protocolType: 'V2',
|
|
1836
|
+
} as never);
|
|
1837
|
+
device.features = normalizeProtocolV2Features(
|
|
1838
|
+
{ ...descriptor, protocolType: 'V2' } as never,
|
|
1839
|
+
{
|
|
1840
|
+
status: { device_id: deviceId, unlocked: true, passphrase_enabled: true },
|
|
1841
|
+
}
|
|
1842
|
+
);
|
|
1843
|
+
device.passphraseState = 'expected-public-address';
|
|
1844
|
+
if (cached) {
|
|
1845
|
+
preloadSessionCache(deviceId, device.passphraseState, randomBytes(32).toString('hex'));
|
|
1846
|
+
}
|
|
1847
|
+
let reads = 0;
|
|
1848
|
+
const typedCall = createWalletSessionTypedCall(
|
|
1849
|
+
jest.fn((request: string) => {
|
|
1850
|
+
if (request === 'DeviceSessionAskPassphrase') return { message: {} };
|
|
1851
|
+
if (request === 'DeviceSessionGet') {
|
|
1852
|
+
reads += 1;
|
|
1853
|
+
if (reads === 1) {
|
|
1854
|
+
throw ERRORS.TypedError(HardwareErrorCode.WalletSessionInvalid);
|
|
1855
|
+
}
|
|
1856
|
+
return {
|
|
1857
|
+
message: {
|
|
1858
|
+
session_id: randomBytes(32).toString('hex'),
|
|
1859
|
+
btc_test_address: 'different-public-address',
|
|
1860
|
+
},
|
|
1861
|
+
};
|
|
1862
|
+
}
|
|
1863
|
+
throw new Error(`Unexpected request: ${request}`);
|
|
1864
|
+
})
|
|
1865
|
+
);
|
|
1866
|
+
const promptPassphrase = jest.fn().mockResolvedValue({ passphraseOnDevice: true });
|
|
1867
|
+
device.commands = { typedCall, promptPassphrase } as never;
|
|
1868
|
+
|
|
1869
|
+
await expect(getProtocolV2WalletSession(device)).rejects.toMatchObject({
|
|
1870
|
+
errorCode: HardwareErrorCode.DeviceCheckPassphraseStateError,
|
|
1871
|
+
});
|
|
1872
|
+
expect(promptPassphrase).toHaveBeenCalledTimes(1);
|
|
1873
|
+
expect(reads).toBe(2);
|
|
1874
|
+
expect(device.getInternalState()).toBeUndefined();
|
|
1875
|
+
}
|
|
1876
|
+
);
|
|
1877
|
+
|
|
1792
1878
|
test('reselects a hidden wallet when the cached Pro2 session resolves to another wallet', async () => {
|
|
1793
1879
|
const device = Device.fromDescriptor({
|
|
1794
1880
|
id: 'cache-device-mismatch',
|
|
@@ -2786,7 +2872,7 @@ describe('Protocol V2 feature adapter', () => {
|
|
|
2786
2872
|
await expect(
|
|
2787
2873
|
device.checkPassphraseStateSafety('stale-hidden-state', true, false)
|
|
2788
2874
|
).resolves.toBe(true);
|
|
2789
|
-
expect(typedCall).toHaveBeenCalledTimes(
|
|
2875
|
+
expect(typedCall).toHaveBeenCalledTimes(6);
|
|
2790
2876
|
expect(typedCall).toHaveBeenCalledWith('ProtocolInfoRequest', 'ProtocolInfo', {
|
|
2791
2877
|
eventless_wallet_session: true,
|
|
2792
2878
|
});
|
|
@@ -2798,7 +2884,7 @@ describe('Protocol V2 feature adapter', () => {
|
|
|
2798
2884
|
});
|
|
2799
2885
|
expect(typedCall).toHaveBeenCalledWith('DeviceStatusGet', 'DeviceStatus', {});
|
|
2800
2886
|
expect(typedCall.mock.calls.filter(([request]) => request === 'DeviceStatusGet')).toHaveLength(
|
|
2801
|
-
|
|
2887
|
+
3
|
|
2802
2888
|
);
|
|
2803
2889
|
expect(typedCall).not.toHaveBeenCalledWith('DeviceSessionAskPin', 'Success', expect.anything());
|
|
2804
2890
|
});
|
|
@@ -8892,6 +8978,50 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
8892
8978
|
expect(recoverProtocolV2FileTransfer).not.toHaveBeenCalled();
|
|
8893
8979
|
});
|
|
8894
8980
|
|
|
8981
|
+
test('keeps public transfer bytes monotonic when a V4 file retry restarts at zero', async () => {
|
|
8982
|
+
const method = new FirmwareUpdateV4({
|
|
8983
|
+
id: 1,
|
|
8984
|
+
payload: {
|
|
8985
|
+
method: 'firmwareUpdateV4',
|
|
8986
|
+
},
|
|
8987
|
+
});
|
|
8988
|
+
let writeCount = 0;
|
|
8989
|
+
(method as any).fileWriteChunk = jest.fn(
|
|
8990
|
+
(_path: string, _size: number, offset: number, data: Uint8Array) => {
|
|
8991
|
+
writeCount += 1;
|
|
8992
|
+
if (writeCount === 3) {
|
|
8993
|
+
return Promise.reject(new Error('transport timeout'));
|
|
8994
|
+
}
|
|
8995
|
+
return Promise.resolve({
|
|
8996
|
+
message: { processed_byte: offset + data.byteLength },
|
|
8997
|
+
});
|
|
8998
|
+
}
|
|
8999
|
+
);
|
|
9000
|
+
(method as any).getProtocolV2FirmwareChunkSize = jest.fn().mockReturnValue(1000);
|
|
9001
|
+
(method as any).recoverProtocolV2FileTransfer = jest.fn().mockResolvedValue(undefined);
|
|
9002
|
+
method.postProgressMessage = jest.fn();
|
|
9003
|
+
const source = await openFirmwareByteSource({
|
|
9004
|
+
binary: new Uint8Array(3000).buffer,
|
|
9005
|
+
});
|
|
9006
|
+
|
|
9007
|
+
try {
|
|
9008
|
+
await (method as any).protocolV2SourceUpdateProcess({
|
|
9009
|
+
source,
|
|
9010
|
+
filePath: 'vol1:firmware.bin',
|
|
9011
|
+
processedSize: 0,
|
|
9012
|
+
totalSize: 3000,
|
|
9013
|
+
});
|
|
9014
|
+
} finally {
|
|
9015
|
+
await source?.close();
|
|
9016
|
+
}
|
|
9017
|
+
|
|
9018
|
+
const transferredBytes = (method.postProgressMessage as jest.Mock).mock.calls.map(
|
|
9019
|
+
([, , metrics]) => metrics.transferredBytes
|
|
9020
|
+
);
|
|
9021
|
+
expect(transferredBytes).toEqual([1000, 2000, 3000]);
|
|
9022
|
+
expect((method as any).recoverProtocolV2FileTransfer).toHaveBeenCalledTimes(1);
|
|
9023
|
+
});
|
|
9024
|
+
|
|
8895
9025
|
test('throttles repeated transfer progress while preserving file completion', async () => {
|
|
8896
9026
|
const method = new FirmwareUpdateV4({
|
|
8897
9027
|
id: 1,
|
|
@@ -22,7 +22,6 @@ describe('public device state API boundary', () => {
|
|
|
22
22
|
expect((publicTypes as Record<string, unknown>).OpenWalletSessionMode).toEqual({
|
|
23
23
|
Standard: 'standard',
|
|
24
24
|
SelectHidden: 'select-hidden',
|
|
25
|
-
ResumeHidden: 'resume-hidden',
|
|
26
25
|
});
|
|
27
26
|
});
|
|
28
27
|
|
|
@@ -83,9 +82,7 @@ describe('public device state API boundary', () => {
|
|
|
83
82
|
useEmptyPassphrase: false,
|
|
84
83
|
});
|
|
85
84
|
await api.openWalletSession('device-2', {
|
|
86
|
-
mode: publicTypes.OpenWalletSessionMode.
|
|
87
|
-
deviceId: 'wallet-device-1',
|
|
88
|
-
passphraseState: 'wallet-state-1',
|
|
85
|
+
mode: publicTypes.OpenWalletSessionMode.SelectHidden,
|
|
89
86
|
});
|
|
90
87
|
await api.clearSessionCache({
|
|
91
88
|
deviceId: 'wallet-device-1',
|
|
@@ -100,9 +97,7 @@ describe('public device state API boundary', () => {
|
|
|
100
97
|
});
|
|
101
98
|
expect(call).toHaveBeenNthCalledWith(2, {
|
|
102
99
|
connectId: 'device-2',
|
|
103
|
-
mode: '
|
|
104
|
-
deviceId: 'wallet-device-1',
|
|
105
|
-
passphraseState: 'wallet-state-1',
|
|
100
|
+
mode: 'select-hidden',
|
|
106
101
|
method: 'openWalletSession',
|
|
107
102
|
});
|
|
108
103
|
expect(call).toHaveBeenNthCalledWith(3, {
|
|
@@ -4,6 +4,7 @@ jest.mock('../src/data-manager/TransportManager', () => ({
|
|
|
4
4
|
__esModule: true,
|
|
5
5
|
default: {
|
|
6
6
|
configure: jest.fn(),
|
|
7
|
+
ensureInitialized: jest.fn(),
|
|
7
8
|
},
|
|
8
9
|
}));
|
|
9
10
|
|
|
@@ -17,29 +18,216 @@ jest.mock('../src/data-manager', () => ({
|
|
|
17
18
|
jest.mock('../src/device/DevicePool', () => ({
|
|
18
19
|
DevicePool: {
|
|
19
20
|
getDevices: jest.fn(),
|
|
21
|
+
getDeviceByPath: jest.fn(),
|
|
20
22
|
},
|
|
21
23
|
}));
|
|
22
24
|
|
|
23
|
-
const transportManagerMock: {
|
|
24
|
-
|
|
25
|
-
);
|
|
26
|
-
const devicePoolMock: {
|
|
27
|
-
|
|
28
|
-
);
|
|
25
|
+
const transportManagerMock: {
|
|
26
|
+
default: { configure: jest.Mock; ensureInitialized: jest.Mock };
|
|
27
|
+
} = jest.requireMock('../src/data-manager/TransportManager');
|
|
28
|
+
const devicePoolMock: {
|
|
29
|
+
DevicePool: { getDevices: jest.Mock; getDeviceByPath: jest.Mock };
|
|
30
|
+
} = jest.requireMock('../src/device/DevicePool');
|
|
29
31
|
const dataManagerMock: {
|
|
30
32
|
DataManager: {
|
|
31
33
|
getSettings: jest.Mock;
|
|
32
34
|
isBleConnect: jest.Mock;
|
|
33
35
|
};
|
|
34
36
|
} = jest.requireMock('../src/data-manager');
|
|
35
|
-
const { configure: mockConfigureTransport } =
|
|
36
|
-
|
|
37
|
+
const { configure: mockConfigureTransport, ensureInitialized: mockEnsureInitialized } =
|
|
38
|
+
transportManagerMock.default;
|
|
39
|
+
const { getDevices: mockGetDevices, getDeviceByPath: mockGetDeviceByPath } =
|
|
40
|
+
devicePoolMock.DevicePool;
|
|
37
41
|
const { isBleConnect: mockIsBleConnect } = dataManagerMock.DataManager;
|
|
38
42
|
|
|
39
43
|
describe('SearchDevices', () => {
|
|
40
44
|
beforeEach(() => {
|
|
41
45
|
jest.clearAllMocks();
|
|
42
46
|
mockIsBleConnect.mockReturnValue(false);
|
|
47
|
+
dataManagerMock.DataManager.getSettings.mockReturnValue('webusb');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test.each(['webusb', 'desktop-webusb'])(
|
|
51
|
+
'%s discovery leaves active V1/V2 requests and their schemas untouched',
|
|
52
|
+
async env => {
|
|
53
|
+
dataManagerMock.DataManager.getSettings.mockReturnValue(env);
|
|
54
|
+
const devices = ['V1', 'V2'].map(protocol => ({
|
|
55
|
+
features: { protocol },
|
|
56
|
+
toMessageObject: () => ({ connectId: `serial-${protocol}` }),
|
|
57
|
+
}));
|
|
58
|
+
mockGetDeviceByPath.mockImplementation(
|
|
59
|
+
(path: string) => devices[['usb-V1', 'usb-V2'].indexOf(path)]
|
|
60
|
+
);
|
|
61
|
+
const extraDevice = {
|
|
62
|
+
toMessageObject: () => ({ connectId: 'not-initialized' }),
|
|
63
|
+
};
|
|
64
|
+
mockGetDevices.mockResolvedValue({
|
|
65
|
+
devices: { 'not-initialized': extraDevice },
|
|
66
|
+
deviceList: [extraDevice],
|
|
67
|
+
});
|
|
68
|
+
const method = new SearchDevices({
|
|
69
|
+
id: 1,
|
|
70
|
+
payload: { method: 'searchDevices' },
|
|
71
|
+
} as never);
|
|
72
|
+
method.init();
|
|
73
|
+
method.context = {
|
|
74
|
+
requestQueue: {
|
|
75
|
+
getRequestTasksId: () => [2],
|
|
76
|
+
getRequestTasksIdByConnectId: (connectId: string) =>
|
|
77
|
+
connectId === 'usb-V1' || connectId === 'usb-V2' ? [2] : [],
|
|
78
|
+
},
|
|
79
|
+
} as never;
|
|
80
|
+
method.connector = {
|
|
81
|
+
enumerate: jest.fn().mockResolvedValue({
|
|
82
|
+
descriptors: [
|
|
83
|
+
{ path: 'usb-V1', commType: 'webusb' },
|
|
84
|
+
{ path: 'usb-V2', commType: 'webusb' },
|
|
85
|
+
{ path: 'not-initialized', commType: 'webusb' },
|
|
86
|
+
],
|
|
87
|
+
}),
|
|
88
|
+
} as never;
|
|
89
|
+
|
|
90
|
+
await expect(method.run()).resolves.toEqual([
|
|
91
|
+
{ connectId: 'serial-V1' },
|
|
92
|
+
{ connectId: 'serial-V2' },
|
|
93
|
+
{ connectId: 'not-initialized' },
|
|
94
|
+
]);
|
|
95
|
+
expect(mockGetDevices).toHaveBeenCalledTimes(1);
|
|
96
|
+
expect(mockGetDevices).toHaveBeenCalledWith(
|
|
97
|
+
[{ path: 'not-initialized', commType: 'webusb' }],
|
|
98
|
+
'not-initialized',
|
|
99
|
+
{
|
|
100
|
+
connectProtocol: undefined,
|
|
101
|
+
forceProtocolDetection: true,
|
|
102
|
+
refreshRuntimeState: true,
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
expect(mockConfigureTransport).not.toHaveBeenCalled();
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const BOOTLOADER_PATH = '00000000000000000000000000000000';
|
|
110
|
+
|
|
111
|
+
const runOwnedSearch = (
|
|
112
|
+
path: string,
|
|
113
|
+
ownerDevice?: unknown,
|
|
114
|
+
usbHandles: unknown[] = [{ vendorId: 0x1209, productId: 0x4f4c }]
|
|
115
|
+
) => {
|
|
116
|
+
const method = new SearchDevices({
|
|
117
|
+
id: 1,
|
|
118
|
+
payload: { method: 'searchDevices' },
|
|
119
|
+
} as never);
|
|
120
|
+
method.init();
|
|
121
|
+
method.context = {
|
|
122
|
+
requestQueue: {
|
|
123
|
+
getRequestTasksId: () => [2],
|
|
124
|
+
getRequestTasksIdByConnectId: (connectId: string) => (connectId === path ? [2] : []),
|
|
125
|
+
getTask: (requestId: number) =>
|
|
126
|
+
requestId === 2 ? { method: { device: ownerDevice } } : undefined,
|
|
127
|
+
},
|
|
128
|
+
} as never;
|
|
129
|
+
method.connector = {
|
|
130
|
+
enumerate: jest.fn().mockResolvedValue({
|
|
131
|
+
descriptors: usbHandles.map(device => ({ path, device, commType: 'webusb' })),
|
|
132
|
+
}),
|
|
133
|
+
} as never;
|
|
134
|
+
return method.run();
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const createOwnerDevice = (path: string, usbHandle: unknown, serialNo: string) => ({
|
|
138
|
+
mainId: path,
|
|
139
|
+
features: { serial_no: serialNo },
|
|
140
|
+
originalDescriptor: { path, device: usbHandle },
|
|
141
|
+
toMessageObject: () => ({ connectId: serialNo, serialNo, uuid: serialNo }),
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test.each(['serial-V2', 'usb-1209-4f4c-onekey', BOOTLOADER_PATH])(
|
|
145
|
+
'owned WebUSB cache miss on %s reports the path without inventing an identity or probing',
|
|
146
|
+
async path => {
|
|
147
|
+
mockGetDeviceByPath.mockReturnValue(undefined);
|
|
148
|
+
|
|
149
|
+
await expect(runOwnedSearch(path)).resolves.toEqual([
|
|
150
|
+
{
|
|
151
|
+
connectId: path,
|
|
152
|
+
uuid: '',
|
|
153
|
+
serialNo: null,
|
|
154
|
+
deviceId: null,
|
|
155
|
+
deviceType: 'unknown',
|
|
156
|
+
name: path,
|
|
157
|
+
commType: 'webusb',
|
|
158
|
+
},
|
|
159
|
+
]);
|
|
160
|
+
expect(mockGetDevices).not.toHaveBeenCalled();
|
|
161
|
+
expect(mockConfigureTransport).not.toHaveBeenCalled();
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
test('owned WebUSB cache miss reports the owning request device identity', async () => {
|
|
166
|
+
mockGetDeviceByPath.mockReturnValue(undefined);
|
|
167
|
+
const usbHandle = { vendorId: 0x1209, productId: 0x4f4c };
|
|
168
|
+
const ownerDevice = createOwnerDevice(BOOTLOADER_PATH, usbHandle, 'PRO2SERIAL');
|
|
169
|
+
|
|
170
|
+
await expect(runOwnedSearch(BOOTLOADER_PATH, ownerDevice, [usbHandle])).resolves.toEqual([
|
|
171
|
+
{ connectId: 'PRO2SERIAL', serialNo: 'PRO2SERIAL', uuid: 'PRO2SERIAL' },
|
|
172
|
+
]);
|
|
173
|
+
expect(mockGetDevices).not.toHaveBeenCalled();
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test('owned WebUSB cache miss ignores an owning request device bound to another path', async () => {
|
|
177
|
+
mockGetDeviceByPath.mockReturnValue(undefined);
|
|
178
|
+
const usbHandle = { vendorId: 0x1209, productId: 0x4f4c };
|
|
179
|
+
const ownerDevice = createOwnerDevice('other-path', usbHandle, 'OTHERSERIAL');
|
|
180
|
+
|
|
181
|
+
await expect(runOwnedSearch('usb-1209-4f4c-onekey', ownerDevice, [usbHandle])).resolves.toEqual(
|
|
182
|
+
[expect.objectContaining({ connectId: 'usb-1209-4f4c-onekey', uuid: '', serialNo: null })]
|
|
183
|
+
);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test('a second device on the shared bootloader path does not take the owner identity', async () => {
|
|
187
|
+
mockGetDeviceByPath.mockReturnValue(undefined);
|
|
188
|
+
const ownerHandle = { vendorId: 0x1209, productId: 0x4f4c };
|
|
189
|
+
const otherHandle = { vendorId: 0x1209, productId: 0x4f4c };
|
|
190
|
+
const ownerDevice = createOwnerDevice(BOOTLOADER_PATH, ownerHandle, 'MINISERIAL');
|
|
191
|
+
|
|
192
|
+
await expect(
|
|
193
|
+
runOwnedSearch(BOOTLOADER_PATH, ownerDevice, [ownerHandle, otherHandle])
|
|
194
|
+
).resolves.toEqual([
|
|
195
|
+
{ connectId: 'MINISERIAL', serialNo: 'MINISERIAL', uuid: 'MINISERIAL' },
|
|
196
|
+
expect.objectContaining({ connectId: BOOTLOADER_PATH, uuid: '', serialNo: null }),
|
|
197
|
+
]);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test('a device swapped onto the bound bootloader path does not take the owner identity', async () => {
|
|
201
|
+
mockGetDeviceByPath.mockReturnValue(undefined);
|
|
202
|
+
const ownerDevice = createOwnerDevice(
|
|
203
|
+
BOOTLOADER_PATH,
|
|
204
|
+
{ vendorId: 0x1209, productId: 0x4f4c },
|
|
205
|
+
'MINISERIAL'
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
await expect(
|
|
209
|
+
runOwnedSearch(BOOTLOADER_PATH, ownerDevice, [{ vendorId: 0x1209, productId: 0x4f4c }])
|
|
210
|
+
).resolves.toEqual([
|
|
211
|
+
expect.objectContaining({ connectId: BOOTLOADER_PATH, uuid: '', serialNo: null }),
|
|
212
|
+
]);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
test('searchDevices resolves empty when WebUSB bring-up is unavailable', async () => {
|
|
216
|
+
mockEnsureInitialized.mockRejectedValueOnce(
|
|
217
|
+
new Error('WebUSB is not supported by current browsers')
|
|
218
|
+
);
|
|
219
|
+
const method = new SearchDevices({
|
|
220
|
+
id: 1,
|
|
221
|
+
payload: { method: 'searchDevices' },
|
|
222
|
+
} as never);
|
|
223
|
+
method.init();
|
|
224
|
+
method.connector = {
|
|
225
|
+
enumerate: jest.fn().mockResolvedValue({ descriptors: [] }),
|
|
226
|
+
} as never;
|
|
227
|
+
|
|
228
|
+
await expect(method.run()).resolves.toEqual([]);
|
|
229
|
+
expect(mockEnsureInitialized).toHaveBeenCalled();
|
|
230
|
+
expect(mockConfigureTransport).toHaveBeenCalledTimes(1);
|
|
43
231
|
});
|
|
44
232
|
|
|
45
233
|
test('搜索忽略调用方协议并主动探测,单个无响应设备不阻断后续结果', async () => {
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
requiredSigners,
|
|
29
|
+
...overrides,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe('SolSignOffchainMessage', () => {
|
|
34
|
+
test.each([
|
|
35
|
+
{ description: 'without a host-side signer count limit', requiredSigners },
|
|
36
|
+
{ description: 'with omitted optional signers', requiredSigners: undefined },
|
|
37
|
+
])('maps V1 parameters $description', async ({ requiredSigners }) => {
|
|
38
|
+
const method = createMethod({ requiredSigners });
|
|
39
|
+
method.init();
|
|
40
|
+
|
|
41
|
+
const typedCall = jest.fn().mockResolvedValue({
|
|
42
|
+
message: { signature: 'signature', public_key: signerA },
|
|
43
|
+
});
|
|
44
|
+
method.device = { commands: { typedCall } } as unknown as Device;
|
|
45
|
+
|
|
46
|
+
await expect(method.run()).resolves.toEqual({ signature: 'signature', pub: signerA });
|
|
47
|
+
expect(typedCall).toHaveBeenCalledWith('SolanaSignOffChainMessage', 'SolanaMessageSignature', {
|
|
48
|
+
address_n: [2147483692, 2147484149, 2147483648, 2147483648],
|
|
49
|
+
message: '48656c6c6f',
|
|
50
|
+
message_version: SolanaOffChainMessageVersion.MESSAGE_VERSION_1,
|
|
51
|
+
message_format: SolanaOffChainMessageFormat.V0_LIMITED_UTF8,
|
|
52
|
+
application_domain: 'aa'.repeat(32),
|
|
53
|
+
required_signers: requiredSigners ?? [],
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test.each([
|
|
58
|
+
{ requiredSigners: ['11'], error: '32-byte hex public key' },
|
|
59
|
+
{ requiredSigners: [signerB, signerA], error: 'strictly sorted and unique' },
|
|
60
|
+
{ requiredSigners: [signerA, signerA], error: 'strictly sorted and unique' },
|
|
61
|
+
])('rejects invalid required signers: $error', ({ requiredSigners, error }) => {
|
|
62
|
+
expect(() => createMethod({ requiredSigners }).init()).toThrow(error);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -23,6 +23,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
23
23
|
private protocolV2LastRuntimeProbeFeatures?;
|
|
24
24
|
private protocolV2LastTransferProgress?;
|
|
25
25
|
private protocolV2LastTransferProgressAt;
|
|
26
|
+
private protocolV2LastTransferredBytes;
|
|
26
27
|
init(): void;
|
|
27
28
|
private getProtocolV2FirmwareChunkSize;
|
|
28
29
|
run(): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV4.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAMZ,MAAM,qBAAqB,CAAC;AA0B7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC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YAuCd,6BAA6B;YAW7B,0BAA0B;YAoB1B,6BAA6B;YAwD7B,gBAAgB;IA0B9B,OAAO,CAAC,qBAAqB;CAM9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GetFeatures.d.ts","sourceRoot":"","sources":["../../src/api/GetFeatures.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"GetFeatures.d.ts","sourceRoot":"","sources":["../../src/api/GetFeatures.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,UAAU;IACjD,IAAI;IAWE,GAAG;CASV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GetPassphraseState.d.ts","sourceRoot":"","sources":["../../src/api/GetPassphraseState.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"GetPassphraseState.d.ts","sourceRoot":"","sources":["../../src/api/GetPassphraseState.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,UAAU;IACxD,qBAAqB;IAIrB,IAAI;IAKE,GAAG;CAiCV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenWalletSession.d.ts","sourceRoot":"","sources":["../../src/api/OpenWalletSession.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OpenWalletSession.d.ts","sourceRoot":"","sources":["../../src/api/OpenWalletSession.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,gCAAgC,CAAC;AAiDxC,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,UAAU,CAAC,uBAAuB,CAAC;IAChF,qBAAqB;IAIrB,IAAI;IAYE,GAAG,IAAI,OAAO,CAAC,wBAAwB,CAAC;CAkJ/C"}
|
|
@@ -1,22 +1,9 @@
|
|
|
1
1
|
import { BaseMethod } from './BaseMethod';
|
|
2
|
+
import type { SearchDevice } from '../types/device';
|
|
2
3
|
import type DeviceConnector from '../device/DeviceConnector';
|
|
3
4
|
export default class SearchDevices extends BaseMethod {
|
|
4
5
|
connector?: DeviceConnector;
|
|
5
6
|
init(): void;
|
|
6
|
-
run(): Promise<
|
|
7
|
-
connectId: string;
|
|
8
|
-
serialNo: null;
|
|
9
|
-
uuid: string;
|
|
10
|
-
deviceId: null;
|
|
11
|
-
name: string | null;
|
|
12
|
-
deviceType: import("..").IDeviceType;
|
|
13
|
-
commType: import("packages/hd-transport/dist").OneKeyDeviceCommType;
|
|
14
|
-
path: string;
|
|
15
|
-
session?: string | null | undefined;
|
|
16
|
-
debugSession?: string | null | undefined;
|
|
17
|
-
debug: boolean;
|
|
18
|
-
id: string;
|
|
19
|
-
protocolType?: import("packages/hd-transport/dist").ProtocolType | undefined;
|
|
20
|
-
}[]>;
|
|
7
|
+
run(): Promise<SearchDevice[]>;
|
|
21
8
|
}
|
|
22
9
|
//# sourceMappingURL=SearchDevices.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchDevices.d.ts","sourceRoot":"","sources":["../../src/api/SearchDevices.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,OAAO,KAAK,eAAe,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"SearchDevices.d.ts","sourceRoot":"","sources":["../../src/api/SearchDevices.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,eAAe,MAAM,2BAA2B,CAAC;AAyE7D,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD,SAAS,CAAC,EAAE,eAAe,CAAC;IAE5B,IAAI;IAME,GAAG,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;CAuFrC"}
|
|
@@ -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,6 +1,8 @@
|
|
|
1
1
|
import AllNetworkGetAddressBase from './AllNetworkGetAddressBase';
|
|
2
2
|
import type { AllNetworkAddress } from '../../types/api/allNetworkGetAddress';
|
|
3
3
|
export default class AllNetworkGetAddress extends AllNetworkGetAddressBase {
|
|
4
|
+
private checkAborted;
|
|
5
|
+
private callAddressGroup;
|
|
4
6
|
getAllNetworkAddress(rootFingerprint: number): Promise<AllNetworkAddress[]>;
|
|
5
7
|
}
|
|
6
8
|
//# sourceMappingURL=AllNetworkGetAddress.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AllNetworkGetAddress.d.ts","sourceRoot":"","sources":["../../../src/api/allnetwork/AllNetworkGetAddress.ts"],"names":[],"mappings":"AAIA,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAGlE,OAAO,KAAK,EACV,iBAAiB,
|
|
1
|
+
{"version":3,"file":"AllNetworkGetAddress.d.ts","sourceRoot":"","sources":["../../../src/api/allnetwork/AllNetworkGetAddress.ts"],"names":[],"mappings":"AAIA,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAGlE,OAAO,KAAK,EACV,iBAAiB,EAElB,MAAM,sCAAsC,CAAC;AAI9C,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,wBAAwB;IACxE,OAAO,CAAC,YAAY;YAMN,gBAAgB;IAsDxB,oBAAoB,CAAC,eAAe,EAAE,MAAM;CA8CnD"}
|
|
@@ -30,18 +30,24 @@ export default abstract class AllNetworkGetAddressBase extends BaseMethod<{
|
|
|
30
30
|
}[]> {
|
|
31
31
|
getSupportedProtocols(): readonly ["V1", "V2"];
|
|
32
32
|
abortController: AbortController | null;
|
|
33
|
+
protected loadingCleanupInBackground: boolean;
|
|
34
|
+
private loadingCommands?;
|
|
35
|
+
private protocolV2ResumedSeedDomains;
|
|
33
36
|
init(): void;
|
|
34
37
|
generateMethodName({ network, payload, originalIndex, }: {
|
|
35
38
|
network: INetwork;
|
|
36
39
|
payload: AllNetworkAddressParams;
|
|
37
40
|
originalIndex: number;
|
|
38
41
|
}): MethodParams;
|
|
42
|
+
private hasProtocolV2WalletResume;
|
|
43
|
+
private markProtocolV2WalletResumed;
|
|
39
44
|
callMethod(methodName: keyof CoreApi, params: any & {
|
|
40
45
|
bundle: (any & {
|
|
41
46
|
_originRequestParams: CommonResponseParams;
|
|
42
47
|
})[];
|
|
43
|
-
}, rootFingerprint: number): Promise<AllNetworkAddress[]>;
|
|
48
|
+
}, rootFingerprint: number, postMessage?: (message: import("../../events").CoreMessage) => void): Promise<AllNetworkAddress[]>;
|
|
44
49
|
abstract getAllNetworkAddress(rootFingerprint: number): Promise<AllNetworkAddress[]>;
|
|
50
|
+
protected stopAllNetworkLoading(canSend?: boolean): Promise<void>;
|
|
45
51
|
run(): Promise<AllNetworkAddress[]>;
|
|
46
52
|
}
|
|
47
53
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AllNetworkGetAddressBase.d.ts","sourceRoot":"","sources":["../../../src/api/allnetwork/AllNetworkGetAddressBase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AllNetworkGetAddressBase.d.ts","sourceRoot":"","sources":["../../../src/api/allnetwork/AllNetworkGetAddressBase.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAiB3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EACV,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,QAAQ,EACT,MAAM,sCAAsC,CAAC;AAI9C,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,MAAM,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,uBAAuB,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;IAClG,kBAAkB,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,EAAE,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC;AAEzF,MAAM,MAAM,gBAAgB,GAAG;KAC5B,CAAC,IAAI,YAAY,GAAG,aAAa;CACnC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,YAAY,CAAC;QAAC,I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AAqB,CAAC,OAAO,UAAO;IAc9C,GAAG;CAiDV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AllNetworkGetAddressByLoop.d.ts","sourceRoot":"","sources":["../../../src/api/allnetwork/AllNetworkGetAddressByLoop.ts"],"names":[],"mappings":"AASA,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAQlE,MAAM,CAAC,OAAO,OAAO,0BAA2B,SAAQ,wBAAwB;IACxE,oBAAoB,CAAC,eAAe,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"AllNetworkGetAddressByLoop.d.ts","sourceRoot":"","sources":["../../../src/api/allnetwork/AllNetworkGetAddressByLoop.ts"],"names":[],"mappings":"AASA,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAQlE,MAAM,CAAC,OAAO,OAAO,0BAA2B,SAAQ,wBAAwB;IACxE,oBAAoB,CAAC,eAAe,EAAE,MAAM;YA8BpC,4BAA4B;IAmF1C,OAAO,CAAC,kBAAkB;IAoB1B,OAAO,CAAC,gBAAgB;CAazB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceVerify.d.ts","sourceRoot":"","sources":["../../../src/api/device/DeviceVerify.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,UAAU,CAAC,wBAAwB,CAAC;IAC5E,qBAAqB;IAIrB,IAAI;
|
|
1
|
+
{"version":3,"file":"DeviceVerify.d.ts","sourceRoot":"","sources":["../../../src/api/device/DeviceVerify.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,UAAU,CAAC,wBAAwB,CAAC;IAC5E,qBAAqB;IAIrB,IAAI;IAwBE,GAAG;CAsDV"}
|
|
@@ -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;AA2B1G,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,UAAU,CAAC,8BAA8B,CAAC;IAC5F,qBAAqB;IAIrB,IAAI;IA0CJ,eAAe;;;;;;;;;;;IAcT,GAAG;;;;CAcV"}
|