@friggframework/core 2.0.0--canary.419.a9bb30f.0 → 2.0.0--canary.419.8343c27.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.
@@ -15,20 +15,7 @@ const validateApiKey = (req, res, next) => {
15
15
  }
16
16
 
17
17
  if (!apiKey || apiKey !== process.env.HEALTH_API_KEY) {
18
- const healthApiKey = process.env.HEALTH_API_KEY;
19
- console.log('Incoming API Key Debug:', {
20
- first3: apiKey ? apiKey.substring(0, 3) : 'undefined',
21
- last3: apiKey ? apiKey.substring(apiKey.length - 3) : 'undefined',
22
- length: apiKey ? apiKey.length : 0,
23
- });
24
- console.log('Health API Key Debug:', {
25
- first3: healthApiKey ? healthApiKey.substring(0, 3) : 'undefined',
26
- last3: healthApiKey
27
- ? healthApiKey.substring(healthApiKey.length - 3)
28
- : 'undefined',
29
- length: healthApiKey ? healthApiKey.length : 0,
30
- });
31
- console.log('Unauthorized access attempt to health endpoint');
18
+ console.error('Unauthorized access attempt to health endpoint');
32
19
  return res.status(401).json({
33
20
  status: 'error',
34
21
  message: 'Unauthorized',
@@ -163,21 +150,6 @@ const createTestEncryptionModel = () => {
163
150
  );
164
151
  };
165
152
 
166
- const createTestDocument = async (TestModel) => {
167
- const testData = {
168
- testSecret: 'This is a secret value that should be encrypted',
169
- normalField: 'This is a normal field that should not be encrypted',
170
- nestedSecret: {
171
- value: 'This is a nested secret that should be encrypted',
172
- },
173
- };
174
-
175
- const testDoc = new TestModel(testData);
176
- await testDoc.save();
177
-
178
- return { testDoc, testData };
179
- };
180
-
181
153
  const verifyDecryption = (retrievedDoc, originalData) => {
182
154
  return (
183
155
  retrievedDoc &&
@@ -251,18 +223,51 @@ const evaluateEncryptionTestResults = (decryptionWorks, encryptionResults) => {
251
223
  };
252
224
  };
253
225
 
226
+ const withTimeout = (promise, ms, errorMessage) => {
227
+ return Promise.race([
228
+ promise,
229
+ new Promise((_, reject) =>
230
+ setTimeout(() => reject(new Error(errorMessage)), ms)
231
+ ),
232
+ ]);
233
+ };
234
+
254
235
  const testEncryption = async () => {
236
+ // eslint-disable-next-line no-console
237
+ console.log('Starting encryption test');
255
238
  const TestModel = createTestEncryptionModel();
256
- const { testDoc, testData } = await createTestDocument(TestModel);
239
+ // eslint-disable-next-line no-console
240
+ console.log('Test model created');
241
+
242
+ const testData = {
243
+ testSecret: 'This is a secret value that should be encrypted',
244
+ normalField: 'This is a normal field that should not be encrypted',
245
+ nestedSecret: {
246
+ value: 'This is a nested secret that should be encrypted',
247
+ },
248
+ };
249
+
250
+ const testDoc = new TestModel(testData);
251
+ await withTimeout(testDoc.save(), 5000, 'Save operation timed out');
252
+ // eslint-disable-next-line no-console
253
+ console.log('Test document saved');
257
254
 
258
255
  try {
259
- const retrievedDoc = await TestModel.findById(testDoc._id);
256
+ const retrievedDoc = await withTimeout(
257
+ TestModel.findById(testDoc._id),
258
+ 5000,
259
+ 'Find operation timed out'
260
+ );
261
+ // eslint-disable-next-line no-console
262
+ console.log('Test document retrieved');
260
263
  const decryptionWorks = verifyDecryption(retrievedDoc, testData);
261
- const encryptionResults = await verifyEncryptionInDatabase(
262
- testDoc,
263
- testData,
264
- TestModel
264
+ const encryptionResults = await withTimeout(
265
+ verifyEncryptionInDatabase(testDoc, testData, TestModel),
266
+ 5000,
267
+ 'Database verification timed out'
265
268
  );
269
+ // eslint-disable-next-line no-console
270
+ console.log('Encryption verification completed');
266
271
 
267
272
  const evaluation = evaluateEncryptionTestResults(
268
273
  decryptionWorks,
@@ -274,7 +279,13 @@ const testEncryption = async () => {
274
279
  encryptionWorks: decryptionWorks,
275
280
  };
276
281
  } finally {
277
- await TestModel.deleteOne({ _id: testDoc._id });
282
+ await withTimeout(
283
+ TestModel.deleteOne({ _id: testDoc._id }),
284
+ 5000,
285
+ 'Delete operation timed out'
286
+ );
287
+ // eslint-disable-next-line no-console
288
+ console.log('Test document deleted');
278
289
  }
279
290
  };
280
291
 
@@ -282,6 +293,12 @@ const checkEncryptionHealth = async () => {
282
293
  const config = getEncryptionConfiguration();
283
294
 
284
295
  if (config.isBypassed || config.mode === 'none') {
296
+ // eslint-disable-next-line no-console
297
+ console.log('Encryption check bypassed:', {
298
+ stage: config.stage,
299
+ mode: config.mode,
300
+ });
301
+
285
302
  const testResult = config.isBypassed
286
303
  ? 'Encryption bypassed for this stage'
287
304
  : 'No encryption keys configured';
@@ -400,6 +417,8 @@ router.get('/health', async (_req, res) => {
400
417
  });
401
418
 
402
419
  router.get('/health/detailed', async (_req, res) => {
420
+ // eslint-disable-next-line no-console
421
+ console.log('Starting detailed health check');
403
422
  const startTime = Date.now();
404
423
  const response = buildHealthCheckResponse(startTime);
405
424
 
@@ -409,12 +428,16 @@ router.get('/health/detailed', async (_req, res) => {
409
428
  if (!dbState.isConnected) {
410
429
  response.status = 'unhealthy';
411
430
  }
431
+ // eslint-disable-next-line no-console
432
+ console.log('Database check completed:', response.checks.database);
412
433
  } catch (error) {
413
434
  response.checks.database = {
414
435
  status: 'unhealthy',
415
436
  error: error.message,
416
437
  };
417
438
  response.status = 'unhealthy';
439
+ // eslint-disable-next-line no-console
440
+ console.log('Database check error:', error.message);
418
441
  }
419
442
 
420
443
  try {
@@ -422,12 +445,16 @@ router.get('/health/detailed', async (_req, res) => {
422
445
  if (response.checks.encryption.status === 'unhealthy') {
423
446
  response.status = 'unhealthy';
424
447
  }
448
+ // eslint-disable-next-line no-console
449
+ console.log('Encryption check completed:', response.checks.encryption);
425
450
  } catch (error) {
426
451
  response.checks.encryption = {
427
452
  status: 'unhealthy',
428
453
  error: error.message,
429
454
  };
430
455
  response.status = 'unhealthy';
456
+ // eslint-disable-next-line no-console
457
+ console.log('Encryption check error:', error.message);
431
458
  }
432
459
 
433
460
  const { apiStatuses, allReachable } = await checkExternalAPIs();
@@ -435,15 +462,24 @@ router.get('/health/detailed', async (_req, res) => {
435
462
  if (!allReachable) {
436
463
  response.status = 'unhealthy';
437
464
  }
465
+ // eslint-disable-next-line no-console
466
+ console.log('External APIs check completed:', response.checks.externalApis);
438
467
 
439
468
  try {
440
469
  response.checks.integrations = checkIntegrations();
470
+ // eslint-disable-next-line no-console
471
+ console.log(
472
+ 'Integrations check completed:',
473
+ response.checks.integrations
474
+ );
441
475
  } catch (error) {
442
476
  response.checks.integrations = {
443
477
  status: 'unhealthy',
444
478
  error: error.message,
445
479
  };
446
480
  response.status = 'unhealthy';
481
+ // eslint-disable-next-line no-console
482
+ console.log('Integrations check error:', error.message);
447
483
  }
448
484
 
449
485
  response.responseTime = response.calculateResponseTime();
@@ -451,6 +487,14 @@ router.get('/health/detailed', async (_req, res) => {
451
487
 
452
488
  const statusCode = response.status === 'healthy' ? 200 : 503;
453
489
  res.status(statusCode).json(response);
490
+
491
+ // eslint-disable-next-line no-console
492
+ console.log(
493
+ 'Final health status:',
494
+ response.status,
495
+ 'Response time:',
496
+ response.responseTime
497
+ );
454
498
  });
455
499
 
456
500
  router.get('/health/live', (_req, res) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@friggframework/core",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0--canary.419.a9bb30f.0",
4
+ "version": "2.0.0--canary.419.8343c27.0",
5
5
  "dependencies": {
6
6
  "@hapi/boom": "^10.0.1",
7
7
  "aws-sdk": "^2.1200.0",
@@ -22,9 +22,9 @@
22
22
  "uuid": "^9.0.1"
23
23
  },
24
24
  "devDependencies": {
25
- "@friggframework/eslint-config": "2.0.0--canary.419.a9bb30f.0",
26
- "@friggframework/prettier-config": "2.0.0--canary.419.a9bb30f.0",
27
- "@friggframework/test": "2.0.0--canary.419.a9bb30f.0",
25
+ "@friggframework/eslint-config": "2.0.0--canary.419.8343c27.0",
26
+ "@friggframework/prettier-config": "2.0.0--canary.419.8343c27.0",
27
+ "@friggframework/test": "2.0.0--canary.419.8343c27.0",
28
28
  "@types/lodash": "4.17.15",
29
29
  "@typescript-eslint/eslint-plugin": "^8.0.0",
30
30
  "chai": "^4.3.6",
@@ -56,5 +56,5 @@
56
56
  "publishConfig": {
57
57
  "access": "public"
58
58
  },
59
- "gitHead": "a9bb30f7ae26580e49e1a2ed7ac62e6df8db9638"
59
+ "gitHead": "8343c27a69423f9186421c9caf188399e56bbf67"
60
60
  }