@futura-dev/microsoft-sdk 1.1.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/graph-api/graph-api.module.d.ts +0 -1
- package/dist/graph-api/graph-api.module.d.ts.map +1 -1
- package/dist/graph-api/graph-api.module.js.map +1 -1
- package/dist/graph-api/graph-api.service.d.ts +0 -1
- package/dist/graph-api/graph-api.service.d.ts.map +1 -1
- package/dist/graph-api/graph-api.service.js +5 -9
- package/dist/graph-api/graph-api.service.js.map +1 -1
- package/dist/sharepoint-api/sharepoint-api.module.d.ts +1 -1
- package/dist/sharepoint-api/sharepoint-api.module.d.ts.map +1 -1
- package/dist/sharepoint-api/sharepoint-api.module.js.map +1 -1
- package/dist/sharepoint-api/sharepoint-api.service.d.ts.map +1 -1
- package/dist/sharepoint-api/sharepoint-api.service.js +4 -7
- package/dist/sharepoint-api/sharepoint-api.service.js.map +1 -1
- package/package.json +4 -1
- package/src/graph-api/graph-api.module.ts +4 -5
- package/src/graph-api/graph-api.service.ts +9 -13
- package/src/sharepoint-api/sharepoint-api.module.ts +2 -2
- package/src/sharepoint-api/sharepoint-api.service.ts +8 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-api.module.d.ts","sourceRoot":"","sources":["../../src/graph-api/graph-api.module.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"graph-api.module.d.ts","sourceRoot":"","sources":["../../src/graph-api/graph-api.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAoB,MAAM,gBAAgB,CAAC;AAGjE,MAAM,MAAM,kBAAkB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB,CAAA;AAED,qBACa,cAAc;IACvB,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,aAAa;CAe/E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-api.module.js","sourceRoot":"","sources":["../../src/graph-api/graph-api.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"graph-api.module.js","sourceRoot":"","sources":["../../src/graph-api/graph-api.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAiE;AACjE,2DAAsD;AAUtD,IAAa,cAAc,sBAA3B,MAAa,cAAc;IACvB,MAAM,CAAC,UAAU,CAAC,KAAa,EAAE,OAA2B;QAExD,MAAM,QAAQ,GAAa;YACvB,OAAO,EAAE,KAAK;YACd,UAAU,EAAE,KAAK,IAAI,EAAE;gBACnB,OAAO,IAAI,mCAAe,mBAAM,OAAO,EAAG,CAAC;YAC/C,CAAC;SACJ,CAAA;QACD,OAAO;YACH,MAAM,EAAE,gBAAc;YACtB,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,CAAC,QAAQ,CAAC;YACrB,OAAO,EAAE,CAAC,QAAQ,CAAC;SACtB,CAAA;IACL,CAAC;CACJ,CAAA;AAhBY,cAAc;IAD1B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,cAAc,CAgB1B;AAhBY,wCAAc"}
|
|
@@ -6,7 +6,6 @@ export declare class GraphApiService {
|
|
|
6
6
|
private readonly client_id;
|
|
7
7
|
private readonly client_secret;
|
|
8
8
|
private readonly scopes;
|
|
9
|
-
private readonly grant_type;
|
|
10
9
|
private readonly msal_client;
|
|
11
10
|
private readonly graph_client;
|
|
12
11
|
constructor(options: GraphModuleOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-api.service.d.ts","sourceRoot":"","sources":["../../src/graph-api/graph-api.service.ts"],"names":[],"mappings":";AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"graph-api.service.d.ts","sourceRoot":"","sources":["../../src/graph-api/graph-api.service.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAIxD,qBACa,eAAe;IASZ,QAAQ,CAAC,OAAO,EAAE,kBAAkB;IAPhD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAW;IAClC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqC;IACjE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;gBAEjB,OAAO,EAAE,kBAAkB;IA0BhD;;;OAGG;IACH,WAAW,YAAmB;QAC1B,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAClB,kBAIC;IAEF;;;OAGG;IACH,cAAc,eAAsB;QAChC,MAAM,EAAE,MAAM,CAAA;QACd,MAAM,EAAE,MAAM,CAAA;KACjB,kBAIA;IAED;;;OAGG;IACH,kBAAkB,YAAmB;QACjC,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAA;QAChB,IAAI,EAAE,MAAM,CAAA;KACf,kBAIA;IAED;;;OAGG;IACH,cAAc,YAAmB;QAC7B,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE;YAAE,MAAM,EAAE,OAAO,MAAM,EAAE,GAAG,CAAC,CAAA;SAAE,CAAA;KACxC,kBAIA;CAGJ"}
|
|
@@ -38,6 +38,7 @@ const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
|
38
38
|
const msal = __importStar(require("@azure/msal-node"));
|
|
39
39
|
let GraphApiService = class GraphApiService {
|
|
40
40
|
constructor(options) {
|
|
41
|
+
var _a;
|
|
41
42
|
this.options = options;
|
|
42
43
|
/**
|
|
43
44
|
*
|
|
@@ -78,25 +79,20 @@ let GraphApiService = class GraphApiService {
|
|
|
78
79
|
this.tenant_id = options.tenantId;
|
|
79
80
|
this.client_id = options.clientId;
|
|
80
81
|
this.client_secret = options.clientSecret;
|
|
81
|
-
this.scopes = options.scopes;
|
|
82
|
-
this.grant_type = options.grantType;
|
|
82
|
+
this.scopes = ((_a = options.scopes) === null || _a === void 0 ? void 0 : _a.split(" ")) || ["https://graph.microsoft.com/.default"];
|
|
83
83
|
// init msal client
|
|
84
84
|
this.msal_client = new msal.ConfidentialClientApplication({
|
|
85
85
|
auth: {
|
|
86
|
-
|
|
87
|
-
`https://login.microsoftonline.com/${this.tenant_id}`,
|
|
88
|
-
],
|
|
86
|
+
authority: `https://login.microsoftonline.com/${this.tenant_id}`,
|
|
89
87
|
clientId: `${this.client_id}`,
|
|
90
|
-
clientSecret: `${this.client_secret}
|
|
88
|
+
clientSecret: `${this.client_secret}`,
|
|
91
89
|
},
|
|
92
90
|
});
|
|
93
91
|
// init graph client
|
|
94
92
|
this.graph_client = microsoft_graph_client_1.Client.init({
|
|
95
93
|
authProvider: async (resolve) => {
|
|
96
|
-
var _a;
|
|
97
94
|
this.msal_client.acquireTokenByClientCredential({
|
|
98
|
-
|
|
99
|
-
scopes: ((_a = this.scopes) === null || _a === void 0 ? void 0 : _a.split(" ")) || ["https://graph.microsoft.com/.default"],
|
|
95
|
+
scopes: this.scopes,
|
|
100
96
|
})
|
|
101
97
|
.then((token) => resolve(null, token.accessToken))
|
|
102
98
|
.catch(error => resolve(error, null));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-api.service.js","sourceRoot":"","sources":["../../src/graph-api/graph-api.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"graph-api.service.js","sourceRoot":"","sources":["../../src/graph-api/graph-api.service.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};
|
|
9
9
|
export declare class SharepointApiModule {
|
|
10
10
|
static forFeature(token: string, options: SharepointModuleOptions): DynamicModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharepoint-api.module.d.ts","sourceRoot":"","sources":["../../src/sharepoint-api/sharepoint-api.module.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"sharepoint-api.module.d.ts","sourceRoot":"","sources":["../../src/sharepoint-api/sharepoint-api.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAoB,MAAM,gBAAgB,CAAC;AAGjE,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAA;AAED,qBACa,mBAAmB;IAC9B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,GAAG,aAAa;CAgBlF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharepoint-api.module.js","sourceRoot":"","sources":["../../src/sharepoint-api/sharepoint-api.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"sharepoint-api.module.js","sourceRoot":"","sources":["../../src/sharepoint-api/sharepoint-api.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAiE;AACjE,qEAAgE;AAWhE,IAAa,mBAAmB,2BAAhC,MAAa,mBAAmB;IAC9B,MAAM,CAAC,UAAU,CAAC,KAAa,EAAE,OAAgC;QAE/D,MAAM,QAAQ,GAAa;YACzB,OAAO,EAAE,KAAK;YACd,UAAU,EAAE,KAAK,IAAI,EAAE;gBACrB,OAAO,IAAI,6CAAoB,mBAAM,OAAO,EAAG,CAAC;YAClD,CAAC;SACF,CAAA;QAED,OAAO;YACL,MAAM,EAAE,qBAAmB;YAC3B,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,CAAC,QAAQ,CAAC;YACrB,OAAO,EAAE,CAAC,QAAQ,CAAC;SACpB,CAAA;IACH,CAAC;CACF,CAAA;AAjBY,mBAAmB;IAD/B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,mBAAmB,CAiB/B;AAjBY,kDAAmB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharepoint-api.service.d.ts","sourceRoot":"","sources":["../../src/sharepoint-api/sharepoint-api.service.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"sharepoint-api.service.d.ts","sourceRoot":"","sources":["../../src/sharepoint-api/sharepoint-api.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAIlE,qBACa,oBAAoB;IAUjB,QAAQ,CAAC,OAAO,EAAE,uBAAuB;IARrD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAW;IAClC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqC;IACjE,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;gBAEtB,OAAO,EAAE,uBAAuB;IA+BrD;;;OAGG;IACH,oBAAoB,WAAkB,MAAM,kBAI1C;IAEF;;;;;OAKG;IACH,sBAAsB,WACV,MAAM,mBACG,MAAM,uBACF,MAAM,kBAS9B;IAED;;;;OAIG;IACH,sBAAsB,WAAkB,MAAM,kBAAkB,MAAM,kBAIpE;IAEF;;;OAGG;IACH,WAAW,YAAmB;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,IAAI,CAAA;KAAE,kBAe3D;CACJ"}
|
|
@@ -55,7 +55,6 @@ let SharepointApiService = class SharepointApiService {
|
|
|
55
55
|
* @param expirationTimestamp
|
|
56
56
|
*/
|
|
57
57
|
this.createListSubscription = async (listId, notificationUrl, expirationTimestamp) => {
|
|
58
|
-
console.log('[SUBSCRIPTION REQUEST]:', listId, notificationUrl);
|
|
59
58
|
// read key from files
|
|
60
59
|
return this.sharepoint_client.api(`https://futuraitsrl.sharepoint.com/sites/hr/_api/web/lists('${listId}')/subscriptions`).post({
|
|
61
60
|
resource: 'https://futuraitsrl.sharepoint.com/sites/hr/Lists/Recruiting%20Board/AllItems.aspx',
|
|
@@ -95,15 +94,13 @@ let SharepointApiService = class SharepointApiService {
|
|
|
95
94
|
};
|
|
96
95
|
this.tenant_id = options.tenantId;
|
|
97
96
|
this.client_id = options.clientId;
|
|
98
|
-
this.scopes = options.scopes;
|
|
97
|
+
this.scopes = options.scopes.split(" ") || [""];
|
|
99
98
|
this.thumbprint = options.thumbprint;
|
|
100
99
|
this.private_key = options.privateKey;
|
|
101
100
|
// init msal client
|
|
102
101
|
this.msal_client = new msal.ConfidentialClientApplication({
|
|
103
102
|
auth: {
|
|
104
|
-
|
|
105
|
-
`https://login.microsoftonline.com/${this.tenant_id}`,
|
|
106
|
-
],
|
|
103
|
+
authority: `https://login.microsoftonline.com/${this.tenant_id}`,
|
|
107
104
|
clientId: `${this.client_id}`,
|
|
108
105
|
clientCertificate: {
|
|
109
106
|
thumbprint: this.thumbprint,
|
|
@@ -115,12 +112,12 @@ let SharepointApiService = class SharepointApiService {
|
|
|
115
112
|
this.sharepoint_client = microsoft_graph_client_1.Client.init({
|
|
116
113
|
authProvider: async (resolve) => {
|
|
117
114
|
this.msal_client.acquireTokenByClientCredential({
|
|
118
|
-
authority: `https://login.microsoftonline.com/${this.tenant_id}`,
|
|
119
115
|
scopes: this.scopes,
|
|
120
116
|
})
|
|
121
117
|
.then((token) => resolve(null, token.accessToken))
|
|
122
118
|
.catch(error => resolve(error, null));
|
|
123
|
-
}
|
|
119
|
+
},
|
|
120
|
+
customHosts: new Set(["futuraitsrl.sharepoint.com"])
|
|
124
121
|
});
|
|
125
122
|
}
|
|
126
123
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharepoint-api.service.js","sourceRoot":"","sources":["../../src/sharepoint-api/sharepoint-api.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"sharepoint-api.service.js","sourceRoot":"","sources":["../../src/sharepoint-api/sharepoint-api.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,uDAAyC;AAEzC,8EAA2D;AAG3D,IACa,oBAAoB,GADjC,MACa,oBAAoB;IAU7B,YAAqB,OAAgC;QAAhC,YAAO,GAAP,OAAO,CAAyB;QA+BrD;;;WAGG;QACH,yBAAoB,GAAG,KAAK,EAAE,MAAc,EAAE,EAAE;YAC5C,OAAO,IAAI,CAAC,iBAAiB;iBACxB,GAAG,CAAC,+DAA+D,MAAM,kBAAkB,CAAC;iBAC5F,GAAG,EAAE,CAAA;QACd,CAAC,CAAC;QAEF;;;;;WAKG;QACH,2BAAsB,GAAG,KAAK,EAC1B,MAAc,EACd,eAAuB,EACvB,mBAA2B,EAC7B,EAAE;YACA,sBAAsB;YACtB,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,+DAA+D,MAAM,kBAAkB,CAAC,CAAC,IAAI,CAAC;gBAC5H,QAAQ,EACJ,oFAAoF;gBACxF,eAAe,EAAE,GAAG,eAAe,EAAE;gBACrC,kBAAkB,EAAE,IAAI,IAAI,CAAC,mBAAmB,CAAC,CAAC,WAAW,EAAE;aAClE,CAAC,CAAA;QACN,CAAC,CAAA;QAED;;;;WAIG;QACH,2BAAsB,GAAG,KAAK,EAAE,MAAc,EAAE,cAAsB,EAAE,EAAE;YACtE,OAAO,IAAI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B,EAAE;oBACf,UAAU,EAAE,IAAI,CAAC,UAAU;oBAC3B,UAAU,EAAE,IAAI,CAAC,WAAW;iBAC/B;aACJ;SACJ,CAAC,CAAC;QACH,oBAAoB;QACpB,IAAI,CAAC,iBAAiB,GAAG,+BAAM,CAAC,IAAI,CAAC;YACjC,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;gBAC5B,IAAI,CAAC,WAAW,CAAC,8BAA8B,CAAC;oBAC5C,MAAM,EAAE,IAAI,CAAC,MAAM;iBACtB,CAAC;qBACG,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;qBACjD,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAA;YAC7C,CAAC;YACD,WAAW,EAAE,IAAI,GAAG,CAAC,CAAC,4BAA4B,CAAC,CAAC;SACvD,CAAC,CAAA;IACN,CAAC;CA+DJ,CAAA;AAtGY,oBAAoB;IADhC,IAAA,mBAAU,GAAE;;GACA,oBAAoB,CAsGhC;AAtGY,oDAAoB"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@futura-dev/microsoft-sdk",
|
|
3
3
|
"private": false,
|
|
4
4
|
"description": "",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.2.1",
|
|
6
6
|
"main": "dist/index",
|
|
7
7
|
"types": "dist/index",
|
|
8
8
|
"scripts": {
|
|
@@ -28,5 +28,8 @@
|
|
|
28
28
|
"@typescript-eslint/eslint-plugin": "^5.59.5",
|
|
29
29
|
"eslint": "^8.40.0",
|
|
30
30
|
"rimraf": "^5.0.0"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18"
|
|
31
34
|
}
|
|
32
35
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {DynamicModule, Module} from '@nestjs/common';
|
|
2
|
-
import {GraphApiService} from './graph-api.service';
|
|
1
|
+
import { DynamicModule, Module, Provider } from '@nestjs/common';
|
|
2
|
+
import { GraphApiService } from './graph-api.service';
|
|
3
3
|
|
|
4
4
|
export type GraphModuleOptions = {
|
|
5
5
|
tenantId: string;
|
|
6
6
|
clientId: string;
|
|
7
7
|
clientSecret: string;
|
|
8
|
-
grantType: 'authorization_code' | 'client_credentials';
|
|
9
8
|
scopes: string;
|
|
10
9
|
}
|
|
11
10
|
|
|
@@ -13,10 +12,10 @@ export type GraphModuleOptions = {
|
|
|
13
12
|
export class GraphApiModule {
|
|
14
13
|
static forFeature(token: string, options: GraphModuleOptions): DynamicModule {
|
|
15
14
|
|
|
16
|
-
const provider = {
|
|
15
|
+
const provider: Provider = {
|
|
17
16
|
provide: token,
|
|
18
17
|
useFactory: async () => {
|
|
19
|
-
return new GraphApiService({...options});
|
|
18
|
+
return new GraphApiService({ ...options });
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {Injectable} from '@nestjs/common';
|
|
2
|
-
import {GraphModuleOptions} from "./graph-api.module";
|
|
3
|
-
import {Client} from '@microsoft/microsoft-graph-client'
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { GraphModuleOptions } from "./graph-api.module";
|
|
3
|
+
import { Client } from '@microsoft/microsoft-graph-client'
|
|
4
4
|
import * as msal from "@azure/msal-node";
|
|
5
5
|
|
|
6
6
|
@Injectable()
|
|
@@ -9,8 +9,7 @@ export class GraphApiService {
|
|
|
9
9
|
private readonly tenant_id: string;
|
|
10
10
|
private readonly client_id: string;
|
|
11
11
|
private readonly client_secret: string;
|
|
12
|
-
private readonly scopes: string;
|
|
13
|
-
private readonly grant_type: string;
|
|
12
|
+
private readonly scopes: string[];
|
|
14
13
|
private readonly msal_client: msal.ConfidentialClientApplication;
|
|
15
14
|
private readonly graph_client: Client;
|
|
16
15
|
|
|
@@ -18,24 +17,21 @@ export class GraphApiService {
|
|
|
18
17
|
this.tenant_id = options.tenantId;
|
|
19
18
|
this.client_id = options.clientId;
|
|
20
19
|
this.client_secret = options.clientSecret;
|
|
21
|
-
this.scopes = options.scopes;
|
|
22
|
-
|
|
20
|
+
this.scopes = options.scopes?.split(" ") || ["https://graph.microsoft.com/.default"];
|
|
21
|
+
|
|
23
22
|
// init msal client
|
|
24
23
|
this.msal_client = new msal.ConfidentialClientApplication({
|
|
25
24
|
auth: {
|
|
26
|
-
|
|
27
|
-
`https://login.microsoftonline.com/${this.tenant_id}`,
|
|
28
|
-
],
|
|
25
|
+
authority: `https://login.microsoftonline.com/${this.tenant_id}`,
|
|
29
26
|
clientId: `${this.client_id}`,
|
|
30
|
-
clientSecret: `${this.client_secret}
|
|
27
|
+
clientSecret: `${this.client_secret}`,
|
|
31
28
|
},
|
|
32
29
|
});
|
|
33
30
|
// init graph client
|
|
34
31
|
this.graph_client = Client.init({
|
|
35
32
|
authProvider: async (resolve) => {
|
|
36
33
|
this.msal_client.acquireTokenByClientCredential({
|
|
37
|
-
|
|
38
|
-
scopes: this.scopes?.split(" ") || ["https://graph.microsoft.com/.default"],
|
|
34
|
+
scopes: this.scopes,
|
|
39
35
|
})
|
|
40
36
|
.then((token) => resolve(null, token.accessToken))
|
|
41
37
|
.catch(error => resolve(error, null))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {DynamicModule, Module, Provider} from '@nestjs/common';
|
|
1
|
+
import { DynamicModule, Module, Provider } from '@nestjs/common';
|
|
2
2
|
import { SharepointApiService } from './sharepoint-api.service';
|
|
3
3
|
|
|
4
4
|
export type SharepointModuleOptions = {
|
|
@@ -6,7 +6,7 @@ export type SharepointModuleOptions = {
|
|
|
6
6
|
clientId: string;
|
|
7
7
|
thumbprint: string;
|
|
8
8
|
privateKey: string;
|
|
9
|
-
scopes: string
|
|
9
|
+
scopes: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
@Module({})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {Injectable} from '@nestjs/common';
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import * as msal from "@azure/msal-node";
|
|
3
|
-
import {SharepointModuleOptions} from "./sharepoint-api.module";
|
|
4
|
-
import {Client} from "@microsoft/microsoft-graph-client";
|
|
3
|
+
import { SharepointModuleOptions } from "./sharepoint-api.module";
|
|
4
|
+
import { Client } from "@microsoft/microsoft-graph-client";
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
@Injectable()
|
|
@@ -18,15 +18,14 @@ export class SharepointApiService {
|
|
|
18
18
|
constructor(readonly options: SharepointModuleOptions) {
|
|
19
19
|
this.tenant_id = options.tenantId;
|
|
20
20
|
this.client_id = options.clientId;
|
|
21
|
-
this.scopes = options.scopes;
|
|
21
|
+
this.scopes = options.scopes.split(" ") || [""];
|
|
22
22
|
this.thumbprint = options.thumbprint;
|
|
23
23
|
this.private_key = options.privateKey;
|
|
24
|
+
|
|
24
25
|
// init msal client
|
|
25
26
|
this.msal_client = new msal.ConfidentialClientApplication({
|
|
26
27
|
auth: {
|
|
27
|
-
|
|
28
|
-
`https://login.microsoftonline.com/${this.tenant_id}`,
|
|
29
|
-
],
|
|
28
|
+
authority: `https://login.microsoftonline.com/${this.tenant_id}`,
|
|
30
29
|
clientId: `${this.client_id}`,
|
|
31
30
|
clientCertificate: {
|
|
32
31
|
thumbprint: this.thumbprint,
|
|
@@ -38,12 +37,12 @@ export class SharepointApiService {
|
|
|
38
37
|
this.sharepoint_client = Client.init({
|
|
39
38
|
authProvider: async (resolve) => {
|
|
40
39
|
this.msal_client.acquireTokenByClientCredential({
|
|
41
|
-
authority: `https://login.microsoftonline.com/${this.tenant_id}`,
|
|
42
40
|
scopes: this.scopes,
|
|
43
41
|
})
|
|
44
42
|
.then((token) => resolve(null, token.accessToken))
|
|
45
43
|
.catch(error => resolve(error, null))
|
|
46
|
-
}
|
|
44
|
+
},
|
|
45
|
+
customHosts: new Set(["futuraitsrl.sharepoint.com"])
|
|
47
46
|
})
|
|
48
47
|
}
|
|
49
48
|
|
|
@@ -68,7 +67,6 @@ export class SharepointApiService {
|
|
|
68
67
|
notificationUrl: string,
|
|
69
68
|
expirationTimestamp: number,
|
|
70
69
|
) => {
|
|
71
|
-
console.log('[SUBSCRIPTION REQUEST]:', listId, notificationUrl);
|
|
72
70
|
// read key from files
|
|
73
71
|
return this.sharepoint_client.api(`https://futuraitsrl.sharepoint.com/sites/hr/_api/web/lists('${listId}')/subscriptions`).post({
|
|
74
72
|
resource:
|
|
@@ -109,5 +107,4 @@ export class SharepointApiService {
|
|
|
109
107
|
},
|
|
110
108
|
})
|
|
111
109
|
}
|
|
112
|
-
|
|
113
110
|
}
|