Skip to content

Commit 55cfd03

Browse files
feat: attach1s (#568)
* feat: attach pin on classic1s * chore: release 1.1.12-alpha.2 * feat: support classic1s
1 parent bc735a9 commit 55cfd03

File tree

22 files changed

+83
-60
lines changed

22 files changed

+83
-60
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.12-alpha.1",
5+
"version": "1.1.12-alpha.2",
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.12-alpha.1",
25+
"@onekeyfe/hd-transport-electron": "1.1.12-alpha.2",
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.12-alpha.1",
3+
"version": "1.1.12-alpha.2",
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.12-alpha.1",
23-
"@onekeyfe/hd-common-connect-sdk": "1.1.12-alpha.1",
24-
"@onekeyfe/hd-core": "1.1.12-alpha.1",
25-
"@onekeyfe/hd-web-sdk": "1.1.12-alpha.1",
22+
"@onekeyfe/hd-ble-sdk": "1.1.12-alpha.2",
23+
"@onekeyfe/hd-common-connect-sdk": "1.1.12-alpha.2",
24+
"@onekeyfe/hd-core": "1.1.12-alpha.2",
25+
"@onekeyfe/hd-web-sdk": "1.1.12-alpha.2",
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.12-alpha.1",
3+
"version": "1.1.12-alpha.2",
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-core": "1.1.12-alpha.1",
21-
"@onekeyfe/hd-shared": "1.1.12-alpha.1",
22-
"@onekeyfe/hd-web-sdk": "1.1.12-alpha.1",
20+
"@onekeyfe/hd-core": "1.1.12-alpha.2",
21+
"@onekeyfe/hd-shared": "1.1.12-alpha.2",
22+
"@onekeyfe/hd-web-sdk": "1.1.12-alpha.2",
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/connect-examples/shared-constants/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@onekey-internal/shared-constants",
3-
"version": "1.1.12-alpha.1",
3+
"version": "1.1.12-alpha.2",
44
"private": true,
55
"author": "OneKey",
66
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",

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.12-alpha.1",
3+
"version": "1.1.12-alpha.2",
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.12-alpha.1",
29-
"@onekeyfe/hd-transport": "1.1.12-alpha.1",
28+
"@onekeyfe/hd-shared": "1.1.12-alpha.2",
29+
"@onekeyfe/hd-transport": "1.1.12-alpha.2",
3030
"axios": "^0.27.2",
3131
"bignumber.js": "^9.0.2",
3232
"bytebuffer": "^5.0.1",

packages/core/src/data/messages/messages.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3063,7 +3063,8 @@
30633063
"PinMatrixRequestType_WipeCodeFirst": 4,
30643064
"PinMatrixRequestType_WipeCodeSecond": 5,
30653065
"PinMatrixRequestType_BackupFirst": 6,
3066-
"PinMatrixRequestType_BackupSecond": 7
3066+
"PinMatrixRequestType_BackupSecond": 7,
3067+
"PinMatrixRequestType_AttachToPin": 8000
30673068
}
30683069
}
30693070
}
@@ -6619,7 +6620,8 @@
66196620
"Capability_U2F": 14,
66206621
"Capability_Shamir": 15,
66216622
"Capability_ShamirGroups": 16,
6622-
"Capability_PassphraseEntry": 17
6623+
"Capability_PassphraseEntry": 17,
6624+
"Capability_AttachToPin": 8000
66236625
}
66246626
}
66256627
}

packages/core/src/device/Device.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import EventEmitter from 'events';
22
import semver from 'semver';
3-
import { OneKeyDeviceInfo as DeviceDescriptor } from '@onekeyfe/hd-transport';
3+
import { OneKeyDeviceInfo as DeviceDescriptor, Enum_Capability } from '@onekeyfe/hd-transport';
44
import {
55
createDeferred,
66
Deferred,
@@ -47,6 +47,7 @@ import { PROTO } from '../constants';
4747
import { DataManager } from '../data-manager';
4848
import TransportManager from '../data-manager/TransportManager';
4949
import { toHardened } from '../api/helpers/pathUtils';
50+
import { existCapability } from '../utils/capabilitieUtils';
5051

5152
export type InitOptions = {
5253
initSession?: boolean;
@@ -765,7 +766,15 @@ export class Device extends EventEmitter {
765766
type => this.supportUnlockVersionRange()[type]
766767
);
767768

768-
if (versionRange && semver.gte(firmwareVersion, versionRange.min)) {
769+
const supportAttachPinCapability = existCapability(
770+
this.features,
771+
Enum_Capability.Capability_AttachToPin
772+
);
773+
774+
const supportUnlock =
775+
supportAttachPinCapability || (versionRange && semver.gte(firmwareVersion, versionRange.min));
776+
777+
if (supportUnlock) {
769778
const res = await this.commands.typedCall('UnLockDevice', 'UnLockDeviceResponse');
770779
if (this.features) {
771780
this.features.unlocked = res.message.unlocked == null ? null : res.message.unlocked;

packages/core/src/utils/capabilitieUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Enum_Capability } from '@onekeyfe/hd-transport';
22
import { Features } from '../types/device';
33

4-
export const existCapability = (features: Features, capability: Enum_Capability) =>
4+
export const existCapability = (features?: Features, capability?: Enum_Capability) =>
55
// @ts-expect-error
66
features?.capabilities?.includes(capability);
77

packages/core/src/utils/deviceFeaturesUtils.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import semver from 'semver';
22
import { isNaN } from 'lodash';
33
import { EDeviceType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
4+
import { Enum_Capability } from '@onekeyfe/hd-transport';
45
import { toHardened } from '../api/helpers/pathUtils';
56
import { DeviceCommands } from '../device/DeviceCommands';
67
import type { Features, SupportFeatureType } from '../types';
@@ -10,6 +11,7 @@ import { PROTOBUF_MESSAGE_CONFIG } from '../data-manager/MessagesConfig';
1011
import { Device } from '../device/Device';
1112
import { getDeviceType } from './deviceInfoUtils';
1213
import { getDeviceFirmwareVersion } from './deviceVersionUtils';
14+
import { existCapability } from './capabilitieUtils';
1315

1416
export const getSupportMessageVersion = (
1517
features: Features | undefined
@@ -138,7 +140,15 @@ export const getPassphraseState = async (
138140
const firmwareVersion = getDeviceFirmwareVersion(features);
139141
const deviceType = getDeviceType(features);
140142

141-
if (deviceType === EDeviceType.Pro && semver.gte(firmwareVersion.join('.'), '4.15.0')) {
143+
const supportAttachPinCapability = existCapability(
144+
features,
145+
Enum_Capability.Capability_AttachToPin
146+
);
147+
const supportGetPassphraseState =
148+
supportAttachPinCapability ||
149+
(deviceType === EDeviceType.Pro && semver.gte(firmwareVersion.join('.'), '4.15.0'));
150+
151+
if (supportGetPassphraseState) {
142152
const { message, type } = await commands.typedCall('GetPassphraseState', 'PassphraseState', {
143153
passphrase_state: options?.onlyMainPin ? undefined : options?.expectPassphraseState,
144154
});

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.12-alpha.1",
3+
"version": "1.1.12-alpha.2",
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.12-alpha.1",
24-
"@onekeyfe/hd-shared": "1.1.12-alpha.1",
25-
"@onekeyfe/hd-transport-react-native": "1.1.12-alpha.1"
23+
"@onekeyfe/hd-core": "1.1.12-alpha.2",
24+
"@onekeyfe/hd-shared": "1.1.12-alpha.2",
25+
"@onekeyfe/hd-transport-react-native": "1.1.12-alpha.2"
2626
}
2727
}

0 commit comments

Comments
 (0)