@social-mail/social-mail-web-server 1.5.149 → 1.5.151

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.5.149",
3
+ "version": "1.5.151",
4
4
  "description": "## Phase 1",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -3,7 +3,7 @@ import semver from "semver";
3
3
 
4
4
  export default async function seedUI(config: DBConfig) {
5
5
 
6
- const version = "1.2.573";
6
+ const version = "1.2.576";
7
7
 
8
8
  const existing = await config.getValue(UIPackageConfig, false);
9
9
  if (existing) {
@@ -62,7 +62,7 @@ export default class ChannelPageService {
62
62
  mailboxSlug = mailboxSlug.toLowerCase();
63
63
  postSlug = postSlug.toLowerCase();
64
64
 
65
- const { 1: emailIDBase36 } = /\-([^\-]+)\/?/.exec(postSlug);
65
+ const { 1: emailIDBase36 } = /\-([^\-]+)\/?$/.exec(postSlug);
66
66
 
67
67
  const emailID = Base36.decode(emailIDBase36) as any;
68
68
 
@@ -31,6 +31,9 @@ export const renderUIClient = async (page: Page, view?: string ) => {
31
31
  }
32
32
  });
33
33
 
34
+ page.response.setHeader("Cross-Origin-Opener-Policy", "same-origin");
35
+ page.response.setHeader("Cross-Origin-Embedder-Policy", "require-corp");
36
+
34
37
  return Content.html(<HtmlDocument>
35
38
  <head>
36
39
  <meta charset="utf-8"/>
@@ -21,6 +21,7 @@ import PostReceiveWorkflow from "../post-receive/PostReceiveWorkflow.js";
21
21
  import ESmtpClient from "../../../protocols/smtp/ESmtpClient.js";
22
22
  import DnsService from "../../smtp/dns/DnsService.js";
23
23
  import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
24
+ import EncryptionService from "../../services/encryption/EncryptionService.js";
24
25
 
25
26
  export const smtpPool = new NamedObjectPool<SMTPClient>((host) => ({
26
27
  asyncFactory: () => new SMTPClient({ host }).connect(),
@@ -103,20 +104,41 @@ export default class DispatchEmailToMX extends Workflow<IMessageEnvelope> {
103
104
  @Inject els?: EmailLogService,
104
105
  @Inject eas?: EmailAddressService,
105
106
  @Inject db?: SocialMailContext,
106
- @Inject dnsService?: DnsService
107
+ @Inject dnsService?: DnsService,
108
+ @Inject es?: EncryptionService
107
109
  ) {
108
110
 
109
- const st = await db.mailboxSyncTargets
111
+ let st = await db.mailboxSyncTargets
110
112
  .where(this.input, (p) => (x) => x.mailboxID === p.senderID
111
113
  && (x.direction === "out" || x.protocol === "smtp")
112
114
  && x.active === true)
113
115
  .first();
114
116
 
115
117
  if (!st) {
116
- throw new Error(`No Smtp Settings Available to send an email.`);
118
+
119
+ // recreate smtp from imap
120
+ const it = await db.mailboxSyncTargets.where(this.input, (p) => (x) => x.mailboxID === p.senderID
121
+ && x.active === true
122
+ && (x.direction === "in" || x.protocol === "imap")
123
+ ).first();
124
+
125
+ if (it?.host?.startsWith("imap.")) {
126
+ st = {
127
+ ... it,
128
+ syncTargetID: void 0,
129
+ host: it.host.replace("imap.", "smtp."),
130
+ port: it.port === 993 ? 465 : 25
131
+ };
132
+ await db.mailboxSyncTargets.statements.insert(st);
133
+ } else {
134
+ throw new Error(`No Smtp Settings Available to send an email.`);
135
+ }
117
136
  }
118
137
 
119
- const { host, username, password } = st;
138
+ const { host, username, password: passwordEncrypted } = st;
139
+
140
+ const password = es.decrypt(passwordEncrypted);
141
+
120
142
 
121
143
  await using client = await ESmtpClient.connect({
122
144
  host,