@onekeyfe/hardware-cli 1.2.0-alpha.50 → 1.2.0-alpha.52
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/pinentry.d.ts +0 -1
- package/dist/sdk.d.ts +0 -8
- package/dist/sdk.js +3 -12
- package/package.json +6 -6
- package/src/__tests__/wallet-session.test.ts +0 -9
- package/src/pinentry.ts +0 -1
- package/src/sdk.ts +4 -12
package/dist/pinentry.d.ts
CHANGED
package/dist/sdk.d.ts
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
* but public SDK responses never expose new device session ids
|
|
10
10
|
*/
|
|
11
11
|
import HardwareSDK from '@onekeyfe/hd-common-connect-sdk';
|
|
12
|
-
import type { PinentryResult } from './pinentry';
|
|
13
12
|
export interface SDKOptions {
|
|
14
13
|
connectId?: string;
|
|
15
14
|
passphraseState?: string;
|
|
@@ -17,13 +16,6 @@ export interface SDKOptions {
|
|
|
17
16
|
debug?: boolean;
|
|
18
17
|
transport?: 'usb' | 'ble';
|
|
19
18
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Prompt user to select wallet type (aligns with app-monorepo flow):
|
|
22
|
-
* 1. Standard wallet (no passphrase)
|
|
23
|
-
* 2. Hidden wallet — enter passphrase via pinentry (secure OS dialog)
|
|
24
|
-
* 3. Hidden wallet — enter passphrase on device screen
|
|
25
|
-
*/
|
|
26
|
-
export declare function resolvePassphraseByChoice(choice: '1' | '2' | '3' | '4'): Promise<PinentryResult>;
|
|
27
19
|
export declare function createSDK(opts: SDKOptions): Promise<typeof HardwareSDK>;
|
|
28
20
|
/**
|
|
29
21
|
* Release the SDK and clear the singleton. Must be called before the CLI
|
package/dist/sdk.js
CHANGED
|
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.disposeSDK = exports.createSDK =
|
|
39
|
+
exports.disposeSDK = exports.createSDK = void 0;
|
|
40
40
|
const readline = __importStar(require("node:readline"));
|
|
41
41
|
const hd_common_connect_sdk_1 = __importDefault(require("@onekeyfe/hd-common-connect-sdk"));
|
|
42
42
|
const hd_core_1 = require("@onekeyfe/hd-core");
|
|
@@ -76,15 +76,8 @@ function resolvePassphraseByChoice(choice) {
|
|
|
76
76
|
return Promise.resolve({ value: '', passphraseOnDevice: false });
|
|
77
77
|
if (choice === '2')
|
|
78
78
|
return (0, pinentry_1.promptPassphraseViaPinentry)();
|
|
79
|
-
if (choice === '4')
|
|
80
|
-
return Promise.resolve({
|
|
81
|
-
value: '',
|
|
82
|
-
passphraseOnDevice: false,
|
|
83
|
-
attachPinOnDevice: true,
|
|
84
|
-
});
|
|
85
79
|
return Promise.resolve({ value: '', passphraseOnDevice: true });
|
|
86
80
|
}
|
|
87
|
-
exports.resolvePassphraseByChoice = resolvePassphraseByChoice;
|
|
88
81
|
function promptPassphraseMode() {
|
|
89
82
|
if (!process.stdin.isTTY) {
|
|
90
83
|
return Promise.resolve({ value: '', passphraseOnDevice: true });
|
|
@@ -101,17 +94,16 @@ function promptPassphraseMode() {
|
|
|
101
94
|
' 1. Standard wallet (no passphrase)',
|
|
102
95
|
' 2. Hidden wallet — enter passphrase on this computer (pinentry)',
|
|
103
96
|
' 3. Hidden wallet — enter passphrase on device screen',
|
|
104
|
-
' 4. Attach PIN wallet — enter Attach PIN on device screen',
|
|
105
97
|
'',
|
|
106
98
|
].join('\n'));
|
|
107
99
|
rl.question('Enter selection [1/2/3]: ', answer => {
|
|
108
100
|
const n = answer.trim();
|
|
109
|
-
if (n === '1' || n === '2' || n === '3'
|
|
101
|
+
if (n === '1' || n === '2' || n === '3') {
|
|
110
102
|
rl.close();
|
|
111
103
|
resolvePassphraseByChoice(n).then(resolve);
|
|
112
104
|
return;
|
|
113
105
|
}
|
|
114
|
-
process.stderr.write('Invalid selection. Enter 1, 2,
|
|
106
|
+
process.stderr.write('Invalid selection. Enter 1, 2, or 3.\n');
|
|
115
107
|
prompt();
|
|
116
108
|
});
|
|
117
109
|
};
|
|
@@ -155,7 +147,6 @@ function registerEventHandlers(sdk) {
|
|
|
155
147
|
payload: {
|
|
156
148
|
value: result.value,
|
|
157
149
|
passphraseOnDevice: result.passphraseOnDevice,
|
|
158
|
-
attachPinOnDevice: result.attachPinOnDevice,
|
|
159
150
|
save: false,
|
|
160
151
|
},
|
|
161
152
|
});
|
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.52",
|
|
4
4
|
"description": "OneKey hardware wallet CLI for testing device communication",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"test": "jest"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@onekeyfe/hd-common-connect-sdk": "1.2.0-alpha.
|
|
35
|
-
"@onekeyfe/hd-core": "1.2.0-alpha.
|
|
36
|
-
"@onekeyfe/hd-shared": "1.2.0-alpha.
|
|
37
|
-
"@onekeyfe/hd-transport-usb": "1.2.0-alpha.
|
|
34
|
+
"@onekeyfe/hd-common-connect-sdk": "1.2.0-alpha.52",
|
|
35
|
+
"@onekeyfe/hd-core": "1.2.0-alpha.52",
|
|
36
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.52",
|
|
37
|
+
"@onekeyfe/hd-transport-usb": "1.2.0-alpha.52",
|
|
38
38
|
"@stoprocent/noble": "2.3.16",
|
|
39
39
|
"commander": "^12.0.0"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "d8fd8f3d30c4ff3653d0379d5c3e1c100414b61e"
|
|
42
42
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { prepareSession } from '../cli';
|
|
2
|
-
import { resolvePassphraseByChoice } from '../sdk';
|
|
3
2
|
import { preloadSessionFromKeychain } from '../session';
|
|
4
3
|
|
|
5
4
|
jest.mock('../session', () => ({
|
|
@@ -8,14 +7,6 @@ jest.mock('../session', () => ({
|
|
|
8
7
|
}));
|
|
9
8
|
|
|
10
9
|
describe('CLI wallet session', () => {
|
|
11
|
-
test('maps the Attach PIN choice to an on-device Attach PIN response', async () => {
|
|
12
|
-
await expect(resolvePassphraseByChoice('4')).resolves.toEqual({
|
|
13
|
-
value: '',
|
|
14
|
-
passphraseOnDevice: false,
|
|
15
|
-
attachPinOnDevice: true,
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
10
|
test('uses the public wallet identity without persisting an internal session id', async () => {
|
|
20
11
|
const sdk = {
|
|
21
12
|
searchDevices: jest.fn().mockResolvedValue({
|
package/src/pinentry.ts
CHANGED
package/src/sdk.ts
CHANGED
|
@@ -59,15 +59,9 @@ let sdkReadyPromise: Promise<typeof HardwareSDK> | null = null;
|
|
|
59
59
|
* 2. Hidden wallet — enter passphrase via pinentry (secure OS dialog)
|
|
60
60
|
* 3. Hidden wallet — enter passphrase on device screen
|
|
61
61
|
*/
|
|
62
|
-
|
|
62
|
+
function resolvePassphraseByChoice(choice: '1' | '2' | '3'): Promise<PinentryResult> {
|
|
63
63
|
if (choice === '1') return Promise.resolve({ value: '', passphraseOnDevice: false });
|
|
64
64
|
if (choice === '2') return promptPassphraseViaPinentry();
|
|
65
|
-
if (choice === '4')
|
|
66
|
-
return Promise.resolve({
|
|
67
|
-
value: '',
|
|
68
|
-
passphraseOnDevice: false,
|
|
69
|
-
attachPinOnDevice: true,
|
|
70
|
-
});
|
|
71
65
|
return Promise.resolve({ value: '', passphraseOnDevice: true });
|
|
72
66
|
}
|
|
73
67
|
|
|
@@ -90,19 +84,18 @@ function promptPassphraseMode(): Promise<PinentryResult> {
|
|
|
90
84
|
' 1. Standard wallet (no passphrase)',
|
|
91
85
|
' 2. Hidden wallet — enter passphrase on this computer (pinentry)',
|
|
92
86
|
' 3. Hidden wallet — enter passphrase on device screen',
|
|
93
|
-
' 4. Attach PIN wallet — enter Attach PIN on device screen',
|
|
94
87
|
'',
|
|
95
88
|
].join('\n')
|
|
96
89
|
);
|
|
97
90
|
|
|
98
91
|
rl.question('Enter selection [1/2/3]: ', answer => {
|
|
99
|
-
const n = answer.trim() as '1' | '2' | '3'
|
|
100
|
-
if (n === '1' || n === '2' || n === '3'
|
|
92
|
+
const n = answer.trim() as '1' | '2' | '3';
|
|
93
|
+
if (n === '1' || n === '2' || n === '3') {
|
|
101
94
|
rl.close();
|
|
102
95
|
resolvePassphraseByChoice(n).then(resolve);
|
|
103
96
|
return;
|
|
104
97
|
}
|
|
105
|
-
process.stderr.write('Invalid selection. Enter 1, 2,
|
|
98
|
+
process.stderr.write('Invalid selection. Enter 1, 2, or 3.\n');
|
|
106
99
|
prompt();
|
|
107
100
|
});
|
|
108
101
|
};
|
|
@@ -150,7 +143,6 @@ function registerEventHandlers(sdk: typeof HardwareSDK): void {
|
|
|
150
143
|
payload: {
|
|
151
144
|
value: result.value,
|
|
152
145
|
passphraseOnDevice: result.passphraseOnDevice,
|
|
153
|
-
attachPinOnDevice: result.attachPinOnDevice,
|
|
154
146
|
save: false,
|
|
155
147
|
},
|
|
156
148
|
});
|