@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.
- package/README.md +196 -21
- package/dist/controllers/calendar.controller.d.ts +10 -0
- package/dist/controllers/calendar.controller.js +166 -0
- package/dist/controllers/calendar.controller.js.map +1 -0
- package/dist/controllers/email.controller.d.ts +10 -0
- package/dist/controllers/email.controller.js +166 -0
- package/dist/controllers/email.controller.js.map +1 -0
- package/dist/controllers/microsoft-auth.controller.d.ts +3 -2
- package/dist/controllers/microsoft-auth.controller.js +15 -13
- package/dist/controllers/microsoft-auth.controller.js.map +1 -1
- package/dist/dto/outlook-webhook-notification.dto.d.ts +5 -0
- package/dist/dto/outlook-webhook-notification.dto.js +39 -1
- package/dist/dto/outlook-webhook-notification.dto.js.map +1 -1
- package/dist/entities/outlook-webhook-subscription.entity.js +3 -4
- package/dist/entities/outlook-webhook-subscription.entity.js.map +1 -1
- package/dist/{event-types.enum.d.ts → enums/event-types.enum.d.ts} +4 -1
- package/dist/{event-types.enum.js → enums/event-types.enum.js} +3 -0
- package/dist/enums/event-types.enum.js.map +1 -0
- package/dist/enums/permission-scope.enum.d.ts +7 -0
- package/dist/enums/permission-scope.enum.js +12 -0
- package/dist/enums/permission-scope.enum.js.map +1 -0
- package/dist/index.d.ts +9 -5
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/interfaces/config/outlook-config.interface.d.ts +1 -1
- package/dist/interfaces/microsoft-auth/state-object.interface.d.ts +4 -2
- package/dist/microsoft-outlook.module.js +9 -6
- package/dist/microsoft-outlook.module.js.map +1 -1
- package/dist/migrations/1697025846000-CreateOutlookTables.js +2 -1
- package/dist/migrations/1697025846000-CreateOutlookTables.js.map +1 -1
- package/dist/migrations/1697026000000-EnsureUniqueSubscriptions.d.ts +5 -0
- package/dist/migrations/1697026000000-EnsureUniqueSubscriptions.js +27 -0
- package/dist/migrations/1697026000000-EnsureUniqueSubscriptions.js.map +1 -0
- package/dist/repositories/outlook-webhook-subscription.repository.js +14 -1
- package/dist/repositories/outlook-webhook-subscription.repository.js.map +1 -1
- package/dist/services/auth/index.d.ts +1 -0
- package/dist/services/auth/index.js +18 -0
- package/dist/services/auth/index.js.map +1 -0
- package/dist/services/auth/microsoft-auth.service.d.ts +41 -0
- package/dist/services/{microsoft-auth.service.js → auth/microsoft-auth.service.js} +110 -37
- package/dist/services/auth/microsoft-auth.service.js.map +1 -0
- package/dist/services/{outlook.service.d.ts → calendar/calendar.service.d.ts} +6 -6
- package/dist/services/{outlook.service.js → calendar/calendar.service.js} +96 -66
- package/dist/services/calendar/calendar.service.js.map +1 -0
- package/dist/services/calendar/index.d.ts +1 -0
- package/dist/services/calendar/index.js +18 -0
- package/dist/services/calendar/index.js.map +1 -0
- package/dist/services/email/email.service.d.ts +24 -0
- package/dist/services/email/email.service.js +207 -0
- package/dist/services/email/email.service.js.map +1 -0
- package/dist/services/email/index.d.ts +1 -0
- package/dist/services/email/index.js +18 -0
- package/dist/services/email/index.js.map +1 -0
- package/dist/services/index.d.ts +3 -0
- package/dist/services/index.js +20 -0
- package/dist/services/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/microsoft-graph.types.d.ts +1 -1
- package/package.json +11 -6
- package/dist/controllers/outlook.controller.d.ts +0 -8
- package/dist/controllers/outlook.controller.js +0 -117
- package/dist/controllers/outlook.controller.js.map +0 -1
- package/dist/event-types.enum.js.map +0 -1
- package/dist/services/microsoft-auth.service.d.ts +0 -32
- package/dist/services/microsoft-auth.service.js.map +0 -1
- package/dist/services/outlook.service.js.map +0 -1
|
@@ -11,23 +11,23 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
+
var MicrosoftAuthController_1;
|
|
14
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
16
|
exports.MicrosoftAuthController = void 0;
|
|
16
17
|
const common_1 = require("@nestjs/common");
|
|
17
18
|
const swagger_1 = require("@nestjs/swagger");
|
|
18
|
-
const microsoft_auth_service_1 = require("../services/microsoft-auth.service");
|
|
19
|
-
let MicrosoftAuthController = class MicrosoftAuthController {
|
|
19
|
+
const microsoft_auth_service_1 = require("../services/auth/microsoft-auth.service");
|
|
20
|
+
let MicrosoftAuthController = MicrosoftAuthController_1 = class MicrosoftAuthController {
|
|
20
21
|
constructor(microsoftAuthService) {
|
|
21
22
|
this.microsoftAuthService = microsoftAuthService;
|
|
23
|
+
this.logger = new common_1.Logger(MicrosoftAuthController_1.name);
|
|
22
24
|
}
|
|
23
|
-
async
|
|
24
|
-
if (!code) {
|
|
25
|
-
throw new common_1.BadRequestException('No code provided');
|
|
26
|
-
}
|
|
27
|
-
if (!state) {
|
|
28
|
-
throw new common_1.BadRequestException('No state parameter provided');
|
|
29
|
-
}
|
|
25
|
+
async handleOauthCallback(code, state, res) {
|
|
30
26
|
try {
|
|
27
|
+
if (!code || !state) {
|
|
28
|
+
this.logger.error('Missing required parameters for OAuth callback');
|
|
29
|
+
return res.status(common_1.HttpStatus.BAD_REQUEST).send('Missing required parameters');
|
|
30
|
+
}
|
|
31
31
|
await this.microsoftAuthService.exchangeCodeForToken(code, state);
|
|
32
32
|
return res.status(common_1.HttpStatus.OK).send(`
|
|
33
33
|
<h1>Authorization successful!</h1>
|
|
@@ -42,8 +42,10 @@ let MicrosoftAuthController = class MicrosoftAuthController {
|
|
|
42
42
|
`);
|
|
43
43
|
}
|
|
44
44
|
catch (error) {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
this.logger.error('Error handling OAuth callback:', error);
|
|
46
|
+
return res
|
|
47
|
+
.status(common_1.HttpStatus.INTERNAL_SERVER_ERROR)
|
|
48
|
+
.send('An error occurred during authentication');
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
};
|
|
@@ -92,8 +94,8 @@ __decorate([
|
|
|
92
94
|
__metadata("design:type", Function),
|
|
93
95
|
__metadata("design:paramtypes", [String, String, Object]),
|
|
94
96
|
__metadata("design:returntype", Promise)
|
|
95
|
-
], MicrosoftAuthController.prototype, "
|
|
96
|
-
exports.MicrosoftAuthController = MicrosoftAuthController = __decorate([
|
|
97
|
+
], MicrosoftAuthController.prototype, "handleOauthCallback", null);
|
|
98
|
+
exports.MicrosoftAuthController = MicrosoftAuthController = MicrosoftAuthController_1 = __decorate([
|
|
97
99
|
(0, swagger_1.ApiTags)('Microsoft Auth'),
|
|
98
100
|
(0, common_1.Controller)('auth/microsoft'),
|
|
99
101
|
__metadata("design:paramtypes", [microsoft_auth_service_1.MicrosoftAuthService])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"microsoft-auth.controller.js","sourceRoot":"","sources":["../../src/controllers/microsoft-auth.controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"microsoft-auth.controller.js","sourceRoot":"","sources":["../../src/controllers/microsoft-auth.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAiF;AAEjF,6CAA4F;AAC5F,oFAA+E;AAIxE,IAAM,uBAAuB,+BAA7B,MAAM,uBAAuB;IAGlC,YAA6B,oBAA0C;QAA1C,yBAAoB,GAApB,oBAAoB,CAAsB;QAFtD,WAAM,GAAG,IAAI,eAAM,CAAC,yBAAuB,CAAC,IAAI,CAAC,CAAC;IAEO,CAAC;IA4DrE,AAAN,KAAK,CAAC,mBAAmB,CACR,IAAY,EACX,KAAa,EACtB,GAAa;QAEpB,IAAI,CAAC;YACH,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACpB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;gBACpE,OAAO,GAAG,CAAC,MAAM,CAAC,mBAAU,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;YA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E,4CAA4C;KAC1D,CAAC;IACD,IAAA,qBAAW,EAAC,WAAW,CAAC;IAEtB,WAAA,IAAA,cAAK,EAAC,MAAM,CAAC,CAAA;IACb,WAAA,IAAA,cAAK,EAAC,OAAO,CAAC,CAAA;IACd,WAAA,IAAA,YAAG,GAAE,CAAA;;;;kEA6BP;kCA/FU,uBAAuB;IAFnC,IAAA,iBAAO,EAAC,gBAAgB,CAAC;IACzB,IAAA,mBAAU,EAAC,gBAAgB,CAAC;qCAIwB,6CAAoB;GAH5D,uBAAuB,CAgGnC"}
|
|
@@ -3,6 +3,11 @@ export declare class OutlookResourceData {
|
|
|
3
3
|
'@odata.id'?: string;
|
|
4
4
|
'@odata.etag'?: string;
|
|
5
5
|
id: string;
|
|
6
|
+
userId?: number;
|
|
7
|
+
subscriptionId?: string;
|
|
8
|
+
resource?: string;
|
|
9
|
+
changeType?: string;
|
|
10
|
+
data?: Record<string, unknown>;
|
|
6
11
|
[key: string]: unknown;
|
|
7
12
|
}
|
|
8
13
|
export declare class OutlookWebhookNotificationItemDto {
|
|
@@ -40,7 +40,7 @@ __decorate([
|
|
|
40
40
|
], OutlookResourceData.prototype, "@odata.id", void 0);
|
|
41
41
|
__decorate([
|
|
42
42
|
(0, swagger_1.ApiProperty)({
|
|
43
|
-
description: 'The
|
|
43
|
+
description: 'The OData entity tag that represents the version of the object',
|
|
44
44
|
example: 'W/"ZWRafd0rFkORSLqrpwPMEQlFkSo="',
|
|
45
45
|
required: false,
|
|
46
46
|
}),
|
|
@@ -57,6 +57,44 @@ __decorate([
|
|
|
57
57
|
(0, class_validator_1.IsNotEmpty)(),
|
|
58
58
|
__metadata("design:type", String)
|
|
59
59
|
], OutlookResourceData.prototype, "id", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
(0, swagger_1.ApiProperty)({
|
|
62
|
+
description: 'The user ID associated with the resource',
|
|
63
|
+
example: 123,
|
|
64
|
+
}),
|
|
65
|
+
__metadata("design:type", Number)
|
|
66
|
+
], OutlookResourceData.prototype, "userId", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, swagger_1.ApiProperty)({
|
|
69
|
+
description: 'The subscription ID that triggered this notification',
|
|
70
|
+
example: '08ee466c-5ceb-4af2-a98f-aea3316a854c',
|
|
71
|
+
}),
|
|
72
|
+
__metadata("design:type", String)
|
|
73
|
+
], OutlookResourceData.prototype, "subscriptionId", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, swagger_1.ApiProperty)({
|
|
76
|
+
description: 'The resource path that changed',
|
|
77
|
+
example: '/me/messages/AAMkAGVmMDEzMTM4LTZmYWUtNDdkNC1hMDZiLTU1OGY5OTZhYmY4OABGAAAAAAAiQ8W967B7TKBjgx9rVEURBwAiIsqMbYjsT5e-T7KzowPTAAAAAAEMAAAiIsqMbYjsT5e-T7KzowPTAAAYbuK-AAA=',
|
|
78
|
+
}),
|
|
79
|
+
__metadata("design:type", String)
|
|
80
|
+
], OutlookResourceData.prototype, "resource", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
(0, swagger_1.ApiProperty)({
|
|
83
|
+
description: 'The type of change that occurred',
|
|
84
|
+
example: 'created',
|
|
85
|
+
}),
|
|
86
|
+
__metadata("design:type", String)
|
|
87
|
+
], OutlookResourceData.prototype, "changeType", void 0);
|
|
88
|
+
__decorate([
|
|
89
|
+
(0, swagger_1.ApiProperty)({
|
|
90
|
+
description: 'Additional data for the resource (like email content for new emails)',
|
|
91
|
+
required: false,
|
|
92
|
+
type: 'object',
|
|
93
|
+
}),
|
|
94
|
+
(0, class_validator_1.IsObject)(),
|
|
95
|
+
(0, class_validator_1.IsOptional)(),
|
|
96
|
+
__metadata("design:type", Object)
|
|
97
|
+
], OutlookResourceData.prototype, "data", void 0);
|
|
60
98
|
class OutlookWebhookNotificationItemDto {
|
|
61
99
|
constructor() {
|
|
62
100
|
this.subscriptionId = '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outlook-webhook-notification.dto.js","sourceRoot":"","sources":["../../src/dto/outlook-webhook-notification.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAsF;AACtF,6CAA8C;AAK9C,MAAa,mBAAmB;IAAhC;QAkCE,OAAE,GAAW,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"outlook-webhook-notification.dto.js","sourceRoot":"","sources":["../../src/dto/outlook-webhook-notification.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAsF;AACtF,6CAA8C;AAK9C,MAAa,mBAAmB;IAAhC;QAkCE,OAAE,GAAW,EAAE,CAAC;IAqClB,CAAC;CAAA;AAvED,kDAuEC;AA/DC;IAPC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,0CAA0C;QACvD,OAAO,EAAE,wBAAwB;QACjC,QAAQ,EAAE,KAAK;KAChB,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;wDACU;AASvB;IAPC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,oCAAoC;QACjD,OAAO,EAAE,kEAAkE;QAC3E,QAAQ,EAAE,KAAK;KAChB,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;sDACQ;AASrB;IAPC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,gEAAgE;QAC7E,OAAO,EAAE,kCAAkC;QAC3C,QAAQ,EAAE,KAAK;KAChB,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;wDACU;AAQvB;IANC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,8BAA8B;QAC3C,OAAO,EAAE,uBAAuB;KACjC,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;+CACG;AAMhB;IAJC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,0CAA0C;QACvD,OAAO,EAAE,GAAG;KACb,CAAC;;mDACc;AAMhB;IAJC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,sD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IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;mEACS;AAQtB;IANC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,uCAAuC;QACpD,IAAI,EAAE,mBAAmB;KAC1B,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;8BACC,mBAAmB;uEAA6B;AAS9D;IAPC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,4CAA4C;QACzD,OAAO,EAAE,sCAAsC;QAC/C,QAAQ,EAAE,KAAK;KAChB,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;sEACQ;AASrB;IAPC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,eAAe;QAC5B,OAAO,EAAE,qCAAqC;QAC9C,QAAQ,EAAE,KAAK;KAChB,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;mEACK;AAMpB,MAAa,6BAA6B;IAA1C;QAME,UAAK,GAAwC,EAAE,CAAC;IAClD,CAAC;CAAA;AAPD,sEAOC;AADC;IALC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,6BAA6B;QAC1C,IAAI,EAAE,CAAC,iCAAiC,CAAC;KAC1C,CAAC;IACD,IAAA,yBAAO,GAAE;;4DACsC"}
|
|
@@ -13,7 +13,6 @@ exports.OutlookWebhookSubscription = void 0;
|
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
let OutlookWebhookSubscription = class OutlookWebhookSubscription {
|
|
15
15
|
constructor() {
|
|
16
|
-
this.id = 0;
|
|
17
16
|
this.subscriptionId = '';
|
|
18
17
|
this.userId = 0;
|
|
19
18
|
this.resource = '';
|
|
@@ -30,11 +29,11 @@ let OutlookWebhookSubscription = class OutlookWebhookSubscription {
|
|
|
30
29
|
};
|
|
31
30
|
exports.OutlookWebhookSubscription = OutlookWebhookSubscription;
|
|
32
31
|
__decorate([
|
|
33
|
-
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
32
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('increment'),
|
|
34
33
|
__metadata("design:type", Number)
|
|
35
34
|
], OutlookWebhookSubscription.prototype, "id", void 0);
|
|
36
35
|
__decorate([
|
|
37
|
-
(0, typeorm_1.Column)({ name: 'subscription_id', length: 255 }),
|
|
36
|
+
(0, typeorm_1.Column)({ name: 'subscription_id', length: 255, unique: true }),
|
|
38
37
|
__metadata("design:type", String)
|
|
39
38
|
], OutlookWebhookSubscription.prototype, "subscriptionId", void 0);
|
|
40
39
|
__decorate([
|
|
@@ -58,7 +57,7 @@ __decorate([
|
|
|
58
57
|
__metadata("design:type", String)
|
|
59
58
|
], OutlookWebhookSubscription.prototype, "notificationUrl", void 0);
|
|
60
59
|
__decorate([
|
|
61
|
-
(0, typeorm_1.Column)({ name: 'expiration_date_time', type: '
|
|
60
|
+
(0, typeorm_1.Column)({ name: 'expiration_date_time', type: 'datetime' }),
|
|
62
61
|
__metadata("design:type", Date)
|
|
63
62
|
], OutlookWebhookSubscription.prototype, "expirationDateTime", void 0);
|
|
64
63
|
__decorate([
|
|
@@ -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;
|
|
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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,QAAQ,EAAE,IAAI,EAAE,CAAC;;+DACtC;AAGzB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gEACtC;AAG1B;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;qCAtClB,0BAA0B;IADtC,IAAA,gBAAM,EAAC,+BAA+B,CAAC;GAC3B,0BAA0B,CAuCtC"}
|
|
@@ -3,5 +3,8 @@ export declare enum OutlookEventTypes {
|
|
|
3
3
|
AUTH_TOKENS_UPDATE = "microsoft.auth.tokens.update",
|
|
4
4
|
EVENT_DELETED = "outlook.event.deleted",
|
|
5
5
|
EVENT_CREATED = "outlook.event.created",
|
|
6
|
-
EVENT_UPDATED = "outlook.event.updated"
|
|
6
|
+
EVENT_UPDATED = "outlook.event.updated",
|
|
7
|
+
EMAIL_RECEIVED = "outlook.email.received",
|
|
8
|
+
EMAIL_UPDATED = "outlook.email.updated",
|
|
9
|
+
EMAIL_DELETED = "outlook.email.deleted"
|
|
7
10
|
}
|
|
@@ -8,5 +8,8 @@ var OutlookEventTypes;
|
|
|
8
8
|
OutlookEventTypes["EVENT_DELETED"] = "outlook.event.deleted";
|
|
9
9
|
OutlookEventTypes["EVENT_CREATED"] = "outlook.event.created";
|
|
10
10
|
OutlookEventTypes["EVENT_UPDATED"] = "outlook.event.updated";
|
|
11
|
+
OutlookEventTypes["EMAIL_RECEIVED"] = "outlook.email.received";
|
|
12
|
+
OutlookEventTypes["EMAIL_UPDATED"] = "outlook.email.updated";
|
|
13
|
+
OutlookEventTypes["EMAIL_DELETED"] = "outlook.email.deleted";
|
|
11
14
|
})(OutlookEventTypes || (exports.OutlookEventTypes = OutlookEventTypes = {}));
|
|
12
15
|
//# sourceMappingURL=event-types.enum.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PermissionScope = void 0;
|
|
4
|
+
var PermissionScope;
|
|
5
|
+
(function (PermissionScope) {
|
|
6
|
+
PermissionScope["CALENDAR_READ"] = "CALENDAR_READ";
|
|
7
|
+
PermissionScope["CALENDAR_WRITE"] = "CALENDAR_WRITE";
|
|
8
|
+
PermissionScope["EMAIL_READ"] = "EMAIL_READ";
|
|
9
|
+
PermissionScope["EMAIL_WRITE"] = "EMAIL_WRITE";
|
|
10
|
+
PermissionScope["EMAIL_SEND"] = "EMAIL_SEND";
|
|
11
|
+
})(PermissionScope || (exports.PermissionScope = PermissionScope = {}));
|
|
12
|
+
//# sourceMappingURL=permission-scope.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission-scope.enum.js","sourceRoot":"","sources":["../../src/enums/permission-scope.enum.ts"],"names":[],"mappings":";;;AAIA,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,kDAA+B,CAAA;IAC/B,oDAAiC,CAAA;IACjC,4CAAyB,CAAA;IACzB,8CAA2B,CAAA;IAC3B,4CAAyB,CAAA;AAC3B,CAAC,EANW,eAAe,+BAAf,eAAe,QAM1B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
export * from './services/auth/microsoft-auth.service';
|
|
2
|
+
export * from './services/calendar/calendar.service';
|
|
3
|
+
export * from './services/email/email.service';
|
|
1
4
|
export * from './microsoft-outlook.module';
|
|
2
|
-
export * from './controllers/outlook.controller';
|
|
3
|
-
export * from './services/outlook.service';
|
|
4
|
-
export * from './services/microsoft-auth.service';
|
|
5
|
-
export * from './dto/outlook-webhook-notification.dto';
|
|
6
5
|
export * from './interfaces/outlook/token-response.interface';
|
|
7
6
|
export * from './interfaces/config/outlook-config.interface';
|
|
8
|
-
export * from './
|
|
7
|
+
export * from './enums/permission-scope.enum';
|
|
8
|
+
export * from './enums/event-types.enum';
|
|
9
9
|
export * from './constants';
|
|
10
|
+
export * from './controllers/calendar.controller';
|
|
11
|
+
export * from './controllers/microsoft-auth.controller';
|
|
12
|
+
export * from './controllers/email.controller';
|
|
13
|
+
export * from './dto/outlook-webhook-notification.dto';
|
|
10
14
|
export * from './entities/outlook-webhook-subscription.entity';
|
|
11
15
|
export * from './repositories/outlook-webhook-subscription.repository';
|
|
12
16
|
export * from './types';
|
package/dist/index.js
CHANGED
|
@@ -14,15 +14,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./services/auth/microsoft-auth.service"), exports);
|
|
18
|
+
__exportStar(require("./services/calendar/calendar.service"), exports);
|
|
19
|
+
__exportStar(require("./services/email/email.service"), exports);
|
|
17
20
|
__exportStar(require("./microsoft-outlook.module"), exports);
|
|
18
|
-
__exportStar(require("./controllers/outlook.controller"), exports);
|
|
19
|
-
__exportStar(require("./services/outlook.service"), exports);
|
|
20
|
-
__exportStar(require("./services/microsoft-auth.service"), exports);
|
|
21
|
-
__exportStar(require("./dto/outlook-webhook-notification.dto"), exports);
|
|
22
21
|
__exportStar(require("./interfaces/outlook/token-response.interface"), exports);
|
|
23
22
|
__exportStar(require("./interfaces/config/outlook-config.interface"), exports);
|
|
24
|
-
__exportStar(require("./
|
|
23
|
+
__exportStar(require("./enums/permission-scope.enum"), exports);
|
|
24
|
+
__exportStar(require("./enums/event-types.enum"), exports);
|
|
25
25
|
__exportStar(require("./constants"), exports);
|
|
26
|
+
__exportStar(require("./controllers/calendar.controller"), exports);
|
|
27
|
+
__exportStar(require("./controllers/microsoft-auth.controller"), exports);
|
|
28
|
+
__exportStar(require("./controllers/email.controller"), exports);
|
|
29
|
+
__exportStar(require("./dto/outlook-webhook-notification.dto"), exports);
|
|
26
30
|
__exportStar(require("./entities/outlook-webhook-subscription.entity"), exports);
|
|
27
31
|
__exportStar(require("./repositories/outlook-webhook-subscription.repository"), exports);
|
|
28
32
|
__exportStar(require("./types"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAGA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAGA,yEAAuD;AACvD,uEAAqD;AACrD,iEAA+C;AAG/C,6DAA2C;AAG3C,gFAA8D;AAC9D,+EAA6D;AAG7D,gEAA8C;AAC9C,2DAAyC;AAGzC,8CAA4B;AAG5B,oEAAkD;AAClD,0EAAwD;AACxD,iEAA+C;AAG/C,yEAAuD;AAGvD,iFAA+D;AAG/D,yFAAuE;AAGvE,0CAAwB"}
|
|
@@ -12,15 +12,17 @@ const common_1 = require("@nestjs/common");
|
|
|
12
12
|
const typeorm_1 = require("@nestjs/typeorm");
|
|
13
13
|
const schedule_1 = require("@nestjs/schedule");
|
|
14
14
|
const event_emitter_1 = require("@nestjs/event-emitter");
|
|
15
|
-
const
|
|
16
|
-
const microsoft_auth_service_1 = require("./services/microsoft-auth.service");
|
|
15
|
+
const microsoft_auth_service_1 = require("./services/auth/microsoft-auth.service");
|
|
17
16
|
const microsoft_auth_controller_1 = require("./controllers/microsoft-auth.controller");
|
|
18
|
-
const
|
|
17
|
+
const calendar_controller_1 = require("./controllers/calendar.controller");
|
|
18
|
+
const email_controller_1 = require("./controllers/email.controller");
|
|
19
19
|
const outlook_webhook_subscription_entity_1 = require("./entities/outlook-webhook-subscription.entity");
|
|
20
20
|
const outlook_webhook_subscription_repository_1 = require("./repositories/outlook-webhook-subscription.repository");
|
|
21
21
|
const constants_1 = require("./constants");
|
|
22
22
|
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
|
+
const calendar_service_1 = require("./services/calendar/calendar.service");
|
|
25
|
+
const email_service_1 = require("./services/email/email.service");
|
|
24
26
|
_a = new common_1.ConfigurableModuleBuilder().setClassMethodName('forRoot').build(), exports.ConfigurableModuleClass = _a.ConfigurableModuleClass, exports.MODULE_OPTIONS_TOKEN = _a.MODULE_OPTIONS_TOKEN;
|
|
25
27
|
let MicrosoftOutlookModule = class MicrosoftOutlookModule extends exports.ConfigurableModuleClass {
|
|
26
28
|
};
|
|
@@ -32,7 +34,7 @@ exports.MicrosoftOutlookModule = MicrosoftOutlookModule = __decorate([
|
|
|
32
34
|
typeorm_1.TypeOrmModule.forFeature([outlook_webhook_subscription_entity_1.OutlookWebhookSubscription, csrf_token_entity_1.MicrosoftCsrfToken]),
|
|
33
35
|
event_emitter_1.EventEmitterModule.forRoot(),
|
|
34
36
|
],
|
|
35
|
-
controllers: [microsoft_auth_controller_1.MicrosoftAuthController,
|
|
37
|
+
controllers: [microsoft_auth_controller_1.MicrosoftAuthController, calendar_controller_1.CalendarController, email_controller_1.EmailController],
|
|
36
38
|
providers: [
|
|
37
39
|
{
|
|
38
40
|
provide: constants_1.MICROSOFT_CONFIG,
|
|
@@ -41,10 +43,11 @@ exports.MicrosoftOutlookModule = MicrosoftOutlookModule = __decorate([
|
|
|
41
43
|
},
|
|
42
44
|
outlook_webhook_subscription_repository_1.OutlookWebhookSubscriptionRepository,
|
|
43
45
|
microsoft_csrf_token_repository_1.MicrosoftCsrfTokenRepository,
|
|
44
|
-
|
|
46
|
+
calendar_service_1.CalendarService,
|
|
47
|
+
email_service_1.EmailService,
|
|
45
48
|
microsoft_auth_service_1.MicrosoftAuthService,
|
|
46
49
|
],
|
|
47
|
-
exports: [
|
|
50
|
+
exports: [calendar_service_1.CalendarService, email_service_1.EmailService, microsoft_auth_service_1.MicrosoftAuthService],
|
|
48
51
|
})
|
|
49
52
|
], MicrosoftOutlookModule);
|
|
50
53
|
//# sourceMappingURL=microsoft-outlook.module.js.map
|
|
@@ -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,
|
|
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"}
|
|
@@ -17,7 +17,8 @@ class CreateOutlookTables1697025846000 {
|
|
|
17
17
|
access_token TEXT,
|
|
18
18
|
refresh_token TEXT,
|
|
19
19
|
created_at TIMESTAMP DEFAULT NOW() NOT NULL,
|
|
20
|
-
updated_at TIMESTAMP DEFAULT NOW() NOT NULL
|
|
20
|
+
updated_at TIMESTAMP DEFAULT NOW() NOT NULL,
|
|
21
|
+
CONSTRAINT "UQ_outlook_webhook_subscriptions_id" UNIQUE (subscription_id)
|
|
21
22
|
);
|
|
22
23
|
`);
|
|
23
24
|
await queryRunner.query(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1697025846000-CreateOutlookTables.js","sourceRoot":"","sources":["../../src/migrations/1697025846000-CreateOutlookTables.ts"],"names":[],"mappings":";;;AAEA,MAAa,gCAAgC;IACpC,KAAK,CAAC,EAAE,CAAC,WAAwB;QAEtC,MAAM,WAAW,CAAC,KAAK,CAAC
|
|
1
|
+
{"version":3,"file":"1697025846000-CreateOutlookTables.js","sourceRoot":"","sources":["../../src/migrations/1697025846000-CreateOutlookTables.ts"],"names":[],"mappings":";;;AAEA,MAAa,gCAAgC;IACpC,KAAK,CAAC,EAAE,CAAC,WAAwB;QAEtC,MAAM,WAAW,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;KAiBvB,CAAC,CAAC;QAGH,MAAM,WAAW,CAAC,KAAK,CAAC;;;;;;;;;KASvB,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,WAAwB;QACxC,MAAM,WAAW,CAAC,KAAK,CAAC,oDAAoD,CAAC,CAAC;QAC9E,MAAM,WAAW,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;IACxE,CAAC;CACF;AAvCD,4EAuCC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnsureUniqueSubscriptions1697026000000 = void 0;
|
|
4
|
+
class EnsureUniqueSubscriptions1697026000000 {
|
|
5
|
+
async up(queryRunner) {
|
|
6
|
+
const uniqueConstraintExists = await queryRunner.query(`
|
|
7
|
+
SELECT COUNT(*) as count
|
|
8
|
+
FROM sqlite_master
|
|
9
|
+
WHERE type='table'
|
|
10
|
+
AND name='outlook_webhook_subscriptions'
|
|
11
|
+
AND sql LIKE '%CONSTRAINT "UQ_outlook_webhook_subscriptions_id"%'
|
|
12
|
+
`);
|
|
13
|
+
if (uniqueConstraintExists[0].count === 0) {
|
|
14
|
+
await queryRunner.query(`
|
|
15
|
+
CREATE UNIQUE INDEX IF NOT EXISTS "UQ_outlook_webhook_subscriptions_id"
|
|
16
|
+
ON "outlook_webhook_subscriptions" ("subscription_id")
|
|
17
|
+
`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async down(queryRunner) {
|
|
21
|
+
await queryRunner.query(`
|
|
22
|
+
DROP INDEX IF EXISTS "UQ_outlook_webhook_subscriptions_id"
|
|
23
|
+
`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.EnsureUniqueSubscriptions1697026000000 = EnsureUniqueSubscriptions1697026000000;
|
|
27
|
+
//# sourceMappingURL=1697026000000-EnsureUniqueSubscriptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1697026000000-EnsureUniqueSubscriptions.js","sourceRoot":"","sources":["../../src/migrations/1697026000000-EnsureUniqueSubscriptions.ts"],"names":[],"mappings":";;;AAMA,MAAa,sCAAsC;IAC1C,KAAK,CAAC,EAAE,CAAC,WAAwB;QAEtC,MAAM,sBAAsB,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC;;;;;;KAMtD,CAAkB,CAAC;QAGpB,IAAI,sBAAsB,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;YAE1C,MAAM,WAAW,CAAC,KAAK,CAAC;;;OAGvB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,WAAwB;QAExC,MAAM,WAAW,CAAC,KAAK,CAAC;;KAEvB,CAAC,CAAC;IACL,CAAC;CACF;AA3BD,wFA2BC"}
|
|
@@ -22,7 +22,20 @@ let OutlookWebhookSubscriptionRepository = class OutlookWebhookSubscriptionRepos
|
|
|
22
22
|
this.repository = repository;
|
|
23
23
|
}
|
|
24
24
|
async saveSubscription(subscription) {
|
|
25
|
-
|
|
25
|
+
if (subscription.subscriptionId) {
|
|
26
|
+
const existingSubscription = await this.repository.findOne({
|
|
27
|
+
where: { subscriptionId: subscription.subscriptionId }
|
|
28
|
+
});
|
|
29
|
+
if (existingSubscription) {
|
|
30
|
+
const originalId = existingSubscription.id;
|
|
31
|
+
Object.assign(existingSubscription, subscription);
|
|
32
|
+
existingSubscription.id = originalId;
|
|
33
|
+
return this.repository.save(existingSubscription);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const subscriptionWithoutId = Object.assign({}, subscription);
|
|
37
|
+
delete subscriptionWithoutId.id;
|
|
38
|
+
const newSubscription = this.repository.create(subscriptionWithoutId);
|
|
26
39
|
return this.repository.save(newSubscription);
|
|
27
40
|
}
|
|
28
41
|
async findBySubscriptionId(subscriptionId) {
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,C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C;QAEpF,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YAC1B,KAAK,EAAE;gBACL,QAAQ,EAAE,IAAI;gBACd,kBAAkB,EAAE,IAAA,kBAAQ,EAAC,mBAAmB,CAAC;aAClD;SACF,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,uBAAuB;QAC3B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YAC1B,KAAK,EAAE;gBACL,QAAQ,EAAE,IAAI;gBACd,kBAAkB,EAAE,IAAA,kBAAQ,EAAC,GAAG,CAAC;aAClC;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAjFY,oFAAoC;+CAApC,oCAAoC;IADhD,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,gEAA0B,CAAC,CAAA;qCAChB,oBAAU;GAH9B,oCAAoC,CAiFhD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './microsoft-auth.service';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./microsoft-auth.service"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/auth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { EventEmitter2 } from '@nestjs/event-emitter';
|
|
2
|
+
import { TokenResponse } from '../../interfaces/outlook/token-response.interface';
|
|
3
|
+
import { CalendarService } from '../calendar/calendar.service';
|
|
4
|
+
import { EmailService } from '../email/email.service';
|
|
5
|
+
import { Subscription } from '@microsoft/microsoft-graph-types';
|
|
6
|
+
import { MicrosoftOutlookConfig } from '../../interfaces/config/outlook-config.interface';
|
|
7
|
+
import { MicrosoftCsrfTokenRepository } from '../../repositories/microsoft-csrf-token.repository';
|
|
8
|
+
import { StateObject } from '../../interfaces/microsoft-auth/state-object.interface';
|
|
9
|
+
import { PermissionScope } from '../../enums/permission-scope.enum';
|
|
10
|
+
export declare class MicrosoftAuthService {
|
|
11
|
+
private readonly eventEmitter;
|
|
12
|
+
private readonly calendarService;
|
|
13
|
+
private readonly emailService;
|
|
14
|
+
private readonly microsoftConfig;
|
|
15
|
+
private readonly csrfTokenRepository;
|
|
16
|
+
private readonly logger;
|
|
17
|
+
private readonly clientId;
|
|
18
|
+
private readonly clientSecret;
|
|
19
|
+
private readonly tenantId;
|
|
20
|
+
private readonly redirectUri;
|
|
21
|
+
private readonly tokenEndpoint;
|
|
22
|
+
private readonly requiredScopes;
|
|
23
|
+
private readonly defaultScopes;
|
|
24
|
+
private readonly CSRF_TOKEN_EXPIRY;
|
|
25
|
+
private subscriptionInProgress;
|
|
26
|
+
constructor(eventEmitter: EventEmitter2, calendarService: CalendarService, emailService: EmailService, microsoftConfig: MicrosoftOutlookConfig, csrfTokenRepository: MicrosoftCsrfTokenRepository);
|
|
27
|
+
private mapToMicrosoftScopes;
|
|
28
|
+
private buildRedirectUri;
|
|
29
|
+
cleanupExpiredTokens(): Promise<void>;
|
|
30
|
+
private generateCsrfToken;
|
|
31
|
+
parseState(state: string): StateObject | null;
|
|
32
|
+
validateCsrfToken(token: string, timestamp?: number): Promise<string | null>;
|
|
33
|
+
getLoginUrl(userId: string, scopes?: PermissionScope[]): Promise<string>;
|
|
34
|
+
exchangeCodeForToken(code: string, state: string): Promise<TokenResponse>;
|
|
35
|
+
private setupSubscriptions;
|
|
36
|
+
refreshAccessToken(refreshToken: string, userId?: number, calendarId?: string, scopes?: PermissionScope[]): Promise<TokenResponse>;
|
|
37
|
+
renewWebhookSubscription(subscriptionId: string, accessToken: string, refreshToken: string, scopes?: PermissionScope[]): Promise<Subscription>;
|
|
38
|
+
private hasCalendarPermission;
|
|
39
|
+
private hasEmailPermission;
|
|
40
|
+
isTokenExpired(tokenExpiry: Date, bufferMinutes?: number): boolean;
|
|
41
|
+
}
|