@microsoft/teamsfx 2.3.1-alpha.8dc033994.0 → 2.3.1-alpha.a83cb5166.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.node.cjs.js
CHANGED
@@ -167,6 +167,7 @@ ErrorMessage.DuplicateHttpsOptionProperty = "Axios HTTPS agent already defined v
|
|
167
167
|
ErrorMessage.DuplicateApiKeyInHeader = "The request already defined api key in request header with name {0}.";
|
168
168
|
ErrorMessage.DuplicateApiKeyInQueryParam = "The request already defined api key in query parameter with name {0}.";
|
169
169
|
ErrorMessage.OnlySupportInQueryActivity = "The handleMessageExtensionQueryWithToken only support in handleTeamsMessagingExtensionQuery with composeExtension/query type.";
|
170
|
+
ErrorMessage.OnlySupportInLinkQueryActivity = "The handleMessageExtensionLinkQueryWithSSO only support in handleTeamsAppBasedLinkQuery with composeExtension/queryLink type.";
|
170
171
|
/**
|
171
172
|
* Error class with code and message thrown by the SDK.
|
172
173
|
*/
|
@@ -4030,9 +4031,9 @@ class MessageBuilder {
|
|
4030
4031
|
* @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
|
4031
4032
|
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
4032
4033
|
*
|
4033
|
-
* @returns SignIn link CardAction with 200 status code.
|
4034
|
+
* @returns SignIn link SilentAuth CardAction with 200 status code.
|
4034
4035
|
*/
|
4035
|
-
function
|
4036
|
+
function getSignInResponseForMessageExtensionWithSilentAuthConfig(authConfig, initiateLoginEndpoint, scopes) {
|
4036
4037
|
const scopesArray = getScopesArray(scopes);
|
4037
4038
|
const signInLink = `${initiateLoginEndpoint}?scope=${encodeURI(scopesArray.join(" "))}&clientId=${authConfig.clientId}&tenantId=${authConfig.tenantId}`;
|
4038
4039
|
return {
|
@@ -4050,6 +4051,34 @@ function getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiate
|
|
4050
4051
|
},
|
4051
4052
|
};
|
4052
4053
|
}
|
4054
|
+
/**
|
4055
|
+
* Retrieve the OAuth Sign in Link to use in the MessagingExtensionResult Suggested Actions.
|
4056
|
+
* This method just a workaround for link unfurling now.
|
4057
|
+
*
|
4058
|
+
* @param {OnBehalfOfCredentialAuthConfig} authConfig - User custom the message extension authentication configuration.
|
4059
|
+
* @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
|
4060
|
+
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
4061
|
+
*
|
4062
|
+
* @returns SignIn link Auth CardAction with 200 status code.
|
4063
|
+
*/
|
4064
|
+
function getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiateLoginEndpoint, scopes) {
|
4065
|
+
const scopesArray = getScopesArray(scopes);
|
4066
|
+
const signInLink = `${initiateLoginEndpoint}?scope=${encodeURI(scopesArray.join(" "))}&clientId=${authConfig.clientId}&tenantId=${authConfig.tenantId}`;
|
4067
|
+
return {
|
4068
|
+
composeExtension: {
|
4069
|
+
type: "auth",
|
4070
|
+
suggestedActions: {
|
4071
|
+
actions: [
|
4072
|
+
{
|
4073
|
+
type: "openUrl",
|
4074
|
+
value: signInLink,
|
4075
|
+
title: "Message Extension OAuth",
|
4076
|
+
},
|
4077
|
+
],
|
4078
|
+
},
|
4079
|
+
},
|
4080
|
+
};
|
4081
|
+
}
|
4053
4082
|
/**
|
4054
4083
|
* Retrieve the OAuth Sign in Link to use in the MessagingExtensionResult Suggested Actions.
|
4055
4084
|
* This method only work on MessageExtension with Query now.
|
@@ -4099,7 +4128,7 @@ function executionWithTokenAndConfig(context, authConfig, initiateLoginEndpoint,
|
|
4099
4128
|
const valueObj = context.activity.value;
|
4100
4129
|
if (!valueObj.authentication || !valueObj.authentication.token) {
|
4101
4130
|
internalLogger.verbose("No AccessToken in request, return silentAuth for AccessToken");
|
4102
|
-
return
|
4131
|
+
return getSignInResponseForMessageExtensionWithSilentAuthConfig(authConfig, initiateLoginEndpoint, scopes);
|
4103
4132
|
}
|
4104
4133
|
try {
|
4105
4134
|
const credential = new OnBehalfOfUserCredential(valueObj.authentication.token, authConfig);
|
@@ -4117,12 +4146,25 @@ function executionWithTokenAndConfig(context, authConfig, initiateLoginEndpoint,
|
|
4117
4146
|
}
|
4118
4147
|
}
|
4119
4148
|
catch (err) {
|
4120
|
-
if (err instanceof ErrorWithCode &&
|
4149
|
+
if (err instanceof ErrorWithCode &&
|
4150
|
+
err.code === exports.ErrorCode.UiRequiredError &&
|
4151
|
+
context.activity.name === "composeExtension/query") {
|
4121
4152
|
internalLogger.verbose("User not consent yet, return 412 to user consent first.");
|
4122
4153
|
const response = { status: 412 };
|
4123
4154
|
yield context.sendActivity({ value: response, type: botbuilder.ActivityTypes.InvokeResponse });
|
4124
4155
|
return;
|
4125
4156
|
}
|
4157
|
+
else if (err instanceof ErrorWithCode &&
|
4158
|
+
err.code === exports.ErrorCode.UiRequiredError &&
|
4159
|
+
context.activity.name === "composeExtension/queryLink") {
|
4160
|
+
internalLogger.verbose("User not consent yet, return auth card for user login");
|
4161
|
+
const response = getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiateLoginEndpoint, scopes);
|
4162
|
+
yield context.sendActivity({
|
4163
|
+
value: { status: 200, body: response },
|
4164
|
+
type: botbuilder.ActivityTypes.InvokeResponse,
|
4165
|
+
});
|
4166
|
+
return;
|
4167
|
+
}
|
4126
4168
|
throw err;
|
4127
4169
|
}
|
4128
4170
|
});
|
@@ -4231,6 +4273,33 @@ function handleMessageExtensionQueryWithSSO(context, config, initiateLoginEndpoi
|
|
4231
4273
|
}
|
4232
4274
|
return yield executionWithTokenAndConfig(context, config !== null && config !== void 0 ? config : {}, initiateLoginEndpoint, scopes, logic);
|
4233
4275
|
});
|
4276
|
+
}
|
4277
|
+
/**
|
4278
|
+
* Users execute link query in message extension with SSO or access token.
|
4279
|
+
*
|
4280
|
+
* @param {TurnContext} context - The context object for the current turn.
|
4281
|
+
* @param {OnBehalfOfCredentialAuthConfig} config - User custom the message extension authentication configuration.
|
4282
|
+
* @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
|
4283
|
+
* @param {string| string[]} scopes - The list of scopes for which the token will have access.
|
4284
|
+
* @param {function} logic - Business logic when executing the link query in message extension with SSO or access token.
|
4285
|
+
*
|
4286
|
+
* @throws {@link ErrorCode|InternalError} when User invoke not response to message extension link query.
|
4287
|
+
* @throws {@link ErrorCode|InternalError} when failed to get access token with unknown error.
|
4288
|
+
* @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
|
4289
|
+
* @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth server.
|
4290
|
+
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
4291
|
+
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
4292
|
+
*
|
4293
|
+
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4294
|
+
*/
|
4295
|
+
function handleMessageExtensionLinkQueryWithSSO(context, config, initiateLoginEndpoint, scopes, logic) {
|
4296
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4297
|
+
if (context.activity.name != "composeExtension/queryLink") {
|
4298
|
+
internalLogger.error(ErrorMessage.OnlySupportInLinkQueryActivity);
|
4299
|
+
throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInLinkQueryActivity), exports.ErrorCode.FailedOperation);
|
4300
|
+
}
|
4301
|
+
return yield executionWithTokenAndConfig(context, config !== null && config !== void 0 ? config : {}, initiateLoginEndpoint, scopes, logic);
|
4302
|
+
});
|
4234
4303
|
}
|
4235
4304
|
|
4236
4305
|
/**
|
@@ -5198,6 +5267,7 @@ exports.createPemCertOption = createPemCertOption;
|
|
5198
5267
|
exports.createPfxCertOption = createPfxCertOption;
|
5199
5268
|
exports.getLogLevel = getLogLevel;
|
5200
5269
|
exports.getTediousConnectionConfig = getTediousConnectionConfig;
|
5270
|
+
exports.handleMessageExtensionLinkQueryWithSSO = handleMessageExtensionLinkQueryWithSSO;
|
5201
5271
|
exports.handleMessageExtensionQueryWithSSO = handleMessageExtensionQueryWithSSO;
|
5202
5272
|
exports.handleMessageExtensionQueryWithToken = handleMessageExtensionQueryWithToken;
|
5203
5273
|
exports.sendAdaptiveCard = sendAdaptiveCard$1;
|