@social-mail/social-mail-web-server 1.4.974 → 1.4.976

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.974",
3
+ "version": "1.4.976",
4
4
  "description": "## Phase 1",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -24,7 +24,11 @@ export const globalEnv = {
24
24
  cdn: process.env.SOCIAL_MAIL_CDN,
25
25
  path: process.env.SOCIAL_MAIL_PATH || "/",
26
26
  externalLogin: process.env.SOCIAL_MAIL_EXTERNAL_LOGIN,
27
- dnsEnabled: /^(true|yes)$/i.test(process.env.SOCIAL_MAIL_DNS_ENABLED),
27
+ dns: {
28
+ enabled: /^(true|yes)$/i.test(process.env.SOCIAL_MAIL_DNS_ENABLED),
29
+ soa: process.env.SOCIAL_MAIL_DNS_SOA || "somewhere somewhere.com",
30
+ letsEncryptPrefix: process.env.SOCIAL_MAIL_DNS_LE_PREFIX
31
+ },
28
32
  altHosts: (process.env.SOCIAL_MAIL_ALT_HOSTS || "").split(","),
29
33
  wildcardDomain: process.env.SOCIAL_MAIL_WILDCARD_DOMAIN,
30
34
  name: process.env.SOCIAL_MAIL_NAME || "Social Mail",
@@ -72,6 +72,9 @@ export class HostedZoneRecord {
72
72
  @Column({ dataType: "Boolean", default: () => false})
73
73
  public disabled: boolean;
74
74
 
75
+ @Column({ dataType: "Boolean", default: () => false})
76
+ public readonly: boolean;
77
+
75
78
  @Column({ dataType: "Char", length: 200})
76
79
  public name: string;
77
80
 
@@ -97,12 +100,12 @@ export class HostedZoneRecord {
97
100
  @Column({ dataType: "Char", nullable: true})
98
101
  public notes: string;
99
102
 
100
- @Column({ dataType: "Char", nullable: true})
101
- public signature: string;
102
-
103
103
  @Column({ nullable: true })
104
104
  public expiryDate: DateTime;
105
105
 
106
+ @Column({ dataType: "Boolean", default: () => false})
107
+ public hosted: boolean;
108
+
106
109
  @Column({ nullable: true})
107
110
  @ReadOnlyJsonProperty
108
111
  public fqdn: string;
@@ -5,6 +5,8 @@ import ChangeEntry from "@entity-access/entity-access/dist/model/changes/ChangeE
5
5
  import { ServiceProvider } from "@entity-access/entity-access/dist/di/di.js";
6
6
  import SocialMailContext from "../SocialMailContext.js";
7
7
  import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
8
+ import DateTime from "@entity-access/entity-access/dist/types/DateTime.js";
9
+ import { globalEnv } from "../../../common/globalEnv.js";
8
10
 
9
11
  export default class HostedZoneEvents extends AuthenticatedEvents<HostedZone> {
10
12
 
@@ -18,6 +20,92 @@ export default class HostedZoneEvents extends AuthenticatedEvents<HostedZone> {
18
20
  return query.where(this.sessionUser, (p) => (x) => x.users.some((u) => u.userID === p.userID));
19
21
  }
20
22
 
23
+ async afterInsert(entity: HostedZone, entry: ChangeEntry<HostedZone>) {
24
+
25
+
26
+ await entry.loadNavigationAsync((x) => x.domain);
27
+
28
+ const { zoneID, domain: { name: domain } } = entity;
29
+
30
+ const dateCreated = DateTime.now;
31
+ const dateUpdated = dateCreated;
32
+
33
+ // add some default records...
34
+ const db = ServiceProvider.resolve(this, SocialMailContext);
35
+
36
+ const ttl = 8600;
37
+
38
+ await db.hostedZoneRecords.statements.insert({
39
+ zoneID,
40
+ dateCreated,
41
+ dateUpdated,
42
+ ttl,
43
+ name: "@",
44
+ type: "SOA",
45
+ value: globalEnv.dns.soa,
46
+ readonly: true,
47
+ });
48
+
49
+ await db.hostedZoneRecords.statements.insert({
50
+ zoneID,
51
+ dateCreated,
52
+ dateUpdated,
53
+ ttl,
54
+ name: "_acme-challenge",
55
+ type: "CNAME",
56
+ value: `${domain}.${globalEnv.dns.letsEncryptPrefix}`,
57
+ readonly: true,
58
+ });
59
+
60
+ await db.hostedZoneRecords.statements.insert({
61
+ zoneID,
62
+ dateCreated,
63
+ dateUpdated,
64
+ ttl,
65
+ name: "_dmarc",
66
+ type: "TXT",
67
+ value: `v=DMARC1; p=reject; rua=mailto:no-reply@${domain};`,
68
+ readonly: true,
69
+ });
70
+
71
+ await db.hostedZoneRecords.statements.insert({
72
+ zoneID,
73
+ dateCreated,
74
+ dateUpdated,
75
+ ttl,
76
+ type: "A",
77
+ name: "@",
78
+ value: "$IP$",
79
+ fqdn: `${domain}`,
80
+ readonly: true
81
+ });
82
+
83
+ await db.hostedZoneRecords.statements.insert({
84
+ zoneID,
85
+ dateCreated,
86
+ dateUpdated,
87
+ ttl,
88
+ type: "CNAME",
89
+ name: "www",
90
+ value: "$HOST$",
91
+ fqdn: `www.${domain}`,
92
+ readonly: true
93
+ });
94
+
95
+ await db.hostedZoneRecords.statements.insert({
96
+ zoneID,
97
+ dateCreated,
98
+ dateUpdated,
99
+ ttl,
100
+ type: "CNAME",
101
+ name: "*",
102
+ value: "$HOST$",
103
+ fqdn: `*.${domain}`,
104
+ readonly: true
105
+ });
106
+
107
+ }
108
+
21
109
  }
22
110
 
23
111
  export class HostedZoneRecordEvents extends AuthenticatedEvents<HostedZoneRecord> {
@@ -32,6 +120,13 @@ export class HostedZoneRecordEvents extends AuthenticatedEvents<HostedZoneRecord
32
120
  return query.where(this.sessionUser, (p) => (x) => x.zone.users.some((u) => u.userID === p.userID));
33
121
  }
34
122
 
123
+ modify(query: IEntityQuery<HostedZoneRecord>) {
124
+ if (this.sessionUser.isAdmin) {
125
+ return query;
126
+ }
127
+ return query.where(void 0, (p) => (x) => x.readonly === false);
128
+ }
129
+
35
130
  async afterInsert(entity: HostedZoneRecord, entry: ChangeEntry<HostedZoneRecord>) {
36
131
  const db = ServiceProvider.resolve(this, SocialMailContext);
37
132
  const prefix = (!entity.name || entity.name === "@") ? "" : entity.name + ".";
@@ -43,7 +43,7 @@ export const renderUIClient = async (page: Page, view?: string ) => {
43
43
  name: globalEnv.name,
44
44
  cdn: globalEnv.cdn,
45
45
  externalLogin: globalEnv.externalLogin,
46
- dnsEnabled: globalEnv.dnsEnabled
46
+ dnsEnabled: globalEnv.dns?.enabled
47
47
  })};
48
48
  </script>
49
49
  <link rel="manifest" href="/pwa/manifest.json"/>