@powerhousedao/ph-cli 2.5.0-dev.1 → 2.5.0-dev.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/ph-cli",
3
- "version": "2.5.0-dev.1",
3
+ "version": "2.5.0-dev.10",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
@@ -20,8 +20,8 @@ else
20
20
  # =============================================================================
21
21
  # Package Installation
22
22
  # =============================================================================
23
- sudo apt install -y postgresql postgresql-contrib nginx nginx-module-brotli
24
- sudo ln -sf /usr/share/nginx/modules-available/mod-brotli.conf /etc/nginx/modules-enabled/50-mod-brotli.conf
23
+ sudo apt install -y postgresql postgresql-contrib nginx libnginx-mod-http-brotli-static libnginx-mod-http-brotli-filter
24
+ sudo sed -i 's/# gzip_vary/gzip_vary/; s/# gzip_proxied/gzip_proxied/; s/# gzip_comp_level/gzip_comp_level/; s/# gzip_buffers/gzip_buffers/; s/# gzip_http_version/gzip_http_version/; s/# gzip_types/gzip_types/' /etc/nginx/nginx.conf
25
25
 
26
26
  # =============================================================================
27
27
  # Interactive Package Installation
@@ -113,6 +113,23 @@ EOF
113
113
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
114
114
  echo " SSL Configuration"
115
115
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
116
+
117
+ # Add compression settings to nginx.conf if not exists
118
+ if ! grep -q "brotli_comp_level" /etc/nginx/nginx.conf || ! grep -q "gzip_comp_level" /etc/nginx/nginx.conf; then
119
+ echo "Adding compression settings to nginx.conf..."
120
+ # Find the http block in nginx.conf
121
+ if ! grep -q "brotli_comp_level" /etc/nginx/nginx.conf; then
122
+ sudo sed -i '/http {/a \ # Brotli compression\n brotli on;\n brotli_comp_level 6;\n brotli_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;\n brotli_static on;' /etc/nginx/nginx.conf
123
+ fi
124
+ if ! grep -q "gzip_comp_level" /etc/nginx/nginx.conf; then
125
+ sudo sed -i '/http {/a \ # Gzip compression\n gzip on;\n gzip_vary on;\n gzip_proxied any;\n gzip_comp_level 6;\n gzip_buffers 16 8k;\n gzip_http_version 1.1;\n gzip_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;' /etc/nginx/nginx.conf
126
+ fi
127
+ else
128
+ echo "Compression settings already present in nginx.conf"
129
+ fi
130
+
131
+
132
+
116
133
  echo "Choose SSL configuration:"
117
134
  echo "1) Let's Encrypt certificates for domains"
118
135
  echo "2) Self-signed certificate for machine hostname"
@@ -130,132 +147,58 @@ EOF
130
147
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
131
148
  read -p "Enter Connect domain (e.g. connect.google.com): " connect_domain
132
149
  read -p "Enter Switchboard domain (e.g. switchboard.google.com): " switchboard_domain
150
+ read -p "Enter admin email for Let's Encrypt notifications: " admin_email
133
151
 
134
152
  echo "Using domains:"
135
153
  echo "Connect: $connect_domain"
136
154
  echo "Switchboard: $switchboard_domain"
137
155
 
138
- # Generate temporary SSL certificates
139
- echo "Generating temporary SSL certificates..."
140
- sudo mkdir -p /etc/nginx/ssl
141
- sudo openssl req -x509 -nodes -days 1 -newkey rsa:2048 \
142
- -keyout /etc/nginx/ssl/temp.key \
143
- -out /etc/nginx/ssl/temp.crt \
144
- -subj "/CN=$connect_domain" \
145
- -addext "subjectAltName = DNS:$connect_domain,DNS:$switchboard_domain"
146
-
147
- # Check if Nginx configuration already exists
148
- if [ -f "/etc/nginx/sites-available/$PROJECT_NAME" ]; then
149
- echo "Nginx configuration for $PROJECT_NAME already exists"
150
- read -p "Do you want to overwrite it? (y/n): " overwrite_nginx
151
- if [ "$overwrite_nginx" != "y" ]; then
152
- echo "Keeping existing Nginx configuration"
153
- else
154
- # Create Nginx configuration for domains
155
- echo "Creating Nginx configuration..."
156
- sudo tee /etc/nginx/sites-available/$PROJECT_NAME > /dev/null << EOF
157
- # Security headers
158
- add_header Strict-Transport-Security "max-age=63072000" always;
159
- add_header X-Frame-Options DENY;
160
- add_header X-Content-Type-Options nosniff;
161
- add_header X-XSS-Protection "1; mode=block";
162
-
163
- # Compression settings
164
- brotli on;
165
- brotli_comp_level 6;
166
- brotli_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;
167
- brotli_static on;
168
-
169
- gzip on;
170
- gzip_vary on;
171
- gzip_proxied any;
172
- gzip_comp_level 6;
173
- gzip_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;
174
- gzip_min_length 1000;
175
- gzip_buffers 16 8k;
176
-
156
+ # Create initial Nginx configuration for certbot
157
+ echo "Creating initial Nginx configuration..."
158
+ sudo tee /etc/nginx/sites-available/$PROJECT_NAME > /dev/null << EOF
177
159
  server {
178
160
  listen 80;
179
161
  server_name $connect_domain $switchboard_domain;
180
- return 301 https://\$host\$request_uri;
181
- }
182
-
183
- server {
184
- listen 443 ssl http2;
185
- server_name $connect_domain;
186
-
187
- ssl_certificate /etc/nginx/ssl/temp.crt;
188
- ssl_certificate_key /etc/nginx/ssl/temp.key;
189
-
190
- # SSL configuration
191
- ssl_protocols TLSv1.2 TLSv1.3;
192
- ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
193
- ssl_prefer_server_ciphers off;
194
- ssl_session_timeout 1d;
195
- ssl_session_cache shared:SSL:50m;
196
- ssl_session_tickets off;
197
- ssl_stapling on;
198
- ssl_stapling_verify on;
199
-
200
- if (\$http_x_forwarded_proto = "http") {
201
- return 301 https://\$server_name\$request_uri;
202
- }
203
162
 
204
163
  location / {
205
- root $PWD/.ph/connect-build/dist;
164
+ root /var/www/html/$PROJECT_NAME;
206
165
  try_files \$uri \$uri/ /index.html;
207
- add_header Cache-Control "no-cache";
208
- add_header X-Forwarded-Proto \$scheme;
209
- add_header X-Forwarded-Host \$host;
210
- add_header X-Forwarded-Port \$server_port;
211
166
  }
212
- }
213
167
 
214
- server {
215
- listen 443 ssl http2;
216
- server_name $switchboard_domain;
217
-
218
- ssl_certificate /etc/nginx/ssl/temp.crt;
219
- ssl_certificate_key /etc/nginx/ssl/temp.key;
220
-
221
- location / {
222
- proxy_pass http://localhost:4001;
223
- proxy_http_version 1.1;
224
- proxy_set_header Upgrade \$http_upgrade;
225
- proxy_set_header Connection 'upgrade';
226
- proxy_set_header Host \$host;
227
- proxy_cache_bypass \$http_upgrade;
228
- proxy_set_header X-Real-IP \$remote_addr;
229
- proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
230
- proxy_set_header X-Forwarded-Proto \$scheme;
168
+ location /.well-known/acme-challenge/ {
169
+ root /var/www/html;
231
170
  }
232
171
  }
233
172
  EOF
234
- fi
235
- else
236
- # Create Nginx configuration for domains
237
- echo "Creating Nginx configuration..."
238
- sudo tee /etc/nginx/sites-available/$PROJECT_NAME > /dev/null << EOF
239
- # Security headers
240
- add_header Strict-Transport-Security "max-age=63072000" always;
241
- add_header X-Frame-Options DENY;
242
- add_header X-Content-Type-Options nosniff;
243
- add_header X-XSS-Protection "1; mode=block";
244
-
245
- # Compression settings
246
- brotli on;
247
- brotli_comp_level 6;
248
- brotli_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;
249
- brotli_static on;
250
-
251
- gzip on;
252
- gzip_vary on;
253
- gzip_proxied any;
254
- gzip_comp_level 6;
255
- gzip_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;
256
- gzip_min_length 1000;
257
- gzip_buffers 16 8k;
258
173
 
174
+ # Enable the site
175
+ sudo ln -sf /etc/nginx/sites-available/$PROJECT_NAME /etc/nginx/sites-enabled/
176
+ sudo rm -f /etc/nginx/sites-enabled/default
177
+
178
+ # Test Nginx configuration
179
+ sudo nginx -t
180
+
181
+ # Restart Nginx to apply changes
182
+ sudo systemctl restart nginx
183
+
184
+ # Obtain SSL certificates
185
+ echo "Obtaining SSL certificates..."
186
+ sudo certbot --nginx -d $connect_domain --non-interactive --agree-tos --email $admin_email --redirect
187
+ sudo certbot --nginx -d $switchboard_domain --non-interactive --agree-tos --email $admin_email --redirect
188
+
189
+ # Wait for certbot to finish and certificates to be installed
190
+ sleep 5
191
+
192
+ # Check if certificates were installed
193
+ if [ ! -f "/etc/letsencrypt/live/$connect_domain/fullchain.pem" ] || [ ! -f "/etc/letsencrypt/live/$switchboard_domain/fullchain.pem" ]; then
194
+ echo "Error: SSL certificates were not installed properly"
195
+ echo "Please check the certbot logs at /var/log/letsencrypt/letsencrypt.log"
196
+ exit 1
197
+ fi
198
+
199
+ # Update Nginx configuration with proper SSL settings
200
+ echo "Updating Nginx configuration with SSL settings..."
201
+ sudo tee /etc/nginx/sites-available/$PROJECT_NAME > /dev/null << EOF
259
202
  server {
260
203
  listen 80;
261
204
  server_name $connect_domain $switchboard_domain;
@@ -263,11 +206,12 @@ server {
263
206
  }
264
207
 
265
208
  server {
266
- listen 443 ssl http2;
209
+ listen 443 ssl;
210
+ http2 on;
267
211
  server_name $connect_domain;
268
212
 
269
- ssl_certificate /etc/nginx/ssl/temp.crt;
270
- ssl_certificate_key /etc/nginx/ssl/temp.key;
213
+ ssl_certificate /etc/letsencrypt/live/$connect_domain/fullchain.pem;
214
+ ssl_certificate_key /etc/letsencrypt/live/$connect_domain/privkey.pem;
271
215
 
272
216
  # SSL configuration
273
217
  ssl_protocols TLSv1.2 TLSv1.3;
@@ -278,6 +222,14 @@ server {
278
222
  ssl_session_tickets off;
279
223
  ssl_stapling on;
280
224
  ssl_stapling_verify on;
225
+ resolver 8.8.8.8 8.8.4.4 valid=300s;
226
+ resolver_timeout 5s;
227
+
228
+ # Security headers
229
+ add_header Strict-Transport-Security "max-age=63072000" always;
230
+ add_header X-Frame-Options DENY;
231
+ add_header X-Content-Type-Options nosniff;
232
+ add_header X-XSS-Protection "1; mode=block";
281
233
 
282
234
  if (\$http_x_forwarded_proto = "http") {
283
235
  return 301 https://\$server_name\$request_uri;
@@ -291,14 +243,37 @@ server {
291
243
  add_header X-Forwarded-Host \$host;
292
244
  add_header X-Forwarded-Port \$server_port;
293
245
  }
246
+
247
+ location /.well-known/acme-challenge/ {
248
+ root /var/www/html;
249
+ }
294
250
  }
295
251
 
296
252
  server {
297
- listen 443 ssl http2;
253
+ listen 443 ssl;
254
+ http2 on;
298
255
  server_name $switchboard_domain;
299
256
 
300
- ssl_certificate /etc/nginx/ssl/temp.crt;
301
- ssl_certificate_key /etc/nginx/ssl/temp.key;
257
+ ssl_certificate /etc/letsencrypt/live/$switchboard_domain/fullchain.pem;
258
+ ssl_certificate_key /etc/letsencrypt/live/$switchboard_domain/privkey.pem;
259
+
260
+ # SSL configuration
261
+ ssl_protocols TLSv1.2 TLSv1.3;
262
+ ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
263
+ ssl_prefer_server_ciphers off;
264
+ ssl_session_timeout 1d;
265
+ ssl_session_cache shared:SSL:50m;
266
+ ssl_session_tickets off;
267
+ ssl_stapling on;
268
+ ssl_stapling_verify on;
269
+ resolver 8.8.8.8 8.8.4.4 valid=300s;
270
+ resolver_timeout 5s;
271
+
272
+ # Security headers
273
+ add_header Strict-Transport-Security "max-age=63072000" always;
274
+ add_header X-Frame-Options DENY;
275
+ add_header X-Content-Type-Options nosniff;
276
+ add_header X-XSS-Protection "1; mode=block";
302
277
 
303
278
  location / {
304
279
  proxy_pass http://localhost:4001;
@@ -311,23 +286,20 @@ server {
311
286
  proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
312
287
  proxy_set_header X-Forwarded-Proto \$scheme;
313
288
  }
289
+
290
+ location /.well-known/acme-challenge/ {
291
+ root /var/www/html;
292
+ }
314
293
  }
315
294
  EOF
316
- fi
317
295
 
318
- # Enable the site
319
- sudo ln -sf /etc/nginx/sites-available/$PROJECT_NAME /etc/nginx/sites-enabled/
320
- sudo rm -f /etc/nginx/sites-enabled/default
296
+ # Test and reload Nginx configuration
297
+ sudo nginx -t && sudo systemctl reload nginx
321
298
 
322
- # Test Nginx configuration
323
- sudo nginx -t
324
-
325
- # Obtain SSL certificates
326
- echo "Obtaining SSL certificates..."
327
- sudo certbot --nginx -d $connect_domain -d $switchboard_domain --non-interactive --agree-tos --email admin@$connect_domain
328
-
329
- # Remove temporary certificates
330
- sudo rm -f /etc/nginx/ssl/temp.*
299
+ # Set up automatic renewal
300
+ echo "Setting up automatic certificate renewal..."
301
+ sudo systemctl enable certbot.timer
302
+ sudo systemctl start certbot.timer
331
303
 
332
304
  else
333
305
  # Get machine hostname
@@ -344,26 +316,6 @@ EOF
344
316
  # Create Nginx configuration for self-signed
345
317
  echo "Creating Nginx configuration..."
346
318
  sudo tee /etc/nginx/sites-available/$PROJECT_NAME > /dev/null << EOF
347
- # Security headers
348
- add_header Strict-Transport-Security "max-age=63072000" always;
349
- add_header X-Frame-Options DENY;
350
- add_header X-Content-Type-Options nosniff;
351
- add_header X-XSS-Protection "1; mode=block";
352
-
353
- # Compression settings
354
- brotli on;
355
- brotli_comp_level 6;
356
- brotli_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;
357
- brotli_static on;
358
-
359
- gzip on;
360
- gzip_vary on;
361
- gzip_proxied any;
362
- gzip_comp_level 6;
363
- gzip_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;
364
- gzip_min_length 1000;
365
- gzip_buffers 16 8k;
366
-
367
319
  server {
368
320
  listen 80;
369
321
  server_name $hostname;
@@ -371,7 +323,8 @@ server {
371
323
  }
372
324
 
373
325
  server {
374
- listen 443 ssl http2;
326
+ listen 443 ssl;
327
+ http2 on;
375
328
  server_name $hostname;
376
329
 
377
330
  ssl_certificate /etc/ssl/certs/$hostname.crt;
@@ -1,2 +1,2 @@
1
- export declare const version = "2.5.0-dev.1";
1
+ export declare const version = "2.5.0-dev.10";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,gBAAgB,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,iBAAiB,CAAC"}
@@ -1,3 +1,3 @@
1
1
  // This file is auto-generated. DO NOT EDIT.
2
- export const version = "2.5.0-dev.1";
2
+ export const version = "2.5.0-dev.10";
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,MAAM,CAAC,MAAM,OAAO,GAAG,cAAc,CAAC"}