bitty-tui 0.0.7 → 0.0.8
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/components/ScrollView.js +1 -1
- package/dist/dashboard/DashboardView.js +4 -6
- package/dist/dashboard/components/HelpBar.d.ts +3 -1
- package/dist/dashboard/components/HelpBar.js +33 -2
- package/dist/dashboard/components/VaultList.js +38 -5
- package/dist/login/LoginView.js +10 -2
- package/package.json +1 -1
- package/readme.md +1 -1
|
@@ -25,7 +25,7 @@ export const ScrollView = ({ count, list, isActive, selectedIndex, onSelect, onS
|
|
|
25
25
|
}, { isActive });
|
|
26
26
|
useEffect(() => {
|
|
27
27
|
if (selectedIndex < offset)
|
|
28
|
-
setOffset(selectedIndex);
|
|
28
|
+
setOffset(selectedIndex > 0 ? selectedIndex : 0);
|
|
29
29
|
}, [selectedIndex]);
|
|
30
30
|
return (_jsx(Box, { flexDirection: "column", overflow: "hidden", children: list.slice(offset, offset + count).map((el, index) => children({
|
|
31
31
|
el,
|
|
@@ -37,16 +37,14 @@ export function DashboardView({ onLogout }) {
|
|
|
37
37
|
const listIndex = useMemo(() => {
|
|
38
38
|
if (!listSelected)
|
|
39
39
|
return 0;
|
|
40
|
-
|
|
40
|
+
const i = filteredCiphers.findIndex((c) => c.id === listSelected.id);
|
|
41
|
+
return i < 0 ? 0 : i;
|
|
41
42
|
}, [listSelected, filteredCiphers]);
|
|
42
43
|
const selectedCipher = detailMode === "new" ? editedCipher : filteredCiphers[listIndex];
|
|
43
44
|
const logout = async () => {
|
|
44
45
|
await clearConfig();
|
|
45
46
|
onLogout();
|
|
46
47
|
};
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
setListSelected(null);
|
|
49
|
-
}, [searchQuery]);
|
|
50
48
|
useEffect(() => {
|
|
51
49
|
setSyncState(sync);
|
|
52
50
|
}, [sync]);
|
|
@@ -104,7 +102,7 @@ export function DashboardView({ onLogout }) {
|
|
|
104
102
|
return (_jsxs(Box, { flexDirection: "column", width: "100%", height: stdout.rows - 1, children: [_jsx(Box, { borderStyle: "double", borderColor: primary, paddingX: 2, justifyContent: "center", flexShrink: 0, children: _jsx(Text, { bold: true, color: primary, children: "BiTTY" }) }), _jsxs(Box, { children: [_jsx(Box, { width: "40%", children: _jsx(TextInput, { id: "search", placeholder: focusedComponent === "search" ? "" : "[/] Search in vault", value: searchQuery, isActive: false, onChange: setSearchQuery, onSubmit: () => {
|
|
105
103
|
setFocusedComponent("list");
|
|
106
104
|
focusNext();
|
|
107
|
-
} }) }), statusMessage && (_jsx(Box, { width: "60%", padding: 1, children: _jsx(Text, { color: statusMessageColor, children: statusMessage }) }))] }), _jsxs(Box, { minHeight: 20, flexGrow: 1, children: [_jsx(VaultList, { filteredCiphers: filteredCiphers, isFocused:
|
|
105
|
+
} }) }), statusMessage && (_jsx(Box, { width: "60%", padding: 1, children: _jsx(Text, { color: statusMessageColor, children: statusMessage }) }))] }), _jsxs(Box, { minHeight: 20, flexGrow: 1, children: [_jsx(VaultList, { filteredCiphers: filteredCiphers, isFocused: ["list", "search"].includes(focusedComponent), selected: listIndex, onSelect: (index) => setListSelected(filteredCiphers[index] || null) }), _jsx(CipherDetail, { selectedCipher: showDetails ? selectedCipher : null, mode: detailMode, isFocused: focusedComponent === "detail", onChange: (cipher) => {
|
|
108
106
|
if (detailMode === "new") {
|
|
109
107
|
setEditedCipher(cipher);
|
|
110
108
|
return;
|
|
@@ -140,5 +138,5 @@ export function DashboardView({ onLogout }) {
|
|
|
140
138
|
showStatusMessage("Synchronization error", "error");
|
|
141
139
|
}
|
|
142
140
|
}
|
|
143
|
-
} })] }), _jsx(HelpBar, { focus: focusedComponent })] }));
|
|
141
|
+
} })] }), _jsx(HelpBar, { focus: focusedComponent, cipher: selectedCipher })] }));
|
|
144
142
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { Cipher } from "../../clients/bw.js";
|
|
2
|
+
export declare function HelpBar({ focus, cipher, }: {
|
|
2
3
|
focus: "list" | "search" | "detail";
|
|
4
|
+
cipher: Cipher | null | undefined;
|
|
3
5
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Text } from "ink";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { CipherType } from "../../clients/bw.js";
|
|
4
|
+
export function HelpBar({ focus, cipher, }) {
|
|
5
|
+
return (_jsxs(Box, { borderStyle: "single", borderColor: "gray", marginTop: 1, paddingX: 1, flexShrink: 0, justifyContent: "space-around", children: [_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "/ " }), "Search"] }), focus === "list" ? (_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "\u2191/\u2193 " }), "Navigate"] })) : focus === "detail" ? (_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Tab/Enter " }), "Next Field"] })) : (_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Esc " }), "Clear Search"] })), focus === "list" ? (_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Tab/Enter " }), "Select"] })) : focus === "detail" ? (_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Esc " }), "Focus List"] })) : (_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Tab/Enter " }), "Focus List"] })), ...copyButtons(focus, cipher), _jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Ctrl+w " }), "Logout"] })] }));
|
|
5
6
|
}
|
|
7
|
+
const copyButtons = (focus, cipher) => {
|
|
8
|
+
if (focus === "detail") {
|
|
9
|
+
return [
|
|
10
|
+
_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Ctrl+y " }), "Copy Field"] }),
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
switch (cipher?.type) {
|
|
14
|
+
case CipherType.Login:
|
|
15
|
+
return [
|
|
16
|
+
_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Ctrl+y " }), "Copy Password"] }, "copy-password"),
|
|
17
|
+
...(cipher.login?.totp
|
|
18
|
+
? [
|
|
19
|
+
_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Ctrl+t " }), "Copy TOTP"] }, "copy-totp"),
|
|
20
|
+
]
|
|
21
|
+
: []),
|
|
22
|
+
_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Ctrl+u " }), "Copy Username"] }, "copy-username"),
|
|
23
|
+
];
|
|
24
|
+
case CipherType.SecureNote:
|
|
25
|
+
return [
|
|
26
|
+
_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Ctrl+y " }), "Copy Note"] }, "copy-note"),
|
|
27
|
+
];
|
|
28
|
+
case CipherType.SSHKey:
|
|
29
|
+
return [
|
|
30
|
+
_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Ctrl+y " }), "Copy Private Key"] }, "copy-private-key"),
|
|
31
|
+
_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Ctrl+u " }), "Copy Public Key"] }, "copy-public-key"),
|
|
32
|
+
];
|
|
33
|
+
default:
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
};
|
|
@@ -23,12 +23,45 @@ export function VaultList({ filteredCiphers, isFocused, selected, onSelect, }) {
|
|
|
23
23
|
const { stdout } = useStdout();
|
|
24
24
|
const { showStatusMessage } = useStatusMessage();
|
|
25
25
|
useInput((input, key) => {
|
|
26
|
+
const cipher = selected !== null ? filteredCiphers[selected] : null;
|
|
27
|
+
let field, fldName;
|
|
26
28
|
if (key.ctrl && input === "y") {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
switch (cipher?.type) {
|
|
30
|
+
case CipherType.Login:
|
|
31
|
+
field = cipher.login?.password;
|
|
32
|
+
fldName = "Password";
|
|
33
|
+
break;
|
|
34
|
+
case CipherType.SecureNote:
|
|
35
|
+
field = cipher.notes;
|
|
36
|
+
fldName = "Note";
|
|
37
|
+
break;
|
|
38
|
+
case CipherType.SSHKey:
|
|
39
|
+
field = cipher.sshKey?.privateKey;
|
|
40
|
+
fldName = "Private Key";
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else if (key.ctrl && input === "u") {
|
|
45
|
+
switch (cipher?.type) {
|
|
46
|
+
case CipherType.Login:
|
|
47
|
+
field = cipher.login?.username;
|
|
48
|
+
fldName = "Username";
|
|
49
|
+
break;
|
|
50
|
+
case CipherType.SSHKey:
|
|
51
|
+
field = cipher.sshKey?.publicKey;
|
|
52
|
+
fldName = "Public Key";
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (key.ctrl && input === "t") {
|
|
57
|
+
if (cipher?.type === CipherType.Login) {
|
|
58
|
+
field = cipher.login?.totp;
|
|
59
|
+
fldName = "TOTP";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (field) {
|
|
63
|
+
clipboard.writeSync(field);
|
|
64
|
+
showStatusMessage(`📋 Copied ${fldName} to clipboard!`, "success");
|
|
32
65
|
}
|
|
33
66
|
}, { isActive: isFocused });
|
|
34
67
|
return (_jsx(Box, { flexDirection: "column", width: "40%", borderStyle: "round", borderColor: isFocused ? primaryLight : "gray", borderRightColor: "gray", paddingX: 1, overflow: "hidden", children: _jsx(ScrollView, { isActive: isFocused, count: Math.max(stdout.rows - 14, 20), list: filteredCiphers, selectedIndex: selected ?? 0, onSelect: onSelect, children: ({ el: cipher, selected }) => (_jsxs(Box, { justifyContent: "space-between", backgroundColor: selected ? (isFocused ? primary : primaryDark) : "", children: [_jsxs(Box, { children: [_jsxs(Text, { children: [getTypeIcon(cipher.type), " "] }), _jsx(Text, { color: selected && isFocused ? "white" : "default", wrap: "truncate", children: cipher.name })] }), cipher.favorite && _jsx(Text, { color: "yellow", children: "\u2605" })] }, cipher.id)) }) }));
|
package/dist/login/LoginView.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Text, useFocusManager, useStdout } from "ink";
|
|
2
|
+
import { Box, Text, useFocusManager, useInput, useStdout } from "ink";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
4
|
import { TextInput } from "../components/TextInput.js";
|
|
5
5
|
import { Button } from "../components/Button.js";
|
|
@@ -27,8 +27,16 @@ export function LoginView({ onLogin }) {
|
|
|
27
27
|
const [askMfa, setAskMfa] = useState(null);
|
|
28
28
|
const [rememberMe, setRememberMe] = useState(false);
|
|
29
29
|
const { stdout } = useStdout();
|
|
30
|
-
const { focusNext } = useFocusManager();
|
|
30
|
+
const { focusNext, focusPrevious } = useFocusManager();
|
|
31
31
|
const { statusMessage, statusMessageColor, showStatusMessage } = useStatusMessage();
|
|
32
|
+
useInput(async (_, key) => {
|
|
33
|
+
if (key.upArrow) {
|
|
34
|
+
focusPrevious();
|
|
35
|
+
}
|
|
36
|
+
else if (key.downArrow) {
|
|
37
|
+
focusNext();
|
|
38
|
+
}
|
|
39
|
+
}, { isActive: !loading });
|
|
32
40
|
const handleLogin = async () => {
|
|
33
41
|
try {
|
|
34
42
|
if (!email?.length || !password?.length) {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -19,8 +19,8 @@ If you check "Remember me" during login, your vault encryption keys will be stor
|
|
|
19
19
|
|
|
20
20
|
## TODO
|
|
21
21
|
|
|
22
|
-
- Implement Argon2 key derivation
|
|
23
22
|
- Collections support
|
|
23
|
+
- Implement Fido, Duo MFA support
|
|
24
24
|
- Handle more fields editing
|
|
25
25
|
- Handle creating different cipher types
|
|
26
26
|
|