@travetto/email 2.1.4 → 2.1.7

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.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/src/util.ts +8 -3
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@travetto/email",
3
3
  "displayName": "Email",
4
- "version": "2.1.4",
4
+ "version": "2.1.7",
5
5
  "description": "Email transmission module.",
6
6
  "keywords": [
7
7
  "email",
@@ -24,19 +24,19 @@
24
24
  "directory": "module/email"
25
25
  },
26
26
  "dependencies": {
27
- "@travetto/config": "^2.1.3",
28
- "@travetto/di": "^2.1.3",
27
+ "@travetto/config": "^2.1.5",
28
+ "@travetto/di": "^2.1.5",
29
29
  "@types/mustache": "^4.1.3",
30
30
  "mustache": "^4.2.0"
31
31
  },
32
32
  "optionalPeerDependencies": {
33
- "nodemailer": "^6.7.5",
33
+ "nodemailer": "^6.7.7",
34
34
  "@types/nodemailer": "^6.4.4"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
39
  "docDependencies": {
40
- "@aws-sdk/client-ses": "^3.118.0"
40
+ "@aws-sdk/client-ses": "^3.131.0"
41
41
  }
42
42
  }
package/src/util.ts CHANGED
@@ -14,15 +14,20 @@ export class MailUtil {
14
14
  const attachments: Attachment[] = [];
15
15
  const contentMap = new Map<string, string>();
16
16
 
17
- html = html.replace(/data:(image\/[^;]+);base64,([^"]+)/g, (__, type, content) => {
17
+ html = html.replace(/data:(image\/[^;]+);base64,([^"']+)/g, (__, contentType, content) => {
18
18
  // Ensure same data uris map to a single cid
19
19
  if (!contentMap.has(content)) {
20
- const cid = `${idx += 1}`;
20
+ const cid = `image-${idx += 1}`;
21
+ const ext = contentType.split('/')[1];
21
22
  attachments.push({
22
23
  cid,
24
+ filename: `${cid}.${ext}`,
25
+ headers: {
26
+ 'X-Attachment-Id': `${cid}`
27
+ },
23
28
  content: Buffer.from(content, 'base64'),
24
29
  contentDisposition: 'inline',
25
- contentType: type
30
+ contentType
26
31
  });
27
32
  contentMap.set(content, cid);
28
33
  return `cid:${cid}`;