@microsoft/teamsfx 0.6.3-alpha.266fa3b9f.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.
@@ -1171,18 +1171,12 @@ class BasicAuthProvider {
1171
1171
  * @param { string } password - Password used in basic auth
1172
1172
  *
1173
1173
  * @throws {@link ErrorCode|InvalidParameter} - when username or password is empty.
1174
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1174
1175
  *
1175
1176
  * @beta
1176
1177
  */
1177
1178
  constructor(userName, password) {
1178
- if (!userName) {
1179
- throw new ErrorWithCode(formatString(ErrorMessage.EmptyParameter, "username"), ErrorCode.InvalidParameter);
1180
- }
1181
- if (!password) {
1182
- throw new ErrorWithCode(formatString(ErrorMessage.EmptyParameter, "password"), ErrorCode.InvalidParameter);
1183
- }
1184
- this.userName = userName;
1185
- this.password = password;
1179
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BasicAuthProvider"), ErrorCode.RuntimeNotSupported);
1186
1180
  }
1187
1181
  /**
1188
1182
  * Adds authentication info to http requests
@@ -1193,22 +1187,13 @@ class BasicAuthProvider {
1193
1187
  * @returns Updated axios request config.
1194
1188
  *
1195
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.
1196
1191
  *
1197
1192
  * @beta
1198
1193
  */
1199
1194
  AddAuthenticationInfo(config) {
1200
1195
  return __awaiter(this, void 0, void 0, function* () {
1201
- if (config.headers && config.headers["Authorization"]) {
1202
- throw new ErrorWithCode(ErrorMessage.AuthorizationHeaderAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
1203
- }
1204
- if (config.auth) {
1205
- throw new ErrorWithCode(ErrorMessage.BasicCredentialAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
1206
- }
1207
- config.auth = {
1208
- username: this.userName,
1209
- password: this.password,
1210
- };
1211
- return config;
1196
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BasicAuthProvider"), ErrorCode.RuntimeNotSupported);
1212
1197
  });
1213
1198
  }
1214
1199
  }
@@ -1227,19 +1212,12 @@ class ApiKeyProvider {
1227
1212
  * @param { ApiKeyLocation } keyLocation - The location of API Key: request header or query parameter.
1228
1213
  *
1229
1214
  * @throws {@link ErrorCode|InvalidParameter} - when key name or key value is empty.
1215
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1230
1216
  *
1231
1217
  * @beta
1232
1218
  */
1233
1219
  constructor(keyName, keyValue, keyLocation) {
1234
- if (!keyName) {
1235
- throw new ErrorWithCode(formatString(ErrorMessage.EmptyParameter, "keyName"), ErrorCode.InvalidParameter);
1236
- }
1237
- if (!keyValue) {
1238
- throw new ErrorWithCode(formatString(ErrorMessage.EmptyParameter, "keyVaule"), ErrorCode.InvalidParameter);
1239
- }
1240
- this.keyName = keyName;
1241
- this.keyValue = keyValue;
1242
- this.keyLocation = keyLocation;
1220
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ApiKeyProvider"), ErrorCode.RuntimeNotSupported);
1243
1221
  }
1244
1222
  /**
1245
1223
  * Adds authentication info to http requests
@@ -1250,33 +1228,13 @@ class ApiKeyProvider {
1250
1228
  * @returns Updated axios request config.
1251
1229
  *
1252
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.
1253
1232
  *
1254
1233
  * @beta
1255
1234
  */
1256
1235
  AddAuthenticationInfo(config) {
1257
1236
  return __awaiter(this, void 0, void 0, function* () {
1258
- switch (this.keyLocation) {
1259
- case ApiKeyLocation.Header:
1260
- if (!config.headers) {
1261
- config.headers = {};
1262
- }
1263
- if (config.headers[this.keyName]) {
1264
- throw new ErrorWithCode(formatString(ErrorMessage.DuplicateApiKeyInHeader, this.keyName), ErrorCode.AuthorizationInfoAlreadyExists);
1265
- }
1266
- config.headers[this.keyName] = this.keyValue;
1267
- break;
1268
- case ApiKeyLocation.QueryParams:
1269
- if (!config.params) {
1270
- config.params = {};
1271
- }
1272
- const url = new URL(config.url, config.baseURL);
1273
- if (config.params[this.keyName] || url.searchParams.has(this.keyName)) {
1274
- throw new ErrorWithCode(formatString(ErrorMessage.DuplicateApiKeyInQueryParam, this.keyName), ErrorCode.AuthorizationInfoAlreadyExists);
1275
- }
1276
- config.params[this.keyName] = this.keyValue;
1277
- break;
1278
- }
1279
- return config;
1237
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ApiKeyProvider"), ErrorCode.RuntimeNotSupported);
1280
1238
  });
1281
1239
  }
1282
1240
  }
@@ -1322,6 +1280,7 @@ class CertificateAuthProvider {
1322
1280
  * @returns Updated axios request config.
1323
1281
  *
1324
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.
1325
1284
  *
1326
1285
  * @beta
1327
1286
  */
@@ -1336,29 +1295,30 @@ class CertificateAuthProvider {
1336
1295
  *
1337
1296
  * @param { string | Buffer } cert - The cert chain in PEM format
1338
1297
  * @param { string | Buffer } key - The private key for the cert chain
1339
- * @param { string? } passphrase - The passphrase for private key
1340
- * @param { string? | Buffer? } ca - Overrides the trusted CA certificates
1298
+ * @param { {passphrase?: string; ca?: string | Buffer} } options - Optional settings when create the cert options.
1341
1299
  *
1342
1300
  * @returns Instance of SecureContextOptions
1343
1301
  *
1344
1302
  * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
1303
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1345
1304
  *
1346
1305
  */
1347
- function createPemCertOption(cert, key, passphrase, ca) {
1306
+ function createPemCertOption(cert, key, options) {
1348
1307
  throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPemCertOption"), ErrorCode.RuntimeNotSupported);
1349
1308
  }
1350
1309
  /**
1351
1310
  * Helper to create SecureContextOptions from PFX format cert
1352
1311
  *
1353
1312
  * @param { string | Buffer } pfx - The content of .pfx file
1354
- * @param { string? } passphrase - Optional. The passphrase of .pfx file
1313
+ * @param { {passphrase?: string} } options - Optional settings when create the cert options.
1355
1314
  *
1356
1315
  * @returns Instance of SecureContextOptions
1357
1316
  *
1358
1317
  * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
1318
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1359
1319
  *
1360
1320
  */
1361
- function createPfxCertOption(pfx, passphrase) {
1321
+ function createPfxCertOption(pfx, options) {
1362
1322
  throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPfxCertOption"), ErrorCode.RuntimeNotSupported);
1363
1323
  }
1364
1324