@microsoft/teamsfx 2.3.0 → 2.3.1-alpha.0028ae747.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 +2 -1
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +119 -13
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +32 -2
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +242 -123
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +28 -11
- 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
|
*/
|
@@ -1475,7 +1475,7 @@ function createApiClient(apiEndpoint, authProvider) {
|
|
1475
1475
|
baseURL: apiEndpoint,
|
1476
1476
|
});
|
1477
1477
|
instance.interceptors.request.use(async function (config) {
|
1478
|
-
return await authProvider.AddAuthenticationInfo(config);
|
1478
|
+
return (await authProvider.AddAuthenticationInfo(config));
|
1479
1479
|
});
|
1480
1480
|
return instance;
|
1481
1481
|
}
|
@@ -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
|
/**
|
@@ -2533,7 +2535,7 @@ class NotificationMiddleware {
|
|
2533
2535
|
return ActivityType.Unknown;
|
2534
2536
|
}
|
2535
2537
|
async tryAddMessagedReference(context) {
|
2536
|
-
var _a, _b, _c, _d;
|
2538
|
+
var _a, _b, _c, _d, _e, _f;
|
2537
2539
|
const reference = TurnContext.getConversationReference(context.activity);
|
2538
2540
|
const conversationType = (_a = reference === null || reference === void 0 ? void 0 : reference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
|
2539
2541
|
if (conversationType === "personal" || conversationType === "groupChat") {
|
@@ -2541,7 +2543,9 @@ class NotificationMiddleware {
|
|
2541
2543
|
}
|
2542
2544
|
else if (conversationType === "channel") {
|
2543
2545
|
const teamId = (_d = (_c = (_b = context.activity) === null || _b === void 0 ? void 0 : _b.channelData) === null || _c === void 0 ? void 0 : _c.team) === null || _d === void 0 ? void 0 : _d.id;
|
2544
|
-
|
2546
|
+
const channelId = (_f = (_e = context.activity.channelData) === null || _e === void 0 ? void 0 : _e.channel) === null || _f === void 0 ? void 0 : _f.id;
|
2547
|
+
// `teamId === channelId` means General channel. Ignore messaging in non-General channel.
|
2548
|
+
if (teamId !== undefined && (channelId === undefined || teamId === channelId)) {
|
2545
2549
|
const teamReference = cloneConversation(reference);
|
2546
2550
|
teamReference.conversation.id = teamId;
|
2547
2551
|
await this.conversationReferenceStore.add(getKey(teamReference), teamReference, {
|
@@ -2558,7 +2562,8 @@ class NotificationMiddleware {
|
|
2558
2562
|
*/
|
2559
2563
|
class LocalFileStorage {
|
2560
2564
|
constructor(fileDir) {
|
2561
|
-
|
2565
|
+
var _a;
|
2566
|
+
this.localFileName = (_a = process.env.TEAMSFX_NOTIFICATION_STORE_FILENAME) !== null && _a !== void 0 ? _a : ".notification.localstore.json";
|
2562
2567
|
this.filePath = path.resolve(fileDir, this.localFileName);
|
2563
2568
|
}
|
2564
2569
|
async read(key) {
|
@@ -3222,6 +3227,38 @@ var SearchScope$1;
|
|
3222
3227
|
SearchScope[SearchScope["All"] = 7] = "All";
|
3223
3228
|
})(SearchScope$1 || (SearchScope$1 = {}));
|
3224
3229
|
|
3230
|
+
/******************************************************************************
|
3231
|
+
Copyright (c) Microsoft Corporation.
|
3232
|
+
|
3233
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
3234
|
+
purpose with or without fee is hereby granted.
|
3235
|
+
|
3236
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
3237
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
3238
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
3239
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
3240
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
3241
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
3242
|
+
PERFORMANCE OF THIS SOFTWARE.
|
3243
|
+
***************************************************************************** */
|
3244
|
+
|
3245
|
+
function __rest(s, e) {
|
3246
|
+
var t = {};
|
3247
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
3248
|
+
t[p] = s[p];
|
3249
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
3250
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
3251
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
3252
|
+
t[p[i]] = s[p[i]];
|
3253
|
+
}
|
3254
|
+
return t;
|
3255
|
+
}
|
3256
|
+
|
3257
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
3258
|
+
var e = new Error(message);
|
3259
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
3260
|
+
};
|
3261
|
+
|
3225
3262
|
// Copyright (c) Microsoft Corporation.
|
3226
3263
|
let DIALOG_NAME = "BotSsoExecutionDialog";
|
3227
3264
|
let TEAMS_SSO_PROMPT_ID = "TeamsFxSsoPrompt";
|
@@ -3554,7 +3591,7 @@ class DefaultBotSsoExecutionActivityHandler extends TeamsActivityHandler {
|
|
3554
3591
|
* @param query Signin state (part of signin action auth flow) verification invoke query
|
3555
3592
|
* @returns A promise that represents the work queued.
|
3556
3593
|
*
|
3557
|
-
* @
|
3594
|
+
* @remarks
|
3558
3595
|
* It should trigger {@link BotSsoExecutionDialog} instance to handle signin process
|
3559
3596
|
*/
|
3560
3597
|
async handleTeamsSigninTokenExchange(context, query) {
|
@@ -3664,9 +3701,12 @@ class ConversationBot$1 {
|
|
3664
3701
|
// the default error handler
|
3665
3702
|
adapter.onTurnError = async (context, error) => {
|
3666
3703
|
// This check writes out errors to console.
|
3704
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
3667
3705
|
console.error(`[onTurnError] unhandled error: ${error}`);
|
3668
3706
|
// Send a trace activity, which will be displayed in Bot Framework Emulator
|
3669
|
-
await context.sendTraceActivity("OnTurnError Trace",
|
3707
|
+
await context.sendTraceActivity("OnTurnError Trace",
|
3708
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
3709
|
+
`${error}`, "https://www.botframework.com/schemas/error", "TurnError");
|
3670
3710
|
// Send a message to the user
|
3671
3711
|
await context.sendActivity(`The bot encountered unhandled error: ${error.message}`);
|
3672
3712
|
await context.sendActivity("To continue to run this bot, please fix the bot source code.");
|
@@ -3848,9 +3888,9 @@ class MessageBuilder {
|
|
3848
3888
|
* @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
|
3849
3889
|
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
3850
3890
|
*
|
3851
|
-
* @returns SignIn link CardAction with 200 status code.
|
3891
|
+
* @returns SignIn link SilentAuth CardAction with 200 status code.
|
3852
3892
|
*/
|
3853
|
-
function
|
3893
|
+
function getSignInResponseForMessageExtensionWithSilentAuthConfig(authConfig, initiateLoginEndpoint, scopes) {
|
3854
3894
|
const scopesArray = getScopesArray(scopes);
|
3855
3895
|
const signInLink = `${initiateLoginEndpoint}?scope=${encodeURI(scopesArray.join(" "))}&clientId=${authConfig.clientId}&tenantId=${authConfig.tenantId}`;
|
3856
3896
|
return {
|
@@ -3868,6 +3908,34 @@ function getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiate
|
|
3868
3908
|
},
|
3869
3909
|
};
|
3870
3910
|
}
|
3911
|
+
/**
|
3912
|
+
* Retrieve the OAuth Sign in Link to use in the MessagingExtensionResult Suggested Actions.
|
3913
|
+
* This method just a workaround for link unfurling now.
|
3914
|
+
*
|
3915
|
+
* @param {OnBehalfOfCredentialAuthConfig} authConfig - User custom the message extension authentication configuration.
|
3916
|
+
* @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
|
3917
|
+
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
3918
|
+
*
|
3919
|
+
* @returns SignIn link Auth CardAction with 200 status code.
|
3920
|
+
*/
|
3921
|
+
function getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiateLoginEndpoint, scopes) {
|
3922
|
+
const scopesArray = getScopesArray(scopes);
|
3923
|
+
const signInLink = `${initiateLoginEndpoint}?scope=${encodeURI(scopesArray.join(" "))}&clientId=${authConfig.clientId}&tenantId=${authConfig.tenantId}`;
|
3924
|
+
return {
|
3925
|
+
composeExtension: {
|
3926
|
+
type: "auth",
|
3927
|
+
suggestedActions: {
|
3928
|
+
actions: [
|
3929
|
+
{
|
3930
|
+
type: "openUrl",
|
3931
|
+
value: signInLink,
|
3932
|
+
title: "Message Extension OAuth",
|
3933
|
+
},
|
3934
|
+
],
|
3935
|
+
},
|
3936
|
+
},
|
3937
|
+
};
|
3938
|
+
}
|
3871
3939
|
/**
|
3872
3940
|
* Retrieve the OAuth Sign in Link to use in the MessagingExtensionResult Suggested Actions.
|
3873
3941
|
* This method only work on MessageExtension with Query now.
|
@@ -3916,7 +3984,7 @@ async function executionWithTokenAndConfig(context, authConfig, initiateLoginEnd
|
|
3916
3984
|
const valueObj = context.activity.value;
|
3917
3985
|
if (!valueObj.authentication || !valueObj.authentication.token) {
|
3918
3986
|
internalLogger.verbose("No AccessToken in request, return silentAuth for AccessToken");
|
3919
|
-
return
|
3987
|
+
return getSignInResponseForMessageExtensionWithSilentAuthConfig(authConfig, initiateLoginEndpoint, scopes);
|
3920
3988
|
}
|
3921
3989
|
try {
|
3922
3990
|
const credential = new OnBehalfOfUserCredential(valueObj.authentication.token, authConfig);
|
@@ -3934,12 +4002,25 @@ async function executionWithTokenAndConfig(context, authConfig, initiateLoginEnd
|
|
3934
4002
|
}
|
3935
4003
|
}
|
3936
4004
|
catch (err) {
|
3937
|
-
if (err instanceof ErrorWithCode &&
|
4005
|
+
if (err instanceof ErrorWithCode &&
|
4006
|
+
err.code === ErrorCode.UiRequiredError &&
|
4007
|
+
context.activity.name === "composeExtension/query") {
|
3938
4008
|
internalLogger.verbose("User not consent yet, return 412 to user consent first.");
|
3939
4009
|
const response = { status: 412 };
|
3940
4010
|
await context.sendActivity({ value: response, type: ActivityTypes.InvokeResponse });
|
3941
4011
|
return;
|
3942
4012
|
}
|
4013
|
+
else if (err instanceof ErrorWithCode &&
|
4014
|
+
err.code === ErrorCode.UiRequiredError &&
|
4015
|
+
context.activity.name === "composeExtension/queryLink") {
|
4016
|
+
internalLogger.verbose("User not consent yet, return auth card for user login");
|
4017
|
+
const response = getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiateLoginEndpoint, scopes);
|
4018
|
+
await context.sendActivity({
|
4019
|
+
value: { status: 200, body: response },
|
4020
|
+
type: ActivityTypes.InvokeResponse,
|
4021
|
+
});
|
4022
|
+
return;
|
4023
|
+
}
|
3943
4024
|
throw err;
|
3944
4025
|
}
|
3945
4026
|
}
|
@@ -4041,6 +4122,31 @@ async function handleMessageExtensionQueryWithSSO(context, config, initiateLogin
|
|
4041
4122
|
throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInQueryActivity), ErrorCode.FailedOperation);
|
4042
4123
|
}
|
4043
4124
|
return await executionWithTokenAndConfig(context, config !== null && config !== void 0 ? config : {}, initiateLoginEndpoint, scopes, logic);
|
4125
|
+
}
|
4126
|
+
/**
|
4127
|
+
* Users execute link query in message extension with SSO or access token.
|
4128
|
+
*
|
4129
|
+
* @param {TurnContext} context - The context object for the current turn.
|
4130
|
+
* @param {OnBehalfOfCredentialAuthConfig} config - User custom the message extension authentication configuration.
|
4131
|
+
* @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
|
4132
|
+
* @param {string| string[]} scopes - The list of scopes for which the token will have access.
|
4133
|
+
* @param {function} logic - Business logic when executing the link query in message extension with SSO or access token.
|
4134
|
+
*
|
4135
|
+
* @throws {@link ErrorCode|InternalError} when User invoke not response to message extension link query.
|
4136
|
+
* @throws {@link ErrorCode|InternalError} when failed to get access token with unknown error.
|
4137
|
+
* @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
|
4138
|
+
* @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth server.
|
4139
|
+
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
4140
|
+
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
4141
|
+
*
|
4142
|
+
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4143
|
+
*/
|
4144
|
+
async function handleMessageExtensionLinkQueryWithSSO(context, config, initiateLoginEndpoint, scopes, logic) {
|
4145
|
+
if (context.activity.name != "composeExtension/queryLink") {
|
4146
|
+
internalLogger.error(ErrorMessage.OnlySupportInLinkQueryActivity);
|
4147
|
+
throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInLinkQueryActivity), ErrorCode.FailedOperation);
|
4148
|
+
}
|
4149
|
+
return await executionWithTokenAndConfig(context, config !== null && config !== void 0 ? config : {}, initiateLoginEndpoint, scopes, logic);
|
4044
4150
|
}
|
4045
4151
|
|
4046
4152
|
/**
|
@@ -4941,5 +5047,5 @@ var conversationWithCloudAdapter = /*#__PURE__*/Object.freeze({
|
|
4941
5047
|
CardActionBot: CardActionBot
|
4942
5048
|
});
|
4943
5049
|
|
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 };
|
5050
|
+
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
5051
|
//# sourceMappingURL=index.esm2017.mjs.map
|