@onekeyfe/hd-web-sdk 0.1.17 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/iframe.html +1 -1
- package/build/js/iframe.7f142b7c642aad17648d.js +3 -0
- package/build/js/{iframe.bc96e38a35b7448d677b.js.LICENSE.txt → iframe.7f142b7c642aad17648d.js.LICENSE.txt} +0 -0
- package/build/js/iframe.7f142b7c642aad17648d.js.map +1 -0
- package/build/onekey-js-sdk.js +331 -92
- package/build/onekey-js-sdk.js.map +1 -1
- package/build/onekey-js-sdk.min.js +1 -1
- package/build/onekey-js-sdk.min.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +2 -0
- package/build/js/iframe.bc96e38a35b7448d677b.js +0 -3
- package/build/js/iframe.bc96e38a35b7448d677b.js.map +0 -1
package/build/onekey-js-sdk.js
CHANGED
|
@@ -4096,8 +4096,9 @@ const inject = ({
|
|
|
4096
4096
|
checkBridgeStatus: () => call({
|
|
4097
4097
|
method: 'checkBridgeStatus'
|
|
4098
4098
|
}),
|
|
4099
|
-
cipherKeyValue: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4099
|
+
cipherKeyValue: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4100
4100
|
connectId,
|
|
4101
|
+
deviceId,
|
|
4101
4102
|
method: 'cipherKeyValue'
|
|
4102
4103
|
})),
|
|
4103
4104
|
deviceBackup: connectId => call({
|
|
@@ -4140,96 +4141,119 @@ const inject = ({
|
|
|
4140
4141
|
connectId,
|
|
4141
4142
|
method: 'deviceWipe'
|
|
4142
4143
|
}),
|
|
4143
|
-
evmGetAddress: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4144
|
+
evmGetAddress: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4144
4145
|
connectId,
|
|
4146
|
+
deviceId,
|
|
4145
4147
|
method: 'evmGetAddress'
|
|
4146
4148
|
})),
|
|
4147
|
-
evmGetPublicKey: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4149
|
+
evmGetPublicKey: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4148
4150
|
connectId,
|
|
4151
|
+
deviceId,
|
|
4149
4152
|
method: 'evmGetPublicKey'
|
|
4150
4153
|
})),
|
|
4151
|
-
evmSignMessage: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4154
|
+
evmSignMessage: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4152
4155
|
connectId,
|
|
4156
|
+
deviceId,
|
|
4153
4157
|
method: 'evmSignMessage'
|
|
4154
4158
|
})),
|
|
4155
|
-
evmSignMessageEIP712: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4159
|
+
evmSignMessageEIP712: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4156
4160
|
connectId,
|
|
4161
|
+
deviceId,
|
|
4157
4162
|
method: 'evmSignMessageEIP712'
|
|
4158
4163
|
})),
|
|
4159
|
-
evmSignTransaction: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4164
|
+
evmSignTransaction: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4160
4165
|
connectId,
|
|
4166
|
+
deviceId,
|
|
4161
4167
|
method: 'evmSignTransaction'
|
|
4162
4168
|
})),
|
|
4163
|
-
evmSignTypedData: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4169
|
+
evmSignTypedData: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4164
4170
|
connectId,
|
|
4171
|
+
deviceId,
|
|
4165
4172
|
method: 'evmSignTypedData'
|
|
4166
4173
|
})),
|
|
4167
|
-
evmVerifyMessage: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4174
|
+
evmVerifyMessage: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4168
4175
|
connectId,
|
|
4176
|
+
deviceId,
|
|
4169
4177
|
method: 'evmVerifyMessage'
|
|
4170
4178
|
})),
|
|
4171
|
-
btcGetAddress: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4179
|
+
btcGetAddress: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4172
4180
|
connectId,
|
|
4181
|
+
deviceId,
|
|
4173
4182
|
method: 'btcGetAddress'
|
|
4174
4183
|
})),
|
|
4175
|
-
btcGetPublicKey: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4184
|
+
btcGetPublicKey: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4176
4185
|
connectId,
|
|
4186
|
+
deviceId,
|
|
4177
4187
|
method: 'btcGetPublicKey'
|
|
4178
4188
|
})),
|
|
4179
|
-
btcSignMessage: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4189
|
+
btcSignMessage: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4180
4190
|
connectId,
|
|
4191
|
+
deviceId,
|
|
4181
4192
|
method: 'btcSignMessage'
|
|
4182
4193
|
})),
|
|
4183
|
-
btcSignTransaction: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4194
|
+
btcSignTransaction: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4184
4195
|
connectId,
|
|
4196
|
+
deviceId,
|
|
4185
4197
|
method: 'btcSignTransaction'
|
|
4186
4198
|
})),
|
|
4187
|
-
btcVerifyMessage: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4199
|
+
btcVerifyMessage: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4188
4200
|
connectId,
|
|
4201
|
+
deviceId,
|
|
4189
4202
|
method: 'btcVerifyMessage'
|
|
4190
4203
|
})),
|
|
4191
|
-
starcoinGetAddress: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4204
|
+
starcoinGetAddress: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4192
4205
|
connectId,
|
|
4206
|
+
deviceId,
|
|
4193
4207
|
method: 'starcoinGetAddress'
|
|
4194
4208
|
})),
|
|
4195
|
-
starcoinGetPublicKey: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4209
|
+
starcoinGetPublicKey: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4196
4210
|
connectId,
|
|
4211
|
+
deviceId,
|
|
4197
4212
|
method: 'starcoinGetPublicKey'
|
|
4198
4213
|
})),
|
|
4199
|
-
starcoinSignMessage: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4214
|
+
starcoinSignMessage: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4200
4215
|
connectId,
|
|
4216
|
+
deviceId,
|
|
4201
4217
|
method: 'starcoinSignMessage'
|
|
4202
4218
|
})),
|
|
4203
|
-
starcoinSignTransaction: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4219
|
+
starcoinSignTransaction: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4204
4220
|
connectId,
|
|
4221
|
+
deviceId,
|
|
4205
4222
|
method: 'starcoinSignTransaction'
|
|
4206
4223
|
})),
|
|
4207
|
-
starcoinVerifyMessage: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4224
|
+
starcoinVerifyMessage: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4208
4225
|
connectId,
|
|
4226
|
+
deviceId,
|
|
4209
4227
|
method: 'starcoinVerifyMessage'
|
|
4210
4228
|
})),
|
|
4211
|
-
nemGetAddress: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4229
|
+
nemGetAddress: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4212
4230
|
connectId,
|
|
4231
|
+
deviceId,
|
|
4213
4232
|
method: 'nemGetAddress'
|
|
4214
4233
|
})),
|
|
4215
|
-
nemSignTransaction: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4234
|
+
nemSignTransaction: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4216
4235
|
connectId,
|
|
4236
|
+
deviceId,
|
|
4217
4237
|
method: 'nemSignTransaction'
|
|
4218
4238
|
})),
|
|
4219
|
-
solGetAddress: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4239
|
+
solGetAddress: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4220
4240
|
connectId,
|
|
4241
|
+
deviceId,
|
|
4221
4242
|
method: 'solGetAddress'
|
|
4222
4243
|
})),
|
|
4223
|
-
solSignTransaction: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4244
|
+
solSignTransaction: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4224
4245
|
connectId,
|
|
4246
|
+
deviceId,
|
|
4225
4247
|
method: 'solSignTransaction'
|
|
4226
4248
|
})),
|
|
4227
|
-
stellarGetAddress: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4249
|
+
stellarGetAddress: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4228
4250
|
connectId,
|
|
4251
|
+
deviceId,
|
|
4229
4252
|
method: 'stellarGetAddress'
|
|
4230
4253
|
})),
|
|
4231
|
-
stellarSignTransaction: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4254
|
+
stellarSignTransaction: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4232
4255
|
connectId,
|
|
4256
|
+
deviceId,
|
|
4233
4257
|
method: 'stellarSignTransaction'
|
|
4234
4258
|
})),
|
|
4235
4259
|
firmwareUpdate: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
@@ -14335,6 +14359,18 @@ const createDeviceMessage = (type, payload) => ({
|
|
|
14335
14359
|
payload
|
|
14336
14360
|
});
|
|
14337
14361
|
|
|
14362
|
+
const FIRMWARE_EVENT = 'FIRMWARE_EVENT';
|
|
14363
|
+
const FIRMWARE = {
|
|
14364
|
+
RELEASE_INFO: 'firmware-release-info',
|
|
14365
|
+
BLE_RELEASE_INFO: 'ble-firmware-release-info'
|
|
14366
|
+
};
|
|
14367
|
+
|
|
14368
|
+
const createFirmwareMessage = (type, payload) => ({
|
|
14369
|
+
event: FIRMWARE_EVENT,
|
|
14370
|
+
type,
|
|
14371
|
+
payload
|
|
14372
|
+
});
|
|
14373
|
+
|
|
14338
14374
|
const assertType = (res, resType) => {
|
|
14339
14375
|
const splitResTypes = Array.isArray(resType) ? resType : resType.split('|');
|
|
14340
14376
|
|
|
@@ -14353,17 +14389,19 @@ class DeviceCommands {
|
|
|
14353
14389
|
this.disposed = false;
|
|
14354
14390
|
}
|
|
14355
14391
|
|
|
14356
|
-
dispose() {
|
|
14392
|
+
dispose(cancelRequest) {
|
|
14357
14393
|
var _a, _b;
|
|
14358
14394
|
|
|
14359
|
-
this
|
|
14395
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14396
|
+
this.disposed = true;
|
|
14360
14397
|
|
|
14361
|
-
|
|
14362
|
-
|
|
14363
|
-
|
|
14398
|
+
if (cancelRequest && this._cancelableRequest) {
|
|
14399
|
+
this._cancelableRequest();
|
|
14400
|
+
}
|
|
14364
14401
|
|
|
14365
|
-
|
|
14366
|
-
|
|
14402
|
+
this._cancelableRequest = undefined;
|
|
14403
|
+
yield (_b = (_a = this.transport).cancel) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
14404
|
+
});
|
|
14367
14405
|
}
|
|
14368
14406
|
|
|
14369
14407
|
call(type, msg = {}) {
|
|
@@ -14491,7 +14529,12 @@ class DeviceCommands {
|
|
|
14491
14529
|
}, () => this._commonCall('Cancel', {}));
|
|
14492
14530
|
}
|
|
14493
14531
|
|
|
14494
|
-
if (res.type === 'PassphraseRequest')
|
|
14532
|
+
if (res.type === 'PassphraseRequest') {
|
|
14533
|
+
return this._commonCall('PassphraseAck', {
|
|
14534
|
+
passphrase: ''
|
|
14535
|
+
});
|
|
14536
|
+
}
|
|
14537
|
+
|
|
14495
14538
|
if (res.type === 'Deprecated_PassphraseStateRequest') ;
|
|
14496
14539
|
if (res.type === 'WordRequest') ;
|
|
14497
14540
|
return Promise.resolve(res);
|
|
@@ -14729,7 +14772,7 @@ class Device extends events.exports {
|
|
|
14729
14772
|
});
|
|
14730
14773
|
|
|
14731
14774
|
if (this.commands) {
|
|
14732
|
-
this.commands.dispose();
|
|
14775
|
+
yield this.commands.dispose(false);
|
|
14733
14776
|
}
|
|
14734
14777
|
|
|
14735
14778
|
this.commands = new DeviceCommands(this, (_d = this.mainId) !== null && _d !== void 0 ? _d : '');
|
|
@@ -14753,7 +14796,7 @@ class Device extends events.exports {
|
|
|
14753
14796
|
|
|
14754
14797
|
if (this.isUsedHere() && !this.keepSession && this.mainId || this.mainId && env === 'react-native') {
|
|
14755
14798
|
if (this.commands) {
|
|
14756
|
-
this.commands.dispose();
|
|
14799
|
+
this.commands.dispose(false);
|
|
14757
14800
|
|
|
14758
14801
|
if (this.commands.callPromise) {
|
|
14759
14802
|
try {
|
|
@@ -14859,7 +14902,7 @@ class Device extends events.exports {
|
|
|
14859
14902
|
run(fn, options) {
|
|
14860
14903
|
return __awaiter(this, void 0, void 0, function* () {
|
|
14861
14904
|
if (this.runPromise) {
|
|
14862
|
-
this.
|
|
14905
|
+
yield this.interruptionFromOutside();
|
|
14863
14906
|
Log$3.debug('[Device] run error:', 'Device is running, but will cancel previous operate');
|
|
14864
14907
|
}
|
|
14865
14908
|
|
|
@@ -14906,14 +14949,28 @@ class Device extends events.exports {
|
|
|
14906
14949
|
});
|
|
14907
14950
|
}
|
|
14908
14951
|
|
|
14909
|
-
|
|
14910
|
-
|
|
14911
|
-
this.commands
|
|
14912
|
-
|
|
14952
|
+
interruptionFromOutside() {
|
|
14953
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14954
|
+
if (this.commands) {
|
|
14955
|
+
yield this.commands.dispose(false);
|
|
14956
|
+
}
|
|
14913
14957
|
|
|
14914
|
-
|
|
14915
|
-
|
|
14916
|
-
|
|
14958
|
+
if (this.runPromise) {
|
|
14959
|
+
this.runPromise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInterruptedFromOutside));
|
|
14960
|
+
}
|
|
14961
|
+
});
|
|
14962
|
+
}
|
|
14963
|
+
|
|
14964
|
+
interruptionFromUser() {
|
|
14965
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14966
|
+
if (this.commands) {
|
|
14967
|
+
yield this.commands.dispose(true);
|
|
14968
|
+
}
|
|
14969
|
+
|
|
14970
|
+
if (this.runPromise) {
|
|
14971
|
+
this.runPromise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInterruptedFromUser));
|
|
14972
|
+
}
|
|
14973
|
+
});
|
|
14917
14974
|
}
|
|
14918
14975
|
|
|
14919
14976
|
getMode() {
|
|
@@ -14991,9 +15048,17 @@ class Device extends events.exports {
|
|
|
14991
15048
|
return null;
|
|
14992
15049
|
}
|
|
14993
15050
|
|
|
15051
|
+
checkDeviceId(deviceId) {
|
|
15052
|
+
if (this.features) {
|
|
15053
|
+
return this.features.device_id === deviceId;
|
|
15054
|
+
}
|
|
15055
|
+
|
|
15056
|
+
return false;
|
|
15057
|
+
}
|
|
15058
|
+
|
|
14994
15059
|
}
|
|
14995
15060
|
|
|
14996
|
-
const cacheDeviceMap =
|
|
15061
|
+
const cacheDeviceMap = {};
|
|
14997
15062
|
const Log$2 = getLogger(exports.d0.DeviceList);
|
|
14998
15063
|
|
|
14999
15064
|
class DeviceList extends events.exports {
|
|
@@ -15002,7 +15067,7 @@ class DeviceList extends events.exports {
|
|
|
15002
15067
|
this.devices = {};
|
|
15003
15068
|
}
|
|
15004
15069
|
|
|
15005
|
-
getDeviceLists() {
|
|
15070
|
+
getDeviceLists(connectId) {
|
|
15006
15071
|
var e_1, _a;
|
|
15007
15072
|
|
|
15008
15073
|
var _b, _c;
|
|
@@ -15014,6 +15079,21 @@ class DeviceList extends events.exports {
|
|
|
15014
15079
|
const deviceList = [];
|
|
15015
15080
|
Log$2.debug('get device list');
|
|
15016
15081
|
|
|
15082
|
+
if (connectId) {
|
|
15083
|
+
const device = cacheDeviceMap[connectId];
|
|
15084
|
+
|
|
15085
|
+
if (device) {
|
|
15086
|
+
const exist = descriptorList.find(d => d.path === device.originalDescriptor.path);
|
|
15087
|
+
|
|
15088
|
+
if (exist) {
|
|
15089
|
+
device.updateDescriptor(exist, true);
|
|
15090
|
+
Log$2.debug('find existed Device: ', connectId);
|
|
15091
|
+
this.devices[connectId] = device;
|
|
15092
|
+
return [device];
|
|
15093
|
+
}
|
|
15094
|
+
}
|
|
15095
|
+
}
|
|
15096
|
+
|
|
15017
15097
|
try {
|
|
15018
15098
|
for (var descriptorList_1 = __asyncValues(descriptorList), descriptorList_1_1; descriptorList_1_1 = yield descriptorList_1.next(), !descriptorList_1_1.done;) {
|
|
15019
15099
|
const descriptor = descriptorList_1_1.value;
|
|
@@ -15027,15 +15107,14 @@ class DeviceList extends events.exports {
|
|
|
15027
15107
|
if (device.features) {
|
|
15028
15108
|
const uuid = getDeviceUUID(device.features);
|
|
15029
15109
|
|
|
15030
|
-
if (cacheDeviceMap
|
|
15031
|
-
const cache = cacheDeviceMap
|
|
15110
|
+
if (cacheDeviceMap[uuid]) {
|
|
15111
|
+
const cache = cacheDeviceMap[uuid];
|
|
15032
15112
|
cache === null || cache === void 0 ? void 0 : cache.updateFromCache(device);
|
|
15033
15113
|
device = cache;
|
|
15034
|
-
Log$2.debug('use cache device: ', uuid);
|
|
15035
15114
|
}
|
|
15036
15115
|
|
|
15037
15116
|
this.devices[uuid] = device;
|
|
15038
|
-
cacheDeviceMap
|
|
15117
|
+
cacheDeviceMap[uuid] = device;
|
|
15039
15118
|
}
|
|
15040
15119
|
}
|
|
15041
15120
|
} catch (e_1_1) {
|
|
@@ -15064,8 +15143,32 @@ class DeviceList extends events.exports {
|
|
|
15064
15143
|
|
|
15065
15144
|
}
|
|
15066
15145
|
|
|
15146
|
+
const getFirmwareReleaseInfo = features => {
|
|
15147
|
+
const firmwareStatus = DataManager.getFirmwareStatus(features);
|
|
15148
|
+
const changelog = DataManager.getFirmwareChangelog(features);
|
|
15149
|
+
const release = DataManager.getFirmwareLeatestRelease(features);
|
|
15150
|
+
return {
|
|
15151
|
+
status: firmwareStatus,
|
|
15152
|
+
changelog,
|
|
15153
|
+
release
|
|
15154
|
+
};
|
|
15155
|
+
};
|
|
15156
|
+
|
|
15157
|
+
const getBleFirmwareReleaseInfo = features => {
|
|
15158
|
+
const firmwareStatus = DataManager.getBLEFirmwareStatus(features);
|
|
15159
|
+
const changelog = DataManager.getBleFirmwareChangelog(features);
|
|
15160
|
+
const release = DataManager.getBleFirmwareLeatestRelease(features);
|
|
15161
|
+
return {
|
|
15162
|
+
status: firmwareStatus,
|
|
15163
|
+
changelog,
|
|
15164
|
+
release
|
|
15165
|
+
};
|
|
15166
|
+
};
|
|
15167
|
+
|
|
15067
15168
|
class BaseMethod {
|
|
15068
15169
|
constructor(message) {
|
|
15170
|
+
this.shouldEnsureConnected = true;
|
|
15171
|
+
this.checkDeviceId = false;
|
|
15069
15172
|
const {
|
|
15070
15173
|
payload
|
|
15071
15174
|
} = message;
|
|
@@ -15073,6 +15176,7 @@ class BaseMethod {
|
|
|
15073
15176
|
this.payload = payload;
|
|
15074
15177
|
this.responseID = message.id || 0;
|
|
15075
15178
|
this.connectId = payload.connectId || '';
|
|
15179
|
+
this.deviceId = payload.deviceId || '';
|
|
15076
15180
|
this.useDevice = true;
|
|
15077
15181
|
this.allowDeviceMode = [UI_REQUEST.INITIALIZE];
|
|
15078
15182
|
this.requireDeviceMode = [];
|
|
@@ -15087,6 +15191,21 @@ class BaseMethod {
|
|
|
15087
15191
|
this.connectId = device.originalDescriptor.path;
|
|
15088
15192
|
}
|
|
15089
15193
|
|
|
15194
|
+
checkFirmwareRelease() {
|
|
15195
|
+
if (!this.device || !this.device.features) return;
|
|
15196
|
+
const releaseInfo = getFirmwareReleaseInfo(this.device.features);
|
|
15197
|
+
|
|
15198
|
+
if (['outdated', 'required'].includes(releaseInfo.status)) {
|
|
15199
|
+
this.postMessage(createFirmwareMessage(FIRMWARE.RELEASE_INFO, releaseInfo));
|
|
15200
|
+
}
|
|
15201
|
+
|
|
15202
|
+
const bleReleaseInfo = getBleFirmwareReleaseInfo(this.device.features);
|
|
15203
|
+
|
|
15204
|
+
if (['outdated', 'required'].includes(bleReleaseInfo.status)) {
|
|
15205
|
+
this.postMessage(createFirmwareMessage(FIRMWARE.BLE_RELEASE_INFO, bleReleaseInfo));
|
|
15206
|
+
}
|
|
15207
|
+
}
|
|
15208
|
+
|
|
15090
15209
|
dispose() {}
|
|
15091
15210
|
|
|
15092
15211
|
}
|
|
@@ -16416,14 +16535,8 @@ class CheckFirmwareRelease extends BaseMethod {
|
|
|
16416
16535
|
|
|
16417
16536
|
run() {
|
|
16418
16537
|
if (this.device.features) {
|
|
16419
|
-
const
|
|
16420
|
-
|
|
16421
|
-
const release = DataManager.getFirmwareLeatestRelease(this.device.features);
|
|
16422
|
-
return Promise.resolve({
|
|
16423
|
-
status: firmwareStatus,
|
|
16424
|
-
changelog,
|
|
16425
|
-
release
|
|
16426
|
-
});
|
|
16538
|
+
const releaseInfo = getFirmwareReleaseInfo(this.device.features);
|
|
16539
|
+
return Promise.resolve(releaseInfo);
|
|
16427
16540
|
}
|
|
16428
16541
|
|
|
16429
16542
|
return Promise.resolve(null);
|
|
@@ -16434,18 +16547,13 @@ class CheckFirmwareRelease extends BaseMethod {
|
|
|
16434
16547
|
class CheckBLEFirmwareRelease extends BaseMethod {
|
|
16435
16548
|
init() {
|
|
16436
16549
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.BOOTLOADER];
|
|
16550
|
+
this.checkDeviceId = true;
|
|
16437
16551
|
}
|
|
16438
16552
|
|
|
16439
16553
|
run() {
|
|
16440
16554
|
if (this.device.features) {
|
|
16441
|
-
const
|
|
16442
|
-
|
|
16443
|
-
const release = DataManager.getBleFirmwareLeatestRelease(this.device.features);
|
|
16444
|
-
return Promise.resolve({
|
|
16445
|
-
status: firmwareStatus,
|
|
16446
|
-
changelog,
|
|
16447
|
-
release
|
|
16448
|
-
});
|
|
16555
|
+
const releaseInfo = getBleFirmwareReleaseInfo(this.device.features);
|
|
16556
|
+
return Promise.resolve(releaseInfo);
|
|
16449
16557
|
}
|
|
16450
16558
|
|
|
16451
16559
|
return Promise.resolve(null);
|
|
@@ -18806,6 +18914,10 @@ function findMethod(message) {
|
|
|
18806
18914
|
const safeThrowError = error => {
|
|
18807
18915
|
if (error instanceof hdShared.HardwareError) {
|
|
18808
18916
|
throw error;
|
|
18917
|
+
} else if (error.code === 'ERR_NETWORK') {
|
|
18918
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BridgeNotInstalled);
|
|
18919
|
+
} else if (error.code === 'ECONNABORTED') {
|
|
18920
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BridgeTimeoutError);
|
|
18809
18921
|
} else {
|
|
18810
18922
|
throw hdShared.ERRORS.TypedError(error);
|
|
18811
18923
|
}
|
|
@@ -18983,7 +19095,10 @@ let _uiPromises = [];
|
|
|
18983
19095
|
|
|
18984
19096
|
let _callPromise;
|
|
18985
19097
|
|
|
19098
|
+
const callApiQueue = [];
|
|
18986
19099
|
const deviceCacheMap = new Map();
|
|
19100
|
+
let pollingId = 1;
|
|
19101
|
+
const pollingState = {};
|
|
18987
19102
|
|
|
18988
19103
|
const callAPI = message => __awaiter(void 0, void 0, void 0, function* () {
|
|
18989
19104
|
var _a;
|
|
@@ -19015,23 +19130,25 @@ const callAPI = message => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
19015
19130
|
}
|
|
19016
19131
|
}
|
|
19017
19132
|
|
|
19018
|
-
|
|
19019
|
-
|
|
19020
|
-
|
|
19021
|
-
|
|
19133
|
+
callApiQueue.push(method);
|
|
19134
|
+
|
|
19135
|
+
if (callApiQueue.length > 1) {
|
|
19136
|
+
Log.debug('should cancel the previous method execution: ', callApiQueue);
|
|
19022
19137
|
}
|
|
19023
19138
|
|
|
19024
|
-
|
|
19139
|
+
if (pollingState[pollingId]) {
|
|
19140
|
+
pollingState[pollingId] = false;
|
|
19141
|
+
}
|
|
19142
|
+
|
|
19143
|
+
pollingId += 1;
|
|
19025
19144
|
let device;
|
|
19026
19145
|
|
|
19027
19146
|
try {
|
|
19028
|
-
|
|
19029
|
-
|
|
19030
|
-
|
|
19031
|
-
|
|
19032
|
-
}
|
|
19033
|
-
} catch (error) {
|
|
19034
|
-
return Promise.reject(error);
|
|
19147
|
+
device = yield ensureConnected(method, pollingId);
|
|
19148
|
+
} catch (e) {
|
|
19149
|
+
return createResponseMessage(method.responseID, false, {
|
|
19150
|
+
error: e
|
|
19151
|
+
});
|
|
19035
19152
|
}
|
|
19036
19153
|
|
|
19037
19154
|
Log.debug('Call API - setDevice: ', device.mainId);
|
|
@@ -19071,6 +19188,16 @@ const callAPI = message => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
19071
19188
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceUnexpectedMode, unexpectedMode));
|
|
19072
19189
|
}
|
|
19073
19190
|
|
|
19191
|
+
if (method.deviceId && method.checkDeviceId) {
|
|
19192
|
+
const isSameDeviceID = device.checkDeviceId(method.deviceId);
|
|
19193
|
+
|
|
19194
|
+
if (!isSameDeviceID) {
|
|
19195
|
+
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckDeviceIdError));
|
|
19196
|
+
}
|
|
19197
|
+
}
|
|
19198
|
+
|
|
19199
|
+
method.checkFirmwareRelease();
|
|
19200
|
+
|
|
19074
19201
|
if (_deviceList) {
|
|
19075
19202
|
yield TransportManager.reconfigure(device.getFirmwareVersion());
|
|
19076
19203
|
}
|
|
@@ -19118,6 +19245,13 @@ const callAPI = message => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
19118
19245
|
}
|
|
19119
19246
|
}
|
|
19120
19247
|
|
|
19248
|
+
const index = messageResponse && messageResponse.id ? callApiQueue.findIndex(m => m.responseID === messageResponse.id) : -1;
|
|
19249
|
+
|
|
19250
|
+
if (index > -1) {
|
|
19251
|
+
callApiQueue.splice(index, 1);
|
|
19252
|
+
Log.debug('Remove the finished method from the queue: ', callApiQueue);
|
|
19253
|
+
}
|
|
19254
|
+
|
|
19121
19255
|
closePopup();
|
|
19122
19256
|
cleanup();
|
|
19123
19257
|
}
|
|
@@ -19138,7 +19272,7 @@ function initDeviceList(method) {
|
|
|
19138
19272
|
_deviceList.connector = _connector;
|
|
19139
19273
|
}
|
|
19140
19274
|
|
|
19141
|
-
yield _deviceList.getDeviceLists();
|
|
19275
|
+
yield _deviceList.getDeviceLists(method.connectId);
|
|
19142
19276
|
});
|
|
19143
19277
|
}
|
|
19144
19278
|
|
|
@@ -19191,23 +19325,118 @@ function initDeviceForBle(method) {
|
|
|
19191
19325
|
return device;
|
|
19192
19326
|
}
|
|
19193
19327
|
|
|
19328
|
+
const ensureConnected = (method, pollingId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19329
|
+
let tryCount = 0;
|
|
19330
|
+
const MAX_RETRY_COUNT = method.payload && method.payload.retryCount || 5;
|
|
19331
|
+
const POLL_INTERVAL_TIME = method.payload && method.payload.pollIntervalTime || 1000;
|
|
19332
|
+
const TIME_OUT = method.payload && method.payload.timeout || 10000;
|
|
19333
|
+
let timer = null;
|
|
19334
|
+
Log.debug(`EnsureConnected function start, MAX_RETRY_COUNT=${MAX_RETRY_COUNT}, POLL_INTERVAL_TIME=${POLL_INTERVAL_TIME} `);
|
|
19335
|
+
|
|
19336
|
+
const poll = (time = POLL_INTERVAL_TIME) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19337
|
+
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19338
|
+
if (!pollingState[pollingId]) {
|
|
19339
|
+
Log.debug('EnsureConnected function stop, polling id: ', pollingId);
|
|
19340
|
+
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Polling stop'));
|
|
19341
|
+
return;
|
|
19342
|
+
}
|
|
19343
|
+
|
|
19344
|
+
if (timer) {
|
|
19345
|
+
clearTimeout(timer);
|
|
19346
|
+
}
|
|
19347
|
+
|
|
19348
|
+
timer = setTimeout(() => {
|
|
19349
|
+
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Polling timeout'));
|
|
19350
|
+
}, TIME_OUT);
|
|
19351
|
+
tryCount += 1;
|
|
19352
|
+
Log.debug('EnsureConnected function try count: ', tryCount, ' poll interval time: ', time);
|
|
19353
|
+
|
|
19354
|
+
try {
|
|
19355
|
+
yield initDeviceList(method);
|
|
19356
|
+
} catch (error) {
|
|
19357
|
+
Log.debug('device list error: ', error);
|
|
19358
|
+
|
|
19359
|
+
if (error.errorCode === hdShared.HardwareErrorCode.BridgeNotInstalled) {
|
|
19360
|
+
reject(error);
|
|
19361
|
+
return;
|
|
19362
|
+
}
|
|
19363
|
+
|
|
19364
|
+
if (error.errorCode === hdShared.HardwareErrorCode.TransportNotConfigured) {
|
|
19365
|
+
yield TransportManager.configure();
|
|
19366
|
+
}
|
|
19367
|
+
}
|
|
19368
|
+
|
|
19369
|
+
const env = DataManager.getSettings('env');
|
|
19370
|
+
let device;
|
|
19371
|
+
|
|
19372
|
+
try {
|
|
19373
|
+
if (env === 'react-native') {
|
|
19374
|
+
device = initDeviceForBle(method);
|
|
19375
|
+
} else {
|
|
19376
|
+
device = initDevice(method);
|
|
19377
|
+
}
|
|
19378
|
+
|
|
19379
|
+
if (device) {
|
|
19380
|
+
if (timer) {
|
|
19381
|
+
clearTimeout(timer);
|
|
19382
|
+
}
|
|
19383
|
+
|
|
19384
|
+
if (env === 'react-native') {
|
|
19385
|
+
yield device.acquire();
|
|
19386
|
+
yield device.initialize();
|
|
19387
|
+
}
|
|
19388
|
+
|
|
19389
|
+
resolve(device);
|
|
19390
|
+
return;
|
|
19391
|
+
}
|
|
19392
|
+
} catch (error) {
|
|
19393
|
+
Log.debug('device error: ', error);
|
|
19394
|
+
|
|
19395
|
+
if (error.errorCode === hdShared.HardwareErrorCode.BlePermissionError) {
|
|
19396
|
+
reject(error);
|
|
19397
|
+
return;
|
|
19398
|
+
}
|
|
19399
|
+
}
|
|
19400
|
+
|
|
19401
|
+
if (tryCount > 5) {
|
|
19402
|
+
if (timer) {
|
|
19403
|
+
clearTimeout(timer);
|
|
19404
|
+
}
|
|
19405
|
+
|
|
19406
|
+
Log.debug('EnsureConnected get to max try count, will return: ', tryCount);
|
|
19407
|
+
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound));
|
|
19408
|
+
return;
|
|
19409
|
+
}
|
|
19410
|
+
|
|
19411
|
+
return setTimeout(() => resolve(poll(time * 1.5)), time);
|
|
19412
|
+
}));
|
|
19413
|
+
});
|
|
19414
|
+
|
|
19415
|
+
pollingState[pollingId] = true;
|
|
19416
|
+
return poll();
|
|
19417
|
+
});
|
|
19418
|
+
|
|
19194
19419
|
const cancel = connectId => {
|
|
19195
19420
|
const env = DataManager.getSettings('env');
|
|
19196
19421
|
|
|
19197
|
-
|
|
19198
|
-
|
|
19422
|
+
try {
|
|
19423
|
+
if (connectId) {
|
|
19424
|
+
let device;
|
|
19199
19425
|
|
|
19200
|
-
|
|
19201
|
-
|
|
19202
|
-
|
|
19203
|
-
|
|
19204
|
-
|
|
19205
|
-
|
|
19206
|
-
|
|
19207
|
-
|
|
19208
|
-
|
|
19426
|
+
if (env === 'react-native') {
|
|
19427
|
+
device = initDeviceForBle({
|
|
19428
|
+
connectId
|
|
19429
|
+
});
|
|
19430
|
+
} else {
|
|
19431
|
+
device = initDevice({
|
|
19432
|
+
connectId
|
|
19433
|
+
});
|
|
19434
|
+
}
|
|
19209
19435
|
|
|
19210
|
-
|
|
19436
|
+
device === null || device === void 0 ? void 0 : device.interruptionFromUser();
|
|
19437
|
+
}
|
|
19438
|
+
} catch (e) {
|
|
19439
|
+
Log.error('Cancel API Error: ', e);
|
|
19211
19440
|
}
|
|
19212
19441
|
|
|
19213
19442
|
cleanup();
|
|
@@ -19378,6 +19607,8 @@ __webpack_unused_export__ = DEFAULT_PRIORITY;
|
|
|
19378
19607
|
__webpack_unused_export__ = DEVICE;
|
|
19379
19608
|
__webpack_unused_export__ = DEVICE_EVENT;
|
|
19380
19609
|
__webpack_unused_export__ = DataManager;
|
|
19610
|
+
__webpack_unused_export__ = FIRMWARE;
|
|
19611
|
+
exports.SI = FIRMWARE_EVENT;
|
|
19381
19612
|
exports.Bg = IFRAME;
|
|
19382
19613
|
__webpack_unused_export__ = LOG;
|
|
19383
19614
|
exports.og = LOG_EVENT;
|
|
@@ -19388,6 +19619,7 @@ __webpack_unused_export__ = UI_RESPONSE;
|
|
|
19388
19619
|
__webpack_unused_export__ = corsValidator;
|
|
19389
19620
|
__webpack_unused_export__ = createDeviceMessage;
|
|
19390
19621
|
exports.xG = createErrorMessage;
|
|
19622
|
+
__webpack_unused_export__ = createFirmwareMessage;
|
|
19391
19623
|
__webpack_unused_export__ = createIFrameMessage;
|
|
19392
19624
|
__webpack_unused_export__ = createLogMessage;
|
|
19393
19625
|
__webpack_unused_export__ = createResponseMessage;
|
|
@@ -20568,6 +20800,8 @@ const HardwareErrorCode = {
|
|
|
20568
20800
|
DeviceInitializeFailed: 106,
|
|
20569
20801
|
DeviceInterruptedFromOutside: 107,
|
|
20570
20802
|
DeviceUnexpectedBootloaderMode: 108,
|
|
20803
|
+
DeviceInterruptedFromUser: 109,
|
|
20804
|
+
DeviceCheckDeviceIdError: 110,
|
|
20571
20805
|
NotInitialized: 200,
|
|
20572
20806
|
IFrameNotInitialized: 300,
|
|
20573
20807
|
IFrameAleradyInitialized: 301,
|
|
@@ -20600,7 +20834,8 @@ const HardwareErrorCode = {
|
|
|
20600
20834
|
FirmwareError: 804,
|
|
20601
20835
|
ResponseUnexpectTypeError: 805,
|
|
20602
20836
|
BridgeNetworkError: 806,
|
|
20603
|
-
BridgeTimeoutError: 807
|
|
20837
|
+
BridgeTimeoutError: 807,
|
|
20838
|
+
BridgeNotInstalled: 808
|
|
20604
20839
|
};
|
|
20605
20840
|
const HardwareErrorCodeMessage = {
|
|
20606
20841
|
[HardwareErrorCode.UnknownError]: 'Unknown error occurred. Check message property.',
|
|
@@ -20611,7 +20846,9 @@ const HardwareErrorCodeMessage = {
|
|
|
20611
20846
|
[HardwareErrorCode.DeviceNotFound]: 'Device not found',
|
|
20612
20847
|
[HardwareErrorCode.DeviceInitializeFailed]: 'Device initialization failed',
|
|
20613
20848
|
[HardwareErrorCode.DeviceInterruptedFromOutside]: 'Device interrupted',
|
|
20849
|
+
[HardwareErrorCode.DeviceInterruptedFromUser]: 'Device interrupted',
|
|
20614
20850
|
[HardwareErrorCode.DeviceUnexpectedBootloaderMode]: 'Device should be in bootloader mode',
|
|
20851
|
+
[HardwareErrorCode.DeviceCheckDeviceIdError]: 'Device Id in the features is not same.',
|
|
20615
20852
|
[HardwareErrorCode.NotInitialized]: 'Not initialized',
|
|
20616
20853
|
[HardwareErrorCode.IFrameNotInitialized]: 'IFrame not initialized',
|
|
20617
20854
|
[HardwareErrorCode.IFrameAleradyInitialized]: 'IFrame alerady initialized',
|
|
@@ -20644,7 +20881,8 @@ const HardwareErrorCodeMessage = {
|
|
|
20644
20881
|
[HardwareErrorCode.FirmwareError]: 'Firmware installation failed',
|
|
20645
20882
|
[HardwareErrorCode.ResponseUnexpectTypeError]: 'Response type is not expected',
|
|
20646
20883
|
[HardwareErrorCode.BridgeNetworkError]: 'Bridge network error',
|
|
20647
|
-
[HardwareErrorCode.BridgeTimeoutError]: 'Bridge network timeout'
|
|
20884
|
+
[HardwareErrorCode.BridgeTimeoutError]: 'Bridge network timeout',
|
|
20885
|
+
[HardwareErrorCode.BridgeNotInstalled]: 'Bridge not installed'
|
|
20648
20886
|
};
|
|
20649
20887
|
|
|
20650
20888
|
const TypedError = (hardwareError, message) => {
|
|
@@ -45776,6 +46014,7 @@ const handleMessage = async message => {
|
|
|
45776
46014
|
break;
|
|
45777
46015
|
|
|
45778
46016
|
case dist/* LOG_EVENT */.og:
|
|
46017
|
+
case dist/* FIRMWARE_EVENT */.SI:
|
|
45779
46018
|
eventEmitter.emit(message.event, message);
|
|
45780
46019
|
break;
|
|
45781
46020
|
|
|
@@ -45867,7 +46106,7 @@ const src_init = async settings => {
|
|
|
45867
46106
|
|
|
45868
46107
|
try {
|
|
45869
46108
|
await init({ ..._settings,
|
|
45870
|
-
version: "0.1.
|
|
46109
|
+
version: "0.1.18"
|
|
45871
46110
|
});
|
|
45872
46111
|
return true;
|
|
45873
46112
|
} catch (e) {
|