@onekeyfe/hd-core 0.1.39 → 0.1.42
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 +1 -0
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/index.js +255 -281
- package/package.json +4 -5
- package/src/api/BaseMethod.ts +23 -1
- package/src/api/device/DeviceSettings.ts +1 -1
- package/src/core/index.ts +20 -1
- package/src/data-manager/connectSettings.ts +1 -1
- package/src/device/Device.ts +10 -4
package/dist/index.js
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var BigNumber = require('bignumber.js');
|
|
9
|
-
var sha256 = require('js-sha256');
|
|
10
|
-
var hdTransport = require('@onekeyfe/hd-transport');
|
|
11
|
-
|
|
12
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
-
|
|
14
|
-
var semver__default = /*#__PURE__*/_interopDefaultLegacy(semver);
|
|
15
|
-
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
16
|
-
var BigNumber__default = /*#__PURE__*/_interopDefaultLegacy(BigNumber);
|
|
17
|
-
var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
|
|
1
|
+
import semver from 'semver';
|
|
2
|
+
import { ERRORS, HardwareErrorCode, HardwareError, serializeError, createDeferred } from '@onekeyfe/hd-shared';
|
|
3
|
+
import axios from 'axios';
|
|
4
|
+
import BigNumber from 'bignumber.js';
|
|
5
|
+
import sha256 from 'js-sha256';
|
|
6
|
+
import { EthereumDataType } from '@onekeyfe/hd-transport';
|
|
7
|
+
export { Messages as PROTO } from '@onekeyfe/hd-transport';
|
|
18
8
|
|
|
19
9
|
const inject = ({ call, cancel, dispose, eventEmitter, init, uiResponse, }) => {
|
|
20
10
|
const api = {
|
|
@@ -617,8 +607,8 @@ function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
|
|
|
617
607
|
const HD_HARDENED = 0x80000000;
|
|
618
608
|
const toHardened = (n) => (n | HD_HARDENED) >>> 0;
|
|
619
609
|
const fromHardened = (n) => (n & ~HD_HARDENED) >>> 0;
|
|
620
|
-
const PATH_NOT_VALID =
|
|
621
|
-
const PATH_NEGATIVE_VALUES =
|
|
610
|
+
const PATH_NOT_VALID = ERRORS.TypedError(HardwareErrorCode.CallMethodInvalidParameter, 'Not a valid path');
|
|
611
|
+
const PATH_NEGATIVE_VALUES = ERRORS.TypedError(HardwareErrorCode.CallMethodInvalidParameter, 'Path cannot contain negative values');
|
|
622
612
|
const getHDPath = (path) => {
|
|
623
613
|
const parts = path.toLowerCase().split('/');
|
|
624
614
|
if (parts[0] !== 'm')
|
|
@@ -783,7 +773,7 @@ const getDeviceBLEFirmwareVersion = (features) => {
|
|
|
783
773
|
if (!features.ble_ver) {
|
|
784
774
|
return null;
|
|
785
775
|
}
|
|
786
|
-
if (!
|
|
776
|
+
if (!semver.valid(features.ble_ver)) {
|
|
787
777
|
return null;
|
|
788
778
|
}
|
|
789
779
|
return features.ble_ver.split('.');
|
|
@@ -796,7 +786,7 @@ const supportInputPinOnSoftware = (features) => {
|
|
|
796
786
|
return { support: false };
|
|
797
787
|
}
|
|
798
788
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
799
|
-
return { support:
|
|
789
|
+
return { support: semver.gte(currentVersion, '2.3.0'), require: '2.3.0' };
|
|
800
790
|
};
|
|
801
791
|
const supportNewPassphrase = (features) => {
|
|
802
792
|
if (!features)
|
|
@@ -806,7 +796,7 @@ const supportNewPassphrase = (features) => {
|
|
|
806
796
|
return { support: true };
|
|
807
797
|
}
|
|
808
798
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
809
|
-
return { support:
|
|
799
|
+
return { support: semver.gte(currentVersion, '2.4.0'), require: '2.4.0' };
|
|
810
800
|
};
|
|
811
801
|
const getPassphraseState = (features, commands) => __awaiter(void 0, void 0, void 0, function* () {
|
|
812
802
|
if (!features)
|
|
@@ -9574,7 +9564,7 @@ var MessagesJSON = {
|
|
|
9574
9564
|
};
|
|
9575
9565
|
|
|
9576
9566
|
const httpRequest$1 = (url, type = 'text') => __awaiter(void 0, void 0, void 0, function* () {
|
|
9577
|
-
const response = yield
|
|
9567
|
+
const response = yield axios.request({
|
|
9578
9568
|
url,
|
|
9579
9569
|
withCredentials: false,
|
|
9580
9570
|
responseType: type === 'binary' ? 'arraybuffer' : 'json',
|
|
@@ -9680,7 +9670,7 @@ const createLogMessage = (type, payload) => ({
|
|
|
9680
9670
|
|
|
9681
9671
|
const MAX_ENTRIES = 500;
|
|
9682
9672
|
let postMessage$1;
|
|
9683
|
-
class Log$
|
|
9673
|
+
class Log$8 {
|
|
9684
9674
|
constructor(prefix, enabled) {
|
|
9685
9675
|
this.prefix = prefix;
|
|
9686
9676
|
this.enabled = enabled;
|
|
@@ -9732,7 +9722,7 @@ class Log$7 {
|
|
|
9732
9722
|
}
|
|
9733
9723
|
const _logs = {};
|
|
9734
9724
|
const initLog = (prefix, enabled) => {
|
|
9735
|
-
const instance = new Log$
|
|
9725
|
+
const instance = new Log$8(prefix, !!enabled);
|
|
9736
9726
|
_logs[prefix] = instance;
|
|
9737
9727
|
return instance;
|
|
9738
9728
|
};
|
|
@@ -9785,7 +9775,7 @@ const getCircularReplacer = () => {
|
|
|
9785
9775
|
const sendLogMessage = (prefix, ...args) => {
|
|
9786
9776
|
postMessage$1 === null || postMessage$1 === void 0 ? void 0 : postMessage$1(createLogMessage(LOG.OUTPUT, serializeLog(prefix, ...args)));
|
|
9787
9777
|
};
|
|
9788
|
-
|
|
9778
|
+
var LoggerNames;
|
|
9789
9779
|
(function (LoggerNames) {
|
|
9790
9780
|
LoggerNames["Core"] = "Core";
|
|
9791
9781
|
LoggerNames["Transport"] = "Transport";
|
|
@@ -9802,28 +9792,28 @@ exports.LoggerNames = void 0;
|
|
|
9802
9792
|
LoggerNames["Iframe"] = "IFrame";
|
|
9803
9793
|
LoggerNames["SendMessage"] = "[SendMessage]";
|
|
9804
9794
|
LoggerNames["Method"] = "[Method]";
|
|
9805
|
-
})(
|
|
9795
|
+
})(LoggerNames || (LoggerNames = {}));
|
|
9806
9796
|
const LoggerMap = {
|
|
9807
|
-
[
|
|
9808
|
-
[
|
|
9809
|
-
[
|
|
9810
|
-
[
|
|
9811
|
-
[
|
|
9812
|
-
[
|
|
9813
|
-
[
|
|
9814
|
-
[
|
|
9815
|
-
[
|
|
9816
|
-
[
|
|
9817
|
-
[
|
|
9818
|
-
[
|
|
9819
|
-
[
|
|
9820
|
-
[
|
|
9821
|
-
[
|
|
9797
|
+
[LoggerNames.Core]: initLog(LoggerNames.Core),
|
|
9798
|
+
[LoggerNames.Transport]: initLog(LoggerNames.Transport),
|
|
9799
|
+
[LoggerNames.Device]: initLog(LoggerNames.Device),
|
|
9800
|
+
[LoggerNames.DeviceCommands]: initLog(LoggerNames.DeviceCommands),
|
|
9801
|
+
[LoggerNames.DeviceConnector]: initLog(LoggerNames.DeviceConnector),
|
|
9802
|
+
[LoggerNames.DeviceList]: initLog(LoggerNames.DeviceList),
|
|
9803
|
+
[LoggerNames.DevicePool]: initLog(LoggerNames.DevicePool),
|
|
9804
|
+
[LoggerNames.HdBleSdk]: initLog(LoggerNames.HdBleSdk),
|
|
9805
|
+
[LoggerNames.HdTransportHttp]: initLog(LoggerNames.HdTransportHttp),
|
|
9806
|
+
[LoggerNames.HdBleTransport]: initLog(LoggerNames.HdBleTransport),
|
|
9807
|
+
[LoggerNames.Connect]: initLog(LoggerNames.Connect),
|
|
9808
|
+
[LoggerNames.Iframe]: initLog(LoggerNames.Iframe),
|
|
9809
|
+
[LoggerNames.SendMessage]: initLog(LoggerNames.SendMessage),
|
|
9810
|
+
[LoggerNames.Method]: initLog(LoggerNames.Method),
|
|
9811
|
+
[LoggerNames.HdCommonConnectSdk]: initLog(LoggerNames.Method),
|
|
9822
9812
|
};
|
|
9823
9813
|
const getLogger = (key) => LoggerMap[key];
|
|
9824
9814
|
|
|
9825
9815
|
const getReleaseStatus = (releases, currentVersion) => {
|
|
9826
|
-
const newVersions = releases.filter(r =>
|
|
9816
|
+
const newVersions = releases.filter(r => semver.gt(r.version.join('.'), currentVersion));
|
|
9827
9817
|
if (newVersions.length === 0) {
|
|
9828
9818
|
return 'valid';
|
|
9829
9819
|
}
|
|
@@ -9833,7 +9823,7 @@ const getReleaseStatus = (releases, currentVersion) => {
|
|
|
9833
9823
|
return 'outdated';
|
|
9834
9824
|
};
|
|
9835
9825
|
const getReleaseChangelog = (releases, currentVersion) => {
|
|
9836
|
-
const newVersions = releases.filter(r =>
|
|
9826
|
+
const newVersions = releases.filter(r => semver.gt(r.version.join('.'), currentVersion));
|
|
9837
9827
|
return newVersions.map(r => r.changelog);
|
|
9838
9828
|
};
|
|
9839
9829
|
|
|
@@ -9843,7 +9833,7 @@ class DataManager {
|
|
|
9843
9833
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9844
9834
|
this.settings = settings;
|
|
9845
9835
|
try {
|
|
9846
|
-
const { data } = yield
|
|
9836
|
+
const { data } = yield axios.get(`https://data.onekey.so/config.json?noCache=${getTimeStamp()}`);
|
|
9847
9837
|
this.deviceMap = {
|
|
9848
9838
|
classic: data.classic,
|
|
9849
9839
|
mini: data.mini,
|
|
@@ -9958,7 +9948,7 @@ DataManager.getTransportStatus = (localVersion) => {
|
|
|
9958
9948
|
const latestTransportVersion = (_c = (_b = _a.assets) === null || _b === void 0 ? void 0 : _b.bridge) === null || _c === void 0 ? void 0 : _c.version;
|
|
9959
9949
|
if (!latestTransportVersion)
|
|
9960
9950
|
return 'valid';
|
|
9961
|
-
const isLatest =
|
|
9951
|
+
const isLatest = semver.gte(localVersion, latestTransportVersion.join('.'));
|
|
9962
9952
|
return isLatest ? 'valid' : 'outdated';
|
|
9963
9953
|
};
|
|
9964
9954
|
|
|
@@ -9980,7 +9970,7 @@ const parseMessage = (messageData) => {
|
|
|
9980
9970
|
};
|
|
9981
9971
|
const createErrorMessage = (error) => {
|
|
9982
9972
|
let payload = { error: error.message, code: error.code };
|
|
9983
|
-
if (error instanceof
|
|
9973
|
+
if (error instanceof HardwareError) {
|
|
9984
9974
|
payload = { error: error.message, code: error.errorCode };
|
|
9985
9975
|
}
|
|
9986
9976
|
return {
|
|
@@ -10025,7 +10015,7 @@ const createResponseMessage = (id, success, payload) => ({
|
|
|
10025
10015
|
type: RESPONSE_EVENT,
|
|
10026
10016
|
id,
|
|
10027
10017
|
success,
|
|
10028
|
-
payload: success ? payload :
|
|
10018
|
+
payload: success ? payload : serializeError(payload),
|
|
10029
10019
|
});
|
|
10030
10020
|
|
|
10031
10021
|
const UI_RESPONSE = {
|
|
@@ -10075,7 +10065,7 @@ const createFirmwareMessage = (type, payload) => ({
|
|
|
10075
10065
|
payload,
|
|
10076
10066
|
});
|
|
10077
10067
|
|
|
10078
|
-
const Log$
|
|
10068
|
+
const Log$7 = getLogger(LoggerNames.DevicePool);
|
|
10079
10069
|
const getDiff = (current, descriptors) => {
|
|
10080
10070
|
const connected = descriptors.filter(d => current.find(x => x.path === d.path) === undefined);
|
|
10081
10071
|
const disconnected = current.filter(d => descriptors.find(x => x.path === d.path) === undefined);
|
|
@@ -10120,7 +10110,7 @@ class DevicePool extends events.exports {
|
|
|
10120
10110
|
var descriptorList_1, descriptorList_1_1;
|
|
10121
10111
|
var e_1, _a;
|
|
10122
10112
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10123
|
-
Log$
|
|
10113
|
+
Log$7.debug('get device list: connectId: ', connectId);
|
|
10124
10114
|
const devices = {};
|
|
10125
10115
|
const deviceList = [];
|
|
10126
10116
|
if (connectId) {
|
|
@@ -10128,14 +10118,14 @@ class DevicePool extends events.exports {
|
|
|
10128
10118
|
if (device) {
|
|
10129
10119
|
const exist = descriptorList.find(d => d.path === device.originalDescriptor.path);
|
|
10130
10120
|
if (exist) {
|
|
10131
|
-
Log$
|
|
10121
|
+
Log$7.debug('find existed Device: ', connectId);
|
|
10132
10122
|
device.updateDescriptor(exist, true);
|
|
10133
10123
|
devices[connectId] = device;
|
|
10134
10124
|
deviceList.push(device);
|
|
10135
10125
|
yield this._checkDevicePool(initOptions);
|
|
10136
10126
|
return { devices, deviceList };
|
|
10137
10127
|
}
|
|
10138
|
-
Log$
|
|
10128
|
+
Log$7.debug('found device in cache, but path is different: ', connectId);
|
|
10139
10129
|
}
|
|
10140
10130
|
}
|
|
10141
10131
|
try {
|
|
@@ -10161,7 +10151,7 @@ class DevicePool extends events.exports {
|
|
|
10161
10151
|
}
|
|
10162
10152
|
finally { if (e_1) throw e_1.error; }
|
|
10163
10153
|
}
|
|
10164
|
-
Log$
|
|
10154
|
+
Log$7.debug('get devices result : ', devices, deviceList);
|
|
10165
10155
|
console.log('device poll -> connected: ', this.connectedPool);
|
|
10166
10156
|
console.log('device poll -> disconnected: ', this.disconnectPool);
|
|
10167
10157
|
yield this._checkDevicePool(initOptions);
|
|
@@ -10169,8 +10159,8 @@ class DevicePool extends events.exports {
|
|
|
10169
10159
|
});
|
|
10170
10160
|
}
|
|
10171
10161
|
static clearDeviceCache(connectId) {
|
|
10172
|
-
Log$
|
|
10173
|
-
Log$
|
|
10162
|
+
Log$7.debug('clear device pool cache: connectId', connectId);
|
|
10163
|
+
Log$7.debug('clear device pool cache: ', this.devicesCache);
|
|
10174
10164
|
if (connectId) {
|
|
10175
10165
|
delete this.devicesCache[connectId];
|
|
10176
10166
|
}
|
|
@@ -10199,7 +10189,7 @@ class DevicePool extends events.exports {
|
|
|
10199
10189
|
for (let i = this.connectedPool.length - 1; i >= 0; i--) {
|
|
10200
10190
|
const descriptor = this.connectedPool[i];
|
|
10201
10191
|
const device = yield this._createDevice(descriptor, initOptions);
|
|
10202
|
-
Log$
|
|
10192
|
+
Log$7.debug('emit DEVICE.CONNECT: ', device);
|
|
10203
10193
|
this.emitter.emit(DEVICE.CONNECT, device);
|
|
10204
10194
|
this.connectedPool.splice(i, 1);
|
|
10205
10195
|
}
|
|
@@ -10231,7 +10221,7 @@ class DevicePool extends events.exports {
|
|
|
10231
10221
|
this._addConnectedDeviceToPool(d);
|
|
10232
10222
|
return;
|
|
10233
10223
|
}
|
|
10234
|
-
Log$
|
|
10224
|
+
Log$7.debug('emit DEVICE.CONNECT: ', device);
|
|
10235
10225
|
this.emitter.emit(DEVICE.CONNECT, device);
|
|
10236
10226
|
});
|
|
10237
10227
|
diff.disconnected.forEach(d => {
|
|
@@ -10241,7 +10231,7 @@ class DevicePool extends events.exports {
|
|
|
10241
10231
|
this._addDisconnectedDeviceToPool(d);
|
|
10242
10232
|
return;
|
|
10243
10233
|
}
|
|
10244
|
-
Log$
|
|
10234
|
+
Log$7.debug('emit DEVICE.DISCONNECT: ', device);
|
|
10245
10235
|
this.emitter.emit(DEVICE.DISCONNECT, device);
|
|
10246
10236
|
});
|
|
10247
10237
|
}
|
|
@@ -10278,12 +10268,12 @@ DevicePool.disconnectPool = [];
|
|
|
10278
10268
|
DevicePool.devicesCache = {};
|
|
10279
10269
|
DevicePool.emitter = new events.exports();
|
|
10280
10270
|
|
|
10281
|
-
const Log$
|
|
10282
|
-
const BleLogger = getLogger(
|
|
10283
|
-
const HttpLogger = getLogger(
|
|
10271
|
+
const Log$6 = getLogger(LoggerNames.Transport);
|
|
10272
|
+
const BleLogger = getLogger(LoggerNames.HdBleTransport);
|
|
10273
|
+
const HttpLogger = getLogger(LoggerNames.HdTransportHttp);
|
|
10284
10274
|
class TransportManager {
|
|
10285
10275
|
static load() {
|
|
10286
|
-
Log$
|
|
10276
|
+
Log$6.debug('transport manager load');
|
|
10287
10277
|
this.defaultMessages = DataManager.getProtobufMessages();
|
|
10288
10278
|
this.currentMessages = this.defaultMessages;
|
|
10289
10279
|
}
|
|
@@ -10291,27 +10281,27 @@ class TransportManager {
|
|
|
10291
10281
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10292
10282
|
try {
|
|
10293
10283
|
const env = DataManager.getSettings('env');
|
|
10294
|
-
Log$
|
|
10284
|
+
Log$6.debug('Initializing transports');
|
|
10295
10285
|
if (env === 'react-native') {
|
|
10296
10286
|
if (!this.reactNativeInit) {
|
|
10297
10287
|
yield this.transport.init(BleLogger, DevicePool.emitter);
|
|
10298
10288
|
this.reactNativeInit = true;
|
|
10299
10289
|
}
|
|
10300
10290
|
else {
|
|
10301
|
-
Log$
|
|
10291
|
+
Log$6.debug('React Native Do Not Initializing transports');
|
|
10302
10292
|
}
|
|
10303
10293
|
}
|
|
10304
10294
|
else {
|
|
10305
10295
|
yield this.transport.init(HttpLogger);
|
|
10306
10296
|
}
|
|
10307
|
-
Log$
|
|
10297
|
+
Log$6.debug('Configuring transports');
|
|
10308
10298
|
yield this.transport.configure(JSON.stringify(this.defaultMessages));
|
|
10309
|
-
Log$
|
|
10299
|
+
Log$6.debug('Configuring transports done');
|
|
10310
10300
|
}
|
|
10311
10301
|
catch (error) {
|
|
10312
|
-
Log$
|
|
10302
|
+
Log$6.debug('Initializing transports error: ', error);
|
|
10313
10303
|
if (error.code === 'ECONNABORTED') {
|
|
10314
|
-
throw
|
|
10304
|
+
throw ERRORS.TypedError(HardwareErrorCode.BridgeTimeoutError);
|
|
10315
10305
|
}
|
|
10316
10306
|
}
|
|
10317
10307
|
});
|
|
@@ -10329,7 +10319,7 @@ class TransportManager {
|
|
|
10329
10319
|
this.currentMessages = messages;
|
|
10330
10320
|
}
|
|
10331
10321
|
catch (error) {
|
|
10332
|
-
throw
|
|
10322
|
+
throw ERRORS.TypedError(HardwareErrorCode.TransportInvalidProtobuf, `Transport_InvalidProtobuf: ${error.message}`);
|
|
10333
10323
|
}
|
|
10334
10324
|
});
|
|
10335
10325
|
}
|
|
@@ -10341,7 +10331,7 @@ class TransportManager {
|
|
|
10341
10331
|
else {
|
|
10342
10332
|
this.transport = new TransportConstructor();
|
|
10343
10333
|
}
|
|
10344
|
-
Log$
|
|
10334
|
+
Log$6.debug('set transport: ', this.transport);
|
|
10345
10335
|
}
|
|
10346
10336
|
static getTransport() {
|
|
10347
10337
|
return this.transport;
|
|
@@ -10358,10 +10348,10 @@ TransportManager.reactNativeInit = false;
|
|
|
10358
10348
|
const assertType = (res, resType) => {
|
|
10359
10349
|
const splitResTypes = Array.isArray(resType) ? resType : resType.split('|');
|
|
10360
10350
|
if (!splitResTypes.includes(res.type)) {
|
|
10361
|
-
throw
|
|
10351
|
+
throw ERRORS.TypedError(HardwareErrorCode.ResponseUnexpectTypeError, `assertType: Response of unexpected type: ${res.type}. Should be ${resType}`);
|
|
10362
10352
|
}
|
|
10363
10353
|
};
|
|
10364
|
-
const Log$
|
|
10354
|
+
const Log$5 = getLogger(LoggerNames.DeviceCommands);
|
|
10365
10355
|
class DeviceCommands {
|
|
10366
10356
|
constructor(device, mainId) {
|
|
10367
10357
|
this.device = device;
|
|
@@ -10383,16 +10373,16 @@ class DeviceCommands {
|
|
|
10383
10373
|
call(type, msg = {}) {
|
|
10384
10374
|
var _a, _b;
|
|
10385
10375
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10386
|
-
Log$
|
|
10376
|
+
Log$5.debug('[DeviceCommands] [call] Sending', type);
|
|
10387
10377
|
try {
|
|
10388
10378
|
const promise = this.transport.call(this.mainId, type, msg);
|
|
10389
10379
|
this.callPromise = promise;
|
|
10390
10380
|
const res = yield promise;
|
|
10391
|
-
Log$
|
|
10381
|
+
Log$5.debug('[DeviceCommands] [call] Received', res.type);
|
|
10392
10382
|
return res;
|
|
10393
10383
|
}
|
|
10394
10384
|
catch (error) {
|
|
10395
|
-
Log$
|
|
10385
|
+
Log$5.debug('[DeviceCommands] [call] Received error', error);
|
|
10396
10386
|
if (((_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === 'device disconnected during action') {
|
|
10397
10387
|
return { type: 'BridgeNetworkError', message: {} };
|
|
10398
10388
|
}
|
|
@@ -10403,18 +10393,18 @@ class DeviceCommands {
|
|
|
10403
10393
|
typedCall(type, resType, msg) {
|
|
10404
10394
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10405
10395
|
if (this.disposed) {
|
|
10406
|
-
throw
|
|
10396
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'typedCall: DeviceCommands already disposed');
|
|
10407
10397
|
}
|
|
10408
10398
|
const response = yield this._commonCall(type, msg);
|
|
10409
10399
|
try {
|
|
10410
10400
|
assertType(response, resType);
|
|
10411
10401
|
}
|
|
10412
10402
|
catch (error) {
|
|
10413
|
-
Log$
|
|
10414
|
-
if (error instanceof
|
|
10415
|
-
if (error.errorCode ===
|
|
10403
|
+
Log$5.debug('DeviceCommands typedcall error: ', error);
|
|
10404
|
+
if (error instanceof HardwareError) {
|
|
10405
|
+
if (error.errorCode === HardwareErrorCode.ResponseUnexpectTypeError) {
|
|
10416
10406
|
if (error.message.indexOf('BridgeNetworkError') > -1) {
|
|
10417
|
-
throw
|
|
10407
|
+
throw ERRORS.TypedError(HardwareErrorCode.BridgeNetworkError);
|
|
10418
10408
|
}
|
|
10419
10409
|
}
|
|
10420
10410
|
}
|
|
@@ -10432,30 +10422,30 @@ class DeviceCommands {
|
|
|
10432
10422
|
});
|
|
10433
10423
|
}
|
|
10434
10424
|
_filterCommonTypes(res) {
|
|
10435
|
-
Log$
|
|
10425
|
+
Log$5.debug('_filterCommonTypes: ', res);
|
|
10436
10426
|
if (res.type === 'Failure') {
|
|
10437
10427
|
const { code } = res.message;
|
|
10438
10428
|
const { message } = res.message;
|
|
10439
10429
|
let error = null;
|
|
10440
10430
|
if (code === 'Failure_FirmwareError' && !message) {
|
|
10441
|
-
error =
|
|
10431
|
+
error = ERRORS.TypedError(HardwareErrorCode.FirmwareError);
|
|
10442
10432
|
}
|
|
10443
10433
|
if (code === 'Failure_ActionCancelled') {
|
|
10444
|
-
error =
|
|
10434
|
+
error = ERRORS.TypedError(HardwareErrorCode.ActionCancelled);
|
|
10445
10435
|
}
|
|
10446
10436
|
if (code === 'Failure_PinInvalid') {
|
|
10447
|
-
error =
|
|
10437
|
+
error = ERRORS.TypedError(HardwareErrorCode.PinInvalid, message);
|
|
10448
10438
|
}
|
|
10449
10439
|
if (code === 'Failure_PinCancelled') {
|
|
10450
|
-
error =
|
|
10440
|
+
error = ERRORS.TypedError(HardwareErrorCode.PinCancelled);
|
|
10451
10441
|
}
|
|
10452
10442
|
if (code === 'Failure_DataError' && message === 'Please confirm the BlindSign enabled') {
|
|
10453
|
-
error =
|
|
10443
|
+
error = ERRORS.TypedError(HardwareErrorCode.BlindSignDisabled);
|
|
10454
10444
|
}
|
|
10455
10445
|
if (error) {
|
|
10456
10446
|
return Promise.reject(error);
|
|
10457
10447
|
}
|
|
10458
|
-
return Promise.reject(
|
|
10448
|
+
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.RuntimeError, `${code || 'Failure_UnknownCode'},${message || 'Failure_UnknownMessage'}`));
|
|
10459
10449
|
}
|
|
10460
10450
|
if (res.type === 'Features') {
|
|
10461
10451
|
return Promise.resolve(patchFeatures(res));
|
|
@@ -10473,7 +10463,7 @@ class DeviceCommands {
|
|
|
10473
10463
|
const isWebusbEnv = DataManager.getSettings('env') === 'webusb';
|
|
10474
10464
|
if (res.type === 'PinMatrixRequest') {
|
|
10475
10465
|
if (isWebusbEnv) {
|
|
10476
|
-
return Promise.reject(
|
|
10466
|
+
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Please unlock your device'));
|
|
10477
10467
|
}
|
|
10478
10468
|
return this._promptPin(res.message.type).then(pin => {
|
|
10479
10469
|
if (pin === '@@ONEKEY_INPUT_PIN_IN_DEVICE') {
|
|
@@ -10483,7 +10473,7 @@ class DeviceCommands {
|
|
|
10483
10473
|
}, () => this._commonCall('Cancel', {}));
|
|
10484
10474
|
}
|
|
10485
10475
|
if (res.type === 'PassphraseRequest') {
|
|
10486
|
-
return Promise.reject(
|
|
10476
|
+
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceNotSupportPassphrase, 'Device not support passphrase', {
|
|
10487
10477
|
require: '2.4.0',
|
|
10488
10478
|
}));
|
|
10489
10479
|
}
|
|
@@ -10507,7 +10497,7 @@ class DeviceCommands {
|
|
|
10507
10497
|
}
|
|
10508
10498
|
else {
|
|
10509
10499
|
console.warn('[DeviceCommands] [call] PIN callback not configured, cancelling request');
|
|
10510
|
-
reject(
|
|
10500
|
+
reject(ERRORS.TypedError(HardwareErrorCode.RuntimeError, '_promptPin: PIN callback not configured'));
|
|
10511
10501
|
}
|
|
10512
10502
|
});
|
|
10513
10503
|
}
|
|
@@ -10537,7 +10527,7 @@ const initialSettings = {
|
|
|
10537
10527
|
trustedHost: false,
|
|
10538
10528
|
connectSrc: DEFAULT_DOMAIN,
|
|
10539
10529
|
iframeSrc: `${DEFAULT_DOMAIN}iframe.html`,
|
|
10540
|
-
parentOrigin: window.location ? window.location.origin : '',
|
|
10530
|
+
parentOrigin: window && window.location ? window.location.origin : '',
|
|
10541
10531
|
supportedBrowser: typeof navigator !== 'undefined' ? !/Trident|MSIE|Edge/.test(navigator.userAgent) : true,
|
|
10542
10532
|
env: 'web',
|
|
10543
10533
|
lazyLoad: false,
|
|
@@ -10617,7 +10607,7 @@ const parseRunOptions = (options) => {
|
|
|
10617
10607
|
options = {};
|
|
10618
10608
|
return options;
|
|
10619
10609
|
};
|
|
10620
|
-
const Log$
|
|
10610
|
+
const Log$4 = getLogger(LoggerNames.Device);
|
|
10621
10611
|
const deviceSessionCache = {};
|
|
10622
10612
|
class Device extends events.exports {
|
|
10623
10613
|
constructor(descriptor) {
|
|
@@ -10700,11 +10690,11 @@ class Device extends events.exports {
|
|
|
10700
10690
|
if (env === 'react-native') {
|
|
10701
10691
|
const res = yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.acquire(this.originalDescriptor.id));
|
|
10702
10692
|
this.mainId = (_b = res.uuid) !== null && _b !== void 0 ? _b : '';
|
|
10703
|
-
Log$
|
|
10693
|
+
Log$4.debug('Expected uuid:', this.mainId);
|
|
10704
10694
|
}
|
|
10705
10695
|
else {
|
|
10706
10696
|
this.mainId = yield ((_c = this.deviceConnector) === null || _c === void 0 ? void 0 : _c.acquire(this.originalDescriptor.path, this.originalDescriptor.session));
|
|
10707
|
-
Log$
|
|
10697
|
+
Log$4.debug('Expected session id:', this.mainId);
|
|
10708
10698
|
}
|
|
10709
10699
|
this.updateDescriptor({ [mainIdKey]: this.mainId });
|
|
10710
10700
|
if (this.commands) {
|
|
@@ -10745,7 +10735,7 @@ class Device extends events.exports {
|
|
|
10745
10735
|
this.updateDescriptor({ session: null });
|
|
10746
10736
|
}
|
|
10747
10737
|
catch (err) {
|
|
10748
|
-
Log$
|
|
10738
|
+
Log$4.error('[Device] release error: ', err);
|
|
10749
10739
|
}
|
|
10750
10740
|
finally {
|
|
10751
10741
|
this.needReloadDevice = true;
|
|
@@ -10757,20 +10747,26 @@ class Device extends events.exports {
|
|
|
10757
10747
|
return this.commands;
|
|
10758
10748
|
}
|
|
10759
10749
|
getInternalState(_deviceId) {
|
|
10760
|
-
var _a, _b
|
|
10761
|
-
Log$
|
|
10762
|
-
Log$
|
|
10750
|
+
var _a, _b;
|
|
10751
|
+
Log$4.debug('getInternalState session param: ', `device_id: ${_deviceId}`, `features.device_id: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.device_id}`, `passphraseState: ${this.passphraseState}`);
|
|
10752
|
+
Log$4.debug('getInternalState session cache: ', deviceSessionCache);
|
|
10763
10753
|
const deviceId = _deviceId || ((_b = this.features) === null || _b === void 0 ? void 0 : _b.device_id);
|
|
10764
10754
|
if (!deviceId)
|
|
10765
10755
|
return undefined;
|
|
10766
|
-
|
|
10756
|
+
if (!this.passphraseState)
|
|
10757
|
+
return undefined;
|
|
10767
10758
|
const usePassKey = `${deviceId}@${this.passphraseState}`;
|
|
10768
|
-
|
|
10769
|
-
|
|
10759
|
+
if (!deviceSessionCache[usePassKey]) {
|
|
10760
|
+
const key = `${deviceId}`;
|
|
10761
|
+
if (deviceSessionCache[key]) {
|
|
10762
|
+
deviceSessionCache[usePassKey] = deviceSessionCache[key];
|
|
10763
|
+
}
|
|
10764
|
+
}
|
|
10765
|
+
return deviceSessionCache[usePassKey];
|
|
10770
10766
|
}
|
|
10771
10767
|
setInternalState(state, initSession) {
|
|
10772
10768
|
var _a;
|
|
10773
|
-
Log$
|
|
10769
|
+
Log$4.debug('setInternalState session param: ', `state: ${state}`, `initSession: ${initSession}`, `device_id: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.device_id}`, `passphraseState: ${this.passphraseState}`);
|
|
10774
10770
|
if (!this.features)
|
|
10775
10771
|
return;
|
|
10776
10772
|
if (!this.passphraseState && !initSession)
|
|
@@ -10782,11 +10778,11 @@ class Device extends events.exports {
|
|
|
10782
10778
|
if (state) {
|
|
10783
10779
|
deviceSessionCache[key] = state;
|
|
10784
10780
|
}
|
|
10785
|
-
Log$
|
|
10781
|
+
Log$4.debug('setInternalState done session cache: ', deviceSessionCache);
|
|
10786
10782
|
}
|
|
10787
10783
|
clearInternalState(_deviceId) {
|
|
10788
10784
|
var _a;
|
|
10789
|
-
Log$
|
|
10785
|
+
Log$4.debug('clearInternalState param: ', _deviceId);
|
|
10790
10786
|
const deviceId = _deviceId || ((_a = this.features) === null || _a === void 0 ? void 0 : _a.device_id);
|
|
10791
10787
|
if (!deviceId)
|
|
10792
10788
|
return;
|
|
@@ -10799,7 +10795,7 @@ class Device extends events.exports {
|
|
|
10799
10795
|
}
|
|
10800
10796
|
initialize(options) {
|
|
10801
10797
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10802
|
-
Log$
|
|
10798
|
+
Log$4.debug('initialize param:', options);
|
|
10803
10799
|
this.passphraseState = options === null || options === void 0 ? void 0 : options.passphraseState;
|
|
10804
10800
|
if (options === null || options === void 0 ? void 0 : options.initSession) {
|
|
10805
10801
|
this.clearInternalState(options === null || options === void 0 ? void 0 : options.deviceId);
|
|
@@ -10809,7 +10805,7 @@ class Device extends events.exports {
|
|
|
10809
10805
|
if (internalState) {
|
|
10810
10806
|
payload.session_id = internalState;
|
|
10811
10807
|
}
|
|
10812
|
-
Log$
|
|
10808
|
+
Log$4.debug('initialize payload:', payload);
|
|
10813
10809
|
const { message } = yield this.commands.typedCall('Initialize', 'Features', payload);
|
|
10814
10810
|
this._updateFeatures(message, options === null || options === void 0 ? void 0 : options.initSession);
|
|
10815
10811
|
});
|
|
@@ -10858,10 +10854,10 @@ class Device extends events.exports {
|
|
|
10858
10854
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10859
10855
|
if (this.runPromise) {
|
|
10860
10856
|
yield this.interruptionFromOutside();
|
|
10861
|
-
Log$
|
|
10857
|
+
Log$4.debug('[Device] run error:', 'Device is running, but will cancel previous operate');
|
|
10862
10858
|
}
|
|
10863
10859
|
options = parseRunOptions(options);
|
|
10864
|
-
this.runPromise =
|
|
10860
|
+
this.runPromise = createDeferred(this._runInner.bind(this, fn, options));
|
|
10865
10861
|
return this.runPromise.promise;
|
|
10866
10862
|
});
|
|
10867
10863
|
}
|
|
@@ -10878,10 +10874,10 @@ class Device extends events.exports {
|
|
|
10878
10874
|
}
|
|
10879
10875
|
catch (error) {
|
|
10880
10876
|
this.runPromise = null;
|
|
10881
|
-
if (error instanceof
|
|
10877
|
+
if (error instanceof HardwareError) {
|
|
10882
10878
|
return Promise.reject(error);
|
|
10883
10879
|
}
|
|
10884
|
-
return Promise.reject(
|
|
10880
|
+
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceInitializeFailed, `Initialize failed: ${error.message}, code: ${error.code}`));
|
|
10885
10881
|
}
|
|
10886
10882
|
}
|
|
10887
10883
|
}
|
|
@@ -10904,7 +10900,7 @@ class Device extends events.exports {
|
|
|
10904
10900
|
options.keepSession === false) {
|
|
10905
10901
|
this.keepSession = false;
|
|
10906
10902
|
yield this.release();
|
|
10907
|
-
Log$
|
|
10903
|
+
Log$4.debug('release device, mainId: ', this.mainId);
|
|
10908
10904
|
}
|
|
10909
10905
|
if (this.runPromise) {
|
|
10910
10906
|
this.runPromise.resolve();
|
|
@@ -10918,7 +10914,7 @@ class Device extends events.exports {
|
|
|
10918
10914
|
yield this.commands.dispose(false);
|
|
10919
10915
|
}
|
|
10920
10916
|
if (this.runPromise) {
|
|
10921
|
-
this.runPromise.reject(
|
|
10917
|
+
this.runPromise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceInterruptedFromOutside));
|
|
10922
10918
|
}
|
|
10923
10919
|
});
|
|
10924
10920
|
}
|
|
@@ -10928,7 +10924,7 @@ class Device extends events.exports {
|
|
|
10928
10924
|
yield this.commands.dispose(true);
|
|
10929
10925
|
}
|
|
10930
10926
|
if (this.runPromise) {
|
|
10931
|
-
this.runPromise.reject(
|
|
10927
|
+
this.runPromise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceInterruptedFromUser));
|
|
10932
10928
|
}
|
|
10933
10929
|
});
|
|
10934
10930
|
}
|
|
@@ -11070,6 +11066,7 @@ const getBleFirmwareReleaseInfo = (features) => {
|
|
|
11070
11066
|
};
|
|
11071
11067
|
};
|
|
11072
11068
|
|
|
11069
|
+
const Log$3 = getLogger(LoggerNames.Method);
|
|
11073
11070
|
class BaseMethod {
|
|
11074
11071
|
constructor(message) {
|
|
11075
11072
|
this.shouldEnsureConnected = true;
|
|
@@ -11109,6 +11106,24 @@ class BaseMethod {
|
|
|
11109
11106
|
device: this.device.toMessageObject(),
|
|
11110
11107
|
}));
|
|
11111
11108
|
}
|
|
11109
|
+
checkSafetyLevelOnTestNet() {
|
|
11110
|
+
var _a, _b, _c;
|
|
11111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11112
|
+
const deviceType = getDeviceType(this.device.features);
|
|
11113
|
+
if (deviceType !== 'touch')
|
|
11114
|
+
return;
|
|
11115
|
+
let checkFlag = false;
|
|
11116
|
+
if (this.name === 'evmSignTransaction' && Number((_b = (_a = this.payload) === null || _a === void 0 ? void 0 : _a.transaction) === null || _b === void 0 ? void 0 : _b.chainId) !== 1) {
|
|
11117
|
+
checkFlag = true;
|
|
11118
|
+
}
|
|
11119
|
+
if (checkFlag && ((_c = this.device.features) === null || _c === void 0 ? void 0 : _c.safety_checks) === 'Strict') {
|
|
11120
|
+
Log$3.debug('will change safety_checks level');
|
|
11121
|
+
yield this.device.commands.typedCall('ApplySettings', 'Success', {
|
|
11122
|
+
safety_checks: 'PromptTemporarily',
|
|
11123
|
+
});
|
|
11124
|
+
}
|
|
11125
|
+
});
|
|
11126
|
+
}
|
|
11112
11127
|
dispose() { }
|
|
11113
11128
|
}
|
|
11114
11129
|
|
|
@@ -11182,7 +11197,7 @@ const formatAnyHex = value => {
|
|
|
11182
11197
|
return value;
|
|
11183
11198
|
};
|
|
11184
11199
|
|
|
11185
|
-
const invalidParameter = (message) =>
|
|
11200
|
+
const invalidParameter = (message) => ERRORS.TypedError(HardwareErrorCode.CallMethodInvalidParameter, message);
|
|
11186
11201
|
const validateParams = (values, fields) => {
|
|
11187
11202
|
fields.forEach(field => {
|
|
11188
11203
|
const existsProp = Object.prototype.hasOwnProperty.call(values, field.name);
|
|
@@ -11205,7 +11220,7 @@ const validateParams = (values, fields) => {
|
|
|
11205
11220
|
throw invalidParameter(`Parameter [${field.name}] is of type invalid and should be [string].`);
|
|
11206
11221
|
}
|
|
11207
11222
|
try {
|
|
11208
|
-
const bn = new
|
|
11223
|
+
const bn = new BigNumber(value);
|
|
11209
11224
|
if (bn.toFixed(0) !== value) {
|
|
11210
11225
|
throw new Error('');
|
|
11211
11226
|
}
|
|
@@ -11498,13 +11513,13 @@ const getCoinInfo = (path, coin) => {
|
|
|
11498
11513
|
}
|
|
11499
11514
|
if (!coinInfo) {
|
|
11500
11515
|
if (coin) {
|
|
11501
|
-
throw
|
|
11516
|
+
throw ERRORS.TypedError(HardwareErrorCode.CallMethodInvalidParameter, `Invalid coin name: ${coin}`);
|
|
11502
11517
|
}
|
|
11503
11518
|
else if (path) {
|
|
11504
|
-
throw
|
|
11519
|
+
throw ERRORS.TypedError(HardwareErrorCode.CallMethodInvalidParameter, `Invalid path: ${path[0]}`);
|
|
11505
11520
|
}
|
|
11506
11521
|
else {
|
|
11507
|
-
throw
|
|
11522
|
+
throw ERRORS.TypedError(HardwareErrorCode.CallMethodInvalidParameter);
|
|
11508
11523
|
}
|
|
11509
11524
|
}
|
|
11510
11525
|
return coinInfo;
|
|
@@ -11661,49 +11676,49 @@ class BTCSignMessage extends BaseMethod {
|
|
|
11661
11676
|
const requestPrevTxInfo$1 = ({ typedCall, txRequest: { request_type, details }, refTxs }) => {
|
|
11662
11677
|
const { tx_hash } = details;
|
|
11663
11678
|
if (!tx_hash) {
|
|
11664
|
-
throw
|
|
11679
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'requestPrevTxInfo: unknown details.tx_hash');
|
|
11665
11680
|
}
|
|
11666
11681
|
const tx = refTxs[tx_hash.toLowerCase()];
|
|
11667
11682
|
if (!tx) {
|
|
11668
|
-
throw
|
|
11683
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `requestPrevTxInfo: Requested unknown tx: ${tx_hash}`);
|
|
11669
11684
|
}
|
|
11670
11685
|
if (request_type === 'TXINPUT') {
|
|
11671
11686
|
if (!tx.bin_outputs)
|
|
11672
|
-
throw
|
|
11687
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `requestPrevTxInfo: Requested unknown TXINPUT: ${tx_hash}`);
|
|
11673
11688
|
return typedCall('TxAckPrevInput', 'TxRequest', {
|
|
11674
11689
|
tx: { input: tx.inputs[details.request_index] },
|
|
11675
11690
|
});
|
|
11676
11691
|
}
|
|
11677
11692
|
if (request_type === 'TXOUTPUT') {
|
|
11678
11693
|
if (!tx.bin_outputs)
|
|
11679
|
-
throw
|
|
11694
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `requestPrevTxInfo: Requested unknown TXOUTPUT: ${tx_hash}`);
|
|
11680
11695
|
return typedCall('TxAckPrevOutput', 'TxRequest', {
|
|
11681
11696
|
tx: { output: tx.bin_outputs[details.request_index] },
|
|
11682
11697
|
});
|
|
11683
11698
|
}
|
|
11684
11699
|
if (request_type === 'TXORIGINPUT') {
|
|
11685
11700
|
if (!tx.outputs)
|
|
11686
|
-
throw
|
|
11701
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `requestPrevTxInfo: Requested unknown TXORIGINPUT: ${tx_hash}`);
|
|
11687
11702
|
return typedCall('TxAckInput', 'TxRequest', {
|
|
11688
11703
|
tx: { input: tx.inputs[details.request_index] },
|
|
11689
11704
|
});
|
|
11690
11705
|
}
|
|
11691
11706
|
if (request_type === 'TXORIGOUTPUT') {
|
|
11692
11707
|
if (!tx.outputs)
|
|
11693
|
-
throw
|
|
11708
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `requestPrevTxInfo: Requested unknown TXORIGOUTPUT: ${tx_hash}`);
|
|
11694
11709
|
return typedCall('TxAckOutput', 'TxRequest', {
|
|
11695
11710
|
tx: { output: tx.outputs[details.request_index] },
|
|
11696
11711
|
});
|
|
11697
11712
|
}
|
|
11698
11713
|
if (request_type === 'TXEXTRADATA') {
|
|
11699
11714
|
if (typeof details.extra_data_len !== 'number') {
|
|
11700
|
-
throw
|
|
11715
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'requestPrevTxInfo: Missing extra_data_len');
|
|
11701
11716
|
}
|
|
11702
11717
|
if (typeof details.extra_data_offset !== 'number') {
|
|
11703
|
-
throw
|
|
11718
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'requestPrevTxInfo: Missing extra_data_offset');
|
|
11704
11719
|
}
|
|
11705
11720
|
if (typeof tx.extra_data !== 'string') {
|
|
11706
|
-
throw
|
|
11721
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `requestPrevTxInfo: No extra data for transaction ${tx.hash}`);
|
|
11707
11722
|
}
|
|
11708
11723
|
const data = tx.extra_data;
|
|
11709
11724
|
const dataLen = details.extra_data_len;
|
|
@@ -11726,7 +11741,7 @@ const requestPrevTxInfo$1 = ({ typedCall, txRequest: { request_type, details },
|
|
|
11726
11741
|
};
|
|
11727
11742
|
return typedCall('TxAckPrevMeta', 'TxRequest', { tx: meta });
|
|
11728
11743
|
}
|
|
11729
|
-
throw
|
|
11744
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `requestPrevTxInfo: Unknown request type: ${request_type}`);
|
|
11730
11745
|
};
|
|
11731
11746
|
const requestSignedTxInfo$1 = ({ typedCall, txRequest: { request_type, details }, inputs, outputs, }) => {
|
|
11732
11747
|
if (request_type === 'TXINPUT') {
|
|
@@ -11738,12 +11753,12 @@ const requestSignedTxInfo$1 = ({ typedCall, txRequest: { request_type, details }
|
|
|
11738
11753
|
});
|
|
11739
11754
|
}
|
|
11740
11755
|
if (request_type === 'TXMETA') {
|
|
11741
|
-
throw
|
|
11756
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'requestSignedTxInfo: Cannot read TXMETA from signed transaction');
|
|
11742
11757
|
}
|
|
11743
11758
|
if (request_type === 'TXEXTRADATA') {
|
|
11744
|
-
throw
|
|
11759
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'requestSignedTxInfo: Cannot read TXEXTRADATA from signed transaction');
|
|
11745
11760
|
}
|
|
11746
|
-
throw
|
|
11761
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `requestSignedTxInfo: Unknown request type: ${request_type}`);
|
|
11747
11762
|
};
|
|
11748
11763
|
const requestTxAck$1 = (props) => {
|
|
11749
11764
|
const { tx_hash } = props.txRequest.details;
|
|
@@ -11761,7 +11776,7 @@ const saveTxSignatures$1 = (serializedTx, signatures, txRequest) => {
|
|
|
11761
11776
|
}
|
|
11762
11777
|
if (typeof signature_index === 'number') {
|
|
11763
11778
|
if (!signature) {
|
|
11764
|
-
throw
|
|
11779
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'saveTxSignatures: Unexpected null in trezor:TxRequestSerialized signature.');
|
|
11765
11780
|
}
|
|
11766
11781
|
signatures[signature_index] = signature;
|
|
11767
11782
|
}
|
|
@@ -11806,14 +11821,14 @@ var signtx = (typedCall, inputs, outputs, refTxsArray, options, coinName) => __a
|
|
|
11806
11821
|
const requestPrevTxInfo = ({ txRequest: { request_type, details }, refTxs, }) => {
|
|
11807
11822
|
const { tx_hash } = details;
|
|
11808
11823
|
if (!tx_hash) {
|
|
11809
|
-
throw
|
|
11824
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'requestPrevTxInfo: unknown details.tx_hash');
|
|
11810
11825
|
}
|
|
11811
11826
|
const tx = refTxs[tx_hash.toLowerCase()];
|
|
11812
11827
|
if (!tx) {
|
|
11813
|
-
throw
|
|
11828
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `requestPrevTxInfo: Requested unknown tx: ${tx_hash}`);
|
|
11814
11829
|
}
|
|
11815
11830
|
if (!tx.bin_outputs) {
|
|
11816
|
-
throw
|
|
11831
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `requestPrevTxInfo: bin_outputs not set tx: ${tx_hash}`);
|
|
11817
11832
|
}
|
|
11818
11833
|
if (request_type === 'TXINPUT') {
|
|
11819
11834
|
return { inputs: [tx.inputs[details.request_index]] };
|
|
@@ -11823,13 +11838,13 @@ const requestPrevTxInfo = ({ txRequest: { request_type, details }, refTxs, }) =>
|
|
|
11823
11838
|
}
|
|
11824
11839
|
if (request_type === 'TXEXTRADATA') {
|
|
11825
11840
|
if (typeof details.extra_data_len !== 'number') {
|
|
11826
|
-
throw
|
|
11841
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'requestPrevTxInfo: Missing extra_data_len');
|
|
11827
11842
|
}
|
|
11828
11843
|
if (typeof details.extra_data_offset !== 'number') {
|
|
11829
|
-
throw
|
|
11844
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'requestPrevTxInfo: Missing extra_data_offset');
|
|
11830
11845
|
}
|
|
11831
11846
|
if (typeof tx.extra_data !== 'string') {
|
|
11832
|
-
throw
|
|
11847
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `requestPrevTxInfo: No extra data for transaction ${tx.hash}`);
|
|
11833
11848
|
}
|
|
11834
11849
|
const data = tx.extra_data;
|
|
11835
11850
|
const dataLen = details.extra_data_len;
|
|
@@ -11854,7 +11869,7 @@ const requestPrevTxInfo = ({ txRequest: { request_type, details }, refTxs, }) =>
|
|
|
11854
11869
|
}
|
|
11855
11870
|
return meta;
|
|
11856
11871
|
}
|
|
11857
|
-
throw
|
|
11872
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `requestPrevTxInfo: Unknown request type: ${request_type}`);
|
|
11858
11873
|
};
|
|
11859
11874
|
const requestSignedTxInfo = ({ txRequest: { request_type, details }, inputs, outputs, }) => {
|
|
11860
11875
|
if (request_type === 'TXINPUT') {
|
|
@@ -11864,12 +11879,12 @@ const requestSignedTxInfo = ({ txRequest: { request_type, details }, inputs, out
|
|
|
11864
11879
|
return { outputs: [outputs[details.request_index]] };
|
|
11865
11880
|
}
|
|
11866
11881
|
if (request_type === 'TXMETA') {
|
|
11867
|
-
throw
|
|
11882
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'requestSignedTxInfo: Cannot read TXMETA from signed transaction');
|
|
11868
11883
|
}
|
|
11869
11884
|
if (request_type === 'TXEXTRADATA') {
|
|
11870
|
-
throw
|
|
11885
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'requestSignedTxInfo: Cannot read TXEXTRADATA from signed transaction');
|
|
11871
11886
|
}
|
|
11872
|
-
throw
|
|
11887
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `requestSignedTxInfo: Unknown request type: ${request_type}`);
|
|
11873
11888
|
};
|
|
11874
11889
|
const requestTxAck = (props) => {
|
|
11875
11890
|
const { tx_hash } = props.txRequest.details;
|
|
@@ -11887,7 +11902,7 @@ const saveTxSignatures = (serializedTx, signatures, txRequest) => {
|
|
|
11887
11902
|
}
|
|
11888
11903
|
if (typeof signature_index === 'number') {
|
|
11889
11904
|
if (!signature) {
|
|
11890
|
-
throw
|
|
11905
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'saveTxSignatures: Unexpected null in trezor:TxRequestSerialized signature.');
|
|
11891
11906
|
}
|
|
11892
11907
|
signatures[signature_index] = signature;
|
|
11893
11908
|
}
|
|
@@ -11982,12 +11997,12 @@ class BTCSignTransaction extends BaseMethod {
|
|
|
11982
11997
|
]);
|
|
11983
11998
|
if (Object.prototype.hasOwnProperty.call(output, 'address_n') &&
|
|
11984
11999
|
Object.prototype.hasOwnProperty.call(output, 'address')) {
|
|
11985
|
-
throw
|
|
12000
|
+
throw ERRORS.TypedError(HardwareErrorCode.CallMethodInvalidParameter, 'Cannot use address and address_n in one output');
|
|
11986
12001
|
}
|
|
11987
12002
|
if (output.address_n) {
|
|
11988
12003
|
const scriptType = getOutputScriptType(output.address_n);
|
|
11989
12004
|
if (output.script_type !== scriptType)
|
|
11990
|
-
throw
|
|
12005
|
+
throw ERRORS.TypedError(HardwareErrorCode.CallMethodInvalidParameter, `Output change script_type should be set to ${scriptType}`);
|
|
11991
12006
|
}
|
|
11992
12007
|
});
|
|
11993
12008
|
const { inputs, outputs, refTxs, account, coin } = this.payload;
|
|
@@ -12100,7 +12115,7 @@ class CheckBridgeStatus$1 extends BaseMethod {
|
|
|
12100
12115
|
run() {
|
|
12101
12116
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12102
12117
|
return new Promise((resolve, reject) => {
|
|
12103
|
-
|
|
12118
|
+
axios
|
|
12104
12119
|
.request({
|
|
12105
12120
|
url: 'http://localhost:21320',
|
|
12106
12121
|
method: 'POST',
|
|
@@ -12110,7 +12125,7 @@ class CheckBridgeStatus$1 extends BaseMethod {
|
|
|
12110
12125
|
.then(() => resolve(true))
|
|
12111
12126
|
.catch(e => {
|
|
12112
12127
|
if (e.code === 'ECONNABORTED') {
|
|
12113
|
-
reject(
|
|
12128
|
+
reject(ERRORS.TypedError(HardwareErrorCode.BridgeTimeoutError));
|
|
12114
12129
|
}
|
|
12115
12130
|
else {
|
|
12116
12131
|
resolve(false);
|
|
@@ -12269,7 +12284,7 @@ class DeviceSettings extends BaseMethod {
|
|
|
12269
12284
|
{ name: 'autoLockDelayMs', type: 'number' },
|
|
12270
12285
|
{ name: 'displayRotation', type: 'number' },
|
|
12271
12286
|
{ name: 'passphraseAlwaysOnDevice', type: 'boolean' },
|
|
12272
|
-
{ name: 'safetyChecks', type: '
|
|
12287
|
+
{ name: 'safetyChecks', type: 'number' },
|
|
12273
12288
|
{ name: 'experimentalFeatures', type: 'boolean' },
|
|
12274
12289
|
]);
|
|
12275
12290
|
this.params = {
|
|
@@ -12321,7 +12336,7 @@ class DeviceSupportFeatures extends BaseMethod {
|
|
|
12321
12336
|
}
|
|
12322
12337
|
run() {
|
|
12323
12338
|
if (!this.device.features)
|
|
12324
|
-
return Promise.reject(
|
|
12339
|
+
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Device not initialized'));
|
|
12325
12340
|
const inputPinOnSoftware = supportInputPinOnSoftware(this.device.features);
|
|
12326
12341
|
return Promise.resolve({
|
|
12327
12342
|
inputPinOnSoftware,
|
|
@@ -12343,7 +12358,7 @@ class DeviceVerify extends BaseMethod {
|
|
|
12343
12358
|
const deviceType = getDeviceType(this.device.features);
|
|
12344
12359
|
let response;
|
|
12345
12360
|
if (deviceType === 'classic') {
|
|
12346
|
-
const res = yield this.device.commands.typedCall('BixinVerifyDeviceRequest', 'BixinVerifyDeviceAck', Object.assign(Object.assign({}, this.params), { data:
|
|
12361
|
+
const res = yield this.device.commands.typedCall('BixinVerifyDeviceRequest', 'BixinVerifyDeviceAck', Object.assign(Object.assign({}, this.params), { data: sha256.sha256(this.params.data) }));
|
|
12347
12362
|
response = res.message;
|
|
12348
12363
|
}
|
|
12349
12364
|
else {
|
|
@@ -12358,7 +12373,7 @@ class DeviceVerify extends BaseMethod {
|
|
|
12358
12373
|
}
|
|
12359
12374
|
if (response)
|
|
12360
12375
|
return Promise.resolve(response);
|
|
12361
|
-
return Promise.reject(
|
|
12376
|
+
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Device not support verify'));
|
|
12362
12377
|
});
|
|
12363
12378
|
}
|
|
12364
12379
|
}
|
|
@@ -12534,7 +12549,7 @@ class EVMSignTransaction extends BaseMethod {
|
|
|
12534
12549
|
const r = request.signature_r;
|
|
12535
12550
|
const s = request.signature_s;
|
|
12536
12551
|
if (v == null || r == null || s == null) {
|
|
12537
|
-
throw
|
|
12552
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'processTxRequest: Unexpected request');
|
|
12538
12553
|
}
|
|
12539
12554
|
if (chain_id && v <= 1) {
|
|
12540
12555
|
v += 2 * chain_id + 35;
|
|
@@ -12654,13 +12669,13 @@ class EVMSignTransaction extends BaseMethod {
|
|
|
12654
12669
|
|
|
12655
12670
|
const twosComplement = (number, bytes) => {
|
|
12656
12671
|
if (bytes < 1 || bytes > 32) {
|
|
12657
|
-
throw
|
|
12672
|
+
throw ERRORS.TypedError('Runtime', 'Int byte size must be between 1 and 32 (8 and 256 bits)');
|
|
12658
12673
|
}
|
|
12659
|
-
const minValue = new
|
|
12674
|
+
const minValue = new BigNumber(2).exponentiatedBy(bytes * 8 - 1).negated();
|
|
12660
12675
|
const maxValue = minValue.negated().minus(1);
|
|
12661
|
-
const bigNumber = new
|
|
12676
|
+
const bigNumber = new BigNumber(number);
|
|
12662
12677
|
if (bigNumber.isGreaterThan(maxValue) || bigNumber.isLessThan(minValue)) {
|
|
12663
|
-
throw
|
|
12678
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `Overflow when trying to convert number ${number.toString()} into ${bytes} bytes`);
|
|
12664
12679
|
}
|
|
12665
12680
|
if (bigNumber.isPositive()) {
|
|
12666
12681
|
return bigNumber;
|
|
@@ -12668,17 +12683,17 @@ const twosComplement = (number, bytes) => {
|
|
|
12668
12683
|
return bigNumber.minus(minValue).minus(minValue);
|
|
12669
12684
|
};
|
|
12670
12685
|
const intToHex = (number, bytes, signed) => {
|
|
12671
|
-
let bigNumber = new
|
|
12686
|
+
let bigNumber = new BigNumber(number);
|
|
12672
12687
|
if (signed) {
|
|
12673
12688
|
bigNumber = twosComplement(bigNumber, bytes);
|
|
12674
12689
|
}
|
|
12675
12690
|
if (bigNumber.isNegative()) {
|
|
12676
|
-
throw
|
|
12691
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `Cannot convert negative number to unsigned interger: ${number.toString()}`);
|
|
12677
12692
|
}
|
|
12678
12693
|
const hex = bigNumber.toString(16);
|
|
12679
12694
|
const hexChars = bytes * 2;
|
|
12680
12695
|
if (hex.length > hexChars) {
|
|
12681
|
-
throw
|
|
12696
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `Overflow when trying to convert number ${number.toString()} into ${bytes} bytes`);
|
|
12682
12697
|
}
|
|
12683
12698
|
return hex.padStart(bytes * 2, '0');
|
|
12684
12699
|
};
|
|
@@ -12689,7 +12704,7 @@ const paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/);
|
|
|
12689
12704
|
const parseArrayType = (arrayTypeName) => {
|
|
12690
12705
|
const arrayMatch = paramTypeArray.exec(arrayTypeName);
|
|
12691
12706
|
if (arrayMatch === null) {
|
|
12692
|
-
throw
|
|
12707
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `typename ${arrayTypeName} could not be parsed as an EIP-712 array`);
|
|
12693
12708
|
}
|
|
12694
12709
|
const [_, entryTypeName, arraySize] = arrayMatch;
|
|
12695
12710
|
return {
|
|
@@ -12713,12 +12728,12 @@ const encodeData = (typeName, data) => {
|
|
|
12713
12728
|
if (typeName === 'bool') {
|
|
12714
12729
|
return data ? '01' : '00';
|
|
12715
12730
|
}
|
|
12716
|
-
throw
|
|
12731
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `Unsupported data type for direct field encoding: ${typeName}`);
|
|
12717
12732
|
};
|
|
12718
12733
|
const paramTypesMap = {
|
|
12719
|
-
string:
|
|
12720
|
-
bool:
|
|
12721
|
-
address:
|
|
12734
|
+
string: EthereumDataType.STRING,
|
|
12735
|
+
bool: EthereumDataType.BOOL,
|
|
12736
|
+
address: EthereumDataType.ADDRESS,
|
|
12722
12737
|
};
|
|
12723
12738
|
const getFieldType = (typeName, types) => {
|
|
12724
12739
|
const arrayMatch = paramTypeArray.exec(typeName);
|
|
@@ -12726,7 +12741,7 @@ const getFieldType = (typeName, types) => {
|
|
|
12726
12741
|
const [_, arrayItemTypeName, arraySize] = arrayMatch;
|
|
12727
12742
|
const entryType = getFieldType(arrayItemTypeName, types);
|
|
12728
12743
|
return {
|
|
12729
|
-
data_type:
|
|
12744
|
+
data_type: EthereumDataType.ARRAY,
|
|
12730
12745
|
size: parseInt(arraySize, 10) || undefined,
|
|
12731
12746
|
entry_type: entryType,
|
|
12732
12747
|
};
|
|
@@ -12735,7 +12750,7 @@ const getFieldType = (typeName, types) => {
|
|
|
12735
12750
|
if (numberMatch) {
|
|
12736
12751
|
const [_, type, bits] = numberMatch;
|
|
12737
12752
|
return {
|
|
12738
|
-
data_type: type === 'uint' ?
|
|
12753
|
+
data_type: type === 'uint' ? EthereumDataType.UINT : EthereumDataType.INT,
|
|
12739
12754
|
size: Math.floor(parseInt(bits, 10) / 8),
|
|
12740
12755
|
};
|
|
12741
12756
|
}
|
|
@@ -12743,7 +12758,7 @@ const getFieldType = (typeName, types) => {
|
|
|
12743
12758
|
if (bytesMatch) {
|
|
12744
12759
|
const [_, size] = bytesMatch;
|
|
12745
12760
|
return {
|
|
12746
|
-
data_type:
|
|
12761
|
+
data_type: EthereumDataType.BYTES,
|
|
12747
12762
|
size: parseInt(size, 10) || undefined,
|
|
12748
12763
|
};
|
|
12749
12764
|
}
|
|
@@ -12755,12 +12770,12 @@ const getFieldType = (typeName, types) => {
|
|
|
12755
12770
|
}
|
|
12756
12771
|
if (typeName in types) {
|
|
12757
12772
|
return {
|
|
12758
|
-
data_type:
|
|
12773
|
+
data_type: EthereumDataType.STRUCT,
|
|
12759
12774
|
size: types[typeName].length,
|
|
12760
12775
|
struct_name: typeName,
|
|
12761
12776
|
};
|
|
12762
12777
|
}
|
|
12763
|
-
throw
|
|
12778
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, `No type definition specified: ${typeName}`);
|
|
12764
12779
|
};
|
|
12765
12780
|
|
|
12766
12781
|
class EVMSignTypedData extends BaseMethod {
|
|
@@ -12787,7 +12802,7 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
12787
12802
|
this.params.messageHash = formatAnyHex(messageHash);
|
|
12788
12803
|
}
|
|
12789
12804
|
else if (!!data && (!data.primaryType || data.primaryType !== 'EIP712Domain')) {
|
|
12790
|
-
throw
|
|
12805
|
+
throw ERRORS.TypedError(HardwareErrorCode.CallMethodInvalidParameter, 'message_hash should only be empty when data.primaryType=EIP712Domain');
|
|
12791
12806
|
}
|
|
12792
12807
|
}
|
|
12793
12808
|
}
|
|
@@ -12809,7 +12824,7 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
12809
12824
|
const { name: typeDefinitionName } = response.message;
|
|
12810
12825
|
const typeDefinition = types[typeDefinitionName];
|
|
12811
12826
|
if (typeDefinition === undefined) {
|
|
12812
|
-
throw
|
|
12827
|
+
throw ERRORS.TypedError('Runtime', `Type ${typeDefinitionName} was not defined in types object`);
|
|
12813
12828
|
}
|
|
12814
12829
|
const dataStruckAck = {
|
|
12815
12830
|
members: typeDefinition.map(({ name, type: typeName }) => ({
|
|
@@ -12838,7 +12853,7 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
12838
12853
|
memberTypeName = primaryType;
|
|
12839
12854
|
break;
|
|
12840
12855
|
default:
|
|
12841
|
-
throw
|
|
12856
|
+
throw ERRORS.TypedError('Runtime', 'Root index can only be 0 or 1');
|
|
12842
12857
|
}
|
|
12843
12858
|
for (const index of nestedMemberPath) {
|
|
12844
12859
|
if (Array.isArray(memberData)) {
|
|
@@ -12864,7 +12879,7 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
12864
12879
|
});
|
|
12865
12880
|
}
|
|
12866
12881
|
if (response.type !== 'EthereumTypedDataSignature') {
|
|
12867
|
-
throw
|
|
12882
|
+
throw ERRORS.TypedError('Runtime', 'Unexpected response type');
|
|
12868
12883
|
}
|
|
12869
12884
|
const { address, signature } = response.message;
|
|
12870
12885
|
return {
|
|
@@ -12885,7 +12900,7 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
12885
12900
|
if (deviceType === 'classic' || deviceType === 'mini') {
|
|
12886
12901
|
const currentVersion = getDeviceFirmwareVersion(this.device.features).join('.');
|
|
12887
12902
|
const supportSignTypedVersion = '2.2.0';
|
|
12888
|
-
if (
|
|
12903
|
+
if (semver.lt(currentVersion, supportSignTypedVersion)) {
|
|
12889
12904
|
return false;
|
|
12890
12905
|
}
|
|
12891
12906
|
}
|
|
@@ -12894,7 +12909,7 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
12894
12909
|
run() {
|
|
12895
12910
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12896
12911
|
if (!this.device.features) {
|
|
12897
|
-
throw
|
|
12912
|
+
throw ERRORS.TypedError('Device_InitializeFailed', 'Device initialization failed. Please try again.');
|
|
12898
12913
|
}
|
|
12899
12914
|
const { addressN } = this.params;
|
|
12900
12915
|
const deviceType = getDeviceType(this.device.features);
|
|
@@ -13309,7 +13324,7 @@ class NEMSignTransaction extends BaseMethod {
|
|
|
13309
13324
|
message.supply_change = this.supplyChangeMessage(transaction);
|
|
13310
13325
|
break;
|
|
13311
13326
|
default:
|
|
13312
|
-
throw
|
|
13327
|
+
throw ERRORS.TypedError(HardwareErrorCode.CallMethodInvalidParameter, 'Unknown transaction type');
|
|
13313
13328
|
}
|
|
13314
13329
|
return message;
|
|
13315
13330
|
};
|
|
@@ -13647,11 +13662,11 @@ class StellarSignTransaction extends BaseMethod {
|
|
|
13647
13662
|
const getBinary = ({ features, updateType, version }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13648
13663
|
const releaseInfo = getInfo({ features, updateType });
|
|
13649
13664
|
if (!releaseInfo) {
|
|
13650
|
-
throw
|
|
13665
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'no firmware found for this device');
|
|
13651
13666
|
}
|
|
13652
13667
|
if (version &&
|
|
13653
|
-
!
|
|
13654
|
-
throw
|
|
13668
|
+
!semver.eq(releaseInfo.version, version)) {
|
|
13669
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'firmware version mismatch');
|
|
13655
13670
|
}
|
|
13656
13671
|
const url = updateType === 'ble' ? releaseInfo.webUpdate : releaseInfo.url;
|
|
13657
13672
|
let fw;
|
|
@@ -13659,7 +13674,7 @@ const getBinary = ({ features, updateType, version }) => __awaiter(void 0, void
|
|
|
13659
13674
|
fw = yield httpRequest(url, 'binary');
|
|
13660
13675
|
}
|
|
13661
13676
|
catch (_a) {
|
|
13662
|
-
throw
|
|
13677
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Method_FirmwareUpdate_DownloadFailed');
|
|
13663
13678
|
}
|
|
13664
13679
|
return Object.assign(Object.assign({}, releaseInfo), { binary: fw });
|
|
13665
13680
|
});
|
|
@@ -13714,7 +13729,7 @@ const uploadFirmware = (updateType, typedCall, postMessage, device, { payload })
|
|
|
13714
13729
|
postProgressMessage(device, 100, postMessage);
|
|
13715
13730
|
return response.message;
|
|
13716
13731
|
}
|
|
13717
|
-
throw
|
|
13732
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'uploadFirmware: unknown major_version');
|
|
13718
13733
|
});
|
|
13719
13734
|
|
|
13720
13735
|
class FirmwareUpdate extends BaseMethod {
|
|
@@ -13728,7 +13743,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
13728
13743
|
{ name: 'binary', type: 'buffer' },
|
|
13729
13744
|
]);
|
|
13730
13745
|
if (!payload.updateType) {
|
|
13731
|
-
throw
|
|
13746
|
+
throw ERRORS.TypedError(HardwareErrorCode.CallMethodInvalidParameter, 'updateType is required');
|
|
13732
13747
|
}
|
|
13733
13748
|
this.params = { updateType: payload.updateType };
|
|
13734
13749
|
if ('version' in payload) {
|
|
@@ -13749,7 +13764,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
13749
13764
|
}
|
|
13750
13765
|
else {
|
|
13751
13766
|
if (!device.features) {
|
|
13752
|
-
throw
|
|
13767
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'no features found for this device');
|
|
13753
13768
|
}
|
|
13754
13769
|
const firmware = yield getBinary({
|
|
13755
13770
|
features: device.features,
|
|
@@ -13760,14 +13775,14 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
13760
13775
|
}
|
|
13761
13776
|
}
|
|
13762
13777
|
catch (err) {
|
|
13763
|
-
throw
|
|
13778
|
+
throw ERRORS.TypedError(HardwareErrorCode.FirmwareUpdateDownloadFailed, (_a = err.message) !== null && _a !== void 0 ? _a : err);
|
|
13764
13779
|
}
|
|
13765
13780
|
return uploadFirmware(params.updateType, this.device.getCommands().typedCall.bind(this.device.getCommands()), this.postMessage, device, { payload: binary });
|
|
13766
13781
|
});
|
|
13767
13782
|
}
|
|
13768
13783
|
}
|
|
13769
13784
|
|
|
13770
|
-
const Log$2 = getLogger(
|
|
13785
|
+
const Log$2 = getLogger(LoggerNames.Method);
|
|
13771
13786
|
class RequestWebUsbDevice extends BaseMethod {
|
|
13772
13787
|
init() {
|
|
13773
13788
|
this.useDevice = false;
|
|
@@ -13779,7 +13794,7 @@ class RequestWebUsbDevice extends BaseMethod {
|
|
|
13779
13794
|
yield TransportManager.configure();
|
|
13780
13795
|
const env = DataManager.getSettings('env');
|
|
13781
13796
|
if (env !== 'webusb') {
|
|
13782
|
-
return Promise.reject(
|
|
13797
|
+
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Not webusb environment'));
|
|
13783
13798
|
}
|
|
13784
13799
|
try {
|
|
13785
13800
|
const deviceDiff = yield ((_a = this.connector) === null || _a === void 0 ? void 0 : _a.enumerate());
|
|
@@ -13788,11 +13803,11 @@ class RequestWebUsbDevice extends BaseMethod {
|
|
|
13788
13803
|
if (deviceList.length > 0) {
|
|
13789
13804
|
return { device: deviceList[0].toMessageObject() };
|
|
13790
13805
|
}
|
|
13791
|
-
return yield Promise.reject(
|
|
13806
|
+
return yield Promise.reject(ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Please select the device to connect'));
|
|
13792
13807
|
}
|
|
13793
13808
|
catch (error) {
|
|
13794
13809
|
Log$2.debug(error);
|
|
13795
|
-
return Promise.reject(
|
|
13810
|
+
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Please select the device to connect'));
|
|
13796
13811
|
}
|
|
13797
13812
|
});
|
|
13798
13813
|
}
|
|
@@ -13807,7 +13822,7 @@ class GetPassphraseState extends BaseMethod {
|
|
|
13807
13822
|
var _a, _b;
|
|
13808
13823
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13809
13824
|
if (!this.device.features)
|
|
13810
|
-
return Promise.reject(
|
|
13825
|
+
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceInitializeFailed));
|
|
13811
13826
|
let { features } = this.device;
|
|
13812
13827
|
const locked = ((_b = (_a = this.device) === null || _a === void 0 ? void 0 : _a.features) === null || _b === void 0 ? void 0 : _b.unlocked) === true;
|
|
13813
13828
|
const passphraseState = yield getPassphraseState(this.device.features, this.device.commands);
|
|
@@ -13889,27 +13904,27 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
|
|
|
13889
13904
|
function findMethod(message) {
|
|
13890
13905
|
const { method } = message.payload;
|
|
13891
13906
|
if (typeof method !== 'string') {
|
|
13892
|
-
throw
|
|
13907
|
+
throw ERRORS.TypedError(HardwareErrorCode.CallMethodInvalidParameter, 'Method is not set');
|
|
13893
13908
|
}
|
|
13894
13909
|
const MethodConstructor = ApiMethods[method];
|
|
13895
13910
|
if (MethodConstructor) {
|
|
13896
13911
|
return new MethodConstructor(message);
|
|
13897
13912
|
}
|
|
13898
|
-
throw
|
|
13913
|
+
throw ERRORS.TypedError(HardwareErrorCode.CallMethodInvalidParameter, `Method ${method} is not set`);
|
|
13899
13914
|
}
|
|
13900
13915
|
|
|
13901
13916
|
const safeThrowError = (error) => {
|
|
13902
|
-
if (error instanceof
|
|
13917
|
+
if (error instanceof HardwareError) {
|
|
13903
13918
|
throw error;
|
|
13904
13919
|
}
|
|
13905
13920
|
else if (error.code === 'ERR_NETWORK') {
|
|
13906
|
-
throw
|
|
13921
|
+
throw ERRORS.TypedError(HardwareErrorCode.BridgeNotInstalled);
|
|
13907
13922
|
}
|
|
13908
13923
|
else if (error.code === 'ECONNABORTED') {
|
|
13909
|
-
throw
|
|
13924
|
+
throw ERRORS.TypedError(HardwareErrorCode.BridgeTimeoutError);
|
|
13910
13925
|
}
|
|
13911
13926
|
else {
|
|
13912
|
-
throw
|
|
13927
|
+
throw ERRORS.TypedError(error);
|
|
13913
13928
|
}
|
|
13914
13929
|
};
|
|
13915
13930
|
|
|
@@ -13917,7 +13932,7 @@ const resolveAfter = (msec, value) => new Promise(resolve => {
|
|
|
13917
13932
|
setTimeout(resolve, msec, value);
|
|
13918
13933
|
});
|
|
13919
13934
|
|
|
13920
|
-
const Log$1 = getLogger(
|
|
13935
|
+
const Log$1 = getLogger(LoggerNames.DeviceConnector);
|
|
13921
13936
|
class DeviceConnector {
|
|
13922
13937
|
constructor() {
|
|
13923
13938
|
this.listenTimestamp = 0;
|
|
@@ -14014,7 +14029,7 @@ class DeviceConnector {
|
|
|
14014
14029
|
}
|
|
14015
14030
|
}
|
|
14016
14031
|
|
|
14017
|
-
const Log = getLogger(
|
|
14032
|
+
const Log = getLogger(LoggerNames.Core);
|
|
14018
14033
|
const parseInitOptions = (method) => ({
|
|
14019
14034
|
initSession: method === null || method === void 0 ? void 0 : method.payload.initSession,
|
|
14020
14035
|
passphraseState: method === null || method === void 0 ? void 0 : method.payload.passphraseState,
|
|
@@ -14035,7 +14050,7 @@ let preConnectCache = {
|
|
|
14035
14050
|
const callAPI = (message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14036
14051
|
var _a;
|
|
14037
14052
|
if (!message.id || !message.payload || message.type !== IFRAME.CALL) {
|
|
14038
|
-
return Promise.reject(
|
|
14053
|
+
return Promise.reject(ERRORS.TypedError('on call: message.id or message.payload is missing'));
|
|
14039
14054
|
}
|
|
14040
14055
|
let method;
|
|
14041
14056
|
let messageResponse;
|
|
@@ -14096,26 +14111,26 @@ const callAPI = (message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
14096
14111
|
const versionRange = versionRangeType !== null && versionRangeType !== void 0 ? versionRangeType : versionRangeModel;
|
|
14097
14112
|
if (versionRange && device.features) {
|
|
14098
14113
|
const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
14099
|
-
if (
|
|
14100
|
-
return Promise.reject(
|
|
14114
|
+
if (semver.valid(versionRange.min) && semver.lt(currentVersion, versionRange.min)) {
|
|
14115
|
+
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.CallMethodNeedUpgradeFirmware, `Device firmware version is too low, please update to ${versionRange.min}`, { current: currentVersion, require: versionRange.min }));
|
|
14101
14116
|
}
|
|
14102
14117
|
if (versionRange.max &&
|
|
14103
|
-
|
|
14104
|
-
|
|
14105
|
-
return Promise.reject(
|
|
14118
|
+
semver.valid(versionRange.max) &&
|
|
14119
|
+
semver.gte(currentVersion, versionRange.max)) {
|
|
14120
|
+
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.CallMethodDeprecated, `Device firmware version is too high, this method has been deprecated in ${versionRange.max}`, { current: currentVersion, deprecated: versionRange.max }));
|
|
14106
14121
|
}
|
|
14107
14122
|
}
|
|
14108
14123
|
const unexpectedMode = device.hasUnexpectedMode(method.allowDeviceMode, method.requireDeviceMode);
|
|
14109
14124
|
if (unexpectedMode) {
|
|
14110
14125
|
if (unexpectedMode === UI_REQUEST$1.NOT_IN_BOOTLOADER) {
|
|
14111
|
-
return Promise.reject(
|
|
14126
|
+
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceUnexpectedBootloaderMode));
|
|
14112
14127
|
}
|
|
14113
|
-
return Promise.reject(
|
|
14128
|
+
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceUnexpectedMode, unexpectedMode));
|
|
14114
14129
|
}
|
|
14115
14130
|
if (method.deviceId && method.checkDeviceId) {
|
|
14116
14131
|
const isSameDeviceID = device.checkDeviceId(method.deviceId);
|
|
14117
14132
|
if (!isSameDeviceID) {
|
|
14118
|
-
return Promise.reject(
|
|
14133
|
+
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceCheckDeviceIdError));
|
|
14119
14134
|
}
|
|
14120
14135
|
}
|
|
14121
14136
|
method.checkFirmwareRelease();
|
|
@@ -14127,7 +14142,7 @@ const callAPI = (message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
14127
14142
|
if (device.hasUsePassphrase() && method.useDevicePassphraseState) {
|
|
14128
14143
|
const support = supportNewPassphrase(device.features);
|
|
14129
14144
|
if (!support.support) {
|
|
14130
|
-
return Promise.reject(
|
|
14145
|
+
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceNotSupportPassphrase, `Device not support passphrase, please update to ${support.require}`, {
|
|
14131
14146
|
require: support.require,
|
|
14132
14147
|
}));
|
|
14133
14148
|
}
|
|
@@ -14135,9 +14150,20 @@ const callAPI = (message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
14135
14150
|
checkPassphraseSafety(method, device.features);
|
|
14136
14151
|
if (passphraseState) {
|
|
14137
14152
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
14138
|
-
return Promise.reject(
|
|
14153
|
+
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceCheckPassphraseStateError));
|
|
14139
14154
|
}
|
|
14140
14155
|
}
|
|
14156
|
+
try {
|
|
14157
|
+
yield method.checkSafetyLevelOnTestNet();
|
|
14158
|
+
}
|
|
14159
|
+
catch (e) {
|
|
14160
|
+
const error = e instanceof HardwareError
|
|
14161
|
+
? e
|
|
14162
|
+
: ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'open safety check failed.');
|
|
14163
|
+
messageResponse = createResponseMessage(method.responseID, false, { error });
|
|
14164
|
+
_callPromise === null || _callPromise === void 0 ? void 0 : _callPromise.resolve(messageResponse);
|
|
14165
|
+
return;
|
|
14166
|
+
}
|
|
14141
14167
|
try {
|
|
14142
14168
|
const response = yield method.run();
|
|
14143
14169
|
Log.debug('Call API - Inner Method Run: ');
|
|
@@ -14153,7 +14179,7 @@ const callAPI = (message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
14153
14179
|
Log.debug('Call API - Device Run: ', device.mainId);
|
|
14154
14180
|
const runOptions = Object.assign({ keepSession: method.payload.keepSession }, parseInitOptions(method));
|
|
14155
14181
|
const deviceRun = () => device.run(inner, runOptions);
|
|
14156
|
-
_callPromise =
|
|
14182
|
+
_callPromise = createDeferred(deviceRun);
|
|
14157
14183
|
try {
|
|
14158
14184
|
return yield _callPromise.promise;
|
|
14159
14185
|
}
|
|
@@ -14164,7 +14190,7 @@ const callAPI = (message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
14164
14190
|
}
|
|
14165
14191
|
catch (error) {
|
|
14166
14192
|
messageResponse = createResponseMessage(method.responseID, false, { error });
|
|
14167
|
-
_callPromise === null || _callPromise === void 0 ? void 0 : _callPromise.reject(
|
|
14193
|
+
_callPromise === null || _callPromise === void 0 ? void 0 : _callPromise.reject(ERRORS.TypedError(HardwareErrorCode.CallMethodError, error.message));
|
|
14168
14194
|
Log.debug('Call API - Run Error: ', error);
|
|
14169
14195
|
}
|
|
14170
14196
|
finally {
|
|
@@ -14203,7 +14229,7 @@ function initDeviceList(method) {
|
|
|
14203
14229
|
}
|
|
14204
14230
|
function initDevice(method) {
|
|
14205
14231
|
if (!_deviceList) {
|
|
14206
|
-
throw
|
|
14232
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceListNotInitialized);
|
|
14207
14233
|
}
|
|
14208
14234
|
let device;
|
|
14209
14235
|
const allDevices = _deviceList.allDevices();
|
|
@@ -14214,17 +14240,17 @@ function initDevice(method) {
|
|
|
14214
14240
|
[device] = allDevices;
|
|
14215
14241
|
}
|
|
14216
14242
|
else if (allDevices.length > 1) {
|
|
14217
|
-
throw
|
|
14243
|
+
throw ERRORS.TypedError(HardwareErrorCode.SelectDevice);
|
|
14218
14244
|
}
|
|
14219
14245
|
if (!device) {
|
|
14220
|
-
throw
|
|
14246
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceNotFound);
|
|
14221
14247
|
}
|
|
14222
14248
|
device.deviceConnector = _connector;
|
|
14223
14249
|
return device;
|
|
14224
14250
|
}
|
|
14225
14251
|
function initDeviceForBle(method) {
|
|
14226
14252
|
if (!method.connectId && !_deviceList) {
|
|
14227
|
-
throw
|
|
14253
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceListNotInitialized);
|
|
14228
14254
|
}
|
|
14229
14255
|
if (!method.connectId) {
|
|
14230
14256
|
return initDevice(method);
|
|
@@ -14251,14 +14277,14 @@ const ensureConnected = (method, pollingId) => __awaiter(void 0, void 0, void 0,
|
|
|
14251
14277
|
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14252
14278
|
if (!pollingState[pollingId]) {
|
|
14253
14279
|
Log.debug('EnsureConnected function stop, polling id: ', pollingId);
|
|
14254
|
-
reject(
|
|
14280
|
+
reject(ERRORS.TypedError(HardwareErrorCode.PollingStop));
|
|
14255
14281
|
return;
|
|
14256
14282
|
}
|
|
14257
14283
|
if (timer) {
|
|
14258
14284
|
clearTimeout(timer);
|
|
14259
14285
|
}
|
|
14260
14286
|
timer = setTimeout(() => {
|
|
14261
|
-
reject(
|
|
14287
|
+
reject(ERRORS.TypedError(HardwareErrorCode.PollingTimeout));
|
|
14262
14288
|
}, TIME_OUT);
|
|
14263
14289
|
tryCount += 1;
|
|
14264
14290
|
Log.debug('EnsureConnected function try count: ', tryCount, ' poll interval time: ', time);
|
|
@@ -14267,12 +14293,12 @@ const ensureConnected = (method, pollingId) => __awaiter(void 0, void 0, void 0,
|
|
|
14267
14293
|
}
|
|
14268
14294
|
catch (error) {
|
|
14269
14295
|
Log.debug('device list error: ', error);
|
|
14270
|
-
if ([
|
|
14296
|
+
if ([HardwareErrorCode.BridgeNotInstalled, HardwareErrorCode.BridgeTimeoutError].includes(error.errorCode)) {
|
|
14271
14297
|
_deviceList = undefined;
|
|
14272
14298
|
reject(error);
|
|
14273
14299
|
return;
|
|
14274
14300
|
}
|
|
14275
|
-
if (error.errorCode ===
|
|
14301
|
+
if (error.errorCode === HardwareErrorCode.TransportNotConfigured) {
|
|
14276
14302
|
yield TransportManager.configure();
|
|
14277
14303
|
}
|
|
14278
14304
|
}
|
|
@@ -14300,12 +14326,12 @@ const ensureConnected = (method, pollingId) => __awaiter(void 0, void 0, void 0,
|
|
|
14300
14326
|
catch (error) {
|
|
14301
14327
|
Log.debug('device error: ', error);
|
|
14302
14328
|
if ([
|
|
14303
|
-
|
|
14304
|
-
|
|
14305
|
-
|
|
14306
|
-
|
|
14307
|
-
|
|
14308
|
-
|
|
14329
|
+
HardwareErrorCode.BlePermissionError,
|
|
14330
|
+
HardwareErrorCode.BleLocationError,
|
|
14331
|
+
HardwareErrorCode.BleDeviceNotBonded,
|
|
14332
|
+
HardwareErrorCode.BleCharacteristicNotifyError,
|
|
14333
|
+
HardwareErrorCode.BleWriteCharacteristicError,
|
|
14334
|
+
HardwareErrorCode.BleAlreadyConnected,
|
|
14309
14335
|
].includes(error.errorCode)) {
|
|
14310
14336
|
reject(error);
|
|
14311
14337
|
return;
|
|
@@ -14316,7 +14342,7 @@ const ensureConnected = (method, pollingId) => __awaiter(void 0, void 0, void 0,
|
|
|
14316
14342
|
clearTimeout(timer);
|
|
14317
14343
|
}
|
|
14318
14344
|
Log.debug('EnsureConnected get to max try count, will return: ', tryCount);
|
|
14319
|
-
reject(
|
|
14345
|
+
reject(ERRORS.TypedError(HardwareErrorCode.DeviceNotFound));
|
|
14320
14346
|
return;
|
|
14321
14347
|
}
|
|
14322
14348
|
return setTimeout(() => resolve(poll(time * 1.5)), time);
|
|
@@ -14350,11 +14376,11 @@ const checkPassphraseSafety = (method, features) => {
|
|
|
14350
14376
|
return;
|
|
14351
14377
|
if ((features === null || features === void 0 ? void 0 : features.passphrase_protection) === true && !method.payload.passphraseState) {
|
|
14352
14378
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
14353
|
-
throw
|
|
14379
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceOpenedPassphrase);
|
|
14354
14380
|
}
|
|
14355
14381
|
if ((features === null || features === void 0 ? void 0 : features.passphrase_protection) === false && method.payload.passphraseState) {
|
|
14356
14382
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
14357
|
-
throw
|
|
14383
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceNotOpenedPassphrase);
|
|
14358
14384
|
}
|
|
14359
14385
|
};
|
|
14360
14386
|
const cleanup = () => {
|
|
@@ -14416,7 +14442,7 @@ const postMessage = (message) => {
|
|
|
14416
14442
|
_core.emit(CORE_EVENT, message);
|
|
14417
14443
|
};
|
|
14418
14444
|
const createUiPromise = (promiseEvent, device) => {
|
|
14419
|
-
const uiPromise =
|
|
14445
|
+
const uiPromise = createDeferred(promiseEvent, device);
|
|
14420
14446
|
_uiPromises.push(uiPromise);
|
|
14421
14447
|
return uiPromise;
|
|
14422
14448
|
};
|
|
@@ -14499,56 +14525,4 @@ const HardwareSdk = ({ init, call, dispose, eventEmitter, uiResponse, cancel, })
|
|
|
14499
14525
|
cancel,
|
|
14500
14526
|
});
|
|
14501
14527
|
|
|
14502
|
-
|
|
14503
|
-
enumerable: true,
|
|
14504
|
-
get: function () { return hdTransport.Messages; }
|
|
14505
|
-
});
|
|
14506
|
-
exports.CORE_EVENT = CORE_EVENT;
|
|
14507
|
-
exports.Core = Core;
|
|
14508
|
-
exports.DEFAULT_PRIORITY = DEFAULT_PRIORITY;
|
|
14509
|
-
exports.DEVICE = DEVICE;
|
|
14510
|
-
exports.DEVICE_EVENT = DEVICE_EVENT;
|
|
14511
|
-
exports.DataManager = DataManager;
|
|
14512
|
-
exports.FIRMWARE = FIRMWARE;
|
|
14513
|
-
exports.FIRMWARE_EVENT = FIRMWARE_EVENT;
|
|
14514
|
-
exports.IFRAME = IFRAME;
|
|
14515
|
-
exports.LOG = LOG;
|
|
14516
|
-
exports.LOG_EVENT = LOG_EVENT;
|
|
14517
|
-
exports.RESPONSE_EVENT = RESPONSE_EVENT;
|
|
14518
|
-
exports.UI_EVENT = UI_EVENT;
|
|
14519
|
-
exports.UI_REQUEST = UI_REQUEST$1;
|
|
14520
|
-
exports.UI_RESPONSE = UI_RESPONSE;
|
|
14521
|
-
exports.corsValidator = corsValidator;
|
|
14522
|
-
exports.createDeviceMessage = createDeviceMessage;
|
|
14523
|
-
exports.createErrorMessage = createErrorMessage;
|
|
14524
|
-
exports.createFirmwareMessage = createFirmwareMessage;
|
|
14525
|
-
exports.createIFrameMessage = createIFrameMessage;
|
|
14526
|
-
exports.createLogMessage = createLogMessage;
|
|
14527
|
-
exports.createResponseMessage = createResponseMessage;
|
|
14528
|
-
exports.createUiMessage = createUiMessage;
|
|
14529
|
-
exports.createUiResponse = createUiResponse;
|
|
14530
|
-
exports["default"] = HardwareSdk;
|
|
14531
|
-
exports.enableLog = enableLog;
|
|
14532
|
-
exports.getDeviceLabel = getDeviceLabel;
|
|
14533
|
-
exports.getDeviceType = getDeviceType;
|
|
14534
|
-
exports.getDeviceTypeByBleName = getDeviceTypeByBleName;
|
|
14535
|
-
exports.getDeviceTypeByDeviceId = getDeviceTypeByDeviceId;
|
|
14536
|
-
exports.getDeviceUUID = getDeviceUUID;
|
|
14537
|
-
exports.getEnv = getEnv;
|
|
14538
|
-
exports.getHDPath = getHDPath;
|
|
14539
|
-
exports.getLog = getLog;
|
|
14540
|
-
exports.getLogger = getLogger;
|
|
14541
|
-
exports.getScriptType = getScriptType;
|
|
14542
|
-
exports.getTimeStamp = getTimeStamp;
|
|
14543
|
-
exports.httpRequest = httpRequest;
|
|
14544
|
-
exports.initCore = init;
|
|
14545
|
-
exports.isValidVersionArray = isValidVersionArray;
|
|
14546
|
-
exports.isValidVersionString = isValidVersionString;
|
|
14547
|
-
exports.normalizeVersionArray = normalizeVersionArray;
|
|
14548
|
-
exports.parseConnectSettings = parseConnectSettings;
|
|
14549
|
-
exports.parseMessage = parseMessage;
|
|
14550
|
-
exports.patchFeatures = patchFeatures;
|
|
14551
|
-
exports.safeThrowError = safeThrowError;
|
|
14552
|
-
exports.setLoggerPostMessage = setLoggerPostMessage;
|
|
14553
|
-
exports.versionCompare = versionCompare;
|
|
14554
|
-
exports.versionSplit = versionSplit;
|
|
14528
|
+
export { CORE_EVENT, Core, DEFAULT_PRIORITY, DEVICE, DEVICE_EVENT, DataManager, FIRMWARE, FIRMWARE_EVENT, IFRAME, LOG, LOG_EVENT, LoggerNames, RESPONSE_EVENT, UI_EVENT, UI_REQUEST$1 as UI_REQUEST, UI_RESPONSE, corsValidator, createDeviceMessage, createErrorMessage, createFirmwareMessage, createIFrameMessage, createLogMessage, createResponseMessage, createUiMessage, createUiResponse, HardwareSdk as default, enableLog, getDeviceLabel, getDeviceType, getDeviceTypeByBleName, getDeviceTypeByDeviceId, getDeviceUUID, getEnv, getHDPath, getLog, getLogger, getScriptType, getTimeStamp, httpRequest, init as initCore, isValidVersionArray, isValidVersionString, normalizeVersionArray, parseConnectSettings, parseMessage, patchFeatures, safeThrowError, setLoggerPostMessage, versionCompare, versionSplit };
|