@microsoft/teamsfx 0.6.3-alpha.f018de6e6.0 → 0.6.3-alpha.f6638b461.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.
@@ -96,6 +96,8 @@ ErrorMessage.BasicCredentialAlreadyExists = "Basic credential already exists!";
96
96
  // InvalidParameter Error
97
97
  ErrorMessage.EmptyParameter = "Parameter {0} is empty";
98
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}.";
99
101
  /**
100
102
  * Error class with code and message thrown by the SDK.
101
103
  *
@@ -1122,7 +1124,7 @@ function createApiClient(apiEndpoint, authProvider) {
1122
1124
  */
1123
1125
  class BearerTokenAuthProvider {
1124
1126
  /**
1125
- * @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
1126
1128
  *
1127
1129
  * @beta
1128
1130
  */
@@ -1132,7 +1134,7 @@ class BearerTokenAuthProvider {
1132
1134
  /**
1133
1135
  * Adds authentication info to http requests
1134
1136
  *
1135
- * @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.
1136
1138
  * Refer https://axios-http.com/docs/req_config for detailed document.
1137
1139
  *
1138
1140
  * @returns Updated axios request config.
@@ -1165,50 +1167,94 @@ class BearerTokenAuthProvider {
1165
1167
  class BasicAuthProvider {
1166
1168
  /**
1167
1169
  *
1168
- * @param userName - Username used in basic auth
1169
- * @param password - Password used in basic auth
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.
1170
1175
  *
1171
1176
  * @beta
1172
1177
  */
1173
1178
  constructor(userName, password) {
1174
- if (!userName) {
1175
- throw new ErrorWithCode(formatString(ErrorMessage.EmptyParameter, "username"), ErrorCode.InvalidParameter);
1176
- }
1177
- if (!password) {
1178
- throw new ErrorWithCode(formatString(ErrorMessage.EmptyParameter, "password"), ErrorCode.InvalidParameter);
1179
- }
1180
- this.userName = userName;
1181
- this.password = password;
1179
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BasicAuthProvider"), ErrorCode.RuntimeNotSupported);
1182
1180
  }
1183
1181
  /**
1184
1182
  * Adds authentication info to http requests
1185
1183
  *
1186
- * @param config - Contains all the request information and can be updated to include extra authentication info.
1184
+ * @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
1187
1185
  * Refer https://axios-http.com/docs/req_config for detailed document.
1188
1186
  *
1189
1187
  * @returns Updated axios request config.
1190
1188
  *
1191
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.
1192
1191
  *
1193
1192
  * @beta
1194
1193
  */
1195
1194
  AddAuthenticationInfo(config) {
1196
1195
  return __awaiter(this, void 0, void 0, function* () {
1197
- if (config.headers && config.headers["Authorization"]) {
1198
- throw new ErrorWithCode(ErrorMessage.AuthorizationHeaderAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
1199
- }
1200
- if (config.auth) {
1201
- throw new ErrorWithCode(ErrorMessage.BasicCredentialAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
1202
- }
1203
- config.auth = {
1204
- username: this.userName,
1205
- password: this.password,
1206
- };
1207
- return config;
1196
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BasicAuthProvider"), ErrorCode.RuntimeNotSupported);
1208
1197
  });
1209
1198
  }
1210
1199
  }
1211
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
+
1212
1258
  // Copyright (c) Microsoft Corporation.
1213
1259
  /**
1214
1260
  * Provider that handles Certificate authentication
@@ -1234,6 +1280,7 @@ class CertificateAuthProvider {
1234
1280
  * @returns Updated axios request config.
1235
1281
  *
1236
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.
1237
1284
  *
1238
1285
  * @beta
1239
1286
  */
@@ -1248,29 +1295,30 @@ class CertificateAuthProvider {
1248
1295
  *
1249
1296
  * @param { string | Buffer } cert - The cert chain in PEM format
1250
1297
  * @param { string | Buffer } key - The private key for the cert chain
1251
- * @param { string? } passphrase - The passphrase for private key
1252
- * @param { string? | Buffer? } ca - Overrides the trusted CA certificates
1298
+ * @param { {passphrase?: string; ca?: string | Buffer} } options - Optional settings when create the cert options.
1253
1299
  *
1254
1300
  * @returns Instance of SecureContextOptions
1255
1301
  *
1256
1302
  * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
1303
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1257
1304
  *
1258
1305
  */
1259
- function createPemCertOption(cert, key, passphrase, ca) {
1306
+ function createPemCertOption(cert, key, options) {
1260
1307
  throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPemCertOption"), ErrorCode.RuntimeNotSupported);
1261
1308
  }
1262
1309
  /**
1263
1310
  * Helper to create SecureContextOptions from PFX format cert
1264
1311
  *
1265
1312
  * @param { string | Buffer } pfx - The content of .pfx file
1266
- * @param { string? } passphrase - Optional. The passphrase of .pfx file
1313
+ * @param { {passphrase?: string} } options - Optional settings when create the cert options.
1267
1314
  *
1268
1315
  * @returns Instance of SecureContextOptions
1269
1316
  *
1270
1317
  * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
1318
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1271
1319
  *
1272
1320
  */
1273
- function createPfxCertOption(pfx, passphrase) {
1321
+ function createPfxCertOption(pfx, options) {
1274
1322
  throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPfxCertOption"), ErrorCode.RuntimeNotSupported);
1275
1323
  }
1276
1324
 
@@ -1804,5 +1852,5 @@ class CommandBot {
1804
1852
  }
1805
1853
  }
1806
1854
 
1807
- 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 };
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 };
1808
1856
  //# sourceMappingURL=index.esm5.js.map