@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.
@@ -1146,18 +1146,12 @@ class BasicAuthProvider {
1146
1146
  * @param { string } password - Password used in basic auth
1147
1147
  *
1148
1148
  * @throws {@link ErrorCode|InvalidParameter} - when username or password is empty.
1149
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1149
1150
  *
1150
1151
  * @beta
1151
1152
  */
1152
1153
  constructor(userName, password) {
1153
- if (!userName) {
1154
- throw new ErrorWithCode(formatString(ErrorMessage.EmptyParameter, "username"), ErrorCode.InvalidParameter);
1155
- }
1156
- if (!password) {
1157
- throw new ErrorWithCode(formatString(ErrorMessage.EmptyParameter, "password"), ErrorCode.InvalidParameter);
1158
- }
1159
- this.userName = userName;
1160
- this.password = password;
1154
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BasicAuthProvider"), ErrorCode.RuntimeNotSupported);
1161
1155
  }
1162
1156
  /**
1163
1157
  * Adds authentication info to http requests
@@ -1168,21 +1162,12 @@ class BasicAuthProvider {
1168
1162
  * @returns Updated axios request config.
1169
1163
  *
1170
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.
1171
1166
  *
1172
1167
  * @beta
1173
1168
  */
1174
1169
  async AddAuthenticationInfo(config) {
1175
- if (config.headers && config.headers["Authorization"]) {
1176
- throw new ErrorWithCode(ErrorMessage.AuthorizationHeaderAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
1177
- }
1178
- if (config.auth) {
1179
- throw new ErrorWithCode(ErrorMessage.BasicCredentialAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
1180
- }
1181
- config.auth = {
1182
- username: this.userName,
1183
- password: this.password,
1184
- };
1185
- return config;
1170
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BasicAuthProvider"), ErrorCode.RuntimeNotSupported);
1186
1171
  }
1187
1172
  }
1188
1173
 
@@ -1200,19 +1185,12 @@ class ApiKeyProvider {
1200
1185
  * @param { ApiKeyLocation } keyLocation - The location of API Key: request header or query parameter.
1201
1186
  *
1202
1187
  * @throws {@link ErrorCode|InvalidParameter} - when key name or key value is empty.
1188
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1203
1189
  *
1204
1190
  * @beta
1205
1191
  */
1206
1192
  constructor(keyName, keyValue, keyLocation) {
1207
- if (!keyName) {
1208
- throw new ErrorWithCode(formatString(ErrorMessage.EmptyParameter, "keyName"), ErrorCode.InvalidParameter);
1209
- }
1210
- if (!keyValue) {
1211
- throw new ErrorWithCode(formatString(ErrorMessage.EmptyParameter, "keyVaule"), ErrorCode.InvalidParameter);
1212
- }
1213
- this.keyName = keyName;
1214
- this.keyValue = keyValue;
1215
- this.keyLocation = keyLocation;
1193
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ApiKeyProvider"), ErrorCode.RuntimeNotSupported);
1216
1194
  }
1217
1195
  /**
1218
1196
  * Adds authentication info to http requests
@@ -1223,32 +1201,12 @@ class ApiKeyProvider {
1223
1201
  * @returns Updated axios request config.
1224
1202
  *
1225
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.
1226
1205
  *
1227
1206
  * @beta
1228
1207
  */
1229
1208
  async AddAuthenticationInfo(config) {
1230
- switch (this.keyLocation) {
1231
- case ApiKeyLocation.Header:
1232
- if (!config.headers) {
1233
- config.headers = {};
1234
- }
1235
- if (config.headers[this.keyName]) {
1236
- throw new ErrorWithCode(formatString(ErrorMessage.DuplicateApiKeyInHeader, this.keyName), ErrorCode.AuthorizationInfoAlreadyExists);
1237
- }
1238
- config.headers[this.keyName] = this.keyValue;
1239
- break;
1240
- case ApiKeyLocation.QueryParams:
1241
- if (!config.params) {
1242
- config.params = {};
1243
- }
1244
- const url = new URL(config.url, config.baseURL);
1245
- if (config.params[this.keyName] || url.searchParams.has(this.keyName)) {
1246
- throw new ErrorWithCode(formatString(ErrorMessage.DuplicateApiKeyInQueryParam, this.keyName), ErrorCode.AuthorizationInfoAlreadyExists);
1247
- }
1248
- config.params[this.keyName] = this.keyValue;
1249
- break;
1250
- }
1251
- return config;
1209
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ApiKeyProvider"), ErrorCode.RuntimeNotSupported);
1252
1210
  }
1253
1211
  }
1254
1212
  /**
@@ -1293,6 +1251,7 @@ class CertificateAuthProvider {
1293
1251
  * @returns Updated axios request config.
1294
1252
  *
1295
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.
1296
1255
  *
1297
1256
  * @beta
1298
1257
  */
@@ -1305,29 +1264,30 @@ class CertificateAuthProvider {
1305
1264
  *
1306
1265
  * @param { string | Buffer } cert - The cert chain in PEM format
1307
1266
  * @param { string | Buffer } key - The private key for the cert chain
1308
- * @param { string? } passphrase - The passphrase for private key
1309
- * @param { string? | Buffer? } ca - Overrides the trusted CA certificates
1267
+ * @param { {passphrase?: string; ca?: string | Buffer} } options - Optional settings when create the cert options.
1310
1268
  *
1311
1269
  * @returns Instance of SecureContextOptions
1312
1270
  *
1313
1271
  * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
1272
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1314
1273
  *
1315
1274
  */
1316
- function createPemCertOption(cert, key, passphrase, ca) {
1275
+ function createPemCertOption(cert, key, options) {
1317
1276
  throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPemCertOption"), ErrorCode.RuntimeNotSupported);
1318
1277
  }
1319
1278
  /**
1320
1279
  * Helper to create SecureContextOptions from PFX format cert
1321
1280
  *
1322
1281
  * @param { string | Buffer } pfx - The content of .pfx file
1323
- * @param { string? } passphrase - Optional. The passphrase of .pfx file
1282
+ * @param { {passphrase?: string} } options - Optional settings when create the cert options.
1324
1283
  *
1325
1284
  * @returns Instance of SecureContextOptions
1326
1285
  *
1327
1286
  * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
1287
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1328
1288
  *
1329
1289
  */
1330
- function createPfxCertOption(pfx, passphrase) {
1290
+ function createPfxCertOption(pfx, options) {
1331
1291
  throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPfxCertOption"), ErrorCode.RuntimeNotSupported);
1332
1292
  }
1333
1293