@microsoft/teamsfx 2.3.1-alpha.e73e76fb5.0 → 2.3.1-alpha.e7a27e1e4.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 +1 -0
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +74 -6
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +1 -0
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +76 -5
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +3 -3
- package/types/teamsfx.d.ts +20 -0
package/dist/index.esm2017.mjs
CHANGED
@@ -138,6 +138,7 @@ ErrorMessage.DuplicateHttpsOptionProperty = "Axios HTTPS agent already defined v
|
|
138
138
|
ErrorMessage.DuplicateApiKeyInHeader = "The request already defined api key in request header with name {0}.";
|
139
139
|
ErrorMessage.DuplicateApiKeyInQueryParam = "The request already defined api key in query parameter with name {0}.";
|
140
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.";
|
141
142
|
/**
|
142
143
|
* Error class with code and message thrown by the SDK.
|
143
144
|
*/
|
@@ -2559,7 +2560,8 @@ class NotificationMiddleware {
|
|
2559
2560
|
*/
|
2560
2561
|
class LocalFileStorage {
|
2561
2562
|
constructor(fileDir) {
|
2562
|
-
|
2563
|
+
var _a;
|
2564
|
+
this.localFileName = (_a = process.env.TEAMSFX_NOTIFICATION_STORE_FILENAME) !== null && _a !== void 0 ? _a : ".notification.localstore.json";
|
2563
2565
|
this.filePath = path.resolve(fileDir, this.localFileName);
|
2564
2566
|
}
|
2565
2567
|
async read(key) {
|
@@ -3884,9 +3886,9 @@ class MessageBuilder {
|
|
3884
3886
|
* @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
|
3885
3887
|
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
3886
3888
|
*
|
3887
|
-
* @returns SignIn link CardAction with 200 status code.
|
3889
|
+
* @returns SignIn link SilentAuth CardAction with 200 status code.
|
3888
3890
|
*/
|
3889
|
-
function
|
3891
|
+
function getSignInResponseForMessageExtensionWithSilentAuthConfig(authConfig, initiateLoginEndpoint, scopes) {
|
3890
3892
|
const scopesArray = getScopesArray(scopes);
|
3891
3893
|
const signInLink = `${initiateLoginEndpoint}?scope=${encodeURI(scopesArray.join(" "))}&clientId=${authConfig.clientId}&tenantId=${authConfig.tenantId}`;
|
3892
3894
|
return {
|
@@ -3904,6 +3906,34 @@ function getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiate
|
|
3904
3906
|
},
|
3905
3907
|
};
|
3906
3908
|
}
|
3909
|
+
/**
|
3910
|
+
* Retrieve the OAuth Sign in Link to use in the MessagingExtensionResult Suggested Actions.
|
3911
|
+
* This method just a workaround for link unfurling now.
|
3912
|
+
*
|
3913
|
+
* @param {OnBehalfOfCredentialAuthConfig} authConfig - User custom the message extension authentication configuration.
|
3914
|
+
* @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
|
3915
|
+
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
3916
|
+
*
|
3917
|
+
* @returns SignIn link Auth CardAction with 200 status code.
|
3918
|
+
*/
|
3919
|
+
function getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiateLoginEndpoint, scopes) {
|
3920
|
+
const scopesArray = getScopesArray(scopes);
|
3921
|
+
const signInLink = `${initiateLoginEndpoint}?scope=${encodeURI(scopesArray.join(" "))}&clientId=${authConfig.clientId}&tenantId=${authConfig.tenantId}`;
|
3922
|
+
return {
|
3923
|
+
composeExtension: {
|
3924
|
+
type: "auth",
|
3925
|
+
suggestedActions: {
|
3926
|
+
actions: [
|
3927
|
+
{
|
3928
|
+
type: "openUrl",
|
3929
|
+
value: signInLink,
|
3930
|
+
title: "Message Extension OAuth",
|
3931
|
+
},
|
3932
|
+
],
|
3933
|
+
},
|
3934
|
+
},
|
3935
|
+
};
|
3936
|
+
}
|
3907
3937
|
/**
|
3908
3938
|
* Retrieve the OAuth Sign in Link to use in the MessagingExtensionResult Suggested Actions.
|
3909
3939
|
* This method only work on MessageExtension with Query now.
|
@@ -3952,7 +3982,7 @@ async function executionWithTokenAndConfig(context, authConfig, initiateLoginEnd
|
|
3952
3982
|
const valueObj = context.activity.value;
|
3953
3983
|
if (!valueObj.authentication || !valueObj.authentication.token) {
|
3954
3984
|
internalLogger.verbose("No AccessToken in request, return silentAuth for AccessToken");
|
3955
|
-
return
|
3985
|
+
return getSignInResponseForMessageExtensionWithSilentAuthConfig(authConfig, initiateLoginEndpoint, scopes);
|
3956
3986
|
}
|
3957
3987
|
try {
|
3958
3988
|
const credential = new OnBehalfOfUserCredential(valueObj.authentication.token, authConfig);
|
@@ -3970,12 +4000,25 @@ async function executionWithTokenAndConfig(context, authConfig, initiateLoginEnd
|
|
3970
4000
|
}
|
3971
4001
|
}
|
3972
4002
|
catch (err) {
|
3973
|
-
if (err instanceof ErrorWithCode &&
|
4003
|
+
if (err instanceof ErrorWithCode &&
|
4004
|
+
err.code === ErrorCode.UiRequiredError &&
|
4005
|
+
context.activity.name === "composeExtension/query") {
|
3974
4006
|
internalLogger.verbose("User not consent yet, return 412 to user consent first.");
|
3975
4007
|
const response = { status: 412 };
|
3976
4008
|
await context.sendActivity({ value: response, type: ActivityTypes.InvokeResponse });
|
3977
4009
|
return;
|
3978
4010
|
}
|
4011
|
+
else if (err instanceof ErrorWithCode &&
|
4012
|
+
err.code === ErrorCode.UiRequiredError &&
|
4013
|
+
context.activity.name === "composeExtension/queryLink") {
|
4014
|
+
internalLogger.verbose("User not consent yet, return auth card for user login");
|
4015
|
+
const response = getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiateLoginEndpoint, scopes);
|
4016
|
+
await context.sendActivity({
|
4017
|
+
value: { status: 200, body: response },
|
4018
|
+
type: ActivityTypes.InvokeResponse,
|
4019
|
+
});
|
4020
|
+
return;
|
4021
|
+
}
|
3979
4022
|
throw err;
|
3980
4023
|
}
|
3981
4024
|
}
|
@@ -4077,6 +4120,31 @@ async function handleMessageExtensionQueryWithSSO(context, config, initiateLogin
|
|
4077
4120
|
throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInQueryActivity), ErrorCode.FailedOperation);
|
4078
4121
|
}
|
4079
4122
|
return await executionWithTokenAndConfig(context, config !== null && config !== void 0 ? config : {}, initiateLoginEndpoint, scopes, logic);
|
4123
|
+
}
|
4124
|
+
/**
|
4125
|
+
* Users execute link query in message extension with SSO or access token.
|
4126
|
+
*
|
4127
|
+
* @param {TurnContext} context - The context object for the current turn.
|
4128
|
+
* @param {OnBehalfOfCredentialAuthConfig} config - User custom the message extension authentication configuration.
|
4129
|
+
* @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
|
4130
|
+
* @param {string| string[]} scopes - The list of scopes for which the token will have access.
|
4131
|
+
* @param {function} logic - Business logic when executing the link query in message extension with SSO or access token.
|
4132
|
+
*
|
4133
|
+
* @throws {@link ErrorCode|InternalError} when User invoke not response to message extension link query.
|
4134
|
+
* @throws {@link ErrorCode|InternalError} when failed to get access token with unknown error.
|
4135
|
+
* @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
|
4136
|
+
* @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth server.
|
4137
|
+
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
4138
|
+
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
4139
|
+
*
|
4140
|
+
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4141
|
+
*/
|
4142
|
+
async function handleMessageExtensionLinkQueryWithSSO(context, config, initiateLoginEndpoint, scopes, logic) {
|
4143
|
+
if (context.activity.name != "composeExtension/queryLink") {
|
4144
|
+
internalLogger.error(ErrorMessage.OnlySupportInLinkQueryActivity);
|
4145
|
+
throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInLinkQueryActivity), ErrorCode.FailedOperation);
|
4146
|
+
}
|
4147
|
+
return await executionWithTokenAndConfig(context, config !== null && config !== void 0 ? config : {}, initiateLoginEndpoint, scopes, logic);
|
4080
4148
|
}
|
4081
4149
|
|
4082
4150
|
/**
|
@@ -4977,5 +5045,5 @@ var conversationWithCloudAdapter = /*#__PURE__*/Object.freeze({
|
|
4977
5045
|
CardActionBot: CardActionBot
|
4978
5046
|
});
|
4979
5047
|
|
4980
|
-
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 };
|
5048
|
+
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 };
|
4981
5049
|
//# sourceMappingURL=index.esm2017.mjs.map
|