@microsoft/teamsfx 2.2.3-alpha.0c7c513de.0 → 2.2.3-alpha.13d1e618d.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/README.md +5 -6
- package/dist/index.esm2017.js +18 -18
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +43 -29
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +15 -43
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +85 -77
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +4 -4
- package/types/teamsfx.d.ts +9 -2
package/dist/index.esm2017.mjs
CHANGED
@@ -815,7 +815,7 @@ class MsGraphAuthProvider {
|
|
815
815
|
* };
|
816
816
|
* const prompt = new TeamsBotSsoPrompt(dialogId, {
|
817
817
|
* config: config
|
818
|
-
* scopes:
|
818
|
+
* scopes: ["User.Read"],
|
819
819
|
* });
|
820
820
|
* this.addDialog(prompt);
|
821
821
|
*
|
@@ -1528,18 +1528,18 @@ class BasicAuthProvider {
|
|
1528
1528
|
* @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header or auth property already exists in request configuration.
|
1529
1529
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
1530
1530
|
*/
|
1531
|
-
|
1531
|
+
AddAuthenticationInfo(config) {
|
1532
1532
|
if (config.headers && config.headers["Authorization"]) {
|
1533
|
-
|
1533
|
+
return Promise.reject(new ErrorWithCode(ErrorMessage.AuthorizationHeaderAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists));
|
1534
1534
|
}
|
1535
1535
|
if (config.auth) {
|
1536
|
-
|
1536
|
+
return Promise.reject(new ErrorWithCode(ErrorMessage.BasicCredentialAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists));
|
1537
1537
|
}
|
1538
1538
|
config.auth = {
|
1539
1539
|
username: this.userName,
|
1540
1540
|
password: this.password,
|
1541
1541
|
};
|
1542
|
-
return config;
|
1542
|
+
return Promise.resolve(config);
|
1543
1543
|
}
|
1544
1544
|
}
|
1545
1545
|
|
@@ -1579,14 +1579,14 @@ class ApiKeyProvider {
|
|
1579
1579
|
* @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when API key already exists in request header or url query parameter.
|
1580
1580
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
1581
1581
|
*/
|
1582
|
-
|
1582
|
+
AddAuthenticationInfo(config) {
|
1583
1583
|
switch (this.keyLocation) {
|
1584
1584
|
case ApiKeyLocation.Header:
|
1585
1585
|
if (!config.headers) {
|
1586
1586
|
config.headers = {};
|
1587
1587
|
}
|
1588
1588
|
if (config.headers[this.keyName]) {
|
1589
|
-
|
1589
|
+
return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.DuplicateApiKeyInHeader, this.keyName), ErrorCode.AuthorizationInfoAlreadyExists));
|
1590
1590
|
}
|
1591
1591
|
config.headers[this.keyName] = this.keyValue;
|
1592
1592
|
break;
|
@@ -1600,12 +1600,12 @@ class ApiKeyProvider {
|
|
1600
1600
|
urlHasDefinedApiKey = url.searchParams.has(this.keyName);
|
1601
1601
|
}
|
1602
1602
|
if (config.params[this.keyName] || urlHasDefinedApiKey) {
|
1603
|
-
|
1603
|
+
return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.DuplicateApiKeyInQueryParam, this.keyName), ErrorCode.AuthorizationInfoAlreadyExists));
|
1604
1604
|
}
|
1605
1605
|
config.params[this.keyName] = this.keyValue;
|
1606
1606
|
break;
|
1607
1607
|
}
|
1608
|
-
return config;
|
1608
|
+
return Promise.resolve(config);
|
1609
1609
|
}
|
1610
1610
|
}
|
1611
1611
|
/**
|
@@ -1652,7 +1652,7 @@ class CertificateAuthProvider {
|
|
1652
1652
|
*
|
1653
1653
|
* @throws {@link ErrorCode|InvalidParameter} - when custom httpsAgent in the request has duplicate properties with certOption provided in constructor.
|
1654
1654
|
*/
|
1655
|
-
|
1655
|
+
AddAuthenticationInfo(config) {
|
1656
1656
|
if (!config.httpsAgent) {
|
1657
1657
|
config.httpsAgent = new Agent(this.certOption);
|
1658
1658
|
}
|
@@ -1660,12 +1660,12 @@ class CertificateAuthProvider {
|
|
1660
1660
|
const existingProperties = new Set(Object.keys(config.httpsAgent.options));
|
1661
1661
|
for (const property of Object.keys(this.certOption)) {
|
1662
1662
|
if (existingProperties.has(property)) {
|
1663
|
-
|
1663
|
+
return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.DuplicateHttpsOptionProperty, property), ErrorCode.InvalidParameter));
|
1664
1664
|
}
|
1665
1665
|
}
|
1666
1666
|
Object.assign(config.httpsAgent.options, this.certOption);
|
1667
1667
|
}
|
1668
|
-
return config;
|
1668
|
+
return Promise.resolve(config);
|
1669
1669
|
}
|
1670
1670
|
}
|
1671
1671
|
/**
|
@@ -2719,7 +2719,7 @@ class Channel$1 {
|
|
2719
2719
|
async sendMessage(text, onError) {
|
2720
2720
|
const response = {};
|
2721
2721
|
await this.parent.adapter.continueConversation(this.parent.conversationReference, async (context) => {
|
2722
|
-
const conversation =
|
2722
|
+
const conversation = this.newConversation(context);
|
2723
2723
|
await this.parent.adapter.continueConversation(conversation, async (ctx) => {
|
2724
2724
|
try {
|
2725
2725
|
const res = await ctx.sendActivity(text);
|
@@ -2748,7 +2748,7 @@ class Channel$1 {
|
|
2748
2748
|
async sendAdaptiveCard(card, onError) {
|
2749
2749
|
const response = {};
|
2750
2750
|
await this.parent.adapter.continueConversation(this.parent.conversationReference, async (context) => {
|
2751
|
-
const conversation =
|
2751
|
+
const conversation = this.newConversation(context);
|
2752
2752
|
await this.parent.adapter.continueConversation(conversation, async (ctx) => {
|
2753
2753
|
try {
|
2754
2754
|
const res = await ctx.sendActivity({
|
@@ -2771,7 +2771,7 @@ class Channel$1 {
|
|
2771
2771
|
/**
|
2772
2772
|
* @internal
|
2773
2773
|
*/
|
2774
|
-
|
2774
|
+
newConversation(context) {
|
2775
2775
|
const reference = TurnContext.getConversationReference(context.activity);
|
2776
2776
|
const channelConversation = cloneConversation(reference);
|
2777
2777
|
channelConversation.conversation.id = this.info.id || "";
|
@@ -4556,6 +4556,27 @@ class NotificationBot {
|
|
4556
4556
|
}
|
4557
4557
|
return new TeamsBotInstallation(this.adapter, conversationReference, this.botAppId);
|
4558
4558
|
}
|
4559
|
+
/**
|
4560
|
+
* Validate the installation by getting paged memebers.
|
4561
|
+
*
|
4562
|
+
* @param conversationReference The bound `ConversationReference`.
|
4563
|
+
* @returns Returns false if recieves `BotNotInConversationRoster` error, otherwise returns true.
|
4564
|
+
*/
|
4565
|
+
async validateInstallation(conversationReference) {
|
4566
|
+
let isValid = true;
|
4567
|
+
await this.adapter.continueConversationAsync(this.botAppId, conversationReference, async (context) => {
|
4568
|
+
try {
|
4569
|
+
// try get member to see if the installation is still valid
|
4570
|
+
await TeamsInfo.getPagedMembers(context, 1);
|
4571
|
+
}
|
4572
|
+
catch (error) {
|
4573
|
+
if (error.code === "BotNotInConversationRoster") {
|
4574
|
+
isValid = false;
|
4575
|
+
}
|
4576
|
+
}
|
4577
|
+
});
|
4578
|
+
return isValid;
|
4579
|
+
}
|
4559
4580
|
/**
|
4560
4581
|
* Gets a pagined list of targets where the bot is installed.
|
4561
4582
|
*
|
@@ -4567,7 +4588,7 @@ class NotificationBot {
|
|
4567
4588
|
*
|
4568
4589
|
* @returns An array of {@link TeamsBotInstallation} with paged data and continuation token.
|
4569
4590
|
*/
|
4570
|
-
async getPagedInstallations(pageSize, continuationToken) {
|
4591
|
+
async getPagedInstallations(pageSize, continuationToken, validationEnabled = true) {
|
4571
4592
|
if (this.conversationReferenceStore === undefined || this.adapter === undefined) {
|
4572
4593
|
throw new Error("NotificationBot has not been initialized.");
|
4573
4594
|
}
|
@@ -4575,19 +4596,12 @@ class NotificationBot {
|
|
4575
4596
|
const targets = [];
|
4576
4597
|
for (const reference of references.data) {
|
4577
4598
|
// validate connection
|
4578
|
-
let valid
|
4579
|
-
|
4580
|
-
try
|
4581
|
-
|
4582
|
-
|
4583
|
-
|
4584
|
-
catch (error) {
|
4585
|
-
if (error.code === "BotNotInConversationRoster") {
|
4586
|
-
valid = false;
|
4587
|
-
}
|
4588
|
-
}
|
4589
|
-
});
|
4590
|
-
if (valid) {
|
4599
|
+
let valid;
|
4600
|
+
if (validationEnabled) {
|
4601
|
+
// try get member to see if the installation is still valid
|
4602
|
+
valid = await this.validateInstallation(reference);
|
4603
|
+
}
|
4604
|
+
if (!validationEnabled || (validationEnabled && valid)) {
|
4591
4605
|
targets.push(new TeamsBotInstallation(this.adapter, reference, this.botAppId));
|
4592
4606
|
}
|
4593
4607
|
else {
|