@checkfirst/nestjs-outlook 3.1.0 → 4.0.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 (29) hide show
  1. package/README.md +48 -103
  2. package/dist/entities/microsoft-user.entity.d.ts +11 -0
  3. package/dist/entities/microsoft-user.entity.js +67 -0
  4. package/dist/entities/microsoft-user.entity.js.map +1 -0
  5. package/dist/entities/outlook-webhook-subscription.entity.d.ts +0 -2
  6. package/dist/entities/outlook-webhook-subscription.entity.js +0 -10
  7. package/dist/entities/outlook-webhook-subscription.entity.js.map +1 -1
  8. package/dist/enums/event-types.enum.d.ts +1 -2
  9. package/dist/enums/event-types.enum.js +1 -2
  10. package/dist/enums/event-types.enum.js.map +1 -1
  11. package/dist/microsoft-outlook.module.js +6 -1
  12. package/dist/microsoft-outlook.module.js.map +1 -1
  13. package/dist/migrations/1699000000000-AddMicrosoftUserTable.d.ts +5 -0
  14. package/dist/migrations/1699000000000-AddMicrosoftUserTable.js +104 -0
  15. package/dist/migrations/1699000000000-AddMicrosoftUserTable.js.map +1 -0
  16. package/dist/repositories/outlook-webhook-subscription.repository.d.ts +1 -1
  17. package/dist/repositories/outlook-webhook-subscription.repository.js +1 -4
  18. package/dist/repositories/outlook-webhook-subscription.repository.js.map +1 -1
  19. package/dist/services/auth/microsoft-auth.service.d.ts +10 -4
  20. package/dist/services/auth/microsoft-auth.service.js +137 -53
  21. package/dist/services/auth/microsoft-auth.service.js.map +1 -1
  22. package/dist/services/calendar/calendar.service.d.ts +6 -8
  23. package/dist/services/calendar/calendar.service.js +48 -57
  24. package/dist/services/calendar/calendar.service.js.map +1 -1
  25. package/dist/services/email/email.service.d.ts +2 -5
  26. package/dist/services/email/email.service.js +16 -36
  27. package/dist/services/email/email.service.js.map +1 -1
  28. package/dist/tsconfig.tsbuildinfo +1 -1
  29. package/package.json +1 -1
package/README.md CHANGED
@@ -16,11 +16,11 @@ An opinionated NestJS module for Microsoft Outlook integration that provides eas
16
16
 
17
17
  ## Features
18
18
 
19
- - 🔄 Simplified Microsoft OAuth flow
20
- - 📅 Calendar events management
21
- - 📧 Email sending capabilities
22
- - 🔔 Real-time webhooks for changes
23
- - 🔐 Secure token storage and refresh
19
+ - 🔗 Simple Microsoft authentication integration
20
+ - 📅 Calendar management (create/update/delete events)
21
+ - 📧 Email sending with rich content
22
+ - 🔔 Real-time notifications via webhooks
23
+ - 🔍 Event-driven architecture for easy integration
24
24
 
25
25
  ## Installation
26
26
 
@@ -32,66 +32,42 @@ npm install @checkfirst/nestjs-outlook
32
32
 
33
33
  ### 1. Database Setup
34
34
 
35
- This library requires two database tables in your application's database. Create these tables using a migration:
35
+ This library requires database tables to store authentication and subscription data. You can use the built-in migrations to set up these tables automatically.
36
+
37
+ For details, see the [Migration Guide](src/migrations/README.md).
38
+
39
+ Alternatively, you can create the tables manually based on your database dialect (PostgreSQL, MySQL, etc.):
36
40
 
37
41
  ```typescript
38
42
  import { MigrationInterface, QueryRunner } from 'typeorm';
39
43
 
40
44
  export class CreateOutlookTables1697025846000 implements MigrationInterface {
41
45
  public async up(queryRunner: QueryRunner): Promise<void> {
42
- // Create outlook_webhook_subscriptions table
43
- await queryRunner.query(`
44
- CREATE TABLE outlook_webhook_subscriptions (
45
- id INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
46
- subscription_id VARCHAR(255) NOT NULL,
47
- user_id INTEGER NOT NULL,
48
- resource VARCHAR(255) NOT NULL,
49
- change_type VARCHAR(255) NOT NULL,
50
- client_state VARCHAR(255) NOT NULL,
51
- notification_url VARCHAR(255) NOT NULL,
52
- expiration_date_time TIMESTAMP NOT NULL,
53
- is_active BOOLEAN DEFAULT true,
54
- access_token TEXT,
55
- refresh_token TEXT,
56
- created_at TIMESTAMP DEFAULT NOW() NOT NULL,
57
- updated_at TIMESTAMP DEFAULT NOW() NOT NULL
58
- );
59
- `);
60
-
61
- // Create microsoft_csrf_tokens table
62
- await queryRunner.query(`
63
- CREATE TABLE microsoft_csrf_tokens (
64
- id INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
65
- token VARCHAR(64) NOT NULL,
66
- user_id VARCHAR(255) NOT NULL,
67
- expires TIMESTAMP NOT NULL,
68
- created_at TIMESTAMP DEFAULT NOW() NOT NULL,
69
- CONSTRAINT "UQ_microsoft_csrf_tokens_token" UNIQUE (token)
70
- );
71
- `);
46
+ // Create required tables for webhooks, authentication, and user data
47
+ // See the Migration Guide for details
72
48
  }
73
49
 
74
50
  public async down(queryRunner: QueryRunner): Promise<void> {
51
+ // Drop tables in reverse order
75
52
  await queryRunner.query(`DROP TABLE IF EXISTS outlook_webhook_subscriptions`);
76
53
  await queryRunner.query(`DROP TABLE IF EXISTS microsoft_csrf_tokens`);
54
+ await queryRunner.query(`DROP TABLE IF EXISTS microsoft_users`);
77
55
  }
78
56
  }
79
57
  ```
80
58
 
81
- You can customize this migration to match your database dialect (PostgreSQL, MySQL, etc.) if needed.
82
-
83
59
  ### 2. Microsoft App Registration
84
60
 
85
- Register your application in the Azure Portal to get a client ID and secret:
61
+ Register your application with Microsoft to get the necessary credentials:
86
62
 
87
63
  1. Go to the [Azure Portal](https://portal.azure.com/)
88
64
  2. Navigate to Azure Active Directory > App registrations
89
65
  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
66
+ 4. Configure redirects to include your callback URL (e.g., `https://your-api.example.com/auth/microsoft/callback`)
67
+ 5. Add Microsoft Graph API permissions based on what features you need:
68
+ - `Calendars.ReadWrite` - For calendar features
69
+ - `Mail.Send` - For email features
70
+ - `offline_access` - Required for all applications
95
71
 
96
72
  ### 3. Import Required Modules
97
73
 
@@ -167,7 +143,7 @@ export class AuthController {
167
143
 
168
144
  ## Permission Scopes
169
145
 
170
- The library provides a flexible permission system that allows you to request only the specific permissions your application needs:
146
+ You can request specific Microsoft permissions based on what your application needs:
171
147
 
172
148
  ```typescript
173
149
  import { PermissionScope } from '@checkfirst/nestjs-outlook';
@@ -180,7 +156,7 @@ PermissionScope.EMAIL_WRITE // Read-write access to emails
180
156
  PermissionScope.EMAIL_SEND // Permission to send emails
181
157
  ```
182
158
 
183
- When requesting login URLs, you can specify exactly which permissions you need:
159
+ When getting a login URL, specify which permissions you need:
184
160
 
185
161
  ```typescript
186
162
  // For a calendar-only app
@@ -194,33 +170,24 @@ const loginUrl = await microsoftAuthService.getLoginUrl(userId, [
194
170
  ]);
195
171
  ```
196
172
 
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
173
  ## Available Services and Controllers
200
174
 
201
- The library provides specialized services and controllers for Microsoft Graph API operations:
175
+ The library provides specialized services and controllers for Microsoft integration:
202
176
 
203
177
  ### 1. MicrosoftAuthService and MicrosoftAuthController
204
178
 
205
- Handle authentication, token management, and OAuth flow:
179
+ Handles the authentication flow with Microsoft:
206
180
 
207
181
  ```typescript
208
- // Initiate the OAuth flow - redirects user to Microsoft login
182
+ // Get a login URL to redirect your user to Microsoft's OAuth page
209
183
  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
184
  ```
220
185
 
186
+ After the user authenticates with Microsoft, they'll be redirected to your callback URL where you can complete the process.
187
+
221
188
  ### 2. CalendarService and CalendarController
222
189
 
223
- Manage calendar operations with Microsoft Graph API:
190
+ Manage calendar operations:
224
191
 
225
192
  ```typescript
226
193
  // Create a calendar event
@@ -236,27 +203,22 @@ const event = {
236
203
  },
237
204
  };
238
205
 
206
+ // Create the event
239
207
  const result = await calendarService.createEvent(
240
208
  event,
241
- accessToken,
242
- refreshToken,
243
- tokenExpiry,
244
- userId,
209
+ externalUserId,
245
210
  calendarId
246
211
  );
247
212
 
248
213
  // 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);
214
+ const calendarId = await calendarService.getDefaultCalendarId(externalUserId);
253
215
  ```
254
216
 
255
217
  The CalendarController provides a webhook endpoint at `/calendar/webhook` for receiving notifications from Microsoft Graph about calendar changes.
256
218
 
257
219
  ### 3. EmailService
258
220
 
259
- Provides email sending capabilities via Microsoft Graph API:
221
+ Send emails:
260
222
 
261
223
  ```typescript
262
224
  // Create email message
@@ -278,63 +240,46 @@ const message = {
278
240
  // Send the email
279
241
  const result = await emailService.sendEmail(
280
242
  message,
281
- accessToken,
282
- refreshToken,
283
- tokenExpiry,
284
- userId
243
+ externalUserId
285
244
  );
286
245
  ```
287
246
 
288
247
  ## Events
289
248
 
290
- The library uses NestJS's EventEmitter to emit events for various Outlook activities. You can listen to these events in your application to react to changes.
249
+ The library emits events for various Microsoft activities that you can listen to in your application.
291
250
 
292
251
  ### Available Events
293
252
 
294
- The library exposes event types through the `OutlookEventTypes` enum:
295
-
296
- - `OutlookEventTypes.AUTH_TOKENS_SAVE` - Emitted when OAuth tokens are initially saved
297
- - `OutlookEventTypes.AUTH_TOKENS_UPDATE` - Emitted when OAuth tokens are refreshed
298
- - `OutlookEventTypes.EVENT_CREATED` - Emitted when a new Outlook calendar event is created via webhook
299
- - `OutlookEventTypes.EVENT_UPDATED` - Emitted when an Outlook calendar event is updated via webhook
300
- - `OutlookEventTypes.EVENT_DELETED` - Emitted when an Outlook calendar event is deleted via webhook
253
+ - `USER_AUTHENTICATED` - When a user completes authentication with Microsoft
254
+ - `EVENT_CREATED` - When a new calendar event is created
255
+ - `EVENT_UPDATED` - When a calendar event is updated
256
+ - `EVENT_DELETED` - When a calendar event is deleted
257
+ - `EMAIL_RECEIVED` - When a new email is received
258
+ - `EMAIL_UPDATED` - When an email is updated
259
+ - `EMAIL_DELETED` - When an email is deleted
301
260
 
302
261
  ### Listening to Events
303
262
 
304
- You can listen to these events in your application using the `@OnEvent` decorator from `@nestjs/event-emitter` and the `OutlookEventTypes` enum:
305
-
306
263
  ```typescript
307
264
  import { Injectable } from '@nestjs/common';
308
265
  import { OnEvent } from '@nestjs/event-emitter';
309
- import { OutlookEventTypes, OutlookResourceData, TokenResponse } from '@checkfirst/nestjs-outlook';
266
+ import { OutlookEventTypes, OutlookResourceData } from '@checkfirst/nestjs-outlook';
310
267
 
311
268
  @Injectable()
312
269
  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
270
+ // Handle user authentication event
271
+ @OnEvent(OutlookEventTypes.USER_AUTHENTICATED)
272
+ async handleUserAuthenticated(externalUserId: string, data: { externalUserId: string, scopes: string[] }) {
273
+ console.log(`User ${externalUserId} authenticated with Microsoft`);
274
+ // Perform any custom logic needed when a user authenticates
318
275
  }
319
276
 
320
277
  // Handle calendar events
321
278
  @OnEvent(OutlookEventTypes.EVENT_CREATED)
322
279
  handleOutlookEventCreated(data: OutlookResourceData) {
323
- console.log('New Outlook event created:', data.id);
280
+ console.log('New calendar event created:', data.id);
324
281
  // Handle the new event
325
282
  }
326
-
327
- @OnEvent(OutlookEventTypes.EVENT_UPDATED)
328
- handleOutlookEventUpdated(data: OutlookResourceData) {
329
- console.log('Outlook event updated:', data.id);
330
- // Handle the updated event
331
- }
332
-
333
- @OnEvent(OutlookEventTypes.EVENT_DELETED)
334
- handleOutlookEventDeleted(data: OutlookResourceData) {
335
- console.log('Outlook event deleted:', data.id);
336
- // Handle the deleted event
337
- }
338
283
  }
339
284
  ```
340
285
 
@@ -0,0 +1,11 @@
1
+ export declare class MicrosoftUser {
2
+ id: number;
3
+ externalUserId: string;
4
+ accessToken: string;
5
+ refreshToken: string;
6
+ tokenExpiry: Date;
7
+ scopes: string;
8
+ isActive: boolean;
9
+ createdAt: Date;
10
+ updatedAt: Date;
11
+ }
@@ -0,0 +1,67 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MicrosoftUser = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ let MicrosoftUser = class MicrosoftUser {
15
+ constructor() {
16
+ this.externalUserId = '';
17
+ this.accessToken = '';
18
+ this.refreshToken = '';
19
+ this.tokenExpiry = new Date();
20
+ this.scopes = '';
21
+ this.isActive = true;
22
+ this.createdAt = new Date();
23
+ this.updatedAt = new Date();
24
+ }
25
+ };
26
+ exports.MicrosoftUser = MicrosoftUser;
27
+ __decorate([
28
+ (0, typeorm_1.PrimaryGeneratedColumn)('increment'),
29
+ __metadata("design:type", Number)
30
+ ], MicrosoftUser.prototype, "id", void 0);
31
+ __decorate([
32
+ (0, typeorm_1.Column)({ name: 'external_user_id' }),
33
+ (0, typeorm_1.Index)(),
34
+ __metadata("design:type", String)
35
+ ], MicrosoftUser.prototype, "externalUserId", void 0);
36
+ __decorate([
37
+ (0, typeorm_1.Column)({ name: 'access_token', type: 'text' }),
38
+ __metadata("design:type", String)
39
+ ], MicrosoftUser.prototype, "accessToken", void 0);
40
+ __decorate([
41
+ (0, typeorm_1.Column)({ name: 'refresh_token', type: 'text' }),
42
+ __metadata("design:type", String)
43
+ ], MicrosoftUser.prototype, "refreshToken", void 0);
44
+ __decorate([
45
+ (0, typeorm_1.Column)({ name: 'token_expiry', type: 'datetime' }),
46
+ __metadata("design:type", Date)
47
+ ], MicrosoftUser.prototype, "tokenExpiry", void 0);
48
+ __decorate([
49
+ (0, typeorm_1.Column)({ name: 'scopes', type: 'text' }),
50
+ __metadata("design:type", String)
51
+ ], MicrosoftUser.prototype, "scopes", void 0);
52
+ __decorate([
53
+ (0, typeorm_1.Column)({ name: 'is_active', default: true }),
54
+ __metadata("design:type", Boolean)
55
+ ], MicrosoftUser.prototype, "isActive", void 0);
56
+ __decorate([
57
+ (0, typeorm_1.CreateDateColumn)({ name: 'created_at' }),
58
+ __metadata("design:type", Date)
59
+ ], MicrosoftUser.prototype, "createdAt", void 0);
60
+ __decorate([
61
+ (0, typeorm_1.UpdateDateColumn)({ name: 'updated_at' }),
62
+ __metadata("design:type", Date)
63
+ ], MicrosoftUser.prototype, "updatedAt", void 0);
64
+ exports.MicrosoftUser = MicrosoftUser = __decorate([
65
+ (0, typeorm_1.Entity)('microsoft_users')
66
+ ], MicrosoftUser);
67
+ //# sourceMappingURL=microsoft-user.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"microsoft-user.entity.js","sourceRoot":"","sources":["../../src/entities/microsoft-user.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAOiB;AAQV,IAAM,aAAa,GAAnB,MAAM,aAAa;IAAnB;QAML,mBAAc,GAAW,EAAE,CAAC;QAG5B,gBAAW,GAAW,EAAE,CAAC;QAGzB,iBAAY,GAAW,EAAE,CAAC;QAG1B,gBAAW,GAAS,IAAI,IAAI,EAAE,CAAC;QAG/B,WAAM,GAAW,EAAE,CAAC;QAGpB,aAAQ,GAAY,IAAI,CAAC;QAGzB,cAAS,GAAS,IAAI,IAAI,EAAE,CAAC;QAG7B,cAAS,GAAS,IAAI,IAAI,EAAE,CAAC;IAC/B,CAAC;CAAA,CAAA;AA5BY,sCAAa;AAExB;IADC,IAAA,gCAAsB,EAAC,WAAW,CAAC;;yCACxB;AAIZ;IAFC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC;IACpC,IAAA,eAAK,GAAE;;qDACoB;AAG5B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDACtB;AAGzB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDACtB;AAG1B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;8BACtC,IAAI;kDAAc;AAG/B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6CACrB;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;+CACpB;AAGzB;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BAC9B,IAAI;gDAAc;AAG7B;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BAC9B,IAAI;gDAAc;wBA3BlB,aAAa;IADzB,IAAA,gBAAM,EAAC,iBAAiB,CAAC;GACb,aAAa,CA4BzB"}
@@ -8,8 +8,6 @@ export declare class OutlookWebhookSubscription {
8
8
  notificationUrl: string;
9
9
  expirationDateTime: Date;
10
10
  isActive: boolean;
11
- accessToken: string;
12
- refreshToken: string;
13
11
  createdAt: Date;
14
12
  updatedAt: Date;
15
13
  }
@@ -21,8 +21,6 @@ let OutlookWebhookSubscription = class OutlookWebhookSubscription {
21
21
  this.notificationUrl = '';
22
22
  this.expirationDateTime = new Date();
23
23
  this.isActive = true;
24
- this.accessToken = '';
25
- this.refreshToken = '';
26
24
  this.createdAt = new Date();
27
25
  this.updatedAt = new Date();
28
26
  }
@@ -64,14 +62,6 @@ __decorate([
64
62
  (0, typeorm_1.Column)({ name: 'is_active', default: true }),
65
63
  __metadata("design:type", Boolean)
66
64
  ], OutlookWebhookSubscription.prototype, "isActive", void 0);
67
- __decorate([
68
- (0, typeorm_1.Column)({ name: 'access_token', type: 'text', nullable: true }),
69
- __metadata("design:type", String)
70
- ], OutlookWebhookSubscription.prototype, "accessToken", void 0);
71
- __decorate([
72
- (0, typeorm_1.Column)({ name: 'refresh_token', type: 'text', nullable: true }),
73
- __metadata("design:type", String)
74
- ], OutlookWebhookSubscription.prototype, "refreshToken", void 0);
75
65
  __decorate([
76
66
  (0, typeorm_1.CreateDateColumn)({ name: 'created_at' }),
77
67
  __metadata("design:type", Date)
@@ -1 +1 @@
1
- {"version":3,"file":"outlook-webhook-subscription.entity.js","sourceRoot":"","sources":["../../src/entities/outlook-webhook-subscription.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAMiB;AAGV,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAAhC;QAKL,mBAAc,GAAW,EAAE,CAAC;QAG5B,WAAM,GAAW,CAAC,CAAC;QAGnB,aAAQ,GAAW,EAAE,CAAC;QAGtB,eAAU,GAAW,EAAE,CAAC;QAGxB,gBAAW,GAAW,EAAE,CAAC;QAGzB,oBAAe,GAAW,EAAE,CAAC;QAG7B,uBAAkB,GAAS,IAAI,IAAI,EAAE,CAAC;QAGtC,aAAQ,GAAY,IAAI,CAAC;QAGzB,gBAAW,GAAW,EAAE,CAAC;QAGzB,iBAAY,GAAW,EAAE,CAAC;QAG1B,cAAS,GAAS,IAAI,IAAI,EAAE,CAAC;QAG7B,cAAS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C;8BAC9B,IAAI;6DAAc;AAG7B;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BAC9B,IAAI;6DAAc;qCAtClB,0BAA0B;IADtC,IAAA,gBAAM,EAAC,+BAA+B,CAAC;GAC3B,0BAA0B,CAuCtC"}
1
+ {"version":3,"file":"outlook-webhook-subscription.entity.js","sourceRoot":"","sources":["../../src/entities/outlook-webhook-subscription.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAMiB;AAGV,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAAhC;QAKL,mBAAc,GAAW,EAAE,CAAC;QAG5B,WAAM,GAAW,CAAC,CAAC;QAGnB,aAAQ,GAAW,EAAE,CAAC;QAGtB,eAAU,GAAW,EAAE,CAAC;QAGxB,gBAAW,GAAW,EAAE,CAAC;QAGzB,oBAAe,GAAW,EAAE,CAAC;QAG7B,uBAAkB,GAAS,IAAI,IAAI,EAAE,CAAC;QAGtC,aAAQ,GAAY,IAAI,CAAC;QAGzB,cAAS,GAAS,IAAI,IAAI,EAAE,CAAC;QAG7B,cAAS,GAAS,IAAI,IAAI,EAAE,CAAC;IAC/B,CAAC;CAAA,CAAA;AAjCY,gEAA0B;AAErC;IADC,IAAA,gCAAsB,EAAC,WAAW,CAAC;;sDACxB;AAGZ;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;kEACnC;AAG5B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;;0DACT;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;;4DACF;AAGtB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;;8DACrB;AAGxB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;;+DACrB;AAGzB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;;mEACrB;AAG7B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;8BACvC,IAAI;sEAAc;AAGtC;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;4DACpB;AAGzB;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BAC9B,IAAI;6DAAc;AAG7B;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BAC9B,IAAI;6DAAc;qCAhClB,0BAA0B;IADtC,IAAA,gBAAM,EAAC,+BAA+B,CAAC;GAC3B,0BAA0B,CAiCtC"}
@@ -1,6 +1,5 @@
1
1
  export declare enum OutlookEventTypes {
2
- AUTH_TOKENS_SAVE = "microsoft.auth.tokens.save",
3
- AUTH_TOKENS_UPDATE = "microsoft.auth.tokens.update",
2
+ USER_AUTHENTICATED = "microsoft.auth.user.authenticated",
4
3
  EVENT_DELETED = "outlook.event.deleted",
5
4
  EVENT_CREATED = "outlook.event.created",
6
5
  EVENT_UPDATED = "outlook.event.updated",
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OutlookEventTypes = void 0;
4
4
  var OutlookEventTypes;
5
5
  (function (OutlookEventTypes) {
6
- OutlookEventTypes["AUTH_TOKENS_SAVE"] = "microsoft.auth.tokens.save";
7
- OutlookEventTypes["AUTH_TOKENS_UPDATE"] = "microsoft.auth.tokens.update";
6
+ OutlookEventTypes["USER_AUTHENTICATED"] = "microsoft.auth.user.authenticated";
8
7
  OutlookEventTypes["EVENT_DELETED"] = "outlook.event.deleted";
9
8
  OutlookEventTypes["EVENT_CREATED"] = "outlook.event.created";
10
9
  OutlookEventTypes["EVENT_UPDATED"] = "outlook.event.updated";
@@ -1 +1 @@
1
- {"version":3,"file":"event-types.enum.js","sourceRoot":"","sources":["../../src/enums/event-types.enum.ts"],"names":[],"mappings":";;;AAGA,IAAY,iBAcX;AAdD,WAAY,iBAAiB;IAE3B,oEAA+C,CAAA;IAC/C,wEAAmD,CAAA;IAGnD,4DAAuC,CAAA;IACvC,4DAAuC,CAAA;IACvC,4DAAuC,CAAA;IAGvC,8DAAyC,CAAA;IACzC,4DAAuC,CAAA;IACvC,4DAAuC,CAAA;AACzC,CAAC,EAdW,iBAAiB,iCAAjB,iBAAiB,QAc5B"}
1
+ {"version":3,"file":"event-types.enum.js","sourceRoot":"","sources":["../../src/enums/event-types.enum.ts"],"names":[],"mappings":";;;AAGA,IAAY,iBAaX;AAbD,WAAY,iBAAiB;IAE3B,6EAAwD,CAAA;IAGxD,4DAAuC,CAAA;IACvC,4DAAuC,CAAA;IACvC,4DAAuC,CAAA;IAGvC,8DAAyC,CAAA;IACzC,4DAAuC,CAAA;IACvC,4DAAuC,CAAA;AACzC,CAAC,EAbW,iBAAiB,iCAAjB,iBAAiB,QAa5B"}
@@ -23,6 +23,7 @@ const csrf_token_entity_1 = require("./entities/csrf-token.entity");
23
23
  const microsoft_csrf_token_repository_1 = require("./repositories/microsoft-csrf-token.repository");
24
24
  const calendar_service_1 = require("./services/calendar/calendar.service");
25
25
  const email_service_1 = require("./services/email/email.service");
26
+ const microsoft_user_entity_1 = require("./entities/microsoft-user.entity");
26
27
  _a = new common_1.ConfigurableModuleBuilder().setClassMethodName('forRoot').build(), exports.ConfigurableModuleClass = _a.ConfigurableModuleClass, exports.MODULE_OPTIONS_TOKEN = _a.MODULE_OPTIONS_TOKEN;
27
28
  let MicrosoftOutlookModule = class MicrosoftOutlookModule extends exports.ConfigurableModuleClass {
28
29
  };
@@ -31,7 +32,11 @@ exports.MicrosoftOutlookModule = MicrosoftOutlookModule = __decorate([
31
32
  (0, common_1.Module)({
32
33
  imports: [
33
34
  schedule_1.ScheduleModule.forRoot(),
34
- typeorm_1.TypeOrmModule.forFeature([outlook_webhook_subscription_entity_1.OutlookWebhookSubscription, csrf_token_entity_1.MicrosoftCsrfToken]),
35
+ typeorm_1.TypeOrmModule.forFeature([
36
+ outlook_webhook_subscription_entity_1.OutlookWebhookSubscription,
37
+ csrf_token_entity_1.MicrosoftCsrfToken,
38
+ microsoft_user_entity_1.MicrosoftUser,
39
+ ]),
35
40
  event_emitter_1.EventEmitterModule.forRoot(),
36
41
  ],
37
42
  controllers: [microsoft_auth_controller_1.MicrosoftAuthController, calendar_controller_1.CalendarController, email_controller_1.EmailController],
@@ -1 +1 @@
1
- {"version":3,"file":"microsoft-outlook.module.js","sourceRoot":"","sources":["../src/microsoft-outlook.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAmE;AACnE,6CAAgD;AAChD,+CAAkD;AAClD,yDAA2D;AAC3D,mFAA8E;AAC9E,uFAAkF;AAClF,2EAAuE;AACvE,qEAAiE;AACjE,wGAA4F;AAC5F,oHAA8G;AAC9G,2CAA+C;AAE/C,oEAAkE;AAClE,oGAA8F;AAC9F,2EAAuE;AACvE,kEAA8D;AAEjD,KACX,IAAI,kCAAyB,EAA0B,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EADhF,+BAAuB,+BAAE,4BAAoB,2BACoC;AA2BzF,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,+BAAuB;CAAG,CAAA;AAAzD,wDAAsB;iCAAtB,sBAAsB;IArBlC,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,yBAAc,CAAC,OAAO,EAAE;YACxB,uBAAa,CAAC,UAAU,CAAC,CAAC,gEAA0B,EAAE,sCAAkB,CAAC,CAAC;YAC1E,kCAAkB,CAAC,OAAO,EAAE;SAC7B;QACD,WAAW,EAAE,CAAC,mDAAuB,EAAE,wCAAkB,EAAE,kCAAe,CAAC;QAC3E,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,4BAAgB;gBACzB,UAAU,EAAE,CAAC,OAA+B,EAAE,EAAE,CAAC,OAAO;gBACxD,MAAM,EAAE,CAAC,4BAAoB,CAAC;aAC/B;YACD,8EAAoC;YACpC,8DAA4B;YAC5B,kCAAe;YACf,4BAAY;YACZ,6CAAoB;SACrB;QACD,OAAO,EAAE,CAAC,kCAAe,EAAE,4BAAY,EAAE,6CAAoB,CAAC;KAC/D,CAAC;GACW,sBAAsB,CAAmC"}
1
+ {"version":3,"file":"microsoft-outlook.module.js","sourceRoot":"","sources":["../src/microsoft-outlook.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAmE;AACnE,6CAAgD;AAChD,+CAAkD;AAClD,yDAA2D;AAC3D,mFAA8E;AAC9E,uFAAkF;AAClF,2EAAuE;AACvE,qEAAiE;AACjE,wGAA4F;AAC5F,oHAA8G;AAC9G,2CAA+C;AAE/C,oEAAkE;AAClE,oGAA8F;AAC9F,2EAAuE;AACvE,kEAA8D;AAC9D,4EAAiE;AAEpD,KACX,IAAI,kCAAyB,EAA0B,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EADhF,+BAAuB,+BAAE,4BAAoB,2BACoC;AA+BzF,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,+BAAuB;CAAG,CAAA;AAAzD,wDAAsB;iCAAtB,sBAAsB;IAzBlC,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,yBAAc,CAAC,OAAO,EAAE;YACxB,uBAAa,CAAC,UAAU,CAAC;gBACvB,gEAA0B;gBAC1B,sCAAkB;gBAClB,qCAAa;aACd,CAAC;YACF,kCAAkB,CAAC,OAAO,EAAE;SAC7B;QACD,WAAW,EAAE,CAAC,mDAAuB,EAAE,wCAAkB,EAAE,kCAAe,CAAC;QAC3E,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,4BAAgB;gBACzB,UAAU,EAAE,CAAC,OAA+B,EAAE,EAAE,CAAC,OAAO;gBACxD,MAAM,EAAE,CAAC,4BAAoB,CAAC;aAC/B;YACD,8EAAoC;YACpC,8DAA4B;YAC5B,kCAAe;YACf,4BAAY;YACZ,6CAAoB;SACrB;QACD,OAAO,EAAE,CAAC,kCAAe,EAAE,4BAAY,EAAE,6CAAoB,CAAC;KAC/D,CAAC;GACW,sBAAsB,CAAmC"}
@@ -0,0 +1,5 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class AddMicrosoftUserTable1699000000000 implements MigrationInterface {
3
+ up(queryRunner: QueryRunner): Promise<void>;
4
+ down(queryRunner: QueryRunner): Promise<void>;
5
+ }
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AddMicrosoftUserTable1699000000000 = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ class AddMicrosoftUserTable1699000000000 {
6
+ async up(queryRunner) {
7
+ await queryRunner.createTable(new typeorm_1.Table({
8
+ name: 'microsoft_users',
9
+ columns: [
10
+ {
11
+ name: 'id',
12
+ type: 'INTEGER',
13
+ isPrimary: true,
14
+ isGenerated: true,
15
+ generationStrategy: 'increment',
16
+ },
17
+ {
18
+ name: 'external_user_id',
19
+ type: 'varchar',
20
+ length: '255',
21
+ isNullable: false,
22
+ },
23
+ {
24
+ name: 'access_token',
25
+ type: 'text',
26
+ isNullable: false,
27
+ },
28
+ {
29
+ name: 'refresh_token',
30
+ type: 'text',
31
+ isNullable: false,
32
+ },
33
+ {
34
+ name: 'token_expiry',
35
+ type: 'timestamp',
36
+ isNullable: false,
37
+ },
38
+ {
39
+ name: 'scopes',
40
+ type: 'text',
41
+ isNullable: false,
42
+ },
43
+ {
44
+ name: 'is_active',
45
+ type: 'boolean',
46
+ default: true,
47
+ isNullable: false,
48
+ },
49
+ {
50
+ name: 'created_at',
51
+ type: 'timestamp',
52
+ default: 'now()',
53
+ isNullable: false,
54
+ },
55
+ {
56
+ name: 'updated_at',
57
+ type: 'timestamp',
58
+ default: 'now()',
59
+ isNullable: false,
60
+ },
61
+ ],
62
+ }), true);
63
+ await queryRunner.createIndex('microsoft_users', new typeorm_1.TableIndex({
64
+ name: 'IDX_microsoft_users_external_user_id',
65
+ columnNames: ['external_user_id'],
66
+ }));
67
+ const table = await queryRunner.getTable('outlook_webhook_subscriptions');
68
+ if (table) {
69
+ const accessTokenColumn = table.findColumnByName('access_token');
70
+ const refreshTokenColumn = table.findColumnByName('refresh_token');
71
+ if (accessTokenColumn) {
72
+ await queryRunner.dropColumn('outlook_webhook_subscriptions', 'access_token');
73
+ }
74
+ if (refreshTokenColumn) {
75
+ await queryRunner.dropColumn('outlook_webhook_subscriptions', 'refresh_token');
76
+ }
77
+ }
78
+ }
79
+ async down(queryRunner) {
80
+ const table = await queryRunner.getTable('outlook_webhook_subscriptions');
81
+ if (table) {
82
+ const accessTokenColumn = table.findColumnByName('access_token');
83
+ const refreshTokenColumn = table.findColumnByName('refresh_token');
84
+ if (!accessTokenColumn) {
85
+ await queryRunner.addColumn('outlook_webhook_subscriptions', new typeorm_1.TableColumn({
86
+ name: 'access_token',
87
+ type: 'text',
88
+ isNullable: true,
89
+ }));
90
+ }
91
+ if (!refreshTokenColumn) {
92
+ await queryRunner.addColumn('outlook_webhook_subscriptions', new typeorm_1.TableColumn({
93
+ name: 'refresh_token',
94
+ type: 'text',
95
+ isNullable: true,
96
+ }));
97
+ }
98
+ }
99
+ await queryRunner.dropIndex('microsoft_users', 'IDX_microsoft_users_external_user_id');
100
+ await queryRunner.dropTable('microsoft_users');
101
+ }
102
+ }
103
+ exports.AddMicrosoftUserTable1699000000000 = AddMicrosoftUserTable1699000000000;
104
+ //# sourceMappingURL=1699000000000-AddMicrosoftUserTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"1699000000000-AddMicrosoftUserTable.js","sourceRoot":"","sources":["../../src/migrations/1699000000000-AddMic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I,EAAE,eAAe;oBACrB,IAAI,EAAE,MAAM;oBACZ,UAAU,EAAE,IAAI;iBACjB,CAAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC;QAGD,MAAM,WAAW,CAAC,SAAS,CAAC,iBAAiB,EAAE,sCAAsC,CAAC,CAAC;QACvF,MAAM,WAAW,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;IACjD,CAAC;CACF;AA9HD,gFA8HC"}
@@ -5,7 +5,7 @@ export declare class OutlookWebhookSubscriptionRepository {
5
5
  constructor(repository: Repository<OutlookWebhookSubscription>);
6
6
  saveSubscription(subscription: Partial<OutlookWebhookSubscription>): Promise<OutlookWebhookSubscription>;
7
7
  findBySubscriptionId(subscriptionId: string): Promise<OutlookWebhookSubscription | null>;
8
- updateSubscriptionExpiration(subscriptionId: string, expirationDateTime: Date, accessToken?: string): Promise<void>;
8
+ updateSubscriptionExpiration(subscriptionId: string, expirationDateTime: Date): Promise<void>;
9
9
  deactivateSubscription(subscriptionId: string): Promise<void>;
10
10
  findSubscriptionsNeedingRenewal(hoursUntilExpiration: number): Promise<OutlookWebhookSubscription[]>;
11
11
  findActiveSubscriptions(): Promise<OutlookWebhookSubscription[]>;
@@ -41,14 +41,11 @@ let OutlookWebhookSubscriptionRepository = class OutlookWebhookSubscriptionRepos
41
41
  async findBySubscriptionId(subscriptionId) {
42
42
  return this.repository.findOne({ where: { subscriptionId, isActive: true } });
43
43
  }
44
- async updateSubscriptionExpiration(subscriptionId, expirationDateTime, accessToken) {
44
+ async updateSubscriptionExpiration(subscriptionId, expirationDateTime) {
45
45
  const update = {
46
46
  expirationDateTime,
47
47
  updatedAt: new Date(),
48
48
  };
49
- if (accessToken) {
50
- update.accessToken = accessToken;
51
- }
52
49
  await this.repository.update({ subscriptionId, isActive: true }, update);
53
50
  }
54
51
  async deactivateSubscription(subscriptionId) {
@@ -1 +1 @@
1
- {"version":3,"file":"outlook-webhook-subscription.repository.js","sourceRoot":"","sources":["../../src/repositories/outlook-webh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A;qCAChB,oBAAU;GAH9B,oCAAoC,CAiFhD"}
1
+ {"version":3,"file":"outlook-webhook-subscription.repository.js","sourceRoot":"","sources":["../../src/repositories/outlook-webhook-subscription.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAyD;AACzD,yGAA6F;AAGtF,IAAM,oCAAoC,GAA1C,MAAM,oCAAoC;IAC/C,YAEmB,UAAkD;QAAlD,eAAU,GAAV,UAAU,CAAwC;IAClE,CAAC;IAEJ,KAAK,CAAC,gBAAgB,CACpB,YAAiD;QAGjD,IAAI,YAAY,CAAC,cAAc,EAAE,CAAC;YAChC,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;gBACzD,KAAK,EAAE,EAAE,cAAc,EAAE,YAAY,CAAC,cAAc,EAAE;aACvD,CAAC,CAAC;YAEH,IAAI,oBAAoB,EAAE,CAAC;gBAEzB,MAAM,UAAU,GAAG,oBAAoB,CAAC,EAAE,CAAC;gBAC3C,MAAM,CAAC,MAAM,CAAC,oBAAoB,EAAE,YAAY,CAAC,CAAC;gBAClD,oBAAoB,CAAC,EAAE,GAAG,UAAU,CAAC;gBACrC,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;QAID,MAAM,qBAAqB,qBAAQ,YAAY,CAAE,CAAC;QAClD,OAAO,qBAAqB,CAAC,EAAE,CAAC;QAChC,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;QAEtE,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,cAAsB;QAC/C,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,cAAc,EAAE,QAAQ,EAAE,I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