@microsoft/teamsfx 2.3.0 → 2.3.1-alpha.041c93f76.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.
@@ -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 tslib.__awaiter(this, void 0, void 0, function* () {
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 tslib.__awaiter(this, void 0, void 0, function* () {
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 tslib.__awaiter(this, void 0, void 0, function* () {
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 tslib.__awaiter(this, void 0, void 0, function* () {
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 tslib.__awaiter(this, void 0, void 0, function* () {
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 tslib.__awaiter(this, void 0, void 0, function* () {
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 tslib.__awaiter(this, void 0, void 0, function* () {
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 tslib.__awaiter(this, void 0, void 0, function* () {
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 tslib.__awaiter(this, void 0, void 0, function* () {
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,7 +1564,7 @@ function createApiClient(apiEndpoint, authProvider) {
1522
1564
  baseURL: apiEndpoint,
1523
1565
  });
1524
1566
  instance.interceptors.request.use(function (config) {
1525
- return tslib.__awaiter(this, void 0, void 0, function* () {
1567
+ return __awaiter(this, void 0, void 0, function* () {
1526
1568
  return yield authProvider.AddAuthenticationInfo(config);
1527
1569
  });
1528
1570
  });
@@ -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 tslib.__awaiter(this, void 0, void 0, function* () {
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 tslib.__awaiter(this, void 0, void 0, function* () {
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 tslib.__awaiter(this, void 0, void 0, function* () {
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 {@link InvokeResponse} object, which can be
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 tslib.__awaiter(this, void 0, void 0, function* () {
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 tslib.__awaiter(this, void 0, void 0, function* () {
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) => tslib.__awaiter(this, void 0, void 0, function* () {
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 tslib.__awaiter(this, void 0, void 0, function* () {
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 tslib.__awaiter(this, void 0, void 0, function* () {
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 tslib.__awaiter(this, void 0, void 0, function* () {
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:
@@ -2599,7 +2643,7 @@ class NotificationMiddleware {
2599
2643
  }
2600
2644
  tryAddMessagedReference(context) {
2601
2645
  var _a, _b, _c, _d;
2602
- return tslib.__awaiter(this, void 0, void 0, function* () {
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") {
@@ -2629,7 +2673,7 @@ class LocalFileStorage {
2629
2673
  this.filePath = path__namespace.resolve(fileDir, this.localFileName);
2630
2674
  }
2631
2675
  read(key) {
2632
- return tslib.__awaiter(this, void 0, void 0, function* () {
2676
+ return __awaiter(this, void 0, void 0, function* () {
2633
2677
  if (!(yield this.storeFileExists())) {
2634
2678
  return undefined;
2635
2679
  }
@@ -2638,7 +2682,7 @@ class LocalFileStorage {
2638
2682
  });
2639
2683
  }
2640
2684
  list() {
2641
- return tslib.__awaiter(this, void 0, void 0, function* () {
2685
+ return __awaiter(this, void 0, void 0, function* () {
2642
2686
  if (!(yield this.storeFileExists())) {
2643
2687
  return [];
2644
2688
  }
@@ -2647,7 +2691,7 @@ class LocalFileStorage {
2647
2691
  });
2648
2692
  }
2649
2693
  write(key, object) {
2650
- return tslib.__awaiter(this, void 0, void 0, function* () {
2694
+ return __awaiter(this, void 0, void 0, function* () {
2651
2695
  if (!(yield this.storeFileExists())) {
2652
2696
  yield this.writeToFile({ [key]: object });
2653
2697
  return;
@@ -2657,7 +2701,7 @@ class LocalFileStorage {
2657
2701
  });
2658
2702
  }
2659
2703
  delete(key) {
2660
- return tslib.__awaiter(this, void 0, void 0, function* () {
2704
+ return __awaiter(this, void 0, void 0, function* () {
2661
2705
  if (yield this.storeFileExists()) {
2662
2706
  const data = yield this.readFromFile();
2663
2707
  if (data[key] !== undefined) {
@@ -2702,7 +2746,7 @@ class LocalFileStorage {
2702
2746
  });
2703
2747
  }
2704
2748
  writeToFile(data) {
2705
- return tslib.__awaiter(this, void 0, void 0, function* () {
2749
+ return __awaiter(this, void 0, void 0, function* () {
2706
2750
  return new Promise((resolve, reject) => {
2707
2751
  try {
2708
2752
  const rawData = JSON.stringify(data, undefined, 2);
@@ -2730,7 +2774,7 @@ class DefaultConversationReferenceStore {
2730
2774
  this.storage = storage;
2731
2775
  }
2732
2776
  add(key, reference, options) {
2733
- return tslib.__awaiter(this, void 0, void 0, function* () {
2777
+ return __awaiter(this, void 0, void 0, function* () {
2734
2778
  if (options.overwrite) {
2735
2779
  yield this.storage.write(key, reference);
2736
2780
  return true;
@@ -2744,7 +2788,7 @@ class DefaultConversationReferenceStore {
2744
2788
  });
2745
2789
  }
2746
2790
  remove(key, reference) {
2747
- return tslib.__awaiter(this, void 0, void 0, function* () {
2791
+ return __awaiter(this, void 0, void 0, function* () {
2748
2792
  const ref = yield this.storage.read(key);
2749
2793
  if (ref === undefined) {
2750
2794
  return false;
@@ -2754,7 +2798,7 @@ class DefaultConversationReferenceStore {
2754
2798
  });
2755
2799
  }
2756
2800
  list(pageSize, continuationToken) {
2757
- return tslib.__awaiter(this, void 0, void 0, function* () {
2801
+ return __awaiter(this, void 0, void 0, function* () {
2758
2802
  const data = yield this.storage.list();
2759
2803
  return {
2760
2804
  data,
@@ -2822,11 +2866,11 @@ class Channel$1 {
2822
2866
  * @returns the response of sending message.
2823
2867
  */
2824
2868
  sendMessage(text, onError) {
2825
- return tslib.__awaiter(this, void 0, void 0, function* () {
2869
+ return __awaiter(this, void 0, void 0, function* () {
2826
2870
  const response = {};
2827
- yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
2871
+ yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
2828
2872
  const conversation = this.newConversation(context);
2829
- yield this.parent.adapter.continueConversation(conversation, (ctx) => tslib.__awaiter(this, void 0, void 0, function* () {
2873
+ yield this.parent.adapter.continueConversation(conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
2830
2874
  try {
2831
2875
  const res = yield ctx.sendActivity(text);
2832
2876
  response.id = res === null || res === void 0 ? void 0 : res.id;
@@ -2853,11 +2897,11 @@ class Channel$1 {
2853
2897
  * @returns the response of sending adaptive card message.
2854
2898
  */
2855
2899
  sendAdaptiveCard(card, onError) {
2856
- return tslib.__awaiter(this, void 0, void 0, function* () {
2900
+ return __awaiter(this, void 0, void 0, function* () {
2857
2901
  const response = {};
2858
- yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
2902
+ yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
2859
2903
  const conversation = this.newConversation(context);
2860
- yield this.parent.adapter.continueConversation(conversation, (ctx) => tslib.__awaiter(this, void 0, void 0, function* () {
2904
+ yield this.parent.adapter.continueConversation(conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
2861
2905
  try {
2862
2906
  const res = yield ctx.sendActivity({
2863
2907
  attachments: [botbuilder.CardFactory.adaptiveCard(card)],
@@ -2920,11 +2964,11 @@ class Member$1 {
2920
2964
  * @returns the response of sending message.
2921
2965
  */
2922
2966
  sendMessage(text, onError) {
2923
- return tslib.__awaiter(this, void 0, void 0, function* () {
2967
+ return __awaiter(this, void 0, void 0, function* () {
2924
2968
  const response = {};
2925
- yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
2969
+ yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
2926
2970
  const conversation = yield this.newConversation(context);
2927
- yield this.parent.adapter.continueConversation(conversation, (ctx) => tslib.__awaiter(this, void 0, void 0, function* () {
2971
+ yield this.parent.adapter.continueConversation(conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
2928
2972
  try {
2929
2973
  const res = yield ctx.sendActivity(text);
2930
2974
  response.id = res === null || res === void 0 ? void 0 : res.id;
@@ -2951,11 +2995,11 @@ class Member$1 {
2951
2995
  * @returns the response of sending adaptive card message.
2952
2996
  */
2953
2997
  sendAdaptiveCard(card, onError) {
2954
- return tslib.__awaiter(this, void 0, void 0, function* () {
2998
+ return __awaiter(this, void 0, void 0, function* () {
2955
2999
  const response = {};
2956
- yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
3000
+ yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
2957
3001
  const conversation = yield this.newConversation(context);
2958
- yield this.parent.adapter.continueConversation(conversation, (ctx) => tslib.__awaiter(this, void 0, void 0, function* () {
3002
+ yield this.parent.adapter.continueConversation(conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
2959
3003
  try {
2960
3004
  const res = yield ctx.sendActivity({
2961
3005
  attachments: [botbuilder.CardFactory.adaptiveCard(card)],
@@ -2979,7 +3023,7 @@ class Member$1 {
2979
3023
  * @internal
2980
3024
  */
2981
3025
  newConversation(context) {
2982
- return tslib.__awaiter(this, void 0, void 0, function* () {
3026
+ return __awaiter(this, void 0, void 0, function* () {
2983
3027
  const reference = botbuilder.TurnContext.getConversationReference(context.activity);
2984
3028
  const personalConversation = cloneConversation(reference);
2985
3029
  const connectorClient = context.turnState.get(this.parent.adapter.ConnectorClientKey);
@@ -3031,9 +3075,9 @@ class TeamsBotInstallation$1 {
3031
3075
  * @returns the response of sending message.
3032
3076
  */
3033
3077
  sendMessage(text, onError) {
3034
- return tslib.__awaiter(this, void 0, void 0, function* () {
3078
+ return __awaiter(this, void 0, void 0, function* () {
3035
3079
  const response = {};
3036
- yield this.adapter.continueConversation(this.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
3080
+ yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
3037
3081
  try {
3038
3082
  const res = yield context.sendActivity(text);
3039
3083
  response.id = res === null || res === void 0 ? void 0 : res.id;
@@ -3059,9 +3103,9 @@ class TeamsBotInstallation$1 {
3059
3103
  * @returns the response of sending adaptive card message.
3060
3104
  */
3061
3105
  sendAdaptiveCard(card, onError) {
3062
- return tslib.__awaiter(this, void 0, void 0, function* () {
3106
+ return __awaiter(this, void 0, void 0, function* () {
3063
3107
  const response = {};
3064
- yield this.adapter.continueConversation(this.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
3108
+ yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
3065
3109
  try {
3066
3110
  const res = yield context.sendActivity({
3067
3111
  attachments: [botbuilder.CardFactory.adaptiveCard(card)],
@@ -3086,13 +3130,13 @@ class TeamsBotInstallation$1 {
3086
3130
  * @returns an array of channels if bot is installed into a team, otherwise returns an empty array.
3087
3131
  */
3088
3132
  channels() {
3089
- return tslib.__awaiter(this, void 0, void 0, function* () {
3133
+ return __awaiter(this, void 0, void 0, function* () {
3090
3134
  const channels = [];
3091
3135
  if (this.type !== exports.NotificationTargetType.Channel) {
3092
3136
  return channels;
3093
3137
  }
3094
3138
  let teamsChannels = [];
3095
- yield this.adapter.continueConversation(this.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
3139
+ yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
3096
3140
  const teamId = getTeamsBotInstallationId(context);
3097
3141
  if (teamId !== undefined) {
3098
3142
  teamsChannels = yield botbuilder.TeamsInfo.getTeamChannels(context, teamId);
@@ -3110,9 +3154,9 @@ class TeamsBotInstallation$1 {
3110
3154
  * @returns an array of members from where the bot is installed.
3111
3155
  */
3112
3156
  members() {
3113
- return tslib.__awaiter(this, void 0, void 0, function* () {
3157
+ return __awaiter(this, void 0, void 0, function* () {
3114
3158
  const members = [];
3115
- yield this.adapter.continueConversation(this.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
3159
+ yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
3116
3160
  let continuationToken;
3117
3161
  do {
3118
3162
  const pagedMembers = yield botbuilder.TeamsInfo.getPagedMembers(context, undefined, continuationToken);
@@ -3131,12 +3175,12 @@ class TeamsBotInstallation$1 {
3131
3175
  * @returns the team details if bot is installed into a team, otherwise returns undefined.
3132
3176
  */
3133
3177
  getTeamDetails() {
3134
- return tslib.__awaiter(this, void 0, void 0, function* () {
3178
+ return __awaiter(this, void 0, void 0, function* () {
3135
3179
  if (this.type !== exports.NotificationTargetType.Channel) {
3136
3180
  return undefined;
3137
3181
  }
3138
3182
  let teamDetails;
3139
- yield this.adapter.continueConversation(this.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
3183
+ yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
3140
3184
  const teamId = getTeamsBotInstallationId(context);
3141
3185
  if (teamId !== undefined) {
3142
3186
  teamDetails = yield botbuilder.TeamsInfo.getTeamDetails(context, teamId);
@@ -3179,7 +3223,7 @@ class NotificationBot$1 {
3179
3223
  * @returns - an array of {@link TeamsBotInstallation}.
3180
3224
  */
3181
3225
  installations() {
3182
- return tslib.__awaiter(this, void 0, void 0, function* () {
3226
+ return __awaiter(this, void 0, void 0, function* () {
3183
3227
  if (this.conversationReferenceStore === undefined || this.adapter === undefined) {
3184
3228
  throw new Error("NotificationBot has not been initialized.");
3185
3229
  }
@@ -3188,7 +3232,7 @@ class NotificationBot$1 {
3188
3232
  for (const reference of references) {
3189
3233
  // validate connection
3190
3234
  let valid = true;
3191
- yield this.adapter.continueConversation(reference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
3235
+ yield this.adapter.continueConversation(reference, (context) => __awaiter(this, void 0, void 0, function* () {
3192
3236
  try {
3193
3237
  // try get member to see if the installation is still valid
3194
3238
  yield botbuilder.TeamsInfo.getPagedMembers(context, 1);
@@ -3220,7 +3264,7 @@ class NotificationBot$1 {
3220
3264
  * @returns the first {@link Member} where predicate is true, and undefined otherwise.
3221
3265
  */
3222
3266
  findMember(predicate, scope) {
3223
- return tslib.__awaiter(this, void 0, void 0, function* () {
3267
+ return __awaiter(this, void 0, void 0, function* () {
3224
3268
  for (const target of yield this.installations()) {
3225
3269
  if (this.matchSearchScope(target, scope)) {
3226
3270
  for (const member of yield target.members()) {
@@ -3243,7 +3287,7 @@ class NotificationBot$1 {
3243
3287
  * @returns the first {@link Channel} where predicate is true, and undefined otherwise.
3244
3288
  */
3245
3289
  findChannel(predicate) {
3246
- return tslib.__awaiter(this, void 0, void 0, function* () {
3290
+ return __awaiter(this, void 0, void 0, function* () {
3247
3291
  for (const target of yield this.installations()) {
3248
3292
  if (target.type === exports.NotificationTargetType.Channel) {
3249
3293
  const teamDetails = yield target.getTeamDetails();
@@ -3266,7 +3310,7 @@ class NotificationBot$1 {
3266
3310
  * @returns an array of {@link Member} where predicate is true, and empty array otherwise.
3267
3311
  */
3268
3312
  findAllMembers(predicate, scope) {
3269
- return tslib.__awaiter(this, void 0, void 0, function* () {
3313
+ return __awaiter(this, void 0, void 0, function* () {
3270
3314
  const members = [];
3271
3315
  for (const target of yield this.installations()) {
3272
3316
  if (this.matchSearchScope(target, scope)) {
@@ -3288,7 +3332,7 @@ class NotificationBot$1 {
3288
3332
  * @returns an array of {@link Channel} where predicate is true, and empty array otherwise.
3289
3333
  */
3290
3334
  findAllChannels(predicate) {
3291
- return tslib.__awaiter(this, void 0, void 0, function* () {
3335
+ return __awaiter(this, void 0, void 0, function* () {
3292
3336
  const channels = [];
3293
3337
  for (const target of yield this.installations()) {
3294
3338
  if (target.type === exports.NotificationTargetType.Channel) {
@@ -3381,7 +3425,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
3381
3425
  const dialog = new botbuilderDialogs.WaterfallDialog(commandId, [
3382
3426
  this.ssoStep.bind(this),
3383
3427
  this.dedupStep.bind(this),
3384
- (stepContext) => tslib.__awaiter(this, void 0, void 0, function* () {
3428
+ (stepContext) => __awaiter(this, void 0, void 0, function* () {
3385
3429
  const tokenResponse = stepContext.result.tokenResponse;
3386
3430
  const context = stepContext.context;
3387
3431
  const message = stepContext.result.message;
@@ -3418,7 +3462,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
3418
3462
  * @param accessor The instance of StatePropertyAccessor for dialog system.
3419
3463
  */
3420
3464
  run(context, accessor) {
3421
- return tslib.__awaiter(this, void 0, void 0, function* () {
3465
+ return __awaiter(this, void 0, void 0, function* () {
3422
3466
  const dialogSet = new botbuilderDialogs.DialogSet(accessor);
3423
3467
  dialogSet.add(this);
3424
3468
  const dialogContext = yield dialogSet.createContext(context);
@@ -3446,7 +3490,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
3446
3490
  return text;
3447
3491
  }
3448
3492
  commandRouteStep(stepContext) {
3449
- return tslib.__awaiter(this, void 0, void 0, function* () {
3493
+ return __awaiter(this, void 0, void 0, function* () {
3450
3494
  const turnContext = stepContext.context;
3451
3495
  const text = this.getActivityText(turnContext.activity);
3452
3496
  const commandId = this.getMatchesCommandId(text);
@@ -3459,7 +3503,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
3459
3503
  });
3460
3504
  }
3461
3505
  ssoStep(stepContext) {
3462
- return tslib.__awaiter(this, void 0, void 0, function* () {
3506
+ return __awaiter(this, void 0, void 0, function* () {
3463
3507
  try {
3464
3508
  const turnContext = stepContext.context;
3465
3509
  const text = this.getActivityText(turnContext.activity);
@@ -3477,7 +3521,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
3477
3521
  });
3478
3522
  }
3479
3523
  dedupStep(stepContext) {
3480
- return tslib.__awaiter(this, void 0, void 0, function* () {
3524
+ return __awaiter(this, void 0, void 0, function* () {
3481
3525
  const tokenResponse = stepContext.result;
3482
3526
  if (!tokenResponse) {
3483
3527
  internalLogger.error(ErrorMessage.FailedToRetrieveSsoToken);
@@ -3506,7 +3550,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
3506
3550
  * @param context Context for the current turn of conversation.
3507
3551
  */
3508
3552
  onEndDialog(context) {
3509
- return tslib.__awaiter(this, void 0, void 0, function* () {
3553
+ return __awaiter(this, void 0, void 0, function* () {
3510
3554
  const conversationId = context.activity.conversation.id;
3511
3555
  const currentDedupKeys = this.dedupStorageKeys.filter((key) => key.indexOf(conversationId) > 0);
3512
3556
  yield this.dedupStorage.delete(currentDedupKeys);
@@ -3522,7 +3566,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
3522
3566
  * @returns boolean value indicate whether the message should be removed
3523
3567
  */
3524
3568
  shouldDedup(context) {
3525
- return tslib.__awaiter(this, void 0, void 0, function* () {
3569
+ return __awaiter(this, void 0, void 0, function* () {
3526
3570
  const storeItem = {
3527
3571
  eTag: context.activity.value.id,
3528
3572
  };
@@ -3622,7 +3666,7 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
3622
3666
  const userState = (_b = (_a = ssoConfig.dialog) === null || _a === void 0 ? void 0 : _a.userState) !== null && _b !== void 0 ? _b : new botbuilder.UserState(memoryStorage);
3623
3667
  const conversationState = (_d = (_c = ssoConfig.dialog) === null || _c === void 0 ? void 0 : _c.conversationState) !== null && _d !== void 0 ? _d : new botbuilder.ConversationState(memoryStorage);
3624
3668
  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 = tslib.__rest(_l, ["scopes"]);
3669
+ const _l = ssoConfig.aad, { scopes } = _l, customConfig = __rest(_l, ["scopes"]);
3626
3670
  const settings = {
3627
3671
  scopes: scopes,
3628
3672
  timeout: (_h = (_g = ssoConfig.dialog) === null || _g === void 0 ? void 0 : _g.ssoPromptConfig) === null || _h === void 0 ? void 0 : _h.timeout,
@@ -3632,7 +3676,7 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
3632
3676
  this.conversationState = conversationState;
3633
3677
  this.dialogState = conversationState.createProperty("DialogState");
3634
3678
  this.userState = userState;
3635
- this.onMessage((context, next) => tslib.__awaiter(this, void 0, void 0, function* () {
3679
+ this.onMessage((context, next) => __awaiter(this, void 0, void 0, function* () {
3636
3680
  yield this.ssoExecutionDialog.run(context, this.dialogState);
3637
3681
  yield next();
3638
3682
  }));
@@ -3656,7 +3700,7 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
3656
3700
  const _super = Object.create(null, {
3657
3701
  run: { get: () => super.run }
3658
3702
  });
3659
- return tslib.__awaiter(this, void 0, void 0, function* () {
3703
+ return __awaiter(this, void 0, void 0, function* () {
3660
3704
  try {
3661
3705
  yield _super.run.call(this, context);
3662
3706
  }
@@ -3676,7 +3720,7 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
3676
3720
  * It should trigger {@link BotSsoExecutionDialog} instance to handle signin process
3677
3721
  */
3678
3722
  handleTeamsSigninVerifyState(context, query) {
3679
- return tslib.__awaiter(this, void 0, void 0, function* () {
3723
+ return __awaiter(this, void 0, void 0, function* () {
3680
3724
  yield this.ssoExecutionDialog.run(context, this.dialogState);
3681
3725
  });
3682
3726
  }
@@ -3686,11 +3730,11 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
3686
3730
  * @param query Signin state (part of signin action auth flow) verification invoke query
3687
3731
  * @returns A promise that represents the work queued.
3688
3732
  *
3689
- * @remark
3733
+ * @remarks
3690
3734
  * It should trigger {@link BotSsoExecutionDialog} instance to handle signin process
3691
3735
  */
3692
3736
  handleTeamsSigninTokenExchange(context, query) {
3693
- return tslib.__awaiter(this, void 0, void 0, function* () {
3737
+ return __awaiter(this, void 0, void 0, function* () {
3694
3738
  yield this.ssoExecutionDialog.run(context, this.dialogState);
3695
3739
  });
3696
3740
  }
@@ -3796,11 +3840,14 @@ class ConversationBot$1 {
3796
3840
  })
3797
3841
  : new botbuilder.BotFrameworkAdapter(adapterConfig);
3798
3842
  // the default error handler
3799
- adapter.onTurnError = (context, error) => tslib.__awaiter(this, void 0, void 0, function* () {
3843
+ adapter.onTurnError = (context, error) => __awaiter(this, void 0, void 0, function* () {
3800
3844
  // This check writes out errors to console.
3845
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
3801
3846
  console.error(`[onTurnError] unhandled error: ${error}`);
3802
3847
  // Send a trace activity, which will be displayed in Bot Framework Emulator
3803
- yield context.sendTraceActivity("OnTurnError Trace", `${error}`, "https://www.botframework.com/schemas/error", "TurnError");
3848
+ yield context.sendTraceActivity("OnTurnError Trace",
3849
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
3850
+ `${error}`, "https://www.botframework.com/schemas/error", "TurnError");
3804
3851
  // Send a message to the user
3805
3852
  yield context.sendActivity(`The bot encountered unhandled error: ${error.message}`);
3806
3853
  yield context.sendActivity("To continue to run this bot, please fix the bot source code.");
@@ -3829,10 +3876,10 @@ class ConversationBot$1 {
3829
3876
  * ```
3830
3877
  */
3831
3878
  requestHandler(req, res, logic) {
3832
- return tslib.__awaiter(this, void 0, void 0, function* () {
3879
+ return __awaiter(this, void 0, void 0, function* () {
3833
3880
  if (logic === undefined) {
3834
3881
  // create empty logic
3835
- logic = () => tslib.__awaiter(this, void 0, void 0, function* () { });
3882
+ logic = () => __awaiter(this, void 0, void 0, function* () { });
3836
3883
  }
3837
3884
  yield this.adapter.processActivity(req, res, logic);
3838
3885
  });
@@ -3984,9 +4031,9 @@ class MessageBuilder {
3984
4031
  * @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
3985
4032
  * @param {string | string[]} scopes - The list of scopes for which the token will have access.
3986
4033
  *
3987
- * @returns SignIn link CardAction with 200 status code.
4034
+ * @returns SignIn link SilentAuth CardAction with 200 status code.
3988
4035
  */
3989
- function getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiateLoginEndpoint, scopes) {
4036
+ function getSignInResponseForMessageExtensionWithSilentAuthConfig(authConfig, initiateLoginEndpoint, scopes) {
3990
4037
  const scopesArray = getScopesArray(scopes);
3991
4038
  const signInLink = `${initiateLoginEndpoint}?scope=${encodeURI(scopesArray.join(" "))}&clientId=${authConfig.clientId}&tenantId=${authConfig.tenantId}`;
3992
4039
  return {
@@ -4004,6 +4051,34 @@ function getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiate
4004
4051
  },
4005
4052
  };
4006
4053
  }
4054
+ /**
4055
+ * Retrieve the OAuth Sign in Link to use in the MessagingExtensionResult Suggested Actions.
4056
+ * This method just a workaround for link unfurling now.
4057
+ *
4058
+ * @param {OnBehalfOfCredentialAuthConfig} authConfig - User custom the message extension authentication configuration.
4059
+ * @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
4060
+ * @param {string | string[]} scopes - The list of scopes for which the token will have access.
4061
+ *
4062
+ * @returns SignIn link Auth CardAction with 200 status code.
4063
+ */
4064
+ function getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiateLoginEndpoint, scopes) {
4065
+ const scopesArray = getScopesArray(scopes);
4066
+ const signInLink = `${initiateLoginEndpoint}?scope=${encodeURI(scopesArray.join(" "))}&clientId=${authConfig.clientId}&tenantId=${authConfig.tenantId}`;
4067
+ return {
4068
+ composeExtension: {
4069
+ type: "auth",
4070
+ suggestedActions: {
4071
+ actions: [
4072
+ {
4073
+ type: "openUrl",
4074
+ value: signInLink,
4075
+ title: "Message Extension OAuth",
4076
+ },
4077
+ ],
4078
+ },
4079
+ },
4080
+ };
4081
+ }
4007
4082
  /**
4008
4083
  * Retrieve the OAuth Sign in Link to use in the MessagingExtensionResult Suggested Actions.
4009
4084
  * This method only work on MessageExtension with Query now.
@@ -4049,11 +4124,11 @@ function getSignInResponseForMessageExtension(teamsfx, scopes) {
4049
4124
  * @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
4050
4125
  */
4051
4126
  function executionWithTokenAndConfig(context, authConfig, initiateLoginEndpoint, scopes, logic) {
4052
- return tslib.__awaiter(this, void 0, void 0, function* () {
4127
+ return __awaiter(this, void 0, void 0, function* () {
4053
4128
  const valueObj = context.activity.value;
4054
4129
  if (!valueObj.authentication || !valueObj.authentication.token) {
4055
4130
  internalLogger.verbose("No AccessToken in request, return silentAuth for AccessToken");
4056
- return getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiateLoginEndpoint, scopes);
4131
+ return getSignInResponseForMessageExtensionWithSilentAuthConfig(authConfig, initiateLoginEndpoint, scopes);
4057
4132
  }
4058
4133
  try {
4059
4134
  const credential = new OnBehalfOfUserCredential(valueObj.authentication.token, authConfig);
@@ -4071,12 +4146,25 @@ function executionWithTokenAndConfig(context, authConfig, initiateLoginEndpoint,
4071
4146
  }
4072
4147
  }
4073
4148
  catch (err) {
4074
- if (err instanceof ErrorWithCode && err.code === exports.ErrorCode.UiRequiredError) {
4149
+ if (err instanceof ErrorWithCode &&
4150
+ err.code === exports.ErrorCode.UiRequiredError &&
4151
+ context.activity.name === "composeExtension/query") {
4075
4152
  internalLogger.verbose("User not consent yet, return 412 to user consent first.");
4076
4153
  const response = { status: 412 };
4077
4154
  yield context.sendActivity({ value: response, type: botbuilder.ActivityTypes.InvokeResponse });
4078
4155
  return;
4079
4156
  }
4157
+ else if (err instanceof ErrorWithCode &&
4158
+ err.code === exports.ErrorCode.UiRequiredError &&
4159
+ context.activity.name === "composeExtension/queryLink") {
4160
+ internalLogger.verbose("User not consent yet, return auth card for user login");
4161
+ const response = getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiateLoginEndpoint, scopes);
4162
+ yield context.sendActivity({
4163
+ value: { status: 200, body: response },
4164
+ type: botbuilder.ActivityTypes.InvokeResponse,
4165
+ });
4166
+ return;
4167
+ }
4080
4168
  throw err;
4081
4169
  }
4082
4170
  });
@@ -4099,7 +4187,7 @@ function executionWithTokenAndConfig(context, authConfig, initiateLoginEndpoint,
4099
4187
  * @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
4100
4188
  */
4101
4189
  function executionWithToken(context, config, scopes, logic) {
4102
- return tslib.__awaiter(this, void 0, void 0, function* () {
4190
+ return __awaiter(this, void 0, void 0, function* () {
4103
4191
  const valueObj = context.activity.value;
4104
4192
  if (!valueObj.authentication || !valueObj.authentication.token) {
4105
4193
  internalLogger.verbose("No AccessToken in request, return silentAuth for AccessToken");
@@ -4151,7 +4239,7 @@ function executionWithToken(context, config, scopes, logic) {
4151
4239
  * @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
4152
4240
  */
4153
4241
  function handleMessageExtensionQueryWithToken(context, config, scopes, logic) {
4154
- return tslib.__awaiter(this, void 0, void 0, function* () {
4242
+ return __awaiter(this, void 0, void 0, function* () {
4155
4243
  if (context.activity.name != "composeExtension/query") {
4156
4244
  internalLogger.error(ErrorMessage.OnlySupportInQueryActivity);
4157
4245
  throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInQueryActivity), exports.ErrorCode.FailedOperation);
@@ -4178,13 +4266,40 @@ function handleMessageExtensionQueryWithToken(context, config, scopes, logic) {
4178
4266
  * @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
4179
4267
  */
4180
4268
  function handleMessageExtensionQueryWithSSO(context, config, initiateLoginEndpoint, scopes, logic) {
4181
- return tslib.__awaiter(this, void 0, void 0, function* () {
4269
+ return __awaiter(this, void 0, void 0, function* () {
4182
4270
  if (context.activity.name != "composeExtension/query") {
4183
4271
  internalLogger.error(ErrorMessage.OnlySupportInQueryActivity);
4184
4272
  throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInQueryActivity), exports.ErrorCode.FailedOperation);
4185
4273
  }
4186
4274
  return yield executionWithTokenAndConfig(context, config !== null && config !== void 0 ? config : {}, initiateLoginEndpoint, scopes, logic);
4187
4275
  });
4276
+ }
4277
+ /**
4278
+ * Users execute link query in message extension with SSO or access token.
4279
+ *
4280
+ * @param {TurnContext} context - The context object for the current turn.
4281
+ * @param {OnBehalfOfCredentialAuthConfig} config - User custom the message extension authentication configuration.
4282
+ * @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
4283
+ * @param {string| string[]} scopes - The list of scopes for which the token will have access.
4284
+ * @param {function} logic - Business logic when executing the link query in message extension with SSO or access token.
4285
+ *
4286
+ * @throws {@link ErrorCode|InternalError} when User invoke not response to message extension link query.
4287
+ * @throws {@link ErrorCode|InternalError} when failed to get access token with unknown error.
4288
+ * @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
4289
+ * @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth server.
4290
+ * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
4291
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
4292
+ *
4293
+ * @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
4294
+ */
4295
+ function handleMessageExtensionLinkQueryWithSSO(context, config, initiateLoginEndpoint, scopes, logic) {
4296
+ return __awaiter(this, void 0, void 0, function* () {
4297
+ if (context.activity.name != "composeExtension/queryLink") {
4298
+ internalLogger.error(ErrorMessage.OnlySupportInLinkQueryActivity);
4299
+ throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInLinkQueryActivity), exports.ErrorCode.FailedOperation);
4300
+ }
4301
+ return yield executionWithTokenAndConfig(context, config !== null && config !== void 0 ? config : {}, initiateLoginEndpoint, scopes, logic);
4302
+ });
4188
4303
  }
4189
4304
 
4190
4305
  /**
@@ -4356,11 +4471,11 @@ class Channel {
4356
4471
  * @returns The response of sending message.
4357
4472
  */
4358
4473
  sendMessage(text, onError) {
4359
- return tslib.__awaiter(this, void 0, void 0, function* () {
4474
+ return __awaiter(this, void 0, void 0, function* () {
4360
4475
  const response = {};
4361
- yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
4476
+ yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
4362
4477
  const conversation = yield this.newConversation(context);
4363
- yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) => tslib.__awaiter(this, void 0, void 0, function* () {
4478
+ yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
4364
4479
  try {
4365
4480
  const res = yield ctx.sendActivity(text);
4366
4481
  response.id = res === null || res === void 0 ? void 0 : res.id;
@@ -4388,11 +4503,11 @@ class Channel {
4388
4503
  * @returns The response of sending adaptive card message.
4389
4504
  */
4390
4505
  sendAdaptiveCard(card, onError) {
4391
- return tslib.__awaiter(this, void 0, void 0, function* () {
4506
+ return __awaiter(this, void 0, void 0, function* () {
4392
4507
  const response = {};
4393
- yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
4508
+ yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
4394
4509
  const conversation = yield this.newConversation(context);
4395
- yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) => tslib.__awaiter(this, void 0, void 0, function* () {
4510
+ yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
4396
4511
  try {
4397
4512
  const res = yield ctx.sendActivity({
4398
4513
  attachments: [botbuilder.CardFactory.adaptiveCard(card)],
@@ -4456,11 +4571,11 @@ class Member {
4456
4571
  * @returns The response of sending message.
4457
4572
  */
4458
4573
  sendMessage(text, onError) {
4459
- return tslib.__awaiter(this, void 0, void 0, function* () {
4574
+ return __awaiter(this, void 0, void 0, function* () {
4460
4575
  const response = {};
4461
- yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
4576
+ yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
4462
4577
  const conversation = yield this.newConversation(context);
4463
- yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) => tslib.__awaiter(this, void 0, void 0, function* () {
4578
+ yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
4464
4579
  try {
4465
4580
  const res = yield ctx.sendActivity(text);
4466
4581
  response.id = res === null || res === void 0 ? void 0 : res.id;
@@ -4488,11 +4603,11 @@ class Member {
4488
4603
  * @returns The response of sending adaptive card message.
4489
4604
  */
4490
4605
  sendAdaptiveCard(card, onError) {
4491
- return tslib.__awaiter(this, void 0, void 0, function* () {
4606
+ return __awaiter(this, void 0, void 0, function* () {
4492
4607
  const response = {};
4493
- yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
4608
+ yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
4494
4609
  const conversation = yield this.newConversation(context);
4495
- yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) => tslib.__awaiter(this, void 0, void 0, function* () {
4610
+ yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
4496
4611
  try {
4497
4612
  const res = yield ctx.sendActivity({
4498
4613
  attachments: [botbuilder.CardFactory.adaptiveCard(card)],
@@ -4516,7 +4631,7 @@ class Member {
4516
4631
  * @internal
4517
4632
  */
4518
4633
  newConversation(context) {
4519
- return tslib.__awaiter(this, void 0, void 0, function* () {
4634
+ return __awaiter(this, void 0, void 0, function* () {
4520
4635
  const reference = botbuilder.TurnContext.getConversationReference(context.activity);
4521
4636
  const personalConversation = cloneConversation(reference);
4522
4637
  const connectorClient = context.turnState.get(this.parent.adapter.ConnectorClientKey);
@@ -4568,9 +4683,9 @@ class TeamsBotInstallation {
4568
4683
  * @returns The response of sending message.
4569
4684
  */
4570
4685
  sendMessage(text, onError) {
4571
- return tslib.__awaiter(this, void 0, void 0, function* () {
4686
+ return __awaiter(this, void 0, void 0, function* () {
4572
4687
  const response = {};
4573
- yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
4688
+ yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
4574
4689
  try {
4575
4690
  const res = yield context.sendActivity(text);
4576
4691
  response.id = res === null || res === void 0 ? void 0 : res.id;
@@ -4597,9 +4712,9 @@ class TeamsBotInstallation {
4597
4712
  * @returns The response of sending adaptive card message.
4598
4713
  */
4599
4714
  sendAdaptiveCard(card, onError) {
4600
- return tslib.__awaiter(this, void 0, void 0, function* () {
4715
+ return __awaiter(this, void 0, void 0, function* () {
4601
4716
  const response = {};
4602
- yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
4717
+ yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
4603
4718
  try {
4604
4719
  const res = yield context.sendActivity({
4605
4720
  attachments: [botbuilder.CardFactory.adaptiveCard(card)],
@@ -4624,13 +4739,13 @@ class TeamsBotInstallation {
4624
4739
  * @returns An array of channels if bot is installed into a team, otherwise returns an empty array.
4625
4740
  */
4626
4741
  channels() {
4627
- return tslib.__awaiter(this, void 0, void 0, function* () {
4742
+ return __awaiter(this, void 0, void 0, function* () {
4628
4743
  const channels = [];
4629
4744
  if (this.type !== exports.NotificationTargetType.Channel) {
4630
4745
  return channels;
4631
4746
  }
4632
4747
  let teamsChannels = [];
4633
- yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
4748
+ yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
4634
4749
  const teamId = getTeamsBotInstallationId(context);
4635
4750
  if (teamId !== undefined) {
4636
4751
  teamsChannels = yield botbuilder.TeamsInfo.getTeamChannels(context, teamId);
@@ -4650,12 +4765,12 @@ class TeamsBotInstallation {
4650
4765
  * @returns An array of members from where the bot is installed.
4651
4766
  */
4652
4767
  getPagedMembers(pageSize, continuationToken) {
4653
- return tslib.__awaiter(this, void 0, void 0, function* () {
4768
+ return __awaiter(this, void 0, void 0, function* () {
4654
4769
  let result = {
4655
4770
  data: [],
4656
4771
  continuationToken: "",
4657
4772
  };
4658
- yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
4773
+ yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
4659
4774
  const pagedMembers = yield botbuilder.TeamsInfo.getPagedMembers(context, pageSize, continuationToken);
4660
4775
  result = {
4661
4776
  data: pagedMembers.members.map((m) => new Member(this, m)),
@@ -4673,7 +4788,7 @@ class TeamsBotInstallation {
4673
4788
  * @deprecated Use `getPagedMembers` instead.
4674
4789
  */
4675
4790
  members() {
4676
- return tslib.__awaiter(this, void 0, void 0, function* () {
4791
+ return __awaiter(this, void 0, void 0, function* () {
4677
4792
  const members = [];
4678
4793
  let continuationToken;
4679
4794
  do {
@@ -4690,12 +4805,12 @@ class TeamsBotInstallation {
4690
4805
  * @returns The team details if bot is installed into a team, otherwise returns `undefined`.
4691
4806
  */
4692
4807
  getTeamDetails() {
4693
- return tslib.__awaiter(this, void 0, void 0, function* () {
4808
+ return __awaiter(this, void 0, void 0, function* () {
4694
4809
  if (this.type !== exports.NotificationTargetType.Channel) {
4695
4810
  return undefined;
4696
4811
  }
4697
4812
  let teamDetails;
4698
- yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
4813
+ yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
4699
4814
  const teamId = getTeamsBotInstallationId(context);
4700
4815
  if (teamId !== undefined) {
4701
4816
  teamDetails = yield botbuilder.TeamsInfo.getTeamDetails(context, teamId);
@@ -4751,9 +4866,9 @@ class NotificationBot {
4751
4866
  * @returns Returns false if recieves `BotNotInConversationRoster` error, otherwise returns true.
4752
4867
  */
4753
4868
  validateInstallation(conversationReference) {
4754
- return tslib.__awaiter(this, void 0, void 0, function* () {
4869
+ return __awaiter(this, void 0, void 0, function* () {
4755
4870
  let isValid = true;
4756
- yield this.adapter.continueConversationAsync(this.botAppId, conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
4871
+ yield this.adapter.continueConversationAsync(this.botAppId, conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
4757
4872
  try {
4758
4873
  // try get member to see if the installation is still valid
4759
4874
  yield botbuilder.TeamsInfo.getPagedMembers(context, 1);
@@ -4779,7 +4894,7 @@ class NotificationBot {
4779
4894
  * @returns An array of {@link TeamsBotInstallation} with paged data and continuation token.
4780
4895
  */
4781
4896
  getPagedInstallations(pageSize, continuationToken, validationEnabled = true) {
4782
- return tslib.__awaiter(this, void 0, void 0, function* () {
4897
+ return __awaiter(this, void 0, void 0, function* () {
4783
4898
  if (this.conversationReferenceStore === undefined || this.adapter === undefined) {
4784
4899
  throw new Error("NotificationBot has not been initialized.");
4785
4900
  }
@@ -4816,7 +4931,7 @@ class NotificationBot {
4816
4931
  * @deprecated Use getPagedInstallations instead.
4817
4932
  */
4818
4933
  installations() {
4819
- return tslib.__awaiter(this, void 0, void 0, function* () {
4934
+ return __awaiter(this, void 0, void 0, function* () {
4820
4935
  let continuationToken;
4821
4936
  const targets = [];
4822
4937
  do {
@@ -4839,7 +4954,7 @@ class NotificationBot {
4839
4954
  * @returns The first {@link Member} where predicate is true, and `undefined` otherwise.
4840
4955
  */
4841
4956
  findMember(predicate, scope) {
4842
- return tslib.__awaiter(this, void 0, void 0, function* () {
4957
+ return __awaiter(this, void 0, void 0, function* () {
4843
4958
  for (const target of yield this.installations()) {
4844
4959
  if (this.matchSearchScope(target, scope)) {
4845
4960
  for (const member of yield target.members()) {
@@ -4863,7 +4978,7 @@ class NotificationBot {
4863
4978
  * @returns The first {@link Channel} where predicate is true, and `undefined` otherwise.
4864
4979
  */
4865
4980
  findChannel(predicate) {
4866
- return tslib.__awaiter(this, void 0, void 0, function* () {
4981
+ return __awaiter(this, void 0, void 0, function* () {
4867
4982
  for (const target of yield this.installations()) {
4868
4983
  if (target.type === exports.NotificationTargetType.Channel) {
4869
4984
  const teamDetails = yield target.getTeamDetails();
@@ -4887,7 +5002,7 @@ class NotificationBot {
4887
5002
  * @returns An array of {@link Member} where predicate is true, and empty array otherwise.
4888
5003
  */
4889
5004
  findAllMembers(predicate, scope) {
4890
- return tslib.__awaiter(this, void 0, void 0, function* () {
5005
+ return __awaiter(this, void 0, void 0, function* () {
4891
5006
  const members = [];
4892
5007
  for (const target of yield this.installations()) {
4893
5008
  if (this.matchSearchScope(target, scope)) {
@@ -4910,7 +5025,7 @@ class NotificationBot {
4910
5025
  * @returns An array of {@link Channel} where predicate is true, and empty array otherwise.
4911
5026
  */
4912
5027
  findAllChannels(predicate) {
4913
- return tslib.__awaiter(this, void 0, void 0, function* () {
5028
+ return __awaiter(this, void 0, void 0, function* () {
4914
5029
  const channels = [];
4915
5030
  for (const target of yield this.installations()) {
4916
5031
  if (target.type === exports.NotificationTargetType.Channel) {
@@ -5063,7 +5178,7 @@ class ConversationBot {
5063
5178
  const botFrameworkAuthentication = new botbuilder.ConfigurationBotFrameworkAuthentication({}, credentialsFactory);
5064
5179
  const adapter = new botbuilder.CloudAdapter(botFrameworkAuthentication);
5065
5180
  // the default error handler
5066
- adapter.onTurnError = (context, error) => tslib.__awaiter(this, void 0, void 0, function* () {
5181
+ adapter.onTurnError = (context, error) => __awaiter(this, void 0, void 0, function* () {
5067
5182
  // This check writes out errors to console.
5068
5183
  console.error(`[onTurnError] unhandled error`, error);
5069
5184
  // Send a trace activity, which will be displayed in Bot Framework Emulator
@@ -5098,10 +5213,10 @@ class ConversationBot {
5098
5213
  * ```
5099
5214
  */
5100
5215
  requestHandler(req, res, logic) {
5101
- return tslib.__awaiter(this, void 0, void 0, function* () {
5216
+ return __awaiter(this, void 0, void 0, function* () {
5102
5217
  if (logic === undefined) {
5103
5218
  // create empty logic
5104
- logic = () => tslib.__awaiter(this, void 0, void 0, function* () { });
5219
+ logic = () => __awaiter(this, void 0, void 0, function* () { });
5105
5220
  }
5106
5221
  yield this.adapter.process(req, res, logic);
5107
5222
  });
@@ -5152,6 +5267,7 @@ exports.createPemCertOption = createPemCertOption;
5152
5267
  exports.createPfxCertOption = createPfxCertOption;
5153
5268
  exports.getLogLevel = getLogLevel;
5154
5269
  exports.getTediousConnectionConfig = getTediousConnectionConfig;
5270
+ exports.handleMessageExtensionLinkQueryWithSSO = handleMessageExtensionLinkQueryWithSSO;
5155
5271
  exports.handleMessageExtensionQueryWithSSO = handleMessageExtensionQueryWithSSO;
5156
5272
  exports.handleMessageExtensionQueryWithToken = handleMessageExtensionQueryWithToken;
5157
5273
  exports.sendAdaptiveCard = sendAdaptiveCard$1;