@microsoft/teamsfx 2.3.0 → 2.3.1-alpha.024294d67.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 +3 -2
- package/dist/index.esm2017.js +2 -1
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +119 -13
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +32 -2
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +242 -123
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +32 -15
- package/types/teamsfx.d.ts +23 -3
package/dist/index.node.cjs.js
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var tslib = require('tslib');
|
6
5
|
var jwt_decode = require('jwt-decode');
|
7
6
|
var msalNode = require('@azure/msal-node');
|
8
7
|
var crypto = require('crypto');
|
@@ -168,6 +167,7 @@ ErrorMessage.DuplicateHttpsOptionProperty = "Axios HTTPS agent already defined v
|
|
168
167
|
ErrorMessage.DuplicateApiKeyInHeader = "The request already defined api key in request header with name {0}.";
|
169
168
|
ErrorMessage.DuplicateApiKeyInQueryParam = "The request already defined api key in query parameter with name {0}.";
|
170
169
|
ErrorMessage.OnlySupportInQueryActivity = "The handleMessageExtensionQueryWithToken only support in handleTeamsMessagingExtensionQuery with composeExtension/query type.";
|
170
|
+
ErrorMessage.OnlySupportInLinkQueryActivity = "The handleMessageExtensionLinkQueryWithSSO only support in handleTeamsAppBasedLinkQuery with composeExtension/queryLink type.";
|
171
171
|
/**
|
172
172
|
* Error class with code and message thrown by the SDK.
|
173
173
|
*/
|
@@ -190,6 +190,48 @@ class ErrorWithCode extends Error {
|
|
190
190
|
}
|
191
191
|
}
|
192
192
|
|
193
|
+
/******************************************************************************
|
194
|
+
Copyright (c) Microsoft Corporation.
|
195
|
+
|
196
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
197
|
+
purpose with or without fee is hereby granted.
|
198
|
+
|
199
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
200
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
201
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
202
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
203
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
204
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
205
|
+
PERFORMANCE OF THIS SOFTWARE.
|
206
|
+
***************************************************************************** */
|
207
|
+
|
208
|
+
function __rest(s, e) {
|
209
|
+
var t = {};
|
210
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
211
|
+
t[p] = s[p];
|
212
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
213
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
214
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
215
|
+
t[p[i]] = s[p[i]];
|
216
|
+
}
|
217
|
+
return t;
|
218
|
+
}
|
219
|
+
|
220
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
221
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
222
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
223
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
224
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
225
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
226
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
227
|
+
});
|
228
|
+
}
|
229
|
+
|
230
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
231
|
+
var e = new Error(message);
|
232
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
233
|
+
};
|
234
|
+
|
193
235
|
// Copyright (c) Microsoft Corporation.
|
194
236
|
// Licensed under the MIT license.
|
195
237
|
/**
|
@@ -514,7 +556,7 @@ class AppCredential {
|
|
514
556
|
* Throw error if get access token failed.
|
515
557
|
*/
|
516
558
|
getToken(scopes, options) {
|
517
|
-
return
|
559
|
+
return __awaiter(this, void 0, void 0, function* () {
|
518
560
|
let accessToken;
|
519
561
|
validateScopesType(scopes);
|
520
562
|
const scopesStr = typeof scopes === "string" ? scopes : scopes.join(" ");
|
@@ -652,7 +694,7 @@ class OnBehalfOfUserCredential {
|
|
652
694
|
* If scopes is non-empty, it returns access token for target scope.
|
653
695
|
*/
|
654
696
|
getToken(scopes, options) {
|
655
|
-
return
|
697
|
+
return __awaiter(this, void 0, void 0, function* () {
|
656
698
|
validateScopesType(scopes);
|
657
699
|
const scopesArray = getScopesArray(scopes);
|
658
700
|
let result;
|
@@ -805,7 +847,7 @@ class MsGraphAuthProvider {
|
|
805
847
|
*
|
806
848
|
*/
|
807
849
|
getAccessToken() {
|
808
|
-
return
|
850
|
+
return __awaiter(this, void 0, void 0, function* () {
|
809
851
|
internalLogger.info(`Get Graph Access token with scopes: '${this.scopes.toString()}'`);
|
810
852
|
let accessToken;
|
811
853
|
if (this.credentialOrTeamsFx.getCredential) {
|
@@ -985,7 +1027,7 @@ const defaultSQLScope = "https://database.windows.net/";
|
|
985
1027
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
986
1028
|
*/
|
987
1029
|
function getTediousConnectionConfig(teamsfx, databaseName) {
|
988
|
-
return
|
1030
|
+
return __awaiter(this, void 0, void 0, function* () {
|
989
1031
|
internalLogger.info("Get SQL configuration");
|
990
1032
|
try {
|
991
1033
|
isSQLConfigurationValid(teamsfx);
|
@@ -1089,7 +1131,7 @@ function generateDefaultConfig(teamsfx, databaseName) {
|
|
1089
1131
|
* @internal
|
1090
1132
|
*/
|
1091
1133
|
function generateTokenConfig(teamsfx, databaseName) {
|
1092
|
-
return
|
1134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1093
1135
|
internalLogger.verbose("Generate tedious config with MSI token");
|
1094
1136
|
let token;
|
1095
1137
|
try {
|
@@ -1246,7 +1288,7 @@ class TeamsBotSsoPrompt extends botbuilderDialogs.Dialog {
|
|
1246
1288
|
*/
|
1247
1289
|
beginDialog(dc) {
|
1248
1290
|
var _a;
|
1249
|
-
return
|
1291
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1250
1292
|
internalLogger.info("Begin Teams Bot SSO Prompt");
|
1251
1293
|
this.ensureMsTeamsChannel(dc);
|
1252
1294
|
// Initialize prompt state
|
@@ -1295,7 +1337,7 @@ class TeamsBotSsoPrompt extends botbuilderDialogs.Dialog {
|
|
1295
1337
|
*/
|
1296
1338
|
continueDialog(dc) {
|
1297
1339
|
var _a;
|
1298
|
-
return
|
1340
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1299
1341
|
internalLogger.info("Continue Teams Bot SSO Prompt");
|
1300
1342
|
this.ensureMsTeamsChannel(dc);
|
1301
1343
|
// Check for timeout
|
@@ -1388,7 +1430,7 @@ class TeamsBotSsoPrompt extends botbuilderDialogs.Dialog {
|
|
1388
1430
|
* @internal
|
1389
1431
|
*/
|
1390
1432
|
sendOAuthCardAsync(context) {
|
1391
|
-
return
|
1433
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1392
1434
|
internalLogger.verbose("Send OAuth card to get SSO token");
|
1393
1435
|
const account = yield botbuilder.TeamsInfo.getMember(context, context.activity.from.id);
|
1394
1436
|
internalLogger.verbose("Get Teams member account user principal name: " +
|
@@ -1425,7 +1467,7 @@ class TeamsBotSsoPrompt extends botbuilderDialogs.Dialog {
|
|
1425
1467
|
* @internal
|
1426
1468
|
*/
|
1427
1469
|
recognizeToken(dc) {
|
1428
|
-
return
|
1470
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1429
1471
|
const context = dc.context;
|
1430
1472
|
let tokenResponse;
|
1431
1473
|
if (this.isTokenExchangeRequestInvoke(context)) {
|
@@ -1522,8 +1564,8 @@ function createApiClient(apiEndpoint, authProvider) {
|
|
1522
1564
|
baseURL: apiEndpoint,
|
1523
1565
|
});
|
1524
1566
|
instance.interceptors.request.use(function (config) {
|
1525
|
-
return
|
1526
|
-
return yield authProvider.AddAuthenticationInfo(config);
|
1567
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1568
|
+
return (yield authProvider.AddAuthenticationInfo(config));
|
1527
1569
|
});
|
1528
1570
|
});
|
1529
1571
|
return instance;
|
@@ -1551,7 +1593,7 @@ class BearerTokenAuthProvider {
|
|
1551
1593
|
* @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header already exists in request configuration.
|
1552
1594
|
*/
|
1553
1595
|
AddAuthenticationInfo(config) {
|
1554
|
-
return
|
1596
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1555
1597
|
const token = yield this.getToken();
|
1556
1598
|
if (!config.headers) {
|
1557
1599
|
config.headers = {};
|
@@ -1870,7 +1912,7 @@ class TeamsFx {
|
|
1870
1912
|
* @returns UserInfo object.
|
1871
1913
|
*/
|
1872
1914
|
getUserInfo(resources) {
|
1873
|
-
return
|
1915
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1874
1916
|
if (this.identityType !== exports.IdentityType.User) {
|
1875
1917
|
const errorMsg = formatString(ErrorMessage.IdentityTypeNotSupported, this.identityType.toString(), "TeamsFx");
|
1876
1918
|
internalLogger.error(errorMsg);
|
@@ -1901,7 +1943,7 @@ class TeamsFx {
|
|
1901
1943
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
1902
1944
|
*/
|
1903
1945
|
login(scopes, resources) {
|
1904
|
-
return
|
1946
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1905
1947
|
throw new ErrorWithCode(formatString(ErrorMessage.NodejsRuntimeNotSupported, "login"), exports.ErrorCode.RuntimeNotSupported);
|
1906
1948
|
});
|
1907
1949
|
}
|
@@ -2040,6 +2082,7 @@ exports.InvokeResponseErrorCode = void 0;
|
|
2040
2082
|
InvokeResponseErrorCode[InvokeResponseErrorCode["InternalServerError"] = 500] = "InternalServerError";
|
2041
2083
|
})(exports.InvokeResponseErrorCode || (exports.InvokeResponseErrorCode = {}));
|
2042
2084
|
|
2085
|
+
// Copyright (c) Microsoft Corporation.
|
2043
2086
|
/**
|
2044
2087
|
* Available response type for an adaptive card invoke response.
|
2045
2088
|
* @internal
|
@@ -2054,7 +2097,7 @@ var InvokeResponseType;
|
|
2054
2097
|
* Provides methods for formatting various invoke responses a bot can send to respond to an invoke request.
|
2055
2098
|
*
|
2056
2099
|
* @remarks
|
2057
|
-
* All of these functions return an
|
2100
|
+
* All of these functions return an `InvokeResponse` object, which can be
|
2058
2101
|
* passed as input to generate a new `invokeResponse` activity.
|
2059
2102
|
*
|
2060
2103
|
* This example sends an invoke response that contains an adaptive card.
|
@@ -2180,7 +2223,7 @@ class CardActionMiddleware {
|
|
2180
2223
|
}
|
2181
2224
|
onTurn(context, next) {
|
2182
2225
|
var _a, _b, _c;
|
2183
|
-
return
|
2226
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2184
2227
|
if (context.activity.name === "adaptiveCard/action") {
|
2185
2228
|
const action = context.activity.value.action;
|
2186
2229
|
const actionVerb = action.verb;
|
@@ -2237,7 +2280,7 @@ class CardActionMiddleware {
|
|
2237
2280
|
});
|
2238
2281
|
}
|
2239
2282
|
sendInvokeResponse(context, response) {
|
2240
|
-
return
|
2283
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2241
2284
|
yield context.sendActivity({
|
2242
2285
|
type: botbuilder.ActivityTypes.InvokeResponse,
|
2243
2286
|
value: response,
|
@@ -2306,7 +2349,7 @@ class CommandResponseMiddleware {
|
|
2306
2349
|
}
|
2307
2350
|
addSsoCommand(ssoHandler) {
|
2308
2351
|
var _a;
|
2309
|
-
(_a = this.ssoActivityHandler) === null || _a === void 0 ? void 0 : _a.addCommand((context, tokenResponse, message) =>
|
2352
|
+
(_a = this.ssoActivityHandler) === null || _a === void 0 ? void 0 : _a.addCommand((context, tokenResponse, message) => __awaiter(this, void 0, void 0, function* () {
|
2310
2353
|
const matchResult = this.shouldTrigger(ssoHandler.triggerPatterns, message.text);
|
2311
2354
|
message.matches = Array.isArray(matchResult) ? matchResult : void 0;
|
2312
2355
|
const response = yield ssoHandler.handleCommandReceived(context, message, tokenResponse);
|
@@ -2317,7 +2360,7 @@ class CommandResponseMiddleware {
|
|
2317
2360
|
}
|
2318
2361
|
onTurn(context, next) {
|
2319
2362
|
var _a, _b;
|
2320
|
-
return
|
2363
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2321
2364
|
if (context.activity.type === botbuilder.ActivityTypes.Message) {
|
2322
2365
|
// Invoke corresponding command handler for the command response
|
2323
2366
|
const commandText = this.getActivityText(context.activity);
|
@@ -2356,7 +2399,7 @@ class CommandResponseMiddleware {
|
|
2356
2399
|
});
|
2357
2400
|
}
|
2358
2401
|
processResponse(context, response) {
|
2359
|
-
return
|
2402
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2360
2403
|
if (typeof response === "string") {
|
2361
2404
|
yield context.sendActivity(response);
|
2362
2405
|
}
|
@@ -2487,6 +2530,7 @@ function cloneConversation(conversation) {
|
|
2487
2530
|
*/
|
2488
2531
|
function getKey(reference) {
|
2489
2532
|
var _a, _b;
|
2533
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
2490
2534
|
return `_${(_a = reference.conversation) === null || _a === void 0 ? void 0 : _a.tenantId}_${(_b = reference.conversation) === null || _b === void 0 ? void 0 : _b.id}`;
|
2491
2535
|
}
|
2492
2536
|
/**
|
@@ -2546,7 +2590,7 @@ class NotificationMiddleware {
|
|
2546
2590
|
this.conversationReferenceStore = options.conversationReferenceStore;
|
2547
2591
|
}
|
2548
2592
|
onTurn(context, next) {
|
2549
|
-
return
|
2593
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2550
2594
|
const type = this.classifyActivity(context.activity);
|
2551
2595
|
switch (type) {
|
2552
2596
|
case ActivityType.CurrentBotInstalled:
|
@@ -2598,8 +2642,8 @@ class NotificationMiddleware {
|
|
2598
2642
|
return ActivityType.Unknown;
|
2599
2643
|
}
|
2600
2644
|
tryAddMessagedReference(context) {
|
2601
|
-
var _a, _b, _c, _d;
|
2602
|
-
return
|
2645
|
+
var _a, _b, _c, _d, _e, _f;
|
2646
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2603
2647
|
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
2604
2648
|
const conversationType = (_a = reference === null || reference === void 0 ? void 0 : reference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
|
2605
2649
|
if (conversationType === "personal" || conversationType === "groupChat") {
|
@@ -2607,7 +2651,9 @@ class NotificationMiddleware {
|
|
2607
2651
|
}
|
2608
2652
|
else if (conversationType === "channel") {
|
2609
2653
|
const teamId = (_d = (_c = (_b = context.activity) === null || _b === void 0 ? void 0 : _b.channelData) === null || _c === void 0 ? void 0 : _c.team) === null || _d === void 0 ? void 0 : _d.id;
|
2610
|
-
|
2654
|
+
const channelId = (_f = (_e = context.activity.channelData) === null || _e === void 0 ? void 0 : _e.channel) === null || _f === void 0 ? void 0 : _f.id;
|
2655
|
+
// `teamId === channelId` means General channel. Ignore messaging in non-General channel.
|
2656
|
+
if (teamId !== undefined && (channelId === undefined || teamId === channelId)) {
|
2611
2657
|
const teamReference = cloneConversation(reference);
|
2612
2658
|
teamReference.conversation.id = teamId;
|
2613
2659
|
yield this.conversationReferenceStore.add(getKey(teamReference), teamReference, {
|
@@ -2625,11 +2671,12 @@ class NotificationMiddleware {
|
|
2625
2671
|
*/
|
2626
2672
|
class LocalFileStorage {
|
2627
2673
|
constructor(fileDir) {
|
2628
|
-
|
2674
|
+
var _a;
|
2675
|
+
this.localFileName = (_a = process.env.TEAMSFX_NOTIFICATION_STORE_FILENAME) !== null && _a !== void 0 ? _a : ".notification.localstore.json";
|
2629
2676
|
this.filePath = path__namespace.resolve(fileDir, this.localFileName);
|
2630
2677
|
}
|
2631
2678
|
read(key) {
|
2632
|
-
return
|
2679
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2633
2680
|
if (!(yield this.storeFileExists())) {
|
2634
2681
|
return undefined;
|
2635
2682
|
}
|
@@ -2638,7 +2685,7 @@ class LocalFileStorage {
|
|
2638
2685
|
});
|
2639
2686
|
}
|
2640
2687
|
list() {
|
2641
|
-
return
|
2688
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2642
2689
|
if (!(yield this.storeFileExists())) {
|
2643
2690
|
return [];
|
2644
2691
|
}
|
@@ -2647,7 +2694,7 @@ class LocalFileStorage {
|
|
2647
2694
|
});
|
2648
2695
|
}
|
2649
2696
|
write(key, object) {
|
2650
|
-
return
|
2697
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2651
2698
|
if (!(yield this.storeFileExists())) {
|
2652
2699
|
yield this.writeToFile({ [key]: object });
|
2653
2700
|
return;
|
@@ -2657,7 +2704,7 @@ class LocalFileStorage {
|
|
2657
2704
|
});
|
2658
2705
|
}
|
2659
2706
|
delete(key) {
|
2660
|
-
return
|
2707
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2661
2708
|
if (yield this.storeFileExists()) {
|
2662
2709
|
const data = yield this.readFromFile();
|
2663
2710
|
if (data[key] !== undefined) {
|
@@ -2702,7 +2749,7 @@ class LocalFileStorage {
|
|
2702
2749
|
});
|
2703
2750
|
}
|
2704
2751
|
writeToFile(data) {
|
2705
|
-
return
|
2752
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2706
2753
|
return new Promise((resolve, reject) => {
|
2707
2754
|
try {
|
2708
2755
|
const rawData = JSON.stringify(data, undefined, 2);
|
@@ -2730,7 +2777,7 @@ class DefaultConversationReferenceStore {
|
|
2730
2777
|
this.storage = storage;
|
2731
2778
|
}
|
2732
2779
|
add(key, reference, options) {
|
2733
|
-
return
|
2780
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2734
2781
|
if (options.overwrite) {
|
2735
2782
|
yield this.storage.write(key, reference);
|
2736
2783
|
return true;
|
@@ -2744,7 +2791,7 @@ class DefaultConversationReferenceStore {
|
|
2744
2791
|
});
|
2745
2792
|
}
|
2746
2793
|
remove(key, reference) {
|
2747
|
-
return
|
2794
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2748
2795
|
const ref = yield this.storage.read(key);
|
2749
2796
|
if (ref === undefined) {
|
2750
2797
|
return false;
|
@@ -2754,7 +2801,7 @@ class DefaultConversationReferenceStore {
|
|
2754
2801
|
});
|
2755
2802
|
}
|
2756
2803
|
list(pageSize, continuationToken) {
|
2757
|
-
return
|
2804
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2758
2805
|
const data = yield this.storage.list();
|
2759
2806
|
return {
|
2760
2807
|
data,
|
@@ -2822,11 +2869,11 @@ class Channel$1 {
|
|
2822
2869
|
* @returns the response of sending message.
|
2823
2870
|
*/
|
2824
2871
|
sendMessage(text, onError) {
|
2825
|
-
return
|
2872
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2826
2873
|
const response = {};
|
2827
|
-
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) =>
|
2874
|
+
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
2828
2875
|
const conversation = this.newConversation(context);
|
2829
|
-
yield this.parent.adapter.continueConversation(conversation, (ctx) =>
|
2876
|
+
yield this.parent.adapter.continueConversation(conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
2830
2877
|
try {
|
2831
2878
|
const res = yield ctx.sendActivity(text);
|
2832
2879
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -2853,11 +2900,11 @@ class Channel$1 {
|
|
2853
2900
|
* @returns the response of sending adaptive card message.
|
2854
2901
|
*/
|
2855
2902
|
sendAdaptiveCard(card, onError) {
|
2856
|
-
return
|
2903
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2857
2904
|
const response = {};
|
2858
|
-
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) =>
|
2905
|
+
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
2859
2906
|
const conversation = this.newConversation(context);
|
2860
|
-
yield this.parent.adapter.continueConversation(conversation, (ctx) =>
|
2907
|
+
yield this.parent.adapter.continueConversation(conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
2861
2908
|
try {
|
2862
2909
|
const res = yield ctx.sendActivity({
|
2863
2910
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -2920,11 +2967,11 @@ class Member$1 {
|
|
2920
2967
|
* @returns the response of sending message.
|
2921
2968
|
*/
|
2922
2969
|
sendMessage(text, onError) {
|
2923
|
-
return
|
2970
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2924
2971
|
const response = {};
|
2925
|
-
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) =>
|
2972
|
+
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
2926
2973
|
const conversation = yield this.newConversation(context);
|
2927
|
-
yield this.parent.adapter.continueConversation(conversation, (ctx) =>
|
2974
|
+
yield this.parent.adapter.continueConversation(conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
2928
2975
|
try {
|
2929
2976
|
const res = yield ctx.sendActivity(text);
|
2930
2977
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -2951,11 +2998,11 @@ class Member$1 {
|
|
2951
2998
|
* @returns the response of sending adaptive card message.
|
2952
2999
|
*/
|
2953
3000
|
sendAdaptiveCard(card, onError) {
|
2954
|
-
return
|
3001
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2955
3002
|
const response = {};
|
2956
|
-
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) =>
|
3003
|
+
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
2957
3004
|
const conversation = yield this.newConversation(context);
|
2958
|
-
yield this.parent.adapter.continueConversation(conversation, (ctx) =>
|
3005
|
+
yield this.parent.adapter.continueConversation(conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
2959
3006
|
try {
|
2960
3007
|
const res = yield ctx.sendActivity({
|
2961
3008
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -2979,7 +3026,7 @@ class Member$1 {
|
|
2979
3026
|
* @internal
|
2980
3027
|
*/
|
2981
3028
|
newConversation(context) {
|
2982
|
-
return
|
3029
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2983
3030
|
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
2984
3031
|
const personalConversation = cloneConversation(reference);
|
2985
3032
|
const connectorClient = context.turnState.get(this.parent.adapter.ConnectorClientKey);
|
@@ -3031,9 +3078,9 @@ class TeamsBotInstallation$1 {
|
|
3031
3078
|
* @returns the response of sending message.
|
3032
3079
|
*/
|
3033
3080
|
sendMessage(text, onError) {
|
3034
|
-
return
|
3081
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3035
3082
|
const response = {};
|
3036
|
-
yield this.adapter.continueConversation(this.conversationReference, (context) =>
|
3083
|
+
yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3037
3084
|
try {
|
3038
3085
|
const res = yield context.sendActivity(text);
|
3039
3086
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -3059,9 +3106,9 @@ class TeamsBotInstallation$1 {
|
|
3059
3106
|
* @returns the response of sending adaptive card message.
|
3060
3107
|
*/
|
3061
3108
|
sendAdaptiveCard(card, onError) {
|
3062
|
-
return
|
3109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3063
3110
|
const response = {};
|
3064
|
-
yield this.adapter.continueConversation(this.conversationReference, (context) =>
|
3111
|
+
yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3065
3112
|
try {
|
3066
3113
|
const res = yield context.sendActivity({
|
3067
3114
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -3086,13 +3133,13 @@ class TeamsBotInstallation$1 {
|
|
3086
3133
|
* @returns an array of channels if bot is installed into a team, otherwise returns an empty array.
|
3087
3134
|
*/
|
3088
3135
|
channels() {
|
3089
|
-
return
|
3136
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3090
3137
|
const channels = [];
|
3091
3138
|
if (this.type !== exports.NotificationTargetType.Channel) {
|
3092
3139
|
return channels;
|
3093
3140
|
}
|
3094
3141
|
let teamsChannels = [];
|
3095
|
-
yield this.adapter.continueConversation(this.conversationReference, (context) =>
|
3142
|
+
yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3096
3143
|
const teamId = getTeamsBotInstallationId(context);
|
3097
3144
|
if (teamId !== undefined) {
|
3098
3145
|
teamsChannels = yield botbuilder.TeamsInfo.getTeamChannels(context, teamId);
|
@@ -3110,9 +3157,9 @@ class TeamsBotInstallation$1 {
|
|
3110
3157
|
* @returns an array of members from where the bot is installed.
|
3111
3158
|
*/
|
3112
3159
|
members() {
|
3113
|
-
return
|
3160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3114
3161
|
const members = [];
|
3115
|
-
yield this.adapter.continueConversation(this.conversationReference, (context) =>
|
3162
|
+
yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3116
3163
|
let continuationToken;
|
3117
3164
|
do {
|
3118
3165
|
const pagedMembers = yield botbuilder.TeamsInfo.getPagedMembers(context, undefined, continuationToken);
|
@@ -3131,12 +3178,12 @@ class TeamsBotInstallation$1 {
|
|
3131
3178
|
* @returns the team details if bot is installed into a team, otherwise returns undefined.
|
3132
3179
|
*/
|
3133
3180
|
getTeamDetails() {
|
3134
|
-
return
|
3181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3135
3182
|
if (this.type !== exports.NotificationTargetType.Channel) {
|
3136
3183
|
return undefined;
|
3137
3184
|
}
|
3138
3185
|
let teamDetails;
|
3139
|
-
yield this.adapter.continueConversation(this.conversationReference, (context) =>
|
3186
|
+
yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3140
3187
|
const teamId = getTeamsBotInstallationId(context);
|
3141
3188
|
if (teamId !== undefined) {
|
3142
3189
|
teamDetails = yield botbuilder.TeamsInfo.getTeamDetails(context, teamId);
|
@@ -3179,7 +3226,7 @@ class NotificationBot$1 {
|
|
3179
3226
|
* @returns - an array of {@link TeamsBotInstallation}.
|
3180
3227
|
*/
|
3181
3228
|
installations() {
|
3182
|
-
return
|
3229
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3183
3230
|
if (this.conversationReferenceStore === undefined || this.adapter === undefined) {
|
3184
3231
|
throw new Error("NotificationBot has not been initialized.");
|
3185
3232
|
}
|
@@ -3188,7 +3235,7 @@ class NotificationBot$1 {
|
|
3188
3235
|
for (const reference of references) {
|
3189
3236
|
// validate connection
|
3190
3237
|
let valid = true;
|
3191
|
-
yield this.adapter.continueConversation(reference, (context) =>
|
3238
|
+
yield this.adapter.continueConversation(reference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3192
3239
|
try {
|
3193
3240
|
// try get member to see if the installation is still valid
|
3194
3241
|
yield botbuilder.TeamsInfo.getPagedMembers(context, 1);
|
@@ -3220,7 +3267,7 @@ class NotificationBot$1 {
|
|
3220
3267
|
* @returns the first {@link Member} where predicate is true, and undefined otherwise.
|
3221
3268
|
*/
|
3222
3269
|
findMember(predicate, scope) {
|
3223
|
-
return
|
3270
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3224
3271
|
for (const target of yield this.installations()) {
|
3225
3272
|
if (this.matchSearchScope(target, scope)) {
|
3226
3273
|
for (const member of yield target.members()) {
|
@@ -3243,7 +3290,7 @@ class NotificationBot$1 {
|
|
3243
3290
|
* @returns the first {@link Channel} where predicate is true, and undefined otherwise.
|
3244
3291
|
*/
|
3245
3292
|
findChannel(predicate) {
|
3246
|
-
return
|
3293
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3247
3294
|
for (const target of yield this.installations()) {
|
3248
3295
|
if (target.type === exports.NotificationTargetType.Channel) {
|
3249
3296
|
const teamDetails = yield target.getTeamDetails();
|
@@ -3266,7 +3313,7 @@ class NotificationBot$1 {
|
|
3266
3313
|
* @returns an array of {@link Member} where predicate is true, and empty array otherwise.
|
3267
3314
|
*/
|
3268
3315
|
findAllMembers(predicate, scope) {
|
3269
|
-
return
|
3316
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3270
3317
|
const members = [];
|
3271
3318
|
for (const target of yield this.installations()) {
|
3272
3319
|
if (this.matchSearchScope(target, scope)) {
|
@@ -3288,7 +3335,7 @@ class NotificationBot$1 {
|
|
3288
3335
|
* @returns an array of {@link Channel} where predicate is true, and empty array otherwise.
|
3289
3336
|
*/
|
3290
3337
|
findAllChannels(predicate) {
|
3291
|
-
return
|
3338
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3292
3339
|
const channels = [];
|
3293
3340
|
for (const target of yield this.installations()) {
|
3294
3341
|
if (target.type === exports.NotificationTargetType.Channel) {
|
@@ -3381,7 +3428,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3381
3428
|
const dialog = new botbuilderDialogs.WaterfallDialog(commandId, [
|
3382
3429
|
this.ssoStep.bind(this),
|
3383
3430
|
this.dedupStep.bind(this),
|
3384
|
-
(stepContext) =>
|
3431
|
+
(stepContext) => __awaiter(this, void 0, void 0, function* () {
|
3385
3432
|
const tokenResponse = stepContext.result.tokenResponse;
|
3386
3433
|
const context = stepContext.context;
|
3387
3434
|
const message = stepContext.result.message;
|
@@ -3418,7 +3465,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3418
3465
|
* @param accessor The instance of StatePropertyAccessor for dialog system.
|
3419
3466
|
*/
|
3420
3467
|
run(context, accessor) {
|
3421
|
-
return
|
3468
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3422
3469
|
const dialogSet = new botbuilderDialogs.DialogSet(accessor);
|
3423
3470
|
dialogSet.add(this);
|
3424
3471
|
const dialogContext = yield dialogSet.createContext(context);
|
@@ -3446,7 +3493,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3446
3493
|
return text;
|
3447
3494
|
}
|
3448
3495
|
commandRouteStep(stepContext) {
|
3449
|
-
return
|
3496
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3450
3497
|
const turnContext = stepContext.context;
|
3451
3498
|
const text = this.getActivityText(turnContext.activity);
|
3452
3499
|
const commandId = this.getMatchesCommandId(text);
|
@@ -3459,7 +3506,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3459
3506
|
});
|
3460
3507
|
}
|
3461
3508
|
ssoStep(stepContext) {
|
3462
|
-
return
|
3509
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3463
3510
|
try {
|
3464
3511
|
const turnContext = stepContext.context;
|
3465
3512
|
const text = this.getActivityText(turnContext.activity);
|
@@ -3477,7 +3524,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3477
3524
|
});
|
3478
3525
|
}
|
3479
3526
|
dedupStep(stepContext) {
|
3480
|
-
return
|
3527
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3481
3528
|
const tokenResponse = stepContext.result;
|
3482
3529
|
if (!tokenResponse) {
|
3483
3530
|
internalLogger.error(ErrorMessage.FailedToRetrieveSsoToken);
|
@@ -3506,7 +3553,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3506
3553
|
* @param context Context for the current turn of conversation.
|
3507
3554
|
*/
|
3508
3555
|
onEndDialog(context) {
|
3509
|
-
return
|
3556
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3510
3557
|
const conversationId = context.activity.conversation.id;
|
3511
3558
|
const currentDedupKeys = this.dedupStorageKeys.filter((key) => key.indexOf(conversationId) > 0);
|
3512
3559
|
yield this.dedupStorage.delete(currentDedupKeys);
|
@@ -3522,7 +3569,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3522
3569
|
* @returns boolean value indicate whether the message should be removed
|
3523
3570
|
*/
|
3524
3571
|
shouldDedup(context) {
|
3525
|
-
return
|
3572
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3526
3573
|
const storeItem = {
|
3527
3574
|
eTag: context.activity.value.id,
|
3528
3575
|
};
|
@@ -3622,7 +3669,7 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
|
|
3622
3669
|
const userState = (_b = (_a = ssoConfig.dialog) === null || _a === void 0 ? void 0 : _a.userState) !== null && _b !== void 0 ? _b : new botbuilder.UserState(memoryStorage);
|
3623
3670
|
const conversationState = (_d = (_c = ssoConfig.dialog) === null || _c === void 0 ? void 0 : _c.conversationState) !== null && _d !== void 0 ? _d : new botbuilder.ConversationState(memoryStorage);
|
3624
3671
|
const dedupStorage = (_f = (_e = ssoConfig.dialog) === null || _e === void 0 ? void 0 : _e.dedupStorage) !== null && _f !== void 0 ? _f : memoryStorage;
|
3625
|
-
const _l = ssoConfig.aad, { scopes } = _l, customConfig =
|
3672
|
+
const _l = ssoConfig.aad, { scopes } = _l, customConfig = __rest(_l, ["scopes"]);
|
3626
3673
|
const settings = {
|
3627
3674
|
scopes: scopes,
|
3628
3675
|
timeout: (_h = (_g = ssoConfig.dialog) === null || _g === void 0 ? void 0 : _g.ssoPromptConfig) === null || _h === void 0 ? void 0 : _h.timeout,
|
@@ -3632,7 +3679,7 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
|
|
3632
3679
|
this.conversationState = conversationState;
|
3633
3680
|
this.dialogState = conversationState.createProperty("DialogState");
|
3634
3681
|
this.userState = userState;
|
3635
|
-
this.onMessage((context, next) =>
|
3682
|
+
this.onMessage((context, next) => __awaiter(this, void 0, void 0, function* () {
|
3636
3683
|
yield this.ssoExecutionDialog.run(context, this.dialogState);
|
3637
3684
|
yield next();
|
3638
3685
|
}));
|
@@ -3656,7 +3703,7 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
|
|
3656
3703
|
const _super = Object.create(null, {
|
3657
3704
|
run: { get: () => super.run }
|
3658
3705
|
});
|
3659
|
-
return
|
3706
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3660
3707
|
try {
|
3661
3708
|
yield _super.run.call(this, context);
|
3662
3709
|
}
|
@@ -3676,7 +3723,7 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
|
|
3676
3723
|
* It should trigger {@link BotSsoExecutionDialog} instance to handle signin process
|
3677
3724
|
*/
|
3678
3725
|
handleTeamsSigninVerifyState(context, query) {
|
3679
|
-
return
|
3726
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3680
3727
|
yield this.ssoExecutionDialog.run(context, this.dialogState);
|
3681
3728
|
});
|
3682
3729
|
}
|
@@ -3686,11 +3733,11 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
|
|
3686
3733
|
* @param query Signin state (part of signin action auth flow) verification invoke query
|
3687
3734
|
* @returns A promise that represents the work queued.
|
3688
3735
|
*
|
3689
|
-
* @
|
3736
|
+
* @remarks
|
3690
3737
|
* It should trigger {@link BotSsoExecutionDialog} instance to handle signin process
|
3691
3738
|
*/
|
3692
3739
|
handleTeamsSigninTokenExchange(context, query) {
|
3693
|
-
return
|
3740
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3694
3741
|
yield this.ssoExecutionDialog.run(context, this.dialogState);
|
3695
3742
|
});
|
3696
3743
|
}
|
@@ -3796,11 +3843,14 @@ class ConversationBot$1 {
|
|
3796
3843
|
})
|
3797
3844
|
: new botbuilder.BotFrameworkAdapter(adapterConfig);
|
3798
3845
|
// the default error handler
|
3799
|
-
adapter.onTurnError = (context, error) =>
|
3846
|
+
adapter.onTurnError = (context, error) => __awaiter(this, void 0, void 0, function* () {
|
3800
3847
|
// This check writes out errors to console.
|
3848
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
3801
3849
|
console.error(`[onTurnError] unhandled error: ${error}`);
|
3802
3850
|
// Send a trace activity, which will be displayed in Bot Framework Emulator
|
3803
|
-
yield context.sendTraceActivity("OnTurnError Trace",
|
3851
|
+
yield context.sendTraceActivity("OnTurnError Trace",
|
3852
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
3853
|
+
`${error}`, "https://www.botframework.com/schemas/error", "TurnError");
|
3804
3854
|
// Send a message to the user
|
3805
3855
|
yield context.sendActivity(`The bot encountered unhandled error: ${error.message}`);
|
3806
3856
|
yield context.sendActivity("To continue to run this bot, please fix the bot source code.");
|
@@ -3829,10 +3879,10 @@ class ConversationBot$1 {
|
|
3829
3879
|
* ```
|
3830
3880
|
*/
|
3831
3881
|
requestHandler(req, res, logic) {
|
3832
|
-
return
|
3882
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3833
3883
|
if (logic === undefined) {
|
3834
3884
|
// create empty logic
|
3835
|
-
logic = () =>
|
3885
|
+
logic = () => __awaiter(this, void 0, void 0, function* () { });
|
3836
3886
|
}
|
3837
3887
|
yield this.adapter.processActivity(req, res, logic);
|
3838
3888
|
});
|
@@ -3984,9 +4034,9 @@ class MessageBuilder {
|
|
3984
4034
|
* @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
|
3985
4035
|
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
3986
4036
|
*
|
3987
|
-
* @returns SignIn link CardAction with 200 status code.
|
4037
|
+
* @returns SignIn link SilentAuth CardAction with 200 status code.
|
3988
4038
|
*/
|
3989
|
-
function
|
4039
|
+
function getSignInResponseForMessageExtensionWithSilentAuthConfig(authConfig, initiateLoginEndpoint, scopes) {
|
3990
4040
|
const scopesArray = getScopesArray(scopes);
|
3991
4041
|
const signInLink = `${initiateLoginEndpoint}?scope=${encodeURI(scopesArray.join(" "))}&clientId=${authConfig.clientId}&tenantId=${authConfig.tenantId}`;
|
3992
4042
|
return {
|
@@ -4004,6 +4054,34 @@ function getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiate
|
|
4004
4054
|
},
|
4005
4055
|
};
|
4006
4056
|
}
|
4057
|
+
/**
|
4058
|
+
* Retrieve the OAuth Sign in Link to use in the MessagingExtensionResult Suggested Actions.
|
4059
|
+
* This method just a workaround for link unfurling now.
|
4060
|
+
*
|
4061
|
+
* @param {OnBehalfOfCredentialAuthConfig} authConfig - User custom the message extension authentication configuration.
|
4062
|
+
* @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
|
4063
|
+
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
4064
|
+
*
|
4065
|
+
* @returns SignIn link Auth CardAction with 200 status code.
|
4066
|
+
*/
|
4067
|
+
function getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiateLoginEndpoint, scopes) {
|
4068
|
+
const scopesArray = getScopesArray(scopes);
|
4069
|
+
const signInLink = `${initiateLoginEndpoint}?scope=${encodeURI(scopesArray.join(" "))}&clientId=${authConfig.clientId}&tenantId=${authConfig.tenantId}`;
|
4070
|
+
return {
|
4071
|
+
composeExtension: {
|
4072
|
+
type: "auth",
|
4073
|
+
suggestedActions: {
|
4074
|
+
actions: [
|
4075
|
+
{
|
4076
|
+
type: "openUrl",
|
4077
|
+
value: signInLink,
|
4078
|
+
title: "Message Extension OAuth",
|
4079
|
+
},
|
4080
|
+
],
|
4081
|
+
},
|
4082
|
+
},
|
4083
|
+
};
|
4084
|
+
}
|
4007
4085
|
/**
|
4008
4086
|
* Retrieve the OAuth Sign in Link to use in the MessagingExtensionResult Suggested Actions.
|
4009
4087
|
* This method only work on MessageExtension with Query now.
|
@@ -4049,11 +4127,11 @@ function getSignInResponseForMessageExtension(teamsfx, scopes) {
|
|
4049
4127
|
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4050
4128
|
*/
|
4051
4129
|
function executionWithTokenAndConfig(context, authConfig, initiateLoginEndpoint, scopes, logic) {
|
4052
|
-
return
|
4130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4053
4131
|
const valueObj = context.activity.value;
|
4054
4132
|
if (!valueObj.authentication || !valueObj.authentication.token) {
|
4055
4133
|
internalLogger.verbose("No AccessToken in request, return silentAuth for AccessToken");
|
4056
|
-
return
|
4134
|
+
return getSignInResponseForMessageExtensionWithSilentAuthConfig(authConfig, initiateLoginEndpoint, scopes);
|
4057
4135
|
}
|
4058
4136
|
try {
|
4059
4137
|
const credential = new OnBehalfOfUserCredential(valueObj.authentication.token, authConfig);
|
@@ -4071,12 +4149,25 @@ function executionWithTokenAndConfig(context, authConfig, initiateLoginEndpoint,
|
|
4071
4149
|
}
|
4072
4150
|
}
|
4073
4151
|
catch (err) {
|
4074
|
-
if (err instanceof ErrorWithCode &&
|
4152
|
+
if (err instanceof ErrorWithCode &&
|
4153
|
+
err.code === exports.ErrorCode.UiRequiredError &&
|
4154
|
+
context.activity.name === "composeExtension/query") {
|
4075
4155
|
internalLogger.verbose("User not consent yet, return 412 to user consent first.");
|
4076
4156
|
const response = { status: 412 };
|
4077
4157
|
yield context.sendActivity({ value: response, type: botbuilder.ActivityTypes.InvokeResponse });
|
4078
4158
|
return;
|
4079
4159
|
}
|
4160
|
+
else if (err instanceof ErrorWithCode &&
|
4161
|
+
err.code === exports.ErrorCode.UiRequiredError &&
|
4162
|
+
context.activity.name === "composeExtension/queryLink") {
|
4163
|
+
internalLogger.verbose("User not consent yet, return auth card for user login");
|
4164
|
+
const response = getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiateLoginEndpoint, scopes);
|
4165
|
+
yield context.sendActivity({
|
4166
|
+
value: { status: 200, body: response },
|
4167
|
+
type: botbuilder.ActivityTypes.InvokeResponse,
|
4168
|
+
});
|
4169
|
+
return;
|
4170
|
+
}
|
4080
4171
|
throw err;
|
4081
4172
|
}
|
4082
4173
|
});
|
@@ -4099,7 +4190,7 @@ function executionWithTokenAndConfig(context, authConfig, initiateLoginEndpoint,
|
|
4099
4190
|
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4100
4191
|
*/
|
4101
4192
|
function executionWithToken(context, config, scopes, logic) {
|
4102
|
-
return
|
4193
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4103
4194
|
const valueObj = context.activity.value;
|
4104
4195
|
if (!valueObj.authentication || !valueObj.authentication.token) {
|
4105
4196
|
internalLogger.verbose("No AccessToken in request, return silentAuth for AccessToken");
|
@@ -4151,7 +4242,7 @@ function executionWithToken(context, config, scopes, logic) {
|
|
4151
4242
|
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4152
4243
|
*/
|
4153
4244
|
function handleMessageExtensionQueryWithToken(context, config, scopes, logic) {
|
4154
|
-
return
|
4245
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4155
4246
|
if (context.activity.name != "composeExtension/query") {
|
4156
4247
|
internalLogger.error(ErrorMessage.OnlySupportInQueryActivity);
|
4157
4248
|
throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInQueryActivity), exports.ErrorCode.FailedOperation);
|
@@ -4178,13 +4269,40 @@ function handleMessageExtensionQueryWithToken(context, config, scopes, logic) {
|
|
4178
4269
|
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4179
4270
|
*/
|
4180
4271
|
function handleMessageExtensionQueryWithSSO(context, config, initiateLoginEndpoint, scopes, logic) {
|
4181
|
-
return
|
4272
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4182
4273
|
if (context.activity.name != "composeExtension/query") {
|
4183
4274
|
internalLogger.error(ErrorMessage.OnlySupportInQueryActivity);
|
4184
4275
|
throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInQueryActivity), exports.ErrorCode.FailedOperation);
|
4185
4276
|
}
|
4186
4277
|
return yield executionWithTokenAndConfig(context, config !== null && config !== void 0 ? config : {}, initiateLoginEndpoint, scopes, logic);
|
4187
4278
|
});
|
4279
|
+
}
|
4280
|
+
/**
|
4281
|
+
* Users execute link query in message extension with SSO or access token.
|
4282
|
+
*
|
4283
|
+
* @param {TurnContext} context - The context object for the current turn.
|
4284
|
+
* @param {OnBehalfOfCredentialAuthConfig} config - User custom the message extension authentication configuration.
|
4285
|
+
* @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
|
4286
|
+
* @param {string| string[]} scopes - The list of scopes for which the token will have access.
|
4287
|
+
* @param {function} logic - Business logic when executing the link query in message extension with SSO or access token.
|
4288
|
+
*
|
4289
|
+
* @throws {@link ErrorCode|InternalError} when User invoke not response to message extension link query.
|
4290
|
+
* @throws {@link ErrorCode|InternalError} when failed to get access token with unknown error.
|
4291
|
+
* @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
|
4292
|
+
* @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth server.
|
4293
|
+
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
4294
|
+
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
4295
|
+
*
|
4296
|
+
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4297
|
+
*/
|
4298
|
+
function handleMessageExtensionLinkQueryWithSSO(context, config, initiateLoginEndpoint, scopes, logic) {
|
4299
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4300
|
+
if (context.activity.name != "composeExtension/queryLink") {
|
4301
|
+
internalLogger.error(ErrorMessage.OnlySupportInLinkQueryActivity);
|
4302
|
+
throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInLinkQueryActivity), exports.ErrorCode.FailedOperation);
|
4303
|
+
}
|
4304
|
+
return yield executionWithTokenAndConfig(context, config !== null && config !== void 0 ? config : {}, initiateLoginEndpoint, scopes, logic);
|
4305
|
+
});
|
4188
4306
|
}
|
4189
4307
|
|
4190
4308
|
/**
|
@@ -4356,11 +4474,11 @@ class Channel {
|
|
4356
4474
|
* @returns The response of sending message.
|
4357
4475
|
*/
|
4358
4476
|
sendMessage(text, onError) {
|
4359
|
-
return
|
4477
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4360
4478
|
const response = {};
|
4361
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) =>
|
4479
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4362
4480
|
const conversation = yield this.newConversation(context);
|
4363
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) =>
|
4481
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
4364
4482
|
try {
|
4365
4483
|
const res = yield ctx.sendActivity(text);
|
4366
4484
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -4388,11 +4506,11 @@ class Channel {
|
|
4388
4506
|
* @returns The response of sending adaptive card message.
|
4389
4507
|
*/
|
4390
4508
|
sendAdaptiveCard(card, onError) {
|
4391
|
-
return
|
4509
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4392
4510
|
const response = {};
|
4393
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) =>
|
4511
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4394
4512
|
const conversation = yield this.newConversation(context);
|
4395
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) =>
|
4513
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
4396
4514
|
try {
|
4397
4515
|
const res = yield ctx.sendActivity({
|
4398
4516
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -4456,11 +4574,11 @@ class Member {
|
|
4456
4574
|
* @returns The response of sending message.
|
4457
4575
|
*/
|
4458
4576
|
sendMessage(text, onError) {
|
4459
|
-
return
|
4577
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4460
4578
|
const response = {};
|
4461
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) =>
|
4579
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4462
4580
|
const conversation = yield this.newConversation(context);
|
4463
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) =>
|
4581
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
4464
4582
|
try {
|
4465
4583
|
const res = yield ctx.sendActivity(text);
|
4466
4584
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -4488,11 +4606,11 @@ class Member {
|
|
4488
4606
|
* @returns The response of sending adaptive card message.
|
4489
4607
|
*/
|
4490
4608
|
sendAdaptiveCard(card, onError) {
|
4491
|
-
return
|
4609
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4492
4610
|
const response = {};
|
4493
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) =>
|
4611
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4494
4612
|
const conversation = yield this.newConversation(context);
|
4495
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) =>
|
4613
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
4496
4614
|
try {
|
4497
4615
|
const res = yield ctx.sendActivity({
|
4498
4616
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -4516,7 +4634,7 @@ class Member {
|
|
4516
4634
|
* @internal
|
4517
4635
|
*/
|
4518
4636
|
newConversation(context) {
|
4519
|
-
return
|
4637
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4520
4638
|
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
4521
4639
|
const personalConversation = cloneConversation(reference);
|
4522
4640
|
const connectorClient = context.turnState.get(this.parent.adapter.ConnectorClientKey);
|
@@ -4568,9 +4686,9 @@ class TeamsBotInstallation {
|
|
4568
4686
|
* @returns The response of sending message.
|
4569
4687
|
*/
|
4570
4688
|
sendMessage(text, onError) {
|
4571
|
-
return
|
4689
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4572
4690
|
const response = {};
|
4573
|
-
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) =>
|
4691
|
+
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4574
4692
|
try {
|
4575
4693
|
const res = yield context.sendActivity(text);
|
4576
4694
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -4597,9 +4715,9 @@ class TeamsBotInstallation {
|
|
4597
4715
|
* @returns The response of sending adaptive card message.
|
4598
4716
|
*/
|
4599
4717
|
sendAdaptiveCard(card, onError) {
|
4600
|
-
return
|
4718
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4601
4719
|
const response = {};
|
4602
|
-
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) =>
|
4720
|
+
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4603
4721
|
try {
|
4604
4722
|
const res = yield context.sendActivity({
|
4605
4723
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -4624,13 +4742,13 @@ class TeamsBotInstallation {
|
|
4624
4742
|
* @returns An array of channels if bot is installed into a team, otherwise returns an empty array.
|
4625
4743
|
*/
|
4626
4744
|
channels() {
|
4627
|
-
return
|
4745
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4628
4746
|
const channels = [];
|
4629
4747
|
if (this.type !== exports.NotificationTargetType.Channel) {
|
4630
4748
|
return channels;
|
4631
4749
|
}
|
4632
4750
|
let teamsChannels = [];
|
4633
|
-
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) =>
|
4751
|
+
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4634
4752
|
const teamId = getTeamsBotInstallationId(context);
|
4635
4753
|
if (teamId !== undefined) {
|
4636
4754
|
teamsChannels = yield botbuilder.TeamsInfo.getTeamChannels(context, teamId);
|
@@ -4650,12 +4768,12 @@ class TeamsBotInstallation {
|
|
4650
4768
|
* @returns An array of members from where the bot is installed.
|
4651
4769
|
*/
|
4652
4770
|
getPagedMembers(pageSize, continuationToken) {
|
4653
|
-
return
|
4771
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4654
4772
|
let result = {
|
4655
4773
|
data: [],
|
4656
4774
|
continuationToken: "",
|
4657
4775
|
};
|
4658
|
-
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) =>
|
4776
|
+
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4659
4777
|
const pagedMembers = yield botbuilder.TeamsInfo.getPagedMembers(context, pageSize, continuationToken);
|
4660
4778
|
result = {
|
4661
4779
|
data: pagedMembers.members.map((m) => new Member(this, m)),
|
@@ -4673,7 +4791,7 @@ class TeamsBotInstallation {
|
|
4673
4791
|
* @deprecated Use `getPagedMembers` instead.
|
4674
4792
|
*/
|
4675
4793
|
members() {
|
4676
|
-
return
|
4794
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4677
4795
|
const members = [];
|
4678
4796
|
let continuationToken;
|
4679
4797
|
do {
|
@@ -4690,12 +4808,12 @@ class TeamsBotInstallation {
|
|
4690
4808
|
* @returns The team details if bot is installed into a team, otherwise returns `undefined`.
|
4691
4809
|
*/
|
4692
4810
|
getTeamDetails() {
|
4693
|
-
return
|
4811
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4694
4812
|
if (this.type !== exports.NotificationTargetType.Channel) {
|
4695
4813
|
return undefined;
|
4696
4814
|
}
|
4697
4815
|
let teamDetails;
|
4698
|
-
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) =>
|
4816
|
+
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4699
4817
|
const teamId = getTeamsBotInstallationId(context);
|
4700
4818
|
if (teamId !== undefined) {
|
4701
4819
|
teamDetails = yield botbuilder.TeamsInfo.getTeamDetails(context, teamId);
|
@@ -4751,9 +4869,9 @@ class NotificationBot {
|
|
4751
4869
|
* @returns Returns false if recieves `BotNotInConversationRoster` error, otherwise returns true.
|
4752
4870
|
*/
|
4753
4871
|
validateInstallation(conversationReference) {
|
4754
|
-
return
|
4872
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4755
4873
|
let isValid = true;
|
4756
|
-
yield this.adapter.continueConversationAsync(this.botAppId, conversationReference, (context) =>
|
4874
|
+
yield this.adapter.continueConversationAsync(this.botAppId, conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4757
4875
|
try {
|
4758
4876
|
// try get member to see if the installation is still valid
|
4759
4877
|
yield botbuilder.TeamsInfo.getPagedMembers(context, 1);
|
@@ -4779,7 +4897,7 @@ class NotificationBot {
|
|
4779
4897
|
* @returns An array of {@link TeamsBotInstallation} with paged data and continuation token.
|
4780
4898
|
*/
|
4781
4899
|
getPagedInstallations(pageSize, continuationToken, validationEnabled = true) {
|
4782
|
-
return
|
4900
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4783
4901
|
if (this.conversationReferenceStore === undefined || this.adapter === undefined) {
|
4784
4902
|
throw new Error("NotificationBot has not been initialized.");
|
4785
4903
|
}
|
@@ -4816,7 +4934,7 @@ class NotificationBot {
|
|
4816
4934
|
* @deprecated Use getPagedInstallations instead.
|
4817
4935
|
*/
|
4818
4936
|
installations() {
|
4819
|
-
return
|
4937
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4820
4938
|
let continuationToken;
|
4821
4939
|
const targets = [];
|
4822
4940
|
do {
|
@@ -4839,7 +4957,7 @@ class NotificationBot {
|
|
4839
4957
|
* @returns The first {@link Member} where predicate is true, and `undefined` otherwise.
|
4840
4958
|
*/
|
4841
4959
|
findMember(predicate, scope) {
|
4842
|
-
return
|
4960
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4843
4961
|
for (const target of yield this.installations()) {
|
4844
4962
|
if (this.matchSearchScope(target, scope)) {
|
4845
4963
|
for (const member of yield target.members()) {
|
@@ -4863,7 +4981,7 @@ class NotificationBot {
|
|
4863
4981
|
* @returns The first {@link Channel} where predicate is true, and `undefined` otherwise.
|
4864
4982
|
*/
|
4865
4983
|
findChannel(predicate) {
|
4866
|
-
return
|
4984
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4867
4985
|
for (const target of yield this.installations()) {
|
4868
4986
|
if (target.type === exports.NotificationTargetType.Channel) {
|
4869
4987
|
const teamDetails = yield target.getTeamDetails();
|
@@ -4887,7 +5005,7 @@ class NotificationBot {
|
|
4887
5005
|
* @returns An array of {@link Member} where predicate is true, and empty array otherwise.
|
4888
5006
|
*/
|
4889
5007
|
findAllMembers(predicate, scope) {
|
4890
|
-
return
|
5008
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4891
5009
|
const members = [];
|
4892
5010
|
for (const target of yield this.installations()) {
|
4893
5011
|
if (this.matchSearchScope(target, scope)) {
|
@@ -4910,7 +5028,7 @@ class NotificationBot {
|
|
4910
5028
|
* @returns An array of {@link Channel} where predicate is true, and empty array otherwise.
|
4911
5029
|
*/
|
4912
5030
|
findAllChannels(predicate) {
|
4913
|
-
return
|
5031
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4914
5032
|
const channels = [];
|
4915
5033
|
for (const target of yield this.installations()) {
|
4916
5034
|
if (target.type === exports.NotificationTargetType.Channel) {
|
@@ -5063,7 +5181,7 @@ class ConversationBot {
|
|
5063
5181
|
const botFrameworkAuthentication = new botbuilder.ConfigurationBotFrameworkAuthentication({}, credentialsFactory);
|
5064
5182
|
const adapter = new botbuilder.CloudAdapter(botFrameworkAuthentication);
|
5065
5183
|
// the default error handler
|
5066
|
-
adapter.onTurnError = (context, error) =>
|
5184
|
+
adapter.onTurnError = (context, error) => __awaiter(this, void 0, void 0, function* () {
|
5067
5185
|
// This check writes out errors to console.
|
5068
5186
|
console.error(`[onTurnError] unhandled error`, error);
|
5069
5187
|
// Send a trace activity, which will be displayed in Bot Framework Emulator
|
@@ -5098,10 +5216,10 @@ class ConversationBot {
|
|
5098
5216
|
* ```
|
5099
5217
|
*/
|
5100
5218
|
requestHandler(req, res, logic) {
|
5101
|
-
return
|
5219
|
+
return __awaiter(this, void 0, void 0, function* () {
|
5102
5220
|
if (logic === undefined) {
|
5103
5221
|
// create empty logic
|
5104
|
-
logic = () =>
|
5222
|
+
logic = () => __awaiter(this, void 0, void 0, function* () { });
|
5105
5223
|
}
|
5106
5224
|
yield this.adapter.process(req, res, logic);
|
5107
5225
|
});
|
@@ -5152,6 +5270,7 @@ exports.createPemCertOption = createPemCertOption;
|
|
5152
5270
|
exports.createPfxCertOption = createPfxCertOption;
|
5153
5271
|
exports.getLogLevel = getLogLevel;
|
5154
5272
|
exports.getTediousConnectionConfig = getTediousConnectionConfig;
|
5273
|
+
exports.handleMessageExtensionLinkQueryWithSSO = handleMessageExtensionLinkQueryWithSSO;
|
5155
5274
|
exports.handleMessageExtensionQueryWithSSO = handleMessageExtensionQueryWithSSO;
|
5156
5275
|
exports.handleMessageExtensionQueryWithToken = handleMessageExtensionQueryWithToken;
|
5157
5276
|
exports.sendAdaptiveCard = sendAdaptiveCard$1;
|