@onekeyfe/hardware-cli 1.1.26-alpha.9 → 1.1.27-alpha.30
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.js +1 -6
- package/jest.config.js +5 -0
- package/package.json +6 -6
- package/src/__tests__/pinentry.test.ts +3 -7
- package/src/pinentry.ts +3 -11
- package/src/sdk.ts +1 -3
package/dist/pinentry.js
CHANGED
|
@@ -15,12 +15,7 @@
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.promptPassphraseViaPinentry = exports.findPinentry = exports.parsePinentryStdout = exports.decodeAssuanData = void 0;
|
|
17
17
|
const node_child_process_1 = require("node:child_process");
|
|
18
|
-
const PINENTRY_PROGRAMS = [
|
|
19
|
-
'pinentry-mac',
|
|
20
|
-
'pinentry',
|
|
21
|
-
'pinentry-gnome3',
|
|
22
|
-
'pinentry-qt',
|
|
23
|
-
];
|
|
18
|
+
const PINENTRY_PROGRAMS = ['pinentry-mac', 'pinentry', 'pinentry-gnome3', 'pinentry-qt'];
|
|
24
19
|
// Assuan protocol percent-encodes %, CR, and LF in D data lines.
|
|
25
20
|
// Without decoding, a passphrase containing `%` would be silently corrupted
|
|
26
21
|
// (e.g. `a%b` -> `a%25b`), deriving a wrong passphraseState and exposing a
|
package/jest.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hardware-cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.27-alpha.30",
|
|
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.1.
|
|
34
|
-
"@onekeyfe/hd-core": "1.1.
|
|
35
|
-
"@onekeyfe/hd-shared": "1.1.
|
|
36
|
-
"@onekeyfe/hd-transport-usb": "1.1.
|
|
33
|
+
"@onekeyfe/hd-common-connect-sdk": "1.1.27-alpha.30",
|
|
34
|
+
"@onekeyfe/hd-core": "1.1.27-alpha.30",
|
|
35
|
+
"@onekeyfe/hd-shared": "1.1.27-alpha.30",
|
|
36
|
+
"@onekeyfe/hd-transport-usb": "1.1.27-alpha.30",
|
|
37
37
|
"commander": "^12.0.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "f1e3a93e766463007436eaa9aff4a271ffd8830c"
|
|
40
40
|
}
|
|
@@ -23,9 +23,7 @@ describe('decodeAssuanData', () => {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
it('decodes CR (%0D) and LF (%0A)', () => {
|
|
26
|
-
expect(decodeAssuanData('line1%0Dline2%0Aline3')).toBe(
|
|
27
|
-
'line1\rline2\nline3'
|
|
28
|
-
);
|
|
26
|
+
expect(decodeAssuanData('line1%0Dline2%0Aline3')).toBe('line1\rline2\nline3');
|
|
29
27
|
});
|
|
30
28
|
|
|
31
29
|
it('handles trailing percent encoding', () => {
|
|
@@ -84,8 +82,7 @@ describe('decodeAssuanData', () => {
|
|
|
84
82
|
|
|
85
83
|
describe('parsePinentryStdout', () => {
|
|
86
84
|
it('parses a real pinentry-mac success response', () => {
|
|
87
|
-
const stdout =
|
|
88
|
-
'OK Pleased to meet you, process 38946\nOK\nOK\nD a%25b%25c\nOK\n';
|
|
85
|
+
const stdout = 'OK Pleased to meet you, process 38946\nOK\nOK\nD a%25b%25c\nOK\n';
|
|
89
86
|
expect(parsePinentryStdout(stdout)).toEqual({
|
|
90
87
|
data: 'a%b%c',
|
|
91
88
|
cancelled: false,
|
|
@@ -99,8 +96,7 @@ describe('parsePinentryStdout', () => {
|
|
|
99
96
|
});
|
|
100
97
|
|
|
101
98
|
it('flags cancellation via ERR 83886179', () => {
|
|
102
|
-
const stdout =
|
|
103
|
-
'OK Pleased to meet you\nOK\nOK\nERR 83886179 Operation cancelled\n';
|
|
99
|
+
const stdout = 'OK Pleased to meet you\nOK\nOK\nERR 83886179 Operation cancelled\n';
|
|
104
100
|
expect(parsePinentryStdout(stdout)).toEqual({ cancelled: true });
|
|
105
101
|
});
|
|
106
102
|
|
package/src/pinentry.ts
CHANGED
|
@@ -14,12 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
import { execFile, execFileSync } from 'node:child_process';
|
|
16
16
|
|
|
17
|
-
const PINENTRY_PROGRAMS = [
|
|
18
|
-
'pinentry-mac',
|
|
19
|
-
'pinentry',
|
|
20
|
-
'pinentry-gnome3',
|
|
21
|
-
'pinentry-qt',
|
|
22
|
-
];
|
|
17
|
+
const PINENTRY_PROGRAMS = ['pinentry-mac', 'pinentry', 'pinentry-gnome3', 'pinentry-qt'];
|
|
23
18
|
|
|
24
19
|
// Assuan protocol percent-encodes %, CR, and LF in D data lines.
|
|
25
20
|
// Without decoding, a passphrase containing `%` would be silently corrupted
|
|
@@ -46,8 +41,7 @@ export function parsePinentryStdout(stdout: string): {
|
|
|
46
41
|
} {
|
|
47
42
|
// Pinentry error code 83886179 is the canonical "user cancelled" signal —
|
|
48
43
|
// surfaces either as a non-zero exit or as an ERR line.
|
|
49
|
-
const cancelled =
|
|
50
|
-
stdout.includes('ERR 83886179') || stdout.includes('Operation cancelled');
|
|
44
|
+
const cancelled = stdout.includes('ERR 83886179') || stdout.includes('Operation cancelled');
|
|
51
45
|
|
|
52
46
|
const dataChunks = stdout
|
|
53
47
|
.split(/\r?\n/)
|
|
@@ -89,9 +83,7 @@ export function promptPassphraseViaPinentry(): Promise<PinentryResult> {
|
|
|
89
83
|
return new Promise((resolve, reject) => {
|
|
90
84
|
const pinentryBin = findPinentry();
|
|
91
85
|
if (!pinentryBin) {
|
|
92
|
-
process.stderr.write(
|
|
93
|
-
'[onekey-hw] No pinentry found, falling back to on-device entry.\n'
|
|
94
|
-
);
|
|
86
|
+
process.stderr.write('[onekey-hw] No pinentry found, falling back to on-device entry.\n');
|
|
95
87
|
resolve({ value: '', passphraseOnDevice: true });
|
|
96
88
|
return;
|
|
97
89
|
}
|
package/src/sdk.ts
CHANGED
|
@@ -56,9 +56,7 @@ let sdkReadyPromise: Promise<typeof HardwareSDK> | null = null;
|
|
|
56
56
|
* 2. Hidden wallet — enter passphrase via pinentry (secure OS dialog)
|
|
57
57
|
* 3. Hidden wallet — enter passphrase on device screen
|
|
58
58
|
*/
|
|
59
|
-
function resolvePassphraseByChoice(
|
|
60
|
-
choice: '1' | '2' | '3'
|
|
61
|
-
): Promise<PinentryResult> {
|
|
59
|
+
function resolvePassphraseByChoice(choice: '1' | '2' | '3'): Promise<PinentryResult> {
|
|
62
60
|
if (choice === '1') return Promise.resolve({ value: '', passphraseOnDevice: false });
|
|
63
61
|
if (choice === '2') return promptPassphraseViaPinentry();
|
|
64
62
|
return Promise.resolve({ value: '', passphraseOnDevice: true });
|