@microsoft/teamsfx 2.3.0-rc-hotfix.0 → 2.3.1-alpha.041c93f76.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 +3 -2
- package/dist/index.esm2017.js +1 -0
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +112 -9
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +31 -1
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +235 -119
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +26 -9
- package/types/teamsfx.d.ts +23 -3
package/dist/index.esm2017.mjs
CHANGED
@@ -10,7 +10,6 @@ import axios from 'axios';
|
|
10
10
|
import { Agent } from 'https';
|
11
11
|
import * as path from 'path';
|
12
12
|
import * as fs from 'fs';
|
13
|
-
import { __rest } from 'tslib';
|
14
13
|
import { AdaptiveCards } from '@microsoft/adaptivecards-tools';
|
15
14
|
|
16
15
|
// Copyright (c) Microsoft Corporation.
|
@@ -139,6 +138,7 @@ ErrorMessage.DuplicateHttpsOptionProperty = "Axios HTTPS agent already defined v
|
|
139
138
|
ErrorMessage.DuplicateApiKeyInHeader = "The request already defined api key in request header with name {0}.";
|
140
139
|
ErrorMessage.DuplicateApiKeyInQueryParam = "The request already defined api key in query parameter with name {0}.";
|
141
140
|
ErrorMessage.OnlySupportInQueryActivity = "The handleMessageExtensionQueryWithToken only support in handleTeamsMessagingExtensionQuery with composeExtension/query type.";
|
141
|
+
ErrorMessage.OnlySupportInLinkQueryActivity = "The handleMessageExtensionLinkQueryWithSSO only support in handleTeamsAppBasedLinkQuery with composeExtension/queryLink type.";
|
142
142
|
/**
|
143
143
|
* Error class with code and message thrown by the SDK.
|
144
144
|
*/
|
@@ -1985,6 +1985,7 @@ var InvokeResponseErrorCode;
|
|
1985
1985
|
InvokeResponseErrorCode[InvokeResponseErrorCode["InternalServerError"] = 500] = "InternalServerError";
|
1986
1986
|
})(InvokeResponseErrorCode || (InvokeResponseErrorCode = {}));
|
1987
1987
|
|
1988
|
+
// Copyright (c) Microsoft Corporation.
|
1988
1989
|
/**
|
1989
1990
|
* Available response type for an adaptive card invoke response.
|
1990
1991
|
* @internal
|
@@ -1999,7 +2000,7 @@ var InvokeResponseType;
|
|
1999
2000
|
* Provides methods for formatting various invoke responses a bot can send to respond to an invoke request.
|
2000
2001
|
*
|
2001
2002
|
* @remarks
|
2002
|
-
* All of these functions return an
|
2003
|
+
* All of these functions return an `InvokeResponse` object, which can be
|
2003
2004
|
* passed as input to generate a new `invokeResponse` activity.
|
2004
2005
|
*
|
2005
2006
|
* This example sends an invoke response that contains an adaptive card.
|
@@ -2424,6 +2425,7 @@ function cloneConversation(conversation) {
|
|
2424
2425
|
*/
|
2425
2426
|
function getKey(reference) {
|
2426
2427
|
var _a, _b;
|
2428
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
2427
2429
|
return `_${(_a = reference.conversation) === null || _a === void 0 ? void 0 : _a.tenantId}_${(_b = reference.conversation) === null || _b === void 0 ? void 0 : _b.id}`;
|
2428
2430
|
}
|
2429
2431
|
/**
|
@@ -3222,6 +3224,38 @@ var SearchScope$1;
|
|
3222
3224
|
SearchScope[SearchScope["All"] = 7] = "All";
|
3223
3225
|
})(SearchScope$1 || (SearchScope$1 = {}));
|
3224
3226
|
|
3227
|
+
/******************************************************************************
|
3228
|
+
Copyright (c) Microsoft Corporation.
|
3229
|
+
|
3230
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
3231
|
+
purpose with or without fee is hereby granted.
|
3232
|
+
|
3233
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
3234
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
3235
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
3236
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
3237
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
3238
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
3239
|
+
PERFORMANCE OF THIS SOFTWARE.
|
3240
|
+
***************************************************************************** */
|
3241
|
+
|
3242
|
+
function __rest(s, e) {
|
3243
|
+
var t = {};
|
3244
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
3245
|
+
t[p] = s[p];
|
3246
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
3247
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
3248
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
3249
|
+
t[p[i]] = s[p[i]];
|
3250
|
+
}
|
3251
|
+
return t;
|
3252
|
+
}
|
3253
|
+
|
3254
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
3255
|
+
var e = new Error(message);
|
3256
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
3257
|
+
};
|
3258
|
+
|
3225
3259
|
// Copyright (c) Microsoft Corporation.
|
3226
3260
|
let DIALOG_NAME = "BotSsoExecutionDialog";
|
3227
3261
|
let TEAMS_SSO_PROMPT_ID = "TeamsFxSsoPrompt";
|
@@ -3554,7 +3588,7 @@ class DefaultBotSsoExecutionActivityHandler extends TeamsActivityHandler {
|
|
3554
3588
|
* @param query Signin state (part of signin action auth flow) verification invoke query
|
3555
3589
|
* @returns A promise that represents the work queued.
|
3556
3590
|
*
|
3557
|
-
* @
|
3591
|
+
* @remarks
|
3558
3592
|
* It should trigger {@link BotSsoExecutionDialog} instance to handle signin process
|
3559
3593
|
*/
|
3560
3594
|
async handleTeamsSigninTokenExchange(context, query) {
|
@@ -3664,9 +3698,12 @@ class ConversationBot$1 {
|
|
3664
3698
|
// the default error handler
|
3665
3699
|
adapter.onTurnError = async (context, error) => {
|
3666
3700
|
// This check writes out errors to console.
|
3701
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
3667
3702
|
console.error(`[onTurnError] unhandled error: ${error}`);
|
3668
3703
|
// Send a trace activity, which will be displayed in Bot Framework Emulator
|
3669
|
-
await context.sendTraceActivity("OnTurnError Trace",
|
3704
|
+
await context.sendTraceActivity("OnTurnError Trace",
|
3705
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
3706
|
+
`${error}`, "https://www.botframework.com/schemas/error", "TurnError");
|
3670
3707
|
// Send a message to the user
|
3671
3708
|
await context.sendActivity(`The bot encountered unhandled error: ${error.message}`);
|
3672
3709
|
await context.sendActivity("To continue to run this bot, please fix the bot source code.");
|
@@ -3848,9 +3885,9 @@ class MessageBuilder {
|
|
3848
3885
|
* @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
|
3849
3886
|
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
3850
3887
|
*
|
3851
|
-
* @returns SignIn link CardAction with 200 status code.
|
3888
|
+
* @returns SignIn link SilentAuth CardAction with 200 status code.
|
3852
3889
|
*/
|
3853
|
-
function
|
3890
|
+
function getSignInResponseForMessageExtensionWithSilentAuthConfig(authConfig, initiateLoginEndpoint, scopes) {
|
3854
3891
|
const scopesArray = getScopesArray(scopes);
|
3855
3892
|
const signInLink = `${initiateLoginEndpoint}?scope=${encodeURI(scopesArray.join(" "))}&clientId=${authConfig.clientId}&tenantId=${authConfig.tenantId}`;
|
3856
3893
|
return {
|
@@ -3868,6 +3905,34 @@ function getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiate
|
|
3868
3905
|
},
|
3869
3906
|
};
|
3870
3907
|
}
|
3908
|
+
/**
|
3909
|
+
* Retrieve the OAuth Sign in Link to use in the MessagingExtensionResult Suggested Actions.
|
3910
|
+
* This method just a workaround for link unfurling now.
|
3911
|
+
*
|
3912
|
+
* @param {OnBehalfOfCredentialAuthConfig} authConfig - User custom the message extension authentication configuration.
|
3913
|
+
* @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
|
3914
|
+
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
3915
|
+
*
|
3916
|
+
* @returns SignIn link Auth CardAction with 200 status code.
|
3917
|
+
*/
|
3918
|
+
function getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiateLoginEndpoint, scopes) {
|
3919
|
+
const scopesArray = getScopesArray(scopes);
|
3920
|
+
const signInLink = `${initiateLoginEndpoint}?scope=${encodeURI(scopesArray.join(" "))}&clientId=${authConfig.clientId}&tenantId=${authConfig.tenantId}`;
|
3921
|
+
return {
|
3922
|
+
composeExtension: {
|
3923
|
+
type: "auth",
|
3924
|
+
suggestedActions: {
|
3925
|
+
actions: [
|
3926
|
+
{
|
3927
|
+
type: "openUrl",
|
3928
|
+
value: signInLink,
|
3929
|
+
title: "Message Extension OAuth",
|
3930
|
+
},
|
3931
|
+
],
|
3932
|
+
},
|
3933
|
+
},
|
3934
|
+
};
|
3935
|
+
}
|
3871
3936
|
/**
|
3872
3937
|
* Retrieve the OAuth Sign in Link to use in the MessagingExtensionResult Suggested Actions.
|
3873
3938
|
* This method only work on MessageExtension with Query now.
|
@@ -3916,7 +3981,7 @@ async function executionWithTokenAndConfig(context, authConfig, initiateLoginEnd
|
|
3916
3981
|
const valueObj = context.activity.value;
|
3917
3982
|
if (!valueObj.authentication || !valueObj.authentication.token) {
|
3918
3983
|
internalLogger.verbose("No AccessToken in request, return silentAuth for AccessToken");
|
3919
|
-
return
|
3984
|
+
return getSignInResponseForMessageExtensionWithSilentAuthConfig(authConfig, initiateLoginEndpoint, scopes);
|
3920
3985
|
}
|
3921
3986
|
try {
|
3922
3987
|
const credential = new OnBehalfOfUserCredential(valueObj.authentication.token, authConfig);
|
@@ -3934,12 +3999,25 @@ async function executionWithTokenAndConfig(context, authConfig, initiateLoginEnd
|
|
3934
3999
|
}
|
3935
4000
|
}
|
3936
4001
|
catch (err) {
|
3937
|
-
if (err instanceof ErrorWithCode &&
|
4002
|
+
if (err instanceof ErrorWithCode &&
|
4003
|
+
err.code === ErrorCode.UiRequiredError &&
|
4004
|
+
context.activity.name === "composeExtension/query") {
|
3938
4005
|
internalLogger.verbose("User not consent yet, return 412 to user consent first.");
|
3939
4006
|
const response = { status: 412 };
|
3940
4007
|
await context.sendActivity({ value: response, type: ActivityTypes.InvokeResponse });
|
3941
4008
|
return;
|
3942
4009
|
}
|
4010
|
+
else if (err instanceof ErrorWithCode &&
|
4011
|
+
err.code === ErrorCode.UiRequiredError &&
|
4012
|
+
context.activity.name === "composeExtension/queryLink") {
|
4013
|
+
internalLogger.verbose("User not consent yet, return auth card for user login");
|
4014
|
+
const response = getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiateLoginEndpoint, scopes);
|
4015
|
+
await context.sendActivity({
|
4016
|
+
value: { status: 200, body: response },
|
4017
|
+
type: ActivityTypes.InvokeResponse,
|
4018
|
+
});
|
4019
|
+
return;
|
4020
|
+
}
|
3943
4021
|
throw err;
|
3944
4022
|
}
|
3945
4023
|
}
|
@@ -4041,6 +4119,31 @@ async function handleMessageExtensionQueryWithSSO(context, config, initiateLogin
|
|
4041
4119
|
throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInQueryActivity), ErrorCode.FailedOperation);
|
4042
4120
|
}
|
4043
4121
|
return await executionWithTokenAndConfig(context, config !== null && config !== void 0 ? config : {}, initiateLoginEndpoint, scopes, logic);
|
4122
|
+
}
|
4123
|
+
/**
|
4124
|
+
* Users execute link query in message extension with SSO or access token.
|
4125
|
+
*
|
4126
|
+
* @param {TurnContext} context - The context object for the current turn.
|
4127
|
+
* @param {OnBehalfOfCredentialAuthConfig} config - User custom the message extension authentication configuration.
|
4128
|
+
* @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
|
4129
|
+
* @param {string| string[]} scopes - The list of scopes for which the token will have access.
|
4130
|
+
* @param {function} logic - Business logic when executing the link query in message extension with SSO or access token.
|
4131
|
+
*
|
4132
|
+
* @throws {@link ErrorCode|InternalError} when User invoke not response to message extension link query.
|
4133
|
+
* @throws {@link ErrorCode|InternalError} when failed to get access token with unknown error.
|
4134
|
+
* @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
|
4135
|
+
* @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth server.
|
4136
|
+
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
4137
|
+
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
4138
|
+
*
|
4139
|
+
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4140
|
+
*/
|
4141
|
+
async function handleMessageExtensionLinkQueryWithSSO(context, config, initiateLoginEndpoint, scopes, logic) {
|
4142
|
+
if (context.activity.name != "composeExtension/queryLink") {
|
4143
|
+
internalLogger.error(ErrorMessage.OnlySupportInLinkQueryActivity);
|
4144
|
+
throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInLinkQueryActivity), ErrorCode.FailedOperation);
|
4145
|
+
}
|
4146
|
+
return await executionWithTokenAndConfig(context, config !== null && config !== void 0 ? config : {}, initiateLoginEndpoint, scopes, logic);
|
4044
4147
|
}
|
4045
4148
|
|
4046
4149
|
/**
|
@@ -4941,5 +5044,5 @@ var conversationWithCloudAdapter = /*#__PURE__*/Object.freeze({
|
|
4941
5044
|
CardActionBot: CardActionBot
|
4942
5045
|
});
|
4943
5046
|
|
4944
|
-
export { AdaptiveCardResponse, ApiKeyLocation, ApiKeyProvider, AppCredential, BasicAuthProvider, BearerTokenAuthProvider, conversationWithCloudAdapter as BotBuilderCloudAdapter, BotSsoExecutionDialog, CardActionBot$1 as CardActionBot, CertificateAuthProvider, Channel$1 as Channel, CommandBot$1 as CommandBot, ConversationBot$1 as ConversationBot, ErrorCode, ErrorWithCode, IdentityType, InvokeResponseErrorCode, InvokeResponseFactory, LogLevel, Member$1 as Member, MessageBuilder, MsGraphAuthProvider, NotificationBot$1 as NotificationBot, NotificationTargetType, OnBehalfOfUserCredential, SearchScope$1 as SearchScope, TeamsBotInstallation$1 as TeamsBotInstallation, TeamsBotSsoPrompt, TeamsFx, TeamsUserCredential, createApiClient, createMicrosoftGraphClient, createMicrosoftGraphClientWithCredential, createPemCertOption, createPfxCertOption, getLogLevel, getTediousConnectionConfig, handleMessageExtensionQueryWithSSO, handleMessageExtensionQueryWithToken, sendAdaptiveCard$1 as sendAdaptiveCard, sendMessage$1 as sendMessage, setLogFunction, setLogLevel, setLogger };
|
5047
|
+
export { AdaptiveCardResponse, ApiKeyLocation, ApiKeyProvider, AppCredential, BasicAuthProvider, BearerTokenAuthProvider, conversationWithCloudAdapter as BotBuilderCloudAdapter, BotSsoExecutionDialog, CardActionBot$1 as CardActionBot, CertificateAuthProvider, Channel$1 as Channel, CommandBot$1 as CommandBot, ConversationBot$1 as ConversationBot, ErrorCode, ErrorWithCode, IdentityType, InvokeResponseErrorCode, InvokeResponseFactory, LogLevel, Member$1 as Member, MessageBuilder, MsGraphAuthProvider, NotificationBot$1 as NotificationBot, NotificationTargetType, OnBehalfOfUserCredential, SearchScope$1 as SearchScope, TeamsBotInstallation$1 as TeamsBotInstallation, TeamsBotSsoPrompt, TeamsFx, TeamsUserCredential, createApiClient, createMicrosoftGraphClient, createMicrosoftGraphClientWithCredential, createPemCertOption, createPfxCertOption, getLogLevel, getTediousConnectionConfig, handleMessageExtensionLinkQueryWithSSO, handleMessageExtensionQueryWithSSO, handleMessageExtensionQueryWithToken, sendAdaptiveCard$1 as sendAdaptiveCard, sendMessage$1 as sendMessage, setLogFunction, setLogLevel, setLogger };
|
4945
5048
|
//# sourceMappingURL=index.esm2017.mjs.map
|