@microsoft/teamsfx 0.6.3-alpha.633d9d21e.0 → 0.6.3-alpha.6b8bcebfe.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,9 +89,14 @@ 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!";
88
95
  // InvalidParameter Error
89
96
  ErrorMessage.EmptyParameter = "Parameter {0} is empty";
90
97
  ErrorMessage.DuplicateHttpsOptionProperty = "Axios HTTPS agent already defined value for property {0}";
98
+ ErrorMessage.DuplicateApiKeyInHeader = "The request already defined api key in request header with name {0}.";
99
+ ErrorMessage.DuplicateApiKeyInQueryParam = "The request already defined api key in query parameter with name {0}.";
91
100
  /**
92
101
  * Error class with code and message thrown by the SDK.
93
102
  *
@@ -1085,7 +1094,6 @@ function createApiClient(apiEndpoint, authProvider) {
1085
1094
  }
1086
1095
 
1087
1096
  // Copyright (c) Microsoft Corporation.
1088
- // Licensed under the MIT license.
1089
1097
  /**
1090
1098
  * Provider that handles Bearer Token authentication
1091
1099
  *
@@ -1093,7 +1101,7 @@ function createApiClient(apiEndpoint, authProvider) {
1093
1101
  */
1094
1102
  class BearerTokenAuthProvider {
1095
1103
  /**
1096
- * @param getToken Function that returns the content of bearer token used in http request
1104
+ * @param { () => Promise<string> } getToken - Function that returns the content of bearer token used in http request
1097
1105
  *
1098
1106
  * @beta
1099
1107
  */
@@ -1103,9 +1111,13 @@ class BearerTokenAuthProvider {
1103
1111
  /**
1104
1112
  * Adds authentication info to http requests
1105
1113
  *
1106
- * @param config - Contains all the request information and can be updated to include extra authentication info.
1114
+ * @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
1107
1115
  * Refer https://axios-http.com/docs/req_config for detailed document.
1108
1116
  *
1117
+ * @returns Updated axios request config.
1118
+ *
1119
+ * @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header already exists in request configuration.
1120
+ *
1109
1121
  * @beta
1110
1122
  */
1111
1123
  async AddAuthenticationInfo(config) {
@@ -1114,13 +1126,106 @@ class BearerTokenAuthProvider {
1114
1126
  config.headers = {};
1115
1127
  }
1116
1128
  if (config.headers["Authorization"]) {
1117
- throw new Error("Authorization header already exists!");
1129
+ throw new ErrorWithCode(ErrorMessage.AuthorizationHeaderAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
1118
1130
  }
1119
1131
  config.headers["Authorization"] = `Bearer ${token}`;
1120
1132
  return config;
1121
1133
  }
1122
1134
  }
1123
1135
 
1136
+ // Copyright (c) Microsoft Corporation.
1137
+ /**
1138
+ * Provider that handles Basic authentication
1139
+ *
1140
+ * @beta
1141
+ */
1142
+ class BasicAuthProvider {
1143
+ /**
1144
+ *
1145
+ * @param { string } userName - Username used in basic auth
1146
+ * @param { string } password - Password used in basic auth
1147
+ *
1148
+ * @throws {@link ErrorCode|InvalidParameter} - when username or password is empty.
1149
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1150
+ *
1151
+ * @beta
1152
+ */
1153
+ constructor(userName, password) {
1154
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BasicAuthProvider"), ErrorCode.RuntimeNotSupported);
1155
+ }
1156
+ /**
1157
+ * Adds authentication info to http requests
1158
+ *
1159
+ * @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
1160
+ * Refer https://axios-http.com/docs/req_config for detailed document.
1161
+ *
1162
+ * @returns Updated axios request config.
1163
+ *
1164
+ * @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header or auth property already exists in request configuration.
1165
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1166
+ *
1167
+ * @beta
1168
+ */
1169
+ async AddAuthenticationInfo(config) {
1170
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BasicAuthProvider"), ErrorCode.RuntimeNotSupported);
1171
+ }
1172
+ }
1173
+
1174
+ // Copyright (c) Microsoft Corporation.
1175
+ /**
1176
+ * Provider that handles API Key authentication
1177
+ *
1178
+ * @beta
1179
+ */
1180
+ class ApiKeyProvider {
1181
+ /**
1182
+ *
1183
+ * @param { string } keyName - The name of request header or query parameter that specifies API Key
1184
+ * @param { string } keyValue - The value of API Key
1185
+ * @param { ApiKeyLocation } keyLocation - The location of API Key: request header or query parameter.
1186
+ *
1187
+ * @throws {@link ErrorCode|InvalidParameter} - when key name or key value is empty.
1188
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1189
+ *
1190
+ * @beta
1191
+ */
1192
+ constructor(keyName, keyValue, keyLocation) {
1193
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ApiKeyProvider"), ErrorCode.RuntimeNotSupported);
1194
+ }
1195
+ /**
1196
+ * Adds authentication info to http requests
1197
+ *
1198
+ * @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
1199
+ * Refer https://axios-http.com/docs/req_config for detailed document.
1200
+ *
1201
+ * @returns Updated axios request config.
1202
+ *
1203
+ * @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when API key already exists in request header or url query parameter.
1204
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1205
+ *
1206
+ * @beta
1207
+ */
1208
+ async AddAuthenticationInfo(config) {
1209
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ApiKeyProvider"), ErrorCode.RuntimeNotSupported);
1210
+ }
1211
+ }
1212
+ /**
1213
+ * Define available location for API Key location
1214
+ *
1215
+ * @beta
1216
+ */
1217
+ var ApiKeyLocation;
1218
+ (function (ApiKeyLocation) {
1219
+ /**
1220
+ * The API Key is placed in request header
1221
+ */
1222
+ ApiKeyLocation[ApiKeyLocation["Header"] = 0] = "Header";
1223
+ /**
1224
+ * The API Key is placed in query parameter
1225
+ */
1226
+ ApiKeyLocation[ApiKeyLocation["QueryParams"] = 1] = "QueryParams";
1227
+ })(ApiKeyLocation || (ApiKeyLocation = {}));
1228
+
1124
1229
  // Copyright (c) Microsoft Corporation.
1125
1230
  /**
1126
1231
  * Provider that handles Certificate authentication
@@ -1146,6 +1251,7 @@ class CertificateAuthProvider {
1146
1251
  * @returns Updated axios request config.
1147
1252
  *
1148
1253
  * @throws {@link ErrorCode|InvalidParameter} - when custom httpsAgent in the request has duplicate properties with certOption provided in constructor.
1254
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1149
1255
  *
1150
1256
  * @beta
1151
1257
  */
@@ -1158,29 +1264,30 @@ class CertificateAuthProvider {
1158
1264
  *
1159
1265
  * @param { string | Buffer } cert - The cert chain in PEM format
1160
1266
  * @param { string | Buffer } key - The private key for the cert chain
1161
- * @param { string? } passphrase - The passphrase for private key
1162
- * @param { string? | Buffer? } ca - Overrides the trusted CA certificates
1267
+ * @param { {passphrase?: string; ca?: string | Buffer} } options - Optional settings when create the cert options.
1163
1268
  *
1164
1269
  * @returns Instance of SecureContextOptions
1165
1270
  *
1166
1271
  * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
1272
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1167
1273
  *
1168
1274
  */
1169
- function createPemCertOption(cert, key, passphrase, ca) {
1275
+ function createPemCertOption(cert, key, options) {
1170
1276
  throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPemCertOption"), ErrorCode.RuntimeNotSupported);
1171
1277
  }
1172
1278
  /**
1173
1279
  * Helper to create SecureContextOptions from PFX format cert
1174
1280
  *
1175
1281
  * @param { string | Buffer } pfx - The content of .pfx file
1176
- * @param { string? } passphrase - Optional. The passphrase of .pfx file
1282
+ * @param { {passphrase?: string} } options - Optional settings when create the cert options.
1177
1283
  *
1178
1284
  * @returns Instance of SecureContextOptions
1179
1285
  *
1180
1286
  * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
1287
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1181
1288
  *
1182
1289
  */
1183
- function createPfxCertOption(pfx, passphrase) {
1290
+ function createPfxCertOption(pfx, options) {
1184
1291
  throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPfxCertOption"), ErrorCode.RuntimeNotSupported);
1185
1292
  }
1186
1293
 
@@ -1698,5 +1805,5 @@ class CommandBot {
1698
1805
  }
1699
1806
  }
1700
1807
 
1701
- export { AppCredential, 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 };
1808
+ 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 };
1702
1809
  //# sourceMappingURL=index.esm2017.js.map