@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.
@@ -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,9 +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!";
89
96
  // InvalidParameter Error
90
97
  ErrorMessage.EmptyParameter = "Parameter {0} is empty";
91
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}.";
92
101
  /**
93
102
  * Error class with code and message thrown by the SDK.
94
103
  *
@@ -1115,7 +1124,7 @@ function createApiClient(apiEndpoint, authProvider) {
1115
1124
  */
1116
1125
  class BearerTokenAuthProvider {
1117
1126
  /**
1118
- * @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
1119
1128
  *
1120
1129
  * @beta
1121
1130
  */
@@ -1125,9 +1134,13 @@ class BearerTokenAuthProvider {
1125
1134
  /**
1126
1135
  * Adds authentication info to http requests
1127
1136
  *
1128
- * @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.
1129
1138
  * Refer https://axios-http.com/docs/req_config for detailed document.
1130
1139
  *
1140
+ * @returns Updated axios request config.
1141
+ *
1142
+ * @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header already exists in request configuration.
1143
+ *
1131
1144
  * @beta
1132
1145
  */
1133
1146
  AddAuthenticationInfo(config) {
@@ -1137,7 +1150,7 @@ class BearerTokenAuthProvider {
1137
1150
  config.headers = {};
1138
1151
  }
1139
1152
  if (config.headers["Authorization"]) {
1140
- throw new Error("Authorization header already exists!");
1153
+ throw new ErrorWithCode(ErrorMessage.AuthorizationHeaderAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
1141
1154
  }
1142
1155
  config.headers["Authorization"] = `Bearer ${token}`;
1143
1156
  return config;
@@ -1145,6 +1158,103 @@ class BearerTokenAuthProvider {
1145
1158
  }
1146
1159
  }
1147
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
+
1148
1258
  // Copyright (c) Microsoft Corporation.
1149
1259
  /**
1150
1260
  * Provider that handles Certificate authentication
@@ -1170,6 +1280,7 @@ class CertificateAuthProvider {
1170
1280
  * @returns Updated axios request config.
1171
1281
  *
1172
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.
1173
1284
  *
1174
1285
  * @beta
1175
1286
  */
@@ -1184,29 +1295,30 @@ class CertificateAuthProvider {
1184
1295
  *
1185
1296
  * @param { string | Buffer } cert - The cert chain in PEM format
1186
1297
  * @param { string | Buffer } key - The private key for the cert chain
1187
- * @param { string? } passphrase - The passphrase for private key
1188
- * @param { string? | Buffer? } ca - Overrides the trusted CA certificates
1298
+ * @param { {passphrase?: string; ca?: string | Buffer} } options - Optional settings when create the cert options.
1189
1299
  *
1190
1300
  * @returns Instance of SecureContextOptions
1191
1301
  *
1192
1302
  * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
1303
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1193
1304
  *
1194
1305
  */
1195
- function createPemCertOption(cert, key, passphrase, ca) {
1306
+ function createPemCertOption(cert, key, options) {
1196
1307
  throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPemCertOption"), ErrorCode.RuntimeNotSupported);
1197
1308
  }
1198
1309
  /**
1199
1310
  * Helper to create SecureContextOptions from PFX format cert
1200
1311
  *
1201
1312
  * @param { string | Buffer } pfx - The content of .pfx file
1202
- * @param { string? } passphrase - Optional. The passphrase of .pfx file
1313
+ * @param { {passphrase?: string} } options - Optional settings when create the cert options.
1203
1314
  *
1204
1315
  * @returns Instance of SecureContextOptions
1205
1316
  *
1206
1317
  * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
1318
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1207
1319
  *
1208
1320
  */
1209
- function createPfxCertOption(pfx, passphrase) {
1321
+ function createPfxCertOption(pfx, options) {
1210
1322
  throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPfxCertOption"), ErrorCode.RuntimeNotSupported);
1211
1323
  }
1212
1324
 
@@ -1740,5 +1852,5 @@ class CommandBot {
1740
1852
  }
1741
1853
  }
1742
1854
 
1743
- 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 };
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 };
1744
1856
  //# sourceMappingURL=index.esm5.js.map