@friggframework/core 2.0.0--canary.428.a673c47.0 → 2.0.0--canary.428.42e0806.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/handlers/routers/health.js +85 -1
- package/package.json +5 -5
|
@@ -416,11 +416,95 @@ const checkKmsDecryptCapability = async () => {
|
|
|
416
416
|
reason: 'KMS_KEY_ARN not configured',
|
|
417
417
|
};
|
|
418
418
|
}
|
|
419
|
+
|
|
420
|
+
// Log environment for debugging
|
|
421
|
+
console.log('KMS Check Debug:', {
|
|
422
|
+
hasKmsKeyArn: !!KMS_KEY_ARN,
|
|
423
|
+
kmsKeyArnPrefix: KMS_KEY_ARN?.substring(0, 30),
|
|
424
|
+
awsRegion: process.env.AWS_REGION,
|
|
425
|
+
awsDefaultRegion: process.env.AWS_DEFAULT_REGION,
|
|
426
|
+
hasDiscoveryKey: !!process.env.AWS_DISCOVERY_KMS_KEY_ID,
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
// Test DNS resolution for KMS endpoint
|
|
430
|
+
try {
|
|
431
|
+
const dns = require('dns').promises;
|
|
432
|
+
const region = process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION || 'eu-central-1';
|
|
433
|
+
const kmsEndpoint = `kms.${region}.amazonaws.com`;
|
|
434
|
+
console.log('Testing DNS resolution for:', kmsEndpoint);
|
|
435
|
+
const addresses = await dns.resolve4(kmsEndpoint);
|
|
436
|
+
console.log('KMS endpoint resolved to:', addresses);
|
|
437
|
+
|
|
438
|
+
// Test TCP connectivity to KMS (port 443)
|
|
439
|
+
const net = require('net');
|
|
440
|
+
const testConnection = () => new Promise((resolve) => {
|
|
441
|
+
const socket = new net.Socket();
|
|
442
|
+
const connectionTimeout = setTimeout(() => {
|
|
443
|
+
socket.destroy();
|
|
444
|
+
resolve({ connected: false, error: 'Connection timeout' });
|
|
445
|
+
}, 3000);
|
|
446
|
+
|
|
447
|
+
socket.on('connect', () => {
|
|
448
|
+
clearTimeout(connectionTimeout);
|
|
449
|
+
socket.destroy();
|
|
450
|
+
resolve({ connected: true });
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
socket.on('error', (err) => {
|
|
454
|
+
clearTimeout(connectionTimeout);
|
|
455
|
+
resolve({ connected: false, error: err.message });
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
// Try connecting to first resolved address on HTTPS port
|
|
459
|
+
socket.connect(443, addresses[0]);
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
const connResult = await testConnection();
|
|
463
|
+
console.log('TCP connectivity test:', connResult);
|
|
464
|
+
|
|
465
|
+
if (!connResult.connected) {
|
|
466
|
+
return {
|
|
467
|
+
status: 'unhealthy',
|
|
468
|
+
error: `Cannot connect to KMS endpoint: ${connResult.error}`,
|
|
469
|
+
dnsResolved: true,
|
|
470
|
+
tcpConnection: false,
|
|
471
|
+
latencyMs: Date.now() - start,
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
} catch (dnsError) {
|
|
475
|
+
console.error('DNS resolution failed:', dnsError.message);
|
|
476
|
+
return {
|
|
477
|
+
status: 'unhealthy',
|
|
478
|
+
error: `Cannot resolve KMS endpoint: ${dnsError.message}`,
|
|
479
|
+
dnsResolved: false,
|
|
480
|
+
latencyMs: Date.now() - start,
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
|
|
419
484
|
try {
|
|
420
485
|
// Lazy load to avoid cost if unused in some environments
|
|
421
486
|
// eslint-disable-next-line global-require
|
|
422
487
|
const AWS = require('aws-sdk');
|
|
423
|
-
|
|
488
|
+
|
|
489
|
+
// Ensure AWS SDK has proper configuration
|
|
490
|
+
const region = process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION;
|
|
491
|
+
if (!region) {
|
|
492
|
+
return {
|
|
493
|
+
status: 'unhealthy',
|
|
494
|
+
error: 'AWS_REGION not configured',
|
|
495
|
+
latencyMs: Date.now() - start,
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
const kms = new AWS.KMS({
|
|
500
|
+
region,
|
|
501
|
+
httpOptions: {
|
|
502
|
+
timeout: 5000, // 5 second timeout
|
|
503
|
+
connectTimeout: 5000,
|
|
504
|
+
},
|
|
505
|
+
maxRetries: 1, // Don't retry on health checks
|
|
506
|
+
});
|
|
507
|
+
|
|
424
508
|
// Generate a data key (without plaintext logging) then immediately decrypt ciphertext to ensure decrypt perms.
|
|
425
509
|
const dataKeyResp = await kms
|
|
426
510
|
.generateDataKey({ KeyId: KMS_KEY_ARN, KeySpec: 'AES_256' })
|
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.428.
|
|
4
|
+
"version": "2.0.0--canary.428.42e0806.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.428.
|
|
26
|
-
"@friggframework/prettier-config": "2.0.0--canary.428.
|
|
27
|
-
"@friggframework/test": "2.0.0--canary.428.
|
|
25
|
+
"@friggframework/eslint-config": "2.0.0--canary.428.42e0806.0",
|
|
26
|
+
"@friggframework/prettier-config": "2.0.0--canary.428.42e0806.0",
|
|
27
|
+
"@friggframework/test": "2.0.0--canary.428.42e0806.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": "
|
|
59
|
+
"gitHead": "42e0806db6ef878a5397b3e1752ae6cf21e6a845"
|
|
60
60
|
}
|