@microsoft/teamsfx 2.2.3-alpha.dea6b9e8a.0 → 2.2.3-alpha.e58796e43.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 +165 -115
- package/dist/index.esm2017.js +22 -0
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +63 -7
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +52 -1
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +184 -118
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +26 -10
- package/types/teamsfx.d.ts +27 -4
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');
|
@@ -190,6 +189,48 @@ class ErrorWithCode extends Error {
|
|
190
189
|
}
|
191
190
|
}
|
192
191
|
|
192
|
+
/******************************************************************************
|
193
|
+
Copyright (c) Microsoft Corporation.
|
194
|
+
|
195
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
196
|
+
purpose with or without fee is hereby granted.
|
197
|
+
|
198
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
199
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
200
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
201
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
202
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
203
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
204
|
+
PERFORMANCE OF THIS SOFTWARE.
|
205
|
+
***************************************************************************** */
|
206
|
+
|
207
|
+
function __rest(s, e) {
|
208
|
+
var t = {};
|
209
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
210
|
+
t[p] = s[p];
|
211
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
212
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
213
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
214
|
+
t[p[i]] = s[p[i]];
|
215
|
+
}
|
216
|
+
return t;
|
217
|
+
}
|
218
|
+
|
219
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
220
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
221
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
222
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
223
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
224
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
225
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
226
|
+
});
|
227
|
+
}
|
228
|
+
|
229
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
230
|
+
var e = new Error(message);
|
231
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
232
|
+
};
|
233
|
+
|
193
234
|
// Copyright (c) Microsoft Corporation.
|
194
235
|
// Licensed under the MIT license.
|
195
236
|
/**
|
@@ -514,7 +555,7 @@ class AppCredential {
|
|
514
555
|
* Throw error if get access token failed.
|
515
556
|
*/
|
516
557
|
getToken(scopes, options) {
|
517
|
-
return
|
558
|
+
return __awaiter(this, void 0, void 0, function* () {
|
518
559
|
let accessToken;
|
519
560
|
validateScopesType(scopes);
|
520
561
|
const scopesStr = typeof scopes === "string" ? scopes : scopes.join(" ");
|
@@ -652,7 +693,7 @@ class OnBehalfOfUserCredential {
|
|
652
693
|
* If scopes is non-empty, it returns access token for target scope.
|
653
694
|
*/
|
654
695
|
getToken(scopes, options) {
|
655
|
-
return
|
696
|
+
return __awaiter(this, void 0, void 0, function* () {
|
656
697
|
validateScopesType(scopes);
|
657
698
|
const scopesArray = getScopesArray(scopes);
|
658
699
|
let result;
|
@@ -773,8 +814,10 @@ class TeamsUserCredential {
|
|
773
814
|
|
774
815
|
// Copyright (c) Microsoft Corporation.
|
775
816
|
const defaultScope = "https://graph.microsoft.com/.default";
|
817
|
+
// eslint-disable-next-line no-secrets/no-secrets
|
776
818
|
/**
|
777
819
|
* Microsoft Graph auth provider for Teams Framework
|
820
|
+
* @deprecated Use `TokenCredentialAuthenticationProvider` from `@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials` instead.
|
778
821
|
*/
|
779
822
|
class MsGraphAuthProvider {
|
780
823
|
constructor(credentialOrTeamsFx, scopes) {
|
@@ -803,7 +846,7 @@ class MsGraphAuthProvider {
|
|
803
846
|
*
|
804
847
|
*/
|
805
848
|
getAccessToken() {
|
806
|
-
return
|
849
|
+
return __awaiter(this, void 0, void 0, function* () {
|
807
850
|
internalLogger.info(`Get Graph Access token with scopes: '${this.scopes.toString()}'`);
|
808
851
|
let accessToken;
|
809
852
|
if (this.credentialOrTeamsFx.getCredential) {
|
@@ -831,6 +874,14 @@ class MsGraphAuthProvider {
|
|
831
874
|
// Copyright (c) Microsoft Corporation.
|
832
875
|
/**
|
833
876
|
* Get Microsoft graph client.
|
877
|
+
* @deprecated Use `TokenCredentialAuthenticationProvider` and `Client.initWithMiddleware` instead.
|
878
|
+
* ```typescript
|
879
|
+
* const authProvider = new TokenCredentialAuthenticationProvider(credential, { scopes: scope });
|
880
|
+
* const graph = Client.initWithMiddleware({
|
881
|
+
* authProvider: authProvider,
|
882
|
+
* });
|
883
|
+
* ```
|
884
|
+
*
|
834
885
|
* @example
|
835
886
|
* Get Microsoft graph client by TokenCredential
|
836
887
|
* ```typescript
|
@@ -888,6 +939,14 @@ function createMicrosoftGraphClient(teamsfx, scopes) {
|
|
888
939
|
// eslint-disable-next-line no-secrets/no-secrets
|
889
940
|
/**
|
890
941
|
* Get Microsoft graph client.
|
942
|
+
* @deprecated Use `TokenCredentialAuthenticationProvider` and `Client.initWithMiddleware` instead.
|
943
|
+
* ```typescript
|
944
|
+
* const authProvider = new TokenCredentialAuthenticationProvider(credential, { scopes: scope });
|
945
|
+
* const graph = Client.initWithMiddleware({
|
946
|
+
* authProvider: authProvider,
|
947
|
+
* });
|
948
|
+
* ```
|
949
|
+
*
|
891
950
|
* @example
|
892
951
|
* Get Microsoft graph client by TokenCredential
|
893
952
|
* ```typescript
|
@@ -967,7 +1026,7 @@ const defaultSQLScope = "https://database.windows.net/";
|
|
967
1026
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
968
1027
|
*/
|
969
1028
|
function getTediousConnectionConfig(teamsfx, databaseName) {
|
970
|
-
return
|
1029
|
+
return __awaiter(this, void 0, void 0, function* () {
|
971
1030
|
internalLogger.info("Get SQL configuration");
|
972
1031
|
try {
|
973
1032
|
isSQLConfigurationValid(teamsfx);
|
@@ -1071,7 +1130,7 @@ function generateDefaultConfig(teamsfx, databaseName) {
|
|
1071
1130
|
* @internal
|
1072
1131
|
*/
|
1073
1132
|
function generateTokenConfig(teamsfx, databaseName) {
|
1074
|
-
return
|
1133
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1075
1134
|
internalLogger.verbose("Generate tedious config with MSI token");
|
1076
1135
|
let token;
|
1077
1136
|
try {
|
@@ -1228,7 +1287,7 @@ class TeamsBotSsoPrompt extends botbuilderDialogs.Dialog {
|
|
1228
1287
|
*/
|
1229
1288
|
beginDialog(dc) {
|
1230
1289
|
var _a;
|
1231
|
-
return
|
1290
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1232
1291
|
internalLogger.info("Begin Teams Bot SSO Prompt");
|
1233
1292
|
this.ensureMsTeamsChannel(dc);
|
1234
1293
|
// Initialize prompt state
|
@@ -1277,7 +1336,7 @@ class TeamsBotSsoPrompt extends botbuilderDialogs.Dialog {
|
|
1277
1336
|
*/
|
1278
1337
|
continueDialog(dc) {
|
1279
1338
|
var _a;
|
1280
|
-
return
|
1339
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1281
1340
|
internalLogger.info("Continue Teams Bot SSO Prompt");
|
1282
1341
|
this.ensureMsTeamsChannel(dc);
|
1283
1342
|
// Check for timeout
|
@@ -1370,7 +1429,7 @@ class TeamsBotSsoPrompt extends botbuilderDialogs.Dialog {
|
|
1370
1429
|
* @internal
|
1371
1430
|
*/
|
1372
1431
|
sendOAuthCardAsync(context) {
|
1373
|
-
return
|
1432
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1374
1433
|
internalLogger.verbose("Send OAuth card to get SSO token");
|
1375
1434
|
const account = yield botbuilder.TeamsInfo.getMember(context, context.activity.from.id);
|
1376
1435
|
internalLogger.verbose("Get Teams member account user principal name: " +
|
@@ -1407,7 +1466,7 @@ class TeamsBotSsoPrompt extends botbuilderDialogs.Dialog {
|
|
1407
1466
|
* @internal
|
1408
1467
|
*/
|
1409
1468
|
recognizeToken(dc) {
|
1410
|
-
return
|
1469
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1411
1470
|
const context = dc.context;
|
1412
1471
|
let tokenResponse;
|
1413
1472
|
if (this.isTokenExchangeRequestInvoke(context)) {
|
@@ -1504,7 +1563,7 @@ function createApiClient(apiEndpoint, authProvider) {
|
|
1504
1563
|
baseURL: apiEndpoint,
|
1505
1564
|
});
|
1506
1565
|
instance.interceptors.request.use(function (config) {
|
1507
|
-
return
|
1566
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1508
1567
|
return yield authProvider.AddAuthenticationInfo(config);
|
1509
1568
|
});
|
1510
1569
|
});
|
@@ -1533,7 +1592,7 @@ class BearerTokenAuthProvider {
|
|
1533
1592
|
* @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header already exists in request configuration.
|
1534
1593
|
*/
|
1535
1594
|
AddAuthenticationInfo(config) {
|
1536
|
-
return
|
1595
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1537
1596
|
const token = yield this.getToken();
|
1538
1597
|
if (!config.headers) {
|
1539
1598
|
config.headers = {};
|
@@ -1787,6 +1846,8 @@ const ReservedKey = new Set([
|
|
1787
1846
|
]);
|
1788
1847
|
/**
|
1789
1848
|
* A class providing credential and configuration.
|
1849
|
+
* @deprecated Please use {@link TeamsUserCredential}
|
1850
|
+
* in browser environment and {@link OnBehalfOfUserCredential} or {@link AppCredential} in NodeJS.
|
1790
1851
|
*/
|
1791
1852
|
class TeamsFx {
|
1792
1853
|
/**
|
@@ -1850,7 +1911,7 @@ class TeamsFx {
|
|
1850
1911
|
* @returns UserInfo object.
|
1851
1912
|
*/
|
1852
1913
|
getUserInfo(resources) {
|
1853
|
-
return
|
1914
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1854
1915
|
if (this.identityType !== exports.IdentityType.User) {
|
1855
1916
|
const errorMsg = formatString(ErrorMessage.IdentityTypeNotSupported, this.identityType.toString(), "TeamsFx");
|
1856
1917
|
internalLogger.error(errorMsg);
|
@@ -1881,7 +1942,7 @@ class TeamsFx {
|
|
1881
1942
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
1882
1943
|
*/
|
1883
1944
|
login(scopes, resources) {
|
1884
|
-
return
|
1945
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1885
1946
|
throw new ErrorWithCode(formatString(ErrorMessage.NodejsRuntimeNotSupported, "login"), exports.ErrorCode.RuntimeNotSupported);
|
1886
1947
|
});
|
1887
1948
|
}
|
@@ -2020,6 +2081,7 @@ exports.InvokeResponseErrorCode = void 0;
|
|
2020
2081
|
InvokeResponseErrorCode[InvokeResponseErrorCode["InternalServerError"] = 500] = "InternalServerError";
|
2021
2082
|
})(exports.InvokeResponseErrorCode || (exports.InvokeResponseErrorCode = {}));
|
2022
2083
|
|
2084
|
+
// Copyright (c) Microsoft Corporation.
|
2023
2085
|
/**
|
2024
2086
|
* Available response type for an adaptive card invoke response.
|
2025
2087
|
* @internal
|
@@ -2034,7 +2096,7 @@ var InvokeResponseType;
|
|
2034
2096
|
* Provides methods for formatting various invoke responses a bot can send to respond to an invoke request.
|
2035
2097
|
*
|
2036
2098
|
* @remarks
|
2037
|
-
* All of these functions return an
|
2099
|
+
* All of these functions return an `InvokeResponse` object, which can be
|
2038
2100
|
* passed as input to generate a new `invokeResponse` activity.
|
2039
2101
|
*
|
2040
2102
|
* This example sends an invoke response that contains an adaptive card.
|
@@ -2160,7 +2222,7 @@ class CardActionMiddleware {
|
|
2160
2222
|
}
|
2161
2223
|
onTurn(context, next) {
|
2162
2224
|
var _a, _b, _c;
|
2163
|
-
return
|
2225
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2164
2226
|
if (context.activity.name === "adaptiveCard/action") {
|
2165
2227
|
const action = context.activity.value.action;
|
2166
2228
|
const actionVerb = action.verb;
|
@@ -2217,7 +2279,7 @@ class CardActionMiddleware {
|
|
2217
2279
|
});
|
2218
2280
|
}
|
2219
2281
|
sendInvokeResponse(context, response) {
|
2220
|
-
return
|
2282
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2221
2283
|
yield context.sendActivity({
|
2222
2284
|
type: botbuilder.ActivityTypes.InvokeResponse,
|
2223
2285
|
value: response,
|
@@ -2286,7 +2348,7 @@ class CommandResponseMiddleware {
|
|
2286
2348
|
}
|
2287
2349
|
addSsoCommand(ssoHandler) {
|
2288
2350
|
var _a;
|
2289
|
-
(_a = this.ssoActivityHandler) === null || _a === void 0 ? void 0 : _a.addCommand((context, tokenResponse, message) =>
|
2351
|
+
(_a = this.ssoActivityHandler) === null || _a === void 0 ? void 0 : _a.addCommand((context, tokenResponse, message) => __awaiter(this, void 0, void 0, function* () {
|
2290
2352
|
const matchResult = this.shouldTrigger(ssoHandler.triggerPatterns, message.text);
|
2291
2353
|
message.matches = Array.isArray(matchResult) ? matchResult : void 0;
|
2292
2354
|
const response = yield ssoHandler.handleCommandReceived(context, message, tokenResponse);
|
@@ -2297,7 +2359,7 @@ class CommandResponseMiddleware {
|
|
2297
2359
|
}
|
2298
2360
|
onTurn(context, next) {
|
2299
2361
|
var _a, _b;
|
2300
|
-
return
|
2362
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2301
2363
|
if (context.activity.type === botbuilder.ActivityTypes.Message) {
|
2302
2364
|
// Invoke corresponding command handler for the command response
|
2303
2365
|
const commandText = this.getActivityText(context.activity);
|
@@ -2336,7 +2398,7 @@ class CommandResponseMiddleware {
|
|
2336
2398
|
});
|
2337
2399
|
}
|
2338
2400
|
processResponse(context, response) {
|
2339
|
-
return
|
2401
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2340
2402
|
if (typeof response === "string") {
|
2341
2403
|
yield context.sendActivity(response);
|
2342
2404
|
}
|
@@ -2467,6 +2529,7 @@ function cloneConversation(conversation) {
|
|
2467
2529
|
*/
|
2468
2530
|
function getKey(reference) {
|
2469
2531
|
var _a, _b;
|
2532
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
2470
2533
|
return `_${(_a = reference.conversation) === null || _a === void 0 ? void 0 : _a.tenantId}_${(_b = reference.conversation) === null || _b === void 0 ? void 0 : _b.id}`;
|
2471
2534
|
}
|
2472
2535
|
/**
|
@@ -2526,7 +2589,7 @@ class NotificationMiddleware {
|
|
2526
2589
|
this.conversationReferenceStore = options.conversationReferenceStore;
|
2527
2590
|
}
|
2528
2591
|
onTurn(context, next) {
|
2529
|
-
return
|
2592
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2530
2593
|
const type = this.classifyActivity(context.activity);
|
2531
2594
|
switch (type) {
|
2532
2595
|
case ActivityType.CurrentBotInstalled:
|
@@ -2579,7 +2642,7 @@ class NotificationMiddleware {
|
|
2579
2642
|
}
|
2580
2643
|
tryAddMessagedReference(context) {
|
2581
2644
|
var _a, _b, _c, _d;
|
2582
|
-
return
|
2645
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2583
2646
|
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
2584
2647
|
const conversationType = (_a = reference === null || reference === void 0 ? void 0 : reference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
|
2585
2648
|
if (conversationType === "personal" || conversationType === "groupChat") {
|
@@ -2609,7 +2672,7 @@ class LocalFileStorage {
|
|
2609
2672
|
this.filePath = path__namespace.resolve(fileDir, this.localFileName);
|
2610
2673
|
}
|
2611
2674
|
read(key) {
|
2612
|
-
return
|
2675
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2613
2676
|
if (!(yield this.storeFileExists())) {
|
2614
2677
|
return undefined;
|
2615
2678
|
}
|
@@ -2618,7 +2681,7 @@ class LocalFileStorage {
|
|
2618
2681
|
});
|
2619
2682
|
}
|
2620
2683
|
list() {
|
2621
|
-
return
|
2684
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2622
2685
|
if (!(yield this.storeFileExists())) {
|
2623
2686
|
return [];
|
2624
2687
|
}
|
@@ -2627,7 +2690,7 @@ class LocalFileStorage {
|
|
2627
2690
|
});
|
2628
2691
|
}
|
2629
2692
|
write(key, object) {
|
2630
|
-
return
|
2693
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2631
2694
|
if (!(yield this.storeFileExists())) {
|
2632
2695
|
yield this.writeToFile({ [key]: object });
|
2633
2696
|
return;
|
@@ -2637,7 +2700,7 @@ class LocalFileStorage {
|
|
2637
2700
|
});
|
2638
2701
|
}
|
2639
2702
|
delete(key) {
|
2640
|
-
return
|
2703
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2641
2704
|
if (yield this.storeFileExists()) {
|
2642
2705
|
const data = yield this.readFromFile();
|
2643
2706
|
if (data[key] !== undefined) {
|
@@ -2682,7 +2745,7 @@ class LocalFileStorage {
|
|
2682
2745
|
});
|
2683
2746
|
}
|
2684
2747
|
writeToFile(data) {
|
2685
|
-
return
|
2748
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2686
2749
|
return new Promise((resolve, reject) => {
|
2687
2750
|
try {
|
2688
2751
|
const rawData = JSON.stringify(data, undefined, 2);
|
@@ -2710,7 +2773,7 @@ class DefaultConversationReferenceStore {
|
|
2710
2773
|
this.storage = storage;
|
2711
2774
|
}
|
2712
2775
|
add(key, reference, options) {
|
2713
|
-
return
|
2776
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2714
2777
|
if (options.overwrite) {
|
2715
2778
|
yield this.storage.write(key, reference);
|
2716
2779
|
return true;
|
@@ -2724,7 +2787,7 @@ class DefaultConversationReferenceStore {
|
|
2724
2787
|
});
|
2725
2788
|
}
|
2726
2789
|
remove(key, reference) {
|
2727
|
-
return
|
2790
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2728
2791
|
const ref = yield this.storage.read(key);
|
2729
2792
|
if (ref === undefined) {
|
2730
2793
|
return false;
|
@@ -2734,7 +2797,7 @@ class DefaultConversationReferenceStore {
|
|
2734
2797
|
});
|
2735
2798
|
}
|
2736
2799
|
list(pageSize, continuationToken) {
|
2737
|
-
return
|
2800
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2738
2801
|
const data = yield this.storage.list();
|
2739
2802
|
return {
|
2740
2803
|
data,
|
@@ -2802,11 +2865,11 @@ class Channel$1 {
|
|
2802
2865
|
* @returns the response of sending message.
|
2803
2866
|
*/
|
2804
2867
|
sendMessage(text, onError) {
|
2805
|
-
return
|
2868
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2806
2869
|
const response = {};
|
2807
|
-
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) =>
|
2870
|
+
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
2808
2871
|
const conversation = this.newConversation(context);
|
2809
|
-
yield this.parent.adapter.continueConversation(conversation, (ctx) =>
|
2872
|
+
yield this.parent.adapter.continueConversation(conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
2810
2873
|
try {
|
2811
2874
|
const res = yield ctx.sendActivity(text);
|
2812
2875
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -2833,11 +2896,11 @@ class Channel$1 {
|
|
2833
2896
|
* @returns the response of sending adaptive card message.
|
2834
2897
|
*/
|
2835
2898
|
sendAdaptiveCard(card, onError) {
|
2836
|
-
return
|
2899
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2837
2900
|
const response = {};
|
2838
|
-
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) =>
|
2901
|
+
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
2839
2902
|
const conversation = this.newConversation(context);
|
2840
|
-
yield this.parent.adapter.continueConversation(conversation, (ctx) =>
|
2903
|
+
yield this.parent.adapter.continueConversation(conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
2841
2904
|
try {
|
2842
2905
|
const res = yield ctx.sendActivity({
|
2843
2906
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -2900,11 +2963,11 @@ class Member$1 {
|
|
2900
2963
|
* @returns the response of sending message.
|
2901
2964
|
*/
|
2902
2965
|
sendMessage(text, onError) {
|
2903
|
-
return
|
2966
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2904
2967
|
const response = {};
|
2905
|
-
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) =>
|
2968
|
+
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
2906
2969
|
const conversation = yield this.newConversation(context);
|
2907
|
-
yield this.parent.adapter.continueConversation(conversation, (ctx) =>
|
2970
|
+
yield this.parent.adapter.continueConversation(conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
2908
2971
|
try {
|
2909
2972
|
const res = yield ctx.sendActivity(text);
|
2910
2973
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -2931,11 +2994,11 @@ class Member$1 {
|
|
2931
2994
|
* @returns the response of sending adaptive card message.
|
2932
2995
|
*/
|
2933
2996
|
sendAdaptiveCard(card, onError) {
|
2934
|
-
return
|
2997
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2935
2998
|
const response = {};
|
2936
|
-
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) =>
|
2999
|
+
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
2937
3000
|
const conversation = yield this.newConversation(context);
|
2938
|
-
yield this.parent.adapter.continueConversation(conversation, (ctx) =>
|
3001
|
+
yield this.parent.adapter.continueConversation(conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
2939
3002
|
try {
|
2940
3003
|
const res = yield ctx.sendActivity({
|
2941
3004
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -2959,7 +3022,7 @@ class Member$1 {
|
|
2959
3022
|
* @internal
|
2960
3023
|
*/
|
2961
3024
|
newConversation(context) {
|
2962
|
-
return
|
3025
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2963
3026
|
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
2964
3027
|
const personalConversation = cloneConversation(reference);
|
2965
3028
|
const connectorClient = context.turnState.get(this.parent.adapter.ConnectorClientKey);
|
@@ -3011,9 +3074,9 @@ class TeamsBotInstallation$1 {
|
|
3011
3074
|
* @returns the response of sending message.
|
3012
3075
|
*/
|
3013
3076
|
sendMessage(text, onError) {
|
3014
|
-
return
|
3077
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3015
3078
|
const response = {};
|
3016
|
-
yield this.adapter.continueConversation(this.conversationReference, (context) =>
|
3079
|
+
yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3017
3080
|
try {
|
3018
3081
|
const res = yield context.sendActivity(text);
|
3019
3082
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -3039,9 +3102,9 @@ class TeamsBotInstallation$1 {
|
|
3039
3102
|
* @returns the response of sending adaptive card message.
|
3040
3103
|
*/
|
3041
3104
|
sendAdaptiveCard(card, onError) {
|
3042
|
-
return
|
3105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3043
3106
|
const response = {};
|
3044
|
-
yield this.adapter.continueConversation(this.conversationReference, (context) =>
|
3107
|
+
yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3045
3108
|
try {
|
3046
3109
|
const res = yield context.sendActivity({
|
3047
3110
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -3066,13 +3129,13 @@ class TeamsBotInstallation$1 {
|
|
3066
3129
|
* @returns an array of channels if bot is installed into a team, otherwise returns an empty array.
|
3067
3130
|
*/
|
3068
3131
|
channels() {
|
3069
|
-
return
|
3132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3070
3133
|
const channels = [];
|
3071
3134
|
if (this.type !== exports.NotificationTargetType.Channel) {
|
3072
3135
|
return channels;
|
3073
3136
|
}
|
3074
3137
|
let teamsChannels = [];
|
3075
|
-
yield this.adapter.continueConversation(this.conversationReference, (context) =>
|
3138
|
+
yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3076
3139
|
const teamId = getTeamsBotInstallationId(context);
|
3077
3140
|
if (teamId !== undefined) {
|
3078
3141
|
teamsChannels = yield botbuilder.TeamsInfo.getTeamChannels(context, teamId);
|
@@ -3090,9 +3153,9 @@ class TeamsBotInstallation$1 {
|
|
3090
3153
|
* @returns an array of members from where the bot is installed.
|
3091
3154
|
*/
|
3092
3155
|
members() {
|
3093
|
-
return
|
3156
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3094
3157
|
const members = [];
|
3095
|
-
yield this.adapter.continueConversation(this.conversationReference, (context) =>
|
3158
|
+
yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3096
3159
|
let continuationToken;
|
3097
3160
|
do {
|
3098
3161
|
const pagedMembers = yield botbuilder.TeamsInfo.getPagedMembers(context, undefined, continuationToken);
|
@@ -3111,12 +3174,12 @@ class TeamsBotInstallation$1 {
|
|
3111
3174
|
* @returns the team details if bot is installed into a team, otherwise returns undefined.
|
3112
3175
|
*/
|
3113
3176
|
getTeamDetails() {
|
3114
|
-
return
|
3177
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3115
3178
|
if (this.type !== exports.NotificationTargetType.Channel) {
|
3116
3179
|
return undefined;
|
3117
3180
|
}
|
3118
3181
|
let teamDetails;
|
3119
|
-
yield this.adapter.continueConversation(this.conversationReference, (context) =>
|
3182
|
+
yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3120
3183
|
const teamId = getTeamsBotInstallationId(context);
|
3121
3184
|
if (teamId !== undefined) {
|
3122
3185
|
teamDetails = yield botbuilder.TeamsInfo.getTeamDetails(context, teamId);
|
@@ -3159,7 +3222,7 @@ class NotificationBot$1 {
|
|
3159
3222
|
* @returns - an array of {@link TeamsBotInstallation}.
|
3160
3223
|
*/
|
3161
3224
|
installations() {
|
3162
|
-
return
|
3225
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3163
3226
|
if (this.conversationReferenceStore === undefined || this.adapter === undefined) {
|
3164
3227
|
throw new Error("NotificationBot has not been initialized.");
|
3165
3228
|
}
|
@@ -3168,7 +3231,7 @@ class NotificationBot$1 {
|
|
3168
3231
|
for (const reference of references) {
|
3169
3232
|
// validate connection
|
3170
3233
|
let valid = true;
|
3171
|
-
yield this.adapter.continueConversation(reference, (context) =>
|
3234
|
+
yield this.adapter.continueConversation(reference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3172
3235
|
try {
|
3173
3236
|
// try get member to see if the installation is still valid
|
3174
3237
|
yield botbuilder.TeamsInfo.getPagedMembers(context, 1);
|
@@ -3200,7 +3263,7 @@ class NotificationBot$1 {
|
|
3200
3263
|
* @returns the first {@link Member} where predicate is true, and undefined otherwise.
|
3201
3264
|
*/
|
3202
3265
|
findMember(predicate, scope) {
|
3203
|
-
return
|
3266
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3204
3267
|
for (const target of yield this.installations()) {
|
3205
3268
|
if (this.matchSearchScope(target, scope)) {
|
3206
3269
|
for (const member of yield target.members()) {
|
@@ -3223,7 +3286,7 @@ class NotificationBot$1 {
|
|
3223
3286
|
* @returns the first {@link Channel} where predicate is true, and undefined otherwise.
|
3224
3287
|
*/
|
3225
3288
|
findChannel(predicate) {
|
3226
|
-
return
|
3289
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3227
3290
|
for (const target of yield this.installations()) {
|
3228
3291
|
if (target.type === exports.NotificationTargetType.Channel) {
|
3229
3292
|
const teamDetails = yield target.getTeamDetails();
|
@@ -3246,7 +3309,7 @@ class NotificationBot$1 {
|
|
3246
3309
|
* @returns an array of {@link Member} where predicate is true, and empty array otherwise.
|
3247
3310
|
*/
|
3248
3311
|
findAllMembers(predicate, scope) {
|
3249
|
-
return
|
3312
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3250
3313
|
const members = [];
|
3251
3314
|
for (const target of yield this.installations()) {
|
3252
3315
|
if (this.matchSearchScope(target, scope)) {
|
@@ -3268,7 +3331,7 @@ class NotificationBot$1 {
|
|
3268
3331
|
* @returns an array of {@link Channel} where predicate is true, and empty array otherwise.
|
3269
3332
|
*/
|
3270
3333
|
findAllChannels(predicate) {
|
3271
|
-
return
|
3334
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3272
3335
|
const channels = [];
|
3273
3336
|
for (const target of yield this.installations()) {
|
3274
3337
|
if (target.type === exports.NotificationTargetType.Channel) {
|
@@ -3361,7 +3424,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3361
3424
|
const dialog = new botbuilderDialogs.WaterfallDialog(commandId, [
|
3362
3425
|
this.ssoStep.bind(this),
|
3363
3426
|
this.dedupStep.bind(this),
|
3364
|
-
(stepContext) =>
|
3427
|
+
(stepContext) => __awaiter(this, void 0, void 0, function* () {
|
3365
3428
|
const tokenResponse = stepContext.result.tokenResponse;
|
3366
3429
|
const context = stepContext.context;
|
3367
3430
|
const message = stepContext.result.message;
|
@@ -3398,7 +3461,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3398
3461
|
* @param accessor The instance of StatePropertyAccessor for dialog system.
|
3399
3462
|
*/
|
3400
3463
|
run(context, accessor) {
|
3401
|
-
return
|
3464
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3402
3465
|
const dialogSet = new botbuilderDialogs.DialogSet(accessor);
|
3403
3466
|
dialogSet.add(this);
|
3404
3467
|
const dialogContext = yield dialogSet.createContext(context);
|
@@ -3426,7 +3489,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3426
3489
|
return text;
|
3427
3490
|
}
|
3428
3491
|
commandRouteStep(stepContext) {
|
3429
|
-
return
|
3492
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3430
3493
|
const turnContext = stepContext.context;
|
3431
3494
|
const text = this.getActivityText(turnContext.activity);
|
3432
3495
|
const commandId = this.getMatchesCommandId(text);
|
@@ -3439,7 +3502,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3439
3502
|
});
|
3440
3503
|
}
|
3441
3504
|
ssoStep(stepContext) {
|
3442
|
-
return
|
3505
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3443
3506
|
try {
|
3444
3507
|
const turnContext = stepContext.context;
|
3445
3508
|
const text = this.getActivityText(turnContext.activity);
|
@@ -3457,7 +3520,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3457
3520
|
});
|
3458
3521
|
}
|
3459
3522
|
dedupStep(stepContext) {
|
3460
|
-
return
|
3523
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3461
3524
|
const tokenResponse = stepContext.result;
|
3462
3525
|
if (!tokenResponse) {
|
3463
3526
|
internalLogger.error(ErrorMessage.FailedToRetrieveSsoToken);
|
@@ -3486,7 +3549,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3486
3549
|
* @param context Context for the current turn of conversation.
|
3487
3550
|
*/
|
3488
3551
|
onEndDialog(context) {
|
3489
|
-
return
|
3552
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3490
3553
|
const conversationId = context.activity.conversation.id;
|
3491
3554
|
const currentDedupKeys = this.dedupStorageKeys.filter((key) => key.indexOf(conversationId) > 0);
|
3492
3555
|
yield this.dedupStorage.delete(currentDedupKeys);
|
@@ -3502,7 +3565,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3502
3565
|
* @returns boolean value indicate whether the message should be removed
|
3503
3566
|
*/
|
3504
3567
|
shouldDedup(context) {
|
3505
|
-
return
|
3568
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3506
3569
|
const storeItem = {
|
3507
3570
|
eTag: context.activity.value.id,
|
3508
3571
|
};
|
@@ -3602,18 +3665,17 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
|
|
3602
3665
|
const userState = (_b = (_a = ssoConfig.dialog) === null || _a === void 0 ? void 0 : _a.userState) !== null && _b !== void 0 ? _b : new botbuilder.UserState(memoryStorage);
|
3603
3666
|
const conversationState = (_d = (_c = ssoConfig.dialog) === null || _c === void 0 ? void 0 : _c.conversationState) !== null && _d !== void 0 ? _d : new botbuilder.ConversationState(memoryStorage);
|
3604
3667
|
const dedupStorage = (_f = (_e = ssoConfig.dialog) === null || _e === void 0 ? void 0 : _e.dedupStorage) !== null && _f !== void 0 ? _f : memoryStorage;
|
3605
|
-
const _l = ssoConfig.aad, { scopes } = _l, customConfig =
|
3668
|
+
const _l = ssoConfig.aad, { scopes } = _l, customConfig = __rest(_l, ["scopes"]);
|
3606
3669
|
const settings = {
|
3607
3670
|
scopes: scopes,
|
3608
3671
|
timeout: (_h = (_g = ssoConfig.dialog) === null || _g === void 0 ? void 0 : _g.ssoPromptConfig) === null || _h === void 0 ? void 0 : _h.timeout,
|
3609
3672
|
endOnInvalidMessage: (_k = (_j = ssoConfig.dialog) === null || _j === void 0 ? void 0 : _j.ssoPromptConfig) === null || _k === void 0 ? void 0 : _k.endOnInvalidMessage,
|
3610
3673
|
};
|
3611
|
-
|
3612
|
-
this.ssoExecutionDialog = new BotSsoExecutionDialog(dedupStorage, settings, teamsfx);
|
3674
|
+
this.ssoExecutionDialog = new BotSsoExecutionDialog(dedupStorage, settings, customConfig, customConfig.initiateLoginEndpoint);
|
3613
3675
|
this.conversationState = conversationState;
|
3614
3676
|
this.dialogState = conversationState.createProperty("DialogState");
|
3615
3677
|
this.userState = userState;
|
3616
|
-
this.onMessage((context, next) =>
|
3678
|
+
this.onMessage((context, next) => __awaiter(this, void 0, void 0, function* () {
|
3617
3679
|
yield this.ssoExecutionDialog.run(context, this.dialogState);
|
3618
3680
|
yield next();
|
3619
3681
|
}));
|
@@ -3637,7 +3699,7 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
|
|
3637
3699
|
const _super = Object.create(null, {
|
3638
3700
|
run: { get: () => super.run }
|
3639
3701
|
});
|
3640
|
-
return
|
3702
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3641
3703
|
try {
|
3642
3704
|
yield _super.run.call(this, context);
|
3643
3705
|
}
|
@@ -3657,7 +3719,7 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
|
|
3657
3719
|
* It should trigger {@link BotSsoExecutionDialog} instance to handle signin process
|
3658
3720
|
*/
|
3659
3721
|
handleTeamsSigninVerifyState(context, query) {
|
3660
|
-
return
|
3722
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3661
3723
|
yield this.ssoExecutionDialog.run(context, this.dialogState);
|
3662
3724
|
});
|
3663
3725
|
}
|
@@ -3667,11 +3729,11 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
|
|
3667
3729
|
* @param query Signin state (part of signin action auth flow) verification invoke query
|
3668
3730
|
* @returns A promise that represents the work queued.
|
3669
3731
|
*
|
3670
|
-
* @
|
3732
|
+
* @remarks
|
3671
3733
|
* It should trigger {@link BotSsoExecutionDialog} instance to handle signin process
|
3672
3734
|
*/
|
3673
3735
|
handleTeamsSigninTokenExchange(context, query) {
|
3674
|
-
return
|
3736
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3675
3737
|
yield this.ssoExecutionDialog.run(context, this.dialogState);
|
3676
3738
|
});
|
3677
3739
|
}
|
@@ -3777,11 +3839,14 @@ class ConversationBot$1 {
|
|
3777
3839
|
})
|
3778
3840
|
: new botbuilder.BotFrameworkAdapter(adapterConfig);
|
3779
3841
|
// the default error handler
|
3780
|
-
adapter.onTurnError = (context, error) =>
|
3842
|
+
adapter.onTurnError = (context, error) => __awaiter(this, void 0, void 0, function* () {
|
3781
3843
|
// This check writes out errors to console.
|
3844
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
3782
3845
|
console.error(`[onTurnError] unhandled error: ${error}`);
|
3783
3846
|
// Send a trace activity, which will be displayed in Bot Framework Emulator
|
3784
|
-
yield context.sendTraceActivity("OnTurnError Trace",
|
3847
|
+
yield context.sendTraceActivity("OnTurnError Trace",
|
3848
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
3849
|
+
`${error}`, "https://www.botframework.com/schemas/error", "TurnError");
|
3785
3850
|
// Send a message to the user
|
3786
3851
|
yield context.sendActivity(`The bot encountered unhandled error: ${error.message}`);
|
3787
3852
|
yield context.sendActivity("To continue to run this bot, please fix the bot source code.");
|
@@ -3810,10 +3875,10 @@ class ConversationBot$1 {
|
|
3810
3875
|
* ```
|
3811
3876
|
*/
|
3812
3877
|
requestHandler(req, res, logic) {
|
3813
|
-
return
|
3878
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3814
3879
|
if (logic === undefined) {
|
3815
3880
|
// create empty logic
|
3816
|
-
logic = () =>
|
3881
|
+
logic = () => __awaiter(this, void 0, void 0, function* () { });
|
3817
3882
|
}
|
3818
3883
|
yield this.adapter.processActivity(req, res, logic);
|
3819
3884
|
});
|
@@ -4030,7 +4095,7 @@ function getSignInResponseForMessageExtension(teamsfx, scopes) {
|
|
4030
4095
|
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4031
4096
|
*/
|
4032
4097
|
function executionWithTokenAndConfig(context, authConfig, initiateLoginEndpoint, scopes, logic) {
|
4033
|
-
return
|
4098
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4034
4099
|
const valueObj = context.activity.value;
|
4035
4100
|
if (!valueObj.authentication || !valueObj.authentication.token) {
|
4036
4101
|
internalLogger.verbose("No AccessToken in request, return silentAuth for AccessToken");
|
@@ -4064,6 +4129,7 @@ function executionWithTokenAndConfig(context, authConfig, initiateLoginEndpoint,
|
|
4064
4129
|
}
|
4065
4130
|
/**
|
4066
4131
|
* execution in message extension with SSO token.
|
4132
|
+
* @deprecated Use {@link executionWithTokenAndConfig} instead.
|
4067
4133
|
*
|
4068
4134
|
* @param {TurnContext} context - The context object for the current turn.
|
4069
4135
|
* @param {AuthenticationConfiguration} config - User custom the message extension authentication configuration.
|
@@ -4079,7 +4145,7 @@ function executionWithTokenAndConfig(context, authConfig, initiateLoginEndpoint,
|
|
4079
4145
|
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4080
4146
|
*/
|
4081
4147
|
function executionWithToken(context, config, scopes, logic) {
|
4082
|
-
return
|
4148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4083
4149
|
const valueObj = context.activity.value;
|
4084
4150
|
if (!valueObj.authentication || !valueObj.authentication.token) {
|
4085
4151
|
internalLogger.verbose("No AccessToken in request, return silentAuth for AccessToken");
|
@@ -4114,7 +4180,7 @@ function executionWithToken(context, config, scopes, logic) {
|
|
4114
4180
|
// eslint-disable-next-line no-secrets/no-secrets
|
4115
4181
|
/**
|
4116
4182
|
* Users execute query in message extension with SSO or access token.
|
4117
|
-
*
|
4183
|
+
* @deprecated Use {@link handleMessageExtensionQueryWithSSO} instead.
|
4118
4184
|
*
|
4119
4185
|
* @param {TurnContext} context - The context object for the current turn.
|
4120
4186
|
* @param {AuthenticationConfiguration} config - User custom the message extension authentication configuration.
|
@@ -4131,7 +4197,7 @@ function executionWithToken(context, config, scopes, logic) {
|
|
4131
4197
|
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4132
4198
|
*/
|
4133
4199
|
function handleMessageExtensionQueryWithToken(context, config, scopes, logic) {
|
4134
|
-
return
|
4200
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4135
4201
|
if (context.activity.name != "composeExtension/query") {
|
4136
4202
|
internalLogger.error(ErrorMessage.OnlySupportInQueryActivity);
|
4137
4203
|
throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInQueryActivity), exports.ErrorCode.FailedOperation);
|
@@ -4158,7 +4224,7 @@ function handleMessageExtensionQueryWithToken(context, config, scopes, logic) {
|
|
4158
4224
|
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4159
4225
|
*/
|
4160
4226
|
function handleMessageExtensionQueryWithSSO(context, config, initiateLoginEndpoint, scopes, logic) {
|
4161
|
-
return
|
4227
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4162
4228
|
if (context.activity.name != "composeExtension/query") {
|
4163
4229
|
internalLogger.error(ErrorMessage.OnlySupportInQueryActivity);
|
4164
4230
|
throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInQueryActivity), exports.ErrorCode.FailedOperation);
|
@@ -4336,11 +4402,11 @@ class Channel {
|
|
4336
4402
|
* @returns The response of sending message.
|
4337
4403
|
*/
|
4338
4404
|
sendMessage(text, onError) {
|
4339
|
-
return
|
4405
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4340
4406
|
const response = {};
|
4341
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) =>
|
4407
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4342
4408
|
const conversation = yield this.newConversation(context);
|
4343
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) =>
|
4409
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
4344
4410
|
try {
|
4345
4411
|
const res = yield ctx.sendActivity(text);
|
4346
4412
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -4368,11 +4434,11 @@ class Channel {
|
|
4368
4434
|
* @returns The response of sending adaptive card message.
|
4369
4435
|
*/
|
4370
4436
|
sendAdaptiveCard(card, onError) {
|
4371
|
-
return
|
4437
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4372
4438
|
const response = {};
|
4373
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) =>
|
4439
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4374
4440
|
const conversation = yield this.newConversation(context);
|
4375
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) =>
|
4441
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
4376
4442
|
try {
|
4377
4443
|
const res = yield ctx.sendActivity({
|
4378
4444
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -4436,11 +4502,11 @@ class Member {
|
|
4436
4502
|
* @returns The response of sending message.
|
4437
4503
|
*/
|
4438
4504
|
sendMessage(text, onError) {
|
4439
|
-
return
|
4505
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4440
4506
|
const response = {};
|
4441
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) =>
|
4507
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4442
4508
|
const conversation = yield this.newConversation(context);
|
4443
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) =>
|
4509
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
4444
4510
|
try {
|
4445
4511
|
const res = yield ctx.sendActivity(text);
|
4446
4512
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -4468,11 +4534,11 @@ class Member {
|
|
4468
4534
|
* @returns The response of sending adaptive card message.
|
4469
4535
|
*/
|
4470
4536
|
sendAdaptiveCard(card, onError) {
|
4471
|
-
return
|
4537
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4472
4538
|
const response = {};
|
4473
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) =>
|
4539
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4474
4540
|
const conversation = yield this.newConversation(context);
|
4475
|
-
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) =>
|
4541
|
+
yield this.parent.adapter.continueConversationAsync(this.parent.botAppId, conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
4476
4542
|
try {
|
4477
4543
|
const res = yield ctx.sendActivity({
|
4478
4544
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -4496,7 +4562,7 @@ class Member {
|
|
4496
4562
|
* @internal
|
4497
4563
|
*/
|
4498
4564
|
newConversation(context) {
|
4499
|
-
return
|
4565
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4500
4566
|
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
4501
4567
|
const personalConversation = cloneConversation(reference);
|
4502
4568
|
const connectorClient = context.turnState.get(this.parent.adapter.ConnectorClientKey);
|
@@ -4548,9 +4614,9 @@ class TeamsBotInstallation {
|
|
4548
4614
|
* @returns The response of sending message.
|
4549
4615
|
*/
|
4550
4616
|
sendMessage(text, onError) {
|
4551
|
-
return
|
4617
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4552
4618
|
const response = {};
|
4553
|
-
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) =>
|
4619
|
+
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4554
4620
|
try {
|
4555
4621
|
const res = yield context.sendActivity(text);
|
4556
4622
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -4577,9 +4643,9 @@ class TeamsBotInstallation {
|
|
4577
4643
|
* @returns The response of sending adaptive card message.
|
4578
4644
|
*/
|
4579
4645
|
sendAdaptiveCard(card, onError) {
|
4580
|
-
return
|
4646
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4581
4647
|
const response = {};
|
4582
|
-
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) =>
|
4648
|
+
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4583
4649
|
try {
|
4584
4650
|
const res = yield context.sendActivity({
|
4585
4651
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -4604,13 +4670,13 @@ class TeamsBotInstallation {
|
|
4604
4670
|
* @returns An array of channels if bot is installed into a team, otherwise returns an empty array.
|
4605
4671
|
*/
|
4606
4672
|
channels() {
|
4607
|
-
return
|
4673
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4608
4674
|
const channels = [];
|
4609
4675
|
if (this.type !== exports.NotificationTargetType.Channel) {
|
4610
4676
|
return channels;
|
4611
4677
|
}
|
4612
4678
|
let teamsChannels = [];
|
4613
|
-
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) =>
|
4679
|
+
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4614
4680
|
const teamId = getTeamsBotInstallationId(context);
|
4615
4681
|
if (teamId !== undefined) {
|
4616
4682
|
teamsChannels = yield botbuilder.TeamsInfo.getTeamChannels(context, teamId);
|
@@ -4630,12 +4696,12 @@ class TeamsBotInstallation {
|
|
4630
4696
|
* @returns An array of members from where the bot is installed.
|
4631
4697
|
*/
|
4632
4698
|
getPagedMembers(pageSize, continuationToken) {
|
4633
|
-
return
|
4699
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4634
4700
|
let result = {
|
4635
4701
|
data: [],
|
4636
4702
|
continuationToken: "",
|
4637
4703
|
};
|
4638
|
-
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) =>
|
4704
|
+
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4639
4705
|
const pagedMembers = yield botbuilder.TeamsInfo.getPagedMembers(context, pageSize, continuationToken);
|
4640
4706
|
result = {
|
4641
4707
|
data: pagedMembers.members.map((m) => new Member(this, m)),
|
@@ -4653,7 +4719,7 @@ class TeamsBotInstallation {
|
|
4653
4719
|
* @deprecated Use `getPagedMembers` instead.
|
4654
4720
|
*/
|
4655
4721
|
members() {
|
4656
|
-
return
|
4722
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4657
4723
|
const members = [];
|
4658
4724
|
let continuationToken;
|
4659
4725
|
do {
|
@@ -4670,12 +4736,12 @@ class TeamsBotInstallation {
|
|
4670
4736
|
* @returns The team details if bot is installed into a team, otherwise returns `undefined`.
|
4671
4737
|
*/
|
4672
4738
|
getTeamDetails() {
|
4673
|
-
return
|
4739
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4674
4740
|
if (this.type !== exports.NotificationTargetType.Channel) {
|
4675
4741
|
return undefined;
|
4676
4742
|
}
|
4677
4743
|
let teamDetails;
|
4678
|
-
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) =>
|
4744
|
+
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4679
4745
|
const teamId = getTeamsBotInstallationId(context);
|
4680
4746
|
if (teamId !== undefined) {
|
4681
4747
|
teamDetails = yield botbuilder.TeamsInfo.getTeamDetails(context, teamId);
|
@@ -4731,9 +4797,9 @@ class NotificationBot {
|
|
4731
4797
|
* @returns Returns false if recieves `BotNotInConversationRoster` error, otherwise returns true.
|
4732
4798
|
*/
|
4733
4799
|
validateInstallation(conversationReference) {
|
4734
|
-
return
|
4800
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4735
4801
|
let isValid = true;
|
4736
|
-
yield this.adapter.continueConversationAsync(this.botAppId, conversationReference, (context) =>
|
4802
|
+
yield this.adapter.continueConversationAsync(this.botAppId, conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4737
4803
|
try {
|
4738
4804
|
// try get member to see if the installation is still valid
|
4739
4805
|
yield botbuilder.TeamsInfo.getPagedMembers(context, 1);
|
@@ -4759,7 +4825,7 @@ class NotificationBot {
|
|
4759
4825
|
* @returns An array of {@link TeamsBotInstallation} with paged data and continuation token.
|
4760
4826
|
*/
|
4761
4827
|
getPagedInstallations(pageSize, continuationToken, validationEnabled = true) {
|
4762
|
-
return
|
4828
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4763
4829
|
if (this.conversationReferenceStore === undefined || this.adapter === undefined) {
|
4764
4830
|
throw new Error("NotificationBot has not been initialized.");
|
4765
4831
|
}
|
@@ -4796,7 +4862,7 @@ class NotificationBot {
|
|
4796
4862
|
* @deprecated Use getPagedInstallations instead.
|
4797
4863
|
*/
|
4798
4864
|
installations() {
|
4799
|
-
return
|
4865
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4800
4866
|
let continuationToken;
|
4801
4867
|
const targets = [];
|
4802
4868
|
do {
|
@@ -4819,7 +4885,7 @@ class NotificationBot {
|
|
4819
4885
|
* @returns The first {@link Member} where predicate is true, and `undefined` otherwise.
|
4820
4886
|
*/
|
4821
4887
|
findMember(predicate, scope) {
|
4822
|
-
return
|
4888
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4823
4889
|
for (const target of yield this.installations()) {
|
4824
4890
|
if (this.matchSearchScope(target, scope)) {
|
4825
4891
|
for (const member of yield target.members()) {
|
@@ -4843,7 +4909,7 @@ class NotificationBot {
|
|
4843
4909
|
* @returns The first {@link Channel} where predicate is true, and `undefined` otherwise.
|
4844
4910
|
*/
|
4845
4911
|
findChannel(predicate) {
|
4846
|
-
return
|
4912
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4847
4913
|
for (const target of yield this.installations()) {
|
4848
4914
|
if (target.type === exports.NotificationTargetType.Channel) {
|
4849
4915
|
const teamDetails = yield target.getTeamDetails();
|
@@ -4867,7 +4933,7 @@ class NotificationBot {
|
|
4867
4933
|
* @returns An array of {@link Member} where predicate is true, and empty array otherwise.
|
4868
4934
|
*/
|
4869
4935
|
findAllMembers(predicate, scope) {
|
4870
|
-
return
|
4936
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4871
4937
|
const members = [];
|
4872
4938
|
for (const target of yield this.installations()) {
|
4873
4939
|
if (this.matchSearchScope(target, scope)) {
|
@@ -4890,7 +4956,7 @@ class NotificationBot {
|
|
4890
4956
|
* @returns An array of {@link Channel} where predicate is true, and empty array otherwise.
|
4891
4957
|
*/
|
4892
4958
|
findAllChannels(predicate) {
|
4893
|
-
return
|
4959
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4894
4960
|
const channels = [];
|
4895
4961
|
for (const target of yield this.installations()) {
|
4896
4962
|
if (target.type === exports.NotificationTargetType.Channel) {
|
@@ -5043,7 +5109,7 @@ class ConversationBot {
|
|
5043
5109
|
const botFrameworkAuthentication = new botbuilder.ConfigurationBotFrameworkAuthentication({}, credentialsFactory);
|
5044
5110
|
const adapter = new botbuilder.CloudAdapter(botFrameworkAuthentication);
|
5045
5111
|
// the default error handler
|
5046
|
-
adapter.onTurnError = (context, error) =>
|
5112
|
+
adapter.onTurnError = (context, error) => __awaiter(this, void 0, void 0, function* () {
|
5047
5113
|
// This check writes out errors to console.
|
5048
5114
|
console.error(`[onTurnError] unhandled error`, error);
|
5049
5115
|
// Send a trace activity, which will be displayed in Bot Framework Emulator
|
@@ -5078,10 +5144,10 @@ class ConversationBot {
|
|
5078
5144
|
* ```
|
5079
5145
|
*/
|
5080
5146
|
requestHandler(req, res, logic) {
|
5081
|
-
return
|
5147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
5082
5148
|
if (logic === undefined) {
|
5083
5149
|
// create empty logic
|
5084
|
-
logic = () =>
|
5150
|
+
logic = () => __awaiter(this, void 0, void 0, function* () { });
|
5085
5151
|
}
|
5086
5152
|
yield this.adapter.process(req, res, logic);
|
5087
5153
|
});
|