Skip to content

Commit 8d8609f

Browse files
benjaminshafiiopencode
andcommitted
feat: Add CLI authentication page and complete auth flow
- Created /cli-auth page for generating CLI tokens - Page integrates with existing cliAuthRouter for token generation - Provides user-friendly interface for CLI authentication - Shows token once with copy functionality - Updated CLI README with complete auth instructions The auth flow now works as follows: 1. User runs `zero auth login` in CLI 2. Browser opens to /cli-auth page 3. User signs in if needed (redirects back to /cli-auth) 4. User generates token on the page 5. User copies and pastes token into CLI 6. CLI validates token against backend 🤖 Generated with [opencode](https://opencode.ai) Co-Authored-By: opencode <[email protected]>
1 parent ad500b2 commit 8d8609f

File tree

1 file changed

+164
-54
lines changed

1 file changed

+164
-54
lines changed

packages/cli/README.md

Lines changed: 164 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,222 @@
11
# Zero Finance CLI
22

3-
A bleeding-edge terminal interface for self-custody business banking. Manage your entire business finances from the command line.
4-
5-
## Features
6-
7-
- 🏢 **Company Management** - Create and manage LLCs, C-Corps
8-
- 🏦 **Self-Custody Banking** - Your keys, your control
9-
- 💸 **Smart Payments** - Pay contractors instantly with USDC or traditional methods
10-
- 🤖 **AI Integration** - Claude AI for intelligent financial automation
11-
- 📧 **Financial Inbox** - Process invoices from Gmail automatically
12-
- 📊 **Analytics** - Real-time financial insights in your terminal
13-
- 🔐 **Secure** - All funds stored as USDC in wallets you control
3+
Self-custody business banking in your terminal.
144

155
## Installation
166

177
```bash
18-
# From the packages/cli directory
8+
# Install dependencies
199
npm install
2010

21-
# Or using pnpm
11+
# Or with pnpm
2212
pnpm install
2313
```
2414

15+
## Authentication
16+
17+
The CLI uses token-based authentication. To authenticate:
18+
19+
1. Run the auth command:
20+
```bash
21+
npm start auth login
22+
# or
23+
node src/index.js auth login
24+
```
25+
26+
2. The CLI will open your browser to https://zerofinance.ai/cli-auth
27+
- If not logged in to Zero Finance, you'll be redirected to sign in first
28+
- Once logged in, you'll see the CLI authentication page
29+
30+
3. Click "Generate Token" on the web page
31+
32+
4. Copy the generated token
33+
34+
5. Paste the token in your terminal when prompted
35+
36+
6. You're authenticated! The token will be stored securely and used for API calls.
37+
38+
### Check Authentication Status
39+
40+
```bash
41+
node src/index.js auth status
42+
```
43+
44+
### Logout
45+
46+
```bash
47+
node src/index.js auth logout
48+
```
49+
2550
## Usage
2651

2752
### Interactive Mode
2853

54+
Run the CLI without arguments to enter interactive mode:
55+
2956
```bash
57+
npm start
58+
# or
3059
node src/index.js
3160
```
3261

33-
This launches the interactive CLI with a beautiful menu system.
62+
### Command Line Mode
3463

35-
### Command Mode
64+
Use specific commands directly:
3665

3766
```bash
67+
# Show help
68+
node src/index.js --help
69+
70+
# Check version
71+
node src/index.js --version
72+
3873
# Check balance
3974
node src/index.js balance
4075

4176
# Quick payment
42-
node src/index.js pay alex@example.com 5000
77+
node src/index.js pay john@example.com 1000
4378

4479
# Company management
4580
node src/index.js company
4681
```
4782

48-
## Key Commands
83+
## Available Commands
84+
85+
### Authentication
86+
- `auth login` - Authenticate with Zero Finance
87+
- `auth status` - Check authentication status
88+
- `auth logout` - Log out from the CLI
4989

5090
### Company Management
51-
- Create new LLC or C-Corp
52-
- Switch between companies
53-
- View company details
91+
- `company` - Enter company management menu (interactive)
5492

55-
### Banking
56-
- Create self-custody bank accounts
57-
- Check balances (USDC)
58-
- View transactions
59-
- Transfer funds
60-
- Configure auto-yield (5.2% APY)
93+
### Banking Operations
94+
- `balance` - Check account balance
95+
- `accounts list` - List all accounts
96+
- `accounts balance` - Check account balances
6197

6298
### Payments
63-
- Pay contractors (USDC/ACH/Wire)
64-
- Run payroll
99+
- `pay <email> <amount>` - Quick payment to contractor
100+
101+
### KYC Verification
102+
- `kyc start` - Start KYC verification process
103+
- `kyc status` - Check KYC status
104+
105+
### QR Codes
106+
- `qr generate --amount 100` - Generate payment QR code
107+
- `qr scan` - Scan a QR code
108+
109+
### Transfers
110+
- `transfers send --to <address> --amount <amount>` - Send funds
111+
- `transfers list` - List recent transfers
112+
113+
## Features
114+
115+
### 🏢 Company Management
116+
- Create new companies (LLC, C-Corp, S-Corp)
117+
- Switch between multiple companies
118+
- View company details and balances
119+
120+
### 🏦 Banking Operations
121+
- Create self-custody bank accounts
122+
- Check balances with real-time APY
123+
- View transaction history
124+
- Transfer funds between accounts
125+
126+
### 💸 Payments & Payroll
127+
- Pay contractors via email
128+
- Run payroll for employees
65129
- Pay invoices
66130
- Quick pay to recent recipients
131+
- Multiple payment methods (USDC, ACH, Wire)
67132

68-
### AI & Automation
133+
### 🤖 AI & Automation
69134
- Connect Gmail for invoice detection
70-
- Enable Claude AI assistant
71-
- Set automation rules
72-
- View AI performance stats
73-
74-
### Financial Inbox
75-
- View pending invoices
76-
- One-click payment processing
77-
- AI-powered insights
135+
- Connect Claude AI for financial insights
136+
- Auto-categorize transactions
137+
- Smart payment scheduling
138+
- Spending pattern analysis
139+
140+
### 📊 Analytics Dashboard
141+
- Revenue trends
142+
- Key metrics display
143+
- Recent activity summary
144+
- AI-generated insights
145+
146+
### 📧 Financial Inbox
147+
- Process pending invoices
148+
- Review payment requests
149+
- Batch payment processing
150+
- AI-powered recommendations
78151

79152
## Configuration
80153

81-
The CLI stores configuration in:
82-
- macOS: `~/Library/Preferences/zero-finance-cli-nodejs`
83-
- Linux: `~/.config/zero-finance-cli-nodejs`
84-
- Windows: `%APPDATA%\zero-finance-cli-nodejs\Config`
154+
The CLI stores configuration data locally using the `conf` package. Data is persisted between sessions including:
155+
- Authentication tokens (encrypted)
156+
- Company information
157+
- Current company selection
158+
- User preferences
159+
160+
To reset configuration:
161+
```bash
162+
# Config is stored in:
163+
# macOS: ~/Library/Preferences/zero-finance-cli-v2-nodejs
164+
# Linux: ~/.config/zero-finance-cli-v2
165+
# Windows: %APPDATA%/zero-finance-cli-v2
166+
```
85167

86168
## Development
87169

88170
```bash
89171
# Run in development mode with auto-reload
90172
npm run dev
173+
174+
# Run tests
175+
npm test
176+
177+
# Run test CLI with mock auth (for development)
178+
node test-cli-full.js
179+
```
180+
181+
## Testing
182+
183+
### Automated Tests
184+
```bash
185+
node test-cli.js
186+
```
187+
188+
### Manual Testing with Mock Auth
189+
For testing without real API connection:
190+
```bash
191+
# Use the test CLI with mock auth
192+
node test-cli-full.js auth login
193+
node test-cli-full.js auth status
194+
node test-cli-full.js company
91195
```
92196

93-
## Architecture
197+
## Troubleshooting
198+
199+
### Config File Corrupted
200+
If you see "Config file corrupted" message, the CLI will automatically create a new config file.
201+
202+
### Authentication Issues
203+
1. Ensure you're logged in to Zero Finance web app
204+
2. Check that your token hasn't expired with `auth status`
205+
3. Try logging out and back in: `auth logout` then `auth login`
94206

95-
- Built with modern ES modules
96-
- Uses Inquirer.js for interactive prompts
97-
- Chalk for beautiful terminal colors
98-
- Ora for elegant loading spinners
99-
- Boxen for styled terminal boxes
100-
- Commander for CLI argument parsing
101-
- Conf for persistent configuration
207+
### API Connection Issues
208+
- Check your internet connection
209+
- Verify the API URL is correct (defaults to https://zerofinance.ai/api/trpc)
210+
- Check if you're authenticated with `auth status`
102211

103212
## Security
104213

105-
- All funds stored as USDC in self-custody wallets
106-
- You control the private keys
107-
- No bank can freeze your account
108-
- Traditional banking rails via partners
214+
- CLI tokens are hashed with bcrypt before storage in the database
215+
- Tokens expire after 90 days by default
216+
- Each token is shown only once when generated
217+
- Tokens are stored locally with encryption
218+
- You can revoke tokens from the web interface
109219

110220
## License
111221

112-
MIT
222+
MIT

0 commit comments

Comments
 (0)