bitty-tui 0.0.19 → 0.0.20
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/clients/bw.d.ts +1 -1
- package/dist/clients/bw.js +1 -1
- package/dist/components/Button.d.ts +2 -1
- package/dist/components/Button.js +3 -3
- package/dist/components/Checkbox.js +1 -1
- package/dist/components/TabButton.js +1 -1
- package/dist/components/TextInput.js +1 -1
- package/dist/dashboard/DashboardView.js +33 -3
- package/dist/dashboard/components/CipherDetail.d.ts +2 -1
- package/dist/dashboard/components/CipherDetail.js +3 -3
- package/dist/dashboard/components/CollectionsTab.js +2 -2
- package/dist/dashboard/components/HelpBar.js +8 -8
- package/dist/dashboard/components/MainTab.js +5 -5
- package/dist/dashboard/components/MoreInfoTab.js +39 -17
- package/dist/dashboard/components/VaultList.js +1 -1
- package/dist/hooks/status-message.d.ts +3 -1
- package/dist/hooks/status-message.js +4 -2
- package/dist/hooks/use-mouse.js +1 -1
- package/dist/login/LoginView.js +9 -1
- package/package.json +1 -1
- package/readme.md +0 -3
package/dist/clients/bw.d.ts
CHANGED
|
@@ -171,7 +171,7 @@ export declare class Client {
|
|
|
171
171
|
* - Derived encryption keys (master key, user key, private key)
|
|
172
172
|
*/
|
|
173
173
|
login(email: string, password: string, skipPrelogin?: boolean, opts?: Record<string, any>): Promise<void>;
|
|
174
|
-
sendEmailMfaCode(email: string): Promise<
|
|
174
|
+
sendEmailMfaCode(email: string): Promise<Response>;
|
|
175
175
|
checkToken(): Promise<void>;
|
|
176
176
|
/**
|
|
177
177
|
* Fetches the latest sync data from the Bitwarden server and decrypts organization keys if available.
|
package/dist/clients/bw.js
CHANGED
|
@@ -416,7 +416,7 @@ export class Client {
|
|
|
416
416
|
this.orgKeys = {};
|
|
417
417
|
}
|
|
418
418
|
async sendEmailMfaCode(email) {
|
|
419
|
-
fetchApi(`${this.apiUrl}/two-factor/send-email-login`, {
|
|
419
|
+
return fetchApi(`${this.apiUrl}/two-factor/send-email-login`, {
|
|
420
420
|
method: "POST",
|
|
421
421
|
headers: {
|
|
422
422
|
"Content-Type": "application/json",
|
|
@@ -2,11 +2,12 @@ import { Box } from "ink";
|
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
type Props = {
|
|
4
4
|
isActive?: boolean;
|
|
5
|
+
activeBorderColor?: string;
|
|
5
6
|
doubleConfirm?: boolean;
|
|
6
7
|
tripleConfirm?: boolean;
|
|
7
8
|
autoFocus?: boolean;
|
|
8
9
|
onClick: () => void;
|
|
9
10
|
children: ReactNode;
|
|
10
11
|
} & React.ComponentProps<typeof Box>;
|
|
11
|
-
export declare const Button: ({ isActive, doubleConfirm, tripleConfirm, onClick, children, autoFocus, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare const Button: ({ isActive, activeBorderColor, doubleConfirm, tripleConfirm, onClick, children, autoFocus, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
12
13
|
export {};
|
|
@@ -3,7 +3,7 @@ import { Text, Box, useFocus, useInput } from "ink";
|
|
|
3
3
|
import { useId, useRef, useState } from "react";
|
|
4
4
|
import { primary } from "../theme/style.js";
|
|
5
5
|
import { useMouseTarget } from "../hooks/use-mouse.js";
|
|
6
|
-
export const Button = ({ isActive = true, doubleConfirm, tripleConfirm, onClick, children, autoFocus = false, ...props }) => {
|
|
6
|
+
export const Button = ({ isActive = true, activeBorderColor, doubleConfirm, tripleConfirm, onClick, children, autoFocus = false, ...props }) => {
|
|
7
7
|
const generatedId = useId();
|
|
8
8
|
const { isFocused } = useFocus({ id: generatedId, autoFocus: autoFocus });
|
|
9
9
|
const [askConfirm, setAskConfirm] = useState(false);
|
|
@@ -37,11 +37,11 @@ export const Button = ({ isActive = true, doubleConfirm, tripleConfirm, onClick,
|
|
|
37
37
|
if (key.return)
|
|
38
38
|
handlePress();
|
|
39
39
|
}, { isActive: isFocused && isActive });
|
|
40
|
-
return (_jsx(Box, { ref: boxRef, borderStyle: "round", borderColor: isFocused && isActive ? primary : "
|
|
40
|
+
return (_jsx(Box, { ref: boxRef, borderStyle: "round", borderColor: isFocused && isActive ? activeBorderColor ?? primary : "#9f9f9f", alignItems: "center", justifyContent: "center", ...props, children: _jsx(Text, { color: isFocused && isActive
|
|
41
41
|
? ask2Confirm
|
|
42
42
|
? "red"
|
|
43
43
|
: askConfirm
|
|
44
44
|
? "yellow"
|
|
45
45
|
: "white"
|
|
46
|
-
: "
|
|
46
|
+
: "#9f9f9f", children: ask2Confirm ? "Are you sure?" : askConfirm ? "Confirm?" : children }) }));
|
|
47
47
|
};
|
|
@@ -15,5 +15,5 @@ export const Checkbox = ({ isActive = true, value, label, onToggle, ...props })
|
|
|
15
15
|
onToggle(!value);
|
|
16
16
|
}
|
|
17
17
|
}, { isActive: isFocused && isActive });
|
|
18
|
-
return (_jsxs(Box, { ref: boxRef, ...props, children: [_jsx(Box, { width: 5, height: 3, flexShrink: 0, borderStyle: "round", borderColor: isFocused && isActive ? primary : "
|
|
18
|
+
return (_jsxs(Box, { ref: boxRef, ...props, children: [_jsx(Box, { width: 5, height: 3, flexShrink: 0, borderStyle: "round", borderColor: isFocused && isActive ? primary : "#9f9f9f", children: value && (_jsx(Box, { width: 1, height: 1, marginLeft: 1, children: _jsx(Text, { color: isFocused && isActive ? primary : "#9f9f9f", children: "X" }) })) }), _jsx(Box, { marginTop: 1, marginLeft: 1, children: _jsx(Text, { children: label }) })] }));
|
|
19
19
|
};
|
|
@@ -7,5 +7,5 @@ export const TabButton = ({ active, onClick, children, borderLess }) => {
|
|
|
7
7
|
const id = useId();
|
|
8
8
|
const boxRef = useRef(null);
|
|
9
9
|
useMouseTarget(id, boxRef, { onClick });
|
|
10
|
-
return (_jsx(Box, { ref: boxRef, borderStyle: borderLess ? undefined : "round", borderColor: active ? primary : "
|
|
10
|
+
return (_jsx(Box, { ref: boxRef, borderStyle: borderLess ? undefined : "round", borderColor: active ? primary : "#9f9f9f", alignItems: "center", justifyContent: "center", paddingX: 1, children: _jsx(Text, { color: active ? "white" : "#9f9f9f", children: children }) }));
|
|
11
11
|
};
|
|
@@ -194,5 +194,5 @@ export const TextInput = ({ id, placeholder, value, isPassword, showPasswordOnFo
|
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
}, { isActive: isFocused });
|
|
197
|
-
return (_jsx(Box, { ref: boxRef, borderStyle: "round", borderColor: isFocused ? primary : "
|
|
197
|
+
return (_jsx(Box, { ref: boxRef, borderStyle: "round", borderColor: isFocused ? primary : "#9f9f9f", borderBottom: !inline, borderTop: !inline, borderLeft: !inline, borderRight: !inline, flexGrow: 1, flexShrink: 0, paddingX: inline ? 0 : 1, overflow: "hidden", minHeight: inline ? 1 : 3, ...props, children: _jsx(Text, { color: value ? undefined : "#9f9f9f", children: displayValue }) }));
|
|
198
198
|
};
|
|
@@ -60,6 +60,9 @@ export function DashboardView({ onLogout }) {
|
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
62
|
setFocusedComponent("detail");
|
|
63
|
+
if (focusedComponent !== "detail") {
|
|
64
|
+
setShowDetails(false);
|
|
65
|
+
}
|
|
63
66
|
}
|
|
64
67
|
});
|
|
65
68
|
useEffect(() => {
|
|
@@ -74,7 +77,27 @@ export function DashboardView({ onLogout }) {
|
|
|
74
77
|
await logout();
|
|
75
78
|
return;
|
|
76
79
|
}
|
|
77
|
-
if (
|
|
80
|
+
if (key.shift && key.rightArrow) {
|
|
81
|
+
setActiveTab((prev) => {
|
|
82
|
+
if (prev === "main")
|
|
83
|
+
return "more";
|
|
84
|
+
if (prev === "more")
|
|
85
|
+
return syncState?.collections?.length ? "collections" : "main";
|
|
86
|
+
return "main";
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (key.shift && key.leftArrow) {
|
|
91
|
+
setActiveTab((prev) => {
|
|
92
|
+
if (prev === "main")
|
|
93
|
+
return syncState?.collections?.length ? "collections" : "more";
|
|
94
|
+
if (prev === "more")
|
|
95
|
+
return "main";
|
|
96
|
+
return "more";
|
|
97
|
+
});
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (input === "/" && focusedComponent === "list") {
|
|
78
101
|
setFocusedComponent("search");
|
|
79
102
|
focus("search");
|
|
80
103
|
return;
|
|
@@ -115,16 +138,23 @@ export function DashboardView({ onLogout }) {
|
|
|
115
138
|
setShowDetails(true);
|
|
116
139
|
setTimeout(focusNext, 50);
|
|
117
140
|
}, [showDetails]);
|
|
118
|
-
return (_jsxs(Box, { flexDirection: "column", width: "100%", height: stdout.rows -
|
|
141
|
+
return (_jsxs(Box, { flexDirection: "column", width: "100%", height: stdout.rows - 2, 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: () => {
|
|
119
142
|
setFocusedComponent("list");
|
|
120
143
|
focusNext();
|
|
121
|
-
} }) }), _jsxs(Box, { width: "60%", paddingX: 1, justifyContent: "space-between", children: [statusMessage ? (_jsx(Box, { padding: 1, flexShrink: 1, children: _jsx(Text, { color: statusMessageColor, children: statusMessage }) })) : (_jsx(Box, {})), selectedCipher && (_jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(TabButton, { active:
|
|
144
|
+
} }) }), _jsxs(Box, { width: "60%", paddingX: 1, justifyContent: "space-between", children: [statusMessage ? (_jsx(Box, { padding: 1, flexShrink: 1, children: _jsx(Text, { color: statusMessageColor, children: statusMessage }) })) : (_jsx(Box, {})), selectedCipher && (_jsxs(Box, { gap: 1, flexShrink: 0, children: [_jsx(TabButton, { active: false, onClick: async () => {
|
|
145
|
+
await fetchSync();
|
|
146
|
+
showStatusMessage("Refreshed!", "success");
|
|
147
|
+
}, children: "\uD83D\uDD04" }), _jsx(TabButton, { active: activeTab === "main", onClick: () => setActiveTab("main"), children: "Main" }), _jsx(TabButton, { active: activeTab === "more", onClick: () => setActiveTab("more"), children: "More" }), !!syncState?.collections?.length && (_jsx(TabButton, { active: activeTab === "collections", onClick: () => setActiveTab("collections"), children: "Collections" }))] }))] })] }), _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, activeTab: activeTab, collections: writableCollections, organizations: organizations, isFocused: focusedComponent === "detail", onTypeChange: (type) => {
|
|
122
148
|
const fresh = createEmptyCipher(type);
|
|
123
149
|
fresh.name = editedCipher?.name ?? "";
|
|
124
150
|
fresh.notes = editedCipher?.notes ?? null;
|
|
125
151
|
fresh.collectionIds = editedCipher?.collectionIds ?? [];
|
|
126
152
|
fresh.organizationId = editedCipher?.organizationId ?? null;
|
|
127
153
|
setEditedCipher(fresh);
|
|
154
|
+
}, onReset: async () => {
|
|
155
|
+
bwClient.decryptedSyncCache = null;
|
|
156
|
+
await fetchSync(false);
|
|
157
|
+
showStatusMessage("Resetted!", "success");
|
|
128
158
|
}, onChange: (cipher) => {
|
|
129
159
|
if (detailMode === "new") {
|
|
130
160
|
setEditedCipher(cipher);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Cipher, CipherType, Collection } from "../../clients/bw.js";
|
|
2
2
|
import { Organization } from "./MoreInfoTab.js";
|
|
3
3
|
export type DetailTab = "main" | "more" | "collections";
|
|
4
|
-
export declare function CipherDetail({ selectedCipher, isFocused, mode, activeTab, collections, organizations, onChange, onSave, onDelete, onTypeChange, }: {
|
|
4
|
+
export declare function CipherDetail({ selectedCipher, isFocused, mode, activeTab, collections, organizations, onChange, onSave, onDelete, onReset, onTypeChange, }: {
|
|
5
5
|
selectedCipher: Cipher | null | undefined;
|
|
6
6
|
isFocused: boolean;
|
|
7
7
|
mode: "view" | "new";
|
|
@@ -11,5 +11,6 @@ export declare function CipherDetail({ selectedCipher, isFocused, mode, activeTa
|
|
|
11
11
|
onChange: (cipher: Cipher) => void;
|
|
12
12
|
onSave: (cipher: Cipher) => void;
|
|
13
13
|
onDelete: (cipher: Cipher) => void;
|
|
14
|
+
onReset: () => void;
|
|
14
15
|
onTypeChange?: (type: CipherType) => void;
|
|
15
16
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box } from "ink";
|
|
3
3
|
import { primaryLight } from "../../theme/style.js";
|
|
4
4
|
import { Button } from "../../components/Button.js";
|
|
5
5
|
import { MoreInfoTab } from "./MoreInfoTab.js";
|
|
6
6
|
import { MainTab } from "./MainTab.js";
|
|
7
7
|
import { CollectionsTab } from "./CollectionsTab.js";
|
|
8
|
-
export function CipherDetail({ selectedCipher, isFocused, mode, activeTab, collections, organizations, onChange, onSave, onDelete, onTypeChange, }) {
|
|
9
|
-
return (_jsx(Box, { flexDirection: "column", width: "60%", flexGrow: 1, paddingX: 1, borderStyle: "round", borderColor: isFocused ? primaryLight : "
|
|
8
|
+
export function CipherDetail({ selectedCipher, isFocused, mode, activeTab, collections, organizations, onChange, onSave, onDelete, onReset, onTypeChange, }) {
|
|
9
|
+
return (_jsx(Box, { flexDirection: "column", width: "60%", flexGrow: 1, paddingX: 1, borderStyle: "round", borderColor: isFocused ? primaryLight : "#9f9f9f", borderLeftColor: "#9f9f9f", children: selectedCipher && (_jsxs(Box, { flexDirection: "column", justifyContent: "space-between", flexGrow: 1, children: [activeTab === "more" ? (_jsx(MoreInfoTab, { isFocused: isFocused, selectedCipher: selectedCipher, organizations: organizations, onChange: onChange })) : activeTab === "collections" ? (_jsx(CollectionsTab, { isFocused: isFocused, selectedCipher: selectedCipher, collections: collections, onChange: onChange })) : (_jsx(MainTab, { isFocused: isFocused, selectedCipher: selectedCipher, mode: mode, onChange: onChange, onTypeChange: onTypeChange })), _jsxs(Box, { marginTop: 1, flexShrink: 0, gap: 1, children: [_jsx(Button, { doubleConfirm: true, width: "49%", isActive: isFocused, onClick: () => onSave(selectedCipher), children: "Save" }), mode !== "new" && (_jsxs(_Fragment, { children: [_jsx(Button, { doubleConfirm: true, width: "25%", activeBorderColor: "yellow", isActive: isFocused, onClick: () => onReset(), children: "Reset" }), _jsx(Button, { tripleConfirm: true, width: "25%", activeBorderColor: "red", isActive: isFocused, onClick: () => onDelete(selectedCipher), children: "Delete" })] }))] })] })) }));
|
|
10
10
|
}
|
|
@@ -15,7 +15,7 @@ export function CollectionsTab({ isFocused, selectedCipher, collections, onChang
|
|
|
15
15
|
}
|
|
16
16
|
}, { isActive: isFocused });
|
|
17
17
|
if (!collections.length) {
|
|
18
|
-
return (_jsx(Box, { flexDirection: "column", height: stdout.rows - 18, children: _jsx(Text, { color: "
|
|
18
|
+
return (_jsx(Box, { flexDirection: "column", height: stdout.rows - 18, children: _jsx(Text, { color: "#9f9f9f", children: "No writable collections available." }) }));
|
|
19
19
|
}
|
|
20
20
|
return (_jsx(Box, { flexDirection: "column", gap: 0, height: stdout.rows - 18, children: collections.map((col, idx) => {
|
|
21
21
|
const checked = selected.includes(col.id);
|
|
@@ -43,6 +43,6 @@ export function CollectionsTab({ isFocused, selectedCipher, collections, onChang
|
|
|
43
43
|
onChange?.(!checked);
|
|
44
44
|
}
|
|
45
45
|
}, { isActive: isCursor });
|
|
46
|
-
return (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { ref: checkRef, children: _jsx(Text, { color: isCursor ? "white" : "
|
|
46
|
+
return (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { ref: checkRef, children: _jsx(Text, { color: isCursor ? "white" : "#9f9f9f", bold: isCursor, children: checked ? "[x] " : "[ ] " }) }), _jsx(Box, { ref: labelRef, children: _jsx(Text, { color: isCursor ? "white" : "#9f9f9f", children: col.name }) })] }, col.id));
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -2,33 +2,33 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Box, Text } from "ink";
|
|
3
3
|
import { CipherType } from "../../clients/bw.js";
|
|
4
4
|
export function HelpBar({ focus, cipher, mode, }) {
|
|
5
|
-
return (_jsxs(Box, { borderStyle: "single", borderColor: "
|
|
5
|
+
return (_jsxs(Box, { borderStyle: "single", borderColor: "#9f9f9f", marginTop: 1, paddingX: 1, flexShrink: 0, justifyContent: "space-around", children: [_jsxs(Text, { color: "#9f9f9f", children: [_jsx(Text, { bold: true, children: "/ " }), "Search"] }), focus === "list" ? (_jsxs(Text, { color: "#9f9f9f", children: [_jsx(Text, { bold: true, children: "\u2191/\u2193 " }), "Navigate"] })) : focus === "detail" ? (_jsxs(Text, { color: "#9f9f9f", children: [_jsx(Text, { bold: true, children: "Tab/Enter " }), "Next Field"] })) : (_jsxs(Text, { color: "#9f9f9f", children: [_jsx(Text, { bold: true, children: "Esc " }), "Clear Search"] })), focus === "list" ? (_jsxs(Text, { color: "#9f9f9f", children: [_jsx(Text, { bold: true, children: "Tab/Enter " }), "Select"] })) : focus === "detail" ? (_jsxs(Text, { color: "#9f9f9f", children: [_jsx(Text, { bold: true, children: "Esc " }), "Focus List"] })) : (_jsxs(Text, { color: "#9f9f9f", children: [_jsx(Text, { bold: true, children: "Tab/Enter " }), "Focus List"] })), mode !== "new" && (_jsxs(Text, { color: "#9f9f9f", children: [_jsx(Text, { bold: true, children: "Ctrl+n " }), "New"] })), ...copyButtons(focus, cipher), _jsxs(Text, { color: "#9f9f9f", children: [_jsx(Text, { bold: true, children: "Ctrl+w " }), "Logout"] })] }));
|
|
6
6
|
}
|
|
7
7
|
const copyButtons = (focus, cipher) => {
|
|
8
8
|
if (focus === "detail") {
|
|
9
9
|
return [
|
|
10
|
-
_jsxs(Text, { color: "
|
|
10
|
+
_jsxs(Text, { color: "#9f9f9f", children: [_jsx(Text, { bold: true, children: "Ctrl+y " }), "Copy Field"] }),
|
|
11
11
|
];
|
|
12
12
|
}
|
|
13
13
|
switch (cipher?.type) {
|
|
14
14
|
case CipherType.Login:
|
|
15
15
|
return [
|
|
16
|
-
_jsxs(Text, { color: "
|
|
16
|
+
_jsxs(Text, { color: "#9f9f9f", children: [_jsx(Text, { bold: true, children: "Ctrl+y " }), "Copy Password"] }, "copy-password"),
|
|
17
17
|
...(cipher.login?.totp
|
|
18
18
|
? [
|
|
19
|
-
_jsxs(Text, { color: "
|
|
19
|
+
_jsxs(Text, { color: "#9f9f9f", children: [_jsx(Text, { bold: true, children: "Ctrl+t " }), "Copy TOTP"] }, "copy-totp"),
|
|
20
20
|
]
|
|
21
21
|
: []),
|
|
22
|
-
_jsxs(Text, { color: "
|
|
22
|
+
_jsxs(Text, { color: "#9f9f9f", children: [_jsx(Text, { bold: true, children: "Ctrl+u " }), "Copy Username"] }, "copy-username"),
|
|
23
23
|
];
|
|
24
24
|
case CipherType.SecureNote:
|
|
25
25
|
return [
|
|
26
|
-
_jsxs(Text, { color: "
|
|
26
|
+
_jsxs(Text, { color: "#9f9f9f", children: [_jsx(Text, { bold: true, children: "Ctrl+y " }), "Copy Note"] }, "copy-note"),
|
|
27
27
|
];
|
|
28
28
|
case CipherType.SSHKey:
|
|
29
29
|
return [
|
|
30
|
-
_jsxs(Text, { color: "
|
|
31
|
-
_jsxs(Text, { color: "
|
|
30
|
+
_jsxs(Text, { color: "#9f9f9f", children: [_jsx(Text, { bold: true, children: "Ctrl+y " }), "Copy Private Key"] }, "copy-private-key"),
|
|
31
|
+
_jsxs(Text, { color: "#9f9f9f", children: [_jsx(Text, { bold: true, children: "Ctrl+u " }), "Copy Public Key"] }, "copy-public-key"),
|
|
32
32
|
];
|
|
33
33
|
default:
|
|
34
34
|
return [];
|
|
@@ -40,7 +40,7 @@ function normalizeBase32Secret(value) {
|
|
|
40
40
|
return value.replace(/\s+/g, "").toUpperCase();
|
|
41
41
|
}
|
|
42
42
|
function Field({ label, value, isFocused, onChange, isPassword, labelWidth = 12, maxLines = 3, }) {
|
|
43
|
-
return (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: labelWidth, flexShrink: 0, children: _jsxs(Text, { bold: true, color: isFocused ? primaryLight : "
|
|
43
|
+
return (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: labelWidth, flexShrink: 0, children: _jsxs(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: [label, ":"] }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, isPassword: isPassword, showPasswordOnFocus: isPassword, value: value, multiline: maxLines > 1, maxLines: maxLines, onChange: onChange }) })] }));
|
|
44
44
|
}
|
|
45
45
|
export function MainTab({ isFocused, selectedCipher, mode, onChange, onTypeChange, }) {
|
|
46
46
|
const [otpCode, setOtpCode] = useState("");
|
|
@@ -105,7 +105,7 @@ export function MainTab({ isFocused, selectedCipher, mode, onChange, onTypeChang
|
|
|
105
105
|
}, [selectedCipher?.login?.totp]);
|
|
106
106
|
const updateIdentity = (patch) => onChange({ ...selectedCipher, identity: { ...selectedCipher.identity, ...patch } });
|
|
107
107
|
const updateCard = (patch) => onChange({ ...selectedCipher, card: { ...selectedCipher.card, ...patch } });
|
|
108
|
-
return (_jsxs(Box, { flexDirection: "column", gap: 1, children: [mode === "new" && (_jsxs(Box, { flexDirection: "row", gap: 1, children: [_jsx(Box, { width: 10, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "
|
|
108
|
+
return (_jsxs(Box, { flexDirection: "column", gap: 1, children: [mode === "new" && (_jsxs(Box, { flexDirection: "row", gap: 1, children: [_jsx(Box, { width: 10, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Type:" }) }), [
|
|
109
109
|
[CipherType.Login, "Login"],
|
|
110
110
|
[CipherType.SecureNote, "Note"],
|
|
111
111
|
[CipherType.Card, "Card"],
|
|
@@ -113,10 +113,10 @@ export function MainTab({ isFocused, selectedCipher, mode, onChange, onTypeChang
|
|
|
113
113
|
].map(([t, label]) => (_jsx(TabButton, { borderLess: true, active: selectedCipher.type === t, onClick: () => onTypeChange?.(t), children: label }, t)))] })), _jsx(Field, { label: "Name", labelWidth: selectedCipher.type === CipherType.SSHKey ? 13 : 12, value: selectedCipher.name, isFocused: isFocused, onChange: (value) => onChange({ ...selectedCipher, name: value }) }), selectedCipher.type === CipherType.Login && (_jsx(Field, { label: "Username", value: selectedCipher.login?.username ?? "", isFocused: isFocused, onChange: (value) => onChange({
|
|
114
114
|
...selectedCipher,
|
|
115
115
|
login: { ...selectedCipher.login, username: value },
|
|
116
|
-
}) })), selectedCipher.type === CipherType.Login && (_jsxs(Box, { flexDirection: "row", children: [_jsxs(Box, { flexDirection: "row", flexGrow: 1, children: [_jsx(Box, { width: 12, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "
|
|
116
|
+
}) })), selectedCipher.type === CipherType.Login && (_jsxs(Box, { flexDirection: "row", children: [_jsxs(Box, { flexDirection: "row", flexGrow: 1, children: [_jsx(Box, { width: 12, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Password:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isPassword: true, showPasswordOnFocus: true, isActive: isFocused, value: selectedCipher.login?.password ?? "", onChange: (value) => onChange({
|
|
117
117
|
...selectedCipher,
|
|
118
118
|
login: { ...selectedCipher.login, password: value },
|
|
119
|
-
}) }) })] }), selectedCipher.login?.totp && (_jsxs(Box, { flexDirection: "row", width: 20, flexShrink: 0, children: [_jsx(Box, { flexShrink: 0, width: 12, children: _jsxs(Text, { bold: true, color: isFocused ? primaryLight : "
|
|
119
|
+
}) }) })] }), selectedCipher.login?.totp && (_jsxs(Box, { flexDirection: "row", width: 20, flexShrink: 0, children: [_jsx(Box, { flexShrink: 0, width: 12, children: _jsxs(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: ["OTP (", otpTimeout.toString().padStart(2, "0"), "s):"] }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: otpCode }) })] }))] })), selectedCipher.type === CipherType.Login && (_jsx(Field, { label: "URL", value: selectedCipher.login?.uris?.[0]?.uri ?? "", isFocused: isFocused, onChange: (value) => onChange({
|
|
120
120
|
...selectedCipher,
|
|
121
121
|
login: {
|
|
122
122
|
...selectedCipher.login,
|
|
@@ -125,7 +125,7 @@ export function MainTab({ isFocused, selectedCipher, mode, onChange, onTypeChang
|
|
|
125
125
|
...selectedCipher.login.uris.slice(1),
|
|
126
126
|
],
|
|
127
127
|
},
|
|
128
|
-
}) })), selectedCipher.type === CipherType.Card && (_jsxs(_Fragment, { children: [_jsx(Field, { label: "Cardholder", value: selectedCipher.card?.cardholderName ?? "", isFocused: isFocused, onChange: (v) => updateCard({ cardholderName: v }) }), _jsx(Field, { label: "Number", value: selectedCipher.card?.number ?? "", isFocused: isFocused, isPassword: true, onChange: (v) => updateCard({ number: v }) }), _jsx(Field, { label: "Brand", value: selectedCipher.card?.brand ?? "", isFocused: isFocused, onChange: (v) => updateCard({ brand: v }) }), _jsxs(Box, { flexDirection: "row", gap: 2, children: [_jsxs(Box, { flexDirection: "row", flexGrow: 1, children: [_jsx(Box, { width: 12, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "
|
|
128
|
+
}) })), selectedCipher.type === CipherType.Card && (_jsxs(_Fragment, { children: [_jsx(Field, { label: "Cardholder", value: selectedCipher.card?.cardholderName ?? "", isFocused: isFocused, onChange: (v) => updateCard({ cardholderName: v }) }), _jsx(Field, { label: "Number", value: selectedCipher.card?.number ?? "", isFocused: isFocused, isPassword: true, onChange: (v) => updateCard({ number: v }) }), _jsx(Field, { label: "Brand", value: selectedCipher.card?.brand ?? "", isFocused: isFocused, onChange: (v) => updateCard({ brand: v }) }), _jsxs(Box, { flexDirection: "row", gap: 2, children: [_jsxs(Box, { flexDirection: "row", flexGrow: 1, children: [_jsx(Box, { width: 12, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Exp Month:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.card?.expMonth ?? "", onChange: (v) => updateCard({ expMonth: v }) }) })] }), _jsxs(Box, { flexDirection: "row", flexGrow: 1, children: [_jsx(Box, { width: 10, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Exp Year:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.card?.expYear ?? "", onChange: (v) => updateCard({ expYear: v }) }) })] })] }), _jsx(Field, { label: "CVV", value: selectedCipher.card?.code ?? "", isFocused: isFocused, isPassword: true, onChange: (v) => updateCard({ code: v }) })] })), selectedCipher.type === CipherType.Identity && (_jsxs(_Fragment, { children: [_jsxs(Box, { flexDirection: "row", gap: 2, children: [_jsxs(Box, { flexDirection: "row", width: "50%", flexShrink: 0, children: [_jsx(Box, { width: 12, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Title:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.title ?? "", onChange: (v) => updateIdentity({ title: v }) }) })] }), _jsxs(Box, { flexDirection: "row", width: "50%", flexShrink: 0, children: [_jsx(Box, { width: 12, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "First Name:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.firstName ?? "", onChange: (v) => updateIdentity({ firstName: v }) }) })] })] }), _jsxs(Box, { flexDirection: "row", gap: 2, children: [_jsxs(Box, { flexDirection: "row", width: "50%", flexShrink: 0, children: [_jsx(Box, { width: 12, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Middle:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.middleName ?? "", onChange: (v) => updateIdentity({ middleName: v }) }) })] }), _jsxs(Box, { flexDirection: "row", width: "50%", flexShrink: 0, children: [_jsx(Box, { width: 12, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Last Name:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.lastName ?? "", onChange: (v) => updateIdentity({ lastName: v }) }) })] })] }), _jsxs(Box, { flexDirection: "row", gap: 2, children: [_jsxs(Box, { flexDirection: "row", width: "50%", flexShrink: 0, children: [_jsx(Box, { width: 12, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Username:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.username ?? "", onChange: (v) => updateIdentity({ username: v }) }) })] }), _jsxs(Box, { flexDirection: "row", width: "50%", flexShrink: 0, children: [_jsx(Box, { width: 12, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Company:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.company ?? "", onChange: (v) => updateIdentity({ company: v }) }) })] })] }), _jsxs(Box, { flexDirection: "row", gap: 2, children: [_jsxs(Box, { flexDirection: "row", width: "50%", flexShrink: 0, children: [_jsx(Box, { width: 12, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Email:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.email ?? "", onChange: (v) => updateIdentity({ email: v }) }) })] }), _jsxs(Box, { flexDirection: "row", width: "50%", flexShrink: 0, children: [_jsx(Box, { width: 12, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Phone:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.phone ?? "", onChange: (v) => updateIdentity({ phone: v }) }) })] })] })] })), selectedCipher.type === CipherType.SSHKey && (_jsxs(_Fragment, { children: [_jsx(Field, { label: "Private Key", labelWidth: 13, value: selectedCipher.sshKey?.privateKey ?? "", isFocused: isFocused }), _jsx(Field, { label: "Public Key", labelWidth: 13, value: selectedCipher.sshKey?.publicKey ?? "", isFocused: isFocused })] })), _jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: selectedCipher.type === CipherType.SSHKey ? 12 : 11, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Notes:" }) }), _jsx(Box, { flexGrow: 1, minHeight: 6, children: _jsx(TextInput, { multiline: true, maxLines: 5, isActive: isFocused, value: selectedCipher.notes ?? "", onChange: (value) => onChange({
|
|
129
129
|
...selectedCipher,
|
|
130
130
|
notes: value,
|
|
131
131
|
}) }) })] })] }));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Text, useInput, useStdout } from "ink";
|
|
3
|
-
import { useRef, useId, useState } from "react";
|
|
3
|
+
import { useRef, useId, useState, useMemo } from "react";
|
|
4
4
|
import { CipherType } from "../../clients/bw.js";
|
|
5
5
|
import { primaryLight } from "../../theme/style.js";
|
|
6
6
|
import { TextInput } from "../../components/TextInput.js";
|
|
@@ -9,7 +9,21 @@ export function MoreInfoTab({ isFocused, selectedCipher, organizations, onChange
|
|
|
9
9
|
const { stdout } = useStdout();
|
|
10
10
|
const [orgCursor, setOrgCursor] = useState(0);
|
|
11
11
|
const canChangeOrg = !selectedCipher.organizationId;
|
|
12
|
-
const orgOptions = canChangeOrg
|
|
12
|
+
const orgOptions = canChangeOrg
|
|
13
|
+
? [
|
|
14
|
+
{ id: null, name: "None (Personal)" },
|
|
15
|
+
...organizations.map((o) => ({
|
|
16
|
+
id: o.id,
|
|
17
|
+
name: o.name,
|
|
18
|
+
})),
|
|
19
|
+
]
|
|
20
|
+
: [];
|
|
21
|
+
const organizationName = useMemo(() => {
|
|
22
|
+
if (!selectedCipher.organizationId)
|
|
23
|
+
return "Personal";
|
|
24
|
+
const org = organizations.find((o) => o.id === selectedCipher.organizationId);
|
|
25
|
+
return org ? org.name : "Unknown Organization";
|
|
26
|
+
}, [selectedCipher.organizationId, organizations]);
|
|
13
27
|
useInput((_input, key) => {
|
|
14
28
|
if (!canChangeOrg)
|
|
15
29
|
return;
|
|
@@ -19,53 +33,61 @@ export function MoreInfoTab({ isFocused, selectedCipher, organizations, onChange
|
|
|
19
33
|
setOrgCursor((c) => Math.min(orgOptions.length - 1, c + 1));
|
|
20
34
|
else if (_input === " ") {
|
|
21
35
|
const selected = orgOptions[orgCursor];
|
|
22
|
-
onChange({
|
|
36
|
+
onChange({
|
|
37
|
+
...selectedCipher,
|
|
38
|
+
organizationId: selected?.id,
|
|
39
|
+
collectionIds: [],
|
|
40
|
+
});
|
|
23
41
|
}
|
|
24
42
|
}, { isActive: isFocused && canChangeOrg });
|
|
25
|
-
return (_jsxs(Box, { flexDirection: "column", gap: 1, height: stdout.rows - 18, children: [_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 9, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "
|
|
43
|
+
return (_jsxs(Box, { flexDirection: "column", gap: 1, height: stdout.rows - 18, children: [_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 9, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "ID:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.id ?? "" }) })] }), selectedCipher.type === CipherType.Login && (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 9, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "TOTP:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, isPassword: true, showPasswordOnFocus: true, value: selectedCipher.login?.totp ?? "", onChange: (value) => onChange({
|
|
26
44
|
...selectedCipher,
|
|
27
45
|
login: { ...selectedCipher.login, totp: value },
|
|
28
|
-
}) }) })] })), canChangeOrg && organizations.length > 0 && (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { bold: true, color: isFocused ? primaryLight : "
|
|
46
|
+
}) }) })] })), canChangeOrg && organizations.length > 0 && (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Organization:" }), orgOptions.map((opt, idx) => {
|
|
29
47
|
const checked = selectedCipher.organizationId === opt.id;
|
|
30
48
|
const isCursor = orgCursor === idx && isFocused;
|
|
31
|
-
return (_jsx(OrgCheckbox, { label: opt.name, isCursor: isCursor, checked: checked, onFocus: () => setOrgCursor(idx), onChange: () => onChange({
|
|
32
|
-
|
|
49
|
+
return (_jsx(OrgCheckbox, { label: opt.name, isCursor: isCursor, checked: checked, onFocus: () => setOrgCursor(idx), onChange: () => onChange({
|
|
50
|
+
...selectedCipher,
|
|
51
|
+
organizationId: opt.id,
|
|
52
|
+
collectionIds: [],
|
|
53
|
+
}) }, opt.id ?? "__none"));
|
|
54
|
+
})] })), !!selectedCipher.organizationId && (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 18, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Organization:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: organizationName }) })] })), !!selectedCipher.folderId && (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 18, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Folder ID:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.folderId ?? "" }) })] })), selectedCipher.type === CipherType.Identity && (_jsxs(Box, { flexDirection: "column", gap: 1, children: [_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 9, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Address:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.address1 ?? "", onChange: (value) => onChange({
|
|
33
55
|
...selectedCipher,
|
|
34
56
|
identity: { ...selectedCipher.identity, address1: value },
|
|
35
|
-
}) }) })] }), _jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 9, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "
|
|
57
|
+
}) }) })] }), _jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 9, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "City:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.city ?? "", onChange: (value) => onChange({
|
|
36
58
|
...selectedCipher,
|
|
37
59
|
identity: { ...selectedCipher.identity, city: value },
|
|
38
|
-
}) }) })] }), _jsxs(Box, { flexDirection: "row", flexGrow: 1, gap: 1, children: [_jsxs(Box, { flexDirection: "row", width: "40%", flexShrink: 0, children: [_jsx(Box, { width: 9, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "
|
|
60
|
+
}) }) })] }), _jsxs(Box, { flexDirection: "row", flexGrow: 1, gap: 1, children: [_jsxs(Box, { flexDirection: "row", width: "40%", flexShrink: 0, children: [_jsx(Box, { width: 9, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "State:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.state ?? "", onChange: (value) => onChange({
|
|
39
61
|
...selectedCipher,
|
|
40
62
|
identity: { ...selectedCipher.identity, state: value },
|
|
41
|
-
}) }) })] }), _jsxs(Box, { flexDirection: "row", width: "60%", flexShrink: 0, children: [_jsx(Box, { width: 13, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "
|
|
63
|
+
}) }) })] }), _jsxs(Box, { flexDirection: "row", width: "60%", flexShrink: 0, children: [_jsx(Box, { width: 13, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Postal Code:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.postalCode ?? "", onChange: (value) => onChange({
|
|
42
64
|
...selectedCipher,
|
|
43
65
|
identity: {
|
|
44
66
|
...selectedCipher.identity,
|
|
45
67
|
postalCode: value,
|
|
46
68
|
},
|
|
47
|
-
}) }) })] })] }), _jsxs(Box, { flexDirection: "row", flexGrow: 1, gap: 1, children: [_jsxs(Box, { flexDirection: "row", width: "40%", flexShrink: 0, children: [_jsx(Box, { width: 9, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "
|
|
69
|
+
}) }) })] })] }), _jsxs(Box, { flexDirection: "row", flexGrow: 1, gap: 1, children: [_jsxs(Box, { flexDirection: "row", width: "40%", flexShrink: 0, children: [_jsx(Box, { width: 9, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Country:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.country ?? "", onChange: (value) => onChange({
|
|
48
70
|
...selectedCipher,
|
|
49
71
|
identity: { ...selectedCipher.identity, country: value },
|
|
50
|
-
}) }) })] }), _jsxs(Box, { flexDirection: "row", width: "60%", flexShrink: 0, children: [_jsx(Box, { width: 13, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "
|
|
72
|
+
}) }) })] }), _jsxs(Box, { flexDirection: "row", width: "60%", flexShrink: 0, children: [_jsx(Box, { width: 13, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "License:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.licenseNumber ?? "", onChange: (value) => onChange({
|
|
51
73
|
...selectedCipher,
|
|
52
74
|
identity: {
|
|
53
75
|
...selectedCipher.identity,
|
|
54
76
|
licenseNumber: value,
|
|
55
77
|
},
|
|
56
|
-
}) }) })] })] }), _jsxs(Box, { flexDirection: "row", flexGrow: 1, gap: 1, children: [_jsxs(Box, { flexDirection: "row", width: "40%", flexShrink: 0, children: [_jsx(Box, { width: 9, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "
|
|
78
|
+
}) }) })] })] }), _jsxs(Box, { flexDirection: "row", flexGrow: 1, gap: 1, children: [_jsxs(Box, { flexDirection: "row", width: "40%", flexShrink: 0, children: [_jsx(Box, { width: 9, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "SSN:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, isPassword: true, showPasswordOnFocus: true, value: selectedCipher.identity?.ssn ?? "", onChange: (value) => onChange({
|
|
57
79
|
...selectedCipher,
|
|
58
80
|
identity: { ...selectedCipher.identity, ssn: value },
|
|
59
|
-
}) }) })] }), _jsxs(Box, { flexDirection: "row", width: "60%", flexShrink: 0, children: [_jsx(Box, { width: 13, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "
|
|
81
|
+
}) }) })] }), _jsxs(Box, { flexDirection: "row", width: "60%", flexShrink: 0, children: [_jsx(Box, { width: 13, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Passport:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.passportNumber ?? "", onChange: (value) => onChange({
|
|
60
82
|
...selectedCipher,
|
|
61
83
|
identity: {
|
|
62
84
|
...selectedCipher.identity,
|
|
63
85
|
passportNumber: value,
|
|
64
86
|
},
|
|
65
|
-
}) }) })] })] })] })), selectedCipher.type === CipherType.SSHKey && (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 13, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "
|
|
87
|
+
}) }) })] })] })] })), selectedCipher.type === CipherType.SSHKey && (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 13, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Fingerprint:" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.sshKey?.keyFingerprint ?? "" }) })] })), !!selectedCipher.fields?.length && (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Fields:" }), selectedCipher.fields?.map((field, idx) => (_jsxs(Box, { flexDirection: "row", paddingLeft: 2, children: [_jsx(Box, { width: 16, children: _jsxs(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: [field.name || idx, ":"] }) }), _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: field.value ?? "", onChange: (value) => {
|
|
66
88
|
const newFields = selectedCipher.fields?.map((f, i) => i === idx ? { ...f, value } : f);
|
|
67
89
|
onChange({ ...selectedCipher, fields: newFields });
|
|
68
|
-
} }) })] }, idx)))] })), !!selectedCipher.login?.uris?.length && (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { bold: true, color: isFocused ? primaryLight : "
|
|
90
|
+
} }) })] }, idx)))] })), !!selectedCipher.login?.uris?.length && (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Uris:" }), selectedCipher.login.uris.map((uri, idx) => (_jsx(Box, { flexDirection: "row", paddingLeft: 2, children: _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: uri.uri ?? "", onChange: (value) => {
|
|
69
91
|
const newUris = selectedCipher.login?.uris?.map((u, i) => i === idx ? { ...u, uri: value } : u);
|
|
70
92
|
onChange({
|
|
71
93
|
...selectedCipher,
|
|
@@ -89,5 +111,5 @@ function OrgCheckbox({ label, isCursor, checked, onChange, onFocus, }) {
|
|
|
89
111
|
onChange();
|
|
90
112
|
}
|
|
91
113
|
}, { isActive: isCursor });
|
|
92
|
-
return (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { ref: checkRef, children: _jsx(Text, { color: isCursor ? "white" : "
|
|
114
|
+
return (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { ref: checkRef, children: _jsx(Text, { color: isCursor ? "white" : "#9f9f9f", bold: isCursor, children: checked ? "[x] " : "[ ] " }) }), _jsx(Box, { ref: labelRef, children: _jsx(Text, { color: isCursor ? "white" : "#9f9f9f", children: label }) })] }));
|
|
93
115
|
}
|
|
@@ -78,5 +78,5 @@ export function VaultList({ filteredCiphers, isFocused, selected, onSelect, }) {
|
|
|
78
78
|
showStatusMessage(`📋 Copied ${fldName} to clipboard!`, "success");
|
|
79
79
|
}
|
|
80
80
|
}, { isActive: isFocused });
|
|
81
|
-
return (_jsx(Box, { ref: boxRef, flexDirection: "column", width: "40%", borderStyle: "round", borderColor: isFocused ? primaryLight : "
|
|
81
|
+
return (_jsx(Box, { ref: boxRef, flexDirection: "column", width: "40%", borderStyle: "round", borderColor: isFocused ? primaryLight : "#9f9f9f", borderRightColor: "#9f9f9f", paddingX: 1, overflow: "hidden", children: _jsx(ScrollView, { isActive: isFocused, count: Math.max(stdout.rows - 14, 20), list: filteredCiphers, selectedIndex: selected ?? 0, onSelect: onSelect, offsetRef: scrollOffsetRef, 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)) }) }));
|
|
82
82
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
type StatusMessageType = "info" | "error" | "warning" | "success";
|
|
1
2
|
export declare const StatusMessageProvider: ({ children, }: {
|
|
2
3
|
children: React.ReactNode;
|
|
3
4
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
4
5
|
export declare const useStatusMessage: () => {
|
|
5
6
|
statusMessage: string | null;
|
|
6
7
|
statusMessageColor: string;
|
|
7
|
-
showStatusMessage: (message: string, type?:
|
|
8
|
+
showStatusMessage: (message: string, type?: StatusMessageType, timeoutMs?: number) => void;
|
|
8
9
|
};
|
|
10
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { createContext, useContext, useRef, useState } from "react";
|
|
3
3
|
const statusMessageContext = createContext({
|
|
4
4
|
statusMessage: null,
|
|
5
|
-
statusMessageColor: "
|
|
5
|
+
statusMessageColor: "#9f9f9f",
|
|
6
6
|
showStatusMessage: () => { },
|
|
7
7
|
});
|
|
8
8
|
const SMProvider = statusMessageContext.Provider;
|
|
@@ -24,7 +24,9 @@ export const StatusMessageProvider = ({ children, }) => {
|
|
|
24
24
|
? "red"
|
|
25
25
|
: messageType === "success"
|
|
26
26
|
? "green"
|
|
27
|
-
: "
|
|
27
|
+
: messageType === "warning"
|
|
28
|
+
? "yellow"
|
|
29
|
+
: "#9f9f9f";
|
|
28
30
|
return (_jsx(SMProvider, { value: { statusMessage, statusMessageColor, showStatusMessage }, children: children }));
|
|
29
31
|
};
|
|
30
32
|
export const useStatusMessage = () => useContext(statusMessageContext);
|
package/dist/hooks/use-mouse.js
CHANGED
|
@@ -79,7 +79,7 @@ export const MouseProvider = ({ children, }) => {
|
|
|
79
79
|
if (match) {
|
|
80
80
|
const button = parseInt(match[1], 10);
|
|
81
81
|
const x = parseInt(match[2], 10) - 1;
|
|
82
|
-
const y = parseInt(match[3], 10) -
|
|
82
|
+
const y = parseInt(match[3], 10) - 2;
|
|
83
83
|
const isPress = match[4] === "M";
|
|
84
84
|
if (isPress && (button & 3) === 0) {
|
|
85
85
|
handleClickRef.current(x, y);
|
package/dist/login/LoginView.js
CHANGED
|
@@ -59,6 +59,9 @@ export function LoginView({ onLogin }) {
|
|
|
59
59
|
}
|
|
60
60
|
if (data.TwoFactorProviders) {
|
|
61
61
|
const providers = data.TwoFactorProviders;
|
|
62
|
+
if (mfaParams) {
|
|
63
|
+
showStatusMessage("Invalid MFA code, please try again.", "error");
|
|
64
|
+
}
|
|
62
65
|
if (providers.length === 1) {
|
|
63
66
|
setMfaParams({
|
|
64
67
|
twoFactorProvider: providers[0],
|
|
@@ -67,9 +70,13 @@ export function LoginView({ onLogin }) {
|
|
|
67
70
|
else if (providers.length > 1) {
|
|
68
71
|
setAskMfa(providers);
|
|
69
72
|
}
|
|
73
|
+
return;
|
|
70
74
|
}
|
|
71
75
|
else if (data.TwoFactorProviders2) {
|
|
72
76
|
const providers = Object.keys(data.TwoFactorProviders2);
|
|
77
|
+
if (mfaParams) {
|
|
78
|
+
showStatusMessage("Invalid MFA code, please try again.", "error");
|
|
79
|
+
}
|
|
73
80
|
if (providers.length === 1) {
|
|
74
81
|
setMfaParams({
|
|
75
82
|
twoFactorProvider: providers[0],
|
|
@@ -78,6 +85,7 @@ export function LoginView({ onLogin }) {
|
|
|
78
85
|
else if (providers.length > 1) {
|
|
79
86
|
setAskMfa(providers);
|
|
80
87
|
}
|
|
88
|
+
return;
|
|
81
89
|
}
|
|
82
90
|
}
|
|
83
91
|
else {
|
|
@@ -162,7 +170,7 @@ export function LoginView({ onLogin }) {
|
|
|
162
170
|
showStatusMessage("Failed to resend MFA code.", "error");
|
|
163
171
|
});
|
|
164
172
|
setResendTimeout(30);
|
|
165
|
-
}, children: "Resend Code" }))] })) : (_jsxs(Box, { flexDirection: "column", width: "50%", children: [_jsx(TextInput, { placeholder: "Server URL", value: url, onChange: setUrl }), _jsx(TextInput, { autoFocus: true, placeholder: "Email address", value: email, onChange: setEmail }), _jsx(TextInput, { placeholder: "Master password", value: password, onChange: setPassword, onSubmit: () => {
|
|
173
|
+
}, children: "Resend Code" })), statusMessage && (_jsx(Box, { marginTop: 1, width: "100%", justifyContent: "center", children: _jsx(Text, { color: statusMessageColor, children: statusMessage }) }))] })) : (_jsxs(Box, { flexDirection: "column", width: "50%", children: [_jsx(TextInput, { placeholder: "Server URL", value: url, onChange: setUrl }), _jsx(TextInput, { autoFocus: true, placeholder: "Email address", value: email, onChange: setEmail }), _jsx(TextInput, { placeholder: "Master password", value: password, onChange: setPassword, onSubmit: () => {
|
|
166
174
|
if (email?.length && password?.length) {
|
|
167
175
|
handleLogin();
|
|
168
176
|
}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -23,9 +23,6 @@ Works also with Vaultwarden.
|
|
|
23
23
|
|
|
24
24
|
If you check "Remember me" during login, your vault encryption keys will be stored in plain text in your home folder (`$HOME/.config/bitty/config.json`). Use this option only if you are the only user of your machine.
|
|
25
25
|
|
|
26
|
-
## TODO
|
|
27
|
-
|
|
28
|
-
- Test Fido, Duo MFA support
|
|
29
26
|
|
|
30
27
|
## Acknowledgments
|
|
31
28
|
- [Bitwarden whitepaper](https://bitwarden.com/help/bitwarden-security-white-paper)
|