@bernierllc/email-domain-verification 1.0.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.
Files changed (36) hide show
  1. package/.eslintrc.cjs +29 -0
  2. package/README.md +397 -0
  3. package/__mocks__/@bernierllc/crypto-utils.ts +15 -0
  4. package/__mocks__/@bernierllc/logger.ts +42 -0
  5. package/__mocks__/@bernierllc/neverhub-adapter.ts +17 -0
  6. package/__tests__/EmailDomainVerificationService.test.ts +582 -0
  7. package/coverage/clover.xml +263 -0
  8. package/coverage/coverage-final.json +3 -0
  9. package/coverage/lcov-report/EmailDomainVerificationService.ts.html +3061 -0
  10. package/coverage/lcov-report/base.css +224 -0
  11. package/coverage/lcov-report/block-navigation.js +87 -0
  12. package/coverage/lcov-report/errors.ts.html +322 -0
  13. package/coverage/lcov-report/favicon.png +0 -0
  14. package/coverage/lcov-report/index.html +131 -0
  15. package/coverage/lcov-report/prettify.css +1 -0
  16. package/coverage/lcov-report/prettify.js +2 -0
  17. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  18. package/coverage/lcov-report/sorter.js +210 -0
  19. package/coverage/lcov.info +485 -0
  20. package/dist/EmailDomainVerificationService.d.ts +179 -0
  21. package/dist/EmailDomainVerificationService.js +822 -0
  22. package/dist/errors.d.ts +39 -0
  23. package/dist/errors.js +66 -0
  24. package/dist/index.d.ts +3 -0
  25. package/dist/index.js +28 -0
  26. package/dist/types.d.ts +209 -0
  27. package/dist/types.js +9 -0
  28. package/jest.config.cjs +44 -0
  29. package/jest.setup.js +19 -0
  30. package/package.json +72 -0
  31. package/src/EmailDomainVerificationService.ts +992 -0
  32. package/src/dns2.d.ts +29 -0
  33. package/src/errors.ts +79 -0
  34. package/src/index.ts +11 -0
  35. package/src/types.ts +281 -0
  36. package/tsconfig.json +30 -0
@@ -0,0 +1,485 @@
1
+ TN:
2
+ SF:src/EmailDomainVerificationService.ts
3
+ FN:42,(anonymous_1)
4
+ FN:63,(anonymous_2)
5
+ FN:80,(anonymous_3)
6
+ FN:153,(anonymous_4)
7
+ FN:201,(anonymous_5)
8
+ FN:206,(anonymous_6)
9
+ FN:220,(anonymous_7)
10
+ FN:281,(anonymous_8)
11
+ FN:302,(anonymous_9)
12
+ FN:314,(anonymous_10)
13
+ FN:323,(anonymous_11)
14
+ FN:353,(anonymous_12)
15
+ FN:370,(anonymous_13)
16
+ FN:389,(anonymous_14)
17
+ FN:412,(anonymous_15)
18
+ FN:429,(anonymous_16)
19
+ FN:433,(anonymous_17)
20
+ FN:437,(anonymous_18)
21
+ FN:457,(anonymous_19)
22
+ FN:488,(anonymous_20)
23
+ FN:504,(anonymous_21)
24
+ FN:525,(anonymous_22)
25
+ FN:545,(anonymous_23)
26
+ FN:565,(anonymous_24)
27
+ FN:613,(anonymous_25)
28
+ FN:632,(anonymous_26)
29
+ FN:670,(anonymous_27)
30
+ FN:706,(anonymous_28)
31
+ FN:724,(anonymous_29)
32
+ FN:744,(anonymous_30)
33
+ FN:759,(anonymous_31)
34
+ FN:790,(anonymous_32)
35
+ FN:820,(anonymous_33)
36
+ FN:836,(anonymous_34)
37
+ FN:848,(anonymous_35)
38
+ FN:849,(anonymous_36)
39
+ FN:862,(anonymous_37)
40
+ FN:867,(anonymous_38)
41
+ FN:879,(anonymous_39)
42
+ FN:879,(anonymous_40)
43
+ FN:886,(anonymous_41)
44
+ FN:891,(anonymous_42)
45
+ FN:892,(anonymous_43)
46
+ FN:909,(anonymous_44)
47
+ FN:920,(anonymous_45)
48
+ FN:940,(anonymous_46)
49
+ FN:961,(anonymous_47)
50
+ FN:982,(anonymous_48)
51
+ FNF:48
52
+ FNH:38
53
+ FNDA:29,(anonymous_1)
54
+ FNDA:0,(anonymous_2)
55
+ FNDA:23,(anonymous_3)
56
+ FNDA:3,(anonymous_4)
57
+ FNDA:4,(anonymous_5)
58
+ FNDA:4,(anonymous_6)
59
+ FNDA:8,(anonymous_7)
60
+ FNDA:1,(anonymous_8)
61
+ FNDA:3,(anonymous_9)
62
+ FNDA:7,(anonymous_10)
63
+ FNDA:0,(anonymous_11)
64
+ FNDA:8,(anonymous_12)
65
+ FNDA:0,(anonymous_13)
66
+ FNDA:22,(anonymous_14)
67
+ FNDA:17,(anonymous_15)
68
+ FNDA:18,(anonymous_16)
69
+ FNDA:1,(anonymous_17)
70
+ FNDA:1,(anonymous_18)
71
+ FNDA:1,(anonymous_19)
72
+ FNDA:22,(anonymous_20)
73
+ FNDA:20,(anonymous_21)
74
+ FNDA:1,(anonymous_22)
75
+ FNDA:1,(anonymous_23)
76
+ FNDA:1,(anonymous_24)
77
+ FNDA:22,(anonymous_25)
78
+ FNDA:20,(anonymous_26)
79
+ FNDA:1,(anonymous_27)
80
+ FNDA:1,(anonymous_28)
81
+ FNDA:0,(anonymous_29)
82
+ FNDA:0,(anonymous_30)
83
+ FNDA:0,(anonymous_31)
84
+ FNDA:0,(anonymous_32)
85
+ FNDA:0,(anonymous_33)
86
+ FNDA:4,(anonymous_34)
87
+ FNDA:8,(anonymous_35)
88
+ FNDA:4,(anonymous_36)
89
+ FNDA:4,(anonymous_37)
90
+ FNDA:4,(anonymous_38)
91
+ FNDA:4,(anonymous_39)
92
+ FNDA:0,(anonymous_40)
93
+ FNDA:4,(anonymous_41)
94
+ FNDA:8,(anonymous_42)
95
+ FNDA:4,(anonymous_43)
96
+ FNDA:23,(anonymous_44)
97
+ FNDA:30,(anonymous_45)
98
+ FNDA:0,(anonymous_46)
99
+ FNDA:33,(anonymous_47)
100
+ FNDA:28,(anonymous_48)
101
+ DA:9,1
102
+ DA:10,1
103
+ DA:11,1
104
+ DA:12,1
105
+ DA:13,1
106
+ DA:14,1
107
+ DA:15,1
108
+ DA:27,1
109
+ DA:35,1
110
+ DA:47,29
111
+ DA:51,29
112
+ DA:52,29
113
+ DA:56,29
114
+ DA:57,29
115
+ DA:64,0
116
+ DA:65,0
117
+ DA:66,0
118
+ DA:69,0
119
+ DA:81,23
120
+ DA:86,23
121
+ DA:88,23
122
+ DA:91,22
123
+ DA:95,22
124
+ DA:96,1
125
+ DA:97,1
126
+ DA:101,22
127
+ DA:104,22
128
+ DA:111,22
129
+ DA:117,22
130
+ DA:133,1
131
+ DA:134,1
132
+ DA:136,1
133
+ DA:157,3
134
+ DA:162,3
135
+ DA:164,3
136
+ DA:165,4
137
+ DA:166,4
138
+ DA:167,4
139
+ DA:169,4
140
+ DA:170,2
141
+ DA:176,2
142
+ DA:184,0
143
+ DA:185,0
144
+ DA:187,0
145
+ DA:201,4
146
+ DA:202,3
147
+ DA:206,4
148
+ DA:209,3
149
+ DA:225,8
150
+ DA:227,8
151
+ DA:228,8
152
+ DA:230,8
153
+ DA:231,8
154
+ DA:233,8
155
+ DA:240,8
156
+ DA:248,8
157
+ DA:249,7
158
+ DA:252,8
159
+ DA:253,8
160
+ DA:262,0
161
+ DA:263,0
162
+ DA:265,0
163
+ DA:282,1
164
+ DA:286,1
165
+ DA:303,3
166
+ DA:304,3
167
+ DA:320,7
168
+ DA:323,7
169
+ DA:324,0
170
+ DA:325,0
171
+ DA:327,0
172
+ DA:328,0
173
+ DA:330,0
174
+ DA:337,0
175
+ DA:338,0
176
+ DA:342,7
177
+ DA:343,7
178
+ DA:345,7
179
+ DA:354,8
180
+ DA:355,8
181
+ DA:356,1
182
+ DA:357,1
183
+ DA:358,1
184
+ DA:377,0
185
+ DA:390,22
186
+ DA:393,22
187
+ DA:394,17
188
+ DA:398,22
189
+ DA:399,1
190
+ DA:403,22
191
+ DA:404,22
192
+ DA:406,22
193
+ DA:413,17
194
+ DA:414,17
195
+ DA:415,17
196
+ DA:416,17
197
+ DA:418,17
198
+ DA:421,17
199
+ DA:422,17
200
+ DA:423,0
201
+ DA:424,0
202
+ DA:425,0
203
+ DA:426,0
204
+ DA:429,17
205
+ DA:430,18
206
+ DA:433,17
207
+ DA:434,1
208
+ DA:437,17
209
+ DA:438,1
210
+ DA:441,17
211
+ DA:443,17
212
+ DA:458,1
213
+ DA:459,1
214
+ DA:460,1
215
+ DA:461,1
216
+ DA:462,1
217
+ DA:464,1
218
+ DA:466,1
219
+ DA:467,1
220
+ DA:470,1
221
+ DA:471,0
222
+ DA:474,1
223
+ DA:489,22
224
+ DA:491,20
225
+ DA:493,1
226
+ DA:495,1
227
+ DA:497,0
228
+ DA:505,20
229
+ DA:509,20
230
+ DA:519,20
231
+ DA:526,1
232
+ DA:529,1
233
+ DA:539,1
234
+ DA:546,1
235
+ DA:549,1
236
+ DA:559,1
237
+ DA:566,1
238
+ DA:567,1
239
+ DA:570,1
240
+ DA:583,1
241
+ DA:589,1
242
+ DA:591,1
243
+ DA:601,1
244
+ DA:617,22
245
+ DA:619,20
246
+ DA:621,1
247
+ DA:623,1
248
+ DA:625,0
249
+ DA:635,20
250
+ DA:636,20
251
+ DA:654,20
252
+ DA:661,0
253
+ DA:662,0
254
+ DA:663,0
255
+ DA:673,1
256
+ DA:674,1
257
+ DA:690,1
258
+ DA:697,0
259
+ DA:698,0
260
+ DA:699,0
261
+ DA:711,1
262
+ DA:715,1
263
+ DA:729,0
264
+ DA:731,0
265
+ DA:733,0
266
+ DA:735,0
267
+ DA:737,0
268
+ DA:748,0
269
+ DA:750,0
270
+ DA:759,0
271
+ DA:760,0
272
+ DA:761,0
273
+ DA:765,0
274
+ DA:775,0
275
+ DA:781,0
276
+ DA:782,0
277
+ DA:783,0
278
+ DA:794,0
279
+ DA:795,0
280
+ DA:805,0
281
+ DA:811,0
282
+ DA:812,0
283
+ DA:813,0
284
+ DA:825,0
285
+ DA:827,0
286
+ DA:840,4
287
+ DA:841,4
288
+ DA:843,4
289
+ DA:844,4
290
+ DA:845,4
291
+ DA:846,4
292
+ DA:847,4
293
+ DA:848,8
294
+ DA:849,4
295
+ DA:852,4
296
+ DA:854,0
297
+ DA:861,4
298
+ DA:862,4
299
+ DA:865,4
300
+ DA:866,4
301
+ DA:867,4
302
+ DA:868,4
303
+ DA:870,4
304
+ DA:879,4
305
+ DA:887,4
306
+ DA:888,4
307
+ DA:889,4
308
+ DA:890,4
309
+ DA:891,8
310
+ DA:892,4
311
+ DA:894,0
312
+ DA:895,0
313
+ DA:898,0
314
+ DA:910,23
315
+ DA:912,23
316
+ DA:913,1
317
+ DA:924,30
318
+ DA:926,30
319
+ DA:927,30
320
+ DA:934,30
321
+ DA:941,0
322
+ DA:943,0
323
+ DA:955,0
324
+ DA:962,33
325
+ DA:964,2
326
+ DA:965,2
327
+ DA:972,0
328
+ DA:984,28
329
+ DA:985,6
330
+ DA:986,6
331
+ DA:989,28
332
+ DA:990,28
333
+ LF:232
334
+ LH:170
335
+ BRDA:47,0,0,29
336
+ BRDA:47,0,1,0
337
+ BRDA:64,1,0,0
338
+ BRDA:95,2,0,1
339
+ BRDA:133,3,0,1
340
+ BRDA:133,3,1,0
341
+ BRDA:141,4,0,1
342
+ BRDA:141,4,1,0
343
+ BRDA:169,5,0,2
344
+ BRDA:169,5,1,2
345
+ BRDA:169,6,0,4
346
+ BRDA:169,6,1,2
347
+ BRDA:184,7,0,0
348
+ BRDA:184,7,1,0
349
+ BRDA:195,8,0,0
350
+ BRDA:195,8,1,0
351
+ BRDA:230,9,0,7
352
+ BRDA:230,9,1,1
353
+ BRDA:231,10,0,8
354
+ BRDA:231,10,1,0
355
+ BRDA:234,11,0,7
356
+ BRDA:234,11,1,1
357
+ BRDA:248,12,0,7
358
+ BRDA:252,13,0,8
359
+ BRDA:252,13,1,0
360
+ BRDA:259,14,0,1
361
+ BRDA:259,14,1,7
362
+ BRDA:262,15,0,0
363
+ BRDA:262,15,1,0
364
+ BRDA:270,16,0,0
365
+ BRDA:270,16,1,0
366
+ BRDA:302,17,0,2
367
+ BRDA:303,18,0,3
368
+ BRDA:303,18,1,1
369
+ BRDA:327,19,0,0
370
+ BRDA:337,20,0,0
371
+ BRDA:337,20,1,0
372
+ BRDA:355,21,0,1
373
+ BRDA:393,22,0,17
374
+ BRDA:398,23,0,1
375
+ BRDA:413,24,0,17
376
+ BRDA:413,24,1,16
377
+ BRDA:414,25,0,17
378
+ BRDA:414,25,1,16
379
+ BRDA:415,26,0,17
380
+ BRDA:415,26,1,16
381
+ BRDA:421,27,0,17
382
+ BRDA:421,27,1,0
383
+ BRDA:423,28,0,0
384
+ BRDA:423,28,1,0
385
+ BRDA:425,29,0,0
386
+ BRDA:441,30,0,16
387
+ BRDA:441,30,1,1
388
+ BRDA:458,31,0,1
389
+ BRDA:458,31,1,0
390
+ BRDA:459,32,0,1
391
+ BRDA:459,32,1,0
392
+ BRDA:462,33,0,1
393
+ BRDA:462,33,1,1
394
+ BRDA:466,34,0,1
395
+ BRDA:470,35,0,0
396
+ BRDA:489,36,0,20
397
+ BRDA:489,36,1,1
398
+ BRDA:489,36,2,1
399
+ BRDA:489,36,3,0
400
+ BRDA:566,37,0,1
401
+ BRDA:566,37,1,0
402
+ BRDA:567,38,0,1
403
+ BRDA:567,38,1,0
404
+ BRDA:617,39,0,20
405
+ BRDA:617,39,1,1
406
+ BRDA:617,39,2,1
407
+ BRDA:617,39,3,0
408
+ BRDA:661,40,0,0
409
+ BRDA:661,40,1,0
410
+ BRDA:678,41,0,1
411
+ BRDA:678,41,1,1
412
+ BRDA:697,42,0,0
413
+ BRDA:697,42,1,0
414
+ BRDA:729,43,0,0
415
+ BRDA:729,43,1,0
416
+ BRDA:729,43,2,0
417
+ BRDA:729,43,3,0
418
+ BRDA:760,44,0,0
419
+ BRDA:778,45,0,0
420
+ BRDA:778,45,1,0
421
+ BRDA:781,46,0,0
422
+ BRDA:781,46,1,0
423
+ BRDA:808,47,0,0
424
+ BRDA:808,47,1,0
425
+ BRDA:811,48,0,0
426
+ BRDA:811,48,1,0
427
+ BRDA:856,49,0,0
428
+ BRDA:856,49,1,0
429
+ BRDA:862,50,0,4
430
+ BRDA:862,50,1,4
431
+ BRDA:868,51,0,4
432
+ BRDA:868,51,1,2
433
+ BRDA:894,52,0,0
434
+ BRDA:894,52,1,0
435
+ BRDA:912,53,0,1
436
+ BRDA:924,54,0,30
437
+ BRDA:924,54,1,21
438
+ BRDA:941,55,0,0
439
+ BRDA:962,56,0,31
440
+ BRDA:974,57,0,0
441
+ BRDA:974,57,1,0
442
+ BRF:107
443
+ BRH:55
444
+ end_of_record
445
+ TN:
446
+ SF:src/errors.ts
447
+ FN:13,(anonymous_0)
448
+ FN:25,(anonymous_1)
449
+ FN:32,(anonymous_2)
450
+ FN:39,(anonymous_3)
451
+ FN:62,successResult
452
+ FN:69,errorResult
453
+ FNF:6
454
+ FNH:2
455
+ FNDA:1,(anonymous_0)
456
+ FNDA:0,(anonymous_1)
457
+ FNDA:0,(anonymous_2)
458
+ FNDA:1,(anonymous_3)
459
+ FNDA:0,successResult
460
+ FNDA:0,errorResult
461
+ DA:12,1
462
+ DA:15,1
463
+ DA:16,1
464
+ DA:17,1
465
+ DA:19,1
466
+ DA:20,1
467
+ DA:24,1
468
+ DA:26,0
469
+ DA:27,0
470
+ DA:31,1
471
+ DA:33,0
472
+ DA:34,0
473
+ DA:38,1
474
+ DA:40,1
475
+ DA:41,1
476
+ DA:62,1
477
+ DA:63,0
478
+ DA:69,1
479
+ DA:70,0
480
+ LF:19
481
+ LH:13
482
+ BRDA:16,0,0,0
483
+ BRF:1
484
+ BRH:0
485
+ end_of_record
@@ -0,0 +1,179 @@
1
+ import { Logger } from '@bernierllc/logger';
2
+ import { NeverHubAdapter } from '@bernierllc/neverhub-adapter';
3
+ import { DomainConfig, DomainVerificationResult, DNSPropagationResult, DomainHealthStatus, VerificationHistoryEntry, DNSRecord, EmailProvider } from './types';
4
+ /**
5
+ * Email Domain Verification Service
6
+ *
7
+ * Manages domain verification for email service providers including
8
+ * DNS record generation, propagation monitoring, and health checks.
9
+ */
10
+ export declare class EmailDomainVerificationService {
11
+ private logger;
12
+ private neverhub?;
13
+ private httpClient;
14
+ private healthCheckJobs;
15
+ private verificationHistory;
16
+ constructor(config?: {
17
+ logger?: Logger;
18
+ neverhub?: NeverHubAdapter;
19
+ healthCheckInterval?: string;
20
+ });
21
+ /**
22
+ * Initialize service with NeverHub registration
23
+ */
24
+ initialize(): Promise<void>;
25
+ /**
26
+ * Setup domain verification for a provider
27
+ *
28
+ * @param config - Domain configuration
29
+ * @returns Verification result with DNS records to configure
30
+ */
31
+ setupDomain(config: DomainConfig): Promise<DomainVerificationResult>;
32
+ /**
33
+ * Check DNS propagation status for domain records
34
+ *
35
+ * @param domain - Domain name
36
+ * @param records - DNS records to check
37
+ * @returns Propagation results for each record
38
+ */
39
+ checkPropagation(domain: string, records: DNSRecord[]): Promise<DNSPropagationResult[]>;
40
+ /**
41
+ * Verify domain with email provider
42
+ *
43
+ * @param domain - Domain name
44
+ * @param provider - Email provider
45
+ * @param providerCredentials - Provider API credentials
46
+ * @returns Verification result
47
+ */
48
+ verifyDomain(domain: string, provider: EmailProvider, providerCredentials: Record<string, unknown>): Promise<DomainVerificationResult>;
49
+ /**
50
+ * Get domain health status
51
+ *
52
+ * @param domain - Domain name
53
+ * @returns Health status
54
+ */
55
+ getDomainHealth(domain: string): Promise<DomainHealthStatus>;
56
+ /**
57
+ * Get verification history for domain
58
+ *
59
+ * @param domain - Domain name
60
+ * @param limit - Maximum number of entries to return
61
+ * @returns History entries
62
+ */
63
+ getVerificationHistory(domain: string, limit?: number): VerificationHistoryEntry[];
64
+ /**
65
+ * Start automated health monitoring for domain
66
+ *
67
+ * @param domain - Domain name
68
+ * @param provider - Email provider
69
+ * @param credentials - Provider credentials
70
+ */
71
+ private startHealthMonitoring;
72
+ /**
73
+ * Stop health monitoring for domain
74
+ *
75
+ * @param domain - Domain name
76
+ */
77
+ stopHealthMonitoring(domain: string): void;
78
+ /**
79
+ * Perform health check for domain
80
+ *
81
+ * @param domain - Domain name
82
+ * @param provider - Email provider
83
+ * @param credentials - Provider credentials
84
+ * @returns Health status
85
+ */
86
+ private performHealthCheck;
87
+ /**
88
+ * Generate DNS records for domain configuration
89
+ */
90
+ private generateDNSRecords;
91
+ /**
92
+ * Generate SPF DNS record
93
+ */
94
+ private generateSPFRecord;
95
+ /**
96
+ * Generate DMARC DNS record
97
+ */
98
+ private generateDMARCRecord;
99
+ /**
100
+ * Generate provider-specific DNS records
101
+ */
102
+ private generateProviderRecords;
103
+ /**
104
+ * Generate SendGrid-specific DNS records
105
+ */
106
+ private generateSendGridRecords;
107
+ /**
108
+ * Generate Mailgun-specific DNS records
109
+ */
110
+ private generateMailgunRecords;
111
+ /**
112
+ * Generate AWS SES-specific DNS records
113
+ */
114
+ private generateSESRecords;
115
+ /**
116
+ * Generate DKIM configuration with keypair
117
+ */
118
+ private generateDKIMConfig;
119
+ /**
120
+ * Register domain with email provider
121
+ */
122
+ private registerWithProvider;
123
+ /**
124
+ * Register domain with SendGrid
125
+ */
126
+ private registerWithSendGrid;
127
+ /**
128
+ * Register domain with Mailgun
129
+ */
130
+ private registerWithMailgun;
131
+ /**
132
+ * Register domain with AWS SES
133
+ */
134
+ private registerWithSES;
135
+ /**
136
+ * Verify domain with email provider
137
+ */
138
+ private verifyWithProvider;
139
+ /**
140
+ * Verify domain with SendGrid
141
+ */
142
+ private verifyWithSendGrid;
143
+ /**
144
+ * Verify domain with Mailgun
145
+ */
146
+ private verifyWithMailgun;
147
+ /**
148
+ * Verify domain with AWS SES
149
+ */
150
+ private verifyWithSES;
151
+ /**
152
+ * Check propagation for single DNS record
153
+ */
154
+ private checkRecordPropagation;
155
+ /**
156
+ * Get nameservers for domain
157
+ */
158
+ private getNameservers;
159
+ /**
160
+ * Validate domain name format
161
+ */
162
+ private validateDomain;
163
+ /**
164
+ * Add entry to verification history
165
+ */
166
+ private addHistoryEntry;
167
+ /**
168
+ * Register with NeverHub
169
+ */
170
+ private registerWithNeverHub;
171
+ /**
172
+ * Publish event to NeverHub
173
+ */
174
+ private publishEvent;
175
+ /**
176
+ * Cleanup resources
177
+ */
178
+ shutdown(): Promise<void>;
179
+ }