@microsoft/teamsfx 1.1.2-alpha.9bd0cb559.0 → 1.1.2-alpha.9d488528e.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/teamsfx",
3
- "version": "1.1.2-alpha.9bd0cb559.0",
3
+ "version": "1.1.2-alpha.9d488528e.0",
4
4
  "description": "Microsoft Teams Framework for Node.js and browser.",
5
5
  "main": "dist/index.node.cjs.js",
6
6
  "browser": "dist/index.esm2017.js",
@@ -21,7 +21,7 @@
21
21
  "test:unit:node": "nyc --no-clean -- mocha 'test/unit/{,!(browser)/**/}*.spec.ts' --file src/index.ts -r config/mocha.env.ts --config config/mocharc.node.js",
22
22
  "test:unit": "npm run test:unit:node && npm run test:unit:browser ",
23
23
  "test:e2e:browser": "karma start --single-run --integration",
24
- "test:e2e:node": "mocha 'test/e2e/node/*.spec.ts' --file src/index.ts -r config/mocha.env.ts --config config/mocharc.node.js --reporter xunit --reporter-option output=test-results.node.xml ",
24
+ "test:e2e:node": "mocha --reporter mocha-multi-reporters 'test/e2e/node/*.spec.ts' --file src/index.ts -r config/mocha.env.ts --config config/mocharc.node.js --reporter-options configFile=config/mocha-multi-reporter.json",
25
25
  "test:e2e": "npm run test:e2e:node && npm run test:e2e:browser",
26
26
  "ui-test": "mocha --no-timeouts -r test/mocha.env.ts -r ts-node/register test/ui/**/*.spec.ts --exit",
27
27
  "check-sensitive": "npx eslint --plugin 'no-secrets' --cache --ignore-pattern 'package.json' --ignore-pattern 'package-lock.json'",
@@ -49,7 +49,7 @@
49
49
  "@azure/identity": "^2.0.1",
50
50
  "@azure/msal-browser": "^2.21.0",
51
51
  "@azure/msal-node": "~1.1.0",
52
- "@microsoft/adaptivecards-tools": "1.0.2-alpha.9bd0cb559.0",
52
+ "@microsoft/adaptivecards-tools": "1.0.2-alpha.9d488528e.0",
53
53
  "@microsoft/microsoft-graph-client": "^3.0.1",
54
54
  "adaptivecards": "^2.10.0",
55
55
  "axios": "^0.27.2",
@@ -78,6 +78,7 @@
78
78
  "@types/chai-as-promised": "^7.1.4",
79
79
  "@types/fs-extra": "^9.0.11",
80
80
  "@types/mocha": "^9.0.0",
81
+ "@types/mochawesome": "^6.2.1",
81
82
  "@types/node": "^16.11.7",
82
83
  "@types/sinon": "^10.0.6",
83
84
  "@types/tedious": "^4.0.5",
@@ -112,7 +113,8 @@
112
113
  "karma-webpack": "^5.0.0",
113
114
  "lint-staged": "^11.2.6",
114
115
  "mocha": "^9.2.0",
115
- "mocha-junit-reporter": "^2.0.2",
116
+ "mocha-multi-reporters": "^1.5.1",
117
+ "mochawesome": "^7.0.1",
116
118
  "mocked-env": "^1.3.5",
117
119
  "nyc": "^15.1.0",
118
120
  "prettier": "^2.4.1",
@@ -129,7 +131,7 @@
129
131
  "webpack": "^5.62.1",
130
132
  "yargs": "^17.2.1"
131
133
  },
132
- "gitHead": "3af4b6e0aa2b7bcfbf2dbbf1fccbe4a03ea8a71b",
134
+ "gitHead": "ffbbe229e83536079e5224c40f62d35d2963ec75",
133
135
  "publishConfig": {
134
136
  "access": "public"
135
137
  },
@@ -22,6 +22,7 @@ import { GetTokenOptions } from '@azure/identity';
22
22
  import { HeroCard } from 'botbuilder';
23
23
  import { IAdaptiveCard } from 'adaptivecards';
24
24
  import { InvokeResponse } from 'botbuilder';
25
+ import { MessagingExtensionResponse } from 'botbuilder';
25
26
  import { O365ConnectorCard } from 'botbuilder';
26
27
  import { ReceiptCard } from 'botbuilder';
27
28
  import { SecureContextOptions } from 'tls';
@@ -29,7 +30,7 @@ import { SigninStateVerificationQuery } from 'botbuilder';
29
30
  import { StatePropertyAccessor } from 'botbuilder';
30
31
  import { StatusCodes } from 'botbuilder';
31
32
  import { Storage as Storage_2 } from 'botbuilder';
32
- import { TeamsActivityHandler } from 'botbuilder';
33
+ import { TeamDetails } from 'botbuilder';
33
34
  import { TeamsChannelAccount } from 'botbuilder';
34
35
  import { ThumbnailCard } from 'botbuilder';
35
36
  import { TokenCredential } from '@azure/identity';
@@ -344,7 +345,7 @@ export declare interface BotSsoConfig {
344
345
  * ...
345
346
  * });
346
347
  * ```
347
- * For details information about how to implement a BotSsoExecutionActivityHandler, please refer {@link DefaultBotSsoExecutionActivityHandler} class source code.
348
+ * For details information about how to implement a BotSsoExecutionActivityHandler, please refer DefaultBotSsoExecutionActivityHandler class source code: https://aka.ms/teamsfx-default-sso-execution-activity-handler
348
349
  */
349
350
  export declare interface BotSsoExecutionActivityHandler {
350
351
  /**
@@ -880,59 +881,6 @@ export declare function createPfxCertOption(pfx: string | Buffer, options?: {
880
881
  passphrase?: string;
881
882
  }): SecureContextOptions;
882
883
 
883
- /**
884
- * Default SSO execution activity handler
885
- */
886
- export declare class DefaultBotSsoExecutionActivityHandler extends TeamsActivityHandler implements BotSsoExecutionActivityHandler {
887
- private ssoExecutionDialog;
888
- private userState;
889
- private conversationState;
890
- private dialogState;
891
- /**
892
- * Creates a new instance of the DefaultBotSsoExecutionActivityHandler.
893
- * @param ssoConfig configuration for SSO command bot
894
- *
895
- * @remarks
896
- * In the constructor, it uses BotSsoConfig parameter which from {@link ConversationBot} options to initialize {@link BotSsoExecutionDialog}.
897
- * It also need to register an event handler for the message event which trigger {@link BotSsoExecutionDialog} instance.
898
- */
899
- constructor(ssoConfig: BotSsoConfig);
900
- /**
901
- * Add TeamsFxBotSsoCommandHandler instance to SSO execution dialog
902
- * @param handler {@link BotSsoExecutionDialogHandler} callback function
903
- * @param triggerPatterns The trigger pattern
904
- *
905
- * @remarks
906
- * This function is used to add SSO command to {@link BotSsoExecutionDialog} instance.
907
- */
908
- addCommand(handler: BotSsoExecutionDialogHandler, triggerPatterns: TriggerPatterns): void;
909
- /**
910
- * Called to initiate the event emission process.
911
- * @param context The context object for the current turn.
912
- */
913
- run(context: TurnContext): Promise<void>;
914
- /**
915
- * Receives invoke activities with Activity name of 'signin/verifyState'.
916
- * @param context A context object for this turn.
917
- * @param query Signin state (part of signin action auth flow) verification invoke query.
918
- * @returns A promise that represents the work queued.
919
- *
920
- * @remarks
921
- * It should trigger {@link BotSsoExecutionDialog} instance to handle signin process
922
- */
923
- handleTeamsSigninVerifyState(context: TurnContext, query: SigninStateVerificationQuery): Promise<void>;
924
- /**
925
- * Receives invoke activities with Activity name of 'signin/tokenExchange'
926
- * @param context A context object for this turn.
927
- * @param query Signin state (part of signin action auth flow) verification invoke query
928
- * @returns A promise that represents the work queued.
929
- *
930
- * @remark
931
- * It should trigger {@link BotSsoExecutionDialog} instance to handle signin process
932
- */
933
- handleTeamsSigninTokenExchange(context: TurnContext, query: SigninStateVerificationQuery): Promise<void>;
934
- }
935
-
936
884
  /**
937
885
  * Error code to trace the error types.
938
886
  */
@@ -1063,6 +1011,25 @@ export declare interface GetTeamsUserTokenOptions extends GetTokenOptions {
1063
1011
  */
1064
1012
  export declare function getTediousConnectionConfig(teamsfx: TeamsFx, databaseName?: string): Promise<ConnectionConfig>;
1065
1013
 
1014
+ /**
1015
+ * Users execute query in message extension with SSO or access token.
1016
+ *
1017
+ * @param {TurnContext} context - The context object for the current turn.
1018
+ * @param {AuthenticationConfiguration} config - User custom the message extension authentication configuration.
1019
+ * @param {string| string[]} scopes - The list of scopes for which the token will have access.
1020
+ * @param {function} logic - Business logic when executing the query in message extension with SSO or access token.
1021
+ *
1022
+ * @throws {@link ErrorCode|InternalError} when User invoke not response to message extension query.
1023
+ * @throws {@link ErrorCode|InternalError} when failed to get access token with unknown error.
1024
+ * @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
1025
+ * @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth server.
1026
+ * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1027
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
1028
+ *
1029
+ * @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
1030
+ */
1031
+ export declare function handleMessageExtensionQueryWithToken(context: TurnContext, config: AuthenticationConfiguration | null, scopes: string | string[], logic: (token: MessageExtensionTokenResponse) => Promise<any>): Promise<MessagingExtensionResponse | void>;
1032
+
1066
1033
  /**
1067
1034
  * Identity type to use in authentication.
1068
1035
  */
@@ -1378,6 +1345,20 @@ export declare class MessageBuilder {
1378
1345
  static attachContent(attachement: Attachment): Partial<Activity>;
1379
1346
  }
1380
1347
 
1348
+ /**
1349
+ * Token response provided by Teams Bot SSO prompt
1350
+ */
1351
+ export declare interface MessageExtensionTokenResponse extends TokenResponse {
1352
+ /**
1353
+ * SSO token for user
1354
+ */
1355
+ ssoToken: string;
1356
+ /**
1357
+ * Expire time of SSO token
1358
+ */
1359
+ ssoTokenExpiration: string;
1360
+ }
1361
+
1381
1362
  /**
1382
1363
  * The response of a message action, e.g., `sendMessage`, `sendAdaptiveCard`.
1383
1364
  */
@@ -1445,6 +1426,43 @@ export declare class NotificationBot {
1445
1426
  * @returns - an array of {@link TeamsBotInstallation}.
1446
1427
  */
1447
1428
  installations(): Promise<TeamsBotInstallation[]>;
1429
+ /**
1430
+ * Returns the first {@link Member} where predicate is true, and undefined otherwise.
1431
+ *
1432
+ * @param predicate find calls predicate once for each member of the installation,
1433
+ * until it finds one where predicate returns true. If such a member is found, find
1434
+ * immediately returns that member. Otherwise, find returns undefined.
1435
+ * @param scope the scope to find members from the installations
1436
+ * (personal chat, group chat, Teams channel).
1437
+ * @returns the first {@link Member} where predicate is true, and undefined otherwise.
1438
+ */
1439
+ findMember(predicate: (member: Member) => Promise<boolean>, scope?: SearchScope): Promise<Member | undefined>;
1440
+ /**
1441
+ * Returns the first {@link Channel} where predicate is true, and undefined otherwise.
1442
+ *
1443
+ * @param predicate find calls predicate once for each channel of the installation,
1444
+ * until it finds one where predicate returns true. If such a channel is found, find
1445
+ * immediately returns that channel. Otherwise, find returns undefined.
1446
+ * @returns the first {@link Channel} where predicate is true, and undefined otherwise.
1447
+ */
1448
+ findChannel(predicate: (channel: Channel, teamDetails: TeamDetails | undefined) => Promise<boolean>): Promise<Channel | undefined>;
1449
+ /**
1450
+ * Returns all {@link Member} where predicate is true, and empty array otherwise.
1451
+ *
1452
+ * @param predicate find calls predicate for each member of the installation.
1453
+ * @param scope the scope to find members from the installations
1454
+ * (personal chat, group chat, Teams channel).
1455
+ * @returns an array of {@link Member} where predicate is true, and empty array otherwise.
1456
+ */
1457
+ findAllMembers(predicate: (member: Member) => Promise<boolean>, scope?: SearchScope): Promise<Member[]>;
1458
+ /**
1459
+ * Returns all {@link Channel} where predicate is true, and empty array otherwise.
1460
+ *
1461
+ * @param predicate find calls predicate for each channel of the installation.
1462
+ * @returns an array of {@link Channel} where predicate is true, and empty array otherwise.
1463
+ */
1464
+ findAllChannels(predicate: (channel: Channel, teamDetails: TeamDetails | undefined) => Promise<boolean>): Promise<Channel[]>;
1465
+ private matchSearchScope;
1448
1466
  }
1449
1467
 
1450
1468
  /**
@@ -1634,6 +1652,30 @@ export declare class OnBehalfOfUserCredential implements TokenCredential {
1634
1652
  private generateAuthServerError;
1635
1653
  }
1636
1654
 
1655
+ /**
1656
+ * The search scope when calling {@link NotificationBot.findMember} and {@link NotificationBot.findAllMembers}.
1657
+ * The search scope is a flagged enum and it can be combined with `|`.
1658
+ * For example, to search from personal chat and group chat, use `SearchScope.Person | SearchScope.Group`.
1659
+ */
1660
+ export declare enum SearchScope {
1661
+ /**
1662
+ * Search members from the installations in personal chat only.
1663
+ */
1664
+ Person = 1,
1665
+ /**
1666
+ * Search members from the installations in group chat only.
1667
+ */
1668
+ Group = 2,
1669
+ /**
1670
+ * Search members from the installations in Teams channel only.
1671
+ */
1672
+ Channel = 4,
1673
+ /**
1674
+ * Search members from all installations including personal chat, group chat and Teams channel.
1675
+ */
1676
+ All = 7
1677
+ }
1678
+
1637
1679
  /**
1638
1680
  * Send an adaptive card message to a notification target.
1639
1681
  *
@@ -1755,6 +1797,12 @@ export declare class TeamsBotInstallation implements NotificationTarget {
1755
1797
  * @returns an array of members from where the bot is installed.
1756
1798
  */
1757
1799
  members(): Promise<Member[]>;
1800
+ /**
1801
+ * Get team details from this bot installation
1802
+ *
1803
+ * @returns the team details if bot is installed into a team, otherwise returns undefined.
1804
+ */
1805
+ getTeamDetails(): Promise<TeamDetails | undefined>;
1758
1806
  }
1759
1807
 
1760
1808
  /**
@@ -2095,11 +2143,11 @@ export declare interface TeamsFxBotSsoCommandHandler {
2095
2143
  *
2096
2144
  * @param context The bot context.
2097
2145
  * @param message The command message the user types from Teams.
2098
- * @param ssoToken The sso token which can be used to exchange access token for the bot.
2146
+ * @param tokenResponse The tokenResponse which contains sso token that can be used to exchange access token for the bot.
2099
2147
  * @returns A `Promise` representing an activity or text to send as the command response.
2100
2148
  * Or no return value if developers want to send the response activity by themselves in this method.
2101
2149
  */
2102
- handleCommandReceived(context: TurnContext, message: CommandMessage, ssoToken: TeamsBotSsoPromptTokenResponse): Promise<string | Partial<Activity> | void>;
2150
+ handleCommandReceived(context: TurnContext, message: CommandMessage, tokenResponse: TeamsBotSsoPromptTokenResponse): Promise<string | Partial<Activity> | void>;
2103
2151
  }
2104
2152
 
2105
2153
  /**