@microsoft/teamsfx 0.6.3-alpha.8d048e1f1.0 → 0.6.3-alpha.f018de6e6.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.
@@ -64,6 +64,10 @@ var ErrorCode;
64
64
  * Identity type error.
65
65
  */
66
66
  ErrorCode["IdentityTypeNotSupported"] = "IdentityTypeNotSupported";
67
+ /**
68
+ * Authentication info already exists error.
69
+ */
70
+ ErrorCode["AuthorizationInfoAlreadyExists"] = "AuthorizationInfoAlreadyExists";
67
71
  })(ErrorCode || (ErrorCode = {}));
68
72
  /**
69
73
  * @internal
@@ -85,6 +89,12 @@ ErrorMessage.FailToAcquireTokenOnBehalfOfUser = "Failed to acquire access token
85
89
  ErrorMessage.OnlyMSTeamsChannelSupported = "{0} is only supported in MS Teams Channel";
86
90
  // IdentityTypeNotSupported Error
87
91
  ErrorMessage.IdentityTypeNotSupported = "{0} identity is not supported in {1}";
92
+ // AuthorizationInfoError
93
+ ErrorMessage.AuthorizationHeaderAlreadyExists = "Authorization header already exists!";
94
+ ErrorMessage.BasicCredentialAlreadyExists = "Basic credential already exists!";
95
+ // InvalidParameter Error
96
+ ErrorMessage.EmptyParameter = "Parameter {0} is empty";
97
+ ErrorMessage.DuplicateHttpsOptionProperty = "Axios HTTPS agent already defined value for property {0}";
88
98
  /**
89
99
  * Error class with code and message thrown by the SDK.
90
100
  *
@@ -1082,7 +1092,6 @@ function createApiClient(apiEndpoint, authProvider) {
1082
1092
  }
1083
1093
 
1084
1094
  // Copyright (c) Microsoft Corporation.
1085
- // Licensed under the MIT license.
1086
1095
  /**
1087
1096
  * Provider that handles Bearer Token authentication
1088
1097
  *
@@ -1103,6 +1112,10 @@ class BearerTokenAuthProvider {
1103
1112
  * @param config - Contains all the request information and can be updated to include extra authentication info.
1104
1113
  * Refer https://axios-http.com/docs/req_config for detailed document.
1105
1114
  *
1115
+ * @returns Updated axios request config.
1116
+ *
1117
+ * @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header already exists in request configuration.
1118
+ *
1106
1119
  * @beta
1107
1120
  */
1108
1121
  async AddAuthenticationInfo(config) {
@@ -1111,13 +1124,127 @@ class BearerTokenAuthProvider {
1111
1124
  config.headers = {};
1112
1125
  }
1113
1126
  if (config.headers["Authorization"]) {
1114
- throw new Error("Authorization header already exists!");
1127
+ throw new ErrorWithCode(ErrorMessage.AuthorizationHeaderAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
1115
1128
  }
1116
1129
  config.headers["Authorization"] = `Bearer ${token}`;
1117
1130
  return config;
1118
1131
  }
1119
1132
  }
1120
1133
 
1134
+ // Copyright (c) Microsoft Corporation.
1135
+ /**
1136
+ * Provider that handles Basic authentication
1137
+ *
1138
+ * @beta
1139
+ */
1140
+ class BasicAuthProvider {
1141
+ /**
1142
+ *
1143
+ * @param userName - Username used in basic auth
1144
+ * @param password - Password used in basic auth
1145
+ *
1146
+ * @beta
1147
+ */
1148
+ constructor(userName, password) {
1149
+ if (!userName) {
1150
+ throw new ErrorWithCode(formatString(ErrorMessage.EmptyParameter, "username"), ErrorCode.InvalidParameter);
1151
+ }
1152
+ if (!password) {
1153
+ throw new ErrorWithCode(formatString(ErrorMessage.EmptyParameter, "password"), ErrorCode.InvalidParameter);
1154
+ }
1155
+ this.userName = userName;
1156
+ this.password = password;
1157
+ }
1158
+ /**
1159
+ * Adds authentication info to http requests
1160
+ *
1161
+ * @param config - Contains all the request information and can be updated to include extra authentication info.
1162
+ * Refer https://axios-http.com/docs/req_config for detailed document.
1163
+ *
1164
+ * @returns Updated axios request config.
1165
+ *
1166
+ * @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header or auth property already exists in request configuration.
1167
+ *
1168
+ * @beta
1169
+ */
1170
+ async AddAuthenticationInfo(config) {
1171
+ if (config.headers && config.headers["Authorization"]) {
1172
+ throw new ErrorWithCode(ErrorMessage.AuthorizationHeaderAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
1173
+ }
1174
+ if (config.auth) {
1175
+ throw new ErrorWithCode(ErrorMessage.BasicCredentialAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
1176
+ }
1177
+ config.auth = {
1178
+ username: this.userName,
1179
+ password: this.password,
1180
+ };
1181
+ return config;
1182
+ }
1183
+ }
1184
+
1185
+ // Copyright (c) Microsoft Corporation.
1186
+ /**
1187
+ * Provider that handles Certificate authentication
1188
+ *
1189
+ * @beta
1190
+ */
1191
+ class CertificateAuthProvider {
1192
+ /**
1193
+ *
1194
+ * @param { SecureContextOptions } certOption - information about the cert used in http requests
1195
+ *
1196
+ * @beta
1197
+ */
1198
+ constructor(certOption) {
1199
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CertificateAuthProvider"), ErrorCode.RuntimeNotSupported);
1200
+ }
1201
+ /**
1202
+ * Adds authentication info to http requests.
1203
+ *
1204
+ * @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
1205
+ * Refer https://axios-http.com/docs/req_config for detailed document.
1206
+ *
1207
+ * @returns Updated axios request config.
1208
+ *
1209
+ * @throws {@link ErrorCode|InvalidParameter} - when custom httpsAgent in the request has duplicate properties with certOption provided in constructor.
1210
+ *
1211
+ * @beta
1212
+ */
1213
+ async AddAuthenticationInfo(config) {
1214
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CertificateAuthProvider"), ErrorCode.RuntimeNotSupported);
1215
+ }
1216
+ }
1217
+ /**
1218
+ * Helper to create SecureContextOptions from PEM format cert
1219
+ *
1220
+ * @param { string | Buffer } cert - The cert chain in PEM format
1221
+ * @param { string | Buffer } key - The private key for the cert chain
1222
+ * @param { string? } passphrase - The passphrase for private key
1223
+ * @param { string? | Buffer? } ca - Overrides the trusted CA certificates
1224
+ *
1225
+ * @returns Instance of SecureContextOptions
1226
+ *
1227
+ * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
1228
+ *
1229
+ */
1230
+ function createPemCertOption(cert, key, passphrase, ca) {
1231
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPemCertOption"), ErrorCode.RuntimeNotSupported);
1232
+ }
1233
+ /**
1234
+ * Helper to create SecureContextOptions from PFX format cert
1235
+ *
1236
+ * @param { string | Buffer } pfx - The content of .pfx file
1237
+ * @param { string? } passphrase - Optional. The passphrase of .pfx file
1238
+ *
1239
+ * @returns Instance of SecureContextOptions
1240
+ *
1241
+ * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
1242
+ *
1243
+ */
1244
+ function createPfxCertOption(pfx, passphrase) {
1245
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPfxCertOption"), ErrorCode.RuntimeNotSupported);
1246
+ }
1247
+
1121
1248
  // Copyright (c) Microsoft Corporation.
1122
1249
  // Licensed under the MIT license.
1123
1250
  /**
@@ -1238,7 +1365,7 @@ class TeamsFx {
1238
1365
  /**
1239
1366
  * Provide utilities for bot conversation, including:
1240
1367
  * - handle command and response.
1241
- * - send notification to varies targets (e.g., member, channel, incoming wehbook).
1368
+ * - send notification to varies targets (e.g., member, group, channel).
1242
1369
  *
1243
1370
  * @remarks
1244
1371
  * Only work on server side.
@@ -1259,6 +1386,21 @@ class ConversationBot {
1259
1386
  constructor(options) {
1260
1387
  throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ConversationBot"), ErrorCode.RuntimeNotSupported);
1261
1388
  }
1389
+ /**
1390
+ * The request handler to integrate with web request.
1391
+ *
1392
+ * @param req - an Express or Restify style request object.
1393
+ * @param res - an Express or Restify style response object.
1394
+ * @param logic - the additional function to handle bot context.
1395
+ *
1396
+ * @remarks
1397
+ * Only work on server side.
1398
+ *
1399
+ * @beta
1400
+ */
1401
+ async requestHandler(req, res, logic) {
1402
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ConversationBot"), ErrorCode.RuntimeNotSupported);
1403
+ }
1262
1404
  }
1263
1405
 
1264
1406
  // Copyright (c) Microsoft Corporation.
@@ -1617,5 +1759,5 @@ class CommandBot {
1617
1759
  }
1618
1760
  }
1619
1761
 
1620
- export { AppCredential, BearerTokenAuthProvider, Channel, CommandBot, ConversationBot, ErrorCode, ErrorWithCode, IdentityType, LogLevel, Member, MsGraphAuthProvider, NotificationBot, OnBehalfOfUserCredential, TeamsBotInstallation, TeamsBotSsoPrompt, TeamsFx, TeamsUserCredential, createApiClient, createMicrosoftGraphClient, getLogLevel, getTediousConnectionConfig, sendAdaptiveCard, sendMessage, setLogFunction, setLogLevel, setLogger };
1762
+ export { 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 };
1621
1763
  //# sourceMappingURL=index.esm2017.js.map