@onekeyfe/hd-core 0.1.17 → 0.1.20
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/CipherKeyValue.d.ts.map +1 -1
- package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
- package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
- package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
- package/dist/api/evm/EVMGetAddress.d.ts.map +1 -1
- package/dist/api/evm/EVMGetPublicKey.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessage.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTransaction.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/evm/EVMVerifyMessage.d.ts.map +1 -1
- package/dist/api/firmware/releaseHelper.d.ts +18 -0
- package/dist/api/firmware/releaseHelper.d.ts.map +1 -0
- package/dist/api/nem/NEMGetAddress.d.ts.map +1 -1
- package/dist/api/nem/NEMSignTransaction.d.ts.map +1 -1
- package/dist/api/solana/SolGetAddress.d.ts.map +1 -1
- package/dist/api/solana/SolSignTransaction.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinGetAddress.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinGetPublicKey.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinSignMessage.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinSignTransaction.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinVerifyMessage.d.ts.map +1 -1
- package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.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/device/Device.d.ts +5 -2
- 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 +2 -1
- package/dist/events/core.d.ts.map +1 -1
- package/dist/events/device.d.ts +8 -2
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/firmware.d.ts +28 -0
- package/dist/events/firmware.d.ts.map +1 -0
- package/dist/events/index.d.ts +1 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/index.d.ts +94 -40
- package/dist/index.js +296 -89
- 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/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/package.json +4 -4
- package/src/api/BaseMethod.ts +36 -1
- package/src/api/CheckBLEFirmwareRelease.ts +4 -9
- package/src/api/CheckFirmwareRelease.ts +3 -9
- package/src/api/CipherKeyValue.ts +1 -0
- package/src/api/btc/BTCGetAddress.ts +1 -0
- package/src/api/btc/BTCGetPublicKey.ts +1 -0
- package/src/api/btc/BTCSignMessage.ts +1 -0
- package/src/api/btc/BTCSignTransaction.ts +1 -0
- package/src/api/btc/BTCVerifyMessage.ts +1 -0
- package/src/api/evm/EVMGetAddress.ts +1 -0
- package/src/api/evm/EVMGetPublicKey.ts +1 -0
- package/src/api/evm/EVMSignMessage.ts +1 -0
- package/src/api/evm/EVMSignMessageEIP712.ts +1 -0
- package/src/api/evm/EVMSignTransaction.ts +1 -0
- package/src/api/evm/EVMSignTypedData.ts +1 -0
- package/src/api/evm/EVMVerifyMessage.ts +1 -0
- package/src/api/firmware/releaseHelper.ts +24 -0
- package/src/api/nem/NEMGetAddress.ts +1 -0
- package/src/api/nem/NEMSignTransaction.ts +1 -0
- package/src/api/solana/SolGetAddress.ts +1 -0
- package/src/api/solana/SolSignTransaction.ts +1 -0
- package/src/api/starcoin/StarcoinGetAddress.ts +1 -0
- package/src/api/starcoin/StarcoinGetPublicKey.ts +1 -0
- package/src/api/starcoin/StarcoinSignMessage.ts +1 -0
- package/src/api/starcoin/StarcoinSignTransaction.ts +1 -0
- package/src/api/starcoin/StarcoinVerifyMessage.ts +1 -0
- package/src/api/stellar/StellarGetAddress.ts +1 -0
- package/src/api/stellar/StellarSignTransaction.ts +2 -4
- package/src/constants/errors.ts +5 -1
- package/src/core/index.ts +160 -29
- package/src/device/Device.ts +34 -7
- package/src/device/DeviceCommands.ts +7 -4
- package/src/device/DeviceList.ts +22 -7
- package/src/events/core.ts +2 -0
- package/src/events/device.ts +11 -2
- package/src/events/firmware.ts +38 -0
- package/src/events/index.ts +1 -0
- package/src/inject.ts +53 -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/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/device/Device.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import EventEmitter from 'events';
|
|
2
2
|
import { OneKeyDeviceInfo as DeviceDescriptor } from '@onekeyfe/hd-transport';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
createDeferred,
|
|
5
|
+
Deferred,
|
|
6
|
+
HardwareErrorCode,
|
|
7
|
+
ERRORS,
|
|
8
|
+
HardwareError,
|
|
9
|
+
} from '@onekeyfe/hd-shared';
|
|
4
10
|
|
|
5
11
|
import DeviceConnector from './DeviceConnector';
|
|
6
12
|
import { DeviceCommands } from './DeviceCommands';
|
|
@@ -14,7 +20,7 @@ import {
|
|
|
14
20
|
getDeviceTypeOnBootloader,
|
|
15
21
|
} from '../utils/deviceFeaturesUtils';
|
|
16
22
|
import type { Features, Device as DeviceTyped, UnavailableCapabilities } from '../types';
|
|
17
|
-
import { DEVICE, DeviceButtonRequestPayload } from '../events';
|
|
23
|
+
import { DEVICE, DeviceButtonRequestPayload, DeviceFeaturesPayload } from '../events';
|
|
18
24
|
import { UI_REQUEST } from '../constants/ui-request';
|
|
19
25
|
import { PROTO } from '../constants';
|
|
20
26
|
import { getLogger, LoggerNames } from '../utils';
|
|
@@ -35,6 +41,7 @@ export interface DeviceEvents {
|
|
|
35
41
|
[DEVICE.PIN]: [Device, PROTO.PinMatrixRequestType | undefined, (err: any, pin: string) => void];
|
|
36
42
|
[DEVICE.PASSPHRASE_ON_DEVICE]: [Device, ((response: any) => void)?];
|
|
37
43
|
[DEVICE.BUTTON]: [Device, DeviceButtonRequestPayload];
|
|
44
|
+
[DEVICE.FEATURES]: [Device, DeviceFeaturesPayload];
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
export interface Device {
|
|
@@ -186,7 +193,7 @@ export class Device extends EventEmitter {
|
|
|
186
193
|
}
|
|
187
194
|
this.updateDescriptor({ [mainIdKey]: this.mainId } as unknown as DeviceDescriptor);
|
|
188
195
|
if (this.commands) {
|
|
189
|
-
this.commands.dispose();
|
|
196
|
+
await this.commands.dispose(false);
|
|
190
197
|
}
|
|
191
198
|
|
|
192
199
|
this.commands = new DeviceCommands(this, this.mainId ?? '');
|
|
@@ -207,7 +214,7 @@ export class Device extends EventEmitter {
|
|
|
207
214
|
(this.mainId && env === 'react-native')
|
|
208
215
|
) {
|
|
209
216
|
if (this.commands) {
|
|
210
|
-
this.commands.dispose();
|
|
217
|
+
this.commands.dispose(false);
|
|
211
218
|
if (this.commands.callPromise) {
|
|
212
219
|
try {
|
|
213
220
|
await this.commands.callPromise;
|
|
@@ -263,6 +270,7 @@ export class Device extends EventEmitter {
|
|
|
263
270
|
|
|
264
271
|
this.features = feat;
|
|
265
272
|
this.featuresNeedsReload = false;
|
|
273
|
+
this.emit(DEVICE.FEATURES, this, feat);
|
|
266
274
|
}
|
|
267
275
|
|
|
268
276
|
/**
|
|
@@ -298,7 +306,7 @@ export class Device extends EventEmitter {
|
|
|
298
306
|
|
|
299
307
|
async run(fn?: () => Promise<void>, options?: RunOptions) {
|
|
300
308
|
if (this.runPromise) {
|
|
301
|
-
this.
|
|
309
|
+
await this.interruptionFromOutside();
|
|
302
310
|
Log.debug('[Device] run error:', 'Device is running, but will cancel previous operate');
|
|
303
311
|
}
|
|
304
312
|
|
|
@@ -317,6 +325,9 @@ export class Device extends EventEmitter {
|
|
|
317
325
|
}
|
|
318
326
|
} catch (error) {
|
|
319
327
|
this.runPromise = null;
|
|
328
|
+
if (error instanceof HardwareError) {
|
|
329
|
+
return Promise.reject(error);
|
|
330
|
+
}
|
|
320
331
|
return Promise.reject(
|
|
321
332
|
ERRORS.TypedError(
|
|
322
333
|
HardwareErrorCode.DeviceInitializeFailed,
|
|
@@ -350,15 +361,24 @@ export class Device extends EventEmitter {
|
|
|
350
361
|
this.runPromise = null;
|
|
351
362
|
}
|
|
352
363
|
|
|
353
|
-
|
|
364
|
+
async interruptionFromOutside() {
|
|
354
365
|
if (this.commands) {
|
|
355
|
-
this.commands.dispose();
|
|
366
|
+
await this.commands.dispose(false);
|
|
356
367
|
}
|
|
357
368
|
if (this.runPromise) {
|
|
358
369
|
this.runPromise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceInterruptedFromOutside));
|
|
359
370
|
}
|
|
360
371
|
}
|
|
361
372
|
|
|
373
|
+
async interruptionFromUser() {
|
|
374
|
+
if (this.commands) {
|
|
375
|
+
await this.commands.dispose(true);
|
|
376
|
+
}
|
|
377
|
+
if (this.runPromise) {
|
|
378
|
+
this.runPromise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceInterruptedFromUser));
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
362
382
|
getMode() {
|
|
363
383
|
if (this.features?.bootloader_mode) return 'bootloader';
|
|
364
384
|
if (!this.features?.initialized) return 'initialize';
|
|
@@ -429,6 +449,13 @@ export class Device extends EventEmitter {
|
|
|
429
449
|
}
|
|
430
450
|
return null;
|
|
431
451
|
}
|
|
452
|
+
|
|
453
|
+
checkDeviceId(deviceId: string) {
|
|
454
|
+
if (this.features) {
|
|
455
|
+
return this.features.device_id === deviceId;
|
|
456
|
+
}
|
|
457
|
+
return false;
|
|
458
|
+
}
|
|
432
459
|
}
|
|
433
460
|
|
|
434
461
|
export default 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.
|
|
@@ -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
|
package/src/device/DeviceList.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { Device } from './Device';
|
|
|
4
4
|
import { getDeviceUUID } from '../utils/deviceFeaturesUtils';
|
|
5
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
10
|
const Log = getLogger(LoggerNames.DeviceList);
|
|
10
11
|
|
|
@@ -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
|
@@ -6,6 +6,7 @@ import { IFrameEventMessage } from './iframe';
|
|
|
6
6
|
import { UiEventMessage } from './ui-request';
|
|
7
7
|
import { UiResponseMessage } from './ui-response';
|
|
8
8
|
import { LogEventMessage } from './log';
|
|
9
|
+
import { FirmwareMessage } from './firmware';
|
|
9
10
|
|
|
10
11
|
export const CORE_EVENT = 'CORE_EVENT';
|
|
11
12
|
|
|
@@ -20,6 +21,7 @@ export type CoreMessage = {
|
|
|
20
21
|
| UiEventMessage
|
|
21
22
|
| DeviceEventMessage
|
|
22
23
|
| LogEventMessage
|
|
24
|
+
| FirmwareMessage
|
|
23
25
|
);
|
|
24
26
|
|
|
25
27
|
export type PostMessageEvent = MessageEvent<any>;
|
package/src/events/device.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PROTO } from '../constants';
|
|
2
|
-
import type { KnownDevice as Device } from '../types/device';
|
|
2
|
+
import type { Features, KnownDevice as Device } from '../types/device';
|
|
3
3
|
import { MessageFactoryFn } from './utils';
|
|
4
4
|
|
|
5
5
|
export const DEVICE_EVENT = 'DEVICE_EVENT';
|
|
@@ -24,6 +24,8 @@ export const DEVICE = {
|
|
|
24
24
|
PASSPHRASE: 'passphrase',
|
|
25
25
|
PASSPHRASE_ON_DEVICE: 'passphrase_on_device',
|
|
26
26
|
WORD: 'word',
|
|
27
|
+
|
|
28
|
+
FEATURES: 'features',
|
|
27
29
|
} as const;
|
|
28
30
|
|
|
29
31
|
export interface DeviceButtonRequestPayload extends Omit<PROTO.ButtonRequest, 'code'> {
|
|
@@ -35,7 +37,14 @@ export interface DeviceButtonRequest {
|
|
|
35
37
|
payload: DeviceButtonRequestPayload & { device: Device | null };
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
export type
|
|
40
|
+
export type DeviceFeaturesPayload = Features;
|
|
41
|
+
|
|
42
|
+
export interface DeviceSendFeatures {
|
|
43
|
+
type: typeof DEVICE.FEATURES;
|
|
44
|
+
payload: DeviceFeaturesPayload;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type DeviceEvent = DeviceButtonRequest | DeviceSendFeatures;
|
|
39
48
|
|
|
40
49
|
export type DeviceEventMessage = DeviceEvent & { event: typeof DEVICE_EVENT };
|
|
41
50
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { MessageFactoryFn } from './utils';
|
|
2
|
+
import { getBleFirmwareReleaseInfo, getFirmwareReleaseInfo } from '../api/firmware/releaseHelper';
|
|
3
|
+
import { Features } from '../types';
|
|
4
|
+
|
|
5
|
+
export const FIRMWARE_EVENT = 'FIRMWARE_EVENT';
|
|
6
|
+
export const FIRMWARE = {
|
|
7
|
+
RELEASE_INFO: 'firmware-release-info',
|
|
8
|
+
BLE_RELEASE_INFO: 'ble-firmware-release-info',
|
|
9
|
+
} as const;
|
|
10
|
+
|
|
11
|
+
export type ReleaseInfoPayload = ReturnType<typeof getFirmwareReleaseInfo> & { features: Features };
|
|
12
|
+
export interface ReleaseInfoEvent {
|
|
13
|
+
type: typeof FIRMWARE.RELEASE_INFO;
|
|
14
|
+
payload: ReleaseInfoPayload;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type BleReleaseInfoPayload = ReturnType<typeof getBleFirmwareReleaseInfo> & {
|
|
18
|
+
features: Features;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export interface BleReleaseInfoEvent {
|
|
22
|
+
type: typeof FIRMWARE.BLE_RELEASE_INFO;
|
|
23
|
+
payload: BleReleaseInfoPayload;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type FirmwareEvent = ReleaseInfoEvent | BleReleaseInfoEvent;
|
|
27
|
+
|
|
28
|
+
export type FirmwareMessage = FirmwareEvent & { event: typeof FIRMWARE_EVENT };
|
|
29
|
+
|
|
30
|
+
export const createFirmwareMessage: MessageFactoryFn<typeof FIRMWARE_EVENT, FirmwareEvent> = (
|
|
31
|
+
type,
|
|
32
|
+
payload
|
|
33
|
+
) =>
|
|
34
|
+
({
|
|
35
|
+
event: FIRMWARE_EVENT,
|
|
36
|
+
type,
|
|
37
|
+
payload,
|
|
38
|
+
} as any);
|
package/src/events/index.ts
CHANGED
package/src/inject.ts
CHANGED
|
@@ -73,7 +73,8 @@ export const inject = ({
|
|
|
73
73
|
*/
|
|
74
74
|
checkBridgeStatus: () => call({ method: 'checkBridgeStatus' }),
|
|
75
75
|
|
|
76
|
-
cipherKeyValue: (connectId, params) =>
|
|
76
|
+
cipherKeyValue: (connectId, deviceId, params) =>
|
|
77
|
+
call({ ...params, connectId, deviceId, method: 'cipherKeyValue' }),
|
|
77
78
|
|
|
78
79
|
deviceBackup: connectId => call({ connectId, method: 'deviceBackup' }),
|
|
79
80
|
deviceChangePin: (connectId, params) =>
|
|
@@ -87,51 +88,57 @@ export const inject = ({
|
|
|
87
88
|
deviceVerify: (connectId, params) => call({ ...params, connectId, method: 'deviceVerify' }),
|
|
88
89
|
deviceWipe: connectId => call({ connectId, method: 'deviceWipe' }),
|
|
89
90
|
|
|
90
|
-
evmGetAddress: (connectId, params) =>
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
call({ ...params, connectId, method: '
|
|
96
|
-
|
|
97
|
-
call({ ...params, connectId, method: '
|
|
98
|
-
|
|
99
|
-
call({ ...params, connectId, method: '
|
|
100
|
-
|
|
101
|
-
call({ ...params, connectId, method: '
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
call({ ...params, connectId, method: '
|
|
109
|
-
|
|
110
|
-
call({ ...params, connectId, method: '
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
call({ ...params, connectId, method: '
|
|
118
|
-
|
|
119
|
-
call({ ...params, connectId, method: '
|
|
120
|
-
|
|
121
|
-
call({ ...params, connectId, method: '
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
call({ ...params, connectId, method: '
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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' }),
|
|
135
142
|
|
|
136
143
|
firmwareUpdate: (connectId, params) => call({ ...params, connectId, method: 'firmwareUpdate' }),
|
|
137
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>>;
|
|
@@ -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>>;
|
|
@@ -12,10 +12,12 @@ export type SolanaGetAddressParams = {
|
|
|
12
12
|
|
|
13
13
|
export declare function solGetAddress(
|
|
14
14
|
connectId: string,
|
|
15
|
+
deviceId: string,
|
|
15
16
|
params: CommonParams & SolanaGetAddressParams
|
|
16
17
|
): Response<SolanaAddress>;
|
|
17
18
|
|
|
18
19
|
export declare function solGetAddress(
|
|
19
20
|
connectId: string,
|
|
21
|
+
deviceId: string,
|
|
20
22
|
params: CommonParams & { bundle?: SolanaGetAddressParams[] }
|
|
21
23
|
): Response<Array<SolanaAddress>>;
|
|
@@ -12,10 +12,12 @@ export type SolanaSignTransactionParams = {
|
|
|
12
12
|
|
|
13
13
|
export declare function solSignTransaction(
|
|
14
14
|
connectId: string,
|
|
15
|
+
deviceId: string,
|
|
15
16
|
params: CommonParams & SolanaSignTransactionParams
|
|
16
17
|
): Response<SolanaSignedTx>;
|
|
17
18
|
|
|
18
19
|
export declare function solSignTransaction(
|
|
19
20
|
connectId: string,
|
|
21
|
+
deviceId: string,
|
|
20
22
|
params: CommonParams & { bundle?: SolanaSignTransactionParams[] }
|
|
21
23
|
): Response<Array<SolanaSignedTx>>;
|
|
@@ -12,10 +12,12 @@ export type StarcoinGetAddressParams = {
|
|
|
12
12
|
|
|
13
13
|
export declare function starcoinGetAddress(
|
|
14
14
|
connectId: string,
|
|
15
|
+
deviceId: string,
|
|
15
16
|
params: CommonParams & StarcoinGetAddressParams
|
|
16
17
|
): Response<StarcoinAddress>;
|
|
17
18
|
|
|
18
19
|
export declare function starcoinGetAddress(
|
|
19
20
|
connectId: string,
|
|
21
|
+
deviceId: string,
|
|
20
22
|
params: CommonParams & { bundle?: StarcoinGetAddressParams[] }
|
|
21
23
|
): Response<Array<StarcoinAddress>>;
|
|
@@ -12,10 +12,12 @@ export type StarcoinGetPublicKeyParams = {
|
|
|
12
12
|
|
|
13
13
|
export declare function starcoinGetPublicKey(
|
|
14
14
|
connectId: string,
|
|
15
|
+
deviceId: string,
|
|
15
16
|
params: CommonParams & StarcoinGetPublicKeyParams
|
|
16
17
|
): Response<StarcoinPublicKey>;
|
|
17
18
|
|
|
18
19
|
export declare function starcoinGetPublicKey(
|
|
19
20
|
connectId: string,
|
|
21
|
+
deviceId: string,
|
|
20
22
|
params: CommonParams & { bundle?: StarcoinGetPublicKeyParams[] }
|
|
21
23
|
): Response<Array<StarcoinPublicKey>>;
|