@backstage/plugin-notifications-backend-module-email 0.3.14-next.1 → 0.3.15-next.0
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @backstage/plugin-notifications-backend-module-email
|
|
2
2
|
|
|
3
|
+
## 0.3.15-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 22a5362: Updated `AWS SES` client to version 2 to support `nodemailer` version 7.
|
|
8
|
+
- 05f60e1: Refactored constructor parameter properties to explicit property declarations for compatibility with TypeScript's `erasableSyntaxOnly` setting. This internal refactoring maintains all existing functionality while ensuring TypeScript compilation compatibility.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @backstage/plugin-notifications-node@0.2.21-next.0
|
|
11
|
+
- @backstage/config@1.3.6-next.0
|
|
12
|
+
- @backstage/catalog-model@1.7.6-next.0
|
|
13
|
+
- @backstage/integration-aws-node@0.1.19-next.0
|
|
14
|
+
- @backstage/backend-plugin-api@1.4.5-next.0
|
|
15
|
+
- @backstage/catalog-client@1.12.1-next.0
|
|
16
|
+
- @backstage/types@1.2.2
|
|
17
|
+
- @backstage/plugin-catalog-node@1.19.2-next.0
|
|
18
|
+
- @backstage/plugin-notifications-common@0.1.2-next.0
|
|
19
|
+
|
|
20
|
+
## 0.3.14
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- b8cf31a: chore(deps): bump `nodemailer` from 6.9.16 to 7.0.7
|
|
25
|
+
- f5e0963: Removed unused dependencies
|
|
26
|
+
- Updated dependencies
|
|
27
|
+
- @backstage/config@1.3.5
|
|
28
|
+
- @backstage/backend-plugin-api@1.4.4
|
|
29
|
+
- @backstage/integration-aws-node@0.1.18
|
|
30
|
+
- @backstage/plugin-catalog-node@1.19.1
|
|
31
|
+
- @backstage/plugin-notifications-common@0.1.1
|
|
32
|
+
- @backstage/plugin-notifications-node@0.2.20
|
|
33
|
+
|
|
3
34
|
## 0.3.14-next.1
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
|
@@ -18,6 +18,25 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
18
18
|
var pThrottle__default = /*#__PURE__*/_interopDefaultCompat(pThrottle);
|
|
19
19
|
|
|
20
20
|
class NotificationsEmailProcessor {
|
|
21
|
+
transporter;
|
|
22
|
+
broadcastConfig;
|
|
23
|
+
transportConfig;
|
|
24
|
+
sender;
|
|
25
|
+
replyTo;
|
|
26
|
+
sesConfig;
|
|
27
|
+
cacheTtl;
|
|
28
|
+
concurrencyLimit;
|
|
29
|
+
throttleInterval;
|
|
30
|
+
frontendBaseUrl;
|
|
31
|
+
filter;
|
|
32
|
+
allowlistEmailAddresses;
|
|
33
|
+
denylistEmailAddresses;
|
|
34
|
+
logger;
|
|
35
|
+
config;
|
|
36
|
+
catalog;
|
|
37
|
+
auth;
|
|
38
|
+
cache;
|
|
39
|
+
templateRenderer;
|
|
21
40
|
constructor(logger, config$1, catalog, auth, cache, templateRenderer) {
|
|
22
41
|
this.logger = logger;
|
|
23
42
|
this.config = config$1;
|
|
@@ -51,19 +70,6 @@ class NotificationsEmailProcessor {
|
|
|
51
70
|
);
|
|
52
71
|
this.filter = pluginNotificationsCommon.getProcessorFiltersFromConfig(emailProcessorConfig);
|
|
53
72
|
}
|
|
54
|
-
transporter;
|
|
55
|
-
broadcastConfig;
|
|
56
|
-
transportConfig;
|
|
57
|
-
sender;
|
|
58
|
-
replyTo;
|
|
59
|
-
sesConfig;
|
|
60
|
-
cacheTtl;
|
|
61
|
-
concurrencyLimit;
|
|
62
|
-
throttleInterval;
|
|
63
|
-
frontendBaseUrl;
|
|
64
|
-
filter;
|
|
65
|
-
allowlistEmailAddresses;
|
|
66
|
-
denylistEmailAddresses;
|
|
67
73
|
async getTransporter() {
|
|
68
74
|
if (this.transporter) {
|
|
69
75
|
return this.transporter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationsEmailProcessor.cjs.js","sources":["../../src/processor/NotificationsEmailProcessor.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n NotificationProcessor,\n NotificationSendOptions,\n} from '@backstage/plugin-notifications-node';\nimport {\n AuthService,\n CacheService,\n LoggerService,\n} from '@backstage/backend-plugin-api';\nimport { Config, readDurationFromConfig } from '@backstage/config';\nimport { durationToMilliseconds } from '@backstage/types';\nimport { CATALOG_FILTER_EXISTS } from '@backstage/catalog-client';\nimport {\n getProcessorFiltersFromConfig,\n Notification,\n NotificationProcessorFilters,\n} from '@backstage/plugin-notifications-common';\nimport {\n createAzureTransport,\n createSendmailTransport,\n createSesTransport,\n createSmtpTransport,\n createStreamTransport,\n} from './transports';\nimport { UserEntity } from '@backstage/catalog-model';\nimport { CatalogService } from '@backstage/plugin-catalog-node';\nimport { compact } from 'lodash';\nimport { DefaultAwsCredentialsManager } from '@backstage/integration-aws-node';\nimport { NotificationTemplateRenderer } from '../extensions';\nimport Mail from 'nodemailer/lib/mailer';\nimport pThrottle from 'p-throttle';\n\nexport class NotificationsEmailProcessor implements NotificationProcessor {\n private transporter: any;\n private readonly broadcastConfig?: Config;\n private readonly transportConfig: Config;\n private readonly sender: string;\n private readonly replyTo?: string;\n private readonly sesConfig?: Config;\n private readonly cacheTtl: number;\n private readonly concurrencyLimit: number;\n private readonly throttleInterval: number;\n private readonly frontendBaseUrl: string;\n private readonly filter: NotificationProcessorFilters;\n private readonly allowlistEmailAddresses?: string[];\n private readonly denylistEmailAddresses?: string[];\n\n constructor(\n private readonly logger: LoggerService,\n private readonly config: Config,\n private readonly catalog: CatalogService,\n private readonly auth: AuthService,\n private readonly cache?: CacheService,\n private readonly templateRenderer?: NotificationTemplateRenderer,\n ) {\n const emailProcessorConfig = config.getConfig(\n 'notifications.processors.email',\n );\n this.transportConfig = emailProcessorConfig.getConfig('transportConfig');\n this.broadcastConfig =\n emailProcessorConfig.getOptionalConfig('broadcastConfig');\n this.sender = emailProcessorConfig.getString('sender');\n this.replyTo = emailProcessorConfig.getOptionalString('replyTo');\n this.sesConfig = emailProcessorConfig.getOptionalConfig('sesConfig');\n this.concurrencyLimit =\n emailProcessorConfig.getOptionalNumber('concurrencyLimit') ?? 2;\n this.throttleInterval = emailProcessorConfig.has('throttleInterval')\n ? durationToMilliseconds(\n readDurationFromConfig(emailProcessorConfig, {\n key: 'throttleInterval',\n }),\n )\n : 100;\n this.cacheTtl = emailProcessorConfig.has('cache.ttl')\n ? durationToMilliseconds(\n readDurationFromConfig(emailProcessorConfig, { key: 'cache.ttl' }),\n )\n : 3_600_000;\n this.frontendBaseUrl = config.getString('app.baseUrl');\n this.allowlistEmailAddresses = emailProcessorConfig.getOptionalStringArray(\n 'allowlistEmailAddresses',\n );\n this.denylistEmailAddresses = emailProcessorConfig.getOptionalStringArray(\n 'denylistEmailAddresses',\n );\n this.filter = getProcessorFiltersFromConfig(emailProcessorConfig);\n }\n\n private async getTransporter() {\n if (this.transporter) {\n return this.transporter;\n }\n const transport = this.transportConfig.getString('transport');\n if (transport === 'smtp') {\n this.transporter = createSmtpTransport(this.transportConfig);\n } else if (transport === 'ses') {\n const awsCredentialsManager = DefaultAwsCredentialsManager.fromConfig(\n this.config,\n );\n this.transporter = await createSesTransport(\n this.transportConfig,\n awsCredentialsManager,\n );\n } else if (transport === 'sendmail') {\n this.transporter = createSendmailTransport(this.transportConfig);\n } else if (transport === 'stream') {\n this.transporter = createStreamTransport();\n } else if (transport === 'azure') {\n this.transporter = createAzureTransport(this.transportConfig);\n } else {\n throw new Error(`Unsupported transport: ${transport}`);\n }\n return this.transporter;\n }\n\n getName(): string {\n return 'Email';\n }\n\n private async getBroadcastEmails(): Promise<string[]> {\n if (!this.broadcastConfig) {\n return [];\n }\n\n const receiver = this.broadcastConfig.getString('receiver');\n if (receiver === 'none') {\n return [];\n }\n\n if (receiver === 'config') {\n return (\n this.broadcastConfig.getOptionalStringArray('receiverEmails') ?? []\n );\n }\n\n if (receiver === 'users') {\n const cached = await this.cache?.get<string[]>('user-emails:all');\n if (cached) {\n return cached;\n }\n\n const entities = await this.catalog.getEntities(\n {\n filter: [\n { kind: 'user', 'spec.profile.email': CATALOG_FILTER_EXISTS },\n ],\n fields: ['spec.profile.email'],\n },\n { credentials: await this.auth.getOwnServiceCredentials() },\n );\n const ret = compact([\n ...new Set(\n entities.items.map(entity => {\n return (entity as UserEntity)?.spec.profile?.email;\n }),\n ),\n ]);\n\n await this.cache?.set('user-emails:all', ret, {\n ttl: this.cacheTtl,\n });\n return ret;\n }\n\n throw new Error(`Unsupported broadcast receiver: ${receiver}`);\n }\n\n private async getUserEmail(entityRef: string): Promise<string[]> {\n const cached = await this.cache?.get<string[]>(`user-emails:${entityRef}`);\n if (cached) {\n return cached;\n }\n\n const entity = await this.catalog.getEntityByRef(entityRef, {\n credentials: await this.auth.getOwnServiceCredentials(),\n });\n const ret: string[] = [];\n if (entity) {\n const userEntity = entity as UserEntity;\n if (userEntity.spec.profile?.email) {\n ret.push(userEntity.spec.profile.email);\n }\n }\n\n await this.cache?.set(`user-emails:${entityRef}`, ret, {\n ttl: this.cacheTtl,\n });\n\n return ret;\n }\n\n private async getRecipientEmails(\n notification: Notification,\n options: NotificationSendOptions,\n ): Promise<string[]> {\n let emails: string[];\n if (options.recipients.type === 'broadcast') {\n emails = await this.getBroadcastEmails();\n } else if (options.recipients.type === 'entity' && !!notification.user) {\n emails = await this.getUserEmail(notification.user);\n } else {\n this.logger.info(\n `Unknown notification type ${options.recipients.type} or missing user.`,\n );\n return [];\n }\n\n if (this.allowlistEmailAddresses) {\n emails = emails.filter(email =>\n this.allowlistEmailAddresses?.includes(email),\n );\n }\n\n if (this.denylistEmailAddresses) {\n emails = emails.filter(\n email => !this.denylistEmailAddresses?.includes(email),\n );\n }\n return emails;\n }\n\n private async sendMail(options: Mail.Options) {\n try {\n this.logger.debug(`Sending notification email to ${options.to}`);\n await this.transporter.sendMail(options);\n } catch (e) {\n this.logger.error(`Failed to send email to ${options.to}: ${e}`);\n }\n }\n\n private async sendMails(options: Mail.Options, emails: string[]) {\n const throttle = pThrottle({\n limit: this.concurrencyLimit,\n interval: this.throttleInterval,\n });\n\n const throttled = throttle((opts: Mail.Options) => this.sendMail(opts));\n await Promise.all(\n emails.map(email => throttled({ ...options, to: email })),\n );\n }\n\n private getNotificationLink(notification: Notification) {\n if (notification.payload.link) {\n const stripLeadingSlash = (s: string) => s.replace(/^\\//, '');\n const ensureTrailingSlash = (s: string) => s.replace(/\\/?$/, '/');\n\n try {\n const url = new URL(\n stripLeadingSlash(notification.payload.link),\n ensureTrailingSlash(this.frontendBaseUrl),\n );\n return url.toString();\n } catch (_e) {\n // noop: fallback to relative URL\n }\n return notification.payload.link;\n }\n return `${this.frontendBaseUrl}/notifications`;\n }\n\n private getHtmlContent(notification: Notification) {\n const contentParts: string[] = [];\n if (notification.payload.description) {\n contentParts.push(`${notification.payload.description}`);\n }\n const link = this.getNotificationLink(notification);\n contentParts.push(`<a href=\"${link}\">${link}</a>`);\n return `<p>${contentParts.join('<br/>')}</p>`;\n }\n\n private getTextContent(notification: Notification) {\n const contentParts: string[] = [];\n if (notification.payload.description) {\n contentParts.push(notification.payload.description);\n }\n contentParts.push(this.getNotificationLink(notification));\n return contentParts.join('\\n\\n');\n }\n\n private async getSesOptions() {\n if (!this.sesConfig) {\n return undefined;\n }\n const ses: Record<string, string> = {};\n const sourceArn = this.sesConfig.getOptionalString('sourceArn');\n const fromArn = this.sesConfig.getOptionalString('fromArn');\n const configurationSetName = this.sesConfig.getOptionalString(\n 'configurationSetName',\n );\n\n if (sourceArn) ses.SourceArn = sourceArn;\n if (fromArn) ses.FromArn = fromArn;\n if (configurationSetName) ses.ConfigurationSetName = configurationSetName;\n\n return Object.keys(ses).length > 0 ? ses : undefined;\n }\n\n private async sendPlainEmail(notification: Notification, emails: string[]) {\n const mailOptions = {\n from: this.sender,\n subject: notification.payload.title,\n html: this.getHtmlContent(notification),\n text: this.getTextContent(notification),\n replyTo: this.replyTo,\n ses: await this.getSesOptions(),\n };\n\n await this.sendMails(mailOptions, emails);\n }\n\n private async sendTemplateEmail(\n notification: Notification,\n emails: string[],\n ) {\n const mailOptions = {\n from: this.sender,\n subject:\n (await this.templateRenderer?.getSubject?.(notification)) ??\n notification.payload.title,\n html: await this.templateRenderer?.getHtml?.(notification),\n text: await this.templateRenderer?.getText?.(notification),\n replyTo: this.replyTo,\n ses: await this.getSesOptions(),\n };\n\n await this.sendMails(mailOptions, emails);\n }\n\n async postProcess(\n notification: Notification,\n options: NotificationSendOptions,\n ): Promise<void> {\n this.transporter = await this.getTransporter();\n\n let emails: string[] = [];\n try {\n emails = await this.getRecipientEmails(notification, options);\n } catch (e) {\n this.logger.error(`Failed to resolve recipient emails: ${e}`);\n return;\n }\n\n if (emails.length === 0) {\n this.logger.info(\n `No email recipients found for notification: ${notification.id}, skipping`,\n );\n return;\n }\n\n this.logger.debug(`Sending notification emails to: ${emails.join(',')}`);\n\n if (!this.templateRenderer) {\n await this.sendPlainEmail(notification, emails);\n return;\n }\n\n await this.sendTemplateEmail(notification, emails);\n }\n\n getNotificationFilters(): NotificationProcessorFilters {\n return this.filter;\n }\n}\n"],"names":["config","durationToMilliseconds","readDurationFromConfig","getProcessorFiltersFromConfig","createSmtpTransport","DefaultAwsCredentialsManager","createSesTransport","createSendmailTransport","createStreamTransport","createAzureTransport","CATALOG_FILTER_EXISTS","compact","pThrottle"],"mappings":";;;;;;;;;;;;;;;;;;;AAgDO,MAAM,2BA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AAAA,MACd,GAAA,EAAK,MAAM,IAAA,CAAK,aAAA;AAAc,KAChC;AAEA,IAAA,MAAM,IAAA,CAAK,SAAA,CAAU,WAAA,EAAa,MAAM,CAAA;AAAA,EAC1C;AAAA,EAEA,MAAM,WAAA,CACJ,YAAA,EACA,OAAA,EACe;AACf,IAAA,IAAA,CAAK,WAAA,GAAc,MAAM,IAAA,CAAK,cAAA,EAAe;AAE7C,IAAA,IAAI,SAAmB,EAAC;AACxB,IAAA,IAAI;AACF,MAAA,MAAA,GAAS,MAAM,IAAA,CAAK,kBAAA,CAAmB,YAAA,EAAc,OAAO,CAAA;AAAA,IAC9D,SAAS,CAAA,EAAG;AACV,MAAA,IAAA,CAAK,MAAA,CAAO,KAAA,CAAM,CAAA,oCAAA,EAAuC,CAAC,CAAA,CAAE,CAAA;AAC5D,MAAA;AAAA,IACF;AAEA,IAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACvB,MAAA,IAAA,CAAK,MAAA,CAAO,IAAA;AAAA,QACV,CAAA,4CAAA,EAA+C,aAAa,EAAE,CAAA,UAAA;AAAA,OAChE;AACA,MAAA;AAAA,IACF;AAEA,IAAA,IAAA,CAAK,OAAO,KAAA,CAAM,CAAA,gCAAA,EAAmC,OAAO,IAAA,CAAK,GAAG,CAAC,CAAA,CAAE,CAAA;AAEvE,IAAA,IAAI,CAAC,KAAK,gBAAA,EAAkB;AAC1B,MAAA,MAAM,IAAA,CAAK,cAAA,CAAe,YAAA,EAAc,MAAM,CAAA;AAC9C,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,IAAA,CAAK,iBAAA,CAAkB,YAAA,EAAc,MAAM,CAAA;AAAA,EACnD;AAAA,EAEA,sBAAA,GAAuD;AACrD,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"NotificationsEmailProcessor.cjs.js","sources":["../../src/processor/NotificationsEmailProcessor.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n NotificationProcessor,\n NotificationSendOptions,\n} from '@backstage/plugin-notifications-node';\nimport {\n AuthService,\n CacheService,\n LoggerService,\n} from '@backstage/backend-plugin-api';\nimport { Config, readDurationFromConfig } from '@backstage/config';\nimport { durationToMilliseconds } from '@backstage/types';\nimport { CATALOG_FILTER_EXISTS } from '@backstage/catalog-client';\nimport {\n getProcessorFiltersFromConfig,\n Notification,\n NotificationProcessorFilters,\n} from '@backstage/plugin-notifications-common';\nimport {\n createAzureTransport,\n createSendmailTransport,\n createSesTransport,\n createSmtpTransport,\n createStreamTransport,\n} from './transports';\nimport { UserEntity } from '@backstage/catalog-model';\nimport { CatalogService } from '@backstage/plugin-catalog-node';\nimport { compact } from 'lodash';\nimport { DefaultAwsCredentialsManager } from '@backstage/integration-aws-node';\nimport { NotificationTemplateRenderer } from '../extensions';\nimport Mail from 'nodemailer/lib/mailer';\nimport pThrottle from 'p-throttle';\n\nexport class NotificationsEmailProcessor implements NotificationProcessor {\n private transporter: any;\n private readonly broadcastConfig?: Config;\n private readonly transportConfig: Config;\n private readonly sender: string;\n private readonly replyTo?: string;\n private readonly sesConfig?: Config;\n private readonly cacheTtl: number;\n private readonly concurrencyLimit: number;\n private readonly throttleInterval: number;\n private readonly frontendBaseUrl: string;\n private readonly filter: NotificationProcessorFilters;\n private readonly allowlistEmailAddresses?: string[];\n private readonly denylistEmailAddresses?: string[];\n\n private readonly logger: LoggerService;\n private readonly config: Config;\n private readonly catalog: CatalogService;\n private readonly auth: AuthService;\n private readonly cache?: CacheService;\n private readonly templateRenderer?: NotificationTemplateRenderer;\n\n constructor(\n logger: LoggerService,\n config: Config,\n catalog: CatalogService,\n auth: AuthService,\n cache?: CacheService,\n templateRenderer?: NotificationTemplateRenderer,\n ) {\n this.logger = logger;\n this.config = config;\n this.catalog = catalog;\n this.auth = auth;\n this.cache = cache;\n this.templateRenderer = templateRenderer;\n const emailProcessorConfig = config.getConfig(\n 'notifications.processors.email',\n );\n this.transportConfig = emailProcessorConfig.getConfig('transportConfig');\n this.broadcastConfig =\n emailProcessorConfig.getOptionalConfig('broadcastConfig');\n this.sender = emailProcessorConfig.getString('sender');\n this.replyTo = emailProcessorConfig.getOptionalString('replyTo');\n this.sesConfig = emailProcessorConfig.getOptionalConfig('sesConfig');\n this.concurrencyLimit =\n emailProcessorConfig.getOptionalNumber('concurrencyLimit') ?? 2;\n this.throttleInterval = emailProcessorConfig.has('throttleInterval')\n ? durationToMilliseconds(\n readDurationFromConfig(emailProcessorConfig, {\n key: 'throttleInterval',\n }),\n )\n : 100;\n this.cacheTtl = emailProcessorConfig.has('cache.ttl')\n ? durationToMilliseconds(\n readDurationFromConfig(emailProcessorConfig, { key: 'cache.ttl' }),\n )\n : 3_600_000;\n this.frontendBaseUrl = config.getString('app.baseUrl');\n this.allowlistEmailAddresses = emailProcessorConfig.getOptionalStringArray(\n 'allowlistEmailAddresses',\n );\n this.denylistEmailAddresses = emailProcessorConfig.getOptionalStringArray(\n 'denylistEmailAddresses',\n );\n this.filter = getProcessorFiltersFromConfig(emailProcessorConfig);\n }\n\n private async getTransporter() {\n if (this.transporter) {\n return this.transporter;\n }\n const transport = this.transportConfig.getString('transport');\n if (transport === 'smtp') {\n this.transporter = createSmtpTransport(this.transportConfig);\n } else if (transport === 'ses') {\n const awsCredentialsManager = DefaultAwsCredentialsManager.fromConfig(\n this.config,\n );\n this.transporter = await createSesTransport(\n this.transportConfig,\n awsCredentialsManager,\n );\n } else if (transport === 'sendmail') {\n this.transporter = createSendmailTransport(this.transportConfig);\n } else if (transport === 'stream') {\n this.transporter = createStreamTransport();\n } else if (transport === 'azure') {\n this.transporter = createAzureTransport(this.transportConfig);\n } else {\n throw new Error(`Unsupported transport: ${transport}`);\n }\n return this.transporter;\n }\n\n getName(): string {\n return 'Email';\n }\n\n private async getBroadcastEmails(): Promise<string[]> {\n if (!this.broadcastConfig) {\n return [];\n }\n\n const receiver = this.broadcastConfig.getString('receiver');\n if (receiver === 'none') {\n return [];\n }\n\n if (receiver === 'config') {\n return (\n this.broadcastConfig.getOptionalStringArray('receiverEmails') ?? []\n );\n }\n\n if (receiver === 'users') {\n const cached = await this.cache?.get<string[]>('user-emails:all');\n if (cached) {\n return cached;\n }\n\n const entities = await this.catalog.getEntities(\n {\n filter: [\n { kind: 'user', 'spec.profile.email': CATALOG_FILTER_EXISTS },\n ],\n fields: ['spec.profile.email'],\n },\n { credentials: await this.auth.getOwnServiceCredentials() },\n );\n const ret = compact([\n ...new Set(\n entities.items.map(entity => {\n return (entity as UserEntity)?.spec.profile?.email;\n }),\n ),\n ]);\n\n await this.cache?.set('user-emails:all', ret, {\n ttl: this.cacheTtl,\n });\n return ret;\n }\n\n throw new Error(`Unsupported broadcast receiver: ${receiver}`);\n }\n\n private async getUserEmail(entityRef: string): Promise<string[]> {\n const cached = await this.cache?.get<string[]>(`user-emails:${entityRef}`);\n if (cached) {\n return cached;\n }\n\n const entity = await this.catalog.getEntityByRef(entityRef, {\n credentials: await this.auth.getOwnServiceCredentials(),\n });\n const ret: string[] = [];\n if (entity) {\n const userEntity = entity as UserEntity;\n if (userEntity.spec.profile?.email) {\n ret.push(userEntity.spec.profile.email);\n }\n }\n\n await this.cache?.set(`user-emails:${entityRef}`, ret, {\n ttl: this.cacheTtl,\n });\n\n return ret;\n }\n\n private async getRecipientEmails(\n notification: Notification,\n options: NotificationSendOptions,\n ): Promise<string[]> {\n let emails: string[];\n if (options.recipients.type === 'broadcast') {\n emails = await this.getBroadcastEmails();\n } else if (options.recipients.type === 'entity' && !!notification.user) {\n emails = await this.getUserEmail(notification.user);\n } else {\n this.logger.info(\n `Unknown notification type ${options.recipients.type} or missing user.`,\n );\n return [];\n }\n\n if (this.allowlistEmailAddresses) {\n emails = emails.filter(email =>\n this.allowlistEmailAddresses?.includes(email),\n );\n }\n\n if (this.denylistEmailAddresses) {\n emails = emails.filter(\n email => !this.denylistEmailAddresses?.includes(email),\n );\n }\n return emails;\n }\n\n private async sendMail(options: Mail.Options) {\n try {\n this.logger.debug(`Sending notification email to ${options.to}`);\n await this.transporter.sendMail(options);\n } catch (e) {\n this.logger.error(`Failed to send email to ${options.to}: ${e}`);\n }\n }\n\n private async sendMails(options: Mail.Options, emails: string[]) {\n const throttle = pThrottle({\n limit: this.concurrencyLimit,\n interval: this.throttleInterval,\n });\n\n const throttled = throttle((opts: Mail.Options) => this.sendMail(opts));\n await Promise.all(\n emails.map(email => throttled({ ...options, to: email })),\n );\n }\n\n private getNotificationLink(notification: Notification) {\n if (notification.payload.link) {\n const stripLeadingSlash = (s: string) => s.replace(/^\\//, '');\n const ensureTrailingSlash = (s: string) => s.replace(/\\/?$/, '/');\n\n try {\n const url = new URL(\n stripLeadingSlash(notification.payload.link),\n ensureTrailingSlash(this.frontendBaseUrl),\n );\n return url.toString();\n } catch (_e) {\n // noop: fallback to relative URL\n }\n return notification.payload.link;\n }\n return `${this.frontendBaseUrl}/notifications`;\n }\n\n private getHtmlContent(notification: Notification) {\n const contentParts: string[] = [];\n if (notification.payload.description) {\n contentParts.push(`${notification.payload.description}`);\n }\n const link = this.getNotificationLink(notification);\n contentParts.push(`<a href=\"${link}\">${link}</a>`);\n return `<p>${contentParts.join('<br/>')}</p>`;\n }\n\n private getTextContent(notification: Notification) {\n const contentParts: string[] = [];\n if (notification.payload.description) {\n contentParts.push(notification.payload.description);\n }\n contentParts.push(this.getNotificationLink(notification));\n return contentParts.join('\\n\\n');\n }\n\n private async getSesOptions() {\n if (!this.sesConfig) {\n return undefined;\n }\n const ses: Record<string, string> = {};\n const sourceArn = this.sesConfig.getOptionalString('sourceArn');\n const fromArn = this.sesConfig.getOptionalString('fromArn');\n const configurationSetName = this.sesConfig.getOptionalString(\n 'configurationSetName',\n );\n\n if (sourceArn) ses.SourceArn = sourceArn;\n if (fromArn) ses.FromArn = fromArn;\n if (configurationSetName) ses.ConfigurationSetName = configurationSetName;\n\n return Object.keys(ses).length > 0 ? ses : undefined;\n }\n\n private async sendPlainEmail(notification: Notification, emails: string[]) {\n const mailOptions = {\n from: this.sender,\n subject: notification.payload.title,\n html: this.getHtmlContent(notification),\n text: this.getTextContent(notification),\n replyTo: this.replyTo,\n ses: await this.getSesOptions(),\n };\n\n await this.sendMails(mailOptions, emails);\n }\n\n private async sendTemplateEmail(\n notification: Notification,\n emails: string[],\n ) {\n const mailOptions = {\n from: this.sender,\n subject:\n (await this.templateRenderer?.getSubject?.(notification)) ??\n notification.payload.title,\n html: await this.templateRenderer?.getHtml?.(notification),\n text: await this.templateRenderer?.getText?.(notification),\n replyTo: this.replyTo,\n ses: await this.getSesOptions(),\n };\n\n await this.sendMails(mailOptions, emails);\n }\n\n async postProcess(\n notification: Notification,\n options: NotificationSendOptions,\n ): Promise<void> {\n this.transporter = await this.getTransporter();\n\n let emails: string[] = [];\n try {\n emails = await this.getRecipientEmails(notification, options);\n } catch (e) {\n this.logger.error(`Failed to resolve recipient emails: ${e}`);\n return;\n }\n\n if (emails.length === 0) {\n this.logger.info(\n `No email recipients found for notification: ${notification.id}, skipping`,\n );\n return;\n }\n\n this.logger.debug(`Sending notification emails to: ${emails.join(',')}`);\n\n if (!this.templateRenderer) {\n await this.sendPlainEmail(notification, emails);\n return;\n }\n\n await this.sendTemplateEmail(notification, emails);\n }\n\n getNotificationFilters(): NotificationProcessorFilters {\n return this.filter;\n }\n}\n"],"names":["config","durationToMilliseconds","readDurationFromConfig","getProcessorFiltersFromConfig","createSmtpTransport","DefaultAwsCredentialsManager","createSesTransport","createSendmailTransport","createStreamTransport","createAzureTransport","CATALOG_FILTER_EXISTS","compact","pThrottle"],"mappings":";;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MAAA;AAAA,EACd;AACF;;;;"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var nodemailer = require('nodemailer');
|
|
4
|
-
var
|
|
4
|
+
var clientSesv2 = require('@aws-sdk/client-sesv2');
|
|
5
5
|
|
|
6
6
|
const createSesTransport = async (config, credentialsManager) => {
|
|
7
7
|
const credentials = await credentialsManager.getCredentialProvider({
|
|
8
8
|
accountId: config.getOptionalString("accountId")
|
|
9
9
|
});
|
|
10
|
-
const
|
|
10
|
+
const sesClient = new clientSesv2.SESv2Client([
|
|
11
11
|
{
|
|
12
|
-
apiVersion: config.getOptionalString("apiVersion")
|
|
13
|
-
credentials: credentials.sdkCredentialProvider,
|
|
12
|
+
apiVersion: config.getOptionalString("apiVersion"),
|
|
14
13
|
region: config.getOptionalString("region"),
|
|
14
|
+
credentials: credentials.sdkCredentialProvider,
|
|
15
15
|
endpoint: config.getOptionalString("endpoint")
|
|
16
16
|
}
|
|
17
17
|
]);
|
|
18
18
|
return nodemailer.createTransport({
|
|
19
|
-
SES: {
|
|
19
|
+
SES: { sesClient, SendEmailCommand: clientSesv2.SendEmailCommand }
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ses.cjs.js","sources":["../../../src/processor/transports/ses.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createTransport } from 'nodemailer';\nimport {
|
|
1
|
+
{"version":3,"file":"ses.cjs.js","sources":["../../../src/processor/transports/ses.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createTransport } from 'nodemailer';\nimport { SendEmailCommand, SESv2Client } from '@aws-sdk/client-sesv2';\n\nimport { Config } from '@backstage/config';\nimport { AwsCredentialsManager } from '@backstage/integration-aws-node';\n\nexport const createSesTransport = async (\n config: Config,\n credentialsManager: AwsCredentialsManager,\n) => {\n const credentials = await credentialsManager.getCredentialProvider({\n accountId: config.getOptionalString('accountId'),\n });\n\n const sesClient = new SESv2Client([\n {\n apiVersion: config.getOptionalString('apiVersion'),\n region: config.getOptionalString('region'),\n credentials: credentials.sdkCredentialProvider,\n endpoint: config.getOptionalString('endpoint'),\n },\n ]);\n\n return createTransport({\n SES: { sesClient, SendEmailCommand },\n });\n};\n"],"names":["SESv2Client","createTransport","SendEmailCommand"],"mappings":";;;;;AAqBO,MAAM,kBAAA,GAAqB,OAChC,MAAA,EACA,kBAAA,KACG;AACH,EAAA,MAAM,WAAA,GAAc,MAAM,kBAAA,CAAmB,qBAAA,CAAsB;AAAA,IACjE,SAAA,EAAW,MAAA,CAAO,iBAAA,CAAkB,WAAW;AAAA,GAChD,CAAA;AAED,EAAA,MAAM,SAAA,GAAY,IAAIA,uBAAA,CAAY;AAAA,IAChC;AAAA,MACE,UAAA,EAAY,MAAA,CAAO,iBAAA,CAAkB,YAAY,CAAA;AAAA,MACjD,MAAA,EAAQ,MAAA,CAAO,iBAAA,CAAkB,QAAQ,CAAA;AAAA,MACzC,aAAa,WAAA,CAAY,qBAAA;AAAA,MACzB,QAAA,EAAU,MAAA,CAAO,iBAAA,CAAkB,UAAU;AAAA;AAC/C,GACD,CAAA;AAED,EAAA,OAAOC,0BAAA,CAAgB;AAAA,IACrB,GAAA,EAAK,EAAE,SAAA,oBAAWC,4BAAA;AAAiB,GACpC,CAAA;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-notifications-backend-module-email",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.15-next.0",
|
|
4
4
|
"description": "The email backend module for the notifications plugin.",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -37,25 +37,25 @@
|
|
|
37
37
|
"test": "backstage-cli package test"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@aws-sdk/client-
|
|
40
|
+
"@aws-sdk/client-sesv2": "^3.911.0",
|
|
41
41
|
"@azure/communication-email": "^1.0.0",
|
|
42
42
|
"@azure/identity": "^4.0.0",
|
|
43
|
-
"@backstage/backend-plugin-api": "1.4.
|
|
44
|
-
"@backstage/catalog-client": "1.12.0",
|
|
45
|
-
"@backstage/catalog-model": "1.7.
|
|
46
|
-
"@backstage/config": "1.3.
|
|
47
|
-
"@backstage/integration-aws-node": "0.1.
|
|
48
|
-
"@backstage/plugin-catalog-node": "1.19.
|
|
49
|
-
"@backstage/plugin-notifications-common": "0.1.
|
|
50
|
-
"@backstage/plugin-notifications-node": "0.2.
|
|
43
|
+
"@backstage/backend-plugin-api": "1.4.5-next.0",
|
|
44
|
+
"@backstage/catalog-client": "1.12.1-next.0",
|
|
45
|
+
"@backstage/catalog-model": "1.7.6-next.0",
|
|
46
|
+
"@backstage/config": "1.3.6-next.0",
|
|
47
|
+
"@backstage/integration-aws-node": "0.1.19-next.0",
|
|
48
|
+
"@backstage/plugin-catalog-node": "1.19.2-next.0",
|
|
49
|
+
"@backstage/plugin-notifications-common": "0.1.2-next.0",
|
|
50
|
+
"@backstage/plugin-notifications-node": "0.2.21-next.0",
|
|
51
51
|
"@backstage/types": "1.2.2",
|
|
52
52
|
"lodash": "^4.17.21",
|
|
53
53
|
"nodemailer": "^7.0.7",
|
|
54
54
|
"p-throttle": "^4.1.1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@backstage/backend-test-utils": "1.
|
|
58
|
-
"@backstage/cli": "0.34.
|
|
57
|
+
"@backstage/backend-test-utils": "1.10.0-next.0",
|
|
58
|
+
"@backstage/cli": "0.34.5-next.0",
|
|
59
59
|
"@types/nodemailer": "^6.4.14"
|
|
60
60
|
},
|
|
61
61
|
"configSchema": "config.d.ts",
|