@cakemail-org/cakemail-cli 1.7.0 → 2.0.0
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/.claude/settings.local.json +12 -0
- package/.env.example +40 -0
- package/.env.test.example +45 -0
- package/CHANGELOG.md +1031 -0
- package/README.md +41 -37
- package/audit-formats.js +128 -0
- package/cakemail.rb +20 -0
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/commands/account.js +1 -1
- package/dist/commands/account.js.map +1 -1
- package/dist/commands/attributes.js +1 -1
- package/dist/commands/attributes.js.map +1 -1
- package/dist/commands/campaigns.js +1 -1
- package/dist/commands/campaigns.js.map +1 -1
- package/dist/commands/contacts.js +1 -1
- package/dist/commands/contacts.js.map +1 -1
- package/dist/commands/emails.js +1 -1
- package/dist/commands/emails.js.map +1 -1
- package/dist/commands/interests.js +1 -1
- package/dist/commands/interests.js.map +1 -1
- package/dist/commands/lists.js +1 -1
- package/dist/commands/lists.js.map +1 -1
- package/dist/commands/logs.js +1 -1
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/reports.js +1 -1
- package/dist/commands/reports.js.map +1 -1
- package/dist/commands/segments.js +1 -1
- package/dist/commands/segments.js.map +1 -1
- package/dist/commands/senders.js +1 -1
- package/dist/commands/senders.js.map +1 -1
- package/dist/commands/suppressed.js +1 -1
- package/dist/commands/suppressed.js.map +1 -1
- package/dist/commands/tags.js +1 -1
- package/dist/commands/tags.js.map +1 -1
- package/dist/commands/templates.js +1 -1
- package/dist/commands/templates.js.map +1 -1
- package/dist/commands/transactional-templates.js +1 -1
- package/dist/commands/transactional-templates.js.map +1 -1
- package/dist/commands/webhooks.js +1 -1
- package/dist/commands/webhooks.js.map +1 -1
- package/dist/utils/config.js +2 -2
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/errors.js +1 -1
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/progress.d.ts.map +1 -1
- package/dist/utils/progress.js +32 -4
- package/dist/utils/progress.js.map +1 -1
- package/dist/utils/spinner.d.ts +17 -0
- package/dist/utils/spinner.d.ts.map +1 -0
- package/dist/utils/spinner.js +43 -0
- package/dist/utils/spinner.js.map +1 -0
- package/docs/DOCUMENTATION-STANDARD.md +1068 -0
- package/docs/README.md +161 -0
- package/docs/developer/ARCHITECTURE.md +516 -0
- package/docs/developer/AUTH.md +204 -0
- package/docs/developer/CONTRIBUTING.md +227 -0
- package/docs/developer/DOCUMENTATION_SUMMARY.md +346 -0
- package/docs/developer/PROJECT_INDEX.md +365 -0
- package/docs/planning/API_COVERAGE.md +1045 -0
- package/docs/planning/BACKLOG.md +1159 -0
- package/docs/planning/PROFILE_SYSTEM_TASKS.md +287 -0
- package/docs/planning/UX_IMPLEMENTATION_PLAN.md +691 -0
- package/docs/planning/archive/RELEASE_CHECKLIST_v1.3.0.md +332 -0
- package/docs/planning/archive/RELEASE_v1.3.0.md +428 -0
- package/docs/planning/archive/cakemail-cli-ux-improvements.md +438 -0
- package/docs/planning/cakemail-profile-system-plan.md +1121 -0
- package/docs/testing/AI_USER_SIMULATION_DESIGN.md +1342 -0
- package/docs/testing/KENOGAMI_BIDIRECTIONAL_FLOW.md +1517 -0
- package/docs/testing/KENOGAMI_TRUTH_RECONCILIATION_SYSTEM.md +1369 -0
- package/docs/user-manual/.obsidian/app.json +1 -0
- package/docs/user-manual/.obsidian/appearance.json +1 -0
- package/docs/user-manual/.obsidian/core-plugins.json +33 -0
- package/docs/user-manual/.obsidian/workspace.json +167 -0
- package/docs/user-manual/01-getting-started/01-installation.md +214 -0
- package/docs/user-manual/01-getting-started/02-quick-start.md +432 -0
- package/docs/user-manual/01-getting-started/03-authentication.md +448 -0
- package/docs/user-manual/01-getting-started/04-configuration.md +430 -0
- package/docs/user-manual/01-getting-started/05-output-formats.md +447 -0
- package/docs/user-manual/02-core-concepts/01-accounts.md +514 -0
- package/docs/user-manual/02-core-concepts/02-profile-system.md +771 -0
- package/docs/user-manual/02-core-concepts/03-smart-defaults.md +485 -0
- package/docs/user-manual/02-core-concepts/04-authentication-methods.md +435 -0
- package/docs/user-manual/02-core-concepts/05-pagination-filtering.md +600 -0
- package/docs/user-manual/02-core-concepts/06-error-handling.md +718 -0
- package/docs/user-manual/02-core-concepts/07-api-coverage.md +483 -0
- package/docs/user-manual/03-email-operations/01-senders.md +490 -0
- package/docs/user-manual/03-email-operations/02-templates.md +444 -0
- package/docs/user-manual/03-email-operations/03-transactional-emails.md +706 -0
- package/docs/user-manual/03-email-operations/04-email-tracking.md +407 -0
- package/docs/user-manual/04-campaign-management/01-campaigns-basics.md +394 -0
- package/docs/user-manual/04-campaign-management/02-campaign-scheduling.md +630 -0
- package/docs/user-manual/04-campaign-management/03-campaign-testing.md +997 -0
- package/docs/user-manual/04-campaign-management/04-campaign-lifecycle.md +709 -0
- package/docs/user-manual/04-campaign-management/05-campaign-links.md +934 -0
- package/docs/user-manual/05-contact-management/01-lists.md +836 -0
- package/docs/user-manual/05-contact-management/02-contacts.md +1035 -0
- package/docs/user-manual/05-contact-management/03-custom-attributes.md +788 -0
- package/docs/user-manual/05-contact-management/04-segments.md +1028 -0
- package/docs/user-manual/05-contact-management/05-contact-import-export.md +1031 -0
- package/docs/user-manual/06-analytics-reporting/01-campaign-analytics.md +867 -0
- package/docs/user-manual/06-analytics-reporting/02-account-reports.md +227 -0
- package/docs/user-manual/07-integrations/01-webhooks-integration.md +259 -0
- package/docs/user-manual/07-integrations/02-automation.md +326 -0
- package/docs/user-manual/08-advanced-usage/01-scripting-patterns.md +672 -0
- package/docs/user-manual/08-advanced-usage/02-bulk-operations.md +932 -0
- package/docs/user-manual/08-advanced-usage/03-ci-cd-integration.md +892 -0
- package/docs/user-manual/08-advanced-usage/04-performance-optimization.md +766 -0
- package/docs/user-manual/09-command-reference/01-config.md +776 -0
- package/docs/user-manual/09-command-reference/02-account.md +652 -0
- package/docs/user-manual/09-command-reference/03-lists.md +958 -0
- package/docs/user-manual/09-command-reference/04-contacts.md +1408 -0
- package/docs/user-manual/09-command-reference/05-attributes.md +617 -0
- package/docs/user-manual/09-command-reference/06-segments.md +894 -0
- package/docs/user-manual/09-command-reference/07-senders.md +803 -0
- package/docs/user-manual/09-command-reference/08-templates.md +818 -0
- package/docs/user-manual/09-command-reference/09-campaigns.md +1250 -0
- package/docs/user-manual/09-command-reference/10-emails.md +807 -0
- package/docs/user-manual/09-command-reference/11-reports.md +1135 -0
- package/docs/user-manual/09-command-reference/12-webhooks.md +773 -0
- package/docs/user-manual/09-command-reference/13-suppressed.md +797 -0
- package/docs/user-manual/09-command-reference/14-interests.md +630 -0
- package/docs/user-manual/09-command-reference/15-tags.md +584 -0
- package/docs/user-manual/09-command-reference/16-logs.md +656 -0
- package/docs/user-manual/09-command-reference/17-transactional-templates.md +850 -0
- package/docs/user-manual/10-troubleshooting/01-common-errors.md +457 -0
- package/docs/user-manual/10-troubleshooting/02-authentication-issues.md +558 -0
- package/docs/user-manual/10-troubleshooting/03-connection-problems.md +634 -0
- package/docs/user-manual/10-troubleshooting/04-debugging.md +725 -0
- package/docs/user-manual/11-appendix/04-faq.md +484 -0
- package/docs/user-manual/11-appendix/05-glossary.md +250 -0
- package/docs/user-manual/README.md +0 -0
- package/package.json +13 -61
- package/src/cli.ts +125 -0
- package/src/client.ts +16 -0
- package/src/commands/account.ts +267 -0
- package/src/commands/accounts.ts +78 -0
- package/src/commands/actions.ts +249 -0
- package/src/commands/attributes.ts +139 -0
- package/src/commands/campaign-blueprints.ts +106 -0
- package/src/commands/campaigns.ts +469 -0
- package/src/commands/config.ts +77 -0
- package/src/commands/contacts.ts +612 -0
- package/src/commands/custom-attributes.ts +127 -0
- package/src/commands/dkims.ts +117 -0
- package/src/commands/domains.ts +82 -0
- package/src/commands/email-apis.ts +569 -0
- package/src/commands/emails.ts +197 -0
- package/src/commands/forms.ts +283 -0
- package/src/commands/interests.ts +155 -0
- package/src/commands/links.ts +38 -0
- package/src/commands/lists.ts +406 -0
- package/src/commands/logos.ts +71 -0
- package/src/commands/logs.ts +386 -0
- package/src/commands/reports.ts +306 -0
- package/src/commands/segments.ts +158 -0
- package/src/commands/senders.ts +204 -0
- package/src/commands/sub-accounts.ts +271 -0
- package/src/commands/suppressed-emails.ts +234 -0
- package/src/commands/suppressed.ts +198 -0
- package/src/commands/system-emails.ts +85 -0
- package/src/commands/tags.ts +146 -0
- package/src/commands/tasks.ts +116 -0
- package/src/commands/templates.ts +189 -0
- package/src/commands/tokens.ts +83 -0
- package/src/commands/transactional-emails.ts +374 -0
- package/src/commands/transactional-templates.ts +385 -0
- package/src/commands/users.ts +506 -0
- package/src/commands/webhooks.ts +172 -0
- package/src/commands/workflow-blueprints.ts +123 -0
- package/src/commands/workflows.ts +265 -0
- package/src/types/profile.ts +93 -0
- package/src/utils/auth.ts +272 -0
- package/src/utils/config-file.ts +96 -0
- package/src/utils/config.ts +134 -0
- package/src/utils/confirm.ts +32 -0
- package/src/utils/defaults.ts +99 -0
- package/src/utils/errors.ts +116 -0
- package/src/utils/interactive.ts +91 -0
- package/src/utils/list-defaults.ts +74 -0
- package/src/utils/output.ts +190 -0
- package/src/utils/progress.ts +320 -0
- package/src/utils/spinner.ts +22 -0
- package/tests/IMPLEMENTATION_STATUS.md +258 -0
- package/tests/PTY_SETUP.md +118 -0
- package/tests/PTY_TESTING_GUIDE.md +507 -0
- package/tests/README.md +244 -0
- package/tests/fixtures/api-responses/campaigns.json +34 -0
- package/tests/fixtures/test-config.json +13 -0
- package/tests/helpers/cli-runner.ts +128 -0
- package/tests/helpers/mock-server.ts +301 -0
- package/tests/helpers/pty-runner.ts +181 -0
- package/tests/integration/campaigns-real-api.test.ts +196 -0
- package/tests/integration/setup-integration.ts +50 -0
- package/tests/pty/campaigns.test.ts +241 -0
- package/tests/setup.ts +34 -0
- package/tsconfig.json +15 -0
- package/vitest.config.ts +28 -0
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
# Authentication Issues
|
|
2
|
+
|
|
3
|
+
Diagnose and resolve authentication and credential problems with the Cakemail CLI.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Common authentication issues:
|
|
8
|
+
- Missing or invalid credentials
|
|
9
|
+
- Expired access tokens
|
|
10
|
+
- Account access problems
|
|
11
|
+
- Permission errors
|
|
12
|
+
- Multi-account conflicts
|
|
13
|
+
|
|
14
|
+
## Missing Credentials
|
|
15
|
+
|
|
16
|
+
### Error: "No credentials found in .env file"
|
|
17
|
+
|
|
18
|
+
**Cause:** The CLI cannot find your credentials.
|
|
19
|
+
|
|
20
|
+
**Solutions:**
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Option 1: Run interactive setup
|
|
24
|
+
$ cakemail config init
|
|
25
|
+
? Email: your@email.com
|
|
26
|
+
? Password: ********
|
|
27
|
+
✓ Configuration saved
|
|
28
|
+
|
|
29
|
+
# Option 2: Create .env file manually
|
|
30
|
+
$ cat > .env << EOF
|
|
31
|
+
CAKEMAIL_EMAIL=your@email.com
|
|
32
|
+
CAKEMAIL_PASSWORD=your_password
|
|
33
|
+
EOF
|
|
34
|
+
|
|
35
|
+
# Option 3: Use environment variables
|
|
36
|
+
$ export CAKEMAIL_EMAIL="your@email.com"
|
|
37
|
+
$ export CAKEMAIL_PASSWORD="your_password"
|
|
38
|
+
|
|
39
|
+
# Verify setup
|
|
40
|
+
$ cakemail account test
|
|
41
|
+
✓ Authentication successful
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Error: "Cannot read .env file"
|
|
45
|
+
|
|
46
|
+
**Cause:** File permissions or path issues.
|
|
47
|
+
|
|
48
|
+
**Solutions:**
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Check if .env exists
|
|
52
|
+
$ ls -la .env
|
|
53
|
+
-rw------- 1 user staff 89 Oct 13 12:00 .env
|
|
54
|
+
|
|
55
|
+
# Fix permissions if needed
|
|
56
|
+
$ chmod 600 .env
|
|
57
|
+
|
|
58
|
+
# Verify file contents (redact password)
|
|
59
|
+
$ cat .env | grep -v PASSWORD
|
|
60
|
+
CAKEMAIL_EMAIL=your@email.com
|
|
61
|
+
|
|
62
|
+
# Check file location
|
|
63
|
+
$ pwd
|
|
64
|
+
/your/project/directory
|
|
65
|
+
|
|
66
|
+
# CLI looks for .env in:
|
|
67
|
+
# 1. Current directory
|
|
68
|
+
# 2. ~/.cakemail/.env
|
|
69
|
+
# 3. Environment variables
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Invalid Credentials
|
|
73
|
+
|
|
74
|
+
### Error: "Invalid credentials" or "Authentication failed"
|
|
75
|
+
|
|
76
|
+
**Cause:** Email or password is incorrect.
|
|
77
|
+
|
|
78
|
+
**Solutions:**
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Test login on web interface first
|
|
82
|
+
# Visit: https://app.cakemail.com
|
|
83
|
+
|
|
84
|
+
# Verify email format
|
|
85
|
+
$ echo $CAKEMAIL_EMAIL
|
|
86
|
+
your@email.com # Must be valid email
|
|
87
|
+
|
|
88
|
+
# Check for typos in .env
|
|
89
|
+
$ cat .env
|
|
90
|
+
# Common issues:
|
|
91
|
+
# - Extra spaces: " your@email.com" (wrong)
|
|
92
|
+
# - Quotes: "your@email.com" (may cause issues)
|
|
93
|
+
# - Wrong variable name: CAKEMAIL_USER (wrong)
|
|
94
|
+
|
|
95
|
+
# Re-initialize with correct credentials
|
|
96
|
+
$ cakemail config init
|
|
97
|
+
|
|
98
|
+
# Test authentication
|
|
99
|
+
$ cakemail account test
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Special Characters in Password
|
|
103
|
+
|
|
104
|
+
**Problem:** Password contains special characters that break parsing.
|
|
105
|
+
|
|
106
|
+
**Solutions:**
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# Quote password in .env
|
|
110
|
+
CAKEMAIL_PASSWORD='p@ssw0rd!$pecial'
|
|
111
|
+
|
|
112
|
+
# Or use environment variable with proper quoting
|
|
113
|
+
export CAKEMAIL_PASSWORD='p@ssw0rd!$pecial'
|
|
114
|
+
|
|
115
|
+
# Avoid in .env (unquoted):
|
|
116
|
+
CAKEMAIL_PASSWORD=p@ssw0rd!$pecial # May fail
|
|
117
|
+
|
|
118
|
+
# Use interactive setup (handles escaping)
|
|
119
|
+
$ cakemail config init
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Expired or Invalid Tokens
|
|
123
|
+
|
|
124
|
+
### Error: "Access token expired" or "Invalid token"
|
|
125
|
+
|
|
126
|
+
**Cause:** Stored access token is no longer valid.
|
|
127
|
+
|
|
128
|
+
**Solutions:**
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# Option 1: Remove token (CLI will get new one)
|
|
132
|
+
$ sed -i '/CAKEMAIL_ACCESS_TOKEN/d' .env
|
|
133
|
+
|
|
134
|
+
# Option 2: Delete token file
|
|
135
|
+
$ rm ~/.cakemail/token
|
|
136
|
+
|
|
137
|
+
# Option 3: Re-initialize
|
|
138
|
+
$ cakemail config init
|
|
139
|
+
|
|
140
|
+
# Test - CLI will automatically refresh token
|
|
141
|
+
$ cakemail account show
|
|
142
|
+
|
|
143
|
+
# Check token in .env (if curious)
|
|
144
|
+
$ grep ACCESS_TOKEN .env
|
|
145
|
+
CAKEMAIL_ACCESS_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Token Not Refreshing
|
|
149
|
+
|
|
150
|
+
**Problem:** CLI not automatically refreshing expired tokens.
|
|
151
|
+
|
|
152
|
+
**Solutions:**
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Force token refresh
|
|
156
|
+
$ rm .env
|
|
157
|
+
$ cakemail config init
|
|
158
|
+
|
|
159
|
+
# Check CLI version (bug in older versions)
|
|
160
|
+
$ cakemail --version
|
|
161
|
+
|
|
162
|
+
# Update if needed
|
|
163
|
+
$ npm update -g @cakemail-org/cakemail-cli
|
|
164
|
+
|
|
165
|
+
# Manual token refresh (advanced)
|
|
166
|
+
$ cakemail config refresh-token
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Account Access Issues
|
|
170
|
+
|
|
171
|
+
### Error: "Account not found" or "Account not accessible"
|
|
172
|
+
|
|
173
|
+
**Cause:** Your account doesn't exist or you don't have access.
|
|
174
|
+
|
|
175
|
+
**Solutions:**
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# Verify account exists
|
|
179
|
+
# Log into: https://app.cakemail.com
|
|
180
|
+
|
|
181
|
+
# Check accessible accounts
|
|
182
|
+
$ cakemail account list
|
|
183
|
+
Available accounts:
|
|
184
|
+
[456] Agency Account
|
|
185
|
+
[457] Client Account
|
|
186
|
+
|
|
187
|
+
# Verify current account
|
|
188
|
+
$ cakemail account show
|
|
189
|
+
Account ID: 456
|
|
190
|
+
Account Name: Agency Account
|
|
191
|
+
|
|
192
|
+
# Switch if needed
|
|
193
|
+
$ cakemail account use 457
|
|
194
|
+
✓ Switched to account 457
|
|
195
|
+
|
|
196
|
+
# Test access
|
|
197
|
+
$ cakemail lists list
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Multiple Accounts Confusion
|
|
201
|
+
|
|
202
|
+
**Problem:** Working with wrong account.
|
|
203
|
+
|
|
204
|
+
**Solutions:**
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
# List all accessible accounts
|
|
208
|
+
$ cakemail account list
|
|
209
|
+
|
|
210
|
+
# Check current account
|
|
211
|
+
$ cakemail account show
|
|
212
|
+
|
|
213
|
+
# Switch to correct account
|
|
214
|
+
$ cakemail account use 456
|
|
215
|
+
|
|
216
|
+
# Verify resources exist in this account
|
|
217
|
+
$ cakemail lists list
|
|
218
|
+
$ cakemail senders list
|
|
219
|
+
|
|
220
|
+
# Use account ID in resource URLs
|
|
221
|
+
# Instead of: cakemail lists get 123
|
|
222
|
+
# Try: cakemail account use 456 && cakemail lists get 123
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Permission Errors
|
|
226
|
+
|
|
227
|
+
### Error: "Insufficient permissions" or "Forbidden"
|
|
228
|
+
|
|
229
|
+
**Cause:** Your account doesn't have required permissions.
|
|
230
|
+
|
|
231
|
+
**Solutions:**
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
# Check account type
|
|
235
|
+
$ cakemail account show -f json | jq '.account_type'
|
|
236
|
+
"standard" # vs "admin"
|
|
237
|
+
|
|
238
|
+
# Verify permissions
|
|
239
|
+
$ cakemail account show -f json | jq '.permissions'
|
|
240
|
+
["campaigns:read", "lists:read"]
|
|
241
|
+
|
|
242
|
+
# Contact account admin for permissions
|
|
243
|
+
# Or use account with appropriate access
|
|
244
|
+
|
|
245
|
+
# Switch to admin account if available
|
|
246
|
+
$ cakemail account list
|
|
247
|
+
$ cakemail account use ADMIN_ACCOUNT_ID
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### API Key vs Password Authentication
|
|
251
|
+
|
|
252
|
+
**Problem:** Using wrong authentication method.
|
|
253
|
+
|
|
254
|
+
**Current status:** CLI uses email/password .
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
# API key support not yet available
|
|
258
|
+
# Use email/password:
|
|
259
|
+
CAKEMAIL_EMAIL=your@email.com
|
|
260
|
+
CAKEMAIL_PASSWORD=your_password
|
|
261
|
+
|
|
262
|
+
# Not supported (yet):
|
|
263
|
+
# CAKEMAIL_API_KEY=abc123...
|
|
264
|
+
|
|
265
|
+
# Check roadmap for API key support
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Multi-User Scenarios
|
|
269
|
+
|
|
270
|
+
### Team Member Access Issues
|
|
271
|
+
|
|
272
|
+
**Problem:** Multiple team members using same credentials.
|
|
273
|
+
|
|
274
|
+
**Solutions:**
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
# Each team member should have own account
|
|
278
|
+
# Don't share credentials
|
|
279
|
+
|
|
280
|
+
# Create separate accounts at:
|
|
281
|
+
# https://app.cakemail.com/settings/team
|
|
282
|
+
|
|
283
|
+
# Each member uses own credentials
|
|
284
|
+
# Member 1:
|
|
285
|
+
CAKEMAIL_EMAIL=member1@company.com
|
|
286
|
+
CAKEMAIL_PASSWORD=password1
|
|
287
|
+
|
|
288
|
+
# Member 2:
|
|
289
|
+
CAKEMAIL_EMAIL=member2@company.com
|
|
290
|
+
CAKEMAIL_PASSWORD=password2
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### CI/CD Authentication
|
|
294
|
+
|
|
295
|
+
**Problem:** Authenticating in automated environments.
|
|
296
|
+
|
|
297
|
+
**Solutions:**
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
# Use environment variables (secure)
|
|
301
|
+
export CAKEMAIL_EMAIL="${SECRETS_EMAIL}"
|
|
302
|
+
export CAKEMAIL_PASSWORD="${SECRETS_PASSWORD}"
|
|
303
|
+
|
|
304
|
+
# Don't commit .env to git
|
|
305
|
+
echo ".env" >> .gitignore
|
|
306
|
+
|
|
307
|
+
# GitHub Actions example:
|
|
308
|
+
env:
|
|
309
|
+
CAKEMAIL_EMAIL: ${{ secrets.CAKEMAIL_EMAIL }}
|
|
310
|
+
CAKEMAIL_PASSWORD: ${{ secrets.CAKEMAIL_PASSWORD }}
|
|
311
|
+
|
|
312
|
+
# Create .env from secrets
|
|
313
|
+
echo "CAKEMAIL_EMAIL=$CAKEMAIL_EMAIL" > .env
|
|
314
|
+
echo "CAKEMAIL_PASSWORD=$CAKEMAIL_PASSWORD" >> .env
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
## Configuration File Issues
|
|
318
|
+
|
|
319
|
+
### Wrong Configuration Directory
|
|
320
|
+
|
|
321
|
+
**Problem:** CLI using wrong config location.
|
|
322
|
+
|
|
323
|
+
**Solutions:**
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
# Check config locations (in order):
|
|
327
|
+
# 1. Current directory: ./env
|
|
328
|
+
$ ls -la .env
|
|
329
|
+
|
|
330
|
+
# 2. Home directory: ~/.cakemail/.env
|
|
331
|
+
$ ls -la ~/.cakemail/.env
|
|
332
|
+
|
|
333
|
+
# 3. Environment variables
|
|
334
|
+
$ env | grep CAKEMAIL
|
|
335
|
+
|
|
336
|
+
# Force specific location
|
|
337
|
+
$ cd /path/to/project
|
|
338
|
+
$ cakemail config init # Creates .env here
|
|
339
|
+
|
|
340
|
+
# Or use home directory
|
|
341
|
+
$ mkdir -p ~/.cakemail
|
|
342
|
+
$ cd ~/.cakemail
|
|
343
|
+
$ cakemail config init
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Corrupted Configuration
|
|
347
|
+
|
|
348
|
+
**Problem:** .env file is corrupted or malformed.
|
|
349
|
+
|
|
350
|
+
**Solutions:**
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
# Validate .env format
|
|
354
|
+
$ cat .env
|
|
355
|
+
CAKEMAIL_EMAIL=your@email.com
|
|
356
|
+
CAKEMAIL_PASSWORD=your_password
|
|
357
|
+
|
|
358
|
+
# Check for issues:
|
|
359
|
+
# - Empty lines at start
|
|
360
|
+
# - Missing = signs
|
|
361
|
+
# - Quotes inconsistency
|
|
362
|
+
# - Extra characters
|
|
363
|
+
|
|
364
|
+
# Recreate if corrupted
|
|
365
|
+
$ rm .env
|
|
366
|
+
$ cakemail config init
|
|
367
|
+
|
|
368
|
+
# Or create manually
|
|
369
|
+
$ cat > .env << 'EOF'
|
|
370
|
+
CAKEMAIL_EMAIL=your@email.com
|
|
371
|
+
CAKEMAIL_PASSWORD=your_password
|
|
372
|
+
EOF
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
## Debugging Authentication
|
|
376
|
+
|
|
377
|
+
### Enable Debug Mode
|
|
378
|
+
|
|
379
|
+
```bash
|
|
380
|
+
# See authentication details
|
|
381
|
+
$ export DEBUG=cakemail:auth
|
|
382
|
+
|
|
383
|
+
# Run command
|
|
384
|
+
$ cakemail account show
|
|
385
|
+
|
|
386
|
+
# Output shows:
|
|
387
|
+
# - Token retrieval
|
|
388
|
+
# - API calls
|
|
389
|
+
# - Auth headers (redacted)
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### Test Authentication Step by Step
|
|
393
|
+
|
|
394
|
+
```bash
|
|
395
|
+
# 1. Check credentials exist
|
|
396
|
+
$ cat .env | grep CAKEMAIL_EMAIL
|
|
397
|
+
CAKEMAIL_EMAIL=your@email.com
|
|
398
|
+
|
|
399
|
+
# 2. Test basic command
|
|
400
|
+
$ cakemail account test
|
|
401
|
+
✓ Authentication successful
|
|
402
|
+
|
|
403
|
+
# 3. Test account access
|
|
404
|
+
$ cakemail account show
|
|
405
|
+
|
|
406
|
+
# 4. Test resource access
|
|
407
|
+
$ cakemail lists list
|
|
408
|
+
|
|
409
|
+
# 5. Check verbose output
|
|
410
|
+
$ cakemail lists list --verbose
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### Manual Token Verification
|
|
414
|
+
|
|
415
|
+
```bash
|
|
416
|
+
# Extract token
|
|
417
|
+
$ TOKEN=$(grep ACCESS_TOKEN .env | cut -d= -f2)
|
|
418
|
+
|
|
419
|
+
# Decode JWT (without verification)
|
|
420
|
+
$ echo $TOKEN | cut -d. -f2 | base64 -d 2>/dev/null | jq .
|
|
421
|
+
|
|
422
|
+
# Check expiration
|
|
423
|
+
{
|
|
424
|
+
"exp": 1710345600,
|
|
425
|
+
"iat": 1710259200,
|
|
426
|
+
"account_id": 456
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
# Compare to current time
|
|
430
|
+
$ date +%s
|
|
431
|
+
1710300000
|
|
432
|
+
|
|
433
|
+
# If exp < current time, token expired
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
## Security Best Practices
|
|
437
|
+
|
|
438
|
+
### Protect Credentials
|
|
439
|
+
|
|
440
|
+
```bash
|
|
441
|
+
# Set restrictive permissions
|
|
442
|
+
$ chmod 600 .env
|
|
443
|
+
|
|
444
|
+
# Don't commit to git
|
|
445
|
+
$ echo ".env" >> .gitignore
|
|
446
|
+
$ echo ".cakemail/" >> .gitignore
|
|
447
|
+
|
|
448
|
+
# Don't log passwords
|
|
449
|
+
# Bad:
|
|
450
|
+
$ echo "Password: $CAKEMAIL_PASSWORD"
|
|
451
|
+
|
|
452
|
+
# Use secrets management
|
|
453
|
+
# - GitHub Secrets
|
|
454
|
+
# - HashiCorp Vault
|
|
455
|
+
# - AWS Secrets Manager
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
### Rotate Credentials
|
|
459
|
+
|
|
460
|
+
```bash
|
|
461
|
+
# Change password regularly
|
|
462
|
+
# 1. Update on web interface
|
|
463
|
+
# 2. Update locally
|
|
464
|
+
$ cakemail config init
|
|
465
|
+
|
|
466
|
+
# Clear old tokens
|
|
467
|
+
$ find . -name ".cakemail" -type d -exec rm -rf {} +
|
|
468
|
+
$ sed -i '/ACCESS_TOKEN/d' .env
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
## Common Scenarios
|
|
472
|
+
|
|
473
|
+
### Scenario 1: New Machine Setup
|
|
474
|
+
|
|
475
|
+
```bash
|
|
476
|
+
# Install CLI
|
|
477
|
+
$ npm install -g @cakemail-org/cakemail-cli
|
|
478
|
+
|
|
479
|
+
# Configure credentials
|
|
480
|
+
$ cakemail config init
|
|
481
|
+
? Email: your@email.com
|
|
482
|
+
? Password: ********
|
|
483
|
+
|
|
484
|
+
# Test
|
|
485
|
+
$ cakemail account show
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
### Scenario 2: Credential Change
|
|
489
|
+
|
|
490
|
+
```bash
|
|
491
|
+
# Password changed on website
|
|
492
|
+
# Update locally:
|
|
493
|
+
$ cakemail config init
|
|
494
|
+
|
|
495
|
+
# Or update .env manually:
|
|
496
|
+
$ vim .env
|
|
497
|
+
# Change CAKEMAIL_PASSWORD value
|
|
498
|
+
|
|
499
|
+
# Remove old token
|
|
500
|
+
$ sed -i '/ACCESS_TOKEN/d' .env
|
|
501
|
+
|
|
502
|
+
# Test
|
|
503
|
+
$ cakemail account test
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
### Scenario 3: Switching Projects
|
|
507
|
+
|
|
508
|
+
```bash
|
|
509
|
+
# Project A (account 456)
|
|
510
|
+
$ cd /projects/project-a
|
|
511
|
+
$ cat .env
|
|
512
|
+
CAKEMAIL_EMAIL=team@project-a.com
|
|
513
|
+
CAKEMAIL_PASSWORD=password_a
|
|
514
|
+
|
|
515
|
+
# Project B (account 457)
|
|
516
|
+
$ cd /projects/project-b
|
|
517
|
+
$ cat .env
|
|
518
|
+
CAKEMAIL_EMAIL=team@project-b.com
|
|
519
|
+
CAKEMAIL_PASSWORD=password_b
|
|
520
|
+
|
|
521
|
+
# CLI automatically uses local .env in each project
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
## Quick Fixes
|
|
525
|
+
|
|
526
|
+
### Reset Everything
|
|
527
|
+
|
|
528
|
+
```bash
|
|
529
|
+
# Nuclear option - start fresh
|
|
530
|
+
$ rm -rf ~/.cakemail
|
|
531
|
+
$ rm .env
|
|
532
|
+
$ cakemail config init
|
|
533
|
+
$ cakemail account test
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
### Check System Status
|
|
537
|
+
|
|
538
|
+
```bash
|
|
539
|
+
# Verify Cakemail API is up
|
|
540
|
+
$ curl -I https://api.cakemail.com
|
|
541
|
+
HTTP/2 200
|
|
542
|
+
|
|
543
|
+
# Check internet connection
|
|
544
|
+
$ ping -c 3 api.cakemail.com
|
|
545
|
+
|
|
546
|
+
# Check DNS resolution
|
|
547
|
+
$ nslookup api.cakemail.com
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
## Getting Help
|
|
551
|
+
|
|
552
|
+
If authentication issues persist:
|
|
553
|
+
|
|
554
|
+
1. **Verify credentials work on web**: https://app.cakemail.com
|
|
555
|
+
2. **Check CLI version**: `cakemail --version`
|
|
556
|
+
3. **Enable debug mode**: `export DEBUG=cakemail:*`
|
|
557
|
+
4. **Create GitHub issue**: Include sanitized debug output
|
|
558
|
+
|