tlc-claude-code 1.4.8 → 1.4.9

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.
Files changed (169) hide show
  1. package/package.json +1 -1
  2. package/server/index.js +229 -14
  3. package/server/lib/compliance/control-mapper.js +401 -0
  4. package/server/lib/compliance/control-mapper.test.js +117 -0
  5. package/server/lib/compliance/evidence-linker.js +296 -0
  6. package/server/lib/compliance/evidence-linker.test.js +121 -0
  7. package/server/lib/compliance/gdpr-checklist.js +416 -0
  8. package/server/lib/compliance/gdpr-checklist.test.js +131 -0
  9. package/server/lib/compliance/hipaa-checklist.js +277 -0
  10. package/server/lib/compliance/hipaa-checklist.test.js +101 -0
  11. package/server/lib/compliance/iso27001-checklist.js +287 -0
  12. package/server/lib/compliance/iso27001-checklist.test.js +99 -0
  13. package/server/lib/compliance/multi-framework-reporter.js +284 -0
  14. package/server/lib/compliance/multi-framework-reporter.test.js +127 -0
  15. package/server/lib/compliance/pci-dss-checklist.js +214 -0
  16. package/server/lib/compliance/pci-dss-checklist.test.js +95 -0
  17. package/server/lib/compliance/trust-centre.js +187 -0
  18. package/server/lib/compliance/trust-centre.test.js +93 -0
  19. package/server/lib/dashboard/api-server.js +155 -0
  20. package/server/lib/dashboard/api-server.test.js +155 -0
  21. package/server/lib/dashboard/health-api.js +199 -0
  22. package/server/lib/dashboard/health-api.test.js +122 -0
  23. package/server/lib/dashboard/notes-api.js +234 -0
  24. package/server/lib/dashboard/notes-api.test.js +134 -0
  25. package/server/lib/dashboard/router-api.js +176 -0
  26. package/server/lib/dashboard/router-api.test.js +132 -0
  27. package/server/lib/dashboard/tasks-api.js +289 -0
  28. package/server/lib/dashboard/tasks-api.test.js +161 -0
  29. package/server/lib/dashboard/tlc-introspection.js +197 -0
  30. package/server/lib/dashboard/tlc-introspection.test.js +138 -0
  31. package/server/lib/dashboard/version-api.js +222 -0
  32. package/server/lib/dashboard/version-api.test.js +112 -0
  33. package/server/lib/dashboard/websocket-server.js +104 -0
  34. package/server/lib/dashboard/websocket-server.test.js +118 -0
  35. package/server/lib/deploy/branch-classifier.js +163 -0
  36. package/server/lib/deploy/branch-classifier.test.js +164 -0
  37. package/server/lib/deploy/deployment-approval.js +299 -0
  38. package/server/lib/deploy/deployment-approval.test.js +296 -0
  39. package/server/lib/deploy/deployment-audit.js +374 -0
  40. package/server/lib/deploy/deployment-audit.test.js +307 -0
  41. package/server/lib/deploy/deployment-executor.js +335 -0
  42. package/server/lib/deploy/deployment-executor.test.js +329 -0
  43. package/server/lib/deploy/deployment-rules.js +163 -0
  44. package/server/lib/deploy/deployment-rules.test.js +188 -0
  45. package/server/lib/deploy/rollback-manager.js +379 -0
  46. package/server/lib/deploy/rollback-manager.test.js +321 -0
  47. package/server/lib/deploy/security-gates.js +236 -0
  48. package/server/lib/deploy/security-gates.test.js +222 -0
  49. package/server/lib/k8s/gitops-config.js +188 -0
  50. package/server/lib/k8s/gitops-config.test.js +59 -0
  51. package/server/lib/k8s/helm-generator.js +196 -0
  52. package/server/lib/k8s/helm-generator.test.js +59 -0
  53. package/server/lib/k8s/kustomize-generator.js +176 -0
  54. package/server/lib/k8s/kustomize-generator.test.js +58 -0
  55. package/server/lib/k8s/network-policy.js +114 -0
  56. package/server/lib/k8s/network-policy.test.js +53 -0
  57. package/server/lib/k8s/pod-security.js +114 -0
  58. package/server/lib/k8s/pod-security.test.js +55 -0
  59. package/server/lib/k8s/rbac-generator.js +132 -0
  60. package/server/lib/k8s/rbac-generator.test.js +57 -0
  61. package/server/lib/k8s/resource-manager.js +172 -0
  62. package/server/lib/k8s/resource-manager.test.js +60 -0
  63. package/server/lib/k8s/secrets-encryption.js +168 -0
  64. package/server/lib/k8s/secrets-encryption.test.js +49 -0
  65. package/server/lib/monitoring/alert-manager.js +238 -0
  66. package/server/lib/monitoring/alert-manager.test.js +106 -0
  67. package/server/lib/monitoring/health-check.js +226 -0
  68. package/server/lib/monitoring/health-check.test.js +176 -0
  69. package/server/lib/monitoring/incident-manager.js +230 -0
  70. package/server/lib/monitoring/incident-manager.test.js +98 -0
  71. package/server/lib/monitoring/log-aggregator.js +147 -0
  72. package/server/lib/monitoring/log-aggregator.test.js +89 -0
  73. package/server/lib/monitoring/metrics-collector.js +337 -0
  74. package/server/lib/monitoring/metrics-collector.test.js +172 -0
  75. package/server/lib/monitoring/status-page.js +214 -0
  76. package/server/lib/monitoring/status-page.test.js +105 -0
  77. package/server/lib/monitoring/uptime-monitor.js +194 -0
  78. package/server/lib/monitoring/uptime-monitor.test.js +109 -0
  79. package/server/lib/network/fail2ban-config.js +294 -0
  80. package/server/lib/network/fail2ban-config.test.js +275 -0
  81. package/server/lib/network/firewall-manager.js +252 -0
  82. package/server/lib/network/firewall-manager.test.js +254 -0
  83. package/server/lib/network/geoip-filter.js +282 -0
  84. package/server/lib/network/geoip-filter.test.js +264 -0
  85. package/server/lib/network/rate-limiter.js +229 -0
  86. package/server/lib/network/rate-limiter.test.js +293 -0
  87. package/server/lib/network/request-validator.js +351 -0
  88. package/server/lib/network/request-validator.test.js +345 -0
  89. package/server/lib/network/security-headers.js +251 -0
  90. package/server/lib/network/security-headers.test.js +283 -0
  91. package/server/lib/network/tls-config.js +210 -0
  92. package/server/lib/network/tls-config.test.js +248 -0
  93. package/server/lib/security/auth-security.js +369 -0
  94. package/server/lib/security/auth-security.test.js +448 -0
  95. package/server/lib/security/cis-benchmark.js +152 -0
  96. package/server/lib/security/cis-benchmark.test.js +137 -0
  97. package/server/lib/security/compose-templates.js +312 -0
  98. package/server/lib/security/compose-templates.test.js +229 -0
  99. package/server/lib/security/container-runtime.js +456 -0
  100. package/server/lib/security/container-runtime.test.js +503 -0
  101. package/server/lib/security/cors-validator.js +278 -0
  102. package/server/lib/security/cors-validator.test.js +310 -0
  103. package/server/lib/security/crypto-utils.js +253 -0
  104. package/server/lib/security/crypto-utils.test.js +409 -0
  105. package/server/lib/security/dockerfile-linter.js +459 -0
  106. package/server/lib/security/dockerfile-linter.test.js +483 -0
  107. package/server/lib/security/dockerfile-templates.js +278 -0
  108. package/server/lib/security/dockerfile-templates.test.js +164 -0
  109. package/server/lib/security/error-sanitizer.js +426 -0
  110. package/server/lib/security/error-sanitizer.test.js +331 -0
  111. package/server/lib/security/headers-generator.js +368 -0
  112. package/server/lib/security/headers-generator.test.js +398 -0
  113. package/server/lib/security/image-scanner.js +83 -0
  114. package/server/lib/security/image-scanner.test.js +106 -0
  115. package/server/lib/security/input-validator.js +352 -0
  116. package/server/lib/security/input-validator.test.js +330 -0
  117. package/server/lib/security/network-policy.js +174 -0
  118. package/server/lib/security/network-policy.test.js +164 -0
  119. package/server/lib/security/output-encoder.js +237 -0
  120. package/server/lib/security/output-encoder.test.js +276 -0
  121. package/server/lib/security/path-validator.js +359 -0
  122. package/server/lib/security/path-validator.test.js +293 -0
  123. package/server/lib/security/query-builder.js +421 -0
  124. package/server/lib/security/query-builder.test.js +318 -0
  125. package/server/lib/security/secret-detector.js +290 -0
  126. package/server/lib/security/secret-detector.test.js +354 -0
  127. package/server/lib/security/secrets-validator.js +137 -0
  128. package/server/lib/security/secrets-validator.test.js +120 -0
  129. package/server/lib/security-testing/dast-runner.js +154 -0
  130. package/server/lib/security-testing/dast-runner.test.js +62 -0
  131. package/server/lib/security-testing/dependency-scanner.js +172 -0
  132. package/server/lib/security-testing/dependency-scanner.test.js +64 -0
  133. package/server/lib/security-testing/pentest-runner.js +230 -0
  134. package/server/lib/security-testing/pentest-runner.test.js +60 -0
  135. package/server/lib/security-testing/sast-runner.js +136 -0
  136. package/server/lib/security-testing/sast-runner.test.js +62 -0
  137. package/server/lib/security-testing/secret-scanner.js +153 -0
  138. package/server/lib/security-testing/secret-scanner.test.js +66 -0
  139. package/server/lib/security-testing/security-gate.js +216 -0
  140. package/server/lib/security-testing/security-gate.test.js +115 -0
  141. package/server/lib/security-testing/security-reporter.js +303 -0
  142. package/server/lib/security-testing/security-reporter.test.js +114 -0
  143. package/server/lib/standards/audit-checker.js +546 -0
  144. package/server/lib/standards/audit-checker.test.js +415 -0
  145. package/server/lib/standards/cleanup-executor.js +452 -0
  146. package/server/lib/standards/cleanup-executor.test.js +293 -0
  147. package/server/lib/standards/refactor-stepper.js +425 -0
  148. package/server/lib/standards/refactor-stepper.test.js +298 -0
  149. package/server/lib/standards/standards-injector.js +167 -0
  150. package/server/lib/standards/standards-injector.test.js +232 -0
  151. package/server/lib/user-management.test.js +284 -0
  152. package/server/lib/vps/backup-manager.js +157 -0
  153. package/server/lib/vps/backup-manager.test.js +59 -0
  154. package/server/lib/vps/caddy-config.js +159 -0
  155. package/server/lib/vps/caddy-config.test.js +48 -0
  156. package/server/lib/vps/compose-orchestrator.js +219 -0
  157. package/server/lib/vps/compose-orchestrator.test.js +50 -0
  158. package/server/lib/vps/database-config.js +208 -0
  159. package/server/lib/vps/database-config.test.js +47 -0
  160. package/server/lib/vps/deploy-script.js +211 -0
  161. package/server/lib/vps/deploy-script.test.js +53 -0
  162. package/server/lib/vps/secrets-manager.js +148 -0
  163. package/server/lib/vps/secrets-manager.test.js +58 -0
  164. package/server/lib/vps/server-hardening.js +174 -0
  165. package/server/lib/vps/server-hardening.test.js +70 -0
  166. package/server/package-lock.json +19 -0
  167. package/server/package.json +1 -0
  168. package/server/templates/CLAUDE.md +37 -0
  169. package/server/templates/CODING-STANDARDS.md +408 -0
@@ -0,0 +1,210 @@
1
+ /**
2
+ * TLS Configuration Manager
3
+ * Generates TLS configurations for various server types
4
+ */
5
+
6
+ export const TLS_VERSIONS = {
7
+ TLS_1_2: '1.2',
8
+ TLS_1_3: '1.3',
9
+ };
10
+
11
+ export const CIPHER_SUITES = {
12
+ MODERN: [
13
+ 'TLS_AES_256_GCM_SHA384',
14
+ 'TLS_CHACHA20_POLY1305_SHA256',
15
+ 'TLS_AES_128_GCM_SHA256',
16
+ 'ECDHE-ECDSA-AES256-GCM-SHA384',
17
+ 'ECDHE-RSA-AES256-GCM-SHA384',
18
+ 'ECDHE-ECDSA-CHACHA20-POLY1305',
19
+ 'ECDHE-RSA-CHACHA20-POLY1305',
20
+ 'ECDHE-ECDSA-AES128-GCM-SHA256',
21
+ 'ECDHE-RSA-AES128-GCM-SHA256',
22
+ ],
23
+ COMPATIBLE: [
24
+ 'TLS_AES_256_GCM_SHA384',
25
+ 'TLS_CHACHA20_POLY1305_SHA256',
26
+ 'TLS_AES_128_GCM_SHA256',
27
+ 'ECDHE-ECDSA-AES256-GCM-SHA384',
28
+ 'ECDHE-RSA-AES256-GCM-SHA384',
29
+ 'ECDHE-ECDSA-AES128-GCM-SHA256',
30
+ 'ECDHE-RSA-AES128-GCM-SHA256',
31
+ 'DHE-RSA-AES256-GCM-SHA384',
32
+ 'DHE-RSA-AES128-GCM-SHA256',
33
+ ],
34
+ };
35
+
36
+ /**
37
+ * Generate Caddyfile TLS block
38
+ */
39
+ export function generateCaddyTls(options) {
40
+ const { domain, minVersion, ocspStapling, email } = options;
41
+
42
+ let config = `${domain} {\n`;
43
+ config += ' tls';
44
+
45
+ if (email) {
46
+ config += ` ${email}`;
47
+ }
48
+
49
+ config += ' {\n';
50
+
51
+ if (minVersion === '1.3') {
52
+ config += ' protocols tls1.3\n';
53
+ } else if (minVersion === '1.2') {
54
+ config += ' protocols tls1.2 tls1.3\n';
55
+ }
56
+
57
+ if (ocspStapling) {
58
+ config += ' ocsp_stapling on\n';
59
+ }
60
+
61
+ config += ' }\n';
62
+ config += '}\n';
63
+
64
+ return config;
65
+ }
66
+
67
+ /**
68
+ * Generate Nginx SSL configuration
69
+ */
70
+ export function generateNginxTls(options) {
71
+ const { domain, minVersion, ciphers, ocspStapling } = options;
72
+
73
+ let config = '';
74
+
75
+ // SSL certificate paths
76
+ config += `ssl_certificate /etc/letsencrypt/live/${domain}/fullchain.pem;\n`;
77
+ config += `ssl_certificate_key /etc/letsencrypt/live/${domain}/privkey.pem;\n\n`;
78
+
79
+ // Protocol version
80
+ if (minVersion === '1.3') {
81
+ config += 'ssl_protocols TLSv1.3;\n';
82
+ } else {
83
+ config += 'ssl_protocols TLSv1.2 TLSv1.3;\n';
84
+ }
85
+
86
+ // Cipher configuration
87
+ if (ciphers === 'modern') {
88
+ config +=
89
+ 'ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;\n';
90
+ } else {
91
+ config += 'ssl_ciphers HIGH:!aNULL:!MD5;\n';
92
+ }
93
+
94
+ config += 'ssl_prefer_server_ciphers on;\n\n';
95
+
96
+ // Session settings
97
+ config += 'ssl_session_timeout 1d;\n';
98
+ config += 'ssl_session_cache shared:SSL:50m;\n';
99
+ config += 'ssl_session_tickets off;\n\n';
100
+
101
+ // OCSP stapling
102
+ if (ocspStapling) {
103
+ config += 'ssl_stapling on;\n';
104
+ config += 'ssl_stapling_verify on;\n';
105
+ config += `ssl_trusted_certificate /etc/letsencrypt/live/${domain}/chain.pem;\n`;
106
+ }
107
+
108
+ return config;
109
+ }
110
+
111
+ /**
112
+ * Generate Let's Encrypt / certbot configuration
113
+ */
114
+ export function generateLetsEncryptConfig(options) {
115
+ const { domain, email, wildcard, autoRenew, staging } = options;
116
+
117
+ let config = '# Let\'s Encrypt Certificate Configuration\n\n';
118
+
119
+ config += `domain=${domain}\n`;
120
+ config += `email=${email}\n\n`;
121
+
122
+ config += '# Certbot command:\n';
123
+ config += 'certbot certonly \\\n';
124
+
125
+ if (staging) {
126
+ config += ' --staging \\\n';
127
+ }
128
+
129
+ if (wildcard) {
130
+ config += ' --dns-cloudflare \\\n';
131
+ config += ' --dns-cloudflare-credentials /etc/cloudflare.ini \\\n';
132
+ } else {
133
+ config += ' --webroot \\\n';
134
+ config += ' --webroot-path /var/www/html \\\n';
135
+ }
136
+
137
+ config += ` -d ${domain} \\\n`;
138
+ config += ` --email ${email} \\\n`;
139
+ config += ' --agree-tos \\\n';
140
+ config += ' --non-interactive\n\n';
141
+
142
+ if (autoRenew) {
143
+ config += '# Auto-renew cron job:\n';
144
+ config += '# 0 0 * * * certbot renew --quiet\n';
145
+ }
146
+
147
+ return config;
148
+ }
149
+
150
+ /**
151
+ * Generate CAA DNS record
152
+ */
153
+ export function generateCaaRecord(options) {
154
+ const { domain, ca, wildcard, reportEmail } = options;
155
+
156
+ let record = `; CAA records for ${domain}\n`;
157
+
158
+ // Standard issue record
159
+ record += `${domain}. IN CAA 0 issue "${ca}"\n`;
160
+
161
+ // Wildcard issue record
162
+ if (wildcard) {
163
+ record += `${domain}. IN CAA 0 issuewild "${ca}"\n`;
164
+ }
165
+
166
+ // Incident reporting
167
+ if (reportEmail) {
168
+ record += `${domain}. IN CAA 0 iodef "mailto:${reportEmail}"\n`;
169
+ }
170
+
171
+ return record;
172
+ }
173
+
174
+ /**
175
+ * Generate TLS config for specified server type
176
+ */
177
+ export function generateTlsConfig(options) {
178
+ const { serverType, ...tlsOptions } = options;
179
+
180
+ switch (serverType) {
181
+ case 'caddy':
182
+ return generateCaddyTls(tlsOptions);
183
+ case 'nginx':
184
+ return generateNginxTls(tlsOptions);
185
+ default:
186
+ throw new Error(`Unsupported server type: ${serverType}`);
187
+ }
188
+ }
189
+
190
+ /**
191
+ * Create a TLS configuration manager with default options
192
+ */
193
+ export function createTlsConfigManager(config = {}) {
194
+ const defaults = config.defaults || {};
195
+
196
+ return {
197
+ generateCaddy(options) {
198
+ return generateCaddyTls({ ...defaults, ...options });
199
+ },
200
+ generateNginx(options) {
201
+ return generateNginxTls({ ...defaults, ...options });
202
+ },
203
+ generateLetsEncrypt(options) {
204
+ return generateLetsEncryptConfig({ ...defaults, ...options });
205
+ },
206
+ generateCaa(options) {
207
+ return generateCaaRecord({ ...defaults, ...options });
208
+ },
209
+ };
210
+ }
@@ -0,0 +1,248 @@
1
+ /**
2
+ * TLS Configuration Manager Tests
3
+ */
4
+ import { describe, it, expect } from 'vitest';
5
+ import {
6
+ generateTlsConfig,
7
+ generateCaddyTls,
8
+ generateNginxTls,
9
+ generateLetsEncryptConfig,
10
+ generateCaaRecord,
11
+ TLS_VERSIONS,
12
+ CIPHER_SUITES,
13
+ createTlsConfigManager,
14
+ } from './tls-config.js';
15
+
16
+ describe('tls-config', () => {
17
+ describe('TLS_VERSIONS', () => {
18
+ it('defines TLS version constants', () => {
19
+ expect(TLS_VERSIONS.TLS_1_2).toBe('1.2');
20
+ expect(TLS_VERSIONS.TLS_1_3).toBe('1.3');
21
+ });
22
+ });
23
+
24
+ describe('CIPHER_SUITES', () => {
25
+ it('defines strong cipher suites', () => {
26
+ expect(CIPHER_SUITES.MODERN).toContain('TLS_AES_256_GCM_SHA384');
27
+ expect(CIPHER_SUITES.MODERN).toContain('TLS_CHACHA20_POLY1305_SHA256');
28
+ });
29
+
30
+ it('excludes weak ciphers', () => {
31
+ expect(CIPHER_SUITES.MODERN).not.toContain('RC4');
32
+ expect(CIPHER_SUITES.MODERN).not.toContain('DES');
33
+ expect(CIPHER_SUITES.MODERN).not.toContain('MD5');
34
+ });
35
+ });
36
+
37
+ describe('generateCaddyTls', () => {
38
+ it('generates valid Caddyfile TLS block', () => {
39
+ const config = generateCaddyTls({ domain: 'example.com' });
40
+
41
+ expect(config).toContain('example.com');
42
+ expect(config).toContain('tls');
43
+ });
44
+
45
+ it('enforces TLS 1.3 minimum when specified', () => {
46
+ const config = generateCaddyTls({
47
+ domain: 'example.com',
48
+ minVersion: '1.3',
49
+ });
50
+
51
+ expect(config).toContain('protocols tls1.3');
52
+ });
53
+
54
+ it('configures OCSP stapling', () => {
55
+ const config = generateCaddyTls({
56
+ domain: 'example.com',
57
+ ocspStapling: true,
58
+ });
59
+
60
+ expect(config).toContain('ocsp_stapling');
61
+ });
62
+
63
+ it('configures Let\'s Encrypt email', () => {
64
+ const config = generateCaddyTls({
65
+ domain: 'example.com',
66
+ email: 'admin@example.com',
67
+ });
68
+
69
+ expect(config).toContain('admin@example.com');
70
+ });
71
+ });
72
+
73
+ describe('generateNginxTls', () => {
74
+ it('generates valid Nginx SSL config', () => {
75
+ const config = generateNginxTls({ domain: 'example.com' });
76
+
77
+ expect(config).toContain('ssl_certificate');
78
+ expect(config).toContain('ssl_certificate_key');
79
+ });
80
+
81
+ it('enforces TLS 1.3 only when specified', () => {
82
+ const config = generateNginxTls({
83
+ domain: 'example.com',
84
+ minVersion: '1.3',
85
+ });
86
+
87
+ expect(config).toContain('ssl_protocols TLSv1.3');
88
+ expect(config).not.toContain('TLSv1.2');
89
+ });
90
+
91
+ it('configures strong cipher suites', () => {
92
+ const config = generateNginxTls({
93
+ domain: 'example.com',
94
+ ciphers: 'modern',
95
+ });
96
+
97
+ expect(config).toContain('ssl_ciphers');
98
+ expect(config).toContain('ECDHE');
99
+ });
100
+
101
+ it('enables OCSP stapling', () => {
102
+ const config = generateNginxTls({
103
+ domain: 'example.com',
104
+ ocspStapling: true,
105
+ });
106
+
107
+ expect(config).toContain('ssl_stapling on');
108
+ expect(config).toContain('ssl_stapling_verify on');
109
+ });
110
+
111
+ it('sets session timeout and cache', () => {
112
+ const config = generateNginxTls({ domain: 'example.com' });
113
+
114
+ expect(config).toContain('ssl_session_timeout');
115
+ expect(config).toContain('ssl_session_cache');
116
+ });
117
+ });
118
+
119
+ describe('generateLetsEncryptConfig', () => {
120
+ it('generates certbot config', () => {
121
+ const config = generateLetsEncryptConfig({
122
+ domain: 'example.com',
123
+ email: 'admin@example.com',
124
+ });
125
+
126
+ expect(config).toContain('example.com');
127
+ expect(config).toContain('admin@example.com');
128
+ });
129
+
130
+ it('supports wildcard domains', () => {
131
+ const config = generateLetsEncryptConfig({
132
+ domain: '*.example.com',
133
+ email: 'admin@example.com',
134
+ wildcard: true,
135
+ });
136
+
137
+ expect(config).toContain('*.example.com');
138
+ expect(config).toContain('dns');
139
+ });
140
+
141
+ it('configures auto-renewal', () => {
142
+ const config = generateLetsEncryptConfig({
143
+ domain: 'example.com',
144
+ email: 'admin@example.com',
145
+ autoRenew: true,
146
+ });
147
+
148
+ expect(config).toContain('renew');
149
+ });
150
+
151
+ it('supports staging environment', () => {
152
+ const config = generateLetsEncryptConfig({
153
+ domain: 'example.com',
154
+ email: 'admin@example.com',
155
+ staging: true,
156
+ });
157
+
158
+ expect(config).toContain('staging');
159
+ });
160
+ });
161
+
162
+ describe('generateCaaRecord', () => {
163
+ it('generates CAA record for Let\'s Encrypt', () => {
164
+ const record = generateCaaRecord({
165
+ domain: 'example.com',
166
+ ca: 'letsencrypt.org',
167
+ });
168
+
169
+ expect(record).toContain('CAA');
170
+ expect(record).toContain('letsencrypt.org');
171
+ expect(record).toContain('issue');
172
+ });
173
+
174
+ it('supports issuewild for wildcards', () => {
175
+ const record = generateCaaRecord({
176
+ domain: 'example.com',
177
+ ca: 'letsencrypt.org',
178
+ wildcard: true,
179
+ });
180
+
181
+ expect(record).toContain('issuewild');
182
+ });
183
+
184
+ it('adds iodef for reporting', () => {
185
+ const record = generateCaaRecord({
186
+ domain: 'example.com',
187
+ ca: 'letsencrypt.org',
188
+ reportEmail: 'security@example.com',
189
+ });
190
+
191
+ expect(record).toContain('iodef');
192
+ expect(record).toContain('security@example.com');
193
+ });
194
+ });
195
+
196
+ describe('generateTlsConfig', () => {
197
+ it('generates config for specified server type', () => {
198
+ const caddyConfig = generateTlsConfig({
199
+ serverType: 'caddy',
200
+ domain: 'example.com',
201
+ });
202
+ expect(caddyConfig).toContain('tls');
203
+
204
+ const nginxConfig = generateTlsConfig({
205
+ serverType: 'nginx',
206
+ domain: 'example.com',
207
+ });
208
+ expect(nginxConfig).toContain('ssl_');
209
+ });
210
+
211
+ it('includes all security options', () => {
212
+ const config = generateTlsConfig({
213
+ serverType: 'nginx',
214
+ domain: 'example.com',
215
+ minVersion: '1.3',
216
+ ocspStapling: true,
217
+ hsts: true,
218
+ });
219
+
220
+ expect(config).toContain('TLSv1.3');
221
+ expect(config).toContain('ssl_stapling');
222
+ });
223
+ });
224
+
225
+ describe('createTlsConfigManager', () => {
226
+ it('creates manager with methods', () => {
227
+ const manager = createTlsConfigManager();
228
+
229
+ expect(manager.generateCaddy).toBeDefined();
230
+ expect(manager.generateNginx).toBeDefined();
231
+ expect(manager.generateLetsEncrypt).toBeDefined();
232
+ expect(manager.generateCaa).toBeDefined();
233
+ });
234
+
235
+ it('uses default options from config', () => {
236
+ const manager = createTlsConfigManager({
237
+ defaults: {
238
+ minVersion: '1.3',
239
+ ocspStapling: true,
240
+ },
241
+ });
242
+
243
+ const config = manager.generateNginx({ domain: 'example.com' });
244
+ expect(config).toContain('TLSv1.3');
245
+ expect(config).toContain('ssl_stapling');
246
+ });
247
+ });
248
+ });