@onekeyfe/hd-transport-electron 1.2.3-alpha.5 → 1.2.3-alpha.6
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/{index-474dbbae.js → index-63b1f562.js} +2 -2
- package/dist/index.js +1 -1
- package/dist/{noble-ble-handler-23c86603.js → noble-ble-handler-46832360.js} +8 -4
- package/dist/noble-ble-handler.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/__tests__/noble-ble-handler.test.ts +2 -2
- package/src/noble-ble-handler.ts +13 -6
|
@@ -55,13 +55,13 @@ function invokeNobleBleIpc(request) {
|
|
|
55
55
|
|
|
56
56
|
function initNobleBleSupport(webContents) {
|
|
57
57
|
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
const { setupNobleBleHandlers } = yield Promise.resolve().then(function () { return require('./noble-ble-handler-
|
|
58
|
+
const { setupNobleBleHandlers } = yield Promise.resolve().then(function () { return require('./noble-ble-handler-46832360.js'); });
|
|
59
59
|
setupNobleBleHandlers(webContents);
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
function disposeNobleBleSupport(releaseNoble) {
|
|
63
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
const handler = yield Promise.resolve().then(function () { return require('./noble-ble-handler-
|
|
64
|
+
const handler = yield Promise.resolve().then(function () { return require('./noble-ble-handler-46832360.js'); });
|
|
65
65
|
yield handler.disposeNobleBleSupport(releaseNoble);
|
|
66
66
|
});
|
|
67
67
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-63b1f562.js');
|
|
4
4
|
var hdShared = require('@onekeyfe/hd-shared');
|
|
5
5
|
var pRetry = require('p-retry');
|
|
6
6
|
|
|
@@ -123,8 +123,7 @@ function assertBleActive() {
|
|
|
123
123
|
}
|
|
124
124
|
function createNobleBleConnectionError(error, messagePrefix = '') {
|
|
125
125
|
const errorMessage = error.message;
|
|
126
|
-
const isInvalidMacOsBond =
|
|
127
|
-
(error.nativeErrorCode === 15 && error.nativeErrorDomain === 'CBATTErrorDomain');
|
|
126
|
+
const isInvalidMacOsBond = error.nativeErrorCode === 14 && error.nativeErrorDomain === 'CBErrorDomain';
|
|
128
127
|
if (isInvalidMacOsBond) {
|
|
129
128
|
const nativeErrorMessage = `${messagePrefix}${errorMessage}`;
|
|
130
129
|
return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleBondInvalid, `${hdShared.HardwareErrorCodeMessage[hdShared.HardwareErrorCode.BleBondInvalid]} (${nativeErrorMessage})`, {
|
|
@@ -1517,7 +1516,12 @@ function subscribeNotifications(deviceId, callback) {
|
|
|
1517
1516
|
});
|
|
1518
1517
|
}
|
|
1519
1518
|
catch (error) {
|
|
1520
|
-
|
|
1519
|
+
const nativeError = error;
|
|
1520
|
+
if (nativeError.nativeErrorCode === 15 &&
|
|
1521
|
+
nativeError.nativeErrorDomain === 'CBATTErrorDomain') {
|
|
1522
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleDeviceNotBonded, hdShared.HardwareErrorCodeMessage[hdShared.HardwareErrorCode.BleDeviceNotBonded], { nativeErrorMessage: `Notification subscription failed: ${nativeError.message}` });
|
|
1523
|
+
}
|
|
1524
|
+
throw createNobleBleConnectionError(nativeError, 'Notification subscription failed: ');
|
|
1521
1525
|
}
|
|
1522
1526
|
finally {
|
|
1523
1527
|
if (!disposing)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noble-ble-handler.d.ts","sourceRoot":"","sources":["../src/noble-ble-handler.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAA+B,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,KAAK,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAiC1F,KAAK,mBAAmB,GAAG,KAAK,GAAG;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,mBAAmB,EAAE,aAAa,SAAK,+
|
|
1
|
+
{"version":3,"file":"noble-ble-handler.d.ts","sourceRoot":"","sources":["../src/noble-ble-handler.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAA+B,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,KAAK,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAiC1F,KAAK,mBAAmB,GAAG,KAAK,GAAG;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,mBAAmB,EAAE,aAAa,SAAK,+CAgB3F;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,OAAO,GAAG,wBAAwB,CAgCvF;AA+KD,wBAAgB,+BAA+B,CAAC,OAAO,CAAC,EAAE,oBAAoB,UAI7E;AA6yDD,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAkOpE;AAOD,wBAAgB,sBAAsB,CACpC,YAAY,GAAE,CAAC,QAAQ,EAAE;IAAE,IAAI,IAAI,IAAI,CAAA;CAAE,KAAK,IAAkC,GAC/E,OAAO,CAAC,IAAI,CAAC,CAiEf"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport-electron",
|
|
3
|
-
"version": "1.2.3-alpha.
|
|
3
|
+
"version": "1.2.3-alpha.6",
|
|
4
4
|
"author": "OneKey",
|
|
5
5
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"electron-log": ">=4.0.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@onekeyfe/hd-core": "1.2.3-alpha.
|
|
29
|
-
"@onekeyfe/hd-shared": "1.2.3-alpha.
|
|
30
|
-
"@onekeyfe/hd-transport": "1.2.3-alpha.
|
|
28
|
+
"@onekeyfe/hd-core": "1.2.3-alpha.6",
|
|
29
|
+
"@onekeyfe/hd-shared": "1.2.3-alpha.6",
|
|
30
|
+
"@onekeyfe/hd-transport": "1.2.3-alpha.6",
|
|
31
31
|
"@stoprocent/noble": "2.3.16",
|
|
32
32
|
"p-retry": "^4.6.2"
|
|
33
33
|
},
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"electron": "^25.0.0",
|
|
37
37
|
"typescript": "^5.3.3"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "80a130479ef3ca8479cfb9041d80097ae43d2574"
|
|
40
40
|
}
|
|
@@ -68,7 +68,7 @@ describe('Electron Noble BLE device discovery', () => {
|
|
|
68
68
|
})
|
|
69
69
|
)
|
|
70
70
|
).toMatchObject({
|
|
71
|
-
errorCode: HardwareErrorCode.
|
|
71
|
+
errorCode: HardwareErrorCode.BleConnectedError,
|
|
72
72
|
});
|
|
73
73
|
expect(createNobleBleConnectionError(new Error('connection failed'))).toMatchObject({
|
|
74
74
|
errorCode: HardwareErrorCode.BleConnectedError,
|
|
@@ -705,7 +705,7 @@ describe('Electron Noble BLE device discovery', () => {
|
|
|
705
705
|
type: 'NobleBleIpcError',
|
|
706
706
|
success: false,
|
|
707
707
|
error: {
|
|
708
|
-
errorCode: HardwareErrorCode.
|
|
708
|
+
errorCode: HardwareErrorCode.BleDeviceNotBonded,
|
|
709
709
|
params: {
|
|
710
710
|
nativeErrorMessage: 'Notification subscription failed: Encryption is insufficient',
|
|
711
711
|
},
|
package/src/noble-ble-handler.ts
CHANGED
|
@@ -75,8 +75,7 @@ type NobleBleNativeError = Error & {
|
|
|
75
75
|
export function createNobleBleConnectionError(error: NobleBleNativeError, messagePrefix = '') {
|
|
76
76
|
const errorMessage = error.message;
|
|
77
77
|
const isInvalidMacOsBond =
|
|
78
|
-
|
|
79
|
-
(error.nativeErrorCode === 15 && error.nativeErrorDomain === 'CBATTErrorDomain');
|
|
78
|
+
error.nativeErrorCode === 14 && error.nativeErrorDomain === 'CBErrorDomain';
|
|
80
79
|
if (isInvalidMacOsBond) {
|
|
81
80
|
const nativeErrorMessage = `${messagePrefix}${errorMessage}`;
|
|
82
81
|
return ERRORS.TypedError(
|
|
@@ -2120,10 +2119,18 @@ async function subscribeNotifications(
|
|
|
2120
2119
|
ms: Date.now() - subscribeStartedAt,
|
|
2121
2120
|
});
|
|
2122
2121
|
} catch (error) {
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2122
|
+
const nativeError = error as NobleBleNativeError;
|
|
2123
|
+
if (
|
|
2124
|
+
nativeError.nativeErrorCode === 15 &&
|
|
2125
|
+
nativeError.nativeErrorDomain === 'CBATTErrorDomain'
|
|
2126
|
+
) {
|
|
2127
|
+
throw ERRORS.TypedError(
|
|
2128
|
+
HardwareErrorCode.BleDeviceNotBonded,
|
|
2129
|
+
HardwareErrorCodeMessage[HardwareErrorCode.BleDeviceNotBonded],
|
|
2130
|
+
{ nativeErrorMessage: `Notification subscription failed: ${nativeError.message}` }
|
|
2131
|
+
);
|
|
2132
|
+
}
|
|
2133
|
+
throw createNobleBleConnectionError(nativeError, 'Notification subscription failed: ');
|
|
2127
2134
|
} finally {
|
|
2128
2135
|
// 🔒 CRITICAL: Always clear operation state (even on error)
|
|
2129
2136
|
if (!disposing) subscriptionOperations.set(deviceId, 'idle');
|