@microsoft/teamsfx 2.2.3-alpha.9b38c38b5.0 → 2.2.3-alpha.dea6b9e8a.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 +62 -62
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +57 -41
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +44 -108
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +99 -95
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +4 -4
- package/types/teamsfx.d.ts +8 -1
package/dist/index.node.cjs.js
CHANGED
@@ -425,6 +425,7 @@ function getAuthority(authorityHost, tenantId) {
|
|
425
425
|
return normalizedAuthorityHost + "/" + tenantId;
|
426
426
|
}
|
427
427
|
|
428
|
+
// Copyright (c) Microsoft Corporation.
|
428
429
|
/**
|
429
430
|
* @internal
|
430
431
|
*/
|
@@ -747,9 +748,7 @@ class TeamsUserCredential {
|
|
747
748
|
* Can only be used within Teams.
|
748
749
|
*/
|
749
750
|
login(scopes, resources) {
|
750
|
-
return
|
751
|
-
throw new ErrorWithCode(formatString(ErrorMessage.NodejsRuntimeNotSupported, "TeamsUserCredential"), exports.ErrorCode.RuntimeNotSupported);
|
752
|
-
});
|
751
|
+
return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.NodejsRuntimeNotSupported, "TeamsUserCredential"), exports.ErrorCode.RuntimeNotSupported));
|
753
752
|
}
|
754
753
|
/**
|
755
754
|
* Get access token from credential.
|
@@ -757,9 +756,7 @@ class TeamsUserCredential {
|
|
757
756
|
* Can only be used within Teams.
|
758
757
|
*/
|
759
758
|
getToken(scopes, options) {
|
760
|
-
return
|
761
|
-
throw new ErrorWithCode(formatString(ErrorMessage.NodejsRuntimeNotSupported, "TeamsUserCredential"), exports.ErrorCode.RuntimeNotSupported);
|
762
|
-
});
|
759
|
+
return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.NodejsRuntimeNotSupported, "TeamsUserCredential"), exports.ErrorCode.RuntimeNotSupported));
|
763
760
|
}
|
764
761
|
/**
|
765
762
|
* Get basic user info from SSO token
|
@@ -770,7 +767,7 @@ class TeamsUserCredential {
|
|
770
767
|
* Can only be used within Teams.
|
771
768
|
*/
|
772
769
|
getUserInfo(resources) {
|
773
|
-
|
770
|
+
return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.NodejsRuntimeNotSupported, "TeamsUserCredential"), exports.ErrorCode.RuntimeNotSupported));
|
774
771
|
}
|
775
772
|
}
|
776
773
|
|
@@ -807,7 +804,7 @@ class MsGraphAuthProvider {
|
|
807
804
|
*/
|
808
805
|
getAccessToken() {
|
809
806
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
810
|
-
internalLogger.info(`Get Graph Access token with scopes: '${this.scopes}'`);
|
807
|
+
internalLogger.info(`Get Graph Access token with scopes: '${this.scopes.toString()}'`);
|
811
808
|
let accessToken;
|
812
809
|
if (this.credentialOrTeamsFx.getCredential) {
|
813
810
|
accessToken = yield this.credentialOrTeamsFx
|
@@ -1048,7 +1045,7 @@ function isMsiAuthentication(teamsfx) {
|
|
1048
1045
|
function generateDefaultConfig(teamsfx, databaseName) {
|
1049
1046
|
internalLogger.verbose(`SQL server ${teamsfx.getConfig("sqlServerEndpoint")}
|
1050
1047
|
, user name ${teamsfx.getConfig("sqlUsername")}
|
1051
|
-
, database name ${databaseName}`);
|
1048
|
+
, database name ${databaseName ? databaseName : ""}`);
|
1052
1049
|
const config = {
|
1053
1050
|
server: teamsfx.getConfig("sqlServerEndpoint"),
|
1054
1051
|
authentication: {
|
@@ -1102,7 +1099,7 @@ function generateTokenConfig(teamsfx, databaseName) {
|
|
1102
1099
|
};
|
1103
1100
|
internalLogger.verbose(`Generate token configuration success
|
1104
1101
|
, server endpoint is ${teamsfx.getConfig("sqlServerEndpoint")}
|
1105
|
-
, database name is ${databaseName}`);
|
1102
|
+
, database name is ${databaseName ? databaseName : ""}`);
|
1106
1103
|
return config;
|
1107
1104
|
}
|
1108
1105
|
internalLogger.error(`Generate token configuration
|
@@ -1376,7 +1373,8 @@ class TeamsBotSsoPrompt extends botbuilderDialogs.Dialog {
|
|
1376
1373
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
1377
1374
|
internalLogger.verbose("Send OAuth card to get SSO token");
|
1378
1375
|
const account = yield botbuilder.TeamsInfo.getMember(context, context.activity.from.id);
|
1379
|
-
internalLogger.verbose("Get Teams member account user principal name: " +
|
1376
|
+
internalLogger.verbose("Get Teams member account user principal name: " +
|
1377
|
+
(account.userPrincipalName ? account.userPrincipalName : ""));
|
1380
1378
|
const loginHint = account.userPrincipalName ? account.userPrincipalName : "";
|
1381
1379
|
const signInResource = this.getSignInResource(loginHint);
|
1382
1380
|
const card = botbuilder.CardFactory.oauthCard("", "Teams SSO Sign In", "Sign In", signInResource.signInLink, signInResource.tokenExchangeResource);
|
@@ -1584,19 +1582,17 @@ class BasicAuthProvider {
|
|
1584
1582
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
1585
1583
|
*/
|
1586
1584
|
AddAuthenticationInfo(config) {
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
return config;
|
1599
|
-
});
|
1585
|
+
if (config.headers && config.headers["Authorization"]) {
|
1586
|
+
return Promise.reject(new ErrorWithCode(ErrorMessage.AuthorizationHeaderAlreadyExists, exports.ErrorCode.AuthorizationInfoAlreadyExists));
|
1587
|
+
}
|
1588
|
+
if (config.auth) {
|
1589
|
+
return Promise.reject(new ErrorWithCode(ErrorMessage.BasicCredentialAlreadyExists, exports.ErrorCode.AuthorizationInfoAlreadyExists));
|
1590
|
+
}
|
1591
|
+
config.auth = {
|
1592
|
+
username: this.userName,
|
1593
|
+
password: this.password,
|
1594
|
+
};
|
1595
|
+
return Promise.resolve(config);
|
1600
1596
|
}
|
1601
1597
|
}
|
1602
1598
|
|
@@ -1637,34 +1633,32 @@ class ApiKeyProvider {
|
|
1637
1633
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
1638
1634
|
*/
|
1639
1635
|
AddAuthenticationInfo(config) {
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
return config;
|
1667
|
-
});
|
1636
|
+
switch (this.keyLocation) {
|
1637
|
+
case exports.ApiKeyLocation.Header:
|
1638
|
+
if (!config.headers) {
|
1639
|
+
config.headers = {};
|
1640
|
+
}
|
1641
|
+
if (config.headers[this.keyName]) {
|
1642
|
+
return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.DuplicateApiKeyInHeader, this.keyName), exports.ErrorCode.AuthorizationInfoAlreadyExists));
|
1643
|
+
}
|
1644
|
+
config.headers[this.keyName] = this.keyValue;
|
1645
|
+
break;
|
1646
|
+
case exports.ApiKeyLocation.QueryParams:
|
1647
|
+
if (!config.params) {
|
1648
|
+
config.params = {};
|
1649
|
+
}
|
1650
|
+
let urlHasDefinedApiKey = false;
|
1651
|
+
if (config.url) {
|
1652
|
+
const url = new URL(config.url, config.baseURL);
|
1653
|
+
urlHasDefinedApiKey = url.searchParams.has(this.keyName);
|
1654
|
+
}
|
1655
|
+
if (config.params[this.keyName] || urlHasDefinedApiKey) {
|
1656
|
+
return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.DuplicateApiKeyInQueryParam, this.keyName), exports.ErrorCode.AuthorizationInfoAlreadyExists));
|
1657
|
+
}
|
1658
|
+
config.params[this.keyName] = this.keyValue;
|
1659
|
+
break;
|
1660
|
+
}
|
1661
|
+
return Promise.resolve(config);
|
1668
1662
|
}
|
1669
1663
|
}
|
1670
1664
|
/**
|
@@ -1712,21 +1706,19 @@ class CertificateAuthProvider {
|
|
1712
1706
|
* @throws {@link ErrorCode|InvalidParameter} - when custom httpsAgent in the request has duplicate properties with certOption provided in constructor.
|
1713
1707
|
*/
|
1714
1708
|
AddAuthenticationInfo(config) {
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
throw new ErrorWithCode(formatString(ErrorMessage.DuplicateHttpsOptionProperty, property), exports.ErrorCode.InvalidParameter);
|
1724
|
-
}
|
1709
|
+
if (!config.httpsAgent) {
|
1710
|
+
config.httpsAgent = new https.Agent(this.certOption);
|
1711
|
+
}
|
1712
|
+
else {
|
1713
|
+
const existingProperties = new Set(Object.keys(config.httpsAgent.options));
|
1714
|
+
for (const property of Object.keys(this.certOption)) {
|
1715
|
+
if (existingProperties.has(property)) {
|
1716
|
+
return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.DuplicateHttpsOptionProperty, property), exports.ErrorCode.InvalidParameter));
|
1725
1717
|
}
|
1726
|
-
Object.assign(config.httpsAgent.options, this.certOption);
|
1727
1718
|
}
|
1728
|
-
|
1729
|
-
}
|
1719
|
+
Object.assign(config.httpsAgent.options, this.certOption);
|
1720
|
+
}
|
1721
|
+
return Promise.resolve(config);
|
1730
1722
|
}
|
1731
1723
|
}
|
1732
1724
|
/**
|
@@ -2813,7 +2805,7 @@ class Channel$1 {
|
|
2813
2805
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
2814
2806
|
const response = {};
|
2815
2807
|
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
|
2816
|
-
const conversation =
|
2808
|
+
const conversation = this.newConversation(context);
|
2817
2809
|
yield this.parent.adapter.continueConversation(conversation, (ctx) => tslib.__awaiter(this, void 0, void 0, function* () {
|
2818
2810
|
try {
|
2819
2811
|
const res = yield ctx.sendActivity(text);
|
@@ -2844,7 +2836,7 @@ class Channel$1 {
|
|
2844
2836
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
2845
2837
|
const response = {};
|
2846
2838
|
yield this.parent.adapter.continueConversation(this.parent.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
|
2847
|
-
const conversation =
|
2839
|
+
const conversation = this.newConversation(context);
|
2848
2840
|
yield this.parent.adapter.continueConversation(conversation, (ctx) => tslib.__awaiter(this, void 0, void 0, function* () {
|
2849
2841
|
try {
|
2850
2842
|
const res = yield ctx.sendActivity({
|
@@ -2869,12 +2861,10 @@ class Channel$1 {
|
|
2869
2861
|
* @internal
|
2870
2862
|
*/
|
2871
2863
|
newConversation(context) {
|
2872
|
-
|
2873
|
-
|
2874
|
-
|
2875
|
-
|
2876
|
-
return channelConversation;
|
2877
|
-
});
|
2864
|
+
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
2865
|
+
const channelConversation = cloneConversation(reference);
|
2866
|
+
channelConversation.conversation.id = this.info.id || "";
|
2867
|
+
return channelConversation;
|
2878
2868
|
}
|
2879
2869
|
}
|
2880
2870
|
/**
|
@@ -4406,12 +4396,10 @@ class Channel {
|
|
4406
4396
|
* @internal
|
4407
4397
|
*/
|
4408
4398
|
newConversation(context) {
|
4409
|
-
|
4410
|
-
|
4411
|
-
|
4412
|
-
|
4413
|
-
return channelConversation;
|
4414
|
-
});
|
4399
|
+
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
4400
|
+
const channelConversation = cloneConversation(reference);
|
4401
|
+
channelConversation.conversation.id = this.info.id || "";
|
4402
|
+
return Promise.resolve(channelConversation);
|
4415
4403
|
}
|
4416
4404
|
}
|
4417
4405
|
/**
|
@@ -4736,6 +4724,29 @@ class NotificationBot {
|
|
4736
4724
|
}
|
4737
4725
|
return new TeamsBotInstallation(this.adapter, conversationReference, this.botAppId);
|
4738
4726
|
}
|
4727
|
+
/**
|
4728
|
+
* Validate the installation by getting paged memebers.
|
4729
|
+
*
|
4730
|
+
* @param conversationReference The bound `ConversationReference`.
|
4731
|
+
* @returns Returns false if recieves `BotNotInConversationRoster` error, otherwise returns true.
|
4732
|
+
*/
|
4733
|
+
validateInstallation(conversationReference) {
|
4734
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
4735
|
+
let isValid = true;
|
4736
|
+
yield this.adapter.continueConversationAsync(this.botAppId, conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
|
4737
|
+
try {
|
4738
|
+
// try get member to see if the installation is still valid
|
4739
|
+
yield botbuilder.TeamsInfo.getPagedMembers(context, 1);
|
4740
|
+
}
|
4741
|
+
catch (error) {
|
4742
|
+
if (error.code === "BotNotInConversationRoster") {
|
4743
|
+
isValid = false;
|
4744
|
+
}
|
4745
|
+
}
|
4746
|
+
}));
|
4747
|
+
return isValid;
|
4748
|
+
});
|
4749
|
+
}
|
4739
4750
|
/**
|
4740
4751
|
* Gets a pagined list of targets where the bot is installed.
|
4741
4752
|
*
|
@@ -4747,7 +4758,7 @@ class NotificationBot {
|
|
4747
4758
|
*
|
4748
4759
|
* @returns An array of {@link TeamsBotInstallation} with paged data and continuation token.
|
4749
4760
|
*/
|
4750
|
-
getPagedInstallations(pageSize, continuationToken) {
|
4761
|
+
getPagedInstallations(pageSize, continuationToken, validationEnabled = true) {
|
4751
4762
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
4752
4763
|
if (this.conversationReferenceStore === undefined || this.adapter === undefined) {
|
4753
4764
|
throw new Error("NotificationBot has not been initialized.");
|
@@ -4756,19 +4767,12 @@ class NotificationBot {
|
|
4756
4767
|
const targets = [];
|
4757
4768
|
for (const reference of references.data) {
|
4758
4769
|
// validate connection
|
4759
|
-
let valid
|
4760
|
-
|
4761
|
-
try
|
4762
|
-
|
4763
|
-
|
4764
|
-
|
4765
|
-
catch (error) {
|
4766
|
-
if (error.code === "BotNotInConversationRoster") {
|
4767
|
-
valid = false;
|
4768
|
-
}
|
4769
|
-
}
|
4770
|
-
}));
|
4771
|
-
if (valid) {
|
4770
|
+
let valid;
|
4771
|
+
if (validationEnabled) {
|
4772
|
+
// try get member to see if the installation is still valid
|
4773
|
+
valid = yield this.validateInstallation(reference);
|
4774
|
+
}
|
4775
|
+
if (!validationEnabled || (validationEnabled && valid)) {
|
4772
4776
|
targets.push(new TeamsBotInstallation(this.adapter, reference, this.botAppId));
|
4773
4777
|
}
|
4774
4778
|
else {
|
@@ -5041,9 +5045,9 @@ class ConversationBot {
|
|
5041
5045
|
// the default error handler
|
5042
5046
|
adapter.onTurnError = (context, error) => tslib.__awaiter(this, void 0, void 0, function* () {
|
5043
5047
|
// This check writes out errors to console.
|
5044
|
-
console.error(`[onTurnError] unhandled error
|
5048
|
+
console.error(`[onTurnError] unhandled error`, error);
|
5045
5049
|
// Send a trace activity, which will be displayed in Bot Framework Emulator
|
5046
|
-
yield context.sendTraceActivity("OnTurnError Trace",
|
5050
|
+
yield context.sendTraceActivity("OnTurnError Trace", error instanceof Error ? error.message : error, "https://www.botframework.com/schemas/error", "TurnError");
|
5047
5051
|
// Send a message to the user
|
5048
5052
|
yield context.sendActivity(`The bot encountered unhandled error: ${error.message}`);
|
5049
5053
|
yield context.sendActivity("To continue to run this bot, please fix the bot source code.");
|