@microsoft/teamsfx 2.2.3-alpha.9b38c38b5.0 → 2.2.3-alpha.a0d5ed36e.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 +84 -62
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +120 -48
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +95 -108
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +281 -211
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +26 -10
- package/types/teamsfx.d.ts +35 -5
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
|
/**
|
@@ -425,6 +466,7 @@ function getAuthority(authorityHost, tenantId) {
|
|
425
466
|
return normalizedAuthorityHost + "/" + tenantId;
|
426
467
|
}
|
427
468
|
|
469
|
+
// Copyright (c) Microsoft Corporation.
|
428
470
|
/**
|
429
471
|
* @internal
|
430
472
|
*/
|
@@ -513,7 +555,7 @@ class AppCredential {
|
|
513
555
|
* Throw error if get access token failed.
|
514
556
|
*/
|
515
557
|
getToken(scopes, options) {
|
516
|
-
return
|
558
|
+
return __awaiter(this, void 0, void 0, function* () {
|
517
559
|
let accessToken;
|
518
560
|
validateScopesType(scopes);
|
519
561
|
const scopesStr = typeof scopes === "string" ? scopes : scopes.join(" ");
|
@@ -651,7 +693,7 @@ class OnBehalfOfUserCredential {
|
|
651
693
|
* If scopes is non-empty, it returns access token for target scope.
|
652
694
|
*/
|
653
695
|
getToken(scopes, options) {
|
654
|
-
return
|
696
|
+
return __awaiter(this, void 0, void 0, function* () {
|
655
697
|
validateScopesType(scopes);
|
656
698
|
const scopesArray = getScopesArray(scopes);
|
657
699
|
let result;
|
@@ -747,9 +789,7 @@ class TeamsUserCredential {
|
|
747
789
|
* Can only be used within Teams.
|
748
790
|
*/
|
749
791
|
login(scopes, resources) {
|
750
|
-
return
|
751
|
-
throw new ErrorWithCode(formatString(ErrorMessage.NodejsRuntimeNotSupported, "TeamsUserCredential"), exports.ErrorCode.RuntimeNotSupported);
|
752
|
-
});
|
792
|
+
return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.NodejsRuntimeNotSupported, "TeamsUserCredential"), exports.ErrorCode.RuntimeNotSupported));
|
753
793
|
}
|
754
794
|
/**
|
755
795
|
* Get access token from credential.
|
@@ -757,9 +797,7 @@ class TeamsUserCredential {
|
|
757
797
|
* Can only be used within Teams.
|
758
798
|
*/
|
759
799
|
getToken(scopes, options) {
|
760
|
-
return
|
761
|
-
throw new ErrorWithCode(formatString(ErrorMessage.NodejsRuntimeNotSupported, "TeamsUserCredential"), exports.ErrorCode.RuntimeNotSupported);
|
762
|
-
});
|
800
|
+
return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.NodejsRuntimeNotSupported, "TeamsUserCredential"), exports.ErrorCode.RuntimeNotSupported));
|
763
801
|
}
|
764
802
|
/**
|
765
803
|
* Get basic user info from SSO token
|
@@ -770,14 +808,16 @@ class TeamsUserCredential {
|
|
770
808
|
* Can only be used within Teams.
|
771
809
|
*/
|
772
810
|
getUserInfo(resources) {
|
773
|
-
|
811
|
+
return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.NodejsRuntimeNotSupported, "TeamsUserCredential"), exports.ErrorCode.RuntimeNotSupported));
|
774
812
|
}
|
775
813
|
}
|
776
814
|
|
777
815
|
// Copyright (c) Microsoft Corporation.
|
778
816
|
const defaultScope = "https://graph.microsoft.com/.default";
|
817
|
+
// eslint-disable-next-line no-secrets/no-secrets
|
779
818
|
/**
|
780
819
|
* Microsoft Graph auth provider for Teams Framework
|
820
|
+
* @deprecated Use `TokenCredentialAuthenticationProvider` from `@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials` instead.
|
781
821
|
*/
|
782
822
|
class MsGraphAuthProvider {
|
783
823
|
constructor(credentialOrTeamsFx, scopes) {
|
@@ -806,8 +846,8 @@ class MsGraphAuthProvider {
|
|
806
846
|
*
|
807
847
|
*/
|
808
848
|
getAccessToken() {
|
809
|
-
return
|
810
|
-
internalLogger.info(`Get Graph Access token with scopes: '${this.scopes}'`);
|
849
|
+
return __awaiter(this, void 0, void 0, function* () {
|
850
|
+
internalLogger.info(`Get Graph Access token with scopes: '${this.scopes.toString()}'`);
|
811
851
|
let accessToken;
|
812
852
|
if (this.credentialOrTeamsFx.getCredential) {
|
813
853
|
accessToken = yield this.credentialOrTeamsFx
|
@@ -834,6 +874,14 @@ class MsGraphAuthProvider {
|
|
834
874
|
// Copyright (c) Microsoft Corporation.
|
835
875
|
/**
|
836
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
|
+
*
|
837
885
|
* @example
|
838
886
|
* Get Microsoft graph client by TokenCredential
|
839
887
|
* ```typescript
|
@@ -891,6 +939,14 @@ function createMicrosoftGraphClient(teamsfx, scopes) {
|
|
891
939
|
// eslint-disable-next-line no-secrets/no-secrets
|
892
940
|
/**
|
893
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
|
+
*
|
894
950
|
* @example
|
895
951
|
* Get Microsoft graph client by TokenCredential
|
896
952
|
* ```typescript
|
@@ -970,7 +1026,7 @@ const defaultSQLScope = "https://database.windows.net/";
|
|
970
1026
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
971
1027
|
*/
|
972
1028
|
function getTediousConnectionConfig(teamsfx, databaseName) {
|
973
|
-
return
|
1029
|
+
return __awaiter(this, void 0, void 0, function* () {
|
974
1030
|
internalLogger.info("Get SQL configuration");
|
975
1031
|
try {
|
976
1032
|
isSQLConfigurationValid(teamsfx);
|
@@ -1048,7 +1104,7 @@ function isMsiAuthentication(teamsfx) {
|
|
1048
1104
|
function generateDefaultConfig(teamsfx, databaseName) {
|
1049
1105
|
internalLogger.verbose(`SQL server ${teamsfx.getConfig("sqlServerEndpoint")}
|
1050
1106
|
, user name ${teamsfx.getConfig("sqlUsername")}
|
1051
|
-
, database name ${databaseName}`);
|
1107
|
+
, database name ${databaseName ? databaseName : ""}`);
|
1052
1108
|
const config = {
|
1053
1109
|
server: teamsfx.getConfig("sqlServerEndpoint"),
|
1054
1110
|
authentication: {
|
@@ -1074,7 +1130,7 @@ function generateDefaultConfig(teamsfx, databaseName) {
|
|
1074
1130
|
* @internal
|
1075
1131
|
*/
|
1076
1132
|
function generateTokenConfig(teamsfx, databaseName) {
|
1077
|
-
return
|
1133
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1078
1134
|
internalLogger.verbose("Generate tedious config with MSI token");
|
1079
1135
|
let token;
|
1080
1136
|
try {
|
@@ -1102,7 +1158,7 @@ function generateTokenConfig(teamsfx, databaseName) {
|
|
1102
1158
|
};
|
1103
1159
|
internalLogger.verbose(`Generate token configuration success
|
1104
1160
|
, server endpoint is ${teamsfx.getConfig("sqlServerEndpoint")}
|
1105
|
-
, database name is ${databaseName}`);
|
1161
|
+
, database name is ${databaseName ? databaseName : ""}`);
|
1106
1162
|
return config;
|
1107
1163
|
}
|
1108
1164
|
internalLogger.error(`Generate token configuration
|
@@ -1231,7 +1287,7 @@ class TeamsBotSsoPrompt extends botbuilderDialogs.Dialog {
|
|
1231
1287
|
*/
|
1232
1288
|
beginDialog(dc) {
|
1233
1289
|
var _a;
|
1234
|
-
return
|
1290
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1235
1291
|
internalLogger.info("Begin Teams Bot SSO Prompt");
|
1236
1292
|
this.ensureMsTeamsChannel(dc);
|
1237
1293
|
// Initialize prompt state
|
@@ -1280,7 +1336,7 @@ class TeamsBotSsoPrompt extends botbuilderDialogs.Dialog {
|
|
1280
1336
|
*/
|
1281
1337
|
continueDialog(dc) {
|
1282
1338
|
var _a;
|
1283
|
-
return
|
1339
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1284
1340
|
internalLogger.info("Continue Teams Bot SSO Prompt");
|
1285
1341
|
this.ensureMsTeamsChannel(dc);
|
1286
1342
|
// Check for timeout
|
@@ -1373,10 +1429,11 @@ class TeamsBotSsoPrompt extends botbuilderDialogs.Dialog {
|
|
1373
1429
|
* @internal
|
1374
1430
|
*/
|
1375
1431
|
sendOAuthCardAsync(context) {
|
1376
|
-
return
|
1432
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1377
1433
|
internalLogger.verbose("Send OAuth card to get SSO token");
|
1378
1434
|
const account = yield botbuilder.TeamsInfo.getMember(context, context.activity.from.id);
|
1379
|
-
internalLogger.verbose("Get Teams member account user principal name: " +
|
1435
|
+
internalLogger.verbose("Get Teams member account user principal name: " +
|
1436
|
+
(account.userPrincipalName ? account.userPrincipalName : ""));
|
1380
1437
|
const loginHint = account.userPrincipalName ? account.userPrincipalName : "";
|
1381
1438
|
const signInResource = this.getSignInResource(loginHint);
|
1382
1439
|
const card = botbuilder.CardFactory.oauthCard("", "Teams SSO Sign In", "Sign In", signInResource.signInLink, signInResource.tokenExchangeResource);
|
@@ -1409,7 +1466,7 @@ class TeamsBotSsoPrompt extends botbuilderDialogs.Dialog {
|
|
1409
1466
|
* @internal
|
1410
1467
|
*/
|
1411
1468
|
recognizeToken(dc) {
|
1412
|
-
return
|
1469
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1413
1470
|
const context = dc.context;
|
1414
1471
|
let tokenResponse;
|
1415
1472
|
if (this.isTokenExchangeRequestInvoke(context)) {
|
@@ -1506,7 +1563,7 @@ function createApiClient(apiEndpoint, authProvider) {
|
|
1506
1563
|
baseURL: apiEndpoint,
|
1507
1564
|
});
|
1508
1565
|
instance.interceptors.request.use(function (config) {
|
1509
|
-
return
|
1566
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1510
1567
|
return yield authProvider.AddAuthenticationInfo(config);
|
1511
1568
|
});
|
1512
1569
|
});
|
@@ -1535,7 +1592,7 @@ class BearerTokenAuthProvider {
|
|
1535
1592
|
* @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header already exists in request configuration.
|
1536
1593
|
*/
|
1537
1594
|
AddAuthenticationInfo(config) {
|
1538
|
-
return
|
1595
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1539
1596
|
const token = yield this.getToken();
|
1540
1597
|
if (!config.headers) {
|
1541
1598
|
config.headers = {};
|
@@ -1584,19 +1641,17 @@ class BasicAuthProvider {
|
|
1584
1641
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
1585
1642
|
*/
|
1586
1643
|
AddAuthenticationInfo(config) {
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
return config;
|
1599
|
-
});
|
1644
|
+
if (config.headers && config.headers["Authorization"]) {
|
1645
|
+
return Promise.reject(new ErrorWithCode(ErrorMessage.AuthorizationHeaderAlreadyExists, exports.ErrorCode.AuthorizationInfoAlreadyExists));
|
1646
|
+
}
|
1647
|
+
if (config.auth) {
|
1648
|
+
return Promise.reject(new ErrorWithCode(ErrorMessage.BasicCredentialAlreadyExists, exports.ErrorCode.AuthorizationInfoAlreadyExists));
|
1649
|
+
}
|
1650
|
+
config.auth = {
|
1651
|
+
username: this.userName,
|
1652
|
+
password: this.password,
|
1653
|
+
};
|
1654
|
+
return Promise.resolve(config);
|
1600
1655
|
}
|
1601
1656
|
}
|
1602
1657
|
|
@@ -1637,34 +1692,32 @@ class ApiKeyProvider {
|
|
1637
1692
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
1638
1693
|
*/
|
1639
1694
|
AddAuthenticationInfo(config) {
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
return config;
|
1667
|
-
});
|
1695
|
+
switch (this.keyLocation) {
|
1696
|
+
case exports.ApiKeyLocation.Header:
|
1697
|
+
if (!config.headers) {
|
1698
|
+
config.headers = {};
|
1699
|
+
}
|
1700
|
+
if (config.headers[this.keyName]) {
|
1701
|
+
return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.DuplicateApiKeyInHeader, this.keyName), exports.ErrorCode.AuthorizationInfoAlreadyExists));
|
1702
|
+
}
|
1703
|
+
config.headers[this.keyName] = this.keyValue;
|
1704
|
+
break;
|
1705
|
+
case exports.ApiKeyLocation.QueryParams:
|
1706
|
+
if (!config.params) {
|
1707
|
+
config.params = {};
|
1708
|
+
}
|
1709
|
+
let urlHasDefinedApiKey = false;
|
1710
|
+
if (config.url) {
|
1711
|
+
const url = new URL(config.url, config.baseURL);
|
1712
|
+
urlHasDefinedApiKey = url.searchParams.has(this.keyName);
|
1713
|
+
}
|
1714
|
+
if (config.params[this.keyName] || urlHasDefinedApiKey) {
|
1715
|
+
return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.DuplicateApiKeyInQueryParam, this.keyName), exports.ErrorCode.AuthorizationInfoAlreadyExists));
|
1716
|
+
}
|
1717
|
+
config.params[this.keyName] = this.keyValue;
|
1718
|
+
break;
|
1719
|
+
}
|
1720
|
+
return Promise.resolve(config);
|
1668
1721
|
}
|
1669
1722
|
}
|
1670
1723
|
/**
|
@@ -1712,21 +1765,19 @@ class CertificateAuthProvider {
|
|
1712
1765
|
* @throws {@link ErrorCode|InvalidParameter} - when custom httpsAgent in the request has duplicate properties with certOption provided in constructor.
|
1713
1766
|
*/
|
1714
1767
|
AddAuthenticationInfo(config) {
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
throw new ErrorWithCode(formatString(ErrorMessage.DuplicateHttpsOptionProperty, property), exports.ErrorCode.InvalidParameter);
|
1724
|
-
}
|
1768
|
+
if (!config.httpsAgent) {
|
1769
|
+
config.httpsAgent = new https.Agent(this.certOption);
|
1770
|
+
}
|
1771
|
+
else {
|
1772
|
+
const existingProperties = new Set(Object.keys(config.httpsAgent.options));
|
1773
|
+
for (const property of Object.keys(this.certOption)) {
|
1774
|
+
if (existingProperties.has(property)) {
|
1775
|
+
return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.DuplicateHttpsOptionProperty, property), exports.ErrorCode.InvalidParameter));
|
1725
1776
|
}
|
1726
|
-
Object.assign(config.httpsAgent.options, this.certOption);
|
1727
1777
|
}
|
1728
|
-
|
1729
|
-
}
|
1778
|
+
Object.assign(config.httpsAgent.options, this.certOption);
|
1779
|
+
}
|
1780
|
+
return Promise.resolve(config);
|
1730
1781
|
}
|
1731
1782
|
}
|
1732
1783
|
/**
|
@@ -1795,6 +1846,8 @@ const ReservedKey = new Set([
|
|
1795
1846
|
]);
|
1796
1847
|
/**
|
1797
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.
|
1798
1851
|
*/
|
1799
1852
|
class TeamsFx {
|
1800
1853
|
/**
|
@@ -1858,7 +1911,7 @@ class TeamsFx {
|
|
1858
1911
|
* @returns UserInfo object.
|
1859
1912
|
*/
|
1860
1913
|
getUserInfo(resources) {
|
1861
|
-
return
|
1914
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1862
1915
|
if (this.identityType !== exports.IdentityType.User) {
|
1863
1916
|
const errorMsg = formatString(ErrorMessage.IdentityTypeNotSupported, this.identityType.toString(), "TeamsFx");
|
1864
1917
|
internalLogger.error(errorMsg);
|
@@ -1889,7 +1942,7 @@ class TeamsFx {
|
|
1889
1942
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
1890
1943
|
*/
|
1891
1944
|
login(scopes, resources) {
|
1892
|
-
return
|
1945
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1893
1946
|
throw new ErrorWithCode(formatString(ErrorMessage.NodejsRuntimeNotSupported, "login"), exports.ErrorCode.RuntimeNotSupported);
|
1894
1947
|
});
|
1895
1948
|
}
|
@@ -2028,6 +2081,7 @@ exports.InvokeResponseErrorCode = void 0;
|
|
2028
2081
|
InvokeResponseErrorCode[InvokeResponseErrorCode["InternalServerError"] = 500] = "InternalServerError";
|
2029
2082
|
})(exports.InvokeResponseErrorCode || (exports.InvokeResponseErrorCode = {}));
|
2030
2083
|
|
2084
|
+
// Copyright (c) Microsoft Corporation.
|
2031
2085
|
/**
|
2032
2086
|
* Available response type for an adaptive card invoke response.
|
2033
2087
|
* @internal
|
@@ -2042,7 +2096,7 @@ var InvokeResponseType;
|
|
2042
2096
|
* Provides methods for formatting various invoke responses a bot can send to respond to an invoke request.
|
2043
2097
|
*
|
2044
2098
|
* @remarks
|
2045
|
-
* All of these functions return an
|
2099
|
+
* All of these functions return an `InvokeResponse` object, which can be
|
2046
2100
|
* passed as input to generate a new `invokeResponse` activity.
|
2047
2101
|
*
|
2048
2102
|
* This example sends an invoke response that contains an adaptive card.
|
@@ -2168,7 +2222,7 @@ class CardActionMiddleware {
|
|
2168
2222
|
}
|
2169
2223
|
onTurn(context, next) {
|
2170
2224
|
var _a, _b, _c;
|
2171
|
-
return
|
2225
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2172
2226
|
if (context.activity.name === "adaptiveCard/action") {
|
2173
2227
|
const action = context.activity.value.action;
|
2174
2228
|
const actionVerb = action.verb;
|
@@ -2225,7 +2279,7 @@ class CardActionMiddleware {
|
|
2225
2279
|
});
|
2226
2280
|
}
|
2227
2281
|
sendInvokeResponse(context, response) {
|
2228
|
-
return
|
2282
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2229
2283
|
yield context.sendActivity({
|
2230
2284
|
type: botbuilder.ActivityTypes.InvokeResponse,
|
2231
2285
|
value: response,
|
@@ -2294,7 +2348,7 @@ class CommandResponseMiddleware {
|
|
2294
2348
|
}
|
2295
2349
|
addSsoCommand(ssoHandler) {
|
2296
2350
|
var _a;
|
2297
|
-
(_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* () {
|
2298
2352
|
const matchResult = this.shouldTrigger(ssoHandler.triggerPatterns, message.text);
|
2299
2353
|
message.matches = Array.isArray(matchResult) ? matchResult : void 0;
|
2300
2354
|
const response = yield ssoHandler.handleCommandReceived(context, message, tokenResponse);
|
@@ -2305,7 +2359,7 @@ class CommandResponseMiddleware {
|
|
2305
2359
|
}
|
2306
2360
|
onTurn(context, next) {
|
2307
2361
|
var _a, _b;
|
2308
|
-
return
|
2362
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2309
2363
|
if (context.activity.type === botbuilder.ActivityTypes.Message) {
|
2310
2364
|
// Invoke corresponding command handler for the command response
|
2311
2365
|
const commandText = this.getActivityText(context.activity);
|
@@ -2344,7 +2398,7 @@ class CommandResponseMiddleware {
|
|
2344
2398
|
});
|
2345
2399
|
}
|
2346
2400
|
processResponse(context, response) {
|
2347
|
-
return
|
2401
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2348
2402
|
if (typeof response === "string") {
|
2349
2403
|
yield context.sendActivity(response);
|
2350
2404
|
}
|
@@ -2475,6 +2529,7 @@ function cloneConversation(conversation) {
|
|
2475
2529
|
*/
|
2476
2530
|
function getKey(reference) {
|
2477
2531
|
var _a, _b;
|
2532
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
2478
2533
|
return `_${(_a = reference.conversation) === null || _a === void 0 ? void 0 : _a.tenantId}_${(_b = reference.conversation) === null || _b === void 0 ? void 0 : _b.id}`;
|
2479
2534
|
}
|
2480
2535
|
/**
|
@@ -2534,7 +2589,7 @@ class NotificationMiddleware {
|
|
2534
2589
|
this.conversationReferenceStore = options.conversationReferenceStore;
|
2535
2590
|
}
|
2536
2591
|
onTurn(context, next) {
|
2537
|
-
return
|
2592
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2538
2593
|
const type = this.classifyActivity(context.activity);
|
2539
2594
|
switch (type) {
|
2540
2595
|
case ActivityType.CurrentBotInstalled:
|
@@ -2587,7 +2642,7 @@ class NotificationMiddleware {
|
|
2587
2642
|
}
|
2588
2643
|
tryAddMessagedReference(context) {
|
2589
2644
|
var _a, _b, _c, _d;
|
2590
|
-
return
|
2645
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2591
2646
|
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
2592
2647
|
const conversationType = (_a = reference === null || reference === void 0 ? void 0 : reference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
|
2593
2648
|
if (conversationType === "personal" || conversationType === "groupChat") {
|
@@ -2617,7 +2672,7 @@ class LocalFileStorage {
|
|
2617
2672
|
this.filePath = path__namespace.resolve(fileDir, this.localFileName);
|
2618
2673
|
}
|
2619
2674
|
read(key) {
|
2620
|
-
return
|
2675
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2621
2676
|
if (!(yield this.storeFileExists())) {
|
2622
2677
|
return undefined;
|
2623
2678
|
}
|
@@ -2626,7 +2681,7 @@ class LocalFileStorage {
|
|
2626
2681
|
});
|
2627
2682
|
}
|
2628
2683
|
list() {
|
2629
|
-
return
|
2684
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2630
2685
|
if (!(yield this.storeFileExists())) {
|
2631
2686
|
return [];
|
2632
2687
|
}
|
@@ -2635,7 +2690,7 @@ class LocalFileStorage {
|
|
2635
2690
|
});
|
2636
2691
|
}
|
2637
2692
|
write(key, object) {
|
2638
|
-
return
|
2693
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2639
2694
|
if (!(yield this.storeFileExists())) {
|
2640
2695
|
yield this.writeToFile({ [key]: object });
|
2641
2696
|
return;
|
@@ -2645,7 +2700,7 @@ class LocalFileStorage {
|
|
2645
2700
|
});
|
2646
2701
|
}
|
2647
2702
|
delete(key) {
|
2648
|
-
return
|
2703
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2649
2704
|
if (yield this.storeFileExists()) {
|
2650
2705
|
const data = yield this.readFromFile();
|
2651
2706
|
if (data[key] !== undefined) {
|
@@ -2690,7 +2745,7 @@ class LocalFileStorage {
|
|
2690
2745
|
});
|
2691
2746
|
}
|
2692
2747
|
writeToFile(data) {
|
2693
|
-
return
|
2748
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2694
2749
|
return new Promise((resolve, reject) => {
|
2695
2750
|
try {
|
2696
2751
|
const rawData = JSON.stringify(data, undefined, 2);
|
@@ -2718,7 +2773,7 @@ class DefaultConversationReferenceStore {
|
|
2718
2773
|
this.storage = storage;
|
2719
2774
|
}
|
2720
2775
|
add(key, reference, options) {
|
2721
|
-
return
|
2776
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2722
2777
|
if (options.overwrite) {
|
2723
2778
|
yield this.storage.write(key, reference);
|
2724
2779
|
return true;
|
@@ -2732,7 +2787,7 @@ class DefaultConversationReferenceStore {
|
|
2732
2787
|
});
|
2733
2788
|
}
|
2734
2789
|
remove(key, reference) {
|
2735
|
-
return
|
2790
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2736
2791
|
const ref = yield this.storage.read(key);
|
2737
2792
|
if (ref === undefined) {
|
2738
2793
|
return false;
|
@@ -2742,7 +2797,7 @@ class DefaultConversationReferenceStore {
|
|
2742
2797
|
});
|
2743
2798
|
}
|
2744
2799
|
list(pageSize, continuationToken) {
|
2745
|
-
return
|
2800
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2746
2801
|
const data = yield this.storage.list();
|
2747
2802
|
return {
|
2748
2803
|
data,
|
@@ -2810,11 +2865,11 @@ class Channel$1 {
|
|
2810
2865
|
* @returns the response of sending message.
|
2811
2866
|
*/
|
2812
2867
|
sendMessage(text, onError) {
|
2813
|
-
return
|
2868
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2814
2869
|
const response = {};
|
2815
|
-
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) =>
|
2816
|
-
const conversation =
|
2817
|
-
yield this.parent.adapter.continueConversation(conversation, (ctx) =>
|
2870
|
+
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
2871
|
+
const conversation = this.newConversation(context);
|
2872
|
+
yield this.parent.adapter.continueConversation(conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
2818
2873
|
try {
|
2819
2874
|
const res = yield ctx.sendActivity(text);
|
2820
2875
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -2841,11 +2896,11 @@ class Channel$1 {
|
|
2841
2896
|
* @returns the response of sending adaptive card message.
|
2842
2897
|
*/
|
2843
2898
|
sendAdaptiveCard(card, onError) {
|
2844
|
-
return
|
2899
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2845
2900
|
const response = {};
|
2846
|
-
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) =>
|
2847
|
-
const conversation =
|
2848
|
-
yield this.parent.adapter.continueConversation(conversation, (ctx) =>
|
2901
|
+
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
2902
|
+
const conversation = this.newConversation(context);
|
2903
|
+
yield this.parent.adapter.continueConversation(conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
2849
2904
|
try {
|
2850
2905
|
const res = yield ctx.sendActivity({
|
2851
2906
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -2869,12 +2924,10 @@ class Channel$1 {
|
|
2869
2924
|
* @internal
|
2870
2925
|
*/
|
2871
2926
|
newConversation(context) {
|
2872
|
-
|
2873
|
-
|
2874
|
-
|
2875
|
-
|
2876
|
-
return channelConversation;
|
2877
|
-
});
|
2927
|
+
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
2928
|
+
const channelConversation = cloneConversation(reference);
|
2929
|
+
channelConversation.conversation.id = this.info.id || "";
|
2930
|
+
return channelConversation;
|
2878
2931
|
}
|
2879
2932
|
}
|
2880
2933
|
/**
|
@@ -2910,11 +2963,11 @@ class Member$1 {
|
|
2910
2963
|
* @returns the response of sending message.
|
2911
2964
|
*/
|
2912
2965
|
sendMessage(text, onError) {
|
2913
|
-
return
|
2966
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2914
2967
|
const response = {};
|
2915
|
-
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* () {
|
2916
2969
|
const conversation = yield this.newConversation(context);
|
2917
|
-
yield this.parent.adapter.continueConversation(conversation, (ctx) =>
|
2970
|
+
yield this.parent.adapter.continueConversation(conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
2918
2971
|
try {
|
2919
2972
|
const res = yield ctx.sendActivity(text);
|
2920
2973
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -2941,11 +2994,11 @@ class Member$1 {
|
|
2941
2994
|
* @returns the response of sending adaptive card message.
|
2942
2995
|
*/
|
2943
2996
|
sendAdaptiveCard(card, onError) {
|
2944
|
-
return
|
2997
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2945
2998
|
const response = {};
|
2946
|
-
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* () {
|
2947
3000
|
const conversation = yield this.newConversation(context);
|
2948
|
-
yield this.parent.adapter.continueConversation(conversation, (ctx) =>
|
3001
|
+
yield this.parent.adapter.continueConversation(conversation, (ctx) => __awaiter(this, void 0, void 0, function* () {
|
2949
3002
|
try {
|
2950
3003
|
const res = yield ctx.sendActivity({
|
2951
3004
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -2969,7 +3022,7 @@ class Member$1 {
|
|
2969
3022
|
* @internal
|
2970
3023
|
*/
|
2971
3024
|
newConversation(context) {
|
2972
|
-
return
|
3025
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2973
3026
|
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
2974
3027
|
const personalConversation = cloneConversation(reference);
|
2975
3028
|
const connectorClient = context.turnState.get(this.parent.adapter.ConnectorClientKey);
|
@@ -3021,9 +3074,9 @@ class TeamsBotInstallation$1 {
|
|
3021
3074
|
* @returns the response of sending message.
|
3022
3075
|
*/
|
3023
3076
|
sendMessage(text, onError) {
|
3024
|
-
return
|
3077
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3025
3078
|
const response = {};
|
3026
|
-
yield this.adapter.continueConversation(this.conversationReference, (context) =>
|
3079
|
+
yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3027
3080
|
try {
|
3028
3081
|
const res = yield context.sendActivity(text);
|
3029
3082
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -3049,9 +3102,9 @@ class TeamsBotInstallation$1 {
|
|
3049
3102
|
* @returns the response of sending adaptive card message.
|
3050
3103
|
*/
|
3051
3104
|
sendAdaptiveCard(card, onError) {
|
3052
|
-
return
|
3105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3053
3106
|
const response = {};
|
3054
|
-
yield this.adapter.continueConversation(this.conversationReference, (context) =>
|
3107
|
+
yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3055
3108
|
try {
|
3056
3109
|
const res = yield context.sendActivity({
|
3057
3110
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -3076,13 +3129,13 @@ class TeamsBotInstallation$1 {
|
|
3076
3129
|
* @returns an array of channels if bot is installed into a team, otherwise returns an empty array.
|
3077
3130
|
*/
|
3078
3131
|
channels() {
|
3079
|
-
return
|
3132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3080
3133
|
const channels = [];
|
3081
3134
|
if (this.type !== exports.NotificationTargetType.Channel) {
|
3082
3135
|
return channels;
|
3083
3136
|
}
|
3084
3137
|
let teamsChannels = [];
|
3085
|
-
yield this.adapter.continueConversation(this.conversationReference, (context) =>
|
3138
|
+
yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3086
3139
|
const teamId = getTeamsBotInstallationId(context);
|
3087
3140
|
if (teamId !== undefined) {
|
3088
3141
|
teamsChannels = yield botbuilder.TeamsInfo.getTeamChannels(context, teamId);
|
@@ -3100,9 +3153,9 @@ class TeamsBotInstallation$1 {
|
|
3100
3153
|
* @returns an array of members from where the bot is installed.
|
3101
3154
|
*/
|
3102
3155
|
members() {
|
3103
|
-
return
|
3156
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3104
3157
|
const members = [];
|
3105
|
-
yield this.adapter.continueConversation(this.conversationReference, (context) =>
|
3158
|
+
yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3106
3159
|
let continuationToken;
|
3107
3160
|
do {
|
3108
3161
|
const pagedMembers = yield botbuilder.TeamsInfo.getPagedMembers(context, undefined, continuationToken);
|
@@ -3121,12 +3174,12 @@ class TeamsBotInstallation$1 {
|
|
3121
3174
|
* @returns the team details if bot is installed into a team, otherwise returns undefined.
|
3122
3175
|
*/
|
3123
3176
|
getTeamDetails() {
|
3124
|
-
return
|
3177
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3125
3178
|
if (this.type !== exports.NotificationTargetType.Channel) {
|
3126
3179
|
return undefined;
|
3127
3180
|
}
|
3128
3181
|
let teamDetails;
|
3129
|
-
yield this.adapter.continueConversation(this.conversationReference, (context) =>
|
3182
|
+
yield this.adapter.continueConversation(this.conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3130
3183
|
const teamId = getTeamsBotInstallationId(context);
|
3131
3184
|
if (teamId !== undefined) {
|
3132
3185
|
teamDetails = yield botbuilder.TeamsInfo.getTeamDetails(context, teamId);
|
@@ -3169,7 +3222,7 @@ class NotificationBot$1 {
|
|
3169
3222
|
* @returns - an array of {@link TeamsBotInstallation}.
|
3170
3223
|
*/
|
3171
3224
|
installations() {
|
3172
|
-
return
|
3225
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3173
3226
|
if (this.conversationReferenceStore === undefined || this.adapter === undefined) {
|
3174
3227
|
throw new Error("NotificationBot has not been initialized.");
|
3175
3228
|
}
|
@@ -3178,7 +3231,7 @@ class NotificationBot$1 {
|
|
3178
3231
|
for (const reference of references) {
|
3179
3232
|
// validate connection
|
3180
3233
|
let valid = true;
|
3181
|
-
yield this.adapter.continueConversation(reference, (context) =>
|
3234
|
+
yield this.adapter.continueConversation(reference, (context) => __awaiter(this, void 0, void 0, function* () {
|
3182
3235
|
try {
|
3183
3236
|
// try get member to see if the installation is still valid
|
3184
3237
|
yield botbuilder.TeamsInfo.getPagedMembers(context, 1);
|
@@ -3210,7 +3263,7 @@ class NotificationBot$1 {
|
|
3210
3263
|
* @returns the first {@link Member} where predicate is true, and undefined otherwise.
|
3211
3264
|
*/
|
3212
3265
|
findMember(predicate, scope) {
|
3213
|
-
return
|
3266
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3214
3267
|
for (const target of yield this.installations()) {
|
3215
3268
|
if (this.matchSearchScope(target, scope)) {
|
3216
3269
|
for (const member of yield target.members()) {
|
@@ -3233,7 +3286,7 @@ class NotificationBot$1 {
|
|
3233
3286
|
* @returns the first {@link Channel} where predicate is true, and undefined otherwise.
|
3234
3287
|
*/
|
3235
3288
|
findChannel(predicate) {
|
3236
|
-
return
|
3289
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3237
3290
|
for (const target of yield this.installations()) {
|
3238
3291
|
if (target.type === exports.NotificationTargetType.Channel) {
|
3239
3292
|
const teamDetails = yield target.getTeamDetails();
|
@@ -3256,7 +3309,7 @@ class NotificationBot$1 {
|
|
3256
3309
|
* @returns an array of {@link Member} where predicate is true, and empty array otherwise.
|
3257
3310
|
*/
|
3258
3311
|
findAllMembers(predicate, scope) {
|
3259
|
-
return
|
3312
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3260
3313
|
const members = [];
|
3261
3314
|
for (const target of yield this.installations()) {
|
3262
3315
|
if (this.matchSearchScope(target, scope)) {
|
@@ -3278,7 +3331,7 @@ class NotificationBot$1 {
|
|
3278
3331
|
* @returns an array of {@link Channel} where predicate is true, and empty array otherwise.
|
3279
3332
|
*/
|
3280
3333
|
findAllChannels(predicate) {
|
3281
|
-
return
|
3334
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3282
3335
|
const channels = [];
|
3283
3336
|
for (const target of yield this.installations()) {
|
3284
3337
|
if (target.type === exports.NotificationTargetType.Channel) {
|
@@ -3371,7 +3424,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3371
3424
|
const dialog = new botbuilderDialogs.WaterfallDialog(commandId, [
|
3372
3425
|
this.ssoStep.bind(this),
|
3373
3426
|
this.dedupStep.bind(this),
|
3374
|
-
(stepContext) =>
|
3427
|
+
(stepContext) => __awaiter(this, void 0, void 0, function* () {
|
3375
3428
|
const tokenResponse = stepContext.result.tokenResponse;
|
3376
3429
|
const context = stepContext.context;
|
3377
3430
|
const message = stepContext.result.message;
|
@@ -3408,7 +3461,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3408
3461
|
* @param accessor The instance of StatePropertyAccessor for dialog system.
|
3409
3462
|
*/
|
3410
3463
|
run(context, accessor) {
|
3411
|
-
return
|
3464
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3412
3465
|
const dialogSet = new botbuilderDialogs.DialogSet(accessor);
|
3413
3466
|
dialogSet.add(this);
|
3414
3467
|
const dialogContext = yield dialogSet.createContext(context);
|
@@ -3436,7 +3489,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3436
3489
|
return text;
|
3437
3490
|
}
|
3438
3491
|
commandRouteStep(stepContext) {
|
3439
|
-
return
|
3492
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3440
3493
|
const turnContext = stepContext.context;
|
3441
3494
|
const text = this.getActivityText(turnContext.activity);
|
3442
3495
|
const commandId = this.getMatchesCommandId(text);
|
@@ -3449,7 +3502,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3449
3502
|
});
|
3450
3503
|
}
|
3451
3504
|
ssoStep(stepContext) {
|
3452
|
-
return
|
3505
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3453
3506
|
try {
|
3454
3507
|
const turnContext = stepContext.context;
|
3455
3508
|
const text = this.getActivityText(turnContext.activity);
|
@@ -3467,7 +3520,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3467
3520
|
});
|
3468
3521
|
}
|
3469
3522
|
dedupStep(stepContext) {
|
3470
|
-
return
|
3523
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3471
3524
|
const tokenResponse = stepContext.result;
|
3472
3525
|
if (!tokenResponse) {
|
3473
3526
|
internalLogger.error(ErrorMessage.FailedToRetrieveSsoToken);
|
@@ -3496,7 +3549,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3496
3549
|
* @param context Context for the current turn of conversation.
|
3497
3550
|
*/
|
3498
3551
|
onEndDialog(context) {
|
3499
|
-
return
|
3552
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3500
3553
|
const conversationId = context.activity.conversation.id;
|
3501
3554
|
const currentDedupKeys = this.dedupStorageKeys.filter((key) => key.indexOf(conversationId) > 0);
|
3502
3555
|
yield this.dedupStorage.delete(currentDedupKeys);
|
@@ -3512,7 +3565,7 @@ class BotSsoExecutionDialog extends botbuilderDialogs.ComponentDialog {
|
|
3512
3565
|
* @returns boolean value indicate whether the message should be removed
|
3513
3566
|
*/
|
3514
3567
|
shouldDedup(context) {
|
3515
|
-
return
|
3568
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3516
3569
|
const storeItem = {
|
3517
3570
|
eTag: context.activity.value.id,
|
3518
3571
|
};
|
@@ -3612,18 +3665,17 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
|
|
3612
3665
|
const userState = (_b = (_a = ssoConfig.dialog) === null || _a === void 0 ? void 0 : _a.userState) !== null && _b !== void 0 ? _b : new botbuilder.UserState(memoryStorage);
|
3613
3666
|
const conversationState = (_d = (_c = ssoConfig.dialog) === null || _c === void 0 ? void 0 : _c.conversationState) !== null && _d !== void 0 ? _d : new botbuilder.ConversationState(memoryStorage);
|
3614
3667
|
const dedupStorage = (_f = (_e = ssoConfig.dialog) === null || _e === void 0 ? void 0 : _e.dedupStorage) !== null && _f !== void 0 ? _f : memoryStorage;
|
3615
|
-
const _l = ssoConfig.aad, { scopes } = _l, customConfig =
|
3668
|
+
const _l = ssoConfig.aad, { scopes } = _l, customConfig = __rest(_l, ["scopes"]);
|
3616
3669
|
const settings = {
|
3617
3670
|
scopes: scopes,
|
3618
3671
|
timeout: (_h = (_g = ssoConfig.dialog) === null || _g === void 0 ? void 0 : _g.ssoPromptConfig) === null || _h === void 0 ? void 0 : _h.timeout,
|
3619
3672
|
endOnInvalidMessage: (_k = (_j = ssoConfig.dialog) === null || _j === void 0 ? void 0 : _j.ssoPromptConfig) === null || _k === void 0 ? void 0 : _k.endOnInvalidMessage,
|
3620
3673
|
};
|
3621
|
-
|
3622
|
-
this.ssoExecutionDialog = new BotSsoExecutionDialog(dedupStorage, settings, teamsfx);
|
3674
|
+
this.ssoExecutionDialog = new BotSsoExecutionDialog(dedupStorage, settings, customConfig, customConfig.initiateLoginEndpoint);
|
3623
3675
|
this.conversationState = conversationState;
|
3624
3676
|
this.dialogState = conversationState.createProperty("DialogState");
|
3625
3677
|
this.userState = userState;
|
3626
|
-
this.onMessage((context, next) =>
|
3678
|
+
this.onMessage((context, next) => __awaiter(this, void 0, void 0, function* () {
|
3627
3679
|
yield this.ssoExecutionDialog.run(context, this.dialogState);
|
3628
3680
|
yield next();
|
3629
3681
|
}));
|
@@ -3647,7 +3699,7 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
|
|
3647
3699
|
const _super = Object.create(null, {
|
3648
3700
|
run: { get: () => super.run }
|
3649
3701
|
});
|
3650
|
-
return
|
3702
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3651
3703
|
try {
|
3652
3704
|
yield _super.run.call(this, context);
|
3653
3705
|
}
|
@@ -3667,7 +3719,7 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
|
|
3667
3719
|
* It should trigger {@link BotSsoExecutionDialog} instance to handle signin process
|
3668
3720
|
*/
|
3669
3721
|
handleTeamsSigninVerifyState(context, query) {
|
3670
|
-
return
|
3722
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3671
3723
|
yield this.ssoExecutionDialog.run(context, this.dialogState);
|
3672
3724
|
});
|
3673
3725
|
}
|
@@ -3677,11 +3729,11 @@ class DefaultBotSsoExecutionActivityHandler extends botbuilder.TeamsActivityHand
|
|
3677
3729
|
* @param query Signin state (part of signin action auth flow) verification invoke query
|
3678
3730
|
* @returns A promise that represents the work queued.
|
3679
3731
|
*
|
3680
|
-
* @
|
3732
|
+
* @remarks
|
3681
3733
|
* It should trigger {@link BotSsoExecutionDialog} instance to handle signin process
|
3682
3734
|
*/
|
3683
3735
|
handleTeamsSigninTokenExchange(context, query) {
|
3684
|
-
return
|
3736
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3685
3737
|
yield this.ssoExecutionDialog.run(context, this.dialogState);
|
3686
3738
|
});
|
3687
3739
|
}
|
@@ -3787,11 +3839,14 @@ class ConversationBot$1 {
|
|
3787
3839
|
})
|
3788
3840
|
: new botbuilder.BotFrameworkAdapter(adapterConfig);
|
3789
3841
|
// the default error handler
|
3790
|
-
adapter.onTurnError = (context, error) =>
|
3842
|
+
adapter.onTurnError = (context, error) => __awaiter(this, void 0, void 0, function* () {
|
3791
3843
|
// This check writes out errors to console.
|
3844
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
3792
3845
|
console.error(`[onTurnError] unhandled error: ${error}`);
|
3793
3846
|
// Send a trace activity, which will be displayed in Bot Framework Emulator
|
3794
|
-
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");
|
3795
3850
|
// Send a message to the user
|
3796
3851
|
yield context.sendActivity(`The bot encountered unhandled error: ${error.message}`);
|
3797
3852
|
yield context.sendActivity("To continue to run this bot, please fix the bot source code.");
|
@@ -3820,10 +3875,10 @@ class ConversationBot$1 {
|
|
3820
3875
|
* ```
|
3821
3876
|
*/
|
3822
3877
|
requestHandler(req, res, logic) {
|
3823
|
-
return
|
3878
|
+
return __awaiter(this, void 0, void 0, function* () {
|
3824
3879
|
if (logic === undefined) {
|
3825
3880
|
// create empty logic
|
3826
|
-
logic = () =>
|
3881
|
+
logic = () => __awaiter(this, void 0, void 0, function* () { });
|
3827
3882
|
}
|
3828
3883
|
yield this.adapter.processActivity(req, res, logic);
|
3829
3884
|
});
|
@@ -4040,7 +4095,7 @@ function getSignInResponseForMessageExtension(teamsfx, scopes) {
|
|
4040
4095
|
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4041
4096
|
*/
|
4042
4097
|
function executionWithTokenAndConfig(context, authConfig, initiateLoginEndpoint, scopes, logic) {
|
4043
|
-
return
|
4098
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4044
4099
|
const valueObj = context.activity.value;
|
4045
4100
|
if (!valueObj.authentication || !valueObj.authentication.token) {
|
4046
4101
|
internalLogger.verbose("No AccessToken in request, return silentAuth for AccessToken");
|
@@ -4074,6 +4129,7 @@ function executionWithTokenAndConfig(context, authConfig, initiateLoginEndpoint,
|
|
4074
4129
|
}
|
4075
4130
|
/**
|
4076
4131
|
* execution in message extension with SSO token.
|
4132
|
+
* @deprecated Use {@link executionWithTokenAndConfig} instead.
|
4077
4133
|
*
|
4078
4134
|
* @param {TurnContext} context - The context object for the current turn.
|
4079
4135
|
* @param {AuthenticationConfiguration} config - User custom the message extension authentication configuration.
|
@@ -4089,7 +4145,7 @@ function executionWithTokenAndConfig(context, authConfig, initiateLoginEndpoint,
|
|
4089
4145
|
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4090
4146
|
*/
|
4091
4147
|
function executionWithToken(context, config, scopes, logic) {
|
4092
|
-
return
|
4148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4093
4149
|
const valueObj = context.activity.value;
|
4094
4150
|
if (!valueObj.authentication || !valueObj.authentication.token) {
|
4095
4151
|
internalLogger.verbose("No AccessToken in request, return silentAuth for AccessToken");
|
@@ -4124,7 +4180,7 @@ function executionWithToken(context, config, scopes, logic) {
|
|
4124
4180
|
// eslint-disable-next-line no-secrets/no-secrets
|
4125
4181
|
/**
|
4126
4182
|
* Users execute query in message extension with SSO or access token.
|
4127
|
-
*
|
4183
|
+
* @deprecated Use {@link handleMessageExtensionQueryWithSSO} instead.
|
4128
4184
|
*
|
4129
4185
|
* @param {TurnContext} context - The context object for the current turn.
|
4130
4186
|
* @param {AuthenticationConfiguration} config - User custom the message extension authentication configuration.
|
@@ -4141,7 +4197,7 @@ function executionWithToken(context, config, scopes, logic) {
|
|
4141
4197
|
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4142
4198
|
*/
|
4143
4199
|
function handleMessageExtensionQueryWithToken(context, config, scopes, logic) {
|
4144
|
-
return
|
4200
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4145
4201
|
if (context.activity.name != "composeExtension/query") {
|
4146
4202
|
internalLogger.error(ErrorMessage.OnlySupportInQueryActivity);
|
4147
4203
|
throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInQueryActivity), exports.ErrorCode.FailedOperation);
|
@@ -4168,7 +4224,7 @@ function handleMessageExtensionQueryWithToken(context, config, scopes, logic) {
|
|
4168
4224
|
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4169
4225
|
*/
|
4170
4226
|
function handleMessageExtensionQueryWithSSO(context, config, initiateLoginEndpoint, scopes, logic) {
|
4171
|
-
return
|
4227
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4172
4228
|
if (context.activity.name != "composeExtension/query") {
|
4173
4229
|
internalLogger.error(ErrorMessage.OnlySupportInQueryActivity);
|
4174
4230
|
throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInQueryActivity), exports.ErrorCode.FailedOperation);
|
@@ -4346,11 +4402,11 @@ class Channel {
|
|
4346
4402
|
* @returns The response of sending message.
|
4347
4403
|
*/
|
4348
4404
|
sendMessage(text, onError) {
|
4349
|
-
return
|
4405
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4350
4406
|
const response = {};
|
4351
|
-
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* () {
|
4352
4408
|
const conversation = yield this.newConversation(context);
|
4353
|
-
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* () {
|
4354
4410
|
try {
|
4355
4411
|
const res = yield ctx.sendActivity(text);
|
4356
4412
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -4378,11 +4434,11 @@ class Channel {
|
|
4378
4434
|
* @returns The response of sending adaptive card message.
|
4379
4435
|
*/
|
4380
4436
|
sendAdaptiveCard(card, onError) {
|
4381
|
-
return
|
4437
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4382
4438
|
const response = {};
|
4383
|
-
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* () {
|
4384
4440
|
const conversation = yield this.newConversation(context);
|
4385
|
-
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* () {
|
4386
4442
|
try {
|
4387
4443
|
const res = yield ctx.sendActivity({
|
4388
4444
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -4406,12 +4462,10 @@ class Channel {
|
|
4406
4462
|
* @internal
|
4407
4463
|
*/
|
4408
4464
|
newConversation(context) {
|
4409
|
-
|
4410
|
-
|
4411
|
-
|
4412
|
-
|
4413
|
-
return channelConversation;
|
4414
|
-
});
|
4465
|
+
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
4466
|
+
const channelConversation = cloneConversation(reference);
|
4467
|
+
channelConversation.conversation.id = this.info.id || "";
|
4468
|
+
return Promise.resolve(channelConversation);
|
4415
4469
|
}
|
4416
4470
|
}
|
4417
4471
|
/**
|
@@ -4448,11 +4502,11 @@ class Member {
|
|
4448
4502
|
* @returns The response of sending message.
|
4449
4503
|
*/
|
4450
4504
|
sendMessage(text, onError) {
|
4451
|
-
return
|
4505
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4452
4506
|
const response = {};
|
4453
|
-
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* () {
|
4454
4508
|
const conversation = yield this.newConversation(context);
|
4455
|
-
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* () {
|
4456
4510
|
try {
|
4457
4511
|
const res = yield ctx.sendActivity(text);
|
4458
4512
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -4480,11 +4534,11 @@ class Member {
|
|
4480
4534
|
* @returns The response of sending adaptive card message.
|
4481
4535
|
*/
|
4482
4536
|
sendAdaptiveCard(card, onError) {
|
4483
|
-
return
|
4537
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4484
4538
|
const response = {};
|
4485
|
-
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* () {
|
4486
4540
|
const conversation = yield this.newConversation(context);
|
4487
|
-
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* () {
|
4488
4542
|
try {
|
4489
4543
|
const res = yield ctx.sendActivity({
|
4490
4544
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -4508,7 +4562,7 @@ class Member {
|
|
4508
4562
|
* @internal
|
4509
4563
|
*/
|
4510
4564
|
newConversation(context) {
|
4511
|
-
return
|
4565
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4512
4566
|
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
4513
4567
|
const personalConversation = cloneConversation(reference);
|
4514
4568
|
const connectorClient = context.turnState.get(this.parent.adapter.ConnectorClientKey);
|
@@ -4560,9 +4614,9 @@ class TeamsBotInstallation {
|
|
4560
4614
|
* @returns The response of sending message.
|
4561
4615
|
*/
|
4562
4616
|
sendMessage(text, onError) {
|
4563
|
-
return
|
4617
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4564
4618
|
const response = {};
|
4565
|
-
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* () {
|
4566
4620
|
try {
|
4567
4621
|
const res = yield context.sendActivity(text);
|
4568
4622
|
response.id = res === null || res === void 0 ? void 0 : res.id;
|
@@ -4589,9 +4643,9 @@ class TeamsBotInstallation {
|
|
4589
4643
|
* @returns The response of sending adaptive card message.
|
4590
4644
|
*/
|
4591
4645
|
sendAdaptiveCard(card, onError) {
|
4592
|
-
return
|
4646
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4593
4647
|
const response = {};
|
4594
|
-
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* () {
|
4595
4649
|
try {
|
4596
4650
|
const res = yield context.sendActivity({
|
4597
4651
|
attachments: [botbuilder.CardFactory.adaptiveCard(card)],
|
@@ -4616,13 +4670,13 @@ class TeamsBotInstallation {
|
|
4616
4670
|
* @returns An array of channels if bot is installed into a team, otherwise returns an empty array.
|
4617
4671
|
*/
|
4618
4672
|
channels() {
|
4619
|
-
return
|
4673
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4620
4674
|
const channels = [];
|
4621
4675
|
if (this.type !== exports.NotificationTargetType.Channel) {
|
4622
4676
|
return channels;
|
4623
4677
|
}
|
4624
4678
|
let teamsChannels = [];
|
4625
|
-
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* () {
|
4626
4680
|
const teamId = getTeamsBotInstallationId(context);
|
4627
4681
|
if (teamId !== undefined) {
|
4628
4682
|
teamsChannels = yield botbuilder.TeamsInfo.getTeamChannels(context, teamId);
|
@@ -4642,12 +4696,12 @@ class TeamsBotInstallation {
|
|
4642
4696
|
* @returns An array of members from where the bot is installed.
|
4643
4697
|
*/
|
4644
4698
|
getPagedMembers(pageSize, continuationToken) {
|
4645
|
-
return
|
4699
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4646
4700
|
let result = {
|
4647
4701
|
data: [],
|
4648
4702
|
continuationToken: "",
|
4649
4703
|
};
|
4650
|
-
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* () {
|
4651
4705
|
const pagedMembers = yield botbuilder.TeamsInfo.getPagedMembers(context, pageSize, continuationToken);
|
4652
4706
|
result = {
|
4653
4707
|
data: pagedMembers.members.map((m) => new Member(this, m)),
|
@@ -4665,7 +4719,7 @@ class TeamsBotInstallation {
|
|
4665
4719
|
* @deprecated Use `getPagedMembers` instead.
|
4666
4720
|
*/
|
4667
4721
|
members() {
|
4668
|
-
return
|
4722
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4669
4723
|
const members = [];
|
4670
4724
|
let continuationToken;
|
4671
4725
|
do {
|
@@ -4682,12 +4736,12 @@ class TeamsBotInstallation {
|
|
4682
4736
|
* @returns The team details if bot is installed into a team, otherwise returns `undefined`.
|
4683
4737
|
*/
|
4684
4738
|
getTeamDetails() {
|
4685
|
-
return
|
4739
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4686
4740
|
if (this.type !== exports.NotificationTargetType.Channel) {
|
4687
4741
|
return undefined;
|
4688
4742
|
}
|
4689
4743
|
let teamDetails;
|
4690
|
-
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* () {
|
4691
4745
|
const teamId = getTeamsBotInstallationId(context);
|
4692
4746
|
if (teamId !== undefined) {
|
4693
4747
|
teamDetails = yield botbuilder.TeamsInfo.getTeamDetails(context, teamId);
|
@@ -4736,6 +4790,29 @@ class NotificationBot {
|
|
4736
4790
|
}
|
4737
4791
|
return new TeamsBotInstallation(this.adapter, conversationReference, this.botAppId);
|
4738
4792
|
}
|
4793
|
+
/**
|
4794
|
+
* Validate the installation by getting paged memebers.
|
4795
|
+
*
|
4796
|
+
* @param conversationReference The bound `ConversationReference`.
|
4797
|
+
* @returns Returns false if recieves `BotNotInConversationRoster` error, otherwise returns true.
|
4798
|
+
*/
|
4799
|
+
validateInstallation(conversationReference) {
|
4800
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4801
|
+
let isValid = true;
|
4802
|
+
yield this.adapter.continueConversationAsync(this.botAppId, conversationReference, (context) => __awaiter(this, void 0, void 0, function* () {
|
4803
|
+
try {
|
4804
|
+
// try get member to see if the installation is still valid
|
4805
|
+
yield botbuilder.TeamsInfo.getPagedMembers(context, 1);
|
4806
|
+
}
|
4807
|
+
catch (error) {
|
4808
|
+
if (error.code === "BotNotInConversationRoster") {
|
4809
|
+
isValid = false;
|
4810
|
+
}
|
4811
|
+
}
|
4812
|
+
}));
|
4813
|
+
return isValid;
|
4814
|
+
});
|
4815
|
+
}
|
4739
4816
|
/**
|
4740
4817
|
* Gets a pagined list of targets where the bot is installed.
|
4741
4818
|
*
|
@@ -4747,8 +4824,8 @@ class NotificationBot {
|
|
4747
4824
|
*
|
4748
4825
|
* @returns An array of {@link TeamsBotInstallation} with paged data and continuation token.
|
4749
4826
|
*/
|
4750
|
-
getPagedInstallations(pageSize, continuationToken) {
|
4751
|
-
return
|
4827
|
+
getPagedInstallations(pageSize, continuationToken, validationEnabled = true) {
|
4828
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4752
4829
|
if (this.conversationReferenceStore === undefined || this.adapter === undefined) {
|
4753
4830
|
throw new Error("NotificationBot has not been initialized.");
|
4754
4831
|
}
|
@@ -4756,19 +4833,12 @@ class NotificationBot {
|
|
4756
4833
|
const targets = [];
|
4757
4834
|
for (const reference of references.data) {
|
4758
4835
|
// validate connection
|
4759
|
-
let valid
|
4760
|
-
|
4761
|
-
try
|
4762
|
-
|
4763
|
-
|
4764
|
-
|
4765
|
-
catch (error) {
|
4766
|
-
if (error.code === "BotNotInConversationRoster") {
|
4767
|
-
valid = false;
|
4768
|
-
}
|
4769
|
-
}
|
4770
|
-
}));
|
4771
|
-
if (valid) {
|
4836
|
+
let valid;
|
4837
|
+
if (validationEnabled) {
|
4838
|
+
// try get member to see if the installation is still valid
|
4839
|
+
valid = yield this.validateInstallation(reference);
|
4840
|
+
}
|
4841
|
+
if (!validationEnabled || (validationEnabled && valid)) {
|
4772
4842
|
targets.push(new TeamsBotInstallation(this.adapter, reference, this.botAppId));
|
4773
4843
|
}
|
4774
4844
|
else {
|
@@ -4792,7 +4862,7 @@ class NotificationBot {
|
|
4792
4862
|
* @deprecated Use getPagedInstallations instead.
|
4793
4863
|
*/
|
4794
4864
|
installations() {
|
4795
|
-
return
|
4865
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4796
4866
|
let continuationToken;
|
4797
4867
|
const targets = [];
|
4798
4868
|
do {
|
@@ -4815,7 +4885,7 @@ class NotificationBot {
|
|
4815
4885
|
* @returns The first {@link Member} where predicate is true, and `undefined` otherwise.
|
4816
4886
|
*/
|
4817
4887
|
findMember(predicate, scope) {
|
4818
|
-
return
|
4888
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4819
4889
|
for (const target of yield this.installations()) {
|
4820
4890
|
if (this.matchSearchScope(target, scope)) {
|
4821
4891
|
for (const member of yield target.members()) {
|
@@ -4839,7 +4909,7 @@ class NotificationBot {
|
|
4839
4909
|
* @returns The first {@link Channel} where predicate is true, and `undefined` otherwise.
|
4840
4910
|
*/
|
4841
4911
|
findChannel(predicate) {
|
4842
|
-
return
|
4912
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4843
4913
|
for (const target of yield this.installations()) {
|
4844
4914
|
if (target.type === exports.NotificationTargetType.Channel) {
|
4845
4915
|
const teamDetails = yield target.getTeamDetails();
|
@@ -4863,7 +4933,7 @@ class NotificationBot {
|
|
4863
4933
|
* @returns An array of {@link Member} where predicate is true, and empty array otherwise.
|
4864
4934
|
*/
|
4865
4935
|
findAllMembers(predicate, scope) {
|
4866
|
-
return
|
4936
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4867
4937
|
const members = [];
|
4868
4938
|
for (const target of yield this.installations()) {
|
4869
4939
|
if (this.matchSearchScope(target, scope)) {
|
@@ -4886,7 +4956,7 @@ class NotificationBot {
|
|
4886
4956
|
* @returns An array of {@link Channel} where predicate is true, and empty array otherwise.
|
4887
4957
|
*/
|
4888
4958
|
findAllChannels(predicate) {
|
4889
|
-
return
|
4959
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4890
4960
|
const channels = [];
|
4891
4961
|
for (const target of yield this.installations()) {
|
4892
4962
|
if (target.type === exports.NotificationTargetType.Channel) {
|
@@ -5039,11 +5109,11 @@ class ConversationBot {
|
|
5039
5109
|
const botFrameworkAuthentication = new botbuilder.ConfigurationBotFrameworkAuthentication({}, credentialsFactory);
|
5040
5110
|
const adapter = new botbuilder.CloudAdapter(botFrameworkAuthentication);
|
5041
5111
|
// the default error handler
|
5042
|
-
adapter.onTurnError = (context, error) =>
|
5112
|
+
adapter.onTurnError = (context, error) => __awaiter(this, void 0, void 0, function* () {
|
5043
5113
|
// This check writes out errors to console.
|
5044
|
-
console.error(`[onTurnError] unhandled error
|
5114
|
+
console.error(`[onTurnError] unhandled error`, error);
|
5045
5115
|
// Send a trace activity, which will be displayed in Bot Framework Emulator
|
5046
|
-
yield context.sendTraceActivity("OnTurnError Trace",
|
5116
|
+
yield context.sendTraceActivity("OnTurnError Trace", error instanceof Error ? error.message : error, "https://www.botframework.com/schemas/error", "TurnError");
|
5047
5117
|
// Send a message to the user
|
5048
5118
|
yield context.sendActivity(`The bot encountered unhandled error: ${error.message}`);
|
5049
5119
|
yield context.sendActivity("To continue to run this bot, please fix the bot source code.");
|
@@ -5074,10 +5144,10 @@ class ConversationBot {
|
|
5074
5144
|
* ```
|
5075
5145
|
*/
|
5076
5146
|
requestHandler(req, res, logic) {
|
5077
|
-
return
|
5147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
5078
5148
|
if (logic === undefined) {
|
5079
5149
|
// create empty logic
|
5080
|
-
logic = () =>
|
5150
|
+
logic = () => __awaiter(this, void 0, void 0, function* () { });
|
5081
5151
|
}
|
5082
5152
|
yield this.adapter.process(req, res, logic);
|
5083
5153
|
});
|