@onekeyfe/hd-transport-react-native 1.2.8-alpha.6 → 1.2.8-alpha.7
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/BleManager.d.ts +2 -4
- package/dist/BleManager.d.ts.map +1 -1
- package/dist/bleNativeDisconnect.d.ts.map +1 -1
- package/dist/index.d.ts +1 -57
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -562
- package/dist/subscribeBleOn.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/BleManager.ts +4 -31
- package/src/__tests__/bleNativeDisconnect.test.ts +22 -1
- package/src/__tests__/connectTimeout.test.ts +110 -0
- package/src/__tests__/enumerate.test.ts +68 -17
- package/src/__tests__/protocolV2Link.test.ts +100 -74
- package/src/__tests__/subscribeBleOn.test.ts +114 -0
- package/src/bleNativeDisconnect.ts +2 -1
- package/src/index.ts +19 -306
- package/src/subscribeBleOn.ts +30 -11
- package/dist/bleEncryption.d.ts +0 -17
- package/dist/bleEncryption.d.ts.map +0 -1
- package/dist/bleIosStaleBond.d.ts +0 -16
- package/dist/bleIosStaleBond.d.ts.map +0 -1
- package/dist/bleKeyMissing.d.ts +0 -7
- package/dist/bleKeyMissing.d.ts.map +0 -1
- package/dist/bleStaleBond.d.ts +0 -5
- package/dist/bleStaleBond.d.ts.map +0 -1
- package/src/__tests__/androidEncryption.test.ts +0 -482
- package/src/__tests__/androidKeyMissing.test.ts +0 -307
- package/src/__tests__/bleStaleBond.test.ts +0 -47
- package/src/__tests__/iosPeerTermination.test.ts +0 -318
- package/src/bleEncryption.ts +0 -267
- package/src/bleIosStaleBond.ts +0 -92
- package/src/bleKeyMissing.ts +0 -106
- package/src/bleStaleBond.ts +0 -64
package/dist/BleManager.d.ts
CHANGED
|
@@ -2,9 +2,7 @@ import type { Peripheral } from '@onekeyfe/react-native-ble-utils';
|
|
|
2
2
|
export declare const getConnectedDeviceIds: (serviceUuids: string[]) => Promise<Peripheral[]>;
|
|
3
3
|
export declare const getBondedDevices: () => Promise<Peripheral[]>;
|
|
4
4
|
export declare const pairDevice: (macAddress: string) => Promise<import("@onekeyfe/react-native-ble-utils").PairDeviceResult>;
|
|
5
|
-
export declare const
|
|
6
|
-
export type DeviceBondStateOptions = {
|
|
5
|
+
export declare const onDeviceBondState: (bleMacAddress: string, signal?: AbortSignal, options?: {
|
|
7
6
|
systemInitiated?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare const onDeviceBondState: (bleMacAddress: string, signal?: AbortSignal, options?: DeviceBondStateOptions) => Promise<Peripheral | undefined>;
|
|
7
|
+
}) => Promise<Peripheral | undefined>;
|
|
10
8
|
//# sourceMappingURL=BleManager.d.ts.map
|
package/dist/BleManager.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BleManager.d.ts","sourceRoot":"","sources":["../src/BleManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BleManager.d.ts","sourceRoot":"","sources":["../src/BleManager.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAsBnE,eAAO,MAAM,qBAAqB,iBAAkB,MAAM,EAAE,0BACZ,CAAC;AAEjD,eAAO,MAAM,gBAAgB,6BAAwC,CAAC;AAEtE,eAAO,MAAM,UAAU,eAAgB,MAAM,yEAAoC,CAAC;AAoClF,eAAO,MAAM,iBAAiB,kBACb,MAAM,WACZ,WAAW,YACV;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,KACtC,QAAQ,UAAU,GAAG,SAAS,CA6D7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bleNativeDisconnect.d.ts","sourceRoot":"","sources":["../src/bleNativeDisconnect.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,0BAA0B,UAAW,OAAO,KAAG,
|
|
1
|
+
{"version":3,"file":"bleNativeDisconnect.d.ts","sourceRoot":"","sources":["../src/bleNativeDisconnect.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,0BAA0B,UAAW,OAAO,KAAG,OAW3D,CAAC;AAEF,eAAO,MAAM,4BAA4B,UAAW,OAAO,UAU1D,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -62,24 +62,6 @@ declare const getFirmwareUploadWriteRetryType: (error: unknown) => FirmwareUploa
|
|
|
62
62
|
*/
|
|
63
63
|
declare const BLE_WRITE_PACKET_TIMEOUT_MS = 10000;
|
|
64
64
|
declare const BLE_NATIVE_TEARDOWN_TIMEOUT_MS = 3000;
|
|
65
|
-
/**
|
|
66
|
-
* Android reports a lost bond (ACTION_KEY_MISSING) while it encrypts a new link, so only
|
|
67
|
-
* a failure this soon after the link started can be explained by it. Later disconnects,
|
|
68
|
-
* such as a firmware-update reboot, must keep their own meaning.
|
|
69
|
-
*/
|
|
70
|
-
declare const ANDROID_KEY_MISSING_LINK_WINDOW_MS = 10000;
|
|
71
|
-
/** The broadcast and the GATT disconnect it explains travel separately; either can land first. */
|
|
72
|
-
declare const ANDROID_KEY_MISSING_GRACE_MS = 500;
|
|
73
|
-
/**
|
|
74
|
-
* Android reports a bonded link's first encryption result within about half a second of
|
|
75
|
-
* connecting. Past this, the result is treated as unknown and the link is used as before.
|
|
76
|
-
*/
|
|
77
|
-
declare const ANDROID_ENCRYPTION_RESULT_TIMEOUT_MS = 1500;
|
|
78
|
-
/**
|
|
79
|
-
* A system re-pairing needs the user to accept a pairing request and confirm the code on the
|
|
80
|
-
* device. The Bluetooth stack gives up after 30s and then reports key missing.
|
|
81
|
-
*/
|
|
82
|
-
declare const ANDROID_SYSTEM_REPAIR_TIMEOUT_MS = 35000;
|
|
83
65
|
/** Consecutive wedged writes on one device before the BLE manager itself is recreated. */
|
|
84
66
|
declare const BLE_WRITE_TIMEOUT_MANAGER_RESET_THRESHOLD = 2;
|
|
85
67
|
type ProtocolV2BleTuning = {
|
|
@@ -167,18 +149,6 @@ declare class ReactNativeBleTransport {
|
|
|
167
149
|
private silentDetections;
|
|
168
150
|
/** Android endpoints whose cached GATT table is suspect; the next connect refreshes it. */
|
|
169
151
|
private androidGattCacheRefreshes;
|
|
170
|
-
/**
|
|
171
|
-
* Native encryption/pairing failures seen before Protocol V2 probe starts.
|
|
172
|
-
* Pro2/Neo GATT connect can succeed on a stale iOS bond; the CCCD write then
|
|
173
|
-
* fails with ATT 5/15. Remember it so detectProtocol fails immediately.
|
|
174
|
-
*/
|
|
175
|
-
private staleBondErrors;
|
|
176
|
-
/** When the current Android link attempt began; bounds which key-missing signals apply. */
|
|
177
|
-
private androidLinkStartedAt;
|
|
178
|
-
/** iOS acquire attempts whose new link the peer ended; two in a row mean a stale bond. */
|
|
179
|
-
private iosPeerTermination;
|
|
180
|
-
/** Strict or previously confirmed V2 target while acquire installs notifications. */
|
|
181
|
-
private acquiringProtocolV2;
|
|
182
152
|
private protocolV2Assemblers;
|
|
183
153
|
private protocolV2FrameQueues;
|
|
184
154
|
private protocolV2FramePromises;
|
|
@@ -222,30 +192,6 @@ declare class ReactNativeBleTransport {
|
|
|
222
192
|
private releaseNative;
|
|
223
193
|
post(session: string, name: string, data: Record<string, unknown>): Promise<void>;
|
|
224
194
|
call(uuid: string, name: string, data: Record<string, unknown>, options?: TransportCallOptions): Promise<transport.MessageFromOneKey>;
|
|
225
|
-
/**
|
|
226
|
-
* Android 16+ keeps a bond the device no longer holds keys for. The device drops the link
|
|
227
|
-
* and the only structured evidence is ACTION_KEY_MISSING, so a link loss right after
|
|
228
|
-
* connect is re-read as an invalid bond when that signal belongs to the same attempt.
|
|
229
|
-
*/
|
|
230
|
-
private resolveAndroidBondInvalid;
|
|
231
|
-
/**
|
|
232
|
-
* iOS says why a link ended only on the operation it interrupted, so the native codes are read
|
|
233
|
-
* and logged here. Codes only: the reason text is localized and cannot be matched or searched.
|
|
234
|
-
*/
|
|
235
|
-
private noteIosLinkError;
|
|
236
|
-
/**
|
|
237
|
-
* iPhones that do not report a lost bond only show the device ending each new link. One such
|
|
238
|
-
* attempt keeps its error so Core retries; the second in a row is the stale bond.
|
|
239
|
-
*/
|
|
240
|
-
private resolveIosBondInvalid;
|
|
241
|
-
/**
|
|
242
|
-
* Android 16+ encrypts a bonded link on its own right after connecting. Subscribing to
|
|
243
|
-
* notifications before that finishes gets the CCCD write rejected, and the framework's retry
|
|
244
|
-
* encrypts again with the same stale key; firmware that allows one failure per link then drops
|
|
245
|
-
* it before the system can re-pair. Holding GATT until the result lets a lost bond be re-paired
|
|
246
|
-
* in place. Without the platform signal this resolves immediately.
|
|
247
|
-
*/
|
|
248
|
-
private waitForAndroidLinkSecurity;
|
|
249
195
|
private callProtocolV1;
|
|
250
196
|
stop(): Promise<void>;
|
|
251
197
|
disconnect(session: string): Promise<void>;
|
|
@@ -310,8 +256,6 @@ declare class ReactNativeBleTransport {
|
|
|
310
256
|
private resolveProtocolV2Frame;
|
|
311
257
|
private resetProtocolV2Frames;
|
|
312
258
|
private rejectProtocolV2Frames;
|
|
313
|
-
private rememberStaleBondError;
|
|
314
|
-
private throwIfStaleBondError;
|
|
315
259
|
private readProtocolV2Frame;
|
|
316
260
|
private writeProtocolV2Packet;
|
|
317
261
|
private writeProtocolV2Frame;
|
|
@@ -325,4 +269,4 @@ declare class ReactNativeBleTransport {
|
|
|
325
269
|
getProtocolType(path: string): ProtocolType | undefined;
|
|
326
270
|
}
|
|
327
271
|
|
|
328
|
-
export {
|
|
272
|
+
export { ANDROID_LINK_DROP_QUIET_MS, ANDROID_MTU_EXCHANGE_TIMEOUT_MS, BLE_CONNECT_TIMEOUT_MANAGER_RESET_THRESHOLD, BLE_CONNECT_TIMEOUT_MS, BLE_GATT_SETUP_TIMEOUT_MS, BLE_NATIVE_TEARDOWN_TIMEOUT_MS, BLE_SETUP_WEDGED_MESSAGE, BLE_WRITE_PACKET_TIMEOUT_MS, BLE_WRITE_TIMEOUT_MANAGER_RESET_THRESHOLD, IOneKeyDevice, PROTOCOL_REPROBE_FALLBACK_ATTEMPTS, ProtocolV2BleTuning, configureProtocolV2BleTuning, ReactNativeBleTransport as default, getFirmwareUploadWriteRetryType, getProtocolV2BleTuning, resetProtocolV2BleTuning };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAGL,UAAU,IAAI,aAAa,EAG5B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,SAAS,EAAE,EAChB,KAAK,oBAAoB,EAIzB,KAAK,YAAY,EAKjB,KAAK,oBAAoB,EAI1B,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAGL,UAAU,IAAI,aAAa,EAG5B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,SAAS,EAAE,EAChB,KAAK,oBAAoB,EAIzB,KAAK,YAAY,EAKjB,KAAK,oBAAoB,EAI1B,MAAM,wBAAwB,CAAC;AA2BhC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAI1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEjE,KAAK,8BAA8B,GAAG,eAAe,GAAG;IAMtD,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAkBF,KAAK,4BAA4B,GAAG,WAAW,CAAC;AAChD,KAAK,0BAA0B,GAAG;IAChC,mBAAmB,EAAE,cAAc,CAAC;IACpC,oBAAoB,EAAE,cAAc,CAAC;CACtC,CAAC;AAkCF,eAAO,MAAM,+BAA+B,UACnC,OAAO,KACb,4BAA4B,GA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