@social-mail/social-mail-web-server 1.4.973 → 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/dist/common/globalEnv.d.ts +5 -0
- package/dist/common/globalEnv.d.ts.map +1 -1
- package/dist/common/globalEnv.js +5 -0
- package/dist/common/globalEnv.js.map +1 -1
- package/dist/server/model/SocialMailContext.d.ts +4 -0
- package/dist/server/model/SocialMailContext.d.ts.map +1 -1
- package/dist/server/model/SocialMailContext.js +4 -0
- package/dist/server/model/SocialMailContext.js.map +1 -1
- package/dist/server/model/SocialMailContextEvents.d.ts.map +1 -1
- package/dist/server/model/SocialMailContextEvents.js +5 -0
- package/dist/server/model/SocialMailContextEvents.js.map +1 -1
- package/dist/server/model/entities/Domain.d.ts +2 -0
- package/dist/server/model/entities/Domain.d.ts.map +1 -1
- package/dist/server/model/entities/Domain.js.map +1 -1
- package/dist/server/model/entities/HostedZone.d.ts +36 -0
- package/dist/server/model/entities/HostedZone.d.ts.map +1 -0
- package/dist/server/model/entities/HostedZone.js +136 -0
- package/dist/server/model/entities/HostedZone.js.map +1 -0
- package/dist/server/model/entities/User.d.ts +2 -0
- package/dist/server/model/entities/User.d.ts.map +1 -1
- package/dist/server/model/entities/User.js.map +1 -1
- package/dist/server/model/events/HostedZoneEvents.d.ts +18 -0
- package/dist/server/model/events/HostedZoneEvents.d.ts.map +1 -0
- package/dist/server/model/events/HostedZoneEvents.js +134 -0
- package/dist/server/model/events/HostedZoneEvents.js.map +1 -0
- package/dist/server/services/ui/renderUIClient.d.ts.map +1 -1
- package/dist/server/services/ui/renderUIClient.js +2 -1
- package/dist/server/services/ui/renderUIClient.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/common/globalEnv.ts +5 -0
- package/src/server/model/SocialMailContext.ts +7 -0
- package/src/server/model/SocialMailContextEvents.ts +5 -0
- package/src/server/model/entities/Domain.ts +2 -0
- package/src/server/model/entities/HostedZone.ts +115 -0
- package/src/server/model/entities/User.ts +2 -0
- package/src/server/model/events/HostedZoneEvents.ts +164 -0
- package/src/server/services/ui/renderUIClient.tsx +2 -1
package/package.json
CHANGED
package/src/common/globalEnv.ts
CHANGED
|
@@ -24,6 +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
|
+
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
|
+
},
|
|
27
32
|
altHosts: (process.env.SOCIAL_MAIL_ALT_HOSTS || "").split(","),
|
|
28
33
|
wildcardDomain: process.env.SOCIAL_MAIL_WILDCARD_DOMAIN,
|
|
29
34
|
name: process.env.SOCIAL_MAIL_NAME || "Social Mail",
|
|
@@ -44,6 +44,7 @@ import ServerActivity from "./entities/ServerActivity.js";
|
|
|
44
44
|
import IncomingSmsSource from "./entities/IncomingSmsSource.js";
|
|
45
45
|
import VerificationToken, { VerificationTokenAddress } from "./entities/VerificationToken.js";
|
|
46
46
|
import MailboxFolder from "./entities/MailboxFolder.js";
|
|
47
|
+
import HostedZone, { HostedZoneRecord, HostedZoneUser } from "./entities/HostedZone.js";
|
|
47
48
|
|
|
48
49
|
@RegisterScoped
|
|
49
50
|
export default class SocialMailContext extends EntityContext {
|
|
@@ -84,6 +85,12 @@ export default class SocialMailContext extends EntityContext {
|
|
|
84
85
|
|
|
85
86
|
public hostedDomainUsers = this.model.register(DomainUser);
|
|
86
87
|
|
|
88
|
+
public hostedZones = this.model.register(HostedZone);
|
|
89
|
+
|
|
90
|
+
public hostedZoneRecords = this.model.register(HostedZoneRecord);
|
|
91
|
+
|
|
92
|
+
public hostedZoneUsers = this.model.register(HostedZoneUser);
|
|
93
|
+
|
|
87
94
|
public domainRelays = this.model.register(DomainRelay);
|
|
88
95
|
|
|
89
96
|
public domainKeys = this.model.register(DomainKey);
|
|
@@ -95,6 +95,8 @@ import VerificationToken from "./entities/VerificationToken.js";
|
|
|
95
95
|
import VerificationTokenEvents from "./events/VerificationTokenEvents.js";
|
|
96
96
|
import StoreTagEvents from "./events/StoreTagEvents.js";
|
|
97
97
|
import StoreItemFolderTagEvents from "./events/StoreItemFolderTagEvents.js";
|
|
98
|
+
import HostedZone, { HostedZoneRecord, HostedZoneUser } from "./entities/HostedZone.js";
|
|
99
|
+
import HostedZoneEvents, { HostedZoneRecordEvents, HostedZoneUserEvents } from "./events/HostedZoneEvents.js";
|
|
98
100
|
|
|
99
101
|
@RegisterSingleton
|
|
100
102
|
export default class SocialMailContextEvents extends ContextEvents {
|
|
@@ -120,6 +122,9 @@ export default class SocialMailContextEvents extends ContextEvents {
|
|
|
120
122
|
this.register(HostedDomain, HostedDomainEvents);
|
|
121
123
|
this.register(DomainUser, DomainUserEvents);
|
|
122
124
|
this.register(DomainKey, DomainKeyEvents);
|
|
125
|
+
this.register(HostedZone, HostedZoneEvents);
|
|
126
|
+
this.register(HostedZoneRecord, HostedZoneRecordEvents);
|
|
127
|
+
this.register(HostedZoneUser, HostedZoneUserEvents);
|
|
123
128
|
this.register(Email, EmailEvents);
|
|
124
129
|
this.register(EmailAddress, EmailAddressEvents);
|
|
125
130
|
this.register(EmailEngagement, EmailEngagementEvents);
|
|
@@ -6,6 +6,7 @@ import type EmailAddress from "./EmailAddress.js";
|
|
|
6
6
|
import { ContactDomain } from "./Contact.js";
|
|
7
7
|
import type ServerActivity from "./ServerActivity.js";
|
|
8
8
|
import type Mailbox from "./Mailbox.js";
|
|
9
|
+
import type HostedZone from "./HostedZone.js";
|
|
9
10
|
|
|
10
11
|
@Table("Domains")
|
|
11
12
|
@Index({
|
|
@@ -34,4 +35,5 @@ export default class Domain {
|
|
|
34
35
|
public contactDomains: ContactDomain[];
|
|
35
36
|
activities: ServerActivity[];
|
|
36
37
|
mailboxes: Mailbox[];
|
|
38
|
+
hostedZone: HostedZone;
|
|
37
39
|
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import Column from "@entity-access/entity-access/dist/decorators/Column.js";
|
|
2
|
+
import { RelateTo, RelateToOne } from "@entity-access/entity-access/dist/decorators/Relate.js";
|
|
3
|
+
import Table from "@entity-access/entity-access/dist/decorators/Table.js";
|
|
4
|
+
import Domain from "./Domain.js";
|
|
5
|
+
import { EnumColumn } from "../../../common/columns.js";
|
|
6
|
+
import Index from "@entity-access/entity-access/dist/decorators/Index.js";
|
|
7
|
+
import { JsonProperty, ReadOnlyJsonProperty } from "@entity-access/server-pages/dist/services/ModelService.js";
|
|
8
|
+
import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
|
|
9
|
+
import DateTime from "@entity-access/entity-access/dist/types/DateTime.js";
|
|
10
|
+
import { User } from "./User.js";
|
|
11
|
+
|
|
12
|
+
const { labels, column: TypeColumn} = EnumColumn(["A", "AAAA", "CNAME", "MX", "TXT", "PTR", "SRV", "CAA", "NS", "SOA" ] as const, 15, { default: () => "A"});
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@Table("HostedZones")
|
|
16
|
+
export default class HostedZone {
|
|
17
|
+
|
|
18
|
+
@Column({ dataType: "BigInt", key: true })
|
|
19
|
+
@RelateToOne(Domain, {
|
|
20
|
+
property: (x) => x.domain,
|
|
21
|
+
inverseProperty: (x) => x.hostedZone
|
|
22
|
+
})
|
|
23
|
+
zoneID: number;
|
|
24
|
+
|
|
25
|
+
domain: Domain;
|
|
26
|
+
records: HostedZoneRecord[];
|
|
27
|
+
users: HostedZoneUser[];
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@Table("HostedZoneUsers")
|
|
32
|
+
export class HostedZoneUser {
|
|
33
|
+
@Column({ dataType: "BigInt", key: true })
|
|
34
|
+
@RelateTo(HostedZone, {
|
|
35
|
+
property: (x) => x.zone,
|
|
36
|
+
inverseProperty: (x) => x.users
|
|
37
|
+
})
|
|
38
|
+
zoneID: number;
|
|
39
|
+
|
|
40
|
+
@Column({ dataType: "BigInt", key: true })
|
|
41
|
+
@RelateTo(User, {
|
|
42
|
+
property: (x) => x.user,
|
|
43
|
+
inverseProperty: (x) => x.hostedZones
|
|
44
|
+
})
|
|
45
|
+
userID: number;
|
|
46
|
+
|
|
47
|
+
zone: HostedZone;
|
|
48
|
+
user: User;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@Table("HostedZoneRecords")
|
|
53
|
+
@Index({
|
|
54
|
+
name: "IX_HostedZoneRecords_FQDN",
|
|
55
|
+
columns: [
|
|
56
|
+
{ name: (x) => x.fqdn, descending: false }
|
|
57
|
+
],
|
|
58
|
+
filter: (x) => x.fqdn !== null
|
|
59
|
+
})
|
|
60
|
+
export class HostedZoneRecord {
|
|
61
|
+
|
|
62
|
+
@Column({ dataType: "BigInt", key: true, generated: "identity"})
|
|
63
|
+
public recordID: number;
|
|
64
|
+
|
|
65
|
+
@Column({ dataType: "BigInt"})
|
|
66
|
+
@RelateTo(HostedZone, {
|
|
67
|
+
property: (x) => x.zone,
|
|
68
|
+
inverseProperty: (x) => x.records
|
|
69
|
+
})
|
|
70
|
+
public zoneID: number;
|
|
71
|
+
|
|
72
|
+
@Column({ dataType: "Boolean", default: () => false})
|
|
73
|
+
public disabled: boolean;
|
|
74
|
+
|
|
75
|
+
@Column({ dataType: "Boolean", default: () => false})
|
|
76
|
+
public readonly: boolean;
|
|
77
|
+
|
|
78
|
+
@Column({ dataType: "Char", length: 200})
|
|
79
|
+
public name: string;
|
|
80
|
+
|
|
81
|
+
@TypeColumn
|
|
82
|
+
@JsonProperty({ enum: labels })
|
|
83
|
+
public type: typeof labels[number];
|
|
84
|
+
|
|
85
|
+
@Column({ dataType: "Boolean", default: () => false })
|
|
86
|
+
public isAlias: boolean;
|
|
87
|
+
|
|
88
|
+
@Column({ dataType: "Char"})
|
|
89
|
+
public value: string;
|
|
90
|
+
|
|
91
|
+
@Column({ dataType: "Int"})
|
|
92
|
+
public ttl: number;
|
|
93
|
+
|
|
94
|
+
@Column({ default: () => Sql.date.now() })
|
|
95
|
+
public dateCreated: DateTime;
|
|
96
|
+
|
|
97
|
+
@Column({ default: () => Sql.date.now() })
|
|
98
|
+
public dateUpdated: DateTime;
|
|
99
|
+
|
|
100
|
+
@Column({ dataType: "Char", nullable: true})
|
|
101
|
+
public notes: string;
|
|
102
|
+
|
|
103
|
+
@Column({ nullable: true })
|
|
104
|
+
public expiryDate: DateTime;
|
|
105
|
+
|
|
106
|
+
@Column({ dataType: "Boolean", default: () => false})
|
|
107
|
+
public hosted: boolean;
|
|
108
|
+
|
|
109
|
+
@Column({ nullable: true})
|
|
110
|
+
@ReadOnlyJsonProperty
|
|
111
|
+
public fqdn: string;
|
|
112
|
+
|
|
113
|
+
public zone: HostedZone;
|
|
114
|
+
|
|
115
|
+
}
|
|
@@ -18,6 +18,7 @@ import type UserPushSubscription from "./UserSubscriptions.js";
|
|
|
18
18
|
import type { StoreUser } from "./Store.js";
|
|
19
19
|
import type AccessToken from "./AccessToken.js";
|
|
20
20
|
import { RelateTo } from "@entity-access/entity-access/dist/decorators/Relate.js";
|
|
21
|
+
import type { HostedZoneUser } from "./HostedZone.js";
|
|
21
22
|
|
|
22
23
|
export class ChangePassword {
|
|
23
24
|
|
|
@@ -147,6 +148,7 @@ export class User {
|
|
|
147
148
|
// storeOrders: StoreBill[];
|
|
148
149
|
stores: StoreUser[];
|
|
149
150
|
closedEmails: Email[];
|
|
151
|
+
hostedZones: HostedZoneUser[];
|
|
150
152
|
|
|
151
153
|
// [GraphService.toGraph]() {
|
|
152
154
|
// return {
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { IEntityQuery } from "@entity-access/entity-access/dist/model/IFilterWithParameter.js";
|
|
2
|
+
import HostedZone, { HostedZoneRecord, HostedZoneUser } from "../entities/HostedZone.js";
|
|
3
|
+
import AuthenticatedEvents from "./AuthenticatedEvents.js";
|
|
4
|
+
import ChangeEntry from "@entity-access/entity-access/dist/model/changes/ChangeEntry.js";
|
|
5
|
+
import { ServiceProvider } from "@entity-access/entity-access/dist/di/di.js";
|
|
6
|
+
import SocialMailContext from "../SocialMailContext.js";
|
|
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";
|
|
10
|
+
|
|
11
|
+
export default class HostedZoneEvents extends AuthenticatedEvents<HostedZone> {
|
|
12
|
+
|
|
13
|
+
filter(query: IEntityQuery<HostedZone>) {
|
|
14
|
+
if (this.verify) {
|
|
15
|
+
this.sessionUser.ensureLoggedIn();
|
|
16
|
+
}
|
|
17
|
+
if (this.sessionUser.isAdmin) {
|
|
18
|
+
return query;
|
|
19
|
+
}
|
|
20
|
+
return query.where(this.sessionUser, (p) => (x) => x.users.some((u) => u.userID === p.userID));
|
|
21
|
+
}
|
|
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
|
+
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export class HostedZoneRecordEvents extends AuthenticatedEvents<HostedZoneRecord> {
|
|
112
|
+
|
|
113
|
+
filter(query: IEntityQuery<HostedZoneRecord>) {
|
|
114
|
+
if (this.verify) {
|
|
115
|
+
this.sessionUser.ensureLoggedIn();
|
|
116
|
+
}
|
|
117
|
+
if (this.sessionUser.isAdmin) {
|
|
118
|
+
return query;
|
|
119
|
+
}
|
|
120
|
+
return query.where(this.sessionUser, (p) => (x) => x.zone.users.some((u) => u.userID === p.userID));
|
|
121
|
+
}
|
|
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
|
+
|
|
130
|
+
async afterInsert(entity: HostedZoneRecord, entry: ChangeEntry<HostedZoneRecord>) {
|
|
131
|
+
const db = ServiceProvider.resolve(this, SocialMailContext);
|
|
132
|
+
const prefix = (!entity.name || entity.name === "@") ? "" : entity.name + ".";
|
|
133
|
+
await db.hostedZoneRecords.where(entity, (p) => (x) => x.recordID === p.recordID)
|
|
134
|
+
.update({ prefix }, (p) => (x) => ({
|
|
135
|
+
fqdn: Sql.text.concat(
|
|
136
|
+
Sql.cast.asText(p.prefix),
|
|
137
|
+
Sql.cast.asText(x.zone.domain.name)) }));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async afterUpdate(entity: HostedZoneRecord, entry: ChangeEntry<HostedZoneRecord>) {
|
|
141
|
+
const db = ServiceProvider.resolve(this, SocialMailContext);
|
|
142
|
+
const prefix = (!entity.name || entity.name === "@") ? "" : entity.name + ".";
|
|
143
|
+
await db.hostedZoneRecords.where(entity, (p) => (x) => x.recordID === p.recordID)
|
|
144
|
+
.update({ prefix }, (p) => (x) => ({
|
|
145
|
+
fqdn: Sql.text.concat(
|
|
146
|
+
Sql.cast.asText(p.prefix),
|
|
147
|
+
Sql.cast.asText(x.zone.domain.name)) }));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export class HostedZoneUserEvents extends AuthenticatedEvents<HostedZoneUser> {
|
|
153
|
+
|
|
154
|
+
filter(query: IEntityQuery<HostedZoneUser>) {
|
|
155
|
+
if (this.verify) {
|
|
156
|
+
this.sessionUser.ensureLoggedIn();
|
|
157
|
+
}
|
|
158
|
+
if (this.sessionUser.isAdmin) {
|
|
159
|
+
return query;
|
|
160
|
+
}
|
|
161
|
+
return query.where(this.sessionUser, (p) => (x) => x.userID === p.userID);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
}
|
|
@@ -42,7 +42,8 @@ export const renderUIClient = async (page: Page, view?: string ) => {
|
|
|
42
42
|
path: globalEnv.path,
|
|
43
43
|
name: globalEnv.name,
|
|
44
44
|
cdn: globalEnv.cdn,
|
|
45
|
-
externalLogin: globalEnv.externalLogin
|
|
45
|
+
externalLogin: globalEnv.externalLogin,
|
|
46
|
+
dnsEnabled: globalEnv.dns?.enabled
|
|
46
47
|
})};
|
|
47
48
|
</script>
|
|
48
49
|
<link rel="manifest" href="/pwa/manifest.json"/>
|