@microsoft/teamsfx 0.6.3-alpha.768a76f6e.0 → 0.6.3-alpha.8178ded9d.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.
@@ -65,6 +65,10 @@ var ErrorCode;
65
65
  * Identity type error.
66
66
  */
67
67
  ErrorCode["IdentityTypeNotSupported"] = "IdentityTypeNotSupported";
68
+ /**
69
+ * Authentication info already exists error.
70
+ */
71
+ ErrorCode["AuthorizationInfoAlreadyExists"] = "AuthorizationInfoAlreadyExists";
68
72
  })(ErrorCode || (ErrorCode = {}));
69
73
  /**
70
74
  * @internal
@@ -86,6 +90,14 @@ ErrorMessage.FailToAcquireTokenOnBehalfOfUser = "Failed to acquire access token
86
90
  ErrorMessage.OnlyMSTeamsChannelSupported = "{0} is only supported in MS Teams Channel";
87
91
  // IdentityTypeNotSupported Error
88
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}.";
89
101
  /**
90
102
  * Error class with code and message thrown by the SDK.
91
103
  *
@@ -1112,7 +1124,7 @@ function createApiClient(apiEndpoint, authProvider) {
1112
1124
  */
1113
1125
  class BearerTokenAuthProvider {
1114
1126
  /**
1115
- * @param getToken Function that returns the content of bearer token used in http request
1127
+ * @param { () => Promise<string> } getToken - Function that returns the content of bearer token used in http request
1116
1128
  *
1117
1129
  * @beta
1118
1130
  */
@@ -1122,9 +1134,13 @@ class BearerTokenAuthProvider {
1122
1134
  /**
1123
1135
  * Adds authentication info to http requests
1124
1136
  *
1125
- * @param config - Contains all the request information and can be updated to include extra authentication info.
1137
+ * @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
1126
1138
  * Refer https://axios-http.com/docs/req_config for detailed document.
1127
1139
  *
1140
+ * @returns Updated axios request config.
1141
+ *
1142
+ * @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header already exists in request configuration.
1143
+ *
1128
1144
  * @beta
1129
1145
  */
1130
1146
  AddAuthenticationInfo(config) {
@@ -1134,7 +1150,7 @@ class BearerTokenAuthProvider {
1134
1150
  config.headers = {};
1135
1151
  }
1136
1152
  if (config.headers["Authorization"]) {
1137
- throw new Error("Authorization header already exists!");
1153
+ throw new ErrorWithCode(ErrorMessage.AuthorizationHeaderAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
1138
1154
  }
1139
1155
  config.headers["Authorization"] = `Bearer ${token}`;
1140
1156
  return config;
@@ -1142,6 +1158,170 @@ class BearerTokenAuthProvider {
1142
1158
  }
1143
1159
  }
1144
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
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1175
+ *
1176
+ * @beta
1177
+ */
1178
+ constructor(userName, password) {
1179
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BasicAuthProvider"), ErrorCode.RuntimeNotSupported);
1180
+ }
1181
+ /**
1182
+ * Adds authentication info to http requests
1183
+ *
1184
+ * @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
1185
+ * Refer https://axios-http.com/docs/req_config for detailed document.
1186
+ *
1187
+ * @returns Updated axios request config.
1188
+ *
1189
+ * @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header or auth property already exists in request configuration.
1190
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1191
+ *
1192
+ * @beta
1193
+ */
1194
+ AddAuthenticationInfo(config) {
1195
+ return __awaiter(this, void 0, void 0, function* () {
1196
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BasicAuthProvider"), ErrorCode.RuntimeNotSupported);
1197
+ });
1198
+ }
1199
+ }
1200
+
1201
+ // Copyright (c) Microsoft Corporation.
1202
+ /**
1203
+ * Provider that handles API Key authentication
1204
+ *
1205
+ * @beta
1206
+ */
1207
+ class ApiKeyProvider {
1208
+ /**
1209
+ *
1210
+ * @param { string } keyName - The name of request header or query parameter that specifies API Key
1211
+ * @param { string } keyValue - The value of API Key
1212
+ * @param { ApiKeyLocation } keyLocation - The location of API Key: request header or query parameter.
1213
+ *
1214
+ * @throws {@link ErrorCode|InvalidParameter} - when key name or key value is empty.
1215
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1216
+ *
1217
+ * @beta
1218
+ */
1219
+ constructor(keyName, keyValue, keyLocation) {
1220
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ApiKeyProvider"), ErrorCode.RuntimeNotSupported);
1221
+ }
1222
+ /**
1223
+ * Adds authentication info to http requests
1224
+ *
1225
+ * @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
1226
+ * Refer https://axios-http.com/docs/req_config for detailed document.
1227
+ *
1228
+ * @returns Updated axios request config.
1229
+ *
1230
+ * @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when API key already exists in request header or url query parameter.
1231
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1232
+ *
1233
+ * @beta
1234
+ */
1235
+ AddAuthenticationInfo(config) {
1236
+ return __awaiter(this, void 0, void 0, function* () {
1237
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ApiKeyProvider"), ErrorCode.RuntimeNotSupported);
1238
+ });
1239
+ }
1240
+ }
1241
+ /**
1242
+ * Define available location for API Key location
1243
+ *
1244
+ * @beta
1245
+ */
1246
+ var ApiKeyLocation;
1247
+ (function (ApiKeyLocation) {
1248
+ /**
1249
+ * The API Key is placed in request header
1250
+ */
1251
+ ApiKeyLocation[ApiKeyLocation["Header"] = 0] = "Header";
1252
+ /**
1253
+ * The API Key is placed in query parameter
1254
+ */
1255
+ ApiKeyLocation[ApiKeyLocation["QueryParams"] = 1] = "QueryParams";
1256
+ })(ApiKeyLocation || (ApiKeyLocation = {}));
1257
+
1258
+ // Copyright (c) Microsoft Corporation.
1259
+ /**
1260
+ * Provider that handles Certificate authentication
1261
+ *
1262
+ * @beta
1263
+ */
1264
+ class CertificateAuthProvider {
1265
+ /**
1266
+ *
1267
+ * @param { SecureContextOptions } certOption - information about the cert used in http requests
1268
+ *
1269
+ * @beta
1270
+ */
1271
+ constructor(certOption) {
1272
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CertificateAuthProvider"), ErrorCode.RuntimeNotSupported);
1273
+ }
1274
+ /**
1275
+ * Adds authentication info to http requests.
1276
+ *
1277
+ * @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
1278
+ * Refer https://axios-http.com/docs/req_config for detailed document.
1279
+ *
1280
+ * @returns Updated axios request config.
1281
+ *
1282
+ * @throws {@link ErrorCode|InvalidParameter} - when custom httpsAgent in the request has duplicate properties with certOption provided in constructor.
1283
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1284
+ *
1285
+ * @beta
1286
+ */
1287
+ AddAuthenticationInfo(config) {
1288
+ return __awaiter(this, void 0, void 0, function* () {
1289
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CertificateAuthProvider"), ErrorCode.RuntimeNotSupported);
1290
+ });
1291
+ }
1292
+ }
1293
+ /**
1294
+ * Helper to create SecureContextOptions from PEM format cert
1295
+ *
1296
+ * @param { string | Buffer } cert - The cert chain in PEM format
1297
+ * @param { string | Buffer } key - The private key for the cert chain
1298
+ * @param { {passphrase?: string; ca?: string | Buffer} } options - Optional settings when create the cert options.
1299
+ *
1300
+ * @returns Instance of SecureContextOptions
1301
+ *
1302
+ * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
1303
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1304
+ *
1305
+ */
1306
+ function createPemCertOption(cert, key, options) {
1307
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPemCertOption"), ErrorCode.RuntimeNotSupported);
1308
+ }
1309
+ /**
1310
+ * Helper to create SecureContextOptions from PFX format cert
1311
+ *
1312
+ * @param { string | Buffer } pfx - The content of .pfx file
1313
+ * @param { {passphrase?: string} } options - Optional settings when create the cert options.
1314
+ *
1315
+ * @returns Instance of SecureContextOptions
1316
+ *
1317
+ * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
1318
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1319
+ *
1320
+ */
1321
+ function createPfxCertOption(pfx, options) {
1322
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPfxCertOption"), ErrorCode.RuntimeNotSupported);
1323
+ }
1324
+
1145
1325
  // Copyright (c) Microsoft Corporation.
1146
1326
  // Licensed under the MIT license.
1147
1327
  /**
@@ -1672,5 +1852,5 @@ class CommandBot {
1672
1852
  }
1673
1853
  }
1674
1854
 
1675
- 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 };
1855
+ 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 };
1676
1856
  //# sourceMappingURL=index.esm5.js.map