@backstage/plugin-notifications-backend-module-email 0.3.1-next.0 → 0.3.1-next.1

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,20 @@
1
1
  # @backstage/plugin-notifications-backend-module-email
2
2
 
3
+ ## 0.3.1-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/plugin-catalog-node@1.13.1-next.1
9
+ - @backstage/catalog-client@1.7.1-next.0
10
+ - @backstage/backend-plugin-api@1.0.1-next.1
11
+ - @backstage/catalog-model@1.7.0
12
+ - @backstage/config@1.2.0
13
+ - @backstage/integration-aws-node@0.1.12
14
+ - @backstage/types@1.1.1
15
+ - @backstage/plugin-notifications-common@0.0.5
16
+ - @backstage/plugin-notifications-node@0.2.7-next.1
17
+
3
18
  ## 0.3.1-next.0
4
19
 
5
20
  ### Patch Changes
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var backendPluginApi = require('@backstage/backend-plugin-api');
4
+
5
+ const notificationsEmailTemplateExtensionPoint = backendPluginApi.createExtensionPoint({
6
+ id: "notifications.email.templates"
7
+ });
8
+
9
+ exports.notificationsEmailTemplateExtensionPoint = notificationsEmailTemplateExtensionPoint;
10
+ //# sourceMappingURL=extensions.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extensions.cjs.js","sources":["../src/extensions.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 { createExtensionPoint } from '@backstage/backend-plugin-api';\nimport { Notification } from '@backstage/plugin-notifications-common';\n\n/**\n * @public\n */\nexport interface NotificationTemplateRenderer {\n getSubject?(notification: Notification): Promise<string>;\n getText?(notification: Notification): Promise<string>;\n getHtml?(notification: Notification): Promise<string>;\n}\n\n/**\n * @public\n */\nexport interface NotificationsEmailTemplateExtensionPoint {\n setTemplateRenderer(renderer: NotificationTemplateRenderer): void;\n}\n\n/**\n * @public\n */\nexport const notificationsEmailTemplateExtensionPoint =\n createExtensionPoint<NotificationsEmailTemplateExtensionPoint>({\n id: 'notifications.email.templates',\n });\n"],"names":["createExtensionPoint"],"mappings":";;;;AAqCO,MAAM,2CACXA,qCAA+D,CAAA;AAAA,EAC7D,EAAI,EAAA,+BAAA;AACN,CAAC;;;;"}
package/dist/index.cjs.js CHANGED
@@ -2,360 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var backendPluginApi = require('@backstage/backend-plugin-api');
6
- var alpha = require('@backstage/plugin-catalog-node/alpha');
7
- var pluginNotificationsNode = require('@backstage/plugin-notifications-node');
8
- var config = require('@backstage/config');
9
- var types = require('@backstage/types');
10
- var catalogClient = require('@backstage/catalog-client');
11
- var pluginNotificationsCommon = require('@backstage/plugin-notifications-common');
12
- var nodemailer = require('nodemailer');
13
- var clientSes = require('@aws-sdk/client-ses');
14
- var lodash = require('lodash');
15
- var integrationAwsNode = require('@backstage/integration-aws-node');
16
- var pThrottle = require('p-throttle');
5
+ var module$1 = require('./module.cjs.js');
6
+ var extensions = require('./extensions.cjs.js');
17
7
 
18
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
19
8
 
20
- var pThrottle__default = /*#__PURE__*/_interopDefaultCompat(pThrottle);
21
9
 
22
- const createSmtpTransport = (config) => {
23
- const username = config.getOptionalString("username");
24
- const password = config.getOptionalString("password");
25
- return nodemailer.createTransport({
26
- host: config.getString("hostname"),
27
- port: config.getNumber("port"),
28
- secure: config.getOptionalBoolean("secure") ?? false,
29
- requireTLS: config.getOptionalBoolean("requireTls") ?? false,
30
- auth: username && password ? { user: username, pass: password } : void 0
31
- });
32
- };
33
-
34
- const createSesTransport = async (config, credentialsManager) => {
35
- const credentials = await credentialsManager.getCredentialProvider({
36
- accountId: config.getOptionalString("accountId")
37
- });
38
- const ses = new clientSes.SES([
39
- {
40
- apiVersion: config.getOptionalString("apiVersion") ?? "2010-12-01",
41
- credentials: credentials.sdkCredentialProvider,
42
- region: config.getOptionalString("region")
43
- }
44
- ]);
45
- return nodemailer.createTransport({
46
- SES: { ses, aws: { SendRawEmailCommand: clientSes.SendRawEmailCommand } }
47
- });
48
- };
49
-
50
- const createSendmailTransport = (config) => {
51
- return nodemailer.createTransport({
52
- sendmail: true,
53
- newline: config.getOptionalString("newline") ?? "unix",
54
- path: config.getOptionalString("path") ?? "/usr/sbin/sendmail"
55
- });
56
- };
57
-
58
- const createStreamTransport = () => {
59
- return nodemailer.createTransport({ streamTransport: true });
60
- };
61
-
62
- class NotificationsEmailProcessor {
63
- constructor(logger, config$1, catalog, auth, cache, templateRenderer) {
64
- this.logger = logger;
65
- this.config = config$1;
66
- this.catalog = catalog;
67
- this.auth = auth;
68
- this.cache = cache;
69
- this.templateRenderer = templateRenderer;
70
- const emailProcessorConfig = config$1.getConfig(
71
- "notifications.processors.email"
72
- );
73
- this.transportConfig = emailProcessorConfig.getConfig("transportConfig");
74
- this.broadcastConfig = emailProcessorConfig.getOptionalConfig("broadcastConfig");
75
- this.sender = emailProcessorConfig.getString("sender");
76
- this.replyTo = emailProcessorConfig.getOptionalString("replyTo");
77
- this.concurrencyLimit = emailProcessorConfig.getOptionalNumber("concurrencyLimit") ?? 2;
78
- const throttleConfig = emailProcessorConfig.getOptionalConfig("throttleInterval");
79
- this.throttleInterval = throttleConfig ? types.durationToMilliseconds(config.readDurationFromConfig(throttleConfig)) : 100;
80
- const cacheConfig = emailProcessorConfig.getOptionalConfig("cache.ttl");
81
- this.cacheTtl = cacheConfig ? types.durationToMilliseconds(config.readDurationFromConfig(cacheConfig)) : 36e5;
82
- this.frontendBaseUrl = config$1.getString("app.baseUrl");
83
- this.allowlistEmailAddresses = emailProcessorConfig.getOptionalStringArray(
84
- "allowlistEmailAddresses"
85
- );
86
- this.denylistEmailAddresses = emailProcessorConfig.getOptionalStringArray(
87
- "denylistEmailAddresses"
88
- );
89
- this.filter = pluginNotificationsCommon.getProcessorFiltersFromConfig(emailProcessorConfig);
90
- }
91
- transporter;
92
- broadcastConfig;
93
- transportConfig;
94
- sender;
95
- replyTo;
96
- cacheTtl;
97
- concurrencyLimit;
98
- throttleInterval;
99
- frontendBaseUrl;
100
- filter;
101
- allowlistEmailAddresses;
102
- denylistEmailAddresses;
103
- async getTransporter() {
104
- if (this.transporter) {
105
- return this.transporter;
106
- }
107
- const transport = this.transportConfig.getString("transport");
108
- if (transport === "smtp") {
109
- this.transporter = createSmtpTransport(this.transportConfig);
110
- } else if (transport === "ses") {
111
- const awsCredentialsManager = integrationAwsNode.DefaultAwsCredentialsManager.fromConfig(
112
- this.config
113
- );
114
- this.transporter = await createSesTransport(
115
- this.transportConfig,
116
- awsCredentialsManager
117
- );
118
- } else if (transport === "sendmail") {
119
- this.transporter = createSendmailTransport(this.transportConfig);
120
- } else if (transport === "stream") {
121
- this.transporter = createStreamTransport();
122
- } else {
123
- throw new Error(`Unsupported transport: ${transport}`);
124
- }
125
- return this.transporter;
126
- }
127
- getName() {
128
- return "Email";
129
- }
130
- async getBroadcastEmails() {
131
- if (!this.broadcastConfig) {
132
- return [];
133
- }
134
- const receiver = this.broadcastConfig.getString("receiver");
135
- if (receiver === "none") {
136
- return [];
137
- }
138
- if (receiver === "config") {
139
- return this.broadcastConfig.getOptionalStringArray("receiverEmails") ?? [];
140
- }
141
- if (receiver === "users") {
142
- const cached = await this.cache?.get("user-emails:all");
143
- if (cached) {
144
- return cached;
145
- }
146
- const { token } = await this.auth.getPluginRequestToken({
147
- onBehalfOf: await this.auth.getOwnServiceCredentials(),
148
- targetPluginId: "catalog"
149
- });
150
- const entities = await this.catalog.getEntities(
151
- {
152
- filter: [
153
- { kind: "user", "spec.profile.email": catalogClient.CATALOG_FILTER_EXISTS }
154
- ],
155
- fields: ["spec.profile.email"]
156
- },
157
- { token }
158
- );
159
- const ret = lodash.compact([
160
- ...new Set(
161
- entities.items.map((entity) => {
162
- return entity?.spec.profile?.email;
163
- })
164
- )
165
- ]);
166
- await this.cache?.set("user-emails:all", ret, {
167
- ttl: this.cacheTtl
168
- });
169
- return ret;
170
- }
171
- throw new Error(`Unsupported broadcast receiver: ${receiver}`);
172
- }
173
- async getUserEmail(entityRef) {
174
- const cached = await this.cache?.get(`user-emails:${entityRef}`);
175
- if (cached) {
176
- return cached;
177
- }
178
- const { token } = await this.auth.getPluginRequestToken({
179
- onBehalfOf: await this.auth.getOwnServiceCredentials(),
180
- targetPluginId: "catalog"
181
- });
182
- const entity = await this.catalog.getEntityByRef(entityRef, { token });
183
- const ret = [];
184
- if (entity) {
185
- const userEntity = entity;
186
- if (userEntity.spec.profile?.email) {
187
- ret.push(userEntity.spec.profile.email);
188
- }
189
- }
190
- await this.cache?.set(`user-emails:${entityRef}`, ret, {
191
- ttl: this.cacheTtl
192
- });
193
- return ret;
194
- }
195
- async getRecipientEmails(notification, options) {
196
- let emails;
197
- if (options.recipients.type === "broadcast") {
198
- emails = await this.getBroadcastEmails();
199
- } else if (options.recipients.type === "entity" && !!notification.user) {
200
- emails = await this.getUserEmail(notification.user);
201
- } else {
202
- this.logger.info(
203
- `Unknown notification type ${options.recipients.type} or missing user.`
204
- );
205
- return [];
206
- }
207
- if (this.allowlistEmailAddresses) {
208
- emails = emails.filter(
209
- (email) => this.allowlistEmailAddresses?.includes(email)
210
- );
211
- }
212
- if (this.denylistEmailAddresses) {
213
- emails = emails.filter(
214
- (email) => !this.denylistEmailAddresses?.includes(email)
215
- );
216
- }
217
- return emails;
218
- }
219
- async sendMail(options) {
220
- try {
221
- this.logger.debug(`Sending notification email to ${options.to}`);
222
- await this.transporter.sendMail(options);
223
- } catch (e) {
224
- this.logger.error(`Failed to send email to ${options.to}: ${e}`);
225
- }
226
- }
227
- async sendMails(options, emails) {
228
- const throttle = pThrottle__default.default({
229
- limit: this.concurrencyLimit,
230
- interval: this.throttleInterval
231
- });
232
- const throttled = throttle((opts) => this.sendMail(opts));
233
- await Promise.all(
234
- emails.map((email) => throttled({ ...options, to: email }))
235
- );
236
- }
237
- getNotificationLink(notification) {
238
- if (notification.payload.link) {
239
- const stripLeadingSlash = (s) => s.replace(/^\//, "");
240
- const ensureTrailingSlash = (s) => s.replace(/\/?$/, "/");
241
- try {
242
- const url = new URL(
243
- stripLeadingSlash(notification.payload.link),
244
- ensureTrailingSlash(this.frontendBaseUrl)
245
- );
246
- return url.toString();
247
- } catch (_e) {
248
- }
249
- return notification.payload.link;
250
- }
251
- return `${this.frontendBaseUrl}/notifications`;
252
- }
253
- getHtmlContent(notification) {
254
- const contentParts = [];
255
- if (notification.payload.description) {
256
- contentParts.push(`${notification.payload.description}`);
257
- }
258
- const link = this.getNotificationLink(notification);
259
- contentParts.push(`<a href="${link}">${link}</a>`);
260
- return `<p>${contentParts.join("<br/>")}</p>`;
261
- }
262
- getTextContent(notification) {
263
- const contentParts = [];
264
- if (notification.payload.description) {
265
- contentParts.push(notification.payload.description);
266
- }
267
- contentParts.push(this.getNotificationLink(notification));
268
- return contentParts.join("\n\n");
269
- }
270
- async sendPlainEmail(notification, emails) {
271
- const mailOptions = {
272
- from: this.sender,
273
- subject: notification.payload.title,
274
- html: this.getHtmlContent(notification),
275
- text: this.getTextContent(notification),
276
- replyTo: this.replyTo
277
- };
278
- await this.sendMails(mailOptions, emails);
279
- }
280
- async sendTemplateEmail(notification, emails) {
281
- const mailOptions = {
282
- from: this.sender,
283
- subject: await this.templateRenderer?.getSubject?.(notification) ?? notification.payload.title,
284
- html: await this.templateRenderer?.getHtml?.(notification),
285
- text: await this.templateRenderer?.getText?.(notification),
286
- replyTo: this.replyTo
287
- };
288
- await this.sendMails(mailOptions, emails);
289
- }
290
- async postProcess(notification, options) {
291
- this.transporter = await this.getTransporter();
292
- let emails = [];
293
- try {
294
- emails = await this.getRecipientEmails(notification, options);
295
- } catch (e) {
296
- this.logger.error(`Failed to resolve recipient emails: ${e}`);
297
- return;
298
- }
299
- if (emails.length === 0) {
300
- this.logger.info(
301
- `No email recipients found for notification: ${notification.id}, skipping`
302
- );
303
- return;
304
- }
305
- this.logger.debug(`Sending notification emails to: ${emails.join(",")}`);
306
- if (!this.templateRenderer) {
307
- await this.sendPlainEmail(notification, emails);
308
- return;
309
- }
310
- await this.sendTemplateEmail(notification, emails);
311
- }
312
- getNotificationFilters() {
313
- return this.filter;
314
- }
315
- }
316
-
317
- const notificationsEmailTemplateExtensionPoint = backendPluginApi.createExtensionPoint({
318
- id: "notifications.email.templates"
319
- });
320
-
321
- const notificationsModuleEmail = backendPluginApi.createBackendModule({
322
- pluginId: "notifications",
323
- moduleId: "email",
324
- register(reg) {
325
- let templateRenderer;
326
- reg.registerExtensionPoint(notificationsEmailTemplateExtensionPoint, {
327
- setTemplateRenderer(renderer) {
328
- if (templateRenderer) {
329
- throw new Error(`Email template renderer was already registered`);
330
- }
331
- templateRenderer = renderer;
332
- }
333
- });
334
- reg.registerInit({
335
- deps: {
336
- config: backendPluginApi.coreServices.rootConfig,
337
- notifications: pluginNotificationsNode.notificationsProcessingExtensionPoint,
338
- logger: backendPluginApi.coreServices.logger,
339
- auth: backendPluginApi.coreServices.auth,
340
- cache: backendPluginApi.coreServices.cache,
341
- catalog: alpha.catalogServiceRef
342
- },
343
- async init({ config, notifications, logger, auth, cache, catalog }) {
344
- notifications.addProcessor(
345
- new NotificationsEmailProcessor(
346
- logger,
347
- config,
348
- catalog,
349
- auth,
350
- cache,
351
- templateRenderer
352
- )
353
- );
354
- }
355
- });
356
- }
357
- });
358
-
359
- exports.default = notificationsModuleEmail;
360
- exports.notificationsEmailTemplateExtensionPoint = notificationsEmailTemplateExtensionPoint;
10
+ exports.default = module$1.notificationsModuleEmail;
11
+ exports.notificationsEmailTemplateExtensionPoint = extensions.notificationsEmailTemplateExtensionPoint;
361
12
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/processor/transports/smtp.ts","../src/processor/transports/ses.ts","../src/processor/transports/sendmail.ts","../src/processor/transports/stream.ts","../src/processor/NotificationsEmailProcessor.ts","../src/extensions.ts","../src/module.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 { Config } from '@backstage/config';\n\nexport const createSmtpTransport = (config: Config) => {\n const username = config.getOptionalString('username');\n const password = config.getOptionalString('password');\n\n return createTransport({\n host: config.getString('hostname'),\n port: config.getNumber('port'),\n secure: config.getOptionalBoolean('secure') ?? false,\n requireTLS: config.getOptionalBoolean('requireTls') ?? false,\n auth: username && password ? { user: username, pass: password } : undefined,\n });\n};\n","/*\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 { SendRawEmailCommand, SES } from '@aws-sdk/client-ses';\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 const ses = new SES([\n {\n apiVersion: config.getOptionalString('apiVersion') ?? '2010-12-01',\n credentials: credentials.sdkCredentialProvider,\n region: config.getOptionalString('region'),\n },\n ]);\n return createTransport({\n SES: { ses, aws: { SendRawEmailCommand } },\n });\n};\n","/*\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 { Config } from '@backstage/config';\n\nexport const createSendmailTransport = (config: Config) => {\n return createTransport({\n sendmail: true,\n newline: config.getOptionalString('newline') ?? 'unix',\n path: config.getOptionalString('path') ?? '/usr/sbin/sendmail',\n });\n};\n","/*\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';\n\nexport const createStreamTransport = () => {\n return createTransport({ streamTransport: true });\n};\n","/*\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 {\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, CatalogApi } from '@backstage/catalog-client';\nimport {\n getProcessorFiltersFromConfig,\n Notification,\n NotificationProcessorFilters,\n} from '@backstage/plugin-notifications-common';\nimport {\n createSendmailTransport,\n createSesTransport,\n createSmtpTransport,\n createStreamTransport,\n} from './transports';\nimport { UserEntity } from '@backstage/catalog-model';\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 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: CatalogApi,\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.concurrencyLimit =\n emailProcessorConfig.getOptionalNumber('concurrencyLimit') ?? 2;\n const throttleConfig =\n emailProcessorConfig.getOptionalConfig('throttleInterval');\n this.throttleInterval = throttleConfig\n ? durationToMilliseconds(readDurationFromConfig(throttleConfig))\n : 100;\n const cacheConfig = emailProcessorConfig.getOptionalConfig('cache.ttl');\n this.cacheTtl = cacheConfig\n ? durationToMilliseconds(readDurationFromConfig(cacheConfig))\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 {\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 { token } = await this.auth.getPluginRequestToken({\n onBehalfOf: await this.auth.getOwnServiceCredentials(),\n targetPluginId: 'catalog',\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 { token },\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 { token } = await this.auth.getPluginRequestToken({\n onBehalfOf: await this.auth.getOwnServiceCredentials(),\n targetPluginId: 'catalog',\n });\n const entity = await this.catalog.getEntityByRef(entityRef, { token });\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 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 };\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 };\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","/*\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 { createExtensionPoint } from '@backstage/backend-plugin-api';\nimport { Notification } from '@backstage/plugin-notifications-common';\n\n/**\n * @public\n */\nexport interface NotificationTemplateRenderer {\n getSubject?(notification: Notification): Promise<string>;\n getText?(notification: Notification): Promise<string>;\n getHtml?(notification: Notification): Promise<string>;\n}\n\n/**\n * @public\n */\nexport interface NotificationsEmailTemplateExtensionPoint {\n setTemplateRenderer(renderer: NotificationTemplateRenderer): void;\n}\n\n/**\n * @public\n */\nexport const notificationsEmailTemplateExtensionPoint =\n createExtensionPoint<NotificationsEmailTemplateExtensionPoint>({\n id: 'notifications.email.templates',\n });\n","/*\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 {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha';\nimport { notificationsProcessingExtensionPoint } from '@backstage/plugin-notifications-node';\nimport { NotificationsEmailProcessor } from './processor';\nimport {\n notificationsEmailTemplateExtensionPoint,\n NotificationTemplateRenderer,\n} from './extensions';\n\n/**\n * @public\n */\nexport const notificationsModuleEmail = createBackendModule({\n pluginId: 'notifications',\n moduleId: 'email',\n register(reg) {\n let templateRenderer: NotificationTemplateRenderer | undefined;\n reg.registerExtensionPoint(notificationsEmailTemplateExtensionPoint, {\n setTemplateRenderer(renderer) {\n if (templateRenderer) {\n throw new Error(`Email template renderer was already registered`);\n }\n templateRenderer = renderer;\n },\n });\n\n reg.registerInit({\n deps: {\n config: coreServices.rootConfig,\n notifications: notificationsProcessingExtensionPoint,\n logger: coreServices.logger,\n auth: coreServices.auth,\n cache: coreServices.cache,\n catalog: catalogServiceRef,\n },\n async init({ config, notifications, logger, auth, cache, catalog }) {\n notifications.addProcessor(\n new NotificationsEmailProcessor(\n logger,\n config,\n catalog,\n auth,\n cache,\n templateRenderer,\n ),\n );\n },\n });\n },\n});\n"],"names":["createTransport","SES","SendRawEmailCommand","config","durationToMilliseconds","readDurationFromConfig","getProcessorFiltersFromConfig","DefaultAwsCredentialsManager","CATALOG_FILTER_EXISTS","compact","pThrottle","createExtensionPoint","createBackendModule","coreServices","notificationsProcessingExtensionPoint","catalogServiceRef"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkBa,MAAA,mBAAA,GAAsB,CAAC,MAAmB,KAAA;AACrD,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,iBAAA,CAAkB,UAAU,CAAA,CAAA;AACpD,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,i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YACA,KAAA;AAAA,YACA,gBAAA;AAAA,WACF;AAAA,SACF,CAAA;AAAA,OACF;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ var backendPluginApi = require('@backstage/backend-plugin-api');
4
+ var alpha = require('@backstage/plugin-catalog-node/alpha');
5
+ var pluginNotificationsNode = require('@backstage/plugin-notifications-node');
6
+ var NotificationsEmailProcessor = require('./processor/NotificationsEmailProcessor.cjs.js');
7
+ var extensions = require('./extensions.cjs.js');
8
+
9
+ const notificationsModuleEmail = backendPluginApi.createBackendModule({
10
+ pluginId: "notifications",
11
+ moduleId: "email",
12
+ register(reg) {
13
+ let templateRenderer;
14
+ reg.registerExtensionPoint(extensions.notificationsEmailTemplateExtensionPoint, {
15
+ setTemplateRenderer(renderer) {
16
+ if (templateRenderer) {
17
+ throw new Error(`Email template renderer was already registered`);
18
+ }
19
+ templateRenderer = renderer;
20
+ }
21
+ });
22
+ reg.registerInit({
23
+ deps: {
24
+ config: backendPluginApi.coreServices.rootConfig,
25
+ notifications: pluginNotificationsNode.notificationsProcessingExtensionPoint,
26
+ logger: backendPluginApi.coreServices.logger,
27
+ auth: backendPluginApi.coreServices.auth,
28
+ cache: backendPluginApi.coreServices.cache,
29
+ catalog: alpha.catalogServiceRef
30
+ },
31
+ async init({ config, notifications, logger, auth, cache, catalog }) {
32
+ notifications.addProcessor(
33
+ new NotificationsEmailProcessor.NotificationsEmailProcessor(
34
+ logger,
35
+ config,
36
+ catalog,
37
+ auth,
38
+ cache,
39
+ templateRenderer
40
+ )
41
+ );
42
+ }
43
+ });
44
+ }
45
+ });
46
+
47
+ exports.notificationsModuleEmail = notificationsModuleEmail;
48
+ //# sourceMappingURL=module.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.cjs.js","sources":["../src/module.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 {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha';\nimport { notificationsProcessingExtensionPoint } from '@backstage/plugin-notifications-node';\nimport { NotificationsEmailProcessor } from './processor';\nimport {\n notificationsEmailTemplateExtensionPoint,\n NotificationTemplateRenderer,\n} from './extensions';\n\n/**\n * @public\n */\nexport const notificationsModuleEmail = createBackendModule({\n pluginId: 'notifications',\n moduleId: 'email',\n register(reg) {\n let templateRenderer: NotificationTemplateRenderer | undefined;\n reg.registerExtensionPoint(notificationsEmailTemplateExtensionPoint, {\n setTemplateRenderer(renderer) {\n if (templateRenderer) {\n throw new Error(`Email template renderer was already registered`);\n }\n templateRenderer = renderer;\n },\n });\n\n reg.registerInit({\n deps: {\n config: coreServices.rootConfig,\n notifications: notificationsProcessingExtensionPoint,\n logger: coreServices.logger,\n auth: coreServices.auth,\n cache: coreServices.cache,\n catalog: catalogServiceRef,\n },\n async init({ config, notifications, logger, auth, cache, catalog }) {\n notifications.addProcessor(\n new NotificationsEmailProcessor(\n logger,\n config,\n catalog,\n auth,\n cache,\n templateRenderer,\n ),\n );\n },\n });\n },\n});\n"],"names":["createBackendModule","notificationsEmailTemplateExtensionPoint","coreServices","notificationsProcessingExtensionPoint","catalogServiceRef","NotificationsEmailProcessor"],"mappings":";;;;;;;;AA8BO,MAAM,2BAA2BA,oCAAoB,CAAA;AAAA,EAC1D,QAAU,EAAA,eAAA;AAAA,EACV,QAAU,EAAA,OAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAI,IAAA,gBAAA,CAAA;AACJ,IAAA,GAAA,CAAI,uBAAuBC,mDAA0C,EAAA;AAAA,MACnE,oBAAoB,QAAU,EAAA;AAC5B,QAAA,IAAI,gBAAkB,EAAA;AACpB,UAAM,MAAA,IAAI,MAAM,CAAgD,8CAAA,CAAA,CAAA,CAAA;AAAA,SAClE;AACA,QAAmB,gBAAA,GAAA,QAAA,CAAA;AAAA,OACrB;AAAA,KACD,CAAA,CAAA;AAED,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,QAAQC,6BAAa,CAAA,UAAA;AAAA,QACrB,aAAe,EAAAC,6DAAA;AAAA,QACf,QAAQD,6BAAa,CAAA,MAAA;AAAA,QACrB,MAAMA,6BAAa,CAAA,IAAA;AAAA,QACnB,OAAOA,6BAAa,CAAA,KAAA;AAAA,QACpB,OAAS,EAAAE,uBAAA;AAAA,OACX;AAAA,MACA,MAAM,KAAK,EAAE,MAAA,EAAQ,eAAe,MAAQ,EAAA,IAAA,EAAM,KAAO,EAAA,OAAA,EAAW,EAAA;AAClE,QAAc,aAAA,CAAA,YAAA;AAAA,UACZ,IAAIC,uDAAA;AAAA,YACF,MAAA;AAAA,YACA,MAAA;AAAA,YACA,OAAA;AAAA,YACA,IAAA;AAAA,YACA,KAAA;AAAA,YACA,gBAAA;AAAA,WACF;AAAA,SACF,CAAA;AAAA,OACF;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;"}
@@ -0,0 +1,275 @@
1
+ 'use strict';
2
+
3
+ var config = require('@backstage/config');
4
+ var types = require('@backstage/types');
5
+ var catalogClient = require('@backstage/catalog-client');
6
+ var pluginNotificationsCommon = require('@backstage/plugin-notifications-common');
7
+ var smtp = require('./transports/smtp.cjs.js');
8
+ var ses = require('./transports/ses.cjs.js');
9
+ var sendmail = require('./transports/sendmail.cjs.js');
10
+ var stream = require('./transports/stream.cjs.js');
11
+ var lodash = require('lodash');
12
+ var integrationAwsNode = require('@backstage/integration-aws-node');
13
+ var pThrottle = require('p-throttle');
14
+
15
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
16
+
17
+ var pThrottle__default = /*#__PURE__*/_interopDefaultCompat(pThrottle);
18
+
19
+ class NotificationsEmailProcessor {
20
+ constructor(logger, config$1, catalog, auth, cache, templateRenderer) {
21
+ this.logger = logger;
22
+ this.config = config$1;
23
+ this.catalog = catalog;
24
+ this.auth = auth;
25
+ this.cache = cache;
26
+ this.templateRenderer = templateRenderer;
27
+ const emailProcessorConfig = config$1.getConfig(
28
+ "notifications.processors.email"
29
+ );
30
+ this.transportConfig = emailProcessorConfig.getConfig("transportConfig");
31
+ this.broadcastConfig = emailProcessorConfig.getOptionalConfig("broadcastConfig");
32
+ this.sender = emailProcessorConfig.getString("sender");
33
+ this.replyTo = emailProcessorConfig.getOptionalString("replyTo");
34
+ this.concurrencyLimit = emailProcessorConfig.getOptionalNumber("concurrencyLimit") ?? 2;
35
+ const throttleConfig = emailProcessorConfig.getOptionalConfig("throttleInterval");
36
+ this.throttleInterval = throttleConfig ? types.durationToMilliseconds(config.readDurationFromConfig(throttleConfig)) : 100;
37
+ const cacheConfig = emailProcessorConfig.getOptionalConfig("cache.ttl");
38
+ this.cacheTtl = cacheConfig ? types.durationToMilliseconds(config.readDurationFromConfig(cacheConfig)) : 36e5;
39
+ this.frontendBaseUrl = config$1.getString("app.baseUrl");
40
+ this.allowlistEmailAddresses = emailProcessorConfig.getOptionalStringArray(
41
+ "allowlistEmailAddresses"
42
+ );
43
+ this.denylistEmailAddresses = emailProcessorConfig.getOptionalStringArray(
44
+ "denylistEmailAddresses"
45
+ );
46
+ this.filter = pluginNotificationsCommon.getProcessorFiltersFromConfig(emailProcessorConfig);
47
+ }
48
+ transporter;
49
+ broadcastConfig;
50
+ transportConfig;
51
+ sender;
52
+ replyTo;
53
+ cacheTtl;
54
+ concurrencyLimit;
55
+ throttleInterval;
56
+ frontendBaseUrl;
57
+ filter;
58
+ allowlistEmailAddresses;
59
+ denylistEmailAddresses;
60
+ async getTransporter() {
61
+ if (this.transporter) {
62
+ return this.transporter;
63
+ }
64
+ const transport = this.transportConfig.getString("transport");
65
+ if (transport === "smtp") {
66
+ this.transporter = smtp.createSmtpTransport(this.transportConfig);
67
+ } else if (transport === "ses") {
68
+ const awsCredentialsManager = integrationAwsNode.DefaultAwsCredentialsManager.fromConfig(
69
+ this.config
70
+ );
71
+ this.transporter = await ses.createSesTransport(
72
+ this.transportConfig,
73
+ awsCredentialsManager
74
+ );
75
+ } else if (transport === "sendmail") {
76
+ this.transporter = sendmail.createSendmailTransport(this.transportConfig);
77
+ } else if (transport === "stream") {
78
+ this.transporter = stream.createStreamTransport();
79
+ } else {
80
+ throw new Error(`Unsupported transport: ${transport}`);
81
+ }
82
+ return this.transporter;
83
+ }
84
+ getName() {
85
+ return "Email";
86
+ }
87
+ async getBroadcastEmails() {
88
+ if (!this.broadcastConfig) {
89
+ return [];
90
+ }
91
+ const receiver = this.broadcastConfig.getString("receiver");
92
+ if (receiver === "none") {
93
+ return [];
94
+ }
95
+ if (receiver === "config") {
96
+ return this.broadcastConfig.getOptionalStringArray("receiverEmails") ?? [];
97
+ }
98
+ if (receiver === "users") {
99
+ const cached = await this.cache?.get("user-emails:all");
100
+ if (cached) {
101
+ return cached;
102
+ }
103
+ const { token } = await this.auth.getPluginRequestToken({
104
+ onBehalfOf: await this.auth.getOwnServiceCredentials(),
105
+ targetPluginId: "catalog"
106
+ });
107
+ const entities = await this.catalog.getEntities(
108
+ {
109
+ filter: [
110
+ { kind: "user", "spec.profile.email": catalogClient.CATALOG_FILTER_EXISTS }
111
+ ],
112
+ fields: ["spec.profile.email"]
113
+ },
114
+ { token }
115
+ );
116
+ const ret = lodash.compact([
117
+ ...new Set(
118
+ entities.items.map((entity) => {
119
+ return entity?.spec.profile?.email;
120
+ })
121
+ )
122
+ ]);
123
+ await this.cache?.set("user-emails:all", ret, {
124
+ ttl: this.cacheTtl
125
+ });
126
+ return ret;
127
+ }
128
+ throw new Error(`Unsupported broadcast receiver: ${receiver}`);
129
+ }
130
+ async getUserEmail(entityRef) {
131
+ const cached = await this.cache?.get(`user-emails:${entityRef}`);
132
+ if (cached) {
133
+ return cached;
134
+ }
135
+ const { token } = await this.auth.getPluginRequestToken({
136
+ onBehalfOf: await this.auth.getOwnServiceCredentials(),
137
+ targetPluginId: "catalog"
138
+ });
139
+ const entity = await this.catalog.getEntityByRef(entityRef, { token });
140
+ const ret = [];
141
+ if (entity) {
142
+ const userEntity = entity;
143
+ if (userEntity.spec.profile?.email) {
144
+ ret.push(userEntity.spec.profile.email);
145
+ }
146
+ }
147
+ await this.cache?.set(`user-emails:${entityRef}`, ret, {
148
+ ttl: this.cacheTtl
149
+ });
150
+ return ret;
151
+ }
152
+ async getRecipientEmails(notification, options) {
153
+ let emails;
154
+ if (options.recipients.type === "broadcast") {
155
+ emails = await this.getBroadcastEmails();
156
+ } else if (options.recipients.type === "entity" && !!notification.user) {
157
+ emails = await this.getUserEmail(notification.user);
158
+ } else {
159
+ this.logger.info(
160
+ `Unknown notification type ${options.recipients.type} or missing user.`
161
+ );
162
+ return [];
163
+ }
164
+ if (this.allowlistEmailAddresses) {
165
+ emails = emails.filter(
166
+ (email) => this.allowlistEmailAddresses?.includes(email)
167
+ );
168
+ }
169
+ if (this.denylistEmailAddresses) {
170
+ emails = emails.filter(
171
+ (email) => !this.denylistEmailAddresses?.includes(email)
172
+ );
173
+ }
174
+ return emails;
175
+ }
176
+ async sendMail(options) {
177
+ try {
178
+ this.logger.debug(`Sending notification email to ${options.to}`);
179
+ await this.transporter.sendMail(options);
180
+ } catch (e) {
181
+ this.logger.error(`Failed to send email to ${options.to}: ${e}`);
182
+ }
183
+ }
184
+ async sendMails(options, emails) {
185
+ const throttle = pThrottle__default.default({
186
+ limit: this.concurrencyLimit,
187
+ interval: this.throttleInterval
188
+ });
189
+ const throttled = throttle((opts) => this.sendMail(opts));
190
+ await Promise.all(
191
+ emails.map((email) => throttled({ ...options, to: email }))
192
+ );
193
+ }
194
+ getNotificationLink(notification) {
195
+ if (notification.payload.link) {
196
+ const stripLeadingSlash = (s) => s.replace(/^\//, "");
197
+ const ensureTrailingSlash = (s) => s.replace(/\/?$/, "/");
198
+ try {
199
+ const url = new URL(
200
+ stripLeadingSlash(notification.payload.link),
201
+ ensureTrailingSlash(this.frontendBaseUrl)
202
+ );
203
+ return url.toString();
204
+ } catch (_e) {
205
+ }
206
+ return notification.payload.link;
207
+ }
208
+ return `${this.frontendBaseUrl}/notifications`;
209
+ }
210
+ getHtmlContent(notification) {
211
+ const contentParts = [];
212
+ if (notification.payload.description) {
213
+ contentParts.push(`${notification.payload.description}`);
214
+ }
215
+ const link = this.getNotificationLink(notification);
216
+ contentParts.push(`<a href="${link}">${link}</a>`);
217
+ return `<p>${contentParts.join("<br/>")}</p>`;
218
+ }
219
+ getTextContent(notification) {
220
+ const contentParts = [];
221
+ if (notification.payload.description) {
222
+ contentParts.push(notification.payload.description);
223
+ }
224
+ contentParts.push(this.getNotificationLink(notification));
225
+ return contentParts.join("\n\n");
226
+ }
227
+ async sendPlainEmail(notification, emails) {
228
+ const mailOptions = {
229
+ from: this.sender,
230
+ subject: notification.payload.title,
231
+ html: this.getHtmlContent(notification),
232
+ text: this.getTextContent(notification),
233
+ replyTo: this.replyTo
234
+ };
235
+ await this.sendMails(mailOptions, emails);
236
+ }
237
+ async sendTemplateEmail(notification, emails) {
238
+ const mailOptions = {
239
+ from: this.sender,
240
+ subject: await this.templateRenderer?.getSubject?.(notification) ?? notification.payload.title,
241
+ html: await this.templateRenderer?.getHtml?.(notification),
242
+ text: await this.templateRenderer?.getText?.(notification),
243
+ replyTo: this.replyTo
244
+ };
245
+ await this.sendMails(mailOptions, emails);
246
+ }
247
+ async postProcess(notification, options) {
248
+ this.transporter = await this.getTransporter();
249
+ let emails = [];
250
+ try {
251
+ emails = await this.getRecipientEmails(notification, options);
252
+ } catch (e) {
253
+ this.logger.error(`Failed to resolve recipient emails: ${e}`);
254
+ return;
255
+ }
256
+ if (emails.length === 0) {
257
+ this.logger.info(
258
+ `No email recipients found for notification: ${notification.id}, skipping`
259
+ );
260
+ return;
261
+ }
262
+ this.logger.debug(`Sending notification emails to: ${emails.join(",")}`);
263
+ if (!this.templateRenderer) {
264
+ await this.sendPlainEmail(notification, emails);
265
+ return;
266
+ }
267
+ await this.sendTemplateEmail(notification, emails);
268
+ }
269
+ getNotificationFilters() {
270
+ return this.filter;
271
+ }
272
+ }
273
+
274
+ exports.NotificationsEmailProcessor = NotificationsEmailProcessor;
275
+ //# sourceMappingURL=NotificationsEmailProcessor.cjs.js.map
@@ -0,0 +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 */\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, CatalogApi } from '@backstage/catalog-client';\nimport {\n getProcessorFiltersFromConfig,\n Notification,\n NotificationProcessorFilters,\n} from '@backstage/plugin-notifications-common';\nimport {\n createSendmailTransport,\n createSesTransport,\n createSmtpTransport,\n createStreamTransport,\n} from './transports';\nimport { UserEntity } from '@backstage/catalog-model';\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 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: CatalogApi,\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.concurrencyLimit =\n emailProcessorConfig.getOptionalNumber('concurrencyLimit') ?? 2;\n const throttleConfig =\n emailProcessorConfig.getOptionalConfig('throttleInterval');\n this.throttleInterval = throttleConfig\n ? durationToMilliseconds(readDurationFromConfig(throttleConfig))\n : 100;\n const cacheConfig = emailProcessorConfig.getOptionalConfig('cache.ttl');\n this.cacheTtl = cacheConfig\n ? durationToMilliseconds(readDurationFromConfig(cacheConfig))\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 {\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 { token } = await this.auth.getPluginRequestToken({\n onBehalfOf: await this.auth.getOwnServiceCredentials(),\n targetPluginId: 'catalog',\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 { token },\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 { token } = await this.auth.getPluginRequestToken({\n onBehalfOf: await this.auth.getOwnServiceCredentials(),\n targetPluginId: 'catalog',\n });\n const entity = await this.catalog.getEntityByRef(entityRef, { token });\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 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 };\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 };\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","CATALOG_FILTER_EXISTS","compact","pThrottle"],"mappings":";;;;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
+
3
+ var nodemailer = require('nodemailer');
4
+
5
+ const createSendmailTransport = (config) => {
6
+ return nodemailer.createTransport({
7
+ sendmail: true,
8
+ newline: config.getOptionalString("newline") ?? "unix",
9
+ path: config.getOptionalString("path") ?? "/usr/sbin/sendmail"
10
+ });
11
+ };
12
+
13
+ exports.createSendmailTransport = createSendmailTransport;
14
+ //# sourceMappingURL=sendmail.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sendmail.cjs.js","sources":["../../../src/processor/transports/sendmail.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 { Config } from '@backstage/config';\n\nexport const createSendmailTransport = (config: Config) => {\n return createTransport({\n sendmail: true,\n newline: config.getOptionalString('newline') ?? 'unix',\n path: config.getOptionalString('path') ?? '/usr/sbin/sendmail',\n });\n};\n"],"names":["createTransport"],"mappings":";;;;AAkBa,MAAA,uBAAA,GAA0B,CAAC,MAAmB,KAAA;AACzD,EAAA,OAAOA,0BAAgB,CAAA;AAAA,IACrB,QAAU,EAAA,IAAA;AAAA,IACV,OAAS,EAAA,MAAA,CAAO,iBAAkB,CAAA,SAAS,CAAK,IAAA,MAAA;AAAA,IAChD,IAAM,EAAA,MAAA,CAAO,iBAAkB,CAAA,MAAM,CAAK,IAAA,oBAAA;AAAA,GAC3C,CAAA,CAAA;AACH;;;;"}
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var nodemailer = require('nodemailer');
4
+ var clientSes = require('@aws-sdk/client-ses');
5
+
6
+ const createSesTransport = async (config, credentialsManager) => {
7
+ const credentials = await credentialsManager.getCredentialProvider({
8
+ accountId: config.getOptionalString("accountId")
9
+ });
10
+ const ses = new clientSes.SES([
11
+ {
12
+ apiVersion: config.getOptionalString("apiVersion") ?? "2010-12-01",
13
+ credentials: credentials.sdkCredentialProvider,
14
+ region: config.getOptionalString("region")
15
+ }
16
+ ]);
17
+ return nodemailer.createTransport({
18
+ SES: { ses, aws: { SendRawEmailCommand: clientSes.SendRawEmailCommand } }
19
+ });
20
+ };
21
+
22
+ exports.createSesTransport = createSesTransport;
23
+ //# sourceMappingURL=ses.cjs.js.map
@@ -0,0 +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 { SendRawEmailCommand, SES } from '@aws-sdk/client-ses';\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 const ses = new SES([\n {\n apiVersion: config.getOptionalString('apiVersion') ?? '2010-12-01',\n credentials: credentials.sdkCredentialProvider,\n region: config.getOptionalString('region'),\n },\n ]);\n return createTransport({\n SES: { ses, aws: { SendRawEmailCommand } },\n });\n};\n"],"names":["SES","createTransport","SendRawEmailCommand"],"mappings":";;;;;AAoBa,MAAA,kBAAA,GAAqB,OAChC,MAAA,EACA,kBACG,KAAA;AACH,EAAM,MAAA,WAAA,GAAc,MAAM,kBAAA,CAAmB,qBAAsB,CAAA;AAAA,IACjE,SAAA,EAAW,MAAO,CAAA,iBAAA,CAAkB,WAAW,CAAA;AAAA,GAChD,CAAA,CAAA;AACD,EAAM,MAAA,GAAA,GAAM,IAAIA,aAAI,CAAA;AAAA,IAClB;AAAA,MACE,UAAY,EAAA,MAAA,CAAO,iBAAkB,CAAA,YAAY,CAAK,IAAA,YAAA;AAAA,MACtD,aAAa,WAAY,CAAA,qBAAA;AAAA,MACzB,MAAA,EAAQ,MAAO,CAAA,iBAAA,CAAkB,QAAQ,CAAA;AAAA,KAC3C;AAAA,GACD,CAAA,CAAA;AACD,EAAA,OAAOC,0BAAgB,CAAA;AAAA,IACrB,KAAK,EAAE,GAAA,EAAK,GAAK,EAAA,uBAAEC,+BAAsB,EAAA;AAAA,GAC1C,CAAA,CAAA;AACH;;;;"}
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ var nodemailer = require('nodemailer');
4
+
5
+ const createSmtpTransport = (config) => {
6
+ const username = config.getOptionalString("username");
7
+ const password = config.getOptionalString("password");
8
+ return nodemailer.createTransport({
9
+ host: config.getString("hostname"),
10
+ port: config.getNumber("port"),
11
+ secure: config.getOptionalBoolean("secure") ?? false,
12
+ requireTLS: config.getOptionalBoolean("requireTls") ?? false,
13
+ auth: username && password ? { user: username, pass: password } : void 0
14
+ });
15
+ };
16
+
17
+ exports.createSmtpTransport = createSmtpTransport;
18
+ //# sourceMappingURL=smtp.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smtp.cjs.js","sources":["../../../src/processor/transports/smtp.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 { Config } from '@backstage/config';\n\nexport const createSmtpTransport = (config: Config) => {\n const username = config.getOptionalString('username');\n const password = config.getOptionalString('password');\n\n return createTransport({\n host: config.getString('hostname'),\n port: config.getNumber('port'),\n secure: config.getOptionalBoolean('secure') ?? false,\n requireTLS: config.getOptionalBoolean('requireTls') ?? false,\n auth: username && password ? { user: username, pass: password } : undefined,\n });\n};\n"],"names":["createTransport"],"mappings":";;;;AAkBa,MAAA,mBAAA,GAAsB,CAAC,MAAmB,KAAA;AACrD,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,iBAAA,CAAkB,UAAU,CAAA,CAAA;AACpD,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,iBAAA,CAAkB,UAAU,CAAA,CAAA;AAEpD,EAAA,OAAOA,0BAAgB,CAAA;AAAA,IACrB,IAAA,EAAM,MAAO,CAAA,SAAA,CAAU,UAAU,CAAA;AAAA,IACjC,IAAA,EAAM,MAAO,CAAA,SAAA,CAAU,MAAM,CAAA;AAAA,IAC7B,MAAQ,EAAA,MAAA,CAAO,kBAAmB,CAAA,QAAQ,CAAK,IAAA,KAAA;AAAA,IAC/C,UAAY,EAAA,MAAA,CAAO,kBAAmB,CAAA,YAAY,CAAK,IAAA,KAAA;AAAA,IACvD,IAAA,EAAM,YAAY,QAAW,GAAA,EAAE,MAAM,QAAU,EAAA,IAAA,EAAM,UAAa,GAAA,KAAA,CAAA;AAAA,GACnE,CAAA,CAAA;AACH;;;;"}
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var nodemailer = require('nodemailer');
4
+
5
+ const createStreamTransport = () => {
6
+ return nodemailer.createTransport({ streamTransport: true });
7
+ };
8
+
9
+ exports.createStreamTransport = createStreamTransport;
10
+ //# sourceMappingURL=stream.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.cjs.js","sources":["../../../src/processor/transports/stream.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';\n\nexport const createStreamTransport = () => {\n return createTransport({ streamTransport: true });\n};\n"],"names":["createTransport"],"mappings":";;;;AAiBO,MAAM,wBAAwB,MAAM;AACzC,EAAA,OAAOA,0BAAgB,CAAA,EAAE,eAAiB,EAAA,IAAA,EAAM,CAAA,CAAA;AAClD;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-notifications-backend-module-email",
3
- "version": "0.3.1-next.0",
3
+ "version": "0.3.1-next.1",
4
4
  "description": "The email backend module for the notifications plugin.",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -37,22 +37,22 @@
37
37
  "@aws-sdk/client-ses": "^3.550.0",
38
38
  "@aws-sdk/types": "^3.347.0",
39
39
  "@backstage/backend-common": "^0.25.0",
40
- "@backstage/backend-plugin-api": "^1.0.1-next.0",
41
- "@backstage/catalog-client": "^1.7.0",
42
- "@backstage/catalog-model": "^1.7.0",
43
- "@backstage/config": "^1.2.0",
44
- "@backstage/integration-aws-node": "^0.1.12",
45
- "@backstage/plugin-catalog-node": "^1.13.1-next.0",
46
- "@backstage/plugin-notifications-common": "^0.0.5",
47
- "@backstage/plugin-notifications-node": "^0.2.7-next.0",
48
- "@backstage/types": "^1.1.1",
40
+ "@backstage/backend-plugin-api": "1.0.1-next.1",
41
+ "@backstage/catalog-client": "1.7.1-next.0",
42
+ "@backstage/catalog-model": "1.7.0",
43
+ "@backstage/config": "1.2.0",
44
+ "@backstage/integration-aws-node": "0.1.12",
45
+ "@backstage/plugin-catalog-node": "1.13.1-next.1",
46
+ "@backstage/plugin-notifications-common": "0.0.5",
47
+ "@backstage/plugin-notifications-node": "0.2.7-next.1",
48
+ "@backstage/types": "1.1.1",
49
49
  "lodash": "^4.17.21",
50
50
  "nodemailer": "^6.9.13",
51
51
  "p-throttle": "^4.1.1"
52
52
  },
53
53
  "devDependencies": {
54
- "@backstage/backend-test-utils": "^1.0.1-next.0",
55
- "@backstage/cli": "^0.28.0-next.0",
54
+ "@backstage/backend-test-utils": "1.0.1-next.2",
55
+ "@backstage/cli": "0.28.0-next.2",
56
56
  "@types/nodemailer": "^6.4.14"
57
57
  },
58
58
  "configSchema": "config.d.ts"