Skip to content

Commit 4a835d0

Browse files
Support/only connect (#627)
* feat: support only connect * chore: release 1.1.20-alpha.1
1 parent bff28f2 commit 4a835d0

File tree

27 files changed

+124
-80
lines changed

27 files changed

+124
-80
lines changed

packages/connect-examples/electron-example/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "hardware-example",
33
"productName": "HardwareExample",
44
"executableName": "onekey-hardware-example",
5-
"version": "1.1.20-alpha.0",
5+
"version": "1.1.20-alpha.1",
66
"author": "OneKey",
77
"description": "End-to-end encrypted workspaces for teams",
88
"main": "dist/index.js",
@@ -22,7 +22,7 @@
2222
"ts:check": "yarn tsc --noEmit"
2323
},
2424
"dependencies": {
25-
"@onekeyfe/hd-transport-electron": "1.1.20-alpha.0",
25+
"@onekeyfe/hd-transport-electron": "1.1.20-alpha.1",
2626
"@stoprocent/noble": "2.3.4",
2727
"debug": "4.3.4",
2828
"electron-is-dev": "^3.0.1",

packages/connect-examples/expo-example/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "expo-example",
3-
"version": "1.1.20-alpha.0",
3+
"version": "1.1.20-alpha.1",
44
"scripts": {
55
"start": "cross-env CONNECT_SRC=https://localhost:8087/ yarn expo start --dev-client",
66
"android": "yarn expo run:android",
@@ -19,10 +19,10 @@
1919
"@noble/ed25519": "^2.1.0",
2020
"@noble/hashes": "^1.3.3",
2121
"@noble/secp256k1": "^1.7.1",
22-
"@onekeyfe/hd-ble-sdk": "1.1.20-alpha.0",
23-
"@onekeyfe/hd-common-connect-sdk": "1.1.20-alpha.0",
24-
"@onekeyfe/hd-core": "1.1.20-alpha.0",
25-
"@onekeyfe/hd-web-sdk": "1.1.20-alpha.0",
22+
"@onekeyfe/hd-ble-sdk": "1.1.20-alpha.1",
23+
"@onekeyfe/hd-common-connect-sdk": "1.1.20-alpha.1",
24+
"@onekeyfe/hd-core": "1.1.20-alpha.1",
25+
"@onekeyfe/hd-web-sdk": "1.1.20-alpha.1",
2626
"@onekeyfe/react-native-ble-utils": "^0.1.3",
2727
"@polkadot/util-crypto": "13.1.1",
2828
"@react-native-async-storage/async-storage": "1.21.0",

packages/connect-examples/expo-playground/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "onekey-hardware-playground",
3-
"version": "1.1.20-alpha.0",
3+
"version": "1.1.20-alpha.1",
44
"private": true,
55
"sideEffects": [
66
"app/utils/shim.js",
@@ -17,9 +17,9 @@
1717
},
1818
"dependencies": {
1919
"@noble/hashes": "^1.8.0",
20-
"@onekeyfe/hd-common-connect-sdk": "1.1.20-alpha.0",
21-
"@onekeyfe/hd-core": "1.1.20-alpha.0",
22-
"@onekeyfe/hd-shared": "1.1.20-alpha.0",
20+
"@onekeyfe/hd-common-connect-sdk": "1.1.20-alpha.1",
21+
"@onekeyfe/hd-core": "1.1.20-alpha.1",
22+
"@onekeyfe/hd-shared": "1.1.20-alpha.1",
2323
"@radix-ui/react-checkbox": "^1.3.2",
2424
"@radix-ui/react-dialog": "^1.1.14",
2525
"@radix-ui/react-dropdown-menu": "^2.1.15",

packages/core/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@onekeyfe/hd-core",
3-
"version": "1.1.20-alpha.0",
3+
"version": "1.1.20-alpha.1",
44
"description": "Core processes and APIs for communicating with OneKey hardware devices.",
55
"author": "OneKey",
66
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
@@ -25,8 +25,8 @@
2525
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
2626
},
2727
"dependencies": {
28-
"@onekeyfe/hd-shared": "1.1.20-alpha.0",
29-
"@onekeyfe/hd-transport": "1.1.20-alpha.0",
28+
"@onekeyfe/hd-shared": "1.1.20-alpha.1",
29+
"@onekeyfe/hd-transport": "1.1.20-alpha.1",
3030
"axios": "1.12.2",
3131
"bignumber.js": "^9.0.2",
3232
"bytebuffer": "^5.0.1",

packages/core/src/core/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,11 @@ const onCallDevice = async (
289289
return createResponseMessage(method.responseID, false, { error: e });
290290
}
291291

292+
if (method.payload?.onlyConnectBleDevice) {
293+
Log.debug('Call API - only connect ble device: ', device?.mainId);
294+
return createResponseMessage(method.responseID, true, null);
295+
}
296+
292297
Log.debug('Call API - setDevice: ', device.mainId);
293298
method.setDevice?.(device);
294299
method.context = context;
@@ -687,6 +692,9 @@ let bleTimeoutRetry = 0;
687692
async function connectDeviceForBle(method: BaseMethod, device: Device) {
688693
try {
689694
await device.acquire();
695+
if (method.payload?.onlyConnectBleDevice) {
696+
return;
697+
}
690698
await device.initialize(parseInitOptions(method));
691699
} catch (err) {
692700
if (err.errorCode === HardwareErrorCode.BleTimeoutError && bleTimeoutRetry <= 5) {

packages/core/src/device/Device.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,14 @@ export class Device extends EventEmitter {
201201
connectId: DataManager.isBleConnect(env) ? this.mainId || null : getDeviceUUID(this.features),
202202
/** Hardware ID, will not change at any time */
203203
uuid: getDeviceUUID(this.features),
204+
communicationType: this.originalDescriptor.type,
204205
sdkInstanceId: this.sdkInstanceId,
205206
instanceId: this.instanceId,
206207
createdAt: this.createdAt,
207208
deviceType,
208209
/** ID for current seeds, will clear after replace a new seed at device */
209210
deviceId: this.features.device_id || null,
210-
path: this.originalDescriptor.path,
211+
path: this.originalDescriptor?.path,
211212
bleName,
212213
name: bleName || label || `OneKey ${deviceType?.toUpperCase()}`,
213214
label: label || 'OneKey',

packages/core/src/types/device.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { EDeviceType } from '@onekeyfe/hd-shared';
22

33
import type { IVersionArray } from './settings';
44
import type { PROTO } from '../constants';
5+
import type { OneKeyDeviceCommunicationType } from '@onekeyfe/hd-transport';
56

67
export type DeviceStatus = 'available' | 'occupied' | 'used';
78

@@ -25,6 +26,7 @@ export type KnownDevice = {
2526
uuid: string;
2627
deviceId: string | null;
2728
deviceType: IDeviceType | null;
29+
communicationType: OneKeyDeviceCommunicationType | null;
2830
path: string;
2931
label: string;
3032
bleName: string | null;

packages/core/src/types/params.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ export interface CommonParams {
4242
* Skip passphrase check
4343
*/
4444
skipPassphraseCheck?: boolean;
45+
46+
/**
47+
* Only connect device, not initialize device, only ble connect
48+
*/
49+
onlyConnectBleDevice?: boolean;
4550
}
4651

4752
export type Params<T> = CommonParams & T & { bundle?: undefined };

packages/hd-ble-sdk/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@onekeyfe/hd-ble-sdk",
3-
"version": "1.1.20-alpha.0",
3+
"version": "1.1.20-alpha.1",
44
"author": "OneKey",
55
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
66
"license": "ISC",
@@ -20,8 +20,8 @@
2020
"lint:fix": "eslint . --fix"
2121
},
2222
"dependencies": {
23-
"@onekeyfe/hd-core": "1.1.20-alpha.0",
24-
"@onekeyfe/hd-shared": "1.1.20-alpha.0",
25-
"@onekeyfe/hd-transport-react-native": "1.1.20-alpha.0"
23+
"@onekeyfe/hd-core": "1.1.20-alpha.1",
24+
"@onekeyfe/hd-shared": "1.1.20-alpha.1",
25+
"@onekeyfe/hd-transport-react-native": "1.1.20-alpha.1"
2626
}
2727
}

packages/hd-common-connect-sdk/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@onekeyfe/hd-common-connect-sdk",
3-
"version": "1.1.20-alpha.0",
3+
"version": "1.1.20-alpha.1",
44
"author": "OneKey",
55
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
66
"license": "ISC",
@@ -20,11 +20,11 @@
2020
"lint:fix": "eslint . --fix"
2121
},
2222
"dependencies": {
23-
"@onekeyfe/hd-core": "1.1.20-alpha.0",
24-
"@onekeyfe/hd-shared": "1.1.20-alpha.0",
25-
"@onekeyfe/hd-transport-emulator": "1.1.20-alpha.0",
26-
"@onekeyfe/hd-transport-http": "1.1.20-alpha.0",
27-
"@onekeyfe/hd-transport-lowlevel": "1.1.20-alpha.0",
28-
"@onekeyfe/hd-transport-web-device": "1.1.20-alpha.0"
23+
"@onekeyfe/hd-core": "1.1.20-alpha.1",
24+
"@onekeyfe/hd-shared": "1.1.20-alpha.1",
25+
"@onekeyfe/hd-transport-emulator": "1.1.20-alpha.1",
26+
"@onekeyfe/hd-transport-http": "1.1.20-alpha.1",
27+
"@onekeyfe/hd-transport-lowlevel": "1.1.20-alpha.1",
28+
"@onekeyfe/hd-transport-web-device": "1.1.20-alpha.1"
2929
}
3030
}

0 commit comments

Comments
 (0)