@onekeyfe/hd-transport-electron 1.2.3-alpha.6 → 1.2.3-alpha.8
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-63b1f562.js → index-474dbbae.js} +2 -2
- package/dist/index.js +1 -1
- package/dist/{noble-ble-handler-46832360.js → noble-ble-handler-23c86603.js} +4 -8
- 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 +6 -13
|
@@ -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-23c86603.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-23c86603.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-474dbbae.js');
|
|
4
4
|
var hdShared = require('@onekeyfe/hd-shared');
|
|
5
5
|
var pRetry = require('p-retry');
|
|
6
6
|
|
|
@@ -123,7 +123,8 @@ function assertBleActive() {
|
|
|
123
123
|
}
|
|
124
124
|
function createNobleBleConnectionError(error, messagePrefix = '') {
|
|
125
125
|
const errorMessage = error.message;
|
|
126
|
-
const isInvalidMacOsBond = error.nativeErrorCode === 14 && error.nativeErrorDomain === 'CBErrorDomain'
|
|
126
|
+
const isInvalidMacOsBond = (error.nativeErrorCode === 14 && error.nativeErrorDomain === 'CBErrorDomain') ||
|
|
127
|
+
(error.nativeErrorCode === 15 && error.nativeErrorDomain === 'CBATTErrorDomain');
|
|
127
128
|
if (isInvalidMacOsBond) {
|
|
128
129
|
const nativeErrorMessage = `${messagePrefix}${errorMessage}`;
|
|
129
130
|
return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleBondInvalid, `${hdShared.HardwareErrorCodeMessage[hdShared.HardwareErrorCode.BleBondInvalid]} (${nativeErrorMessage})`, {
|
|
@@ -1516,12 +1517,7 @@ function subscribeNotifications(deviceId, callback) {
|
|
|
1516
1517
|
});
|
|
1517
1518
|
}
|
|
1518
1519
|
catch (error) {
|
|
1519
|
-
|
|
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: ');
|
|
1520
|
+
throw createNobleBleConnectionError(error, 'Notification subscription failed: ');
|
|
1525
1521
|
}
|
|
1526
1522
|
finally {
|
|
1527
1523
|
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,+CAiB3F;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,OAAO,GAAG,wBAAwB,CAgCvF;AA+KD,wBAAgB,+BAA+B,CAAC,OAAO,CAAC,EAAE,oBAAoB,UAI7E;AAqyDD,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.8",
|
|
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.8",
|
|
29
|
+
"@onekeyfe/hd-shared": "1.2.3-alpha.8",
|
|
30
|
+
"@onekeyfe/hd-transport": "1.2.3-alpha.8",
|
|
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": "170aac4b7ca98bf24b5dd36b9729c98a10389161"
|
|
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.BleBondInvalid,
|
|
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.BleBondInvalid,
|
|
709
709
|
params: {
|
|
710
710
|
nativeErrorMessage: 'Notification subscription failed: Encryption is insufficient',
|
|
711
711
|
},
|
package/src/noble-ble-handler.ts
CHANGED
|
@@ -75,7 +75,8 @@ type NobleBleNativeError = Error & {
|
|
|
75
75
|
export function createNobleBleConnectionError(error: NobleBleNativeError, messagePrefix = '') {
|
|
76
76
|
const errorMessage = error.message;
|
|
77
77
|
const isInvalidMacOsBond =
|
|
78
|
-
error.nativeErrorCode === 14 && error.nativeErrorDomain === 'CBErrorDomain'
|
|
78
|
+
(error.nativeErrorCode === 14 && error.nativeErrorDomain === 'CBErrorDomain') ||
|
|
79
|
+
(error.nativeErrorCode === 15 && error.nativeErrorDomain === 'CBATTErrorDomain');
|
|
79
80
|
if (isInvalidMacOsBond) {
|
|
80
81
|
const nativeErrorMessage = `${messagePrefix}${errorMessage}`;
|
|
81
82
|
return ERRORS.TypedError(
|
|
@@ -2119,18 +2120,10 @@ async function subscribeNotifications(
|
|
|
2119
2120
|
ms: Date.now() - subscribeStartedAt,
|
|
2120
2121
|
});
|
|
2121
2122
|
} catch (error) {
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
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: ');
|
|
2123
|
+
throw createNobleBleConnectionError(
|
|
2124
|
+
error as NobleBleNativeError,
|
|
2125
|
+
'Notification subscription failed: '
|
|
2126
|
+
);
|
|
2134
2127
|
} finally {
|
|
2135
2128
|
// 🔒 CRITICAL: Always clear operation state (even on error)
|
|
2136
2129
|
if (!disposing) subscriptionOperations.set(deviceId, 'idle');
|