bitty-tui 0.0.11 → 0.0.13

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 CHANGED
@@ -3,4 +3,23 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { render } from "ink";
4
4
  import App from "./app.js";
5
5
  import { StatusMessageProvider } from "./hooks/status-message.js";
6
+ import { readPackageUpSync } from "read-package-up";
7
+ import { art } from "./theme/art.js";
8
+ const args = process.argv.slice(2);
9
+ if (args.includes("--version") || args.includes("-v")) {
10
+ const pkg = readPackageUpSync();
11
+ console.log(pkg?.packageJson.version ?? "unknown");
12
+ process.exit(0);
13
+ }
14
+ if (args.includes("--help") || args.includes("-h")) {
15
+ console.log(`${art}
16
+ Usage
17
+ $ bitty
18
+
19
+ Options
20
+ --help Show help
21
+ --version Show version
22
+ `);
23
+ process.exit(0);
24
+ }
6
25
  render(_jsx(StatusMessageProvider, { children: _jsx(App, {}) }));
@@ -139,6 +139,7 @@ export declare class Client {
139
139
  syncCache: SyncResponse | null;
140
140
  constructor(uri?: ClientConfig);
141
141
  private patchObject;
142
+ isVaultWarden(): boolean;
142
143
  setUrls(uri: ClientConfig): void;
143
144
  /**
144
145
  * Authenticates a user with the Bitwarden server using their email and password.
@@ -375,6 +375,10 @@ export class Client {
375
375
  }
376
376
  return result;
377
377
  }
378
+ isVaultWarden() {
379
+ return (!this.apiUrl.endsWith("bitwarden.eu/api") &&
380
+ !this.apiUrl.endsWith("bitwarden.com/api"));
381
+ }
378
382
  setUrls(uri) {
379
383
  if (uri.baseUrl) {
380
384
  this.apiUrl = uri.baseUrl + "/api";
@@ -695,7 +699,12 @@ export class Client {
695
699
  decrypt(value, key) {
696
700
  if (!value)
697
701
  return value;
698
- return mcbw.decrypt(value, key ?? this.keys.userKey);
702
+ try {
703
+ return mcbw.decrypt(value, key ?? this.keys.userKey);
704
+ }
705
+ catch (error) {
706
+ return value;
707
+ }
699
708
  }
700
709
  encryptCipher(obj, key) {
701
710
  const { ...ret } = obj;
@@ -66,6 +66,13 @@ export function DashboardView({ onLogout }) {
66
66
  focus("search");
67
67
  return;
68
68
  }
69
+ if (key.ctrl && input === "n") {
70
+ setDetailMode("new");
71
+ setEditedCipher(emptyCipher);
72
+ setFocusedComponent("detail");
73
+ setShowDetails(false);
74
+ return;
75
+ }
69
76
  if (key.escape) {
70
77
  setFocusedComponent("list");
71
78
  setDetailMode("view");
@@ -85,12 +92,6 @@ export function DashboardView({ onLogout }) {
85
92
  setFocusedComponent("detail");
86
93
  setShowDetails(false);
87
94
  }
88
- if (input === "n") {
89
- setDetailMode("new");
90
- setEditedCipher(emptyCipher);
91
- setFocusedComponent("detail");
92
- setShowDetails(false);
93
- }
94
95
  }
95
96
  });
96
97
  useEffect(() => {
@@ -138,5 +139,5 @@ export function DashboardView({ onLogout }) {
138
139
  showStatusMessage("Synchronization error", "error");
139
140
  }
140
141
  }
141
- } })] }), _jsx(HelpBar, { focus: focusedComponent, cipher: selectedCipher })] }));
142
+ } })] }), _jsx(HelpBar, { focus: focusedComponent, cipher: selectedCipher, mode: detailMode })] }));
142
143
  }
@@ -1,5 +1,6 @@
1
1
  import { Cipher } from "../../clients/bw.js";
2
- export declare function HelpBar({ focus, cipher, }: {
2
+ export declare function HelpBar({ focus, cipher, mode, }: {
3
3
  focus: "list" | "search" | "detail";
4
+ mode: "view" | "new";
4
5
  cipher: Cipher | null | undefined;
5
6
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,8 @@
1
1
  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
- export function HelpBar({ focus, cipher, }) {
5
- return (_jsxs(Box, { borderStyle: "single", borderColor: "gray", marginTop: 1, paddingX: 1, flexShrink: 0, justifyContent: "space-around", children: [_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "/ " }), "Search"] }), focus === "list" ? (_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "\u2191/\u2193 " }), "Navigate"] })) : focus === "detail" ? (_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Tab/Enter " }), "Next Field"] })) : (_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Esc " }), "Clear Search"] })), focus === "list" ? (_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Tab/Enter " }), "Select"] })) : focus === "detail" ? (_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Esc " }), "Focus List"] })) : (_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Tab/Enter " }), "Focus List"] })), ...copyButtons(focus, cipher), _jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Ctrl+w " }), "Logout"] })] }));
4
+ export function HelpBar({ focus, cipher, mode, }) {
5
+ return (_jsxs(Box, { borderStyle: "single", borderColor: "gray", marginTop: 1, paddingX: 1, flexShrink: 0, justifyContent: "space-around", children: [_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "/ " }), "Search"] }), focus === "list" ? (_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "\u2191/\u2193 " }), "Navigate"] })) : focus === "detail" ? (_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Tab/Enter " }), "Next Field"] })) : (_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Esc " }), "Clear Search"] })), focus === "list" ? (_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Tab/Enter " }), "Select"] })) : focus === "detail" ? (_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Esc " }), "Focus List"] })) : (_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Tab/Enter " }), "Focus List"] })), mode !== "new" && (_jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Ctrl+n " }), "New"] })), ...copyButtons(focus, cipher), _jsxs(Text, { color: "gray", children: [_jsx(Text, { bold: true, children: "Ctrl+w " }), "Logout"] })] }));
6
6
  }
7
7
  const copyButtons = (focus, cipher) => {
8
8
  if (focus === "detail") {
@@ -14,9 +14,7 @@ export function MainTab({ isFocused, selectedCipher, onChange, }) {
14
14
  interval = setInterval(() => {
15
15
  setOtpTimeout((t) => {
16
16
  if (t <= 1) {
17
- const totp = authenticator.generate(selectedCipher.login.totp);
18
- selectedCipher.login.currentTotp = totp;
19
- setOtpCode(totp);
17
+ setOtpCode(authenticator.generate(selectedCipher.login.totp));
20
18
  return 30;
21
19
  }
22
20
  return t - 1;
@@ -8,16 +8,7 @@ import { bwClient, loadConfig, saveConfig } from "../hooks/bw.js";
8
8
  import { useStatusMessage } from "../hooks/status-message.js";
9
9
  import { Checkbox } from "../components/Checkbox.js";
10
10
  import { FetchError, TwoFactorProvider } from "../clients/bw.js";
11
- const art = `
12
- ███████████ ███ ███████████ ███████████ █████ █████
13
- ░░███░░░░░███ ░░░ ░█░░░███░░░█░█░░░███░░░█░░███ ░░███
14
- ░███ ░███ ████ ░ ░███ ░ ░ ░███ ░ ░░███ ███
15
- ░██████████ ░░███ ░███ ░███ ░░█████
16
- ░███░░░░░███ ░███ ░███ ░███ ░░███
17
- ░███ ░███ ░███ ░███ ░███ ░███
18
- ███████████ █████ █████ █████ █████
19
- ░░░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░
20
- `;
11
+ import { art } from "../theme/art.js";
21
12
  export function LoginView({ onLogin }) {
22
13
  const [loading, setLoading] = useState(true);
23
14
  const [url, setUrl] = useState("https://vault.bitwarden.eu");
@@ -103,7 +94,9 @@ export function LoginView({ onLogin }) {
103
94
  })();
104
95
  }, []);
105
96
  return (_jsxs(Box, { flexDirection: "column", alignItems: "center", padding: 1, flexGrow: 1, minHeight: stdout.rows - 2, children: [_jsx(Box, { marginBottom: 2, children: _jsx(Text, { color: primary, children: art }) }), loading ? (_jsx(Text, { children: "Loading..." })) : askMfa ? (_jsx(Box, { flexDirection: "column", width: "50%", children: Object.values(askMfa).map((provider) => (_jsx(Button, { autoFocus: true, onClick: () => {
106
- if (provider === "1") {
97
+ if (provider === "1" &&
98
+ (Object.values(askMfa).length > 1 ||
99
+ !bwClient.isVaultWarden())) {
107
100
  bwClient.sendEmailMfaCode(email);
108
101
  }
109
102
  setMfaParams((p) => ({
@@ -0,0 +1 @@
1
+ export declare const art = "\n \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\n\u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588 \u2591\u2591\u2591 \u2591\u2588\u2591\u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2588\u2591\u2591\u2588\u2588\u2588 \u2591\u2591\u2588\u2588\u2588\n \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2588\u2588\u2588\u2588 \u2591 \u2591\u2588\u2588\u2588 \u2591 \u2591 \u2591\u2588\u2588\u2588 \u2591 \u2591\u2591\u2588\u2588\u2588 \u2588\u2588\u2588\n \u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2591\u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591\u2591\u2588\u2588\u2588\u2588\u2588\n \u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591\u2591\u2588\u2588\u2588\n \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588\n \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\n\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2591\n";
@@ -0,0 +1,10 @@
1
+ export const art = `
2
+ ███████████ ███ ███████████ ███████████ █████ █████
3
+ ░░███░░░░░███ ░░░ ░█░░░███░░░█░█░░░███░░░█░░███ ░░███
4
+ ░███ ░███ ████ ░ ░███ ░ ░ ░███ ░ ░░███ ███
5
+ ░██████████ ░░███ ░███ ░███ ░░█████
6
+ ░███░░░░░███ ░███ ░███ ░███ ░░███
7
+ ░███ ░███ ░███ ░███ ░███ ░███
8
+ ███████████ █████ █████ █████ █████
9
+ ░░░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░
10
+ `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bitty-tui",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "license": "MIT",
5
5
  "repository": "https://github.com/mceck/bitty",
6
6
  "keywords": [
@@ -34,7 +34,8 @@
34
34
  "clipboardy": "^4.0.0",
35
35
  "ink": "^6.3.0",
36
36
  "otplib": "^12.0.1",
37
- "react": "^19.1.0"
37
+ "react": "^19.1.0",
38
+ "read-package-up": "^12.0.0"
38
39
  },
39
40
  "devDependencies": {
40
41
  "@sindresorhus/tsconfig": "^8.0.1",