@checkfirst/nestjs-outlook 2.0.0 → 3.1.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.
Files changed (66) hide show
  1. package/README.md +196 -21
  2. package/dist/controllers/calendar.controller.d.ts +10 -0
  3. package/dist/controllers/calendar.controller.js +166 -0
  4. package/dist/controllers/calendar.controller.js.map +1 -0
  5. package/dist/controllers/email.controller.d.ts +10 -0
  6. package/dist/controllers/email.controller.js +166 -0
  7. package/dist/controllers/email.controller.js.map +1 -0
  8. package/dist/controllers/microsoft-auth.controller.d.ts +3 -2
  9. package/dist/controllers/microsoft-auth.controller.js +15 -13
  10. package/dist/controllers/microsoft-auth.controller.js.map +1 -1
  11. package/dist/dto/outlook-webhook-notification.dto.d.ts +5 -0
  12. package/dist/dto/outlook-webhook-notification.dto.js +39 -1
  13. package/dist/dto/outlook-webhook-notification.dto.js.map +1 -1
  14. package/dist/entities/outlook-webhook-subscription.entity.js +3 -4
  15. package/dist/entities/outlook-webhook-subscription.entity.js.map +1 -1
  16. package/dist/{event-types.enum.d.ts → enums/event-types.enum.d.ts} +4 -1
  17. package/dist/{event-types.enum.js → enums/event-types.enum.js} +3 -0
  18. package/dist/enums/event-types.enum.js.map +1 -0
  19. package/dist/enums/permission-scope.enum.d.ts +7 -0
  20. package/dist/enums/permission-scope.enum.js +12 -0
  21. package/dist/enums/permission-scope.enum.js.map +1 -0
  22. package/dist/index.d.ts +9 -5
  23. package/dist/index.js +9 -5
  24. package/dist/index.js.map +1 -1
  25. package/dist/interfaces/config/outlook-config.interface.d.ts +1 -1
  26. package/dist/interfaces/microsoft-auth/state-object.interface.d.ts +4 -2
  27. package/dist/microsoft-outlook.module.js +9 -6
  28. package/dist/microsoft-outlook.module.js.map +1 -1
  29. package/dist/migrations/1697025846000-CreateOutlookTables.js +2 -1
  30. package/dist/migrations/1697025846000-CreateOutlookTables.js.map +1 -1
  31. package/dist/migrations/1697026000000-EnsureUniqueSubscriptions.d.ts +5 -0
  32. package/dist/migrations/1697026000000-EnsureUniqueSubscriptions.js +27 -0
  33. package/dist/migrations/1697026000000-EnsureUniqueSubscriptions.js.map +1 -0
  34. package/dist/repositories/outlook-webhook-subscription.repository.js +14 -1
  35. package/dist/repositories/outlook-webhook-subscription.repository.js.map +1 -1
  36. package/dist/services/auth/index.d.ts +1 -0
  37. package/dist/services/auth/index.js +18 -0
  38. package/dist/services/auth/index.js.map +1 -0
  39. package/dist/services/auth/microsoft-auth.service.d.ts +41 -0
  40. package/dist/services/{microsoft-auth.service.js → auth/microsoft-auth.service.js} +110 -37
  41. package/dist/services/auth/microsoft-auth.service.js.map +1 -0
  42. package/dist/services/{outlook.service.d.ts → calendar/calendar.service.d.ts} +6 -6
  43. package/dist/services/{outlook.service.js → calendar/calendar.service.js} +96 -66
  44. package/dist/services/calendar/calendar.service.js.map +1 -0
  45. package/dist/services/calendar/index.d.ts +1 -0
  46. package/dist/services/calendar/index.js +18 -0
  47. package/dist/services/calendar/index.js.map +1 -0
  48. package/dist/services/email/email.service.d.ts +24 -0
  49. package/dist/services/email/email.service.js +207 -0
  50. package/dist/services/email/email.service.js.map +1 -0
  51. package/dist/services/email/index.d.ts +1 -0
  52. package/dist/services/email/index.js +18 -0
  53. package/dist/services/email/index.js.map +1 -0
  54. package/dist/services/index.d.ts +3 -0
  55. package/dist/services/index.js +20 -0
  56. package/dist/services/index.js.map +1 -0
  57. package/dist/tsconfig.tsbuildinfo +1 -1
  58. package/dist/types/microsoft-graph.types.d.ts +1 -1
  59. package/package.json +11 -6
  60. package/dist/controllers/outlook.controller.d.ts +0 -8
  61. package/dist/controllers/outlook.controller.js +0 -117
  62. package/dist/controllers/outlook.controller.js.map +0 -1
  63. package/dist/event-types.enum.js.map +0 -1
  64. package/dist/services/microsoft-auth.service.d.ts +0 -32
  65. package/dist/services/microsoft-auth.service.js.map +0 -1
  66. package/dist/services/outlook.service.js.map +0 -1
package/README.md CHANGED
@@ -18,6 +18,7 @@ An opinionated NestJS module for Microsoft Outlook integration that provides eas
18
18
 
19
19
  - 🔄 Simplified Microsoft OAuth flow
20
20
  - 📅 Calendar events management
21
+ - 📧 Email sending capabilities
21
22
  - 🔔 Real-time webhooks for changes
22
23
  - 🔐 Secure token storage and refresh
23
24
 
@@ -79,7 +80,20 @@ export class CreateOutlookTables1697025846000 implements MigrationInterface {
79
80
 
80
81
  You can customize this migration to match your database dialect (PostgreSQL, MySQL, etc.) if needed.
81
82
 
82
- ### 2. Import Required Modules
83
+ ### 2. Microsoft App Registration
84
+
85
+ Register your application in the Azure Portal to get a client ID and secret:
86
+
87
+ 1. Go to the [Azure Portal](https://portal.azure.com/)
88
+ 2. Navigate to Azure Active Directory > App registrations
89
+ 3. Create a new registration
90
+ 4. Configure redirects to include your callback URL
91
+ 5. Add the following Microsoft Graph API permissions:
92
+ - `Calendars.ReadWrite` - For calendar operations
93
+ - `Mail.Send` - For sending emails
94
+ - `offline_access` - For refresh tokens
95
+
96
+ ### 3. Import Required Modules
83
97
 
84
98
  Register the module in your NestJS application and include the module entities in TypeORM:
85
99
 
@@ -122,34 +136,154 @@ const outlookPackagePath = path.dirname(require.resolve('@checkfirst/nestjs-outl
122
136
  export class AppModule {}
123
137
  ```
124
138
 
125
- ### 3. Create a Login Controller
139
+ ### 4. Create an Auth Controller
126
140
 
127
- Create a controller to handle Microsoft authentication:
141
+ The library provides a MicrosoftAuthController for handling authentication, but you can also create your own:
128
142
 
129
143
  ```typescript
130
- export class CalendarController {
144
+ import { Controller, Get, Req } from '@nestjs/common';
145
+ import { MicrosoftAuthService, PermissionScope } from '@checkfirst/nestjs-outlook';
146
+
147
+ @Controller('auth')
148
+ export class AuthController {
131
149
  constructor(
132
150
  private readonly microsoftAuthService: MicrosoftAuthService
133
151
  ) {}
134
152
 
135
- @UseGuards(AuthGuard)
136
- @Get('auth/microsoft/login')
137
- async login(@Req() req: Request) {
138
- const user = req.user as UserTokenPayload;
139
- if (!user?.id) {
140
- throw new ForbiddenException('User not authenticated');
141
- }
153
+ @Get('microsoft/login')
154
+ async login(@Req() req: any) {
155
+ // In a real application, get the user ID from your authentication system
156
+ const userId = req.user?.id.toString() || '1';
142
157
 
143
- // Get the login URL from the Microsoft auth service
144
- return await this.microsoftAuthService.getLoginUrl(user.id.toString());
158
+ // Get the login URL with specific permission scopes
159
+ return await this.microsoftAuthService.getLoginUrl(userId, [
160
+ PermissionScope.CALENDAR_READ,
161
+ PermissionScope.EMAIL_READ,
162
+ PermissionScope.EMAIL_SEND
163
+ ]);
145
164
  }
146
165
  }
147
166
  ```
148
167
 
149
- ## Available Services
168
+ ## Permission Scopes
169
+
170
+ The library provides a flexible permission system that allows you to request only the specific permissions your application needs:
171
+
172
+ ```typescript
173
+ import { PermissionScope } from '@checkfirst/nestjs-outlook';
174
+
175
+ // Available permission scopes:
176
+ PermissionScope.CALENDAR_READ // Read-only access to calendars
177
+ PermissionScope.CALENDAR_WRITE // Read-write access to calendars
178
+ PermissionScope.EMAIL_READ // Read-only access to emails
179
+ PermissionScope.EMAIL_WRITE // Read-write access to emails
180
+ PermissionScope.EMAIL_SEND // Permission to send emails
181
+ ```
182
+
183
+ When requesting login URLs, you can specify exactly which permissions you need:
150
184
 
151
- - `OutlookService` - Main service for Microsoft Graph API operations on Outlook
152
- - `MicrosoftAuthService` - For authentication and token management
185
+ ```typescript
186
+ // For a calendar-only app
187
+ const loginUrl = await microsoftAuthService.getLoginUrl(userId, [
188
+ PermissionScope.CALENDAR_READ
189
+ ]);
190
+
191
+ // For an email-only app
192
+ const loginUrl = await microsoftAuthService.getLoginUrl(userId, [
193
+ PermissionScope.EMAIL_SEND
194
+ ]);
195
+ ```
196
+
197
+ The system will automatically include the necessary base permissions (`offline_access` and `User.Read`) and map your requested permissions to the appropriate Microsoft Graph API scopes.
198
+
199
+ ## Available Services and Controllers
200
+
201
+ The library provides specialized services and controllers for Microsoft Graph API operations:
202
+
203
+ ### 1. MicrosoftAuthService and MicrosoftAuthController
204
+
205
+ Handle authentication, token management, and OAuth flow:
206
+
207
+ ```typescript
208
+ // Initiate the OAuth flow - redirects user to Microsoft login
209
+ const loginUrl = await microsoftAuthService.getLoginUrl(userId);
210
+
211
+ // Exchange OAuth code for tokens (used in callback endpoint)
212
+ const tokens = await microsoftAuthService.exchangeCodeForToken(code, state);
213
+
214
+ // Refresh an expired access token
215
+ const newTokens = await microsoftAuthService.refreshAccessToken(refreshToken, userId);
216
+
217
+ // Check if a token is expired
218
+ const isExpired = microsoftAuthService.isTokenExpired(tokenExpiryDate);
219
+ ```
220
+
221
+ ### 2. CalendarService and CalendarController
222
+
223
+ Manage calendar operations with Microsoft Graph API:
224
+
225
+ ```typescript
226
+ // Create a calendar event
227
+ const event = {
228
+ subject: 'Team Meeting',
229
+ start: {
230
+ dateTime: '2023-06-01T10:00:00',
231
+ timeZone: 'UTC',
232
+ },
233
+ end: {
234
+ dateTime: '2023-06-01T11:00:00',
235
+ timeZone: 'UTC',
236
+ },
237
+ };
238
+
239
+ const result = await calendarService.createEvent(
240
+ event,
241
+ accessToken,
242
+ refreshToken,
243
+ tokenExpiry,
244
+ userId,
245
+ calendarId
246
+ );
247
+
248
+ // Get user's default calendar ID
249
+ const calendarId = await calendarService.getDefaultCalendarId(accessToken);
250
+
251
+ // Create webhook subscription for calendar events
252
+ await calendarService.createWebhookSubscription(userId, accessToken, refreshToken);
253
+ ```
254
+
255
+ The CalendarController provides a webhook endpoint at `/calendar/webhook` for receiving notifications from Microsoft Graph about calendar changes.
256
+
257
+ ### 3. EmailService
258
+
259
+ Provides email sending capabilities via Microsoft Graph API:
260
+
261
+ ```typescript
262
+ // Create email message
263
+ const message = {
264
+ subject: 'Hello from NestJS Outlook',
265
+ body: {
266
+ contentType: 'HTML',
267
+ content: '<p>This is the email body</p>'
268
+ },
269
+ toRecipients: [
270
+ {
271
+ emailAddress: {
272
+ address: 'recipient@example.com'
273
+ }
274
+ }
275
+ ]
276
+ };
277
+
278
+ // Send the email
279
+ const result = await emailService.sendEmail(
280
+ message,
281
+ accessToken,
282
+ refreshToken,
283
+ tokenExpiry,
284
+ userId
285
+ );
286
+ ```
153
287
 
154
288
  ## Events
155
289
 
@@ -172,31 +306,72 @@ You can listen to these events in your application using the `@OnEvent` decorato
172
306
  ```typescript
173
307
  import { Injectable } from '@nestjs/common';
174
308
  import { OnEvent } from '@nestjs/event-emitter';
175
- import { OutlookEventTypes, OutlookResourceData } from '@checkfirst/nestjs-outlook';
309
+ import { OutlookEventTypes, OutlookResourceData, TokenResponse } from '@checkfirst/nestjs-outlook';
176
310
 
177
311
  @Injectable()
178
312
  export class YourService {
313
+ // Handle token save event
314
+ @OnEvent(OutlookEventTypes.AUTH_TOKENS_SAVE)
315
+ async handleAuthTokensSave(userId: string, tokenData: TokenResponse) {
316
+ console.log(`Saving new tokens for user ${userId}`);
317
+ // Save tokens to your database
318
+ }
319
+
320
+ // Handle calendar events
179
321
  @OnEvent(OutlookEventTypes.EVENT_CREATED)
180
322
  handleOutlookEventCreated(data: OutlookResourceData) {
181
323
  console.log('New Outlook event created:', data.id);
182
- // Handle the new event...
324
+ // Handle the new event
183
325
  }
184
326
 
185
327
  @OnEvent(OutlookEventTypes.EVENT_UPDATED)
186
328
  handleOutlookEventUpdated(data: OutlookResourceData) {
187
329
  console.log('Outlook event updated:', data.id);
188
- // Handle the updated event...
330
+ // Handle the updated event
189
331
  }
190
332
 
191
333
  @OnEvent(OutlookEventTypes.EVENT_DELETED)
192
334
  handleOutlookEventDeleted(data: OutlookResourceData) {
193
335
  console.log('Outlook event deleted:', data.id);
194
- // Handle the deleted event...
336
+ // Handle the deleted event
195
337
  }
196
338
  }
197
339
  ```
198
340
 
199
- These events are emitted when Microsoft Graph sends webhook notifications to your application for calendar events changes.
341
+ ## Example Application Architecture
342
+
343
+ For a more complete example of how to structure your application using this library, check out the sample application included in this repository:
344
+
345
+ **Path:** `samples/nestjs-outlook-example/`
346
+
347
+ The sample app demonstrates a modular architecture with clear separation of concerns:
348
+
349
+ ```
350
+ src/
351
+ ├── auth/
352
+ │ ├── auth.controller.ts # Handles Microsoft login and OAuth callback
353
+ │ └── auth.module.ts # Configures MicrosoftOutlookModule for auth
354
+
355
+ ├── calendar/
356
+ │ ├── calendar.controller.ts # API endpoints for calendar operations
357
+ │ ├── calendar.module.ts # Configures MicrosoftOutlookModule for calendar
358
+ │ ├── calendar.service.ts # Your business logic for calendars
359
+ │ └── dto/
360
+ │ └── create-event.dto.ts # Data validation for event creation
361
+
362
+ ├── email/
363
+ │ ├── email.controller.ts # API endpoints for email operations
364
+ │ ├── email.module.ts # Configures MicrosoftOutlookModule for email
365
+ │ ├── email.service.ts # Your business logic for emails
366
+ │ └── dto/
367
+ │ └── send-email.dto.ts # Data validation for email sending
368
+
369
+ └── app.module.ts # Root module that imports feature modules
370
+ ```
371
+
372
+ > **See:** [`samples/nestjs-outlook-example`](./samples/nestjs-outlook-example) for a full working example.
373
+
374
+ This modular architecture keeps concerns separated and makes your application easier to maintain and test.
200
375
 
201
376
  ## Support
202
377
 
@@ -0,0 +1,10 @@
1
+ import { Response, Request } from 'express';
2
+ import { CalendarService } from '../services/calendar/calendar.service';
3
+ import { OutlookWebhookNotificationDto } from '../dto/outlook-webhook-notification.dto';
4
+ export declare class CalendarController {
5
+ private readonly calendarService;
6
+ private readonly logger;
7
+ constructor(calendarService: CalendarService);
8
+ handleCalendarWebhook(validationToken: string, notificationBody: OutlookWebhookNotificationDto, req: Request, res: Response): Promise<void>;
9
+ private processCalendarNotificationBatch;
10
+ }
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var CalendarController_1;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.CalendarController = void 0;
17
+ const common_1 = require("@nestjs/common");
18
+ const swagger_1 = require("@nestjs/swagger");
19
+ const calendar_service_1 = require("../services/calendar/calendar.service");
20
+ const outlook_webhook_notification_dto_1 = require("../dto/outlook-webhook-notification.dto");
21
+ let CalendarController = CalendarController_1 = class CalendarController {
22
+ constructor(calendarService) {
23
+ this.calendarService = calendarService;
24
+ this.logger = new common_1.Logger(CalendarController_1.name);
25
+ }
26
+ async handleCalendarWebhook(validationToken, notificationBody, req, res) {
27
+ if (validationToken) {
28
+ this.logger.log('Handling Microsoft Graph validation request');
29
+ const decodedToken = decodeURIComponent(validationToken);
30
+ res.set('Content-Type', 'text/plain; charset=utf-8');
31
+ res.send(decodedToken);
32
+ return;
33
+ }
34
+ try {
35
+ this.logger.debug(`Received webhook notification: ${JSON.stringify(notificationBody)}`);
36
+ if (Array.isArray(notificationBody.value) && notificationBody.value.length > 2) {
37
+ this.logger.log(`Received batch of ${notificationBody.value.length.toString()} notifications, responding with 202 Accepted`);
38
+ res.status(202).json({
39
+ success: true,
40
+ message: 'Notifications accepted for processing',
41
+ });
42
+ this.processCalendarNotificationBatch(notificationBody).catch((error) => {
43
+ const errorMessage = error instanceof Error ? error.message : String(error);
44
+ this.logger.error(`Error processing notification batch: ${errorMessage}`);
45
+ });
46
+ return;
47
+ }
48
+ if (Array.isArray(notificationBody.value) && notificationBody.value.length > 0) {
49
+ const results = await this.processCalendarNotificationBatch(notificationBody);
50
+ res.json({
51
+ success: true,
52
+ message: `Processed ${results.successCount.toString()} out of ${notificationBody.value.length.toString()} notifications`,
53
+ });
54
+ return;
55
+ }
56
+ this.logger.warn('Received webhook notification with unexpected format');
57
+ res.json({
58
+ success: true,
59
+ message: `Received webhook notification with unexpected format`,
60
+ });
61
+ }
62
+ catch (error) {
63
+ const errorMessage = error instanceof Error ? error.message : String(error);
64
+ const errorStack = error instanceof Error ? error.stack : undefined;
65
+ this.logger.error(`Error processing webhook notification: ${errorMessage}`, errorStack);
66
+ res.status(500).json({
67
+ success: false,
68
+ message: 'Error processing webhook notification',
69
+ });
70
+ }
71
+ }
72
+ async processCalendarNotificationBatch(notificationBody) {
73
+ let successCount = 0;
74
+ let failureCount = 0;
75
+ const processedEvents = new Set();
76
+ for (const item of notificationBody.value) {
77
+ if (!item.subscriptionId || !item.resource) {
78
+ this.logger.warn(`Skipping notification with missing required fields`);
79
+ failureCount++;
80
+ continue;
81
+ }
82
+ const resourceData = item.resourceData;
83
+ if (resourceData.id && processedEvents.has(resourceData.id)) {
84
+ this.logger.debug(`Skipping duplicate event: ${resourceData.id}`);
85
+ continue;
86
+ }
87
+ if (resourceData.id) {
88
+ processedEvents.add(resourceData.id);
89
+ }
90
+ const validChangeTypes = ['created', 'updated', 'deleted'];
91
+ if (!validChangeTypes.includes(item.changeType)) {
92
+ this.logger.warn(`Skipping notification with unsupported change type: ${item.changeType}`);
93
+ failureCount++;
94
+ continue;
95
+ }
96
+ try {
97
+ const changeNotification = {
98
+ subscriptionId: item.subscriptionId,
99
+ subscriptionExpirationDateTime: item.subscriptionExpirationDateTime,
100
+ changeType: item.changeType,
101
+ resource: item.resource,
102
+ resourceData: resourceData,
103
+ clientState: item.clientState,
104
+ tenantId: item.tenantId,
105
+ };
106
+ const result = await this.calendarService.handleOutlookWebhook(changeNotification);
107
+ if (result.success) {
108
+ this.logger.log(`Successfully processed ${item.changeType} event for resource ID: ${resourceData.id || 'unknown'}`);
109
+ successCount++;
110
+ }
111
+ else {
112
+ this.logger.warn(`Failed to process event: ${result.message}`);
113
+ failureCount++;
114
+ }
115
+ }
116
+ catch (error) {
117
+ const errorMessage = error instanceof Error ? error.message : String(error);
118
+ this.logger.error(`Error processing event: ${errorMessage}`);
119
+ failureCount++;
120
+ }
121
+ }
122
+ this.logger.log(`Finished processing batch: ${successCount.toString()} succeeded, ${failureCount.toString()} failed`);
123
+ return { successCount, failureCount };
124
+ }
125
+ };
126
+ exports.CalendarController = CalendarController;
127
+ __decorate([
128
+ (0, common_1.Post)('webhook'),
129
+ (0, common_1.HttpCode)(200),
130
+ (0, swagger_1.ApiResponse)({
131
+ status: 200,
132
+ description: 'Webhook validation or notification processed successfully',
133
+ }),
134
+ (0, swagger_1.ApiResponse)({
135
+ status: 202,
136
+ description: 'Notification accepted for processing',
137
+ }),
138
+ (0, swagger_1.ApiResponse)({
139
+ status: 500,
140
+ description: 'Server error processing the notification',
141
+ }),
142
+ (0, swagger_1.ApiQuery)({
143
+ name: 'validationToken',
144
+ required: false,
145
+ description: 'Token sent by Microsoft Graph to validate the webhook endpoint',
146
+ }),
147
+ (0, swagger_1.ApiBody)({
148
+ description: 'Microsoft Graph webhook notification payload',
149
+ type: outlook_webhook_notification_dto_1.OutlookWebhookNotificationDto,
150
+ required: false,
151
+ }),
152
+ __param(0, (0, common_1.Query)('validationToken')),
153
+ __param(1, (0, common_1.Body)()),
154
+ __param(2, (0, common_1.Req)()),
155
+ __param(3, (0, common_1.Res)()),
156
+ __metadata("design:type", Function),
157
+ __metadata("design:paramtypes", [String, outlook_webhook_notification_dto_1.OutlookWebhookNotificationDto, Object, Object]),
158
+ __metadata("design:returntype", Promise)
159
+ ], CalendarController.prototype, "handleCalendarWebhook", null);
160
+ exports.CalendarController = CalendarController = CalendarController_1 = __decorate([
161
+ (0, swagger_1.ApiTags)('Calendar'),
162
+ (0, common_1.Controller)('calendar'),
163
+ (0, common_1.Injectable)(),
164
+ __metadata("design:paramtypes", [calendar_service_1.CalendarService])
165
+ ], CalendarController);
166
+ //# sourceMappingURL=calendar.controller.js.map
@@ -0,0 +1 @@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,CAAC,CAAC;QACtH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;IACxC,CAAC;CACF,CAAA;AAvLY,gDAAkB;AA0CvB;IAxBL,IAAA,aAAI,EAAC,SAAS,CAAC;IACf,IAAA,iBAAQ,EAAC,GAAG,CAAC;IACb,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,2DAA2D;KACzE,CAAC;IACD,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,sCAAsC;KACpD,CAAC;IACD,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,0CAA0C;KACxD,CAAC;IACD,IAAA,kBAAQ,EAAC;QACR,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE,KAAK;QACf,WAAW,EAAE,gEAAgE;KAC9E,CAAC;IACD,IAAA,iBAAO,EAAC;QACP,WAAW,EAAE,8CAA8C;QAC3D,IAAI,EAAE,gEAA6B;QACnC,QAAQ,EAAE,KAAK;KAChB,CAAC;IAEC,WAAA,IAAA,cAAK,EAAC,iBAAiB,CAAC,CAAA;IACxB,WAAA,IAAA,aAAI,GAAE,CAAA;IACN,WAAA,IAAA,YAAG,GAAE,CAAA;IACL,WAAA,IAAA,YAAG,GAAE,CAAA;;6CAFoB,gEAA6B;;+DA6DxD;6BAzGU,kBAAkB;IAH9B,IAAA,iBAAO,EAAC,UAAU,CAAC;IACnB,IAAA,mBAAU,EAAC,UAAU,CAAC;IACtB,IAAA,mBAAU,GAAE;qCAImC,kCAAe;GAHlD,kBAAkB,CAuL9B"}
@@ -0,0 +1,10 @@
1
+ import { Response, Request } from 'express';
2
+ import { EmailService } from '../services/email/email.service';
3
+ import { OutlookWebhookNotificationDto } from '../dto/outlook-webhook-notification.dto';
4
+ export declare class EmailController {
5
+ private readonly emailService;
6
+ private readonly logger;
7
+ constructor(emailService: EmailService);
8
+ handleEmailWebhook(validationToken: string, notificationBody: OutlookWebhookNotificationDto, req: Request, res: Response): Promise<void>;
9
+ private processEmailNotificationBatch;
10
+ }
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var EmailController_1;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.EmailController = void 0;
17
+ const common_1 = require("@nestjs/common");
18
+ const swagger_1 = require("@nestjs/swagger");
19
+ const email_service_1 = require("../services/email/email.service");
20
+ const outlook_webhook_notification_dto_1 = require("../dto/outlook-webhook-notification.dto");
21
+ let EmailController = EmailController_1 = class EmailController {
22
+ constructor(emailService) {
23
+ this.emailService = emailService;
24
+ this.logger = new common_1.Logger(EmailController_1.name);
25
+ }
26
+ async handleEmailWebhook(validationToken, notificationBody, req, res) {
27
+ if (validationToken) {
28
+ this.logger.log('Handling Microsoft Graph validation request');
29
+ const decodedToken = decodeURIComponent(validationToken);
30
+ res.set('Content-Type', 'text/plain; charset=utf-8');
31
+ res.send(decodedToken);
32
+ return;
33
+ }
34
+ try {
35
+ this.logger.debug(`Received email webhook notification: ${JSON.stringify(notificationBody)}`);
36
+ if (Array.isArray(notificationBody.value) && notificationBody.value.length > 2) {
37
+ this.logger.log(`Received batch of ${notificationBody.value.length.toString()} email notifications, responding with 202 Accepted`);
38
+ res.status(202).json({
39
+ success: true,
40
+ message: 'Email notifications accepted for processing',
41
+ });
42
+ this.processEmailNotificationBatch(notificationBody).catch((error) => {
43
+ const errorMessage = error instanceof Error ? error.message : String(error);
44
+ this.logger.error(`Error processing email notification batch: ${errorMessage}`);
45
+ });
46
+ return;
47
+ }
48
+ if (Array.isArray(notificationBody.value) && notificationBody.value.length > 0) {
49
+ const results = await this.processEmailNotificationBatch(notificationBody);
50
+ res.json({
51
+ success: true,
52
+ message: `Processed ${results.successCount.toString()} out of ${notificationBody.value.length.toString()} email notifications`,
53
+ });
54
+ return;
55
+ }
56
+ this.logger.warn('Received email webhook notification with unexpected format');
57
+ res.json({
58
+ success: true,
59
+ message: `Received email webhook notification with unexpected format`,
60
+ });
61
+ }
62
+ catch (error) {
63
+ const errorMessage = error instanceof Error ? error.message : String(error);
64
+ const errorStack = error instanceof Error ? error.stack : undefined;
65
+ this.logger.error(`Error processing email webhook notification: ${errorMessage}`, errorStack);
66
+ res.status(500).json({
67
+ success: false,
68
+ message: 'Error processing email webhook notification',
69
+ });
70
+ }
71
+ }
72
+ async processEmailNotificationBatch(notificationBody) {
73
+ let successCount = 0;
74
+ let failureCount = 0;
75
+ const processedMessages = new Set();
76
+ for (const item of notificationBody.value) {
77
+ if (!item.subscriptionId || !item.resource) {
78
+ this.logger.warn(`Skipping email notification with missing required fields`);
79
+ failureCount++;
80
+ continue;
81
+ }
82
+ const resourceData = item.resourceData;
83
+ if (resourceData.id && processedMessages.has(resourceData.id)) {
84
+ this.logger.debug(`Skipping duplicate email: ${resourceData.id}`);
85
+ continue;
86
+ }
87
+ if (resourceData.id) {
88
+ processedMessages.add(resourceData.id);
89
+ }
90
+ const validChangeTypes = ['created', 'updated', 'deleted'];
91
+ if (!validChangeTypes.includes(item.changeType)) {
92
+ this.logger.warn(`Skipping email notification with unsupported change type: ${item.changeType}`);
93
+ failureCount++;
94
+ continue;
95
+ }
96
+ try {
97
+ const changeNotification = {
98
+ subscriptionId: item.subscriptionId,
99
+ subscriptionExpirationDateTime: item.subscriptionExpirationDateTime,
100
+ changeType: item.changeType,
101
+ resource: item.resource,
102
+ resourceData: resourceData,
103
+ clientState: item.clientState,
104
+ tenantId: item.tenantId,
105
+ };
106
+ const result = await this.emailService.handleEmailWebhook(changeNotification);
107
+ if (result.success) {
108
+ this.logger.log(`Successfully processed ${item.changeType} email for resource ID: ${resourceData.id || 'unknown'}`);
109
+ successCount++;
110
+ }
111
+ else {
112
+ this.logger.warn(`Failed to process email: ${result.message}`);
113
+ failureCount++;
114
+ }
115
+ }
116
+ catch (error) {
117
+ const errorMessage = error instanceof Error ? error.message : String(error);
118
+ this.logger.error(`Error processing email event: ${errorMessage}`);
119
+ failureCount++;
120
+ }
121
+ }
122
+ this.logger.log(`Finished processing email batch: ${successCount.toString()} succeeded, ${failureCount.toString()} failed`);
123
+ return { successCount, failureCount };
124
+ }
125
+ };
126
+ exports.EmailController = EmailController;
127
+ __decorate([
128
+ (0, common_1.Post)('webhook'),
129
+ (0, common_1.HttpCode)(200),
130
+ (0, swagger_1.ApiResponse)({
131
+ status: 200,
132
+ description: 'Webhook validation or notification processed successfully',
133
+ }),
134
+ (0, swagger_1.ApiResponse)({
135
+ status: 202,
136
+ description: 'Notification accepted for processing',
137
+ }),
138
+ (0, swagger_1.ApiResponse)({
139
+ status: 500,
140
+ description: 'Server error processing the notification',
141
+ }),
142
+ (0, swagger_1.ApiQuery)({
143
+ name: 'validationToken',
144
+ required: false,
145
+ description: 'Token sent by Microsoft Graph to validate the webhook endpoint',
146
+ }),
147
+ (0, swagger_1.ApiBody)({
148
+ description: 'Microsoft Graph webhook notification payload',
149
+ type: outlook_webhook_notification_dto_1.OutlookWebhookNotificationDto,
150
+ required: false,
151
+ }),
152
+ __param(0, (0, common_1.Query)('validationToken')),
153
+ __param(1, (0, common_1.Body)()),
154
+ __param(2, (0, common_1.Req)()),
155
+ __param(3, (0, common_1.Res)()),
156
+ __metadata("design:type", Function),
157
+ __metadata("design:paramtypes", [String, outlook_webhook_notification_dto_1.OutlookWebhookNotificationDto, Object, Object]),
158
+ __metadata("design:returntype", Promise)
159
+ ], EmailController.prototype, "handleEmailWebhook", null);
160
+ exports.EmailController = EmailController = EmailController_1 = __decorate([
161
+ (0, swagger_1.ApiTags)('Email'),
162
+ (0, common_1.Controller)('email'),
163
+ (0, common_1.Injectable)(),
164
+ __metadata("design:paramtypes", [email_service_1.EmailService])
165
+ ], EmailController);
166
+ //# sourceMappingURL=email.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email.controller.js","sourceRoot":"","sources":["../../src/controllers/email.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAuG;AACvG,6CAA0E;AAE1E,mEAA+D;AAE/D,8FAAwF;AAKjF,IAAM,eAAe,uBAArB,MAAM,eAAe;IAG1B,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;QAFtC,WAAM,GAAG,IAAI,eAAM,CAAC,iBAAe,CAAC,IAAI,CAAC,CAAC;IAED,CAAC;IAuCrD,AAAN,KAAK,CAAC,kBAAkB,CACI,eAAuB,EACzC,gBAA+C,EAChD,GAAY,EACZ,GAAa;QAGpB,IAAI,eAAe,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;YAG/D,MAAM,YAAY,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAAC;YACzD,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,2BAA2B,CAAC,CAAC;YACrD,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACvB,OAAO;QACT,CAAC;QAGD,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,wCAAwC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;YAI9F,IAAI,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,KAAK,C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AC,OAAO,CAAC;IAChB,IAAA,mBAAU,EAAC,OAAO,CAAC;IACnB,IAAA,mBAAU,GAAE;qCAIgC,4BAAY;GAH5C,eAAe,CAuL3B"}
@@ -1,7 +1,8 @@
1
1
  import { Response } from 'express';
2
- import { MicrosoftAuthService } from '../services/microsoft-auth.service';
2
+ import { MicrosoftAuthService } from '../services/auth/microsoft-auth.service';
3
3
  export declare class MicrosoftAuthController {
4
4
  private readonly microsoftAuthService;
5
+ private readonly logger;
5
6
  constructor(microsoftAuthService: MicrosoftAuthService);
6
- callback(code: string, state: string, res: Response): Promise<Response<any, Record<string, any>>>;
7
+ handleOauthCallback(code: string, state: string, res: Response): Promise<Response<any, Record<string, any>>>;
7
8
  }