1- # Password Setup Script
1+ # Environment Setup Scripts
22
33## Quick Start
44
5- Run the interactive password setup:
5+ ### Complete Environment Setup (Recommended)
6+
7+ Run the interactive environment setup that handles everything:
8+
9+ ``` bash
10+ npm run setup-env
11+ ```
12+
13+ Or directly:
14+
15+ ``` bash
16+ node scripts/setup-env.js
17+ ```
18+
19+ This will set up:
20+
21+ - SESSION_SECRET (auto-generated)
22+ - MASTER_PASSWORD_BCRYPT_HASH (interactive)
23+ - IMAP_CONFIG (optional, interactive)
24+
25+ ### Password-Only Setup
26+
27+ If you only need to update the password:
628
729``` bash
830npm run setup-password
@@ -14,7 +36,58 @@ Or directly:
1436node scripts/setup-password.js
1537```
1638
17- ## What It Does
39+ ## setup-env.js - Complete Environment Setup
40+
41+ ### What It Does
42+
43+ The script will:
44+
45+ 1 . ✅ Generate a SESSION_SECRET using ` openssl rand -base64 32 `
46+ 2 . ✅ Ask you to enter your desired master password
47+ 3 . ✅ Ask you to confirm the password
48+ 4 . ✅ Generate a secure bcrypt hash (using 10 salt rounds) and base64 encode it
49+ 5 . ✅ Ask if you want to update the IMAP configuration
50+ 6 . ✅ If yes, open the current IMAP config in Notepad for editing
51+ 7 . ✅ Wait for you to save and close Notepad
52+ 8 . ✅ Convert the edited JSON to base64-encoded single line
53+ 9 . ✅ Automatically update the ` .env ` file with all new values
54+ 10 . ✅ Run comprehensive tests to ensure everything works
55+
56+ ### IMAP Configuration Editing
57+
58+ When you choose to update the IMAP config:
59+
60+ 1 . The script decodes the current ` IMAP_CONFIG ` from base64
61+ 2 . Formats it as readable JSON with proper line breaks
62+ 3 . Saves it to a temporary ` temp.json ` file
63+ 4 . Opens it in Notepad for you to edit
64+ 5 . ** You edit, save (Ctrl+S), and close Notepad**
65+ 6 . The script validates the JSON
66+ 7 . Converts it back to base64 in a single line
67+ 8 . Updates the ` .env ` file
68+ 9 . Cleans up the temporary file
69+
70+ ### Example IMAP Config Format
71+
72+ ``` json
73+ {
74+ "accounts" : [
75+ {
76+ "id" : " account1" ,
77+ "label" : " Account 1" ,
78+ "imap" : {
79+ "host" : " imap.example.com" ,
80+ "port" : 993 ,
81+ "secure" : true ,
82+ "user" : " user@example.com" ,
83+ "password" : " your-password"
84+ }
85+ }
86+ ]
87+ }
88+ ```
89+
90+ ## setup-password.js - Password-Only Setup
1891
1992The script will:
2093
@@ -57,7 +130,7 @@ Step 4: Updating .env file...
57130✓ .env file updated successfully!
58131
59132Step 5: Testing password verification...
60- ✓ Password verification successful!
133+ ✓ Password verification successful!e
61134 ✓ .env file contains correct hash!
62135 ✓ Password matches hash from .env!
63136
@@ -98,6 +171,8 @@ Step 5: Testing password verification...
98171
99172## Related Scripts
100173
101- - ` password_gen.js ` - Simple password hash generator (non-interactive)
174+ - ` setup-env.js ` - ** Recommended** : Complete environment setup (SESSION_SECRET + password + IMAP config)
175+ - ` setup-password.js ` - Password-only setup (legacy)
176+ - ` test-password.js ` - Test password verification
102177- ` setup-password.js ` - This interactive setup script (recommended)
103178
0 commit comments