bitty-tui 0.0.18 → 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/cli.js +0 -0
- package/dist/clients/bw.d.ts +28 -2
- package/dist/clients/bw.js +108 -3
- package/dist/components/Button.d.ts +3 -1
- package/dist/components/Button.js +20 -3
- package/dist/components/Checkbox.js +1 -1
- package/dist/components/TabButton.d.ts +9 -0
- package/dist/components/TabButton.js +11 -0
- package/dist/components/TextInput.js +1 -1
- package/dist/dashboard/DashboardView.js +88 -5
- package/dist/dashboard/components/CipherDetail.d.ts +10 -2
- package/dist/dashboard/components/CipherDetail.js +4 -6
- package/dist/dashboard/components/CollectionsTab.d.ts +7 -0
- package/dist/dashboard/components/CollectionsTab.js +48 -0
- package/dist/dashboard/components/HelpBar.js +8 -8
- package/dist/dashboard/components/MainInfoTab.js +4 -29
- package/dist/dashboard/components/MainTab.d.ts +4 -2
- package/dist/dashboard/components/MainTab.js +97 -58
- package/dist/dashboard/components/MoreInfoTab.d.ts +6 -1
- package/dist/dashboard/components/MoreInfoTab.js +101 -4
- package/dist/dashboard/components/VaultList.js +1 -1
- package/dist/hooks/bw.d.ts +2 -1
- package/dist/hooks/bw.js +56 -11
- 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 +3 -3
- package/readme.md +0 -6
|
@@ -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 [];
|
|
@@ -3,39 +3,14 @@ import { Box, Text } from "ink";
|
|
|
3
3
|
import { CipherType } from "../../clients/bw.js";
|
|
4
4
|
import { primaryLight } from "../../theme/style.js";
|
|
5
5
|
import { TextInput } from "../../components/TextInput.js";
|
|
6
|
-
import { useEffect, useState } from "react";
|
|
7
|
-
import { authenticator } from "otplib";
|
|
8
6
|
export function MainTab({ isFocused, selectedCipher, onChange, }) {
|
|
9
|
-
const [otpCode, setOtpCode] = useState("");
|
|
10
|
-
const [otpTimeout, setOtpTimeout] = useState(0);
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
let interval = null;
|
|
13
|
-
if (selectedCipher?.login?.totp) {
|
|
14
|
-
interval = setInterval(() => {
|
|
15
|
-
setOtpTimeout((t) => {
|
|
16
|
-
if (t <= 1) {
|
|
17
|
-
setOtpCode(authenticator.generate(selectedCipher.login.totp));
|
|
18
|
-
return 30;
|
|
19
|
-
}
|
|
20
|
-
return t - 1;
|
|
21
|
-
});
|
|
22
|
-
}, 1000);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
setOtpCode("");
|
|
26
|
-
}
|
|
27
|
-
return () => {
|
|
28
|
-
if (interval)
|
|
29
|
-
clearInterval(interval);
|
|
30
|
-
};
|
|
31
|
-
}, [selectedCipher?.login?.totp]);
|
|
32
7
|
return (_jsxs(Box, { flexDirection: "column", gap: 1, children: [_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 12, marginRight: 2, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "gray", children: "Name:" }) }), _jsx(Box, { flexGrow: 1, paddingLeft: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.name, onChange: (value) => onChange({ ...selectedCipher, name: value }) }) })] }), selectedCipher.type === CipherType.Login && (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 12, marginRight: 2, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "gray", children: "Username:" }) }), _jsx(Box, { flexGrow: 1, paddingLeft: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.login?.username ?? "", onChange: (value) => onChange({
|
|
33
8
|
...selectedCipher,
|
|
34
9
|
login: { ...selectedCipher.login, username: value },
|
|
35
|
-
}) }) })] })), selectedCipher.type === CipherType.Login && (_jsxs(Box, { flexDirection: "row", children: [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
10
|
+
}) }) })] })), selectedCipher.type === CipherType.Login && (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 12, marginRight: 2, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "gray", children: "Password:" }) }), _jsx(Box, { flexGrow: 1, paddingLeft: 1, children: _jsx(TextInput, { inline: true, isPassword: true, showPasswordOnFocus: true, isActive: isFocused, value: selectedCipher.login?.password ?? "", onChange: (value) => onChange({
|
|
11
|
+
...selectedCipher,
|
|
12
|
+
login: { ...selectedCipher.login, password: value },
|
|
13
|
+
}) }) })] })), selectedCipher.type === CipherType.Login && (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 12, marginRight: 2, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "gray", children: "URL:" }) }), _jsx(Box, { flexGrow: 1, paddingLeft: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.login?.uris?.[0]?.uri ?? "", onChange: (value) => onChange({
|
|
39
14
|
...selectedCipher,
|
|
40
15
|
login: {
|
|
41
16
|
...selectedCipher.login,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { Cipher } from "../../clients/bw.js";
|
|
2
|
-
export declare function MainTab({ isFocused, selectedCipher, onChange, }: {
|
|
1
|
+
import { Cipher, CipherType } from "../../clients/bw.js";
|
|
2
|
+
export declare function MainTab({ isFocused, selectedCipher, mode, onChange, onTypeChange, }: {
|
|
3
3
|
isFocused: boolean;
|
|
4
4
|
selectedCipher: Cipher;
|
|
5
|
+
mode: "view" | "new";
|
|
5
6
|
onChange: (cipher: Cipher) => void;
|
|
7
|
+
onTypeChange?: (type: CipherType) => void;
|
|
6
8
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,31 +1,95 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Text } from "ink";
|
|
3
3
|
import { CipherType } from "../../clients/bw.js";
|
|
4
4
|
import { primaryLight } from "../../theme/style.js";
|
|
5
5
|
import { TextInput } from "../../components/TextInput.js";
|
|
6
|
+
import { TabButton } from "../../components/TabButton.js";
|
|
6
7
|
import { useEffect, useState } from "react";
|
|
7
|
-
import {
|
|
8
|
+
import { createGuardrails, generate, stringToBytes } from "otplib";
|
|
8
9
|
const OTP_INTERVAL = 30;
|
|
9
|
-
|
|
10
|
+
const OTP_GUARDRAILS = createGuardrails({
|
|
11
|
+
MIN_SECRET_BYTES: 1,
|
|
12
|
+
MAX_SECRET_BYTES: 1024,
|
|
13
|
+
});
|
|
14
|
+
function parseTotpConfig(value) {
|
|
15
|
+
if (!value.startsWith("otpauth://")) {
|
|
16
|
+
return { secret: value };
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const url = new URL(value);
|
|
20
|
+
const secret = url.searchParams.get("secret") ?? "";
|
|
21
|
+
const periodRaw = Number.parseInt(url.searchParams.get("period") ?? "", 10);
|
|
22
|
+
const digitsRaw = Number.parseInt(url.searchParams.get("digits") ?? "", 10);
|
|
23
|
+
const algorithmRaw = (url.searchParams.get("algorithm") ?? "").toLowerCase();
|
|
24
|
+
const period = Number.isFinite(periodRaw) && periodRaw > 0 ? periodRaw : undefined;
|
|
25
|
+
const digits = digitsRaw === 6 || digitsRaw === 7 || digitsRaw === 8
|
|
26
|
+
? digitsRaw
|
|
27
|
+
: undefined;
|
|
28
|
+
const algorithm = algorithmRaw === "sha1" ||
|
|
29
|
+
algorithmRaw === "sha256" ||
|
|
30
|
+
algorithmRaw === "sha512"
|
|
31
|
+
? algorithmRaw
|
|
32
|
+
: undefined;
|
|
33
|
+
return { secret, period, digits, algorithm };
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return { secret: value };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function normalizeBase32Secret(value) {
|
|
40
|
+
return value.replace(/\s+/g, "").toUpperCase();
|
|
41
|
+
}
|
|
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 : "#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
|
+
}
|
|
45
|
+
export function MainTab({ isFocused, selectedCipher, mode, onChange, onTypeChange, }) {
|
|
10
46
|
const [otpCode, setOtpCode] = useState("");
|
|
11
47
|
const [otpTimeout, setOtpTimeout] = useState(0);
|
|
12
|
-
const genOtp = () => {
|
|
13
|
-
if (
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
48
|
+
const genOtp = async (config) => {
|
|
49
|
+
if (config.secret) {
|
|
50
|
+
const normalizedSecret = normalizeBase32Secret(config.secret);
|
|
51
|
+
const options = {
|
|
52
|
+
guardrails: OTP_GUARDRAILS,
|
|
53
|
+
...(config.period ? { period: config.period } : {}),
|
|
54
|
+
...(config.digits ? { digits: config.digits } : {}),
|
|
55
|
+
...(config.algorithm ? { algorithm: config.algorithm } : {}),
|
|
56
|
+
};
|
|
57
|
+
try {
|
|
58
|
+
const totp = await generate({ ...options, secret: normalizedSecret });
|
|
59
|
+
if (selectedCipher.login) {
|
|
60
|
+
selectedCipher.login.currentTotp = totp;
|
|
61
|
+
}
|
|
62
|
+
setOtpCode(totp);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
try {
|
|
66
|
+
const totp = await generate({
|
|
67
|
+
...options,
|
|
68
|
+
secret: stringToBytes(config.secret),
|
|
69
|
+
});
|
|
70
|
+
if (selectedCipher.login) {
|
|
71
|
+
selectedCipher.login.currentTotp = totp;
|
|
72
|
+
}
|
|
73
|
+
setOtpCode(totp);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
setOtpCode("");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
17
79
|
}
|
|
18
80
|
};
|
|
19
81
|
useEffect(() => {
|
|
20
82
|
let interval = null;
|
|
21
83
|
if (selectedCipher?.login?.totp) {
|
|
22
|
-
|
|
23
|
-
|
|
84
|
+
const config = parseTotpConfig(selectedCipher.login.totp);
|
|
85
|
+
const intervalSeconds = config.period ?? OTP_INTERVAL;
|
|
86
|
+
void genOtp(config);
|
|
87
|
+
setOtpTimeout(intervalSeconds);
|
|
24
88
|
interval = setInterval(() => {
|
|
25
89
|
setOtpTimeout((t) => {
|
|
26
90
|
if (t <= 1) {
|
|
27
|
-
genOtp();
|
|
28
|
-
return
|
|
91
|
+
void genOtp(config);
|
|
92
|
+
return intervalSeconds;
|
|
29
93
|
}
|
|
30
94
|
return t - 1;
|
|
31
95
|
});
|
|
@@ -39,54 +103,29 @@ export function MainTab({ isFocused, selectedCipher, onChange, }) {
|
|
|
39
103
|
clearInterval(interval);
|
|
40
104
|
};
|
|
41
105
|
}, [selectedCipher?.login?.totp]);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
106
|
+
const updateIdentity = (patch) => onChange({ ...selectedCipher, identity: { ...selectedCipher.identity, ...patch } });
|
|
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 : "#9f9f9f", children: "Type:" }) }), [
|
|
109
|
+
[CipherType.Login, "Login"],
|
|
110
|
+
[CipherType.SecureNote, "Note"],
|
|
111
|
+
[CipherType.Card, "Card"],
|
|
112
|
+
[CipherType.Identity, "Identity"],
|
|
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
|
+
...selectedCipher,
|
|
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 : "#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({
|
|
46
117
|
...selectedCipher,
|
|
47
118
|
login: { ...selectedCipher.login, password: value },
|
|
48
|
-
}) }) })] }), selectedCipher.login?.totp && (_jsxs(Box, { flexDirection: "row",
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
selectedCipher.identity?.firstName && (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 12, marginRight: 2, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "gray", children: "First Name:" }) }), _jsx(Box, { flexGrow: 1, paddingLeft: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.firstName ?? "", onChange: (value) => onChange({
|
|
59
|
-
...selectedCipher,
|
|
60
|
-
identity: { ...selectedCipher.identity, firstName: value },
|
|
61
|
-
}) }) })] })), selectedCipher.type === CipherType.Identity &&
|
|
62
|
-
selectedCipher.identity?.lastName && (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 12, marginRight: 2, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "gray", children: "Last Name:" }) }), _jsx(Box, { flexGrow: 1, paddingLeft: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.lastName ?? "", onChange: (value) => onChange({
|
|
63
|
-
...selectedCipher,
|
|
64
|
-
identity: { ...selectedCipher.identity, lastName: value },
|
|
65
|
-
}) }) })] })), selectedCipher.type === CipherType.Identity &&
|
|
66
|
-
selectedCipher.identity?.username && (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 12, marginRight: 2, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "gray", children: "Username:" }) }), _jsx(Box, { flexGrow: 1, paddingLeft: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.username ?? "", onChange: (value) => onChange({
|
|
67
|
-
...selectedCipher,
|
|
68
|
-
identity: { ...selectedCipher.identity, username: value },
|
|
69
|
-
}) }) })] })), selectedCipher.type === CipherType.Identity &&
|
|
70
|
-
selectedCipher.identity?.city && (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 12, marginRight: 2, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "gray", children: "City:" }) }), _jsx(Box, { flexGrow: 1, paddingLeft: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.city ?? "", onChange: (value) => onChange({
|
|
71
|
-
...selectedCipher,
|
|
72
|
-
identity: { ...selectedCipher.identity, city: value },
|
|
73
|
-
}) }) })] })), selectedCipher.type === CipherType.Identity &&
|
|
74
|
-
selectedCipher.identity?.address1 && (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 12, marginRight: 2, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "gray", children: "Address:" }) }), _jsx(Box, { flexGrow: 1, paddingLeft: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.address1 ?? "", onChange: (value) => onChange({
|
|
75
|
-
...selectedCipher,
|
|
76
|
-
identity: { ...selectedCipher.identity, address1: value },
|
|
77
|
-
}) }) })] })), selectedCipher.type === CipherType.Identity &&
|
|
78
|
-
selectedCipher.identity?.country && (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 12, marginRight: 2, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "gray", children: "Country:" }) }), _jsx(Box, { flexGrow: 1, paddingLeft: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.country ?? "", onChange: (value) => onChange({
|
|
79
|
-
...selectedCipher,
|
|
80
|
-
identity: { ...selectedCipher.identity, country: value },
|
|
81
|
-
}) }) })] })), selectedCipher.type === CipherType.Identity &&
|
|
82
|
-
selectedCipher.identity?.email && (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 12, marginRight: 2, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "gray", children: "Email:" }) }), _jsx(Box, { flexGrow: 1, paddingLeft: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.email ?? "", onChange: (value) => onChange({
|
|
83
|
-
...selectedCipher,
|
|
84
|
-
identity: { ...selectedCipher.identity, email: value },
|
|
85
|
-
}) }) })] })), selectedCipher.type === CipherType.Identity &&
|
|
86
|
-
selectedCipher.identity?.phone && (_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 12, marginRight: 2, flexShrink: 0, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "gray", children: "Phone:" }) }), _jsx(Box, { flexGrow: 1, paddingLeft: 1, children: _jsx(TextInput, { inline: true, isActive: isFocused, value: selectedCipher.identity?.phone ?? "", onChange: (value) => onChange({
|
|
87
|
-
...selectedCipher,
|
|
88
|
-
identity: { ...selectedCipher.identity, phone: value },
|
|
89
|
-
}) }) })] })), _jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 12, flexShrink: 0, marginRight: 2, children: _jsx(Text, { bold: true, color: isFocused ? primaryLight : "gray", children: "Notes:" }) }), _jsx(Box, { flexGrow: 1, minHeight: 7, children: _jsx(TextInput, { multiline: true, maxLines: 5, isActive: isFocused, value: selectedCipher.notes ?? "", onChange: (value) => onChange({
|
|
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
|
+
...selectedCipher,
|
|
121
|
+
login: {
|
|
122
|
+
...selectedCipher.login,
|
|
123
|
+
uris: [
|
|
124
|
+
{ uri: value },
|
|
125
|
+
...selectedCipher.login.uris.slice(1),
|
|
126
|
+
],
|
|
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 : "#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({
|
|
90
129
|
...selectedCipher,
|
|
91
130
|
notes: value,
|
|
92
131
|
}) }) })] })] }));
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Cipher } from "../../clients/bw.js";
|
|
2
|
-
export
|
|
2
|
+
export type Organization = {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function MoreInfoTab({ isFocused, selectedCipher, organizations, onChange, }: {
|
|
3
7
|
isFocused: boolean;
|
|
4
8
|
selectedCipher: Cipher;
|
|
9
|
+
organizations: Organization[];
|
|
5
10
|
onChange: (cipher: Cipher) => void;
|
|
6
11
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,14 +1,93 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Text, useStdout } from "ink";
|
|
2
|
+
import { Box, Text, useInput, useStdout } from "ink";
|
|
3
|
+
import { useRef, useId, useState, useMemo } from "react";
|
|
3
4
|
import { CipherType } from "../../clients/bw.js";
|
|
4
5
|
import { primaryLight } from "../../theme/style.js";
|
|
5
6
|
import { TextInput } from "../../components/TextInput.js";
|
|
6
|
-
|
|
7
|
+
import { useMouseTarget } from "../../hooks/use-mouse.js";
|
|
8
|
+
export function MoreInfoTab({ isFocused, selectedCipher, organizations, onChange, }) {
|
|
7
9
|
const { stdout } = useStdout();
|
|
8
|
-
|
|
10
|
+
const [orgCursor, setOrgCursor] = useState(0);
|
|
11
|
+
const canChangeOrg = !selectedCipher.organizationId;
|
|
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]);
|
|
27
|
+
useInput((_input, key) => {
|
|
28
|
+
if (!canChangeOrg)
|
|
29
|
+
return;
|
|
30
|
+
if (key.upArrow)
|
|
31
|
+
setOrgCursor((c) => Math.max(0, c - 1));
|
|
32
|
+
else if (key.downArrow)
|
|
33
|
+
setOrgCursor((c) => Math.min(orgOptions.length - 1, c + 1));
|
|
34
|
+
else if (_input === " ") {
|
|
35
|
+
const selected = orgOptions[orgCursor];
|
|
36
|
+
onChange({
|
|
37
|
+
...selectedCipher,
|
|
38
|
+
organizationId: selected?.id,
|
|
39
|
+
collectionIds: [],
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}, { isActive: isFocused && canChangeOrg });
|
|
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({
|
|
44
|
+
...selectedCipher,
|
|
45
|
+
login: { ...selectedCipher.login, totp: value },
|
|
46
|
+
}) }) })] })), canChangeOrg && organizations.length > 0 && (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { bold: true, color: isFocused ? primaryLight : "#9f9f9f", children: "Organization:" }), orgOptions.map((opt, idx) => {
|
|
47
|
+
const checked = selectedCipher.organizationId === opt.id;
|
|
48
|
+
const isCursor = orgCursor === idx && isFocused;
|
|
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({
|
|
55
|
+
...selectedCipher,
|
|
56
|
+
identity: { ...selectedCipher.identity, address1: value },
|
|
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({
|
|
58
|
+
...selectedCipher,
|
|
59
|
+
identity: { ...selectedCipher.identity, city: value },
|
|
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({
|
|
61
|
+
...selectedCipher,
|
|
62
|
+
identity: { ...selectedCipher.identity, state: value },
|
|
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({
|
|
64
|
+
...selectedCipher,
|
|
65
|
+
identity: {
|
|
66
|
+
...selectedCipher.identity,
|
|
67
|
+
postalCode: value,
|
|
68
|
+
},
|
|
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({
|
|
70
|
+
...selectedCipher,
|
|
71
|
+
identity: { ...selectedCipher.identity, country: value },
|
|
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({
|
|
73
|
+
...selectedCipher,
|
|
74
|
+
identity: {
|
|
75
|
+
...selectedCipher.identity,
|
|
76
|
+
licenseNumber: value,
|
|
77
|
+
},
|
|
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({
|
|
79
|
+
...selectedCipher,
|
|
80
|
+
identity: { ...selectedCipher.identity, ssn: value },
|
|
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({
|
|
82
|
+
...selectedCipher,
|
|
83
|
+
identity: {
|
|
84
|
+
...selectedCipher.identity,
|
|
85
|
+
passportNumber: value,
|
|
86
|
+
},
|
|
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) => {
|
|
9
88
|
const newFields = selectedCipher.fields?.map((f, i) => i === idx ? { ...f, value } : f);
|
|
10
89
|
onChange({ ...selectedCipher, fields: newFields });
|
|
11
|
-
} }) })] }, 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) => {
|
|
12
91
|
const newUris = selectedCipher.login?.uris?.map((u, i) => i === idx ? { ...u, uri: value } : u);
|
|
13
92
|
onChange({
|
|
14
93
|
...selectedCipher,
|
|
@@ -16,3 +95,21 @@ export function MoreInfoTab({ isFocused, selectedCipher, onChange, }) {
|
|
|
16
95
|
});
|
|
17
96
|
} }) }) }, idx)))] }))] }));
|
|
18
97
|
}
|
|
98
|
+
function OrgCheckbox({ label, isCursor, checked, onChange, onFocus, }) {
|
|
99
|
+
const checkRef = useRef(null);
|
|
100
|
+
const labelRef = useRef(null);
|
|
101
|
+
const checkId = useId();
|
|
102
|
+
const labelId = useId();
|
|
103
|
+
useMouseTarget(checkId, checkRef, {
|
|
104
|
+
onClick: () => onChange(),
|
|
105
|
+
});
|
|
106
|
+
useMouseTarget(labelId, labelRef, {
|
|
107
|
+
onClick: () => onFocus(),
|
|
108
|
+
});
|
|
109
|
+
useInput((input) => {
|
|
110
|
+
if (input === " ") {
|
|
111
|
+
onChange();
|
|
112
|
+
}
|
|
113
|
+
}, { isActive: isCursor });
|
|
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 }) })] }));
|
|
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
|
}
|
package/dist/hooks/bw.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BwKeys, Client, SyncResponse } from "../clients/bw.js";
|
|
1
|
+
import { BwKeys, CipherType, Client, SyncResponse } from "../clients/bw.js";
|
|
2
2
|
interface BwConfig {
|
|
3
3
|
baseUrl?: string;
|
|
4
4
|
keys: BwKeys;
|
|
@@ -19,5 +19,6 @@ export declare const useBwSync: () => {
|
|
|
19
19
|
error: string | null;
|
|
20
20
|
fetchSync: (forceRefresh?: boolean) => Promise<void>;
|
|
21
21
|
};
|
|
22
|
+
export declare function createEmptyCipher(type?: CipherType): any;
|
|
22
23
|
export declare const emptyCipher: any;
|
|
23
24
|
export {};
|
package/dist/hooks/bw.js
CHANGED
|
@@ -123,15 +123,60 @@ export const useBwSync = () => {
|
|
|
123
123
|
}, [fetchSync]);
|
|
124
124
|
return { sync, error, fetchSync };
|
|
125
125
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
username: null,
|
|
132
|
-
password: null,
|
|
133
|
-
uris: [],
|
|
134
|
-
},
|
|
135
|
-
fields: [],
|
|
136
|
-
organizationId: null,
|
|
126
|
+
const emptyLogin = {
|
|
127
|
+
username: null,
|
|
128
|
+
password: null,
|
|
129
|
+
totp: null,
|
|
130
|
+
uris: [],
|
|
137
131
|
};
|
|
132
|
+
const emptyCard = {
|
|
133
|
+
cardholderName: null,
|
|
134
|
+
brand: null,
|
|
135
|
+
number: null,
|
|
136
|
+
expMonth: null,
|
|
137
|
+
expYear: null,
|
|
138
|
+
code: null,
|
|
139
|
+
};
|
|
140
|
+
const emptyIdentity = {
|
|
141
|
+
title: null,
|
|
142
|
+
firstName: null,
|
|
143
|
+
middleName: null,
|
|
144
|
+
lastName: null,
|
|
145
|
+
username: null,
|
|
146
|
+
company: null,
|
|
147
|
+
email: null,
|
|
148
|
+
phone: null,
|
|
149
|
+
address1: null,
|
|
150
|
+
address2: null,
|
|
151
|
+
address3: null,
|
|
152
|
+
city: null,
|
|
153
|
+
state: null,
|
|
154
|
+
postalCode: null,
|
|
155
|
+
country: null,
|
|
156
|
+
ssn: null,
|
|
157
|
+
passportNumber: null,
|
|
158
|
+
licenseNumber: null,
|
|
159
|
+
};
|
|
160
|
+
export function createEmptyCipher(type = CipherType.Login) {
|
|
161
|
+
const base = {
|
|
162
|
+
name: "",
|
|
163
|
+
type,
|
|
164
|
+
notes: null,
|
|
165
|
+
fields: [],
|
|
166
|
+
organizationId: null,
|
|
167
|
+
collectionIds: [],
|
|
168
|
+
};
|
|
169
|
+
switch (type) {
|
|
170
|
+
case CipherType.Login:
|
|
171
|
+
return { ...base, login: { ...emptyLogin } };
|
|
172
|
+
case CipherType.SecureNote:
|
|
173
|
+
return { ...base, secureNote: { type: 0 } };
|
|
174
|
+
case CipherType.Card:
|
|
175
|
+
return { ...base, card: { ...emptyCard } };
|
|
176
|
+
case CipherType.Identity:
|
|
177
|
+
return { ...base, identity: { ...emptyIdentity } };
|
|
178
|
+
default:
|
|
179
|
+
return base;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
export const emptyCipher = createEmptyCipher();
|
|
@@ -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);
|