@social-mail/social-mail-web-server 1.7.243 → 1.7.245
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/WebServer.js +3 -0
- package/dist/WebServer.js.map +1 -1
- package/dist/server/services/cert/SocialAcmeService.d.ts +10 -0
- package/dist/server/services/cert/SocialAcmeService.d.ts.map +1 -0
- package/dist/server/services/cert/SocialAcmeService.js +113 -0
- package/dist/server/services/cert/SocialAcmeService.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/WebServer.ts +3 -3
- package/src/server/services/cert/SocialAcmeService.ts +50 -0
package/package.json
CHANGED
package/src/WebServer.ts
CHANGED
|
@@ -51,10 +51,10 @@ import AppKeyProvider from "./server/services/AppKeyProvider.js";
|
|
|
51
51
|
import KeyProvider from "@entity-access/server-pages/dist/services/KeyProvider.js";
|
|
52
52
|
import SessionSecurity from "@entity-access/server-pages/dist/services/SessionSecurity.js";
|
|
53
53
|
import RootCertificates from "./server/services/root-certs/RootCertificates.js";
|
|
54
|
-
import TlsSessionKeys from "./common/tls/TlsSessionKeys.js";
|
|
55
|
-
import { Http2SecureServer } from "node:http2";
|
|
56
|
-
import { Socket } from "node:net";
|
|
57
54
|
import AcmeCertificateService from "@entity-access/server-pages/dist/ssl/AcmeCertificateService.js";
|
|
55
|
+
import SocialAcmeService from "./server/services/cert/SocialAcmeService.js";
|
|
56
|
+
|
|
57
|
+
ServiceCollection.registerMultiple("Singleton", [AcmeCertificateService, SocialAcmeService], SocialAcmeService);
|
|
58
58
|
|
|
59
59
|
declare module "@entity-access/server-pages/dist/core/SessionUser.js" {
|
|
60
60
|
// eslint-disable-next-line @typescript-eslint/naming-convention, no-shadow
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import AcmeCertificateService, { IAcmeOptions } from "@entity-access/server-pages/dist/ssl/AcmeCertificateService.js";
|
|
2
|
+
import { cacheFor, ICacheContainer, ObjectCache } from "../../../common/cacheFor.js";
|
|
3
|
+
import { ServiceProvider } from "@entity-access/entity-access/dist/di/di.js";
|
|
4
|
+
import MessagingService from "../message-events/MessagingService.js";
|
|
5
|
+
import SocialMailContext from "../../model/SocialMailContext.js";
|
|
6
|
+
import ApexDomain from "../../../common/ApexDomain.js";
|
|
7
|
+
import { globalEnv } from "../../../common/globalEnv.js";
|
|
8
|
+
|
|
9
|
+
export default class SocialAcmeService
|
|
10
|
+
extends AcmeCertificateService
|
|
11
|
+
implements ICacheContainer<SocialAcmeService> {
|
|
12
|
+
|
|
13
|
+
cache: ObjectCache<SocialAcmeService>;
|
|
14
|
+
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
setTimeout(() => this.postInit(), 1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@cacheFor()
|
|
21
|
+
async getSecureContext(host: any, options: IAcmeOptions) {
|
|
22
|
+
host = await this.rewriteHost(host);
|
|
23
|
+
return super.getSecureContext(host, options);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@cacheFor()
|
|
27
|
+
async rewriteHost(host: string) {
|
|
28
|
+
using scope = ServiceProvider.createScope(this);
|
|
29
|
+
|
|
30
|
+
const db = scope.resolve(SocialMailContext);
|
|
31
|
+
|
|
32
|
+
const root = ApexDomain.getApexDomain(host);
|
|
33
|
+
const wildCard = `*.${root}`;
|
|
34
|
+
|
|
35
|
+
const record = await db.hostedZoneRecords.where({ wildCard, host }, (p) => (x) => x.fqdn === p.host || x.fqdn === p.wildCard)
|
|
36
|
+
.orderByDescending({ wildCard }, (p) => (x) => x.fqdn === p.wildCard)
|
|
37
|
+
.first();
|
|
38
|
+
|
|
39
|
+
return record?.fqdn ?? globalEnv.host;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private postInit() {
|
|
43
|
+
const ms = ServiceProvider.resolve(this, MessagingService);
|
|
44
|
+
ms.refreshDns.on(() => {
|
|
45
|
+
this.cache?.clear("getSecureContext");
|
|
46
|
+
this.cache?.clear("rewriteHost");
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|