@microsoft/teamsfx 0.6.2 → 0.6.3-alpha.266fa3b9f.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.
@@ -3,6 +3,7 @@ import jwt_decode from 'jwt-decode';
3
3
  import * as microsoftTeams from '@microsoft/teams-js';
4
4
  import { PublicClientApplication } from '@azure/msal-browser';
5
5
  import { Client } from '@microsoft/microsoft-graph-client';
6
+ import axios from 'axios';
6
7
 
7
8
  // Copyright (c) Microsoft Corporation.
8
9
  // Licensed under the MIT license.
@@ -64,6 +65,10 @@ var ErrorCode;
64
65
  * Identity type error.
65
66
  */
66
67
  ErrorCode["IdentityTypeNotSupported"] = "IdentityTypeNotSupported";
68
+ /**
69
+ * Authentication info already exists error.
70
+ */
71
+ ErrorCode["AuthorizationInfoAlreadyExists"] = "AuthorizationInfoAlreadyExists";
67
72
  })(ErrorCode || (ErrorCode = {}));
68
73
  /**
69
74
  * @internal
@@ -85,6 +90,14 @@ ErrorMessage.FailToAcquireTokenOnBehalfOfUser = "Failed to acquire access token
85
90
  ErrorMessage.OnlyMSTeamsChannelSupported = "{0} is only supported in MS Teams Channel";
86
91
  // IdentityTypeNotSupported Error
87
92
  ErrorMessage.IdentityTypeNotSupported = "{0} identity is not supported in {1}";
93
+ // AuthorizationInfoError
94
+ ErrorMessage.AuthorizationHeaderAlreadyExists = "Authorization header already exists!";
95
+ ErrorMessage.BasicCredentialAlreadyExists = "Basic credential already exists!";
96
+ // InvalidParameter Error
97
+ ErrorMessage.EmptyParameter = "Parameter {0} is empty";
98
+ ErrorMessage.DuplicateHttpsOptionProperty = "Axios HTTPS agent already defined value for property {0}";
99
+ ErrorMessage.DuplicateApiKeyInHeader = "The request already defined api key in request header with name {0}.";
100
+ ErrorMessage.DuplicateApiKeyInQueryParam = "The request already defined api key in query parameter with name {0}.";
88
101
  /**
89
102
  * Error class with code and message thrown by the SDK.
90
103
  *
@@ -1075,6 +1088,280 @@ class TeamsBotSsoPrompt {
1075
1088
  }
1076
1089
  }
1077
1090
 
1091
+ // Copyright (c) Microsoft Corporation.
1092
+ /**
1093
+ * Initializes new Axios instance with specific auth provider
1094
+ *
1095
+ * @param apiEndpoint - Base url of the API
1096
+ * @param authProvider - Auth provider that injects authentication info to each request
1097
+ * @returns axios instance configured with specfic auth provider
1098
+ *
1099
+ * @example
1100
+ * ```typescript
1101
+ * const client = createApiClient("https://my-api-endpoint-base-url", new BasicAuthProvider("xxx","xxx"));
1102
+ * ```
1103
+ *
1104
+ * @beta
1105
+ */
1106
+ function createApiClient(apiEndpoint, authProvider) {
1107
+ // Add a request interceptor
1108
+ const instance = axios.create({
1109
+ baseURL: apiEndpoint,
1110
+ });
1111
+ instance.interceptors.request.use(function (config) {
1112
+ return __awaiter(this, void 0, void 0, function* () {
1113
+ return yield authProvider.AddAuthenticationInfo(config);
1114
+ });
1115
+ });
1116
+ return instance;
1117
+ }
1118
+
1119
+ // Copyright (c) Microsoft Corporation.
1120
+ /**
1121
+ * Provider that handles Bearer Token authentication
1122
+ *
1123
+ * @beta
1124
+ */
1125
+ class BearerTokenAuthProvider {
1126
+ /**
1127
+ * @param { () => Promise<string> } getToken - Function that returns the content of bearer token used in http request
1128
+ *
1129
+ * @beta
1130
+ */
1131
+ constructor(getToken) {
1132
+ this.getToken = getToken;
1133
+ }
1134
+ /**
1135
+ * Adds authentication info to http requests
1136
+ *
1137
+ * @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
1138
+ * Refer https://axios-http.com/docs/req_config for detailed document.
1139
+ *
1140
+ * @returns Updated axios request config.
1141
+ *
1142
+ * @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header already exists in request configuration.
1143
+ *
1144
+ * @beta
1145
+ */
1146
+ AddAuthenticationInfo(config) {
1147
+ return __awaiter(this, void 0, void 0, function* () {
1148
+ const token = yield this.getToken();
1149
+ if (!config.headers) {
1150
+ config.headers = {};
1151
+ }
1152
+ if (config.headers["Authorization"]) {
1153
+ throw new ErrorWithCode(ErrorMessage.AuthorizationHeaderAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
1154
+ }
1155
+ config.headers["Authorization"] = `Bearer ${token}`;
1156
+ return config;
1157
+ });
1158
+ }
1159
+ }
1160
+
1161
+ // Copyright (c) Microsoft Corporation.
1162
+ /**
1163
+ * Provider that handles Basic authentication
1164
+ *
1165
+ * @beta
1166
+ */
1167
+ class BasicAuthProvider {
1168
+ /**
1169
+ *
1170
+ * @param { string } userName - Username used in basic auth
1171
+ * @param { string } password - Password used in basic auth
1172
+ *
1173
+ * @throws {@link ErrorCode|InvalidParameter} - when username or password is empty.
1174
+ *
1175
+ * @beta
1176
+ */
1177
+ constructor(userName, password) {
1178
+ if (!userName) {
1179
+ throw new ErrorWithCode(formatString(ErrorMessage.EmptyParameter, "username"), ErrorCode.InvalidParameter);
1180
+ }
1181
+ if (!password) {
1182
+ throw new ErrorWithCode(formatString(ErrorMessage.EmptyParameter, "password"), ErrorCode.InvalidParameter);
1183
+ }
1184
+ this.userName = userName;
1185
+ this.password = password;
1186
+ }
1187
+ /**
1188
+ * Adds authentication info to http requests
1189
+ *
1190
+ * @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
1191
+ * Refer https://axios-http.com/docs/req_config for detailed document.
1192
+ *
1193
+ * @returns Updated axios request config.
1194
+ *
1195
+ * @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header or auth property already exists in request configuration.
1196
+ *
1197
+ * @beta
1198
+ */
1199
+ AddAuthenticationInfo(config) {
1200
+ return __awaiter(this, void 0, void 0, function* () {
1201
+ if (config.headers && config.headers["Authorization"]) {
1202
+ throw new ErrorWithCode(ErrorMessage.AuthorizationHeaderAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
1203
+ }
1204
+ if (config.auth) {
1205
+ throw new ErrorWithCode(ErrorMessage.BasicCredentialAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
1206
+ }
1207
+ config.auth = {
1208
+ username: this.userName,
1209
+ password: this.password,
1210
+ };
1211
+ return config;
1212
+ });
1213
+ }
1214
+ }
1215
+
1216
+ // Copyright (c) Microsoft Corporation.
1217
+ /**
1218
+ * Provider that handles API Key authentication
1219
+ *
1220
+ * @beta
1221
+ */
1222
+ class ApiKeyProvider {
1223
+ /**
1224
+ *
1225
+ * @param { string } keyName - The name of request header or query parameter that specifies API Key
1226
+ * @param { string } keyValue - The value of API Key
1227
+ * @param { ApiKeyLocation } keyLocation - The location of API Key: request header or query parameter.
1228
+ *
1229
+ * @throws {@link ErrorCode|InvalidParameter} - when key name or key value is empty.
1230
+ *
1231
+ * @beta
1232
+ */
1233
+ constructor(keyName, keyValue, keyLocation) {
1234
+ if (!keyName) {
1235
+ throw new ErrorWithCode(formatString(ErrorMessage.EmptyParameter, "keyName"), ErrorCode.InvalidParameter);
1236
+ }
1237
+ if (!keyValue) {
1238
+ throw new ErrorWithCode(formatString(ErrorMessage.EmptyParameter, "keyVaule"), ErrorCode.InvalidParameter);
1239
+ }
1240
+ this.keyName = keyName;
1241
+ this.keyValue = keyValue;
1242
+ this.keyLocation = keyLocation;
1243
+ }
1244
+ /**
1245
+ * Adds authentication info to http requests
1246
+ *
1247
+ * @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
1248
+ * Refer https://axios-http.com/docs/req_config for detailed document.
1249
+ *
1250
+ * @returns Updated axios request config.
1251
+ *
1252
+ * @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when API key already exists in request header or url query parameter.
1253
+ *
1254
+ * @beta
1255
+ */
1256
+ AddAuthenticationInfo(config) {
1257
+ return __awaiter(this, void 0, void 0, function* () {
1258
+ switch (this.keyLocation) {
1259
+ case ApiKeyLocation.Header:
1260
+ if (!config.headers) {
1261
+ config.headers = {};
1262
+ }
1263
+ if (config.headers[this.keyName]) {
1264
+ throw new ErrorWithCode(formatString(ErrorMessage.DuplicateApiKeyInHeader, this.keyName), ErrorCode.AuthorizationInfoAlreadyExists);
1265
+ }
1266
+ config.headers[this.keyName] = this.keyValue;
1267
+ break;
1268
+ case ApiKeyLocation.QueryParams:
1269
+ if (!config.params) {
1270
+ config.params = {};
1271
+ }
1272
+ const url = new URL(config.url, config.baseURL);
1273
+ if (config.params[this.keyName] || url.searchParams.has(this.keyName)) {
1274
+ throw new ErrorWithCode(formatString(ErrorMessage.DuplicateApiKeyInQueryParam, this.keyName), ErrorCode.AuthorizationInfoAlreadyExists);
1275
+ }
1276
+ config.params[this.keyName] = this.keyValue;
1277
+ break;
1278
+ }
1279
+ return config;
1280
+ });
1281
+ }
1282
+ }
1283
+ /**
1284
+ * Define available location for API Key location
1285
+ *
1286
+ * @beta
1287
+ */
1288
+ var ApiKeyLocation;
1289
+ (function (ApiKeyLocation) {
1290
+ /**
1291
+ * The API Key is placed in request header
1292
+ */
1293
+ ApiKeyLocation[ApiKeyLocation["Header"] = 0] = "Header";
1294
+ /**
1295
+ * The API Key is placed in query parameter
1296
+ */
1297
+ ApiKeyLocation[ApiKeyLocation["QueryParams"] = 1] = "QueryParams";
1298
+ })(ApiKeyLocation || (ApiKeyLocation = {}));
1299
+
1300
+ // Copyright (c) Microsoft Corporation.
1301
+ /**
1302
+ * Provider that handles Certificate authentication
1303
+ *
1304
+ * @beta
1305
+ */
1306
+ class CertificateAuthProvider {
1307
+ /**
1308
+ *
1309
+ * @param { SecureContextOptions } certOption - information about the cert used in http requests
1310
+ *
1311
+ * @beta
1312
+ */
1313
+ constructor(certOption) {
1314
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CertificateAuthProvider"), ErrorCode.RuntimeNotSupported);
1315
+ }
1316
+ /**
1317
+ * Adds authentication info to http requests.
1318
+ *
1319
+ * @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
1320
+ * Refer https://axios-http.com/docs/req_config for detailed document.
1321
+ *
1322
+ * @returns Updated axios request config.
1323
+ *
1324
+ * @throws {@link ErrorCode|InvalidParameter} - when custom httpsAgent in the request has duplicate properties with certOption provided in constructor.
1325
+ *
1326
+ * @beta
1327
+ */
1328
+ AddAuthenticationInfo(config) {
1329
+ return __awaiter(this, void 0, void 0, function* () {
1330
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CertificateAuthProvider"), ErrorCode.RuntimeNotSupported);
1331
+ });
1332
+ }
1333
+ }
1334
+ /**
1335
+ * Helper to create SecureContextOptions from PEM format cert
1336
+ *
1337
+ * @param { string | Buffer } cert - The cert chain in PEM format
1338
+ * @param { string | Buffer } key - The private key for the cert chain
1339
+ * @param { string? } passphrase - The passphrase for private key
1340
+ * @param { string? | Buffer? } ca - Overrides the trusted CA certificates
1341
+ *
1342
+ * @returns Instance of SecureContextOptions
1343
+ *
1344
+ * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
1345
+ *
1346
+ */
1347
+ function createPemCertOption(cert, key, passphrase, ca) {
1348
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPemCertOption"), ErrorCode.RuntimeNotSupported);
1349
+ }
1350
+ /**
1351
+ * Helper to create SecureContextOptions from PFX format cert
1352
+ *
1353
+ * @param { string | Buffer } pfx - The content of .pfx file
1354
+ * @param { string? } passphrase - Optional. The passphrase of .pfx file
1355
+ *
1356
+ * @returns Instance of SecureContextOptions
1357
+ *
1358
+ * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
1359
+ *
1360
+ */
1361
+ function createPfxCertOption(pfx, passphrase) {
1362
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPfxCertOption"), ErrorCode.RuntimeNotSupported);
1363
+ }
1364
+
1078
1365
  // Copyright (c) Microsoft Corporation.
1079
1366
  // Licensed under the MIT license.
1080
1367
  /**
@@ -1195,5 +1482,415 @@ class TeamsFx {
1195
1482
  }
1196
1483
  }
1197
1484
 
1198
- export { AppCredential, ErrorCode, ErrorWithCode, IdentityType, LogLevel, MsGraphAuthProvider, OnBehalfOfUserCredential, TeamsBotSsoPrompt, TeamsFx, TeamsUserCredential, createMicrosoftGraphClient, getLogLevel, getTediousConnectionConfig, setLogFunction, setLogLevel, setLogger };
1485
+ // Copyright (c) Microsoft Corporation.
1486
+ /**
1487
+ * Provide utilities for bot conversation, including:
1488
+ * - handle command and response.
1489
+ * - send notification to varies targets (e.g., member, group, channel).
1490
+ *
1491
+ * @remarks
1492
+ * Only work on server side.
1493
+ *
1494
+ * @beta
1495
+ */
1496
+ class ConversationBot {
1497
+ /**
1498
+ * Creates new instance of the `ConversationBot`.
1499
+ *
1500
+ * @param options - initialize options
1501
+ *
1502
+ * @remarks
1503
+ * Only work on server side.
1504
+ *
1505
+ * @beta
1506
+ */
1507
+ constructor(options) {
1508
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ConversationBot"), ErrorCode.RuntimeNotSupported);
1509
+ }
1510
+ /**
1511
+ * The request handler to integrate with web request.
1512
+ *
1513
+ * @param req - an Express or Restify style request object.
1514
+ * @param res - an Express or Restify style response object.
1515
+ * @param logic - the additional function to handle bot context.
1516
+ *
1517
+ * @remarks
1518
+ * Only work on server side.
1519
+ *
1520
+ * @beta
1521
+ */
1522
+ requestHandler(req, res, logic) {
1523
+ return __awaiter(this, void 0, void 0, function* () {
1524
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ConversationBot"), ErrorCode.RuntimeNotSupported);
1525
+ });
1526
+ }
1527
+ }
1528
+
1529
+ // Copyright (c) Microsoft Corporation.
1530
+ /**
1531
+ * Send a plain text message to a notification target.
1532
+ *
1533
+ * @remarks
1534
+ * Only work on server side.
1535
+ *
1536
+ * @param target - the notification target.
1537
+ * @param text - the plain text message.
1538
+ * @returns A `Promise` representing the asynchronous operation.
1539
+ *
1540
+ * @beta
1541
+ */
1542
+ function sendMessage(target, text) {
1543
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "sendMessage"), ErrorCode.RuntimeNotSupported);
1544
+ }
1545
+ /**
1546
+ * Send an adaptive card message to a notification target.
1547
+ *
1548
+ * @remarks
1549
+ * Only work on server side.
1550
+ *
1551
+ * @param target - the notification target.
1552
+ * @param card - the adaptive card raw JSON.
1553
+ * @returns A `Promise` representing the asynchronous operation.
1554
+ *
1555
+ * @beta
1556
+ */
1557
+ function sendAdaptiveCard(target, card) {
1558
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "sendAdaptiveCard"), ErrorCode.RuntimeNotSupported);
1559
+ }
1560
+ /**
1561
+ * A {@link NotificationTarget} that represents a team channel.
1562
+ *
1563
+ * @remarks
1564
+ * Only work on server side.
1565
+ *
1566
+ * It's recommended to get channels from {@link TeamsBotInstallation.channels()}.
1567
+ *
1568
+ * @beta
1569
+ */
1570
+ class Channel {
1571
+ /**
1572
+ * Constuctor.
1573
+ *
1574
+ * @remarks
1575
+ * Only work on server side.
1576
+ *
1577
+ * It's recommended to get channels from {@link TeamsBotInstallation.channels()}, instead of using this constructor.
1578
+ *
1579
+ * @param parent - The parent {@link TeamsBotInstallation} where this channel is created from.
1580
+ * @param info - Detailed channel information.
1581
+ *
1582
+ * @beta
1583
+ */
1584
+ constructor(parent, info) {
1585
+ /**
1586
+ * Notification target type. For channel it's always "Channel".
1587
+ *
1588
+ * @remarks
1589
+ * Only work on server side.
1590
+ *
1591
+ * @beta
1592
+ */
1593
+ this.type = "Channel";
1594
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "Channel"), ErrorCode.RuntimeNotSupported);
1595
+ }
1596
+ /**
1597
+ * Send a plain text message.
1598
+ *
1599
+ * @remarks
1600
+ * Only work on server side.
1601
+ *
1602
+ * @param text - the plain text message.
1603
+ * @returns A `Promise` representing the asynchronous operation.
1604
+ *
1605
+ * @beta
1606
+ */
1607
+ sendMessage(text) {
1608
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "Channel"), ErrorCode.RuntimeNotSupported);
1609
+ }
1610
+ /**
1611
+ * Send an adaptive card message.
1612
+ *
1613
+ * @remarks
1614
+ * Only work on server side.
1615
+ *
1616
+ * @param card - the adaptive card raw JSON.
1617
+ * @returns A `Promise` representing the asynchronous operation.
1618
+ *
1619
+ * @beta
1620
+ */
1621
+ sendAdaptiveCard(card) {
1622
+ return __awaiter(this, void 0, void 0, function* () {
1623
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "Channel"), ErrorCode.RuntimeNotSupported);
1624
+ });
1625
+ }
1626
+ }
1627
+ /**
1628
+ * A {@link NotificationTarget} that represents a team member.
1629
+ *
1630
+ * @remarks
1631
+ * Only work on server side.
1632
+ *
1633
+ * It's recommended to get members from {@link TeamsBotInstallation.members()}.
1634
+ *
1635
+ * @beta
1636
+ */
1637
+ class Member {
1638
+ /**
1639
+ * Constuctor.
1640
+ *
1641
+ * @remarks
1642
+ * Only work on server side.
1643
+ *
1644
+ * It's recommended to get members from {@link TeamsBotInstallation.members()}, instead of using this constructor.
1645
+ *
1646
+ * @param parent - The parent {@link TeamsBotInstallation} where this member is created from.
1647
+ * @param account - Detailed member account information.
1648
+ *
1649
+ * @beta
1650
+ */
1651
+ constructor(parent, account) {
1652
+ /**
1653
+ * Notification target type. For member it's always "Person".
1654
+ *
1655
+ * @remarks
1656
+ * Only work on server side.
1657
+ *
1658
+ * @beta
1659
+ */
1660
+ this.type = "Person";
1661
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "Member"), ErrorCode.RuntimeNotSupported);
1662
+ }
1663
+ /**
1664
+ * Send a plain text message.
1665
+ *
1666
+ * @remarks
1667
+ * Only work on server side.
1668
+ *
1669
+ * @param text - the plain text message.
1670
+ * @returns A `Promise` representing the asynchronous operation.
1671
+ *
1672
+ * @beta
1673
+ */
1674
+ sendMessage(text) {
1675
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "Member"), ErrorCode.RuntimeNotSupported);
1676
+ }
1677
+ /**
1678
+ * Send an adaptive card message.
1679
+ *
1680
+ * @remarks
1681
+ * Only work on server side.
1682
+ *
1683
+ * @param card - the adaptive card raw JSON.
1684
+ * @returns A `Promise` representing the asynchronous operation.
1685
+ *
1686
+ * @beta
1687
+ */
1688
+ sendAdaptiveCard(card) {
1689
+ return __awaiter(this, void 0, void 0, function* () {
1690
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "Member"), ErrorCode.RuntimeNotSupported);
1691
+ });
1692
+ }
1693
+ }
1694
+ /**
1695
+ * A {@link NotificationTarget} that represents a bot installation. Teams Bot could be installed into
1696
+ * - Personal chat
1697
+ * - Group chat
1698
+ * - Team (by default the `General` channel)
1699
+ *
1700
+ * @remarks
1701
+ * Only work on server side.
1702
+ *
1703
+ * It's recommended to get bot installations from {@link ConversationBot.installations()}.
1704
+ *
1705
+ * @beta
1706
+ */
1707
+ class TeamsBotInstallation {
1708
+ /**
1709
+ * Constructor
1710
+ *
1711
+ * @remarks
1712
+ * Only work on server side.
1713
+ *
1714
+ * It's recommended to get bot installations from {@link ConversationBot.installations()}, instead of using this constructor.
1715
+ *
1716
+ * @param adapter - the bound `BotFrameworkAdapter`.
1717
+ * @param conversationReference - the bound `ConversationReference`.
1718
+ *
1719
+ * @beta
1720
+ */
1721
+ constructor(adapter, conversationReference) {
1722
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotInstallation"), ErrorCode.RuntimeNotSupported);
1723
+ }
1724
+ /**
1725
+ * Send a plain text message.
1726
+ *
1727
+ * @remarks
1728
+ * Only work on server side.
1729
+ *
1730
+ * @param text - the plain text message.
1731
+ * @returns A `Promise` representing the asynchronous operation.
1732
+ *
1733
+ * @beta
1734
+ */
1735
+ sendMessage(text) {
1736
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotInstallation"), ErrorCode.RuntimeNotSupported);
1737
+ }
1738
+ /**
1739
+ * Send an adaptive card message.
1740
+ *
1741
+ * @remarks
1742
+ * Only work on server side.
1743
+ *
1744
+ * @param card - the adaptive card raw JSON.
1745
+ * @returns A `Promise` representing the asynchronous operation.
1746
+ *
1747
+ * @beta
1748
+ */
1749
+ sendAdaptiveCard(card) {
1750
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotInstallation"), ErrorCode.RuntimeNotSupported);
1751
+ }
1752
+ /**
1753
+ * Get channels from this bot installation.
1754
+ *
1755
+ * @remarks
1756
+ * Only work on server side.
1757
+ *
1758
+ * @returns an array of channels if bot is installed into a team, otherwise returns an empty array.
1759
+ *
1760
+ * @beta
1761
+ */
1762
+ channels() {
1763
+ return __awaiter(this, void 0, void 0, function* () {
1764
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotInstallation"), ErrorCode.RuntimeNotSupported);
1765
+ });
1766
+ }
1767
+ /**
1768
+ * Get members from this bot installation.
1769
+ *
1770
+ * @remarks
1771
+ * Only work on server side.
1772
+ *
1773
+ * @returns an array of members from where the bot is installed.
1774
+ *
1775
+ * @beta
1776
+ */
1777
+ members() {
1778
+ return __awaiter(this, void 0, void 0, function* () {
1779
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotInstallation"), ErrorCode.RuntimeNotSupported);
1780
+ });
1781
+ }
1782
+ }
1783
+ /**
1784
+ * Provide static utilities for bot notification.
1785
+ *
1786
+ * @remarks
1787
+ * Only work on server side.
1788
+ *
1789
+ * @example
1790
+ * Here's an example on how to send notification via Teams Bot.
1791
+ * ```typescript
1792
+ * // initialize (it's recommended to be called before handling any bot message)
1793
+ * const notificationBot = new NotificationBot(adapter);
1794
+ *
1795
+ * // get all bot installations and send message
1796
+ * for (const target of await notificationBot.installations()) {
1797
+ * await target.sendMessage("Hello Notification");
1798
+ * }
1799
+ *
1800
+ * // alternative - send message to all members
1801
+ * for (const target of await notificationBot.installations()) {
1802
+ * for (const member of await target.members()) {
1803
+ * await member.sendMessage("Hello Notification");
1804
+ * }
1805
+ * }
1806
+ * ```
1807
+ *
1808
+ * @beta
1809
+ */
1810
+ class NotificationBot {
1811
+ /**
1812
+ * constructor of the notification bot.
1813
+ *
1814
+ * @remarks
1815
+ * Only work on server side.
1816
+ *
1817
+ * To ensure accuracy, it's recommended to initialize before handling any message.
1818
+ *
1819
+ * @param adapter - the bound `BotFrameworkAdapter`
1820
+ * @param options - initialize options
1821
+ *
1822
+ * @beta
1823
+ */
1824
+ constructor(adapter, options) {
1825
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "NotificationBot"), ErrorCode.RuntimeNotSupported);
1826
+ }
1827
+ /**
1828
+ * Get all targets where the bot is installed.
1829
+ *
1830
+ * @remarks
1831
+ * Only work on server side.
1832
+ *
1833
+ * The result is retrieving from the persisted storage.
1834
+ *
1835
+ * @returns - an array of {@link TeamsBotInstallation}.
1836
+ *
1837
+ * @beta
1838
+ */
1839
+ static installations() {
1840
+ return __awaiter(this, void 0, void 0, function* () {
1841
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "NotificationBot"), ErrorCode.RuntimeNotSupported);
1842
+ });
1843
+ }
1844
+ }
1845
+
1846
+ // Copyright (c) Microsoft Corporation.
1847
+ /**
1848
+ * A command bot for receiving commands and sending responses in Teams.
1849
+ *
1850
+ * @remarks
1851
+ * Only work on server side.
1852
+ *
1853
+ * @beta
1854
+ */
1855
+ class CommandBot {
1856
+ /**
1857
+ * Creates a new instance of the `CommandBot`.
1858
+ *
1859
+ * @param adapter The bound `BotFrameworkAdapter`.
1860
+ * @param commands The commands to registered with the command bot. Each command should implement the interface {@link TeamsFxBotCommandHandler} so that it can be correctly handled by this command bot.
1861
+ *
1862
+ * @beta
1863
+ */
1864
+ constructor(adapter, commands) {
1865
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CommandBot"), ErrorCode.RuntimeNotSupported);
1866
+ }
1867
+ /**
1868
+ * Registers a command into the command bot.
1869
+ *
1870
+ * @param command The command to registered.
1871
+ *
1872
+ * @remarks
1873
+ * Only work on server side.
1874
+ *
1875
+ * @beta
1876
+ */
1877
+ registerCommand(command) {
1878
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CommandBot"), ErrorCode.RuntimeNotSupported);
1879
+ }
1880
+ /**
1881
+ * Registers commands into the command bot.
1882
+ *
1883
+ * @param commands The command to registered.
1884
+ *
1885
+ * @remarks
1886
+ * Only work on server side.
1887
+ *
1888
+ * @beta
1889
+ */
1890
+ registerCommands(commands) {
1891
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CommandnBot"), ErrorCode.RuntimeNotSupported);
1892
+ }
1893
+ }
1894
+
1895
+ export { ApiKeyLocation, ApiKeyProvider, AppCredential, BasicAuthProvider, BearerTokenAuthProvider, CertificateAuthProvider, Channel, CommandBot, ConversationBot, ErrorCode, ErrorWithCode, IdentityType, LogLevel, Member, MsGraphAuthProvider, NotificationBot, OnBehalfOfUserCredential, TeamsBotInstallation, TeamsBotSsoPrompt, TeamsFx, TeamsUserCredential, createApiClient, createMicrosoftGraphClient, createPemCertOption, createPfxCertOption, getLogLevel, getTediousConnectionConfig, sendAdaptiveCard, sendMessage, setLogFunction, setLogLevel, setLogger };
1199
1896
  //# sourceMappingURL=index.esm5.js.map