@microsoft/teamsfx 2.3.1-alpha.da822cd72.0 → 2.3.1-alpha.df8521401.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 +2 -1
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +89 -24
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +4 -8
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +91 -43
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +10 -10
- package/types/teamsfx.d.ts +20 -0
package/dist/index.node.cjs.js
CHANGED
@@ -18,28 +18,8 @@ var adaptivecardsTools = require('@microsoft/adaptivecards-tools');
|
|
18
18
|
|
19
19
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
20
20
|
|
21
|
-
function _interopNamespace(e) {
|
22
|
-
if (e && e.__esModule) return e;
|
23
|
-
var n = Object.create(null);
|
24
|
-
if (e) {
|
25
|
-
Object.keys(e).forEach(function (k) {
|
26
|
-
if (k !== 'default') {
|
27
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
28
|
-
Object.defineProperty(n, k, d.get ? d : {
|
29
|
-
enumerable: true,
|
30
|
-
get: function () { return e[k]; }
|
31
|
-
});
|
32
|
-
}
|
33
|
-
});
|
34
|
-
}
|
35
|
-
n["default"] = e;
|
36
|
-
return Object.freeze(n);
|
37
|
-
}
|
38
|
-
|
39
21
|
var jwt_decode__default = /*#__PURE__*/_interopDefaultLegacy(jwt_decode);
|
40
22
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
41
|
-
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
42
|
-
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
43
23
|
|
44
24
|
// Copyright (c) Microsoft Corporation.
|
45
25
|
// Licensed under the MIT license.
|
@@ -167,6 +147,7 @@ ErrorMessage.DuplicateHttpsOptionProperty = "Axios HTTPS agent already defined v
|
|
167
147
|
ErrorMessage.DuplicateApiKeyInHeader = "The request already defined api key in request header with name {0}.";
|
168
148
|
ErrorMessage.DuplicateApiKeyInQueryParam = "The request already defined api key in query parameter with name {0}.";
|
169
149
|
ErrorMessage.OnlySupportInQueryActivity = "The handleMessageExtensionQueryWithToken only support in handleTeamsMessagingExtensionQuery with composeExtension/query type.";
|
150
|
+
ErrorMessage.OnlySupportInLinkQueryActivity = "The handleMessageExtensionLinkQueryWithSSO only support in handleTeamsAppBasedLinkQuery with composeExtension/queryLink type.";
|
170
151
|
/**
|
171
152
|
* Error class with code and message thrown by the SDK.
|
172
153
|
*/
|
@@ -189,7 +170,7 @@ class ErrorWithCode extends Error {
|
|
189
170
|
}
|
190
171
|
}
|
191
172
|
|
192
|
-
|
173
|
+
/*! *****************************************************************************
|
193
174
|
Copyright (c) Microsoft Corporation.
|
194
175
|
|
195
176
|
Permission to use, copy, modify, and/or distribute this software for any
|
@@ -224,12 +205,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
224
205
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
225
206
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
226
207
|
});
|
227
|
-
}
|
228
|
-
|
229
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
230
|
-
var e = new Error(message);
|
231
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
232
|
-
};
|
208
|
+
}
|
233
209
|
|
234
210
|
// Copyright (c) Microsoft Corporation.
|
235
211
|
// Licensed under the MIT license.
|
@@ -375,7 +351,7 @@ function setLogFunction(logFunction) {
|
|
375
351
|
*/
|
376
352
|
function parseJwt(token) {
|
377
353
|
try {
|
378
|
-
const tokenObj = jwt_decode__default[
|
354
|
+
const tokenObj = jwt_decode__default['default'](token);
|
379
355
|
if (!tokenObj || !tokenObj.exp) {
|
380
356
|
throw new ErrorWithCode("Decoded token is null or exp claim does not exists.", exports.ErrorCode.InternalError);
|
381
357
|
}
|
@@ -1559,12 +1535,12 @@ class TeamsBotSsoPrompt extends botbuilderDialogs.Dialog {
|
|
1559
1535
|
*/
|
1560
1536
|
function createApiClient(apiEndpoint, authProvider) {
|
1561
1537
|
// Add a request interceptor
|
1562
|
-
const instance = axios__default[
|
1538
|
+
const instance = axios__default['default'].create({
|
1563
1539
|
baseURL: apiEndpoint,
|
1564
1540
|
});
|
1565
1541
|
instance.interceptors.request.use(function (config) {
|
1566
1542
|
return __awaiter(this, void 0, void 0, function* () {
|
1567
|
-
return yield authProvider.AddAuthenticationInfo(config);
|
1543
|
+
return (yield authProvider.AddAuthenticationInfo(config));
|
1568
1544
|
});
|
1569
1545
|
});
|
1570
1546
|
return instance;
|
@@ -2641,7 +2617,7 @@ class NotificationMiddleware {
|
|
2641
2617
|
return ActivityType.Unknown;
|
2642
2618
|
}
|
2643
2619
|
tryAddMessagedReference(context) {
|
2644
|
-
var _a, _b, _c, _d;
|
2620
|
+
var _a, _b, _c, _d, _e, _f;
|
2645
2621
|
return __awaiter(this, void 0, void 0, function* () {
|
2646
2622
|
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
2647
2623
|
const conversationType = (_a = reference === null || reference === void 0 ? void 0 : reference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
|
@@ -2650,7 +2626,9 @@ class NotificationMiddleware {
|
|
2650
2626
|
}
|
2651
2627
|
else if (conversationType === "channel") {
|
2652
2628
|
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;
|
2653
|
-
|
2629
|
+
const channelId = (_f = (_e = context.activity.channelData) === null || _e === void 0 ? void 0 : _e.channel) === null || _f === void 0 ? void 0 : _f.id;
|
2630
|
+
// `teamId === channelId` means General channel. Ignore messaging in non-General channel.
|
2631
|
+
if (teamId !== undefined && (channelId === undefined || teamId === channelId)) {
|
2654
2632
|
const teamReference = cloneConversation(reference);
|
2655
2633
|
teamReference.conversation.id = teamId;
|
2656
2634
|
yield this.conversationReferenceStore.add(getKey(teamReference), teamReference, {
|
@@ -2668,8 +2646,9 @@ class NotificationMiddleware {
|
|
2668
2646
|
*/
|
2669
2647
|
class LocalFileStorage {
|
2670
2648
|
constructor(fileDir) {
|
2671
|
-
|
2672
|
-
this.
|
2649
|
+
var _a;
|
2650
|
+
this.localFileName = (_a = process.env.TEAMSFX_NOTIFICATION_STORE_FILENAME) !== null && _a !== void 0 ? _a : ".notification.localstore.json";
|
2651
|
+
this.filePath = path.resolve(fileDir, this.localFileName);
|
2673
2652
|
}
|
2674
2653
|
read(key) {
|
2675
2654
|
return __awaiter(this, void 0, void 0, function* () {
|
@@ -2713,7 +2692,7 @@ class LocalFileStorage {
|
|
2713
2692
|
storeFileExists() {
|
2714
2693
|
return new Promise((resolve) => {
|
2715
2694
|
try {
|
2716
|
-
|
2695
|
+
fs.access(this.filePath, (err) => {
|
2717
2696
|
if (err) {
|
2718
2697
|
resolve(false);
|
2719
2698
|
}
|
@@ -2730,7 +2709,7 @@ class LocalFileStorage {
|
|
2730
2709
|
readFromFile() {
|
2731
2710
|
return new Promise((resolve, reject) => {
|
2732
2711
|
try {
|
2733
|
-
|
2712
|
+
fs.readFile(this.filePath, { encoding: "utf-8" }, (err, rawData) => {
|
2734
2713
|
if (err) {
|
2735
2714
|
reject(err);
|
2736
2715
|
}
|
@@ -2749,7 +2728,7 @@ class LocalFileStorage {
|
|
2749
2728
|
return new Promise((resolve, reject) => {
|
2750
2729
|
try {
|
2751
2730
|
const rawData = JSON.stringify(data, undefined, 2);
|
2752
|
-
|
2731
|
+
fs.writeFile(this.filePath, rawData, { encoding: "utf-8" }, (err) => {
|
2753
2732
|
if (err) {
|
2754
2733
|
reject(err);
|
2755
2734
|
}
|
@@ -3207,7 +3186,7 @@ class NotificationBot$1 {
|
|
3207
3186
|
*/
|
3208
3187
|
constructor(adapter, options) {
|
3209
3188
|
var _a, _b;
|
3210
|
-
const storage = (_a = options === null || options === void 0 ? void 0 : options.storage) !== null && _a !== void 0 ? _a : new LocalFileStorage(
|
3189
|
+
const storage = (_a = options === null || options === void 0 ? void 0 : options.storage) !== null && _a !== void 0 ? _a : new LocalFileStorage(path.resolve(process.env.RUNNING_ON_AZURE === "1" ? (_b = process.env.TEMP) !== null && _b !== void 0 ? _b : "./" : "./"));
|
3211
3190
|
this.conversationReferenceStore = new DefaultConversationReferenceStore(storage);
|
3212
3191
|
this.adapter = adapter.use(new NotificationMiddleware({
|
3213
3192
|
conversationReferenceStore: this.conversationReferenceStore,
|
@@ -4030,9 +4009,9 @@ class MessageBuilder {
|
|
4030
4009
|
* @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
|
4031
4010
|
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
4032
4011
|
*
|
4033
|
-
* @returns SignIn link CardAction with 200 status code.
|
4012
|
+
* @returns SignIn link SilentAuth CardAction with 200 status code.
|
4034
4013
|
*/
|
4035
|
-
function
|
4014
|
+
function getSignInResponseForMessageExtensionWithSilentAuthConfig(authConfig, initiateLoginEndpoint, scopes) {
|
4036
4015
|
const scopesArray = getScopesArray(scopes);
|
4037
4016
|
const signInLink = `${initiateLoginEndpoint}?scope=${encodeURI(scopesArray.join(" "))}&clientId=${authConfig.clientId}&tenantId=${authConfig.tenantId}`;
|
4038
4017
|
return {
|
@@ -4050,6 +4029,34 @@ function getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiate
|
|
4050
4029
|
},
|
4051
4030
|
};
|
4052
4031
|
}
|
4032
|
+
/**
|
4033
|
+
* Retrieve the OAuth Sign in Link to use in the MessagingExtensionResult Suggested Actions.
|
4034
|
+
* This method just a workaround for link unfurling now.
|
4035
|
+
*
|
4036
|
+
* @param {OnBehalfOfCredentialAuthConfig} authConfig - User custom the message extension authentication configuration.
|
4037
|
+
* @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
|
4038
|
+
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
4039
|
+
*
|
4040
|
+
* @returns SignIn link Auth CardAction with 200 status code.
|
4041
|
+
*/
|
4042
|
+
function getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiateLoginEndpoint, scopes) {
|
4043
|
+
const scopesArray = getScopesArray(scopes);
|
4044
|
+
const signInLink = `${initiateLoginEndpoint}?scope=${encodeURI(scopesArray.join(" "))}&clientId=${authConfig.clientId}&tenantId=${authConfig.tenantId}`;
|
4045
|
+
return {
|
4046
|
+
composeExtension: {
|
4047
|
+
type: "auth",
|
4048
|
+
suggestedActions: {
|
4049
|
+
actions: [
|
4050
|
+
{
|
4051
|
+
type: "openUrl",
|
4052
|
+
value: signInLink,
|
4053
|
+
title: "Message Extension OAuth",
|
4054
|
+
},
|
4055
|
+
],
|
4056
|
+
},
|
4057
|
+
},
|
4058
|
+
};
|
4059
|
+
}
|
4053
4060
|
/**
|
4054
4061
|
* Retrieve the OAuth Sign in Link to use in the MessagingExtensionResult Suggested Actions.
|
4055
4062
|
* This method only work on MessageExtension with Query now.
|
@@ -4099,7 +4106,7 @@ function executionWithTokenAndConfig(context, authConfig, initiateLoginEndpoint,
|
|
4099
4106
|
const valueObj = context.activity.value;
|
4100
4107
|
if (!valueObj.authentication || !valueObj.authentication.token) {
|
4101
4108
|
internalLogger.verbose("No AccessToken in request, return silentAuth for AccessToken");
|
4102
|
-
return
|
4109
|
+
return getSignInResponseForMessageExtensionWithSilentAuthConfig(authConfig, initiateLoginEndpoint, scopes);
|
4103
4110
|
}
|
4104
4111
|
try {
|
4105
4112
|
const credential = new OnBehalfOfUserCredential(valueObj.authentication.token, authConfig);
|
@@ -4117,12 +4124,25 @@ function executionWithTokenAndConfig(context, authConfig, initiateLoginEndpoint,
|
|
4117
4124
|
}
|
4118
4125
|
}
|
4119
4126
|
catch (err) {
|
4120
|
-
if (err instanceof ErrorWithCode &&
|
4127
|
+
if (err instanceof ErrorWithCode &&
|
4128
|
+
err.code === exports.ErrorCode.UiRequiredError &&
|
4129
|
+
context.activity.name === "composeExtension/query") {
|
4121
4130
|
internalLogger.verbose("User not consent yet, return 412 to user consent first.");
|
4122
4131
|
const response = { status: 412 };
|
4123
4132
|
yield context.sendActivity({ value: response, type: botbuilder.ActivityTypes.InvokeResponse });
|
4124
4133
|
return;
|
4125
4134
|
}
|
4135
|
+
else if (err instanceof ErrorWithCode &&
|
4136
|
+
err.code === exports.ErrorCode.UiRequiredError &&
|
4137
|
+
context.activity.name === "composeExtension/queryLink") {
|
4138
|
+
internalLogger.verbose("User not consent yet, return auth card for user login");
|
4139
|
+
const response = getSignInResponseForMessageExtensionWithAuthConfig(authConfig, initiateLoginEndpoint, scopes);
|
4140
|
+
yield context.sendActivity({
|
4141
|
+
value: { status: 200, body: response },
|
4142
|
+
type: botbuilder.ActivityTypes.InvokeResponse,
|
4143
|
+
});
|
4144
|
+
return;
|
4145
|
+
}
|
4126
4146
|
throw err;
|
4127
4147
|
}
|
4128
4148
|
});
|
@@ -4231,6 +4251,33 @@ function handleMessageExtensionQueryWithSSO(context, config, initiateLoginEndpoi
|
|
4231
4251
|
}
|
4232
4252
|
return yield executionWithTokenAndConfig(context, config !== null && config !== void 0 ? config : {}, initiateLoginEndpoint, scopes, logic);
|
4233
4253
|
});
|
4254
|
+
}
|
4255
|
+
/**
|
4256
|
+
* Users execute link query in message extension with SSO or access token.
|
4257
|
+
*
|
4258
|
+
* @param {TurnContext} context - The context object for the current turn.
|
4259
|
+
* @param {OnBehalfOfCredentialAuthConfig} config - User custom the message extension authentication configuration.
|
4260
|
+
* @param {initiateLoginEndpoint} initiateLoginEndpoint - Login page for Teams to redirect to.
|
4261
|
+
* @param {string| string[]} scopes - The list of scopes for which the token will have access.
|
4262
|
+
* @param {function} logic - Business logic when executing the link query in message extension with SSO or access token.
|
4263
|
+
*
|
4264
|
+
* @throws {@link ErrorCode|InternalError} when User invoke not response to message extension link query.
|
4265
|
+
* @throws {@link ErrorCode|InternalError} when failed to get access token with unknown error.
|
4266
|
+
* @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
|
4267
|
+
* @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth server.
|
4268
|
+
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
4269
|
+
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
4270
|
+
*
|
4271
|
+
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
4272
|
+
*/
|
4273
|
+
function handleMessageExtensionLinkQueryWithSSO(context, config, initiateLoginEndpoint, scopes, logic) {
|
4274
|
+
return __awaiter(this, void 0, void 0, function* () {
|
4275
|
+
if (context.activity.name != "composeExtension/queryLink") {
|
4276
|
+
internalLogger.error(ErrorMessage.OnlySupportInLinkQueryActivity);
|
4277
|
+
throw new ErrorWithCode(formatString(ErrorMessage.OnlySupportInLinkQueryActivity), exports.ErrorCode.FailedOperation);
|
4278
|
+
}
|
4279
|
+
return yield executionWithTokenAndConfig(context, config !== null && config !== void 0 ? config : {}, initiateLoginEndpoint, scopes, logic);
|
4280
|
+
});
|
4234
4281
|
}
|
4235
4282
|
|
4236
4283
|
/**
|
@@ -4770,7 +4817,7 @@ class NotificationBot {
|
|
4770
4817
|
this.conversationReferenceStore = options.store;
|
4771
4818
|
}
|
4772
4819
|
else {
|
4773
|
-
const storage = (_a = options === null || options === void 0 ? void 0 : options.storage) !== null && _a !== void 0 ? _a : new LocalFileStorage(
|
4820
|
+
const storage = (_a = options === null || options === void 0 ? void 0 : options.storage) !== null && _a !== void 0 ? _a : new LocalFileStorage(path.resolve(process.env.RUNNING_ON_AZURE === "1" ? (_b = process.env.TEMP) !== null && _b !== void 0 ? _b : "./" : "./"));
|
4774
4821
|
this.conversationReferenceStore = new DefaultConversationReferenceStore(storage);
|
4775
4822
|
}
|
4776
4823
|
this.adapter = adapter.use(new NotificationMiddleware({
|
@@ -5198,6 +5245,7 @@ exports.createPemCertOption = createPemCertOption;
|
|
5198
5245
|
exports.createPfxCertOption = createPfxCertOption;
|
5199
5246
|
exports.getLogLevel = getLogLevel;
|
5200
5247
|
exports.getTediousConnectionConfig = getTediousConnectionConfig;
|
5248
|
+
exports.handleMessageExtensionLinkQueryWithSSO = handleMessageExtensionLinkQueryWithSSO;
|
5201
5249
|
exports.handleMessageExtensionQueryWithSSO = handleMessageExtensionQueryWithSSO;
|
5202
5250
|
exports.handleMessageExtensionQueryWithToken = handleMessageExtensionQueryWithToken;
|
5203
5251
|
exports.sendAdaptiveCard = sendAdaptiveCard$1;
|