@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.esm2017.js
CHANGED
|
@@ -64,6 +64,10 @@ var ErrorCode;
|
|
|
64
64
|
* Identity type error.
|
|
65
65
|
*/
|
|
66
66
|
ErrorCode["IdentityTypeNotSupported"] = "IdentityTypeNotSupported";
|
|
67
|
+
/**
|
|
68
|
+
* Authentication info already exists error.
|
|
69
|
+
*/
|
|
70
|
+
ErrorCode["AuthorizationInfoAlreadyExists"] = "AuthorizationInfoAlreadyExists";
|
|
67
71
|
})(ErrorCode || (ErrorCode = {}));
|
|
68
72
|
/**
|
|
69
73
|
* @internal
|
|
@@ -85,6 +89,14 @@ ErrorMessage.FailToAcquireTokenOnBehalfOfUser = "Failed to acquire access token
|
|
|
85
89
|
ErrorMessage.OnlyMSTeamsChannelSupported = "{0} is only supported in MS Teams Channel";
|
|
86
90
|
// IdentityTypeNotSupported Error
|
|
87
91
|
ErrorMessage.IdentityTypeNotSupported = "{0} identity is not supported in {1}";
|
|
92
|
+
// AuthorizationInfoError
|
|
93
|
+
ErrorMessage.AuthorizationHeaderAlreadyExists = "Authorization header already exists!";
|
|
94
|
+
ErrorMessage.BasicCredentialAlreadyExists = "Basic credential already exists!";
|
|
95
|
+
// InvalidParameter Error
|
|
96
|
+
ErrorMessage.EmptyParameter = "Parameter {0} is empty";
|
|
97
|
+
ErrorMessage.DuplicateHttpsOptionProperty = "Axios HTTPS agent already defined value for property {0}";
|
|
98
|
+
ErrorMessage.DuplicateApiKeyInHeader = "The request already defined api key in request header with name {0}.";
|
|
99
|
+
ErrorMessage.DuplicateApiKeyInQueryParam = "The request already defined api key in query parameter with name {0}.";
|
|
88
100
|
/**
|
|
89
101
|
* Error class with code and message thrown by the SDK.
|
|
90
102
|
*
|
|
@@ -1082,7 +1094,6 @@ function createApiClient(apiEndpoint, authProvider) {
|
|
|
1082
1094
|
}
|
|
1083
1095
|
|
|
1084
1096
|
// Copyright (c) Microsoft Corporation.
|
|
1085
|
-
// Licensed under the MIT license.
|
|
1086
1097
|
/**
|
|
1087
1098
|
* Provider that handles Bearer Token authentication
|
|
1088
1099
|
*
|
|
@@ -1090,7 +1101,7 @@ function createApiClient(apiEndpoint, authProvider) {
|
|
|
1090
1101
|
*/
|
|
1091
1102
|
class BearerTokenAuthProvider {
|
|
1092
1103
|
/**
|
|
1093
|
-
* @param getToken Function that returns the content of bearer token used in http request
|
|
1104
|
+
* @param { () => Promise<string> } getToken - Function that returns the content of bearer token used in http request
|
|
1094
1105
|
*
|
|
1095
1106
|
* @beta
|
|
1096
1107
|
*/
|
|
@@ -1100,9 +1111,13 @@ class BearerTokenAuthProvider {
|
|
|
1100
1111
|
/**
|
|
1101
1112
|
* Adds authentication info to http requests
|
|
1102
1113
|
*
|
|
1103
|
-
* @param config - Contains all the request information and can be updated to include extra authentication info.
|
|
1114
|
+
* @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
|
|
1104
1115
|
* Refer https://axios-http.com/docs/req_config for detailed document.
|
|
1105
1116
|
*
|
|
1117
|
+
* @returns Updated axios request config.
|
|
1118
|
+
*
|
|
1119
|
+
* @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header already exists in request configuration.
|
|
1120
|
+
*
|
|
1106
1121
|
* @beta
|
|
1107
1122
|
*/
|
|
1108
1123
|
async AddAuthenticationInfo(config) {
|
|
@@ -1111,13 +1126,211 @@ class BearerTokenAuthProvider {
|
|
|
1111
1126
|
config.headers = {};
|
|
1112
1127
|
}
|
|
1113
1128
|
if (config.headers["Authorization"]) {
|
|
1114
|
-
throw new
|
|
1129
|
+
throw new ErrorWithCode(ErrorMessage.AuthorizationHeaderAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
|
|
1115
1130
|
}
|
|
1116
1131
|
config.headers["Authorization"] = `Bearer ${token}`;
|
|
1117
1132
|
return config;
|
|
1118
1133
|
}
|
|
1119
1134
|
}
|
|
1120
1135
|
|
|
1136
|
+
// Copyright (c) Microsoft Corporation.
|
|
1137
|
+
/**
|
|
1138
|
+
* Provider that handles Basic authentication
|
|
1139
|
+
*
|
|
1140
|
+
* @beta
|
|
1141
|
+
*/
|
|
1142
|
+
class BasicAuthProvider {
|
|
1143
|
+
/**
|
|
1144
|
+
*
|
|
1145
|
+
* @param { string } userName - Username used in basic auth
|
|
1146
|
+
* @param { string } password - Password used in basic auth
|
|
1147
|
+
*
|
|
1148
|
+
* @throws {@link ErrorCode|InvalidParameter} - when username or password is empty.
|
|
1149
|
+
*
|
|
1150
|
+
* @beta
|
|
1151
|
+
*/
|
|
1152
|
+
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;
|
|
1161
|
+
}
|
|
1162
|
+
/**
|
|
1163
|
+
* Adds authentication info to http requests
|
|
1164
|
+
*
|
|
1165
|
+
* @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
|
|
1166
|
+
* Refer https://axios-http.com/docs/req_config for detailed document.
|
|
1167
|
+
*
|
|
1168
|
+
* @returns Updated axios request config.
|
|
1169
|
+
*
|
|
1170
|
+
* @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header or auth property already exists in request configuration.
|
|
1171
|
+
*
|
|
1172
|
+
* @beta
|
|
1173
|
+
*/
|
|
1174
|
+
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;
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
// Copyright (c) Microsoft Corporation.
|
|
1190
|
+
/**
|
|
1191
|
+
* Provider that handles API Key authentication
|
|
1192
|
+
*
|
|
1193
|
+
* @beta
|
|
1194
|
+
*/
|
|
1195
|
+
class ApiKeyProvider {
|
|
1196
|
+
/**
|
|
1197
|
+
*
|
|
1198
|
+
* @param { string } keyName - The name of request header or query parameter that specifies API Key
|
|
1199
|
+
* @param { string } keyValue - The value of API Key
|
|
1200
|
+
* @param { ApiKeyLocation } keyLocation - The location of API Key: request header or query parameter.
|
|
1201
|
+
*
|
|
1202
|
+
* @throws {@link ErrorCode|InvalidParameter} - when key name or key value is empty.
|
|
1203
|
+
*
|
|
1204
|
+
* @beta
|
|
1205
|
+
*/
|
|
1206
|
+
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;
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* Adds authentication info to http requests
|
|
1219
|
+
*
|
|
1220
|
+
* @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
|
|
1221
|
+
* Refer https://axios-http.com/docs/req_config for detailed document.
|
|
1222
|
+
*
|
|
1223
|
+
* @returns Updated axios request config.
|
|
1224
|
+
*
|
|
1225
|
+
* @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when API key already exists in request header or url query parameter.
|
|
1226
|
+
*
|
|
1227
|
+
* @beta
|
|
1228
|
+
*/
|
|
1229
|
+
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;
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
/**
|
|
1255
|
+
* Define available location for API Key location
|
|
1256
|
+
*
|
|
1257
|
+
* @beta
|
|
1258
|
+
*/
|
|
1259
|
+
var ApiKeyLocation;
|
|
1260
|
+
(function (ApiKeyLocation) {
|
|
1261
|
+
/**
|
|
1262
|
+
* The API Key is placed in request header
|
|
1263
|
+
*/
|
|
1264
|
+
ApiKeyLocation[ApiKeyLocation["Header"] = 0] = "Header";
|
|
1265
|
+
/**
|
|
1266
|
+
* The API Key is placed in query parameter
|
|
1267
|
+
*/
|
|
1268
|
+
ApiKeyLocation[ApiKeyLocation["QueryParams"] = 1] = "QueryParams";
|
|
1269
|
+
})(ApiKeyLocation || (ApiKeyLocation = {}));
|
|
1270
|
+
|
|
1271
|
+
// Copyright (c) Microsoft Corporation.
|
|
1272
|
+
/**
|
|
1273
|
+
* Provider that handles Certificate authentication
|
|
1274
|
+
*
|
|
1275
|
+
* @beta
|
|
1276
|
+
*/
|
|
1277
|
+
class CertificateAuthProvider {
|
|
1278
|
+
/**
|
|
1279
|
+
*
|
|
1280
|
+
* @param { SecureContextOptions } certOption - information about the cert used in http requests
|
|
1281
|
+
*
|
|
1282
|
+
* @beta
|
|
1283
|
+
*/
|
|
1284
|
+
constructor(certOption) {
|
|
1285
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CertificateAuthProvider"), ErrorCode.RuntimeNotSupported);
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* Adds authentication info to http requests.
|
|
1289
|
+
*
|
|
1290
|
+
* @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
|
|
1291
|
+
* Refer https://axios-http.com/docs/req_config for detailed document.
|
|
1292
|
+
*
|
|
1293
|
+
* @returns Updated axios request config.
|
|
1294
|
+
*
|
|
1295
|
+
* @throws {@link ErrorCode|InvalidParameter} - when custom httpsAgent in the request has duplicate properties with certOption provided in constructor.
|
|
1296
|
+
*
|
|
1297
|
+
* @beta
|
|
1298
|
+
*/
|
|
1299
|
+
async AddAuthenticationInfo(config) {
|
|
1300
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CertificateAuthProvider"), ErrorCode.RuntimeNotSupported);
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* Helper to create SecureContextOptions from PEM format cert
|
|
1305
|
+
*
|
|
1306
|
+
* @param { string | Buffer } cert - The cert chain in PEM format
|
|
1307
|
+
* @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
|
|
1310
|
+
*
|
|
1311
|
+
* @returns Instance of SecureContextOptions
|
|
1312
|
+
*
|
|
1313
|
+
* @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
|
|
1314
|
+
*
|
|
1315
|
+
*/
|
|
1316
|
+
function createPemCertOption(cert, key, passphrase, ca) {
|
|
1317
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPemCertOption"), ErrorCode.RuntimeNotSupported);
|
|
1318
|
+
}
|
|
1319
|
+
/**
|
|
1320
|
+
* Helper to create SecureContextOptions from PFX format cert
|
|
1321
|
+
*
|
|
1322
|
+
* @param { string | Buffer } pfx - The content of .pfx file
|
|
1323
|
+
* @param { string? } passphrase - Optional. The passphrase of .pfx file
|
|
1324
|
+
*
|
|
1325
|
+
* @returns Instance of SecureContextOptions
|
|
1326
|
+
*
|
|
1327
|
+
* @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
|
|
1328
|
+
*
|
|
1329
|
+
*/
|
|
1330
|
+
function createPfxCertOption(pfx, passphrase) {
|
|
1331
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPfxCertOption"), ErrorCode.RuntimeNotSupported);
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1121
1334
|
// Copyright (c) Microsoft Corporation.
|
|
1122
1335
|
// Licensed under the MIT license.
|
|
1123
1336
|
/**
|
|
@@ -1238,7 +1451,7 @@ class TeamsFx {
|
|
|
1238
1451
|
/**
|
|
1239
1452
|
* Provide utilities for bot conversation, including:
|
|
1240
1453
|
* - handle command and response.
|
|
1241
|
-
* - send notification to varies targets (e.g., member,
|
|
1454
|
+
* - send notification to varies targets (e.g., member, group, channel).
|
|
1242
1455
|
*
|
|
1243
1456
|
* @remarks
|
|
1244
1457
|
* Only work on server side.
|
|
@@ -1259,6 +1472,21 @@ class ConversationBot {
|
|
|
1259
1472
|
constructor(options) {
|
|
1260
1473
|
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ConversationBot"), ErrorCode.RuntimeNotSupported);
|
|
1261
1474
|
}
|
|
1475
|
+
/**
|
|
1476
|
+
* The request handler to integrate with web request.
|
|
1477
|
+
*
|
|
1478
|
+
* @param req - an Express or Restify style request object.
|
|
1479
|
+
* @param res - an Express or Restify style response object.
|
|
1480
|
+
* @param logic - the additional function to handle bot context.
|
|
1481
|
+
*
|
|
1482
|
+
* @remarks
|
|
1483
|
+
* Only work on server side.
|
|
1484
|
+
*
|
|
1485
|
+
* @beta
|
|
1486
|
+
*/
|
|
1487
|
+
async requestHandler(req, res, logic) {
|
|
1488
|
+
throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ConversationBot"), ErrorCode.RuntimeNotSupported);
|
|
1489
|
+
}
|
|
1262
1490
|
}
|
|
1263
1491
|
|
|
1264
1492
|
// Copyright (c) Microsoft Corporation.
|
|
@@ -1617,5 +1845,5 @@ class CommandBot {
|
|
|
1617
1845
|
}
|
|
1618
1846
|
}
|
|
1619
1847
|
|
|
1620
|
-
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 };
|
|
1848
|
+
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 };
|
|
1621
1849
|
//# sourceMappingURL=index.esm2017.js.map
|