@onekeyfe/hd-web-sdk 0.1.13 → 0.1.14
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.3c144affd37209f8865f.js +3 -0
- package/build/js/{iframe.b96245cb401eda8e8824.js.LICENSE.txt → iframe.3c144affd37209f8865f.js.LICENSE.txt} +0 -0
- package/build/js/iframe.3c144affd37209f8865f.js.map +1 -0
- package/build/onekey-js-sdk.js +41 -9
- 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 +5 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/bridgeUtils.d.ts.map +1 -1
- package/dist/utils/bridgeUtils.js +2 -1
- package/dist/utils/bridgeUtils.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +6 -2
- package/src/utils/bridgeUtils.ts +2 -1
- package/build/js/iframe.b96245cb401eda8e8824.js +0 -3
- package/build/js/iframe.b96245cb401eda8e8824.js.map +0 -1
package/build/onekey-js-sdk.js
CHANGED
|
@@ -13979,6 +13979,10 @@ class TransportManager {
|
|
|
13979
13979
|
Log$5.debug('Configuring transports done');
|
|
13980
13980
|
} catch (error) {
|
|
13981
13981
|
Log$5.debug('Initializing transports error: ', error);
|
|
13982
|
+
|
|
13983
|
+
if (error.code === 'ECONNABORTED') {
|
|
13984
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BridgeTimeoutError);
|
|
13985
|
+
}
|
|
13982
13986
|
}
|
|
13983
13987
|
});
|
|
13984
13988
|
}
|
|
@@ -16291,12 +16295,19 @@ class CheckBridgeStatus extends BaseMethod {
|
|
|
16291
16295
|
|
|
16292
16296
|
run() {
|
|
16293
16297
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16294
|
-
return new Promise(resolve => {
|
|
16298
|
+
return new Promise((resolve, reject) => {
|
|
16295
16299
|
axios__default["default"].request({
|
|
16296
16300
|
url: 'http://localhost:21320',
|
|
16297
16301
|
method: 'POST',
|
|
16298
|
-
withCredentials: false
|
|
16299
|
-
|
|
16302
|
+
withCredentials: false,
|
|
16303
|
+
timeout: 3000
|
|
16304
|
+
}).then(() => resolve(true)).catch(e => {
|
|
16305
|
+
if (e.code === 'ECONNABORTED') {
|
|
16306
|
+
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BridgeTimeoutError));
|
|
16307
|
+
} else {
|
|
16308
|
+
resolve(false);
|
|
16309
|
+
}
|
|
16310
|
+
});
|
|
16300
16311
|
});
|
|
16301
16312
|
});
|
|
16302
16313
|
}
|
|
@@ -20389,7 +20400,8 @@ const HardwareErrorCode = {
|
|
|
20389
20400
|
ActionCancelled: 803,
|
|
20390
20401
|
FirmwareError: 804,
|
|
20391
20402
|
ResponseUnexpectTypeError: 805,
|
|
20392
|
-
BridgeNetworkError: 806
|
|
20403
|
+
BridgeNetworkError: 806,
|
|
20404
|
+
BridgeTimeoutError: 807
|
|
20393
20405
|
};
|
|
20394
20406
|
const HardwareErrorCodeMessage = {
|
|
20395
20407
|
[HardwareErrorCode.UnknownError]: 'Unknown error occurred. Check message property.',
|
|
@@ -20432,7 +20444,8 @@ const HardwareErrorCodeMessage = {
|
|
|
20432
20444
|
[HardwareErrorCode.ActionCancelled]: 'Action cancelled by user',
|
|
20433
20445
|
[HardwareErrorCode.FirmwareError]: 'Firmware installation failed',
|
|
20434
20446
|
[HardwareErrorCode.ResponseUnexpectTypeError]: 'Response type is not expected',
|
|
20435
|
-
[HardwareErrorCode.BridgeNetworkError]: 'Bridge network error'
|
|
20447
|
+
[HardwareErrorCode.BridgeNetworkError]: 'Bridge network error',
|
|
20448
|
+
[HardwareErrorCode.BridgeTimeoutError]: 'Bridge network timeout'
|
|
20436
20449
|
};
|
|
20437
20450
|
|
|
20438
20451
|
const TypedError = (hardwareError, message) => {
|
|
@@ -20464,13 +20477,24 @@ const serializeError = payload => {
|
|
|
20464
20477
|
return payload;
|
|
20465
20478
|
};
|
|
20466
20479
|
|
|
20480
|
+
const CreateErrorByMessage = message => {
|
|
20481
|
+
for (const code of Object.values(HardwareErrorCode)) {
|
|
20482
|
+
if (HardwareErrorCodeMessage[code] === message) {
|
|
20483
|
+
return TypedError(code);
|
|
20484
|
+
}
|
|
20485
|
+
}
|
|
20486
|
+
|
|
20487
|
+
return new HardwareError(message);
|
|
20488
|
+
};
|
|
20489
|
+
|
|
20467
20490
|
var HardwareError$1 = /*#__PURE__*/Object.freeze({
|
|
20468
20491
|
__proto__: null,
|
|
20469
20492
|
HardwareError: HardwareError,
|
|
20470
20493
|
HardwareErrorCode: HardwareErrorCode,
|
|
20471
20494
|
HardwareErrorCodeMessage: HardwareErrorCodeMessage,
|
|
20472
20495
|
TypedError: TypedError,
|
|
20473
|
-
serializeError: serializeError
|
|
20496
|
+
serializeError: serializeError,
|
|
20497
|
+
CreateErrorByMessage: CreateErrorByMessage
|
|
20474
20498
|
});
|
|
20475
20499
|
const MAX_ENTRIES = 100;
|
|
20476
20500
|
|
|
@@ -20591,6 +20615,7 @@ const getLog = () => {
|
|
|
20591
20615
|
return logs;
|
|
20592
20616
|
};
|
|
20593
20617
|
|
|
20618
|
+
exports.CreateErrorByMessage = CreateErrorByMessage;
|
|
20594
20619
|
exports.ERRORS = HardwareError$1;
|
|
20595
20620
|
exports.HardwareError = HardwareError;
|
|
20596
20621
|
exports.HardwareErrorCode = HardwareErrorCode;
|
|
@@ -45606,6 +45631,7 @@ function createCodeJsBridgeReceive(payloadStr) {
|
|
|
45606
45631
|
;// CONCATENATED MODULE: ./src/utils/bridgeUtils.ts
|
|
45607
45632
|
|
|
45608
45633
|
|
|
45634
|
+
|
|
45609
45635
|
// eslint-disable-next-line import/no-mutable-exports
|
|
45610
45636
|
|
|
45611
45637
|
let frameBridge; // eslint-disable-next-line import/no-mutable-exports
|
|
@@ -45635,7 +45661,7 @@ const sendMessage = async (messages, isHost = true) => {
|
|
|
45635
45661
|
return result;
|
|
45636
45662
|
} catch (error) {
|
|
45637
45663
|
Log.error(error);
|
|
45638
|
-
throw error;
|
|
45664
|
+
throw shared_dist.ERRORS.CreateErrorByMessage(error.message);
|
|
45639
45665
|
}
|
|
45640
45666
|
};
|
|
45641
45667
|
|
|
@@ -45746,7 +45772,7 @@ const src_init = async settings => {
|
|
|
45746
45772
|
|
|
45747
45773
|
try {
|
|
45748
45774
|
await init({ ..._settings,
|
|
45749
|
-
version: "0.1.
|
|
45775
|
+
version: "0.1.14"
|
|
45750
45776
|
});
|
|
45751
45777
|
return true;
|
|
45752
45778
|
} catch (e) {
|
|
@@ -45786,7 +45812,13 @@ const call = async params => {
|
|
|
45786
45812
|
return (0,dist/* createErrorMessage */.xG)(shared_dist.ERRORS.TypedError(shared_dist.HardwareErrorCode.CallMethodNotResponse));
|
|
45787
45813
|
} catch (error) {
|
|
45788
45814
|
src_Log.error('__call error: ', error);
|
|
45789
|
-
|
|
45815
|
+
let err = error;
|
|
45816
|
+
|
|
45817
|
+
if (!(err instanceof shared_dist.HardwareError)) {
|
|
45818
|
+
err = shared_dist.ERRORS.CreateErrorByMessage(error.message);
|
|
45819
|
+
}
|
|
45820
|
+
|
|
45821
|
+
return (0,dist/* createErrorMessage */.xG)(err);
|
|
45790
45822
|
}
|
|
45791
45823
|
};
|
|
45792
45824
|
|