emailengine-app 2.73.1 → 2.74.1

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/server.js CHANGED
@@ -114,6 +114,7 @@ initSentry('main');
114
114
  // Import additional dependencies
115
115
  const pathlib = require('path');
116
116
  const { redis, queueConf, notifyQueue, submitQueue, documentsQueue, exportQueue } = require('./lib/db');
117
+ const { packRpcError, unpackRpcError } = require('./lib/worker-rpc-error');
117
118
  const promClient = require('prom-client');
118
119
  const fs = require('fs').promises;
119
120
  const crypto = require('crypto');
@@ -1262,17 +1263,7 @@ let spawnWorker = async (type, opts) => {
1262
1263
  clearTimeout(timer);
1263
1264
  callQueue.delete(message.mid);
1264
1265
  if (message.error) {
1265
- let err = new Error(message.error);
1266
- if (message.code) {
1267
- err.code = message.code;
1268
- }
1269
- if (message.statusCode) {
1270
- err.statusCode = message.statusCode;
1271
- }
1272
- if (message.info) {
1273
- err.info = message.info;
1274
- }
1275
- return reject(err);
1266
+ return reject(unpackRpcError(message));
1276
1267
  } else {
1277
1268
  return resolve(message.response);
1278
1269
  }
@@ -1309,14 +1300,7 @@ let spawnWorker = async (type, opts) => {
1309
1300
  }
1310
1301
  })
1311
1302
  .catch(err => {
1312
- let callPayload = {
1313
- cmd: 'resp',
1314
- mid: message.mid,
1315
- error: err.message,
1316
- code: err.code,
1317
- statusCode: err.statusCode,
1318
- info: err.info
1319
- };
1303
+ let callPayload = Object.assign({ cmd: 'resp', mid: message.mid }, packRpcError(err));
1320
1304
 
1321
1305
  try {
1322
1306
  postMessage(worker, callPayload);
@@ -55,6 +55,10 @@ if [ ! -f "docker-compose.yml" ]; then
55
55
  exit 1
56
56
  fi
57
57
 
58
+ # Everything this script writes from here on (the .env file and its backup) holds EENGINE_SECRET and
59
+ # generated passwords, so create them owner-only from birth instead of tightening after the fact.
60
+ umask 077
61
+
58
62
  # Create .env file if it doesn't exist
59
63
  if [ -f ".env" ]; then
60
64
  print_message $YELLOW "Warning: .env file already exists"
@@ -64,8 +68,9 @@ if [ -f ".env" ]; then
64
68
  print_message $YELLOW "Setup cancelled. Existing .env file preserved."
65
69
  exit 0
66
70
  fi
67
- # Backup existing .env
68
- cp .env .env.backup.$(date +%Y%m%d-%H%M%S)
71
+ # Backup existing .env. It holds EENGINE_SECRET and generated passwords; umask 077 (set above)
72
+ # keeps the copy owner-only from creation rather than leaving a world-readable window.
73
+ cp .env ".env.backup.$(date +%Y%m%d-%H%M%S)"
69
74
  print_message $GREEN "✓ Existing .env backed up"
70
75
  fi
71
76