@microsoft/teamsfx 2.3.1-alpha.7f6ee9970.0 → 2.3.1-alpha.831e41ff5.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 +72 -5
- 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 +74 -4
- 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
|
*/
|
@@ -3884,9 +3885,9 @@ class MessageBuilder {
|
|
3884
3885
|
* @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
|
3885
3886
|
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
3886
3887
|
*
|
3887
|
-
* @returns SignIn link CardAction with 200 status code.
|
3888
|
+
* @returns SignIn link SilentAuth CardAction with 200 status code.
|
3888
3889
|
*/
|
3889
|
-
function
|
3890
|
+
function getSignInResponseForMessageExtensionWithSilentAuthConfig(authConfig, initiateLoginEndpoint, scopes) {
|
3890
3891
|
const scopesArray = getScopesArray(scopes);
|
3891
3892
|
const signInLink = `${initiateLoginEndpoint}?scope=${encodeURI(scopesArray.join(" "))}&clientId=${authConfig.clientId}&tenantId=${authConfig.tenantId}`;
|
3892
3893
|
return {
|
@@ -3904,6 +3905,34 @@ function getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiate
|
|
3904
3905
|
},
|
3905
3906
|
};
|
3906
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
|
+
}
|
3907
3936
|
/**
|
3908
3937
|
* Retrieve the OAuth Sign in Link to use in the MessagingExtensionResult Suggested Actions.
|
3909
3938
|
* This method only work on MessageExtension with Query now.
|
@@ -3952,7 +3981,7 @@ async function executionWithTokenAndConfig(context, authConfig, initiateLoginEnd
|
|
3952
3981
|
const valueObj = context.activity.value;
|
3953
3982
|
if (!valueObj.authentication || !valueObj.authentication.token) {
|
3954
3983
|
internalLogger.verbose("No AccessToken in request, return silentAuth for AccessToken");
|
3955
|
-
return
|
3984
|
+
return getSignInResponseForMessageExtensionWithSilentAuthConfig(authConfig, initiateLoginEndpoint, scopes);
|
3956
3985
|
}
|
3957
3986
|
try {
|
3958
3987
|
const credential = new OnBehalfOfUserCredential(valueObj.authentication.token, authConfig);
|
@@ -3970,12 +3999,25 @@ async function executionWithTokenAndConfig(context, authConfig, initiateLoginEnd
|
|
3970
3999
|
}
|
3971
4000
|
}
|
3972
4001
|
catch (err) {
|
3973
|
-
if (err instanceof ErrorWithCode &&
|
4002
|
+
if (err instanceof ErrorWithCode &&
|
4003
|
+
err.code === ErrorCode.UiRequiredError &&
|
4004
|
+
context.activity.name === "composeExtension/query") {
|
3974
4005
|
internalLogger.verbose("User not consent yet, return 412 to user consent first.");
|
3975
4006
|
const response = { status: 412 };
|
3976
4007
|
await context.sendActivity({ value: response, type: ActivityTypes.InvokeResponse });
|
3977
4008
|
return;
|
3978
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
|
+
}
|
3979
4021
|
throw err;
|
3980
4022
|
}
|
3981
4023
|
}
|
@@ -4077,6 +4119,31 @@ async function handleMessageExtensionQueryWithSSO(context, config, initiateLogin
|
|
4077
4119
|
throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInQueryActivity), ErrorCode.FailedOperation);
|
4078
4120
|
}
|
4079
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);
|
4080
4147
|
}
|
4081
4148
|
|
4082
4149
|
/**
|
@@ -4977,5 +5044,5 @@ var conversationWithCloudAdapter = /*#__PURE__*/Object.freeze({
|
|
4977
5044
|
CardActionBot: CardActionBot
|
4978
5045
|
});
|
4979
5046
|
|
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 };
|
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 };
|
4981
5048
|
//# sourceMappingURL=index.esm2017.mjs.map
|