@onekeyfe/hd-core 0.1.14 → 0.1.18
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/dist/api/BaseMethod.d.ts +4 -0
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckBLEFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CheckFirmwareRelease.d.ts.map +1 -1
- package/dist/api/GetLogs.d.ts +11 -0
- package/dist/api/GetLogs.d.ts.map +1 -0
- package/dist/api/firmware/releaseHelper.d.ts +18 -0
- package/dist/api/firmware/releaseHelper.d.ts.map +1 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/constants/errors.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/device/Device.d.ts +3 -1
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +1 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceList.d.ts +1 -1
- package/dist/device/DeviceList.d.ts.map +1 -1
- package/dist/events/core.d.ts +3 -1
- package/dist/events/core.d.ts.map +1 -1
- package/dist/events/firmware.d.ts +21 -0
- package/dist/events/firmware.d.ts.map +1 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/log.d.ts +15 -0
- package/dist/events/log.d.ts.map +1 -0
- package/dist/index.d.ts +134 -40
- package/dist/index.js +730 -396
- package/dist/inject.d.ts.map +1 -1
- package/dist/types/api/btcGetAddress.d.ts +2 -2
- package/dist/types/api/btcGetAddress.d.ts.map +1 -1
- package/dist/types/api/btcGetPublicKey.d.ts +2 -2
- package/dist/types/api/btcGetPublicKey.d.ts.map +1 -1
- package/dist/types/api/btcSignMessage.d.ts +1 -1
- package/dist/types/api/btcSignMessage.d.ts.map +1 -1
- package/dist/types/api/btcSignTransaction.d.ts +1 -1
- package/dist/types/api/btcSignTransaction.d.ts.map +1 -1
- package/dist/types/api/btcVerifyMessage.d.ts +1 -1
- package/dist/types/api/btcVerifyMessage.d.ts.map +1 -1
- package/dist/types/api/cipherKeyValue.d.ts +2 -2
- package/dist/types/api/cipherKeyValue.d.ts.map +1 -1
- package/dist/types/api/evmGetAddress.d.ts +2 -2
- package/dist/types/api/evmGetAddress.d.ts.map +1 -1
- package/dist/types/api/evmGetPublicKey.d.ts +2 -2
- package/dist/types/api/evmGetPublicKey.d.ts.map +1 -1
- package/dist/types/api/evmSignMessage.d.ts +1 -1
- package/dist/types/api/evmSignMessage.d.ts.map +1 -1
- package/dist/types/api/evmSignMessageEIP712.d.ts +1 -1
- package/dist/types/api/evmSignMessageEIP712.d.ts.map +1 -1
- package/dist/types/api/evmSignTransaction.d.ts +1 -1
- package/dist/types/api/evmSignTransaction.d.ts.map +1 -1
- package/dist/types/api/evmSignTypedData.d.ts +1 -1
- package/dist/types/api/evmSignTypedData.d.ts.map +1 -1
- package/dist/types/api/evmVerifyMessage.d.ts +1 -1
- package/dist/types/api/evmVerifyMessage.d.ts.map +1 -1
- package/dist/types/api/getLogs.d.ts +3 -0
- package/dist/types/api/getLogs.d.ts.map +1 -0
- package/dist/types/api/index.d.ts +2 -0
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/nemGetAddress.d.ts +2 -2
- package/dist/types/api/nemGetAddress.d.ts.map +1 -1
- package/dist/types/api/nemSignTransaction.d.ts +1 -1
- package/dist/types/api/nemSignTransaction.d.ts.map +1 -1
- package/dist/types/api/solGetAddress.d.ts +2 -2
- package/dist/types/api/solGetAddress.d.ts.map +1 -1
- package/dist/types/api/solSignTransaction.d.ts +2 -2
- package/dist/types/api/solSignTransaction.d.ts.map +1 -1
- package/dist/types/api/starcoinGetAddress.d.ts +2 -2
- package/dist/types/api/starcoinGetAddress.d.ts.map +1 -1
- package/dist/types/api/starcoinGetPublicKey.d.ts +2 -2
- package/dist/types/api/starcoinGetPublicKey.d.ts.map +1 -1
- package/dist/types/api/starcoinSignMessage.d.ts +1 -1
- package/dist/types/api/starcoinSignMessage.d.ts.map +1 -1
- package/dist/types/api/starcoinSignTransaction.d.ts +1 -1
- package/dist/types/api/starcoinSignTransaction.d.ts.map +1 -1
- package/dist/types/api/starcoinVerifyMessage.d.ts +1 -1
- package/dist/types/api/starcoinVerifyMessage.d.ts.map +1 -1
- package/dist/types/api/stellarGetAddress.d.ts +2 -2
- package/dist/types/api/stellarGetAddress.d.ts.map +1 -1
- package/dist/types/api/stellarSignTransaction.d.ts +1 -1
- package/dist/types/api/stellarSignTransaction.d.ts.map +1 -1
- package/dist/types/params.d.ts +3 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/logger.d.ts +56 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +30 -1
- package/src/api/CheckBLEFirmwareRelease.ts +4 -9
- package/src/api/CheckFirmwareRelease.ts +3 -9
- package/src/api/FirmwareUpdate.ts +1 -1
- package/src/api/GetLogs.ts +13 -0
- package/src/api/device/DeviceVerify.ts +1 -1
- package/src/api/firmware/releaseHelper.ts +24 -0
- package/src/api/index.ts +2 -0
- package/src/constants/errors.ts +5 -1
- package/src/core/index.ts +150 -32
- package/src/data-manager/TransportManager.ts +8 -6
- package/src/device/Device.ts +23 -7
- package/src/device/DeviceCommands.ts +12 -9
- package/src/device/DeviceConnector.ts +3 -3
- package/src/device/DeviceList.ts +25 -10
- package/src/events/core.ts +4 -0
- package/src/events/firmware.ts +32 -0
- package/src/events/index.ts +2 -0
- package/src/events/log.ts +23 -0
- package/src/inject.ts +55 -46
- package/src/types/api/btcGetAddress.ts +3 -5
- package/src/types/api/btcGetPublicKey.ts +2 -0
- package/src/types/api/btcSignMessage.ts +1 -0
- package/src/types/api/btcSignTransaction.ts +1 -0
- package/src/types/api/btcVerifyMessage.ts +1 -0
- package/src/types/api/cipherKeyValue.ts +2 -0
- package/src/types/api/evmGetAddress.ts +2 -0
- package/src/types/api/evmGetPublicKey.ts +2 -0
- package/src/types/api/evmSignMessage.ts +1 -0
- package/src/types/api/evmSignMessageEIP712.ts +1 -0
- package/src/types/api/evmSignTransaction.ts +1 -0
- package/src/types/api/evmSignTypedData.ts +1 -0
- package/src/types/api/evmVerifyMessage.ts +1 -0
- package/src/types/api/getLogs.ts +3 -0
- package/src/types/api/index.ts +2 -0
- package/src/types/api/nemGetAddress.ts +2 -0
- package/src/types/api/nemSignTransaction.ts +1 -0
- package/src/types/api/solGetAddress.ts +2 -0
- package/src/types/api/solSignTransaction.ts +2 -0
- package/src/types/api/starcoinGetAddress.ts +2 -0
- package/src/types/api/starcoinGetPublicKey.ts +2 -0
- package/src/types/api/starcoinSignMessage.ts +1 -0
- package/src/types/api/starcoinSignTransaction.ts +1 -0
- package/src/types/api/starcoinVerifyMessage.ts +1 -0
- package/src/types/api/stellarGetAddress.ts +2 -0
- package/src/types/api/stellarSignTransaction.ts +1 -0
- package/src/types/params.ts +12 -0
- package/src/utils/deviceFeaturesUtils.ts +2 -10
- package/src/utils/index.ts +1 -3
- package/src/utils/logger.ts +179 -0
package/src/device/Device.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { createDeferred, Deferred, HardwareErrorCode, ERRORS } from '@onekeyfe/h
|
|
|
5
5
|
import DeviceConnector from './DeviceConnector';
|
|
6
6
|
import { DeviceCommands } from './DeviceCommands';
|
|
7
7
|
|
|
8
|
-
import { initLog } from '../utils';
|
|
9
8
|
import {
|
|
10
9
|
getDeviceFirmwareVersion,
|
|
11
10
|
getDeviceLabel,
|
|
@@ -18,6 +17,7 @@ import type { Features, Device as DeviceTyped, UnavailableCapabilities } from '.
|
|
|
18
17
|
import { DEVICE, DeviceButtonRequestPayload } from '../events';
|
|
19
18
|
import { UI_REQUEST } from '../constants/ui-request';
|
|
20
19
|
import { PROTO } from '../constants';
|
|
20
|
+
import { getLogger, LoggerNames } from '../utils';
|
|
21
21
|
import { DataManager } from '../data-manager';
|
|
22
22
|
|
|
23
23
|
type RunOptions = {
|
|
@@ -29,7 +29,7 @@ const parseRunOptions = (options?: RunOptions): RunOptions => {
|
|
|
29
29
|
return options;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
const Log =
|
|
32
|
+
const Log = getLogger(LoggerNames.Device);
|
|
33
33
|
|
|
34
34
|
export interface DeviceEvents {
|
|
35
35
|
[DEVICE.PIN]: [Device, PROTO.PinMatrixRequestType | undefined, (err: any, pin: string) => void];
|
|
@@ -186,7 +186,7 @@ export class Device extends EventEmitter {
|
|
|
186
186
|
}
|
|
187
187
|
this.updateDescriptor({ [mainIdKey]: this.mainId } as unknown as DeviceDescriptor);
|
|
188
188
|
if (this.commands) {
|
|
189
|
-
this.commands.dispose();
|
|
189
|
+
await this.commands.dispose(false);
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
this.commands = new DeviceCommands(this, this.mainId ?? '');
|
|
@@ -207,7 +207,7 @@ export class Device extends EventEmitter {
|
|
|
207
207
|
(this.mainId && env === 'react-native')
|
|
208
208
|
) {
|
|
209
209
|
if (this.commands) {
|
|
210
|
-
this.commands.dispose();
|
|
210
|
+
this.commands.dispose(false);
|
|
211
211
|
if (this.commands.callPromise) {
|
|
212
212
|
try {
|
|
213
213
|
await this.commands.callPromise;
|
|
@@ -298,7 +298,7 @@ export class Device extends EventEmitter {
|
|
|
298
298
|
|
|
299
299
|
async run(fn?: () => Promise<void>, options?: RunOptions) {
|
|
300
300
|
if (this.runPromise) {
|
|
301
|
-
this.
|
|
301
|
+
await this.interruptionFromOutside();
|
|
302
302
|
Log.debug('[Device] run error:', 'Device is running, but will cancel previous operate');
|
|
303
303
|
}
|
|
304
304
|
|
|
@@ -350,15 +350,24 @@ export class Device extends EventEmitter {
|
|
|
350
350
|
this.runPromise = null;
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
-
|
|
353
|
+
async interruptionFromOutside() {
|
|
354
354
|
if (this.commands) {
|
|
355
|
-
this.commands.dispose();
|
|
355
|
+
await this.commands.dispose(false);
|
|
356
356
|
}
|
|
357
357
|
if (this.runPromise) {
|
|
358
358
|
this.runPromise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceInterruptedFromOutside));
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
+
async interruptionFromUser() {
|
|
363
|
+
if (this.commands) {
|
|
364
|
+
await this.commands.dispose(true);
|
|
365
|
+
}
|
|
366
|
+
if (this.runPromise) {
|
|
367
|
+
this.runPromise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceInterruptedFromUser));
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
362
371
|
getMode() {
|
|
363
372
|
if (this.features?.bootloader_mode) return 'bootloader';
|
|
364
373
|
if (!this.features?.initialized) return 'initialize';
|
|
@@ -429,6 +438,13 @@ export class Device extends EventEmitter {
|
|
|
429
438
|
}
|
|
430
439
|
return null;
|
|
431
440
|
}
|
|
441
|
+
|
|
442
|
+
checkDeviceId(deviceId: string) {
|
|
443
|
+
if (this.features) {
|
|
444
|
+
return this.features.device_id === deviceId;
|
|
445
|
+
}
|
|
446
|
+
return false;
|
|
447
|
+
}
|
|
432
448
|
}
|
|
433
449
|
|
|
434
450
|
export default Device;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Transport, Messages } from '@onekeyfe/hd-transport';
|
|
2
2
|
import { ERRORS, HardwareError, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
3
3
|
import TransportManager from '../data-manager/TransportManager';
|
|
4
|
-
import {
|
|
4
|
+
import { patchFeatures, getLogger, LoggerNames } from '../utils';
|
|
5
5
|
import type { Device } from './Device';
|
|
6
6
|
import { DEVICE } from '../events';
|
|
7
7
|
|
|
@@ -32,7 +32,7 @@ const assertType = (res: DefaultMessageResponse, resType: string | string[]) =>
|
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
const Log =
|
|
35
|
+
const Log = getLogger(LoggerNames.DeviceCommands);
|
|
36
36
|
|
|
37
37
|
export class DeviceCommands {
|
|
38
38
|
device: Device;
|
|
@@ -54,13 +54,13 @@ export class DeviceCommands {
|
|
|
54
54
|
this.disposed = false;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
dispose() {
|
|
57
|
+
async dispose(cancelRequest: boolean) {
|
|
58
58
|
this.disposed = true;
|
|
59
|
-
if (this._cancelableRequest) {
|
|
59
|
+
if (cancelRequest && this._cancelableRequest) {
|
|
60
60
|
this._cancelableRequest();
|
|
61
61
|
}
|
|
62
62
|
this._cancelableRequest = undefined;
|
|
63
|
-
this.transport.cancel?.();
|
|
63
|
+
await this.transport.cancel?.();
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
// Sends an async message to the opened device.
|
|
@@ -68,7 +68,7 @@ export class DeviceCommands {
|
|
|
68
68
|
type: MessageKey,
|
|
69
69
|
msg: DefaultMessageResponse['message'] = {}
|
|
70
70
|
): Promise<DefaultMessageResponse> {
|
|
71
|
-
|
|
71
|
+
Log.debug('[DeviceCommands] [call] Sending', type);
|
|
72
72
|
|
|
73
73
|
try {
|
|
74
74
|
const promise = this.transport.call(this.mainId, type, msg) as any;
|
|
@@ -117,7 +117,7 @@ export class DeviceCommands {
|
|
|
117
117
|
// Bridge may have some unread message in buffer, read it
|
|
118
118
|
// await this.transport.read?.(this.mainId);
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
Log.debug('DeviceCommands typedcall error: ', error);
|
|
121
121
|
|
|
122
122
|
// throw bridge network error
|
|
123
123
|
if (error instanceof HardwareError) {
|
|
@@ -140,7 +140,7 @@ export class DeviceCommands {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
_filterCommonTypes(res: DefaultMessageResponse): Promise<DefaultMessageResponse> {
|
|
143
|
-
|
|
143
|
+
Log.debug('_filterCommonTypes: ', res);
|
|
144
144
|
if (res.type === 'Failure') {
|
|
145
145
|
const { code } = res.message;
|
|
146
146
|
const { message } = res.message;
|
|
@@ -206,7 +206,10 @@ export class DeviceCommands {
|
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
if (res.type === 'PassphraseRequest') {
|
|
209
|
-
|
|
209
|
+
/**
|
|
210
|
+
* Temporary, callback an empty passphrase
|
|
211
|
+
*/
|
|
212
|
+
return this._commonCall('PassphraseAck', { passphrase: '' });
|
|
210
213
|
}
|
|
211
214
|
|
|
212
215
|
// TT fw lower than 2.3.0, device send his current state
|
|
@@ -2,8 +2,8 @@ import { Transport, OneKeyDeviceInfo as DeviceDescriptor } from '@onekeyfe/hd-tr
|
|
|
2
2
|
import { safeThrowError } from '../constants';
|
|
3
3
|
import { DataManager } from '../data-manager';
|
|
4
4
|
import TransportManager from '../data-manager/TransportManager';
|
|
5
|
-
import { initLog } from '../utils';
|
|
6
5
|
import { resolveAfter } from '../utils/promiseUtils';
|
|
6
|
+
import { getLogger, LoggerNames } from '../utils';
|
|
7
7
|
|
|
8
8
|
export type DeviceDescriptorDiff = {
|
|
9
9
|
didUpdate: boolean;
|
|
@@ -18,7 +18,7 @@ export type DeviceDescriptorDiff = {
|
|
|
18
18
|
descriptors: DeviceDescriptor[];
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
const Log =
|
|
21
|
+
const Log = getLogger(LoggerNames.DeviceConnector);
|
|
22
22
|
|
|
23
23
|
const getDiff = (
|
|
24
24
|
current: DeviceDescriptor[],
|
|
@@ -141,7 +141,7 @@ export default class DeviceConnector {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
async acquire(path: string, session?: string | null) {
|
|
144
|
-
|
|
144
|
+
Log.debug('acquire', path, session);
|
|
145
145
|
const env = DataManager.getSettings('env');
|
|
146
146
|
try {
|
|
147
147
|
let res;
|
package/src/device/DeviceList.ts
CHANGED
|
@@ -2,11 +2,12 @@ import EventEmitter from 'events';
|
|
|
2
2
|
import DeviceConnector from './DeviceConnector';
|
|
3
3
|
import { Device } from './Device';
|
|
4
4
|
import { getDeviceUUID } from '../utils/deviceFeaturesUtils';
|
|
5
|
-
import {
|
|
5
|
+
import { getLogger, LoggerNames } from '../utils';
|
|
6
6
|
|
|
7
|
-
const cacheDeviceMap = new Map<string, Device>();
|
|
7
|
+
// const cacheDeviceMap = new Map<string, Device>();
|
|
8
|
+
const cacheDeviceMap: Record<string, Device> = {};
|
|
8
9
|
|
|
9
|
-
const Log =
|
|
10
|
+
const Log = getLogger(LoggerNames.DeviceList);
|
|
10
11
|
|
|
11
12
|
export class DeviceList extends EventEmitter {
|
|
12
13
|
devices: Record<string, Device> = {};
|
|
@@ -17,13 +18,28 @@ export class DeviceList extends EventEmitter {
|
|
|
17
18
|
* 获取已连接的设备列表
|
|
18
19
|
* @returns {OneKeyDeviceInfo[]}
|
|
19
20
|
*/
|
|
20
|
-
async getDeviceLists() {
|
|
21
|
+
async getDeviceLists(connectId?: string) {
|
|
21
22
|
const deviceDiff = await this.connector?.enumerate();
|
|
22
23
|
const descriptorList = deviceDiff?.descriptors ?? [];
|
|
23
24
|
|
|
24
25
|
this.devices = {};
|
|
25
26
|
const deviceList = [];
|
|
26
|
-
|
|
27
|
+
Log.debug('get device list');
|
|
28
|
+
|
|
29
|
+
// find existed device
|
|
30
|
+
if (connectId) {
|
|
31
|
+
const device = cacheDeviceMap[connectId];
|
|
32
|
+
if (device) {
|
|
33
|
+
const exist = descriptorList.find(d => d.path === device.originalDescriptor.path);
|
|
34
|
+
if (exist) {
|
|
35
|
+
device.updateDescriptor(exist, true);
|
|
36
|
+
Log.debug('find existed Device: ', connectId);
|
|
37
|
+
this.devices[connectId] = device;
|
|
38
|
+
return [device];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
27
43
|
for await (const descriptor of descriptorList) {
|
|
28
44
|
let device = Device.fromDescriptor(descriptor);
|
|
29
45
|
device.deviceConnector = this.connector;
|
|
@@ -35,14 +51,13 @@ export class DeviceList extends EventEmitter {
|
|
|
35
51
|
deviceList.push(device);
|
|
36
52
|
if (device.features) {
|
|
37
53
|
const uuid = getDeviceUUID(device.features);
|
|
38
|
-
if (cacheDeviceMap
|
|
39
|
-
const cache = cacheDeviceMap
|
|
54
|
+
if (cacheDeviceMap[uuid]) {
|
|
55
|
+
const cache = cacheDeviceMap[uuid];
|
|
40
56
|
cache?.updateFromCache(device);
|
|
41
|
-
device = cache
|
|
42
|
-
Log.debug('use cache device: ', uuid);
|
|
57
|
+
device = cache;
|
|
43
58
|
}
|
|
44
59
|
this.devices[uuid] = device;
|
|
45
|
-
cacheDeviceMap
|
|
60
|
+
cacheDeviceMap[uuid] = device;
|
|
46
61
|
}
|
|
47
62
|
}
|
|
48
63
|
|
package/src/events/core.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { DeviceEventMessage } from './device';
|
|
|
5
5
|
import { IFrameEventMessage } from './iframe';
|
|
6
6
|
import { UiEventMessage } from './ui-request';
|
|
7
7
|
import { UiResponseMessage } from './ui-response';
|
|
8
|
+
import { LogEventMessage } from './log';
|
|
9
|
+
import { FirmwareMessage } from './firmware';
|
|
8
10
|
|
|
9
11
|
export const CORE_EVENT = 'CORE_EVENT';
|
|
10
12
|
|
|
@@ -18,6 +20,8 @@ export type CoreMessage = {
|
|
|
18
20
|
| UiResponseMessage
|
|
19
21
|
| UiEventMessage
|
|
20
22
|
| DeviceEventMessage
|
|
23
|
+
| LogEventMessage
|
|
24
|
+
| FirmwareMessage
|
|
21
25
|
);
|
|
22
26
|
|
|
23
27
|
export type PostMessageEvent = MessageEvent<any>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { MessageFactoryFn } from './utils';
|
|
2
|
+
import { getBleFirmwareReleaseInfo, getFirmwareReleaseInfo } from '../api/firmware/releaseHelper';
|
|
3
|
+
|
|
4
|
+
export const FIRMWARE_EVENT = 'FIRMWARE_EVENT';
|
|
5
|
+
export const FIRMWARE = {
|
|
6
|
+
RELEASE_INFO: 'firmware-release-info',
|
|
7
|
+
BLE_RELEASE_INFO: 'ble-firmware-release-info',
|
|
8
|
+
} as const;
|
|
9
|
+
|
|
10
|
+
export interface ReleaseInfoEvent {
|
|
11
|
+
type: typeof FIRMWARE.RELEASE_INFO;
|
|
12
|
+
payload: ReturnType<typeof getFirmwareReleaseInfo>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface BleReleaseInfoEvent {
|
|
16
|
+
type: typeof FIRMWARE.BLE_RELEASE_INFO;
|
|
17
|
+
payload: ReturnType<typeof getBleFirmwareReleaseInfo>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type FirmwareEvent = ReleaseInfoEvent | BleReleaseInfoEvent;
|
|
21
|
+
|
|
22
|
+
export type FirmwareMessage = FirmwareEvent & { event: typeof FIRMWARE_EVENT };
|
|
23
|
+
|
|
24
|
+
export const createFirmwareMessage: MessageFactoryFn<typeof FIRMWARE_EVENT, FirmwareEvent> = (
|
|
25
|
+
type,
|
|
26
|
+
payload
|
|
27
|
+
) =>
|
|
28
|
+
({
|
|
29
|
+
event: FIRMWARE_EVENT,
|
|
30
|
+
type,
|
|
31
|
+
payload,
|
|
32
|
+
} as any);
|
package/src/events/index.ts
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { MessageFactoryFn } from './utils';
|
|
2
|
+
|
|
3
|
+
export const LOG_EVENT = 'LOG_EVENT';
|
|
4
|
+
|
|
5
|
+
export const LOG = {
|
|
6
|
+
OUTPUT: 'log-output',
|
|
7
|
+
} as const;
|
|
8
|
+
|
|
9
|
+
export interface LogOutput {
|
|
10
|
+
type: typeof LOG.OUTPUT;
|
|
11
|
+
payload: any;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type LogEvent = LogOutput;
|
|
15
|
+
|
|
16
|
+
export type LogEventMessage = LogEvent & { event: typeof LOG_EVENT };
|
|
17
|
+
|
|
18
|
+
export const createLogMessage: MessageFactoryFn<typeof LOG_EVENT, LogEvent> = (type, payload) =>
|
|
19
|
+
({
|
|
20
|
+
event: LOG_EVENT,
|
|
21
|
+
type,
|
|
22
|
+
payload,
|
|
23
|
+
} as any);
|
package/src/inject.ts
CHANGED
|
@@ -41,6 +41,8 @@ export const inject = ({
|
|
|
41
41
|
uiResponse,
|
|
42
42
|
|
|
43
43
|
cancel,
|
|
44
|
+
|
|
45
|
+
getLogs: () => call({ method: 'getLogs' }),
|
|
44
46
|
/**
|
|
45
47
|
* 搜索设备
|
|
46
48
|
*/
|
|
@@ -71,7 +73,8 @@ export const inject = ({
|
|
|
71
73
|
*/
|
|
72
74
|
checkBridgeStatus: () => call({ method: 'checkBridgeStatus' }),
|
|
73
75
|
|
|
74
|
-
cipherKeyValue: (connectId, params) =>
|
|
76
|
+
cipherKeyValue: (connectId, deviceId, params) =>
|
|
77
|
+
call({ ...params, connectId, deviceId, method: 'cipherKeyValue' }),
|
|
75
78
|
|
|
76
79
|
deviceBackup: connectId => call({ connectId, method: 'deviceBackup' }),
|
|
77
80
|
deviceChangePin: (connectId, params) =>
|
|
@@ -85,51 +88,57 @@ export const inject = ({
|
|
|
85
88
|
deviceVerify: (connectId, params) => call({ ...params, connectId, method: 'deviceVerify' }),
|
|
86
89
|
deviceWipe: connectId => call({ connectId, method: 'deviceWipe' }),
|
|
87
90
|
|
|
88
|
-
evmGetAddress: (connectId, params) =>
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
call({ ...params, connectId, method: '
|
|
94
|
-
|
|
95
|
-
call({ ...params, connectId, method: '
|
|
96
|
-
|
|
97
|
-
call({ ...params, connectId, method: '
|
|
98
|
-
|
|
99
|
-
call({ ...params, connectId, method: '
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
call({ ...params, connectId, method: '
|
|
107
|
-
|
|
108
|
-
call({ ...params, connectId, method: '
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
call({ ...params, connectId, method: '
|
|
116
|
-
|
|
117
|
-
call({ ...params, connectId, method: '
|
|
118
|
-
|
|
119
|
-
call({ ...params, connectId, method: '
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
call({ ...params, connectId, method: '
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
91
|
+
evmGetAddress: (connectId, deviceId, params) =>
|
|
92
|
+
call({ ...params, connectId, deviceId, method: 'evmGetAddress' }),
|
|
93
|
+
evmGetPublicKey: (connectId, deviceId, params) =>
|
|
94
|
+
call({ ...params, connectId, deviceId, method: 'evmGetPublicKey' }),
|
|
95
|
+
evmSignMessage: (connectId, deviceId, params) =>
|
|
96
|
+
call({ ...params, connectId, deviceId, method: 'evmSignMessage' }),
|
|
97
|
+
evmSignMessageEIP712: (connectId, deviceId, params) =>
|
|
98
|
+
call({ ...params, connectId, deviceId, method: 'evmSignMessageEIP712' }),
|
|
99
|
+
evmSignTransaction: (connectId, deviceId, params) =>
|
|
100
|
+
call({ ...params, connectId, deviceId, method: 'evmSignTransaction' }),
|
|
101
|
+
evmSignTypedData: (connectId, deviceId, params) =>
|
|
102
|
+
call({ ...params, connectId, deviceId, method: 'evmSignTypedData' }),
|
|
103
|
+
evmVerifyMessage: (connectId, deviceId, params) =>
|
|
104
|
+
call({ ...params, connectId, deviceId, method: 'evmVerifyMessage' }),
|
|
105
|
+
|
|
106
|
+
btcGetAddress: (connectId, deviceId, params) =>
|
|
107
|
+
call({ ...params, connectId, deviceId, method: 'btcGetAddress' }),
|
|
108
|
+
btcGetPublicKey: (connectId, deviceId, params) =>
|
|
109
|
+
call({ ...params, connectId, deviceId, method: 'btcGetPublicKey' }),
|
|
110
|
+
btcSignMessage: (connectId, deviceId, params) =>
|
|
111
|
+
call({ ...params, connectId, deviceId, method: 'btcSignMessage' }),
|
|
112
|
+
btcSignTransaction: (connectId, deviceId, params) =>
|
|
113
|
+
call({ ...params, connectId, deviceId, method: 'btcSignTransaction' }),
|
|
114
|
+
btcVerifyMessage: (connectId, deviceId, params) =>
|
|
115
|
+
call({ ...params, connectId, deviceId, method: 'btcVerifyMessage' }),
|
|
116
|
+
|
|
117
|
+
starcoinGetAddress: (connectId, deviceId, params) =>
|
|
118
|
+
call({ ...params, connectId, deviceId, method: 'starcoinGetAddress' }),
|
|
119
|
+
starcoinGetPublicKey: (connectId, deviceId, params) =>
|
|
120
|
+
call({ ...params, connectId, deviceId, method: 'starcoinGetPublicKey' }),
|
|
121
|
+
starcoinSignMessage: (connectId, deviceId, params) =>
|
|
122
|
+
call({ ...params, connectId, deviceId, method: 'starcoinSignMessage' }),
|
|
123
|
+
starcoinSignTransaction: (connectId, deviceId, params) =>
|
|
124
|
+
call({ ...params, connectId, deviceId, method: 'starcoinSignTransaction' }),
|
|
125
|
+
starcoinVerifyMessage: (connectId, deviceId, params) =>
|
|
126
|
+
call({ ...params, connectId, deviceId, method: 'starcoinVerifyMessage' }),
|
|
127
|
+
|
|
128
|
+
nemGetAddress: (connectId, deviceId, params) =>
|
|
129
|
+
call({ ...params, connectId, deviceId, method: 'nemGetAddress' }),
|
|
130
|
+
nemSignTransaction: (connectId, deviceId, params) =>
|
|
131
|
+
call({ ...params, connectId, deviceId, method: 'nemSignTransaction' }),
|
|
132
|
+
|
|
133
|
+
solGetAddress: (connectId, deviceId, params) =>
|
|
134
|
+
call({ ...params, connectId, deviceId, method: 'solGetAddress' }),
|
|
135
|
+
solSignTransaction: (connectId, deviceId, params) =>
|
|
136
|
+
call({ ...params, connectId, deviceId, method: 'solSignTransaction' }),
|
|
137
|
+
|
|
138
|
+
stellarGetAddress: (connectId, deviceId, params) =>
|
|
139
|
+
call({ ...params, connectId, deviceId, method: 'stellarGetAddress' }),
|
|
140
|
+
stellarSignTransaction: (connectId, deviceId, params) =>
|
|
141
|
+
call({ ...params, connectId, deviceId, method: 'stellarSignTransaction' }),
|
|
133
142
|
|
|
134
143
|
firmwareUpdate: (connectId, params) => call({ ...params, connectId, method: 'firmwareUpdate' }),
|
|
135
144
|
};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Address,
|
|
3
|
-
InputScriptType,
|
|
4
|
-
MultisigRedeemScriptType,
|
|
5
|
-
} from '@onekeyfe/hd-transport';
|
|
1
|
+
import { Address, InputScriptType, MultisigRedeemScriptType } from '@onekeyfe/hd-transport';
|
|
6
2
|
import type { CommonParams, Response } from '../params';
|
|
7
3
|
|
|
8
4
|
export type BTCAddress = {
|
|
@@ -19,10 +15,12 @@ export type BTCGetAddressParams = {
|
|
|
19
15
|
|
|
20
16
|
export declare function btcGetAddress(
|
|
21
17
|
connectId: string,
|
|
18
|
+
deviceId: string,
|
|
22
19
|
params: CommonParams & BTCGetAddressParams
|
|
23
20
|
): Response<BTCAddress>;
|
|
24
21
|
|
|
25
22
|
export declare function btcGetAddress(
|
|
26
23
|
connectId: string,
|
|
24
|
+
deviceId: string,
|
|
27
25
|
params: CommonParams & { bundle?: BTCGetAddressParams[] }
|
|
28
26
|
): Response<Array<BTCAddress>>;
|
|
@@ -14,10 +14,12 @@ export type BTCGetPublicKeyParams = {
|
|
|
14
14
|
|
|
15
15
|
export declare function btcGetPublicKey(
|
|
16
16
|
connectId: string,
|
|
17
|
+
deviceId: string,
|
|
17
18
|
params: CommonParams & BTCGetPublicKeyParams
|
|
18
19
|
): Response<BTCPublicKey>;
|
|
19
20
|
|
|
20
21
|
export declare function btcGetPublicKey(
|
|
21
22
|
connectId: string,
|
|
23
|
+
deviceId: string,
|
|
22
24
|
params: CommonParams & { bundle?: BTCGetPublicKeyParams[] }
|
|
23
25
|
): Response<Array<BTCPublicKey>>;
|
|
@@ -17,10 +17,12 @@ export type CipheredKeyValueParams = {
|
|
|
17
17
|
|
|
18
18
|
export declare function cipherKeyValue(
|
|
19
19
|
connectId: string,
|
|
20
|
+
deviceId: string,
|
|
20
21
|
params: CommonParams & CipheredKeyValueParams
|
|
21
22
|
): Response<CipheredKeyValue>;
|
|
22
23
|
|
|
23
24
|
export declare function cipherKeyValue(
|
|
24
25
|
connectId: string,
|
|
26
|
+
deviceId: string,
|
|
25
27
|
params: CommonParams & { bundle?: CipheredKeyValueParams[] }
|
|
26
28
|
): Response<Array<CipheredKeyValue>>;
|
|
@@ -12,10 +12,12 @@ export type EVMGetAddressParams = {
|
|
|
12
12
|
|
|
13
13
|
export declare function evmGetAddress(
|
|
14
14
|
connectId: string,
|
|
15
|
+
deviceId: string,
|
|
15
16
|
params: CommonParams & EVMGetAddressParams
|
|
16
17
|
): Response<EVMAddress>;
|
|
17
18
|
|
|
18
19
|
export declare function evmGetAddress(
|
|
19
20
|
connectId: string,
|
|
21
|
+
deviceId: string,
|
|
20
22
|
params: CommonParams & { bundle?: EVMGetAddressParams[] }
|
|
21
23
|
): Response<Array<EVMAddress>>;
|
|
@@ -12,10 +12,12 @@ export type EVMGetPublicKeyParams = {
|
|
|
12
12
|
|
|
13
13
|
export declare function evmGetPublicKey(
|
|
14
14
|
connectId: string,
|
|
15
|
+
deviceId: string,
|
|
15
16
|
params: CommonParams & EVMGetPublicKeyParams
|
|
16
17
|
): Response<EVMPublicKey>;
|
|
17
18
|
|
|
18
19
|
export declare function evmGetPublicKey(
|
|
19
20
|
connectId: string,
|
|
21
|
+
deviceId: string,
|
|
20
22
|
params: CommonParams & { bundle?: EVMGetPublicKeyParams[] }
|
|
21
23
|
): Response<Array<EVMPublicKey>>;
|
package/src/types/api/index.ts
CHANGED
|
@@ -42,6 +42,7 @@ import { stellarGetAddress } from './stellarGetAddress';
|
|
|
42
42
|
import { stellarSignTransaction } from './stellarSignTransaction';
|
|
43
43
|
import { cipherKeyValue } from './cipherKeyValue';
|
|
44
44
|
import { firmwareUpdate } from './firmwareUpdate';
|
|
45
|
+
import { getLogs } from './getLogs';
|
|
45
46
|
|
|
46
47
|
export * from './export';
|
|
47
48
|
|
|
@@ -57,6 +58,7 @@ export type CoreApi = {
|
|
|
57
58
|
call: (params: any) => Promise<any>;
|
|
58
59
|
uiResponse: typeof uiResponse;
|
|
59
60
|
cancel: (connectId?: string) => void;
|
|
61
|
+
getLogs: typeof getLogs;
|
|
60
62
|
|
|
61
63
|
/**
|
|
62
64
|
* Core function
|
|
@@ -13,10 +13,12 @@ export type NEMGetAddressParams = {
|
|
|
13
13
|
|
|
14
14
|
export declare function nemGetAddress(
|
|
15
15
|
connectId: string,
|
|
16
|
+
deviceId: string,
|
|
16
17
|
params: CommonParams & NEMGetAddressParams
|
|
17
18
|
): Response<NEMAddress>;
|
|
18
19
|
|
|
19
20
|
export declare function nemGetAddress(
|
|
20
21
|
connectId: string,
|
|
22
|
+
deviceId: string,
|
|
21
23
|
params: CommonParams & { bundle?: NEMGetAddressParams[] }
|
|
22
24
|
): Response<Array<NEMAddress>>;
|