@social-mail/social-mail-web-server 1.4.989 → 1.4.992

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@social-mail/social-mail-web-server",
3
- "version": "1.4.989",
3
+ "version": "1.4.992",
4
4
  "description": "## Phase 1",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -0,0 +1,12 @@
1
+ export default class StringFormat {
2
+
3
+ static fixed(n: number, max = 2) {
4
+ const t = n.toString();
5
+ const pad = max - t.length;
6
+ if (pad > 0) {
7
+ return t.padStart(pad, "0");
8
+ }
9
+ return t;
10
+ }
11
+
12
+ }
@@ -27,7 +27,7 @@ export const globalEnv = {
27
27
  externalLogin: process.env.SOCIAL_MAIL_EXTERNAL_LOGIN,
28
28
  dns: {
29
29
  enabled: /^(true|yes)$/i.test(process.env.SOCIAL_MAIL_DNS_ENABLED),
30
- soa: process.env.SOCIAL_MAIL_DNS_SOA || "somewhere somewhere.com",
30
+ soa: (process.env.SOCIAL_MAIL_DNS_SOA || "admin.socialmail.in somewhere.com").split(/[\s\,\;]/g).map((txt: string) => txt.endsWith(".") ? txt : txt + "."),
31
31
  letsEncryptPrefix: process.env.SOCIAL_MAIL_DNS_LE_PREFIX
32
32
  },
33
33
  altHosts: (process.env.SOCIAL_MAIL_ALT_HOSTS || "").split(","),
@@ -40,91 +40,8 @@ export default class HostedZoneEvents extends AuthenticatedEvents<HostedZone> {
40
40
  }
41
41
 
42
42
  async afterInsert(entity: HostedZone, entry: ChangeEntry<HostedZone>) {
43
-
44
-
45
- await entry.loadNavigationAsync((x) => x.domain);
46
-
47
- const { zoneID, domain: { name: domain } } = entity;
48
-
49
- const dateCreated = DateTime.now;
50
- const dateUpdated = dateCreated;
51
-
52
- // add some default records...
53
- const db = ServiceProvider.resolve(this, SocialMailContext);
54
-
55
- const ttl = 8600;
56
-
57
- await db.hostedZoneRecords.statements.insert({
58
- zoneID,
59
- dateCreated,
60
- dateUpdated,
61
- ttl,
62
- name: "@",
63
- type: "SOA",
64
- value: globalEnv.dns.soa,
65
- readonly: true,
66
- });
67
-
68
- await db.hostedZoneRecords.statements.insert({
69
- zoneID,
70
- dateCreated,
71
- dateUpdated,
72
- ttl,
73
- name: "_acme-challenge",
74
- type: "CNAME",
75
- value: `${domain}.${globalEnv.dns.letsEncryptPrefix}`,
76
- readonly: true,
77
- });
78
-
79
- await db.hostedZoneRecords.statements.insert({
80
- zoneID,
81
- dateCreated,
82
- dateUpdated,
83
- ttl,
84
- name: "_dmarc",
85
- type: "TXT",
86
- value: `v=DMARC1; p=reject; rua=mailto:no-reply@${domain};`,
87
- readonly: true,
88
- });
89
-
90
- await db.hostedZoneRecords.statements.insert({
91
- zoneID,
92
- dateCreated,
93
- dateUpdated,
94
- ttl,
95
- type: "A",
96
- name: "@",
97
- value: "$IP$",
98
- fqdn: `${domain}`,
99
- readonly: true
100
- });
101
-
102
- await db.hostedZoneRecords.statements.insert({
103
- zoneID,
104
- dateCreated,
105
- dateUpdated,
106
- ttl,
107
- type: "CNAME",
108
- name: "www",
109
- value: "$HOST$",
110
- fqdn: `www.${domain}`,
111
- readonly: true
112
- });
113
-
114
- await db.hostedZoneRecords.statements.insert({
115
- zoneID,
116
- dateCreated,
117
- dateUpdated,
118
- ttl,
119
- type: "CNAME",
120
- name: "*",
121
- value: "$HOST$",
122
- fqdn: `*.${domain}`,
123
- readonly: true
124
- });
125
-
126
43
  const wc = ServiceProvider.resolve(this, WorkflowContext);
127
- await SyncDnsZoneRecordsWorkflow.enqueue(wc, zoneID);
44
+ await SyncDnsZoneRecordsWorkflow.enqueue(wc, entity.zoneID);
128
45
  }
129
46
 
130
47
  }
@@ -7,6 +7,10 @@ import EmailAddressService from "../../services/EmailAddressService.js";
7
7
  import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
8
8
  import { globalEnv } from "../../../common/globalEnv.js";
9
9
  import GlobalEvents from "../../../common/GlobalEvents.js";
10
+ import StringFormat from "../../../common/StringFormat.js";
11
+
12
+ const toUnixDateAndHour = (date: Date | DateTime, d = DateTime.from(date)) =>
13
+ `${StringFormat.fixed(d.year, 4)}${StringFormat.fixed(d.month)}${StringFormat.fixed(d.day)}${StringFormat.fixed(d.hour)}`;
10
14
 
11
15
  export default class SyncDnsZoneRecordsWorkflow extends Workflow {
12
16
 
@@ -67,10 +71,17 @@ export default class SyncDnsZoneRecordsWorkflow extends Workflow {
67
71
  ttl,
68
72
  name: "@",
69
73
  type: "SOA",
70
- value: globalEnv.dns.soa,
74
+ value: globalEnv.dns.soa.join(" ") + `(
75
+ ${toUnixDateAndHour(dateCreated)}
76
+ 28000
77
+ 7200
78
+ 604800
79
+ 600
80
+ )`,
71
81
  readonly: true,
72
82
  });
73
83
 
84
+
74
85
  await db.hostedZoneRecords.statements.insert({
75
86
  zoneID,
76
87
  dateCreated,