@memberjunction/communication-ms-graph 2.27.0 → 2.28.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/dist/MSGraphProvider.js +36 -33
- package/dist/MSGraphProvider.js.map +1 -1
- package/dist/auth.js +1 -61
- package/dist/auth.js.map +1 -1
- package/dist/config.js +0 -1
- package/dist/config.js.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/package.json +15 -13
- package/dist/MSGraphProvider.d.ts +0 -20
- package/dist/MSGraphProvider.d.ts.map +0 -1
- package/dist/auth.d.ts +0 -25
- package/dist/auth.d.ts.map +0 -1
- package/dist/config.d.ts +0 -8
- package/dist/config.d.ts.map +0 -1
- package/dist/fetch.d.ts +0 -7
- package/dist/fetch.d.ts.map +0 -1
- package/dist/fetch.js +0 -41
- package/dist/fetch.js.map +0 -1
- package/dist/generic/models.d.ts +0 -40
- package/dist/generic/models.d.ts.map +0 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +0 -1
package/dist/MSGraphProvider.js
CHANGED
|
@@ -28,6 +28,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
28
28
|
__setModuleDefault(result, mod);
|
|
29
29
|
return result;
|
|
30
30
|
};
|
|
31
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
|
+
};
|
|
31
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
35
|
exports.LoadMSGraphProvider = exports.MSGraphProvider = void 0;
|
|
33
36
|
const communication_types_1 = require("@memberjunction/communication-types");
|
|
@@ -36,9 +39,6 @@ const core_1 = require("@memberjunction/core");
|
|
|
36
39
|
const html_to_text_1 = require("html-to-text");
|
|
37
40
|
const Auth = __importStar(require("./auth"));
|
|
38
41
|
const Config = __importStar(require("./config"));
|
|
39
|
-
/**
|
|
40
|
-
* Implementation of the MS Graph provider for sending and receiving messages
|
|
41
|
-
*/
|
|
42
42
|
let MSGraphProvider = class MSGraphProvider extends communication_types_1.BaseCommunicationProvider {
|
|
43
43
|
constructor() {
|
|
44
44
|
super();
|
|
@@ -98,14 +98,13 @@ let MSGraphProvider = class MSGraphProvider extends communication_types_1.BaseCo
|
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
async ReplyToMessage(
|
|
101
|
+
async ReplyToMessage(params) {
|
|
102
102
|
try {
|
|
103
103
|
const user = await this.GetServiceAccount();
|
|
104
104
|
if (!user) {
|
|
105
105
|
return {
|
|
106
|
-
Message: message,
|
|
107
106
|
Success: false,
|
|
108
|
-
|
|
107
|
+
ErrorMessage: 'Service account not found'
|
|
109
108
|
};
|
|
110
109
|
}
|
|
111
110
|
const reply = {
|
|
@@ -113,27 +112,25 @@ let MSGraphProvider = class MSGraphProvider extends communication_types_1.BaseCo
|
|
|
113
112
|
toRecipients: [
|
|
114
113
|
{
|
|
115
114
|
emailAddress: {
|
|
116
|
-
address:
|
|
115
|
+
address: params.Message.From
|
|
117
116
|
}
|
|
118
117
|
}
|
|
119
118
|
]
|
|
120
119
|
},
|
|
121
|
-
comment:
|
|
120
|
+
comment: params.Message.ProcessedBody || params.Message.ProcessedHTMLBody
|
|
122
121
|
};
|
|
123
|
-
const sendMessagePath = `${Auth.ApiConfig.uri}/${user.id}/messages/${
|
|
124
|
-
await Auth.GraphClient.api(sendMessagePath).post(reply);
|
|
122
|
+
const sendMessagePath = `${Auth.ApiConfig.uri}/${user.id}/messages/${params.MessageID}/reply`;
|
|
123
|
+
const result = await Auth.GraphClient.api(sendMessagePath).post(reply);
|
|
125
124
|
return {
|
|
126
|
-
Message: message,
|
|
127
125
|
Success: true,
|
|
128
|
-
|
|
126
|
+
Result: result
|
|
129
127
|
};
|
|
130
128
|
}
|
|
131
129
|
catch (ex) {
|
|
132
130
|
(0, core_1.LogError)(ex);
|
|
133
131
|
return {
|
|
134
|
-
Message: message,
|
|
135
132
|
Success: false,
|
|
136
|
-
|
|
133
|
+
ErrorMessage: 'Error sending message'
|
|
137
134
|
};
|
|
138
135
|
}
|
|
139
136
|
}
|
|
@@ -142,36 +139,41 @@ let MSGraphProvider = class MSGraphProvider extends communication_types_1.BaseCo
|
|
|
142
139
|
const user = await this.GetServiceAccount(contextData?.Email);
|
|
143
140
|
if (!user || !user.id) {
|
|
144
141
|
return {
|
|
142
|
+
Success: false,
|
|
145
143
|
Messages: []
|
|
146
144
|
};
|
|
147
145
|
}
|
|
148
|
-
let filter = "
|
|
149
|
-
let top =
|
|
146
|
+
let filter = "";
|
|
147
|
+
let top = params.NumMessages;
|
|
148
|
+
if (params.UnreadOnly) {
|
|
149
|
+
filter = "(isRead eq false)";
|
|
150
|
+
}
|
|
150
151
|
if (contextData && contextData.Filter) {
|
|
151
152
|
filter = contextData.Filter;
|
|
152
153
|
}
|
|
153
|
-
if (contextData && contextData.Top) {
|
|
154
|
-
top = contextData.Top;
|
|
155
|
-
}
|
|
156
154
|
const messagesPath = `${Auth.ApiConfig.uri}/${user.id}/messages`;
|
|
157
155
|
const Client = Auth.GraphClient;
|
|
158
156
|
const response = await Client.api(messagesPath)
|
|
159
157
|
.filter(filter).top(top).get();
|
|
160
158
|
if (!response) {
|
|
161
|
-
console.log('Error: could not get messages');
|
|
162
159
|
return {
|
|
160
|
+
Success: false,
|
|
163
161
|
Messages: []
|
|
164
162
|
};
|
|
165
163
|
}
|
|
166
164
|
const sourceMessages = response.value;
|
|
167
165
|
let messageResults = {
|
|
166
|
+
Success: true,
|
|
168
167
|
SourceData: sourceMessages,
|
|
169
168
|
Messages: []
|
|
170
169
|
};
|
|
171
170
|
const messages = sourceMessages.map((message) => {
|
|
171
|
+
const replyTo = message.replyTo?.map((replyTo) => replyTo.emailAddress?.address || '') || [];
|
|
172
|
+
const primaryToRecipient = replyTo.length > 0 ? replyTo[0] : '';
|
|
172
173
|
return {
|
|
173
174
|
From: message.from?.emailAddress?.address || '',
|
|
174
|
-
|
|
175
|
+
To: primaryToRecipient,
|
|
176
|
+
ReplyTo: replyTo,
|
|
175
177
|
Subject: message.subject || '',
|
|
176
178
|
Body: contextData?.ReturnAsPlainTex ? this.HTMLConverter(message.body?.content || '') : message.body?.content || '',
|
|
177
179
|
ExternalSystemRecordID: message.id || '',
|
|
@@ -187,17 +189,17 @@ let MSGraphProvider = class MSGraphProvider extends communication_types_1.BaseCo
|
|
|
187
189
|
}
|
|
188
190
|
async ForwardMessage(params) {
|
|
189
191
|
try {
|
|
190
|
-
if (!params.
|
|
192
|
+
if (!params.MessageID) {
|
|
191
193
|
return {
|
|
192
194
|
Success: false,
|
|
193
|
-
|
|
195
|
+
ErrorMessage: 'Message ID not set'
|
|
194
196
|
};
|
|
195
197
|
}
|
|
196
198
|
const user = await this.GetServiceAccount();
|
|
197
199
|
if (!user) {
|
|
198
200
|
return {
|
|
199
201
|
Success: false,
|
|
200
|
-
|
|
202
|
+
ErrorMessage: 'Service account not found'
|
|
201
203
|
};
|
|
202
204
|
}
|
|
203
205
|
const forward = {
|
|
@@ -211,17 +213,18 @@ let MSGraphProvider = class MSGraphProvider extends communication_types_1.BaseCo
|
|
|
211
213
|
};
|
|
212
214
|
})
|
|
213
215
|
};
|
|
214
|
-
const sendMessagePath = `${Auth.ApiConfig.uri}/${user.id}/messages/${params.
|
|
215
|
-
await Auth.GraphClient.api(sendMessagePath).post(forward);
|
|
216
|
+
const sendMessagePath = `${Auth.ApiConfig.uri}/${user.id}/messages/${params.MessageID}/forward`;
|
|
217
|
+
const forwardResult = await Auth.GraphClient.api(sendMessagePath).post(forward);
|
|
216
218
|
return {
|
|
217
|
-
Success: true
|
|
219
|
+
Success: true,
|
|
220
|
+
Result: forwardResult
|
|
218
221
|
};
|
|
219
222
|
}
|
|
220
223
|
catch (ex) {
|
|
221
224
|
(0, core_1.LogError)(ex);
|
|
222
225
|
return {
|
|
223
|
-
|
|
224
|
-
Success: false
|
|
226
|
+
ErrorMessage: 'An Error occurred while forwarding the message',
|
|
227
|
+
Success: false
|
|
225
228
|
};
|
|
226
229
|
}
|
|
227
230
|
}
|
|
@@ -230,8 +233,8 @@ let MSGraphProvider = class MSGraphProvider extends communication_types_1.BaseCo
|
|
|
230
233
|
return this.ServiceAccount;
|
|
231
234
|
}
|
|
232
235
|
let accountEmail = email || Config.AZURE_ACCOUNT_EMAIL;
|
|
233
|
-
const
|
|
234
|
-
const user = await Auth.
|
|
236
|
+
const endpoint = `${Auth.ApiConfig.uri}/${accountEmail}`;
|
|
237
|
+
const user = await Auth.GraphClient.api(endpoint).get();
|
|
235
238
|
if (!user) {
|
|
236
239
|
(0, core_1.LogError)('Error: could not get user info');
|
|
237
240
|
return null;
|
|
@@ -263,10 +266,10 @@ let MSGraphProvider = class MSGraphProvider extends communication_types_1.BaseCo
|
|
|
263
266
|
};
|
|
264
267
|
exports.MSGraphProvider = MSGraphProvider;
|
|
265
268
|
exports.MSGraphProvider = MSGraphProvider = __decorate([
|
|
266
|
-
(0, global_1.RegisterClass)(communication_types_1.BaseCommunicationProvider, 'Microsoft Graph')
|
|
269
|
+
(0, global_1.RegisterClass)(communication_types_1.BaseCommunicationProvider, 'Microsoft Graph'),
|
|
270
|
+
__metadata("design:paramtypes", [])
|
|
267
271
|
], MSGraphProvider);
|
|
268
272
|
function LoadMSGraphProvider() {
|
|
269
|
-
// do nothing, this prevents tree shaking from removing this class
|
|
270
273
|
}
|
|
271
274
|
exports.LoadMSGraphProvider = LoadMSGraphProvider;
|
|
272
275
|
//# sourceMappingURL=MSGraphProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MSGraphProvider.js","sourceRoot":"","sources":["../src/MSGraphProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MSGraphProvider.js","sourceRoot":"","sources":["../src/MSGraphProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6EAA+O;AAG/O,mDAAuD;AAC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,eAAe;IAD3B,IAAA,sBAAa,EAAC,+CAAyB,EAAE,iBAAiB,CAAC;;GAC/C,eAAe,CAuQ3B;AAED,SAAgB,mBAAmB;AAEnC,CAAC;AAFD,kDAEC"}
|
package/dist/auth.js
CHANGED
|
@@ -22,78 +22,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
26
|
+
exports.ApiConfig = exports.GraphClient = void 0;
|
|
30
27
|
const identity_1 = require("@azure/identity");
|
|
31
28
|
const Config = __importStar(require("./config"));
|
|
32
|
-
const msal_node_1 = __importDefault(require("@azure/msal-node"));
|
|
33
29
|
const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
34
30
|
const azureTokenCredentials_1 = require("@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials");
|
|
35
|
-
const core_1 = require("@memberjunction/core");
|
|
36
|
-
/**
|
|
37
|
-
* Configuration object to be passed to MSAL instance on creation.
|
|
38
|
-
* For a full list of MSAL Node configuration parameters, visit:
|
|
39
|
-
* https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-node/docs/configuration.md
|
|
40
|
-
*/
|
|
41
|
-
const msalConfig = {
|
|
42
|
-
auth: {
|
|
43
|
-
clientId: Config.AZURE_CLIENT_ID,
|
|
44
|
-
authority: Config.AZURE_AAD_ENDPOINT + '/' + Config.AZURE_TENANT_ID,
|
|
45
|
-
clientSecret: Config.AZURE_CLIENT_SECRET,
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Initialize a confidential client application. For more info, visit:
|
|
50
|
-
* https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-node/docs/initialize-confidential-client-application.md
|
|
51
|
-
*/
|
|
52
|
-
const cca = new msal_node_1.default.ConfidentialClientApplication(msalConfig);
|
|
53
31
|
const credential = new identity_1.ClientSecretCredential(Config.AZURE_TENANT_ID, Config.AZURE_CLIENT_ID, Config.AZURE_CLIENT_SECRET);
|
|
54
|
-
// @microsoft/microsoft-graph-client/authProviders/azureTokenCredentials
|
|
55
32
|
const authProvider = new azureTokenCredentials_1.TokenCredentialAuthenticationProvider(credential, {
|
|
56
|
-
// The client credentials flow requires that you request the
|
|
57
|
-
// /.default scope, and pre-configure your permissions on the
|
|
58
|
-
// app registration in Azure. An administrator must grant consent
|
|
59
|
-
// to those permissions beforehand.
|
|
60
33
|
scopes: ['https://graph.microsoft.com/.default'],
|
|
61
34
|
});
|
|
62
35
|
exports.GraphClient = microsoft_graph_client_1.Client.initWithMiddleware({ authProvider: authProvider });
|
|
63
|
-
/**
|
|
64
|
-
* With client credentials flows permissions need to be granted in the portal by a tenant administrator.
|
|
65
|
-
* The scope is always in the format '<resource>/.default'. For more, visit:
|
|
66
|
-
* https://learn.microsoft.com/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow
|
|
67
|
-
*/
|
|
68
|
-
exports.TokenRequest = {
|
|
69
|
-
scopes: [Config.AZURE_GRAPH_ENDPOINT + '/.default'],
|
|
70
|
-
};
|
|
71
36
|
exports.ApiConfig = {
|
|
72
37
|
uri: Config.AZURE_GRAPH_ENDPOINT + '/v1.0/users',
|
|
73
38
|
};
|
|
74
|
-
/**
|
|
75
|
-
* Acquires token with client credentials.
|
|
76
|
-
* @param {object} tokenRequest
|
|
77
|
-
*/
|
|
78
|
-
async function GetToken(tokenRequest) {
|
|
79
|
-
const authResult = await cca.acquireTokenByClientCredential(tokenRequest);
|
|
80
|
-
return authResult;
|
|
81
|
-
}
|
|
82
|
-
exports.GetToken = GetToken;
|
|
83
|
-
/**
|
|
84
|
-
* Calls the endpoint with authorization bearer token.
|
|
85
|
-
* @param {string} endpoint
|
|
86
|
-
*/
|
|
87
|
-
async function CallGraphApi(endpoint) {
|
|
88
|
-
try {
|
|
89
|
-
const response = await exports.GraphClient.api(endpoint).get();
|
|
90
|
-
return response;
|
|
91
|
-
}
|
|
92
|
-
catch (error) {
|
|
93
|
-
(0, core_1.LogError)(`Error calling api:`, undefined, error);
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
exports.CallGraphApi = CallGraphApi;
|
|
98
|
-
;
|
|
99
39
|
//# sourceMappingURL=auth.js.map
|
package/dist/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAyD;AACzD,iDAAmC;AACnC,8EAA2D;AAC3D,iHAA8H;AAG9H,MAAM,UAAU,GAA2B,IAAI,iCAAsB,CACjE,MAAM,CAAC,eAAe,EACtB,MAAM,CAAC,eAAe,EACtB,MAAM,CAAC,mBAAmB,CAC7B,CAAC;AAGF,MAAM,YAAY,GAA0C,IAAI,6DAAqC,CAAC,UAAU,EAAE;IAK9G,MAAM,EAAE,CAAC,sCAAsC,CAAC;CACjD,CAAC,CAAC;AAEQ,QAAA,WAAW,GAAW,+BAAM,CAAC,kBAAkB,CAAC,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC,CAAC;AAEhF,QAAA,SAAS,GAAG;IACrB,GAAG,EAAE,MAAM,CAAC,oBAAoB,GAAG,aAAa;CACnD,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.AZURE_ACCOUNT_ID = exports.AZURE_ACCOUNT_EMAIL = exports.AZURE_GRAPH_ENDPOINT = exports.AZURE_CLIENT_SECRET = exports.AZURE_TENANT_ID = exports.AZURE_AAD_ENDPOINT = exports.AZURE_CLIENT_ID = void 0;
|
|
7
7
|
const env_var_1 = __importDefault(require("env-var"));
|
|
8
|
-
//Azure Related
|
|
9
8
|
exports.AZURE_CLIENT_ID = env_var_1.default.get('AZURE_CLIENT_ID').required().asString();
|
|
10
9
|
exports.AZURE_AAD_ENDPOINT = env_var_1.default.get('AZURE_AAD_ENDPOINT').required().asString();
|
|
11
10
|
exports.AZURE_TENANT_ID = env_var_1.default.get('AZURE_TENANT_ID').required().asString();
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA0B;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA0B;AAGb,QAAA,eAAe,GAAW,iBAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AAC3E,QAAA,kBAAkB,GAAW,iBAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AACjF,QAAA,eAAe,GAAW,iBAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AAC3E,QAAA,mBAAmB,GAAW,iBAAG,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AACnF,QAAA,oBAAoB,GAAW,iBAAG,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AACrF,QAAA,mBAAmB,GAAW,iBAAG,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AACnF,QAAA,gBAAgB,GAAW,iBAAG,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,5 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./MSGraphProvider"), exports);
|
|
18
18
|
__exportStar(require("./auth"), exports);
|
|
19
19
|
__exportStar(require("./generic/models"), exports);
|
|
20
|
-
__exportStar(require("./fetch"), exports);
|
|
21
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,yCAAuB;AACvB,mDAAiC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,yCAAuB;AACvB,mDAAiC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/communication-ms-graph",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.28.0",
|
|
4
4
|
"description": "MemberJunction: Microsoft Graph Provider for the MJ Communication Framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,24 +17,26 @@
|
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"ts-node-dev": "^2.0.0",
|
|
19
19
|
"typescript": "^5.4.5",
|
|
20
|
-
"@types/
|
|
21
|
-
"@microsoft/microsoft-graph-types": "^2.40.0"
|
|
20
|
+
"@types/node": "^20.14.10"
|
|
22
21
|
},
|
|
23
22
|
"dependencies": {
|
|
24
23
|
"@azure/identity": "^4.4.1",
|
|
25
|
-
"@
|
|
26
|
-
"@memberjunction/
|
|
27
|
-
"@memberjunction/ai": "2.
|
|
28
|
-
"@memberjunction/
|
|
29
|
-
"@memberjunction/
|
|
30
|
-
"@memberjunction/core": "2.
|
|
31
|
-
"@memberjunction/
|
|
32
|
-
"@memberjunction/
|
|
33
|
-
"@memberjunction/sqlserver-dataprovider": "2.27.0",
|
|
24
|
+
"@memberjunction/communication-types": "2.28.0",
|
|
25
|
+
"@memberjunction/ai": "2.28.0",
|
|
26
|
+
"@memberjunction/ai-openai": "2.28.0",
|
|
27
|
+
"@memberjunction/aiengine": "2.28.0",
|
|
28
|
+
"@memberjunction/core": "2.28.0",
|
|
29
|
+
"@memberjunction/core-entities": "2.28.0",
|
|
30
|
+
"@memberjunction/global": "2.28.0",
|
|
31
|
+
"@memberjunction/sqlserver-dataprovider": "2.28.0",
|
|
34
32
|
"@microsoft/microsoft-graph-client": "^3.0.7",
|
|
33
|
+
"@azure/msal-node": "^2.14.0",
|
|
35
34
|
"html-to-text": "^9.0.5",
|
|
36
35
|
"axios": "^1.7.7",
|
|
37
36
|
"dotenv": "^16.4.5",
|
|
38
|
-
"env-var": "^7.5.0"
|
|
37
|
+
"env-var": "^7.5.0",
|
|
38
|
+
"isomorphic-fetch": "^3.0.0",
|
|
39
|
+
"@types/html-to-text": "^9.0.4",
|
|
40
|
+
"@microsoft/microsoft-graph-types": "^2.40.0"
|
|
39
41
|
}
|
|
40
42
|
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { BaseCommunicationProvider, GetMessagesParams, GetMessagesResult, MessageResult, ProcessedMessage } from "@memberjunction/communication-types";
|
|
2
|
-
import { User, Message } from "@microsoft/microsoft-graph-types";
|
|
3
|
-
import { compiledFunction } from 'html-to-text';
|
|
4
|
-
import { ForwardMessageParams, ForwardMessageResult } from "./generic/models";
|
|
5
|
-
/**
|
|
6
|
-
* Implementation of the MS Graph provider for sending and receiving messages
|
|
7
|
-
*/
|
|
8
|
-
export declare class MSGraphProvider extends BaseCommunicationProvider {
|
|
9
|
-
ServiceAccount: User | null;
|
|
10
|
-
HTMLConverter: compiledFunction;
|
|
11
|
-
constructor();
|
|
12
|
-
SendSingleMessage(message: ProcessedMessage): Promise<MessageResult>;
|
|
13
|
-
ReplyToMessage(message: ProcessedMessage, messageID: string): Promise<MessageResult>;
|
|
14
|
-
GetMessages(params: GetMessagesParams<Record<string, any>>): Promise<GetMessagesResult<Message>>;
|
|
15
|
-
ForwardMessage(params: ForwardMessageParams): Promise<ForwardMessageResult>;
|
|
16
|
-
protected GetServiceAccount(email?: string): Promise<User | null>;
|
|
17
|
-
protected MarkMessageAsRead(userID: string, messageID: string): Promise<boolean>;
|
|
18
|
-
}
|
|
19
|
-
export declare function LoadMSGraphProvider(): void;
|
|
20
|
-
//# sourceMappingURL=MSGraphProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MSGraphProvider.d.ts","sourceRoot":"","sources":["../src/MSGraphProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAEvJ,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAGjE,OAAO,EAAW,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGzD,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE9E;;GAEG;AACH,qBACa,eAAgB,SAAQ,yBAAyB;IAE1D,cAAc,EAAE,IAAI,GAAG,IAAI,CAAQ;IACnC,aAAa,EAAE,gBAAgB,CAAC;;IAUnB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;IAwDpE,cAAc,CAAC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IA2CpF,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IA4DhG,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC;cA6CxE,iBAAiB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;cAwBvD,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAiBzF;AAED,wBAAgB,mBAAmB,SAElC"}
|
package/dist/auth.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import msal from '@azure/msal-node';
|
|
2
|
-
import { Client } from '@microsoft/microsoft-graph-client';
|
|
3
|
-
export declare const GraphClient: Client;
|
|
4
|
-
/**
|
|
5
|
-
* With client credentials flows permissions need to be granted in the portal by a tenant administrator.
|
|
6
|
-
* The scope is always in the format '<resource>/.default'. For more, visit:
|
|
7
|
-
* https://learn.microsoft.com/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow
|
|
8
|
-
*/
|
|
9
|
-
export declare const TokenRequest: {
|
|
10
|
-
scopes: string[];
|
|
11
|
-
};
|
|
12
|
-
export declare const ApiConfig: {
|
|
13
|
-
uri: string;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Acquires token with client credentials.
|
|
17
|
-
* @param {object} tokenRequest
|
|
18
|
-
*/
|
|
19
|
-
export declare function GetToken(tokenRequest: msal.ClientCredentialRequest): Promise<msal.AuthenticationResult | null>;
|
|
20
|
-
/**
|
|
21
|
-
* Calls the endpoint with authorization bearer token.
|
|
22
|
-
* @param {string} endpoint
|
|
23
|
-
*/
|
|
24
|
-
export declare function CallGraphApi<T>(endpoint: string): Promise<T | null>;
|
|
25
|
-
//# sourceMappingURL=auth.d.ts.map
|
package/dist/auth.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAsC3D,eAAO,MAAM,WAAW,EAAE,MAAkE,CAAC;AAE7F;;;;GAIG;AACH,eAAO,MAAM,YAAY;;CAExB,CAAC;AAEF,eAAO,MAAM,SAAS;;CAErB,CAAC;AAEF;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,YAAY,EAAE,IAAI,CAAC,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAGpH;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CASzE"}
|
package/dist/config.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const AZURE_CLIENT_ID: string;
|
|
2
|
-
export declare const AZURE_AAD_ENDPOINT: string;
|
|
3
|
-
export declare const AZURE_TENANT_ID: string;
|
|
4
|
-
export declare const AZURE_CLIENT_SECRET: string;
|
|
5
|
-
export declare const AZURE_GRAPH_ENDPOINT: string;
|
|
6
|
-
export declare const AZURE_ACCOUNT_EMAIL: string;
|
|
7
|
-
export declare const AZURE_ACCOUNT_ID: string;
|
|
8
|
-
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,EAAE,MAAyD,CAAC;AACxF,eAAO,MAAM,kBAAkB,EAAE,MAA4D,CAAC;AAC9F,eAAO,MAAM,eAAe,EAAE,MAAyD,CAAC;AACxF,eAAO,MAAM,mBAAmB,EAAE,MAA6D,CAAC;AAChG,eAAO,MAAM,oBAAoB,EAAE,MAA8D,CAAC;AAClG,eAAO,MAAM,mBAAmB,EAAE,MAA6D,CAAC;AAChG,eAAO,MAAM,gBAAgB,EAAE,MAA2D,CAAC"}
|
package/dist/fetch.d.ts
DELETED
package/dist/fetch.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CA4BzF"}
|
package/dist/fetch.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.CallApi = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
/**
|
|
9
|
-
* Calls the endpoint with authorization bearer token.
|
|
10
|
-
* @param {string} endpoint
|
|
11
|
-
* @param {string} accessToken
|
|
12
|
-
*/
|
|
13
|
-
async function CallApi(endpoint, accessToken) {
|
|
14
|
-
const options = {
|
|
15
|
-
headers: {
|
|
16
|
-
Authorization: `Bearer ${accessToken}`
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
try {
|
|
20
|
-
const response = await axios_1.default.get(endpoint, options);
|
|
21
|
-
return response.data;
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
if (axios_1.default.isAxiosError(error)) {
|
|
25
|
-
const axiosError = error;
|
|
26
|
-
if (axiosError.response) {
|
|
27
|
-
console.log(`Error calling api: ${axiosError.response.status} - ${axiosError.response.statusText}`);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
console.log(`Error calling api: ${axiosError.message}`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
console.log(`Error calling api`);
|
|
35
|
-
}
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.CallApi = CallApi;
|
|
40
|
-
;
|
|
41
|
-
//# sourceMappingURL=fetch.js.map
|
package/dist/fetch.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0C;AAE1C;;;;GAIG;AACI,KAAK,UAAU,OAAO,CAAI,QAAgB,EAAE,WAAmB;IAElE,MAAM,OAAO,GAAG;QACZ,OAAO,EAAE;YACL,aAAa,EAAE,UAAU,WAAW,EAAE;SACzC;KACJ,CAAC;IAEF,IAAI,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAI,QAAQ,EAAE,OAAO,CAAC,CAAC;QACvD,OAAO,QAAQ,CAAC,IAAI,CAAC;IACzB,CAAC;IACD,OAAO,KAAK,EAAE,CAAC;QACX,IAAG,eAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAC,CAAC;YAC1B,MAAM,UAAU,GAAG,KAAmB,CAAC;YACvC,IAAG,UAAU,CAAC,QAAQ,EAAC,CAAC;gBACpB,OAAO,CAAC,GAAG,CAAC,sBAAsB,UAAU,CAAC,QAAQ,CAAC,MAAM,MAAM,UAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;YACxG,CAAC;iBACG,CAAC;gBACD,OAAO,CAAC,GAAG,CAAC,sBAAsB,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;YAC5D,CAAC;QACL,CAAC;aACG,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QACrC,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;AACL,CAAC;AA5BD,0BA4BC;AAAA,CAAC"}
|
package/dist/generic/models.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export type MSGraphGetResponse<T> = {
|
|
2
|
-
"@odata.context": string;
|
|
3
|
-
value: T;
|
|
4
|
-
};
|
|
5
|
-
export type GetMessagesContextDataParams = {
|
|
6
|
-
/**
|
|
7
|
-
* The email address of the service account to use. If not provide,
|
|
8
|
-
* defaults to the AZURE_ACCOUNT_EMAIL config variable
|
|
9
|
-
*/
|
|
10
|
-
Email?: string;
|
|
11
|
-
/**
|
|
12
|
-
* If true, messages will be returned with the body stripped of HTLM tags
|
|
13
|
-
*/
|
|
14
|
-
ReturnAsPlainText?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* If true, messages will be marked as read after being processed
|
|
17
|
-
*/
|
|
18
|
-
MarkAsRead?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Filter to use in the MS Graph request to fetch messages. Defaults to fetching messages not marked as read.
|
|
21
|
-
*/
|
|
22
|
-
Filter?: string;
|
|
23
|
-
/**
|
|
24
|
-
* Number of messages to return, defaults to 10.
|
|
25
|
-
*/
|
|
26
|
-
Top?: number;
|
|
27
|
-
};
|
|
28
|
-
export type ForwardMessageParams = {
|
|
29
|
-
EmailID: string;
|
|
30
|
-
Message: string;
|
|
31
|
-
ToRecipients: {
|
|
32
|
-
Name: string;
|
|
33
|
-
Address: string;
|
|
34
|
-
}[];
|
|
35
|
-
};
|
|
36
|
-
export type ForwardMessageResult = {
|
|
37
|
-
Success: boolean;
|
|
38
|
-
Message?: string;
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=models.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/generic/models.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI;IAChC,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,CAAC,CAAA;CACX,CAAA;AAED,MAAM,MAAM,4BAA4B,GAAG;IACvC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE;QACV,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACnB,EAAE,CAAC;CACP,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAA"}
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC"}
|