@onekeyfe/hardware-cli 1.2.0-alpha.0 → 1.2.0-alpha.2
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/cli.js +11 -11
- package/package.json +6 -6
- package/src/cli.ts +12 -22
package/dist/cli.js
CHANGED
|
@@ -59,8 +59,8 @@ program
|
|
|
59
59
|
const features = await sdk.getFeatures(device.connectId);
|
|
60
60
|
if (features?.success && features.payload) {
|
|
61
61
|
device.features = features.payload;
|
|
62
|
-
device.name = features.payload.label || features.payload.
|
|
63
|
-
const devType = features.payload.
|
|
62
|
+
device.name = features.payload.label || features.payload.bleName || device.name;
|
|
63
|
+
const devType = features.payload.deviceType;
|
|
64
64
|
if (devType) {
|
|
65
65
|
device.deviceType = devType;
|
|
66
66
|
}
|
|
@@ -592,8 +592,8 @@ sessionCmd
|
|
|
592
592
|
skipPassphraseCheck: true,
|
|
593
593
|
});
|
|
594
594
|
const featPayload = featResult?.success ? featResult.payload : undefined;
|
|
595
|
-
const deviceId = featPayload?.
|
|
596
|
-
const sessionId = passphraseSessionId || featPayload?.
|
|
595
|
+
const deviceId = featPayload?.deviceId || device.deviceId || '';
|
|
596
|
+
const sessionId = passphraseSessionId || featPayload?.sessionId || '';
|
|
597
597
|
// 6. Save to keychain
|
|
598
598
|
if (passphraseState && deviceId && sessionId) {
|
|
599
599
|
await (0, session_1.saveSessionToKeychain)(deviceId, passphraseState, sessionId);
|
|
@@ -723,18 +723,18 @@ globalOpts) {
|
|
|
723
723
|
// ── Step 2: Get features if searchDevices didn't populate them ──
|
|
724
724
|
// getFeatures failures here are non-fatal — we fall through to Step 3
|
|
725
725
|
// which will fail with a clearer error if the device is truly unreachable.
|
|
726
|
-
let deviceId = device.features?.
|
|
726
|
+
let deviceId = device.features?.deviceId || device.deviceId || '';
|
|
727
727
|
let deviceType = (0, hd_core_1.getDeviceType)(device.features);
|
|
728
728
|
let unlocked = device.features?.unlocked;
|
|
729
|
-
let passphraseProtection = device.features?.
|
|
729
|
+
let passphraseProtection = device.features?.passphraseProtection;
|
|
730
730
|
if (!deviceId || unlocked == null || passphraseProtection == null) {
|
|
731
731
|
try {
|
|
732
732
|
const featResult = await sdk.getFeatures(connectId);
|
|
733
733
|
if (featResult?.success && featResult.payload) {
|
|
734
|
-
deviceId = featResult.payload.
|
|
734
|
+
deviceId = featResult.payload.deviceId || deviceId;
|
|
735
735
|
deviceType = (0, hd_core_1.getDeviceType)(featResult.payload) || deviceType;
|
|
736
736
|
unlocked = featResult.payload.unlocked;
|
|
737
|
-
passphraseProtection = featResult.payload.
|
|
737
|
+
passphraseProtection = featResult.payload.passphraseProtection;
|
|
738
738
|
}
|
|
739
739
|
}
|
|
740
740
|
catch {
|
|
@@ -750,9 +750,9 @@ globalOpts) {
|
|
|
750
750
|
if (wasLocked) {
|
|
751
751
|
process.stderr.write('[onekey-hw] Device is locked. Unlocking (PIN required)...\n');
|
|
752
752
|
const { payload: feat } = await unlockWithRetry(sdk, connectId);
|
|
753
|
-
deviceId = feat.
|
|
753
|
+
deviceId = feat.deviceId || deviceId;
|
|
754
754
|
unlocked = feat.unlocked;
|
|
755
|
-
passphraseProtection = feat.
|
|
755
|
+
passphraseProtection = feat.passphraseProtection;
|
|
756
756
|
}
|
|
757
757
|
if (!globalOpts.deviceId && deviceId) {
|
|
758
758
|
globalOpts.deviceId = deviceId;
|
|
@@ -793,7 +793,7 @@ globalOpts) {
|
|
|
793
793
|
passphraseState,
|
|
794
794
|
skipPassphraseCheck: true,
|
|
795
795
|
});
|
|
796
|
-
const sessionId = passphraseSessionId || (featAfter?.success ? featAfter.payload?.
|
|
796
|
+
const sessionId = passphraseSessionId || (featAfter?.success ? featAfter.payload?.sessionId : undefined);
|
|
797
797
|
if (sessionId) {
|
|
798
798
|
await (0, session_1.saveSessionToKeychain)(deviceId, passphraseState, sessionId);
|
|
799
799
|
await (0, session_1.preloadSessionFromKeychain)(deviceId);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hardware-cli",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.2",
|
|
4
4
|
"description": "OneKey hardware wallet CLI for testing device communication",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"test": "jest"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@onekeyfe/hd-common-connect-sdk": "1.2.0-alpha.
|
|
34
|
-
"@onekeyfe/hd-core": "1.2.0-alpha.
|
|
35
|
-
"@onekeyfe/hd-shared": "1.2.0-alpha.
|
|
36
|
-
"@onekeyfe/hd-transport-usb": "1.2.0-alpha.
|
|
33
|
+
"@onekeyfe/hd-common-connect-sdk": "1.2.0-alpha.2",
|
|
34
|
+
"@onekeyfe/hd-core": "1.2.0-alpha.2",
|
|
35
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.2",
|
|
36
|
+
"@onekeyfe/hd-transport-usb": "1.2.0-alpha.2",
|
|
37
37
|
"commander": "^12.0.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "6c183b7f7027f4b4d3db4f427f6360351a6c6680"
|
|
40
40
|
}
|
package/src/cli.ts
CHANGED
|
@@ -100,8 +100,8 @@ program
|
|
|
100
100
|
const features = await sdk.getFeatures(device.connectId);
|
|
101
101
|
if (features?.success && features.payload) {
|
|
102
102
|
device.features = features.payload;
|
|
103
|
-
device.name = features.payload.label || features.payload.
|
|
104
|
-
const devType = features.payload.
|
|
103
|
+
device.name = features.payload.label || features.payload.bleName || device.name;
|
|
104
|
+
const devType = features.payload.deviceType;
|
|
105
105
|
if (devType) {
|
|
106
106
|
device.deviceType = devType as IDeviceType;
|
|
107
107
|
}
|
|
@@ -757,8 +757,8 @@ sessionCmd
|
|
|
757
757
|
skipPassphraseCheck: true,
|
|
758
758
|
});
|
|
759
759
|
const featPayload = featResult?.success ? featResult.payload : undefined;
|
|
760
|
-
const deviceId = featPayload?.
|
|
761
|
-
const sessionId = passphraseSessionId || featPayload?.
|
|
760
|
+
const deviceId = featPayload?.deviceId || device.deviceId || '';
|
|
761
|
+
const sessionId = passphraseSessionId || featPayload?.sessionId || '';
|
|
762
762
|
|
|
763
763
|
// 6. Save to keychain
|
|
764
764
|
if (passphraseState && deviceId && sessionId) {
|
|
@@ -910,17 +910,7 @@ async function prepareSession(
|
|
|
910
910
|
return undefined;
|
|
911
911
|
}
|
|
912
912
|
|
|
913
|
-
const device = searchResult.payload[0] as
|
|
914
|
-
connectId?: string;
|
|
915
|
-
deviceId?: string;
|
|
916
|
-
features?: {
|
|
917
|
-
device_id?: string;
|
|
918
|
-
onekey_device_type?: string;
|
|
919
|
-
session_id?: string;
|
|
920
|
-
passphrase_protection?: boolean | null;
|
|
921
|
-
unlocked?: boolean | null;
|
|
922
|
-
};
|
|
923
|
-
};
|
|
913
|
+
const device = searchResult.payload[0] as EnrichedSearchDevice;
|
|
924
914
|
const connectId = device.connectId || globalOpts.connectId || '';
|
|
925
915
|
if (!globalOpts.connectId && connectId) {
|
|
926
916
|
globalOpts.connectId = connectId;
|
|
@@ -929,19 +919,19 @@ async function prepareSession(
|
|
|
929
919
|
// ── Step 2: Get features if searchDevices didn't populate them ──
|
|
930
920
|
// getFeatures failures here are non-fatal — we fall through to Step 3
|
|
931
921
|
// which will fail with a clearer error if the device is truly unreachable.
|
|
932
|
-
let deviceId = device.features?.
|
|
922
|
+
let deviceId = device.features?.deviceId || device.deviceId || '';
|
|
933
923
|
let deviceType = getDeviceType(device.features as Features | undefined);
|
|
934
924
|
let unlocked = device.features?.unlocked;
|
|
935
|
-
let passphraseProtection = device.features?.
|
|
925
|
+
let passphraseProtection = device.features?.passphraseProtection;
|
|
936
926
|
|
|
937
927
|
if (!deviceId || unlocked == null || passphraseProtection == null) {
|
|
938
928
|
try {
|
|
939
929
|
const featResult = await sdk.getFeatures(connectId);
|
|
940
930
|
if (featResult?.success && featResult.payload) {
|
|
941
|
-
deviceId = featResult.payload.
|
|
931
|
+
deviceId = featResult.payload.deviceId || deviceId;
|
|
942
932
|
deviceType = getDeviceType(featResult.payload) || deviceType;
|
|
943
933
|
unlocked = featResult.payload.unlocked;
|
|
944
|
-
passphraseProtection = featResult.payload.
|
|
934
|
+
passphraseProtection = featResult.payload.passphraseProtection;
|
|
945
935
|
}
|
|
946
936
|
} catch {
|
|
947
937
|
/* non-fatal — Step 3 will surface a clear error if device is gone */
|
|
@@ -957,9 +947,9 @@ async function prepareSession(
|
|
|
957
947
|
if (wasLocked) {
|
|
958
948
|
process.stderr.write('[onekey-hw] Device is locked. Unlocking (PIN required)...\n');
|
|
959
949
|
const { payload: feat } = await unlockWithRetry(sdk, connectId);
|
|
960
|
-
deviceId = feat.
|
|
950
|
+
deviceId = feat.deviceId || deviceId;
|
|
961
951
|
unlocked = feat.unlocked;
|
|
962
|
-
passphraseProtection = feat.
|
|
952
|
+
passphraseProtection = feat.passphraseProtection;
|
|
963
953
|
}
|
|
964
954
|
|
|
965
955
|
if (!globalOpts.deviceId && deviceId) {
|
|
@@ -1009,7 +999,7 @@ async function prepareSession(
|
|
|
1009
999
|
skipPassphraseCheck: true,
|
|
1010
1000
|
});
|
|
1011
1001
|
const sessionId =
|
|
1012
|
-
passphraseSessionId || (featAfter?.success ? featAfter.payload?.
|
|
1002
|
+
passphraseSessionId || (featAfter?.success ? featAfter.payload?.sessionId : undefined);
|
|
1013
1003
|
if (sessionId) {
|
|
1014
1004
|
await saveSessionToKeychain(deviceId, passphraseState, sessionId);
|
|
1015
1005
|
await preloadSessionFromKeychain(deviceId);
|