@microsoft/teamsfx 0.6.3-alpha.8d048e1f1.0 → 0.6.3-alpha.cc1068ff9.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.
- package/dist/index.esm2017.js +234 -6
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +345 -42
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +242 -5
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +357 -40
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +3 -3
- package/types/teamsfx.d.ts +1428 -1239
package/dist/index.esm5.js
CHANGED
|
@@ -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,6 +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!";
|
|
96
|
+
// InvalidParameter Error
|
|
97
|
+
ErrorMessage.EmptyParameter = "Parameter {0} is empty";
|
|
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}.";
|
|
89
101
|
/**
|
|
90
102
|
* Error class with code and message thrown by the SDK.
|
|
91
103
|
*
|
|
@@ -1112,7 +1124,7 @@ function createApiClient(apiEndpoint, authProvider) {
|
|
|
1112
1124
|
*/
|
|
1113
1125
|
class BearerTokenAuthProvider {
|
|
1114
1126
|
/**
|
|
1115
|
-
* @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
|
|
1116
1128
|
*
|
|
1117
1129
|
* @beta
|
|
1118
1130
|
*/
|
|
@@ -1122,9 +1134,13 @@ class BearerTokenAuthProvider {
|
|
|
1122
1134
|
/**
|
|
1123
1135
|
* Adds authentication info to http requests
|
|
1124
1136
|
*
|
|
1125
|
-
* @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.
|
|
1126
1138
|
* Refer https://axios-http.com/docs/req_config for detailed document.
|
|
1127
1139
|
*
|
|
1140
|
+
* @returns Updated axios request config.
|
|
1141
|
+
*
|
|
1142
|
+
* @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header already exists in request configuration.
|
|
1143
|
+
*
|
|
1128
1144
|
* @beta
|
|
1129
1145
|
*/
|
|
1130
1146
|
AddAuthenticationInfo(config) {
|
|
@@ -1134,7 +1150,7 @@ class BearerTokenAuthProvider {
|
|
|
1134
1150
|
config.headers = {};
|
|
1135
1151
|
}
|
|
1136
1152
|
if (config.headers["Authorization"]) {
|
|
1137
|
-
throw new
|
|
1153
|
+
throw new ErrorWithCode(ErrorMessage.AuthorizationHeaderAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
|
|
1138
1154
|
}
|
|
1139
1155
|
config.headers["Authorization"] = `Bearer ${token}`;
|
|
1140
1156
|
return config;
|
|
@@ -1142,6 +1158,210 @@ class BearerTokenAuthProvider {
|
|
|
1142
1158
|
}
|
|
1143
1159
|
}
|
|
1144
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
|
+
*
|
|
1175
|
+
* @beta
|
|
1176
|
+
*/
|
|
1177
|
+
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;
|
|
1186
|
+
}
|
|
1187
|
+
/**
|
|
1188
|
+
* Adds authentication info to http requests
|
|
1189
|
+
*
|
|
1190
|
+
* @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
|
|
1191
|
+
* Refer https://axios-http.com/docs/req_config for detailed document.
|
|
1192
|
+
*
|
|
1193
|
+
* @returns Updated axios request config.
|
|
1194
|
+
*
|
|
1195
|
+
* @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header or auth property already exists in request configuration.
|
|
1196
|
+
*
|
|
1197
|
+
* @beta
|
|
1198
|
+
*/
|
|
1199
|
+
AddAuthenticationInfo(config) {
|
|
1200
|
+
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;
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
// Copyright (c) Microsoft Corporation.
|
|
1217
|
+
/**
|
|
1218
|
+
* Provider that handles API Key authentication
|
|
1219
|
+
*
|
|
1220
|
+
* @beta
|
|
1221
|
+
*/
|
|
1222
|
+
class ApiKeyProvider {
|
|
1223
|
+
/**
|
|
1224
|
+
*
|
|
1225
|
+
* @param { string } keyName - The name of request header or query parameter that specifies API Key
|
|
1226
|
+
* @param { string } keyValue - The value of API Key
|
|
1227
|
+
* @param { ApiKeyLocation } keyLocation - The location of API Key: request header or query parameter.
|
|
1228
|
+
*
|
|
1229
|
+
* @throws {@link ErrorCode|InvalidParameter} - when key name or key value is empty.
|
|
1230
|
+
*
|
|
1231
|
+
* @beta
|
|
1232
|
+
*/
|
|
1233
|
+
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;
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* Adds authentication info to http requests
|
|
1246
|
+
*
|
|
1247
|
+
* @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
|
|
1248
|
+
* Refer https://axios-http.com/docs/req_config for detailed document.
|
|
1249
|
+
*
|
|
1250
|
+
* @returns Updated axios request config.
|
|
1251
|
+
*
|
|
1252
|
+
* @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when API key already exists in request header or url query parameter.
|
|
1253
|
+
*
|
|
1254
|
+
* @beta
|
|
1255
|
+
*/
|
|
1256
|
+
AddAuthenticationInfo(config) {
|
|
1257
|
+
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;
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
/**
|
|
1284
|
+
* Define available location for API Key location
|
|
1285
|
+
*
|
|
1286
|
+
* @beta
|
|
1287
|
+
*/
|
|
1288
|
+
var ApiKeyLocation;
|
|
1289
|
+
(function (ApiKeyLocation) {
|
|
1290
|
+
/**
|
|
1291
|
+
* The API Key is placed in request header
|
|
1292
|
+
*/
|
|
1293
|
+
ApiKeyLocation[ApiKeyLocation["Header"] = 0] = "Header";
|
|
1294
|
+
/**
|
|
1295
|
+
* The API Key is placed in query parameter
|
|
1296
|
+
*/
|
|
1297
|
+
ApiKeyLocation[ApiKeyLocation["QueryParams"] = 1] = "QueryParams";
|
|
1298
|
+
})(ApiKeyLocation || (ApiKeyLocation = {}));
|
|
1299
|
+
|
|
1300
|
+
// Copyright (c) Microsoft Corporation.
|
|
1301
|
+
/**
|
|
1302
|
+
* Provider that handles Certificate authentication
|
|
1303
|
+
*
|
|
1304
|
+
* @beta
|
|
1305
|
+
*/
|
|
1306
|
+
class CertificateAuthProvider {
|
|
1307
|
+
/**
|
|
1308
|
+
*
|
|
1309
|
+
* @param { SecureContextOptions } certOption - information about the cert used in http requests
|
|
1310
|
+
*
|
|
1311
|
+
* @beta
|
|
1312
|
+
*/
|
|
1313
|
+
constructor(certOption) {
|
|
1314
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CertificateAuthProvider"), ErrorCode.RuntimeNotSupported);
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* Adds authentication info to http requests.
|
|
1318
|
+
*
|
|
1319
|
+
* @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
|
|
1320
|
+
* Refer https://axios-http.com/docs/req_config for detailed document.
|
|
1321
|
+
*
|
|
1322
|
+
* @returns Updated axios request config.
|
|
1323
|
+
*
|
|
1324
|
+
* @throws {@link ErrorCode|InvalidParameter} - when custom httpsAgent in the request has duplicate properties with certOption provided in constructor.
|
|
1325
|
+
*
|
|
1326
|
+
* @beta
|
|
1327
|
+
*/
|
|
1328
|
+
AddAuthenticationInfo(config) {
|
|
1329
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1330
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CertificateAuthProvider"), ErrorCode.RuntimeNotSupported);
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
/**
|
|
1335
|
+
* Helper to create SecureContextOptions from PEM format cert
|
|
1336
|
+
*
|
|
1337
|
+
* @param { string | Buffer } cert - The cert chain in PEM format
|
|
1338
|
+
* @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
|
|
1341
|
+
*
|
|
1342
|
+
* @returns Instance of SecureContextOptions
|
|
1343
|
+
*
|
|
1344
|
+
* @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
|
|
1345
|
+
*
|
|
1346
|
+
*/
|
|
1347
|
+
function createPemCertOption(cert, key, passphrase, ca) {
|
|
1348
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPemCertOption"), ErrorCode.RuntimeNotSupported);
|
|
1349
|
+
}
|
|
1350
|
+
/**
|
|
1351
|
+
* Helper to create SecureContextOptions from PFX format cert
|
|
1352
|
+
*
|
|
1353
|
+
* @param { string | Buffer } pfx - The content of .pfx file
|
|
1354
|
+
* @param { string? } passphrase - Optional. The passphrase of .pfx file
|
|
1355
|
+
*
|
|
1356
|
+
* @returns Instance of SecureContextOptions
|
|
1357
|
+
*
|
|
1358
|
+
* @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
|
|
1359
|
+
*
|
|
1360
|
+
*/
|
|
1361
|
+
function createPfxCertOption(pfx, passphrase) {
|
|
1362
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPfxCertOption"), ErrorCode.RuntimeNotSupported);
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1145
1365
|
// Copyright (c) Microsoft Corporation.
|
|
1146
1366
|
// Licensed under the MIT license.
|
|
1147
1367
|
/**
|
|
@@ -1266,7 +1486,7 @@ class TeamsFx {
|
|
|
1266
1486
|
/**
|
|
1267
1487
|
* Provide utilities for bot conversation, including:
|
|
1268
1488
|
* - handle command and response.
|
|
1269
|
-
* - send notification to varies targets (e.g., member,
|
|
1489
|
+
* - send notification to varies targets (e.g., member, group, channel).
|
|
1270
1490
|
*
|
|
1271
1491
|
* @remarks
|
|
1272
1492
|
* Only work on server side.
|
|
@@ -1287,6 +1507,23 @@ class ConversationBot {
|
|
|
1287
1507
|
constructor(options) {
|
|
1288
1508
|
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ConversationBot"), ErrorCode.RuntimeNotSupported);
|
|
1289
1509
|
}
|
|
1510
|
+
/**
|
|
1511
|
+
* The request handler to integrate with web request.
|
|
1512
|
+
*
|
|
1513
|
+
* @param req - an Express or Restify style request object.
|
|
1514
|
+
* @param res - an Express or Restify style response object.
|
|
1515
|
+
* @param logic - the additional function to handle bot context.
|
|
1516
|
+
*
|
|
1517
|
+
* @remarks
|
|
1518
|
+
* Only work on server side.
|
|
1519
|
+
*
|
|
1520
|
+
* @beta
|
|
1521
|
+
*/
|
|
1522
|
+
requestHandler(req, res, logic) {
|
|
1523
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1524
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ConversationBot"), ErrorCode.RuntimeNotSupported);
|
|
1525
|
+
});
|
|
1526
|
+
}
|
|
1290
1527
|
}
|
|
1291
1528
|
|
|
1292
1529
|
// Copyright (c) Microsoft Corporation.
|
|
@@ -1655,5 +1892,5 @@ class CommandBot {
|
|
|
1655
1892
|
}
|
|
1656
1893
|
}
|
|
1657
1894
|
|
|
1658
|
-
export { AppCredential, BearerTokenAuthProvider, Channel, CommandBot, ConversationBot, ErrorCode, ErrorWithCode, IdentityType, LogLevel, Member, MsGraphAuthProvider, NotificationBot, OnBehalfOfUserCredential, TeamsBotInstallation, TeamsBotSsoPrompt, TeamsFx, TeamsUserCredential, createApiClient, createMicrosoftGraphClient, getLogLevel, getTediousConnectionConfig, sendAdaptiveCard, sendMessage, setLogFunction, setLogLevel, setLogger };
|
|
1895
|
+
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 };
|
|
1659
1896
|
//# sourceMappingURL=index.esm5.js.map
|