@onekeyfe/hardware-cli 1.2.0-alpha.0 → 1.2.0-alpha.1
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 +15 -15
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?.toLowerCase();
|
|
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.1",
|
|
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.1",
|
|
34
|
+
"@onekeyfe/hd-core": "1.2.0-alpha.1",
|
|
35
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.1",
|
|
36
|
+
"@onekeyfe/hd-transport-usb": "1.2.0-alpha.1",
|
|
37
37
|
"commander": "^12.0.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "4f4aae3a47be7bd54b4db4a10c400056784e01bd"
|
|
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?.toLowerCase();
|
|
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) {
|
|
@@ -914,10 +914,10 @@ async function prepareSession(
|
|
|
914
914
|
connectId?: string;
|
|
915
915
|
deviceId?: string;
|
|
916
916
|
features?: {
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
917
|
+
deviceId?: string | null;
|
|
918
|
+
deviceType?: string;
|
|
919
|
+
sessionId?: string | null;
|
|
920
|
+
passphraseProtection?: boolean | null;
|
|
921
921
|
unlocked?: boolean | null;
|
|
922
922
|
};
|
|
923
923
|
};
|
|
@@ -929,19 +929,19 @@ async function prepareSession(
|
|
|
929
929
|
// ── Step 2: Get features if searchDevices didn't populate them ──
|
|
930
930
|
// getFeatures failures here are non-fatal — we fall through to Step 3
|
|
931
931
|
// which will fail with a clearer error if the device is truly unreachable.
|
|
932
|
-
let deviceId = device.features?.
|
|
932
|
+
let deviceId = device.features?.deviceId || device.deviceId || '';
|
|
933
933
|
let deviceType = getDeviceType(device.features as Features | undefined);
|
|
934
934
|
let unlocked = device.features?.unlocked;
|
|
935
|
-
let passphraseProtection = device.features?.
|
|
935
|
+
let passphraseProtection = device.features?.passphraseProtection;
|
|
936
936
|
|
|
937
937
|
if (!deviceId || unlocked == null || passphraseProtection == null) {
|
|
938
938
|
try {
|
|
939
939
|
const featResult = await sdk.getFeatures(connectId);
|
|
940
940
|
if (featResult?.success && featResult.payload) {
|
|
941
|
-
deviceId = featResult.payload.
|
|
941
|
+
deviceId = featResult.payload.deviceId || deviceId;
|
|
942
942
|
deviceType = getDeviceType(featResult.payload) || deviceType;
|
|
943
943
|
unlocked = featResult.payload.unlocked;
|
|
944
|
-
passphraseProtection = featResult.payload.
|
|
944
|
+
passphraseProtection = featResult.payload.passphraseProtection;
|
|
945
945
|
}
|
|
946
946
|
} catch {
|
|
947
947
|
/* non-fatal — Step 3 will surface a clear error if device is gone */
|
|
@@ -957,9 +957,9 @@ async function prepareSession(
|
|
|
957
957
|
if (wasLocked) {
|
|
958
958
|
process.stderr.write('[onekey-hw] Device is locked. Unlocking (PIN required)...\n');
|
|
959
959
|
const { payload: feat } = await unlockWithRetry(sdk, connectId);
|
|
960
|
-
deviceId = feat.
|
|
960
|
+
deviceId = feat.deviceId || deviceId;
|
|
961
961
|
unlocked = feat.unlocked;
|
|
962
|
-
passphraseProtection = feat.
|
|
962
|
+
passphraseProtection = feat.passphraseProtection;
|
|
963
963
|
}
|
|
964
964
|
|
|
965
965
|
if (!globalOpts.deviceId && deviceId) {
|
|
@@ -1009,7 +1009,7 @@ async function prepareSession(
|
|
|
1009
1009
|
skipPassphraseCheck: true,
|
|
1010
1010
|
});
|
|
1011
1011
|
const sessionId =
|
|
1012
|
-
passphraseSessionId || (featAfter?.success ? featAfter.payload?.
|
|
1012
|
+
passphraseSessionId || (featAfter?.success ? featAfter.payload?.sessionId : undefined);
|
|
1013
1013
|
if (sessionId) {
|
|
1014
1014
|
await saveSessionToKeychain(deviceId, passphraseState, sessionId);
|
|
1015
1015
|
await preloadSessionFromKeychain(deviceId);
|