@microsoft/teamsfx 1.1.2-alpha.7eddd6cf4.0 → 1.1.2-alpha.8d60b4f8e.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 +248 -2
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +714 -27
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +272 -2
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +750 -24
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +7 -5
- package/types/teamsfx.d.ts +417 -22
package/types/teamsfx.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
|
|
3
3
|
import { AccessToken } from '@azure/identity';
|
|
4
|
-
import { Activity } from 'botbuilder
|
|
5
|
-
import { Activity as Activity_2 } from 'botbuilder';
|
|
4
|
+
import { Activity } from 'botbuilder';
|
|
6
5
|
import { Attachment } from 'botbuilder';
|
|
7
6
|
import { AuthenticationProvider } from '@microsoft/microsoft-graph-client';
|
|
8
7
|
import { AxiosInstance } from 'axios';
|
|
@@ -12,26 +11,33 @@ import { CardAction } from 'botbuilder';
|
|
|
12
11
|
import { CardImage } from 'botbuilder';
|
|
13
12
|
import { ChannelInfo } from 'botbuilder';
|
|
14
13
|
import { Client } from '@microsoft/microsoft-graph-client';
|
|
14
|
+
import { ComponentDialog } from 'botbuilder-dialogs';
|
|
15
15
|
import { ConnectionConfig } from 'tedious';
|
|
16
16
|
import { ConversationReference } from 'botbuilder';
|
|
17
|
+
import { ConversationState } from 'botbuilder';
|
|
17
18
|
import { Dialog } from 'botbuilder-dialogs';
|
|
18
19
|
import { DialogContext } from 'botbuilder-dialogs';
|
|
19
20
|
import { DialogTurnResult } from 'botbuilder-dialogs';
|
|
20
21
|
import { GetTokenOptions } from '@azure/identity';
|
|
21
22
|
import { HeroCard } from 'botbuilder';
|
|
22
23
|
import { IAdaptiveCard } from 'adaptivecards';
|
|
23
|
-
import { InvokeResponse } from 'botbuilder
|
|
24
|
-
import {
|
|
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
|
+
import { SigninStateVerificationQuery } from 'botbuilder';
|
|
30
|
+
import { StatePropertyAccessor } from 'botbuilder';
|
|
28
31
|
import { StatusCodes } from 'botbuilder';
|
|
32
|
+
import { Storage as Storage_2 } from 'botbuilder';
|
|
33
|
+
import { TeamDetails } from 'botbuilder';
|
|
34
|
+
import { TeamsActivityHandler } from 'botbuilder';
|
|
29
35
|
import { TeamsChannelAccount } from 'botbuilder';
|
|
30
36
|
import { ThumbnailCard } from 'botbuilder';
|
|
31
37
|
import { TokenCredential } from '@azure/identity';
|
|
32
38
|
import { TokenResponse } from 'botframework-schema';
|
|
33
|
-
import { TurnContext } from 'botbuilder
|
|
34
|
-
import {
|
|
39
|
+
import { TurnContext } from 'botbuilder';
|
|
40
|
+
import { UserState } from 'botbuilder';
|
|
35
41
|
import { WebRequest } from 'botbuilder';
|
|
36
42
|
import { WebResponse } from 'botbuilder';
|
|
37
43
|
|
|
@@ -271,6 +277,176 @@ export declare class BearerTokenAuthProvider implements AuthProvider {
|
|
|
271
277
|
AddAuthenticationInfo(config: AxiosRequestConfig): Promise<AxiosRequestConfig>;
|
|
272
278
|
}
|
|
273
279
|
|
|
280
|
+
/**
|
|
281
|
+
* Interface for SSO configuration for Bot SSO
|
|
282
|
+
*/
|
|
283
|
+
export declare interface BotSsoConfig {
|
|
284
|
+
/**
|
|
285
|
+
* aad related configurations
|
|
286
|
+
*/
|
|
287
|
+
aad: {
|
|
288
|
+
/**
|
|
289
|
+
* The list of scopes for which the token will have access
|
|
290
|
+
*/
|
|
291
|
+
scopes: string[];
|
|
292
|
+
} & AuthenticationConfiguration;
|
|
293
|
+
dialog?: {
|
|
294
|
+
/**
|
|
295
|
+
* Custom sso execution activity handler class which should implement the interface {@link BotSsoExecutionActivityHandler}. If not provided, it will use {@link DefaultBotSsoExecutionActivityHandler} by default
|
|
296
|
+
*/
|
|
297
|
+
CustomBotSsoExecutionActivityHandler?: new (ssoConfig: BotSsoConfig) => BotSsoExecutionActivityHandler;
|
|
298
|
+
/**
|
|
299
|
+
* Conversation state for sso command bot, if not provided, it will use internal memory storage to create a new one.
|
|
300
|
+
*/
|
|
301
|
+
conversationState?: ConversationState;
|
|
302
|
+
/**
|
|
303
|
+
* User state for sso command bot, if not provided, it will use internal memory storage to create a new one.
|
|
304
|
+
*/
|
|
305
|
+
userState?: UserState;
|
|
306
|
+
/**
|
|
307
|
+
* Used by {@link BotSsoExecutionDialog} to remove duplicated messages, if not provided, it will use internal memory storage
|
|
308
|
+
*/
|
|
309
|
+
dedupStorage?: Storage_2;
|
|
310
|
+
/**
|
|
311
|
+
* Settings used to configure an teams sso prompt dialog.
|
|
312
|
+
*/
|
|
313
|
+
ssoPromptConfig?: {
|
|
314
|
+
/**
|
|
315
|
+
* Number of milliseconds the prompt will wait for the user to authenticate.
|
|
316
|
+
* Defaults to a value `900,000` (15 minutes.)
|
|
317
|
+
*/
|
|
318
|
+
timeout?: number;
|
|
319
|
+
/**
|
|
320
|
+
* Value indicating whether the TeamsBotSsoPrompt should end upon receiving an
|
|
321
|
+
* invalid message. Generally the TeamsBotSsoPrompt will end the auth flow when receives user
|
|
322
|
+
* message not related to the auth flow. Setting the flag to false ignores the user's message instead.
|
|
323
|
+
* Defaults to value `true`
|
|
324
|
+
*/
|
|
325
|
+
endOnInvalidMessage?: boolean;
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Interface for user to customize SSO execution activity handler
|
|
332
|
+
*
|
|
333
|
+
* @remarks
|
|
334
|
+
* Bot SSO execution activity handler is to handle SSO login process and trigger SSO command using {@link BotSsoExecutionDialog}.
|
|
335
|
+
* You can use this interface to implement your own SSO execution dialog, and pass it to ConversationBot options:
|
|
336
|
+
*
|
|
337
|
+
* ```typescript
|
|
338
|
+
* export const commandBot = new ConversationBot({
|
|
339
|
+
* ...
|
|
340
|
+
* ssoConfig: {
|
|
341
|
+
* ...
|
|
342
|
+
* dialog: {
|
|
343
|
+
* CustomBotSsoExecutionActivityHandler: YourCustomBotSsoExecutionActivityHandler,
|
|
344
|
+
* }
|
|
345
|
+
* },
|
|
346
|
+
* ...
|
|
347
|
+
* });
|
|
348
|
+
* ```
|
|
349
|
+
* For details information about how to implement a BotSsoExecutionActivityHandler, please refer {@link DefaultBotSsoExecutionActivityHandler} class source code.
|
|
350
|
+
*/
|
|
351
|
+
export declare interface BotSsoExecutionActivityHandler {
|
|
352
|
+
/**
|
|
353
|
+
* Add {@link TeamsFxBotSsoCommandHandler} instance to {@link BotSsoExecutionDialog}
|
|
354
|
+
* @param handler {@link BotSsoExecutionDialogHandler} callback function
|
|
355
|
+
* @param triggerPatterns The trigger pattern
|
|
356
|
+
*
|
|
357
|
+
* @remarks
|
|
358
|
+
* This function is used to add SSO command to {@link BotSsoExecutionDialog} instance.
|
|
359
|
+
*/
|
|
360
|
+
addCommand(handler: BotSsoExecutionDialogHandler, triggerPatterns: TriggerPatterns): void;
|
|
361
|
+
/**
|
|
362
|
+
* Called to initiate the event emission process.
|
|
363
|
+
* @param context The context object for the current turn.
|
|
364
|
+
*/
|
|
365
|
+
run(context: TurnContext): Promise<void>;
|
|
366
|
+
/**
|
|
367
|
+
* Receives invoke activities with Activity name of 'signin/verifyState'.
|
|
368
|
+
* @param context A context object for this turn.
|
|
369
|
+
* @param query Signin state (part of signin action auth flow) verification invoke query.
|
|
370
|
+
* @returns A promise that represents the work queued.
|
|
371
|
+
*
|
|
372
|
+
* @remarks
|
|
373
|
+
* It should trigger {@link BotSsoExecutionDialog} instance to handle signin process
|
|
374
|
+
*/
|
|
375
|
+
handleTeamsSigninVerifyState(context: TurnContext, query: SigninStateVerificationQuery): Promise<void>;
|
|
376
|
+
/**
|
|
377
|
+
* Receives invoke activities with Activity name of 'signin/tokenExchange'
|
|
378
|
+
* @param context A context object for this turn.
|
|
379
|
+
* @param query Signin state (part of signin action auth flow) verification invoke query
|
|
380
|
+
* @returns A promise that represents the work queued.
|
|
381
|
+
*
|
|
382
|
+
* @remark
|
|
383
|
+
* It should trigger {@link BotSsoExecutionDialog} instance to handle signin process
|
|
384
|
+
*/
|
|
385
|
+
handleTeamsSigninTokenExchange(context: TurnContext, query: SigninStateVerificationQuery): Promise<void>;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Sso execution dialog, use to handle sso command
|
|
390
|
+
*/
|
|
391
|
+
export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
392
|
+
private dedupStorage;
|
|
393
|
+
private dedupStorageKeys;
|
|
394
|
+
private commandMapping;
|
|
395
|
+
/**
|
|
396
|
+
* Creates a new instance of the BotSsoExecutionDialog.
|
|
397
|
+
* @param dedupStorage Helper storage to remove duplicated messages
|
|
398
|
+
* @param settings The list of scopes for which the token will have access
|
|
399
|
+
* @param teamsfx {@link TeamsFx} instance for authentication
|
|
400
|
+
*/
|
|
401
|
+
constructor(dedupStorage: Storage_2, ssoPromptSettings: TeamsBotSsoPromptSettings, teamsfx: TeamsFx, dialogName?: string);
|
|
402
|
+
/**
|
|
403
|
+
* Add TeamsFxBotSsoCommandHandler instance
|
|
404
|
+
* @param handler {@link BotSsoExecutionDialogHandler} callback function
|
|
405
|
+
* @param triggerPatterns The trigger pattern
|
|
406
|
+
*/
|
|
407
|
+
addCommand(handler: BotSsoExecutionDialogHandler, triggerPatterns: TriggerPatterns): void;
|
|
408
|
+
private getCommandHash;
|
|
409
|
+
/**
|
|
410
|
+
* The run method handles the incoming activity (in the form of a DialogContext) and passes it through the dialog system.
|
|
411
|
+
*
|
|
412
|
+
* @param context The context object for the current turn.
|
|
413
|
+
* @param accessor The instance of StatePropertyAccessor for dialog system.
|
|
414
|
+
*/
|
|
415
|
+
run(context: TurnContext, accessor: StatePropertyAccessor): Promise<void>;
|
|
416
|
+
private getActivityText;
|
|
417
|
+
private commandRouteStep;
|
|
418
|
+
private ssoStep;
|
|
419
|
+
private dedupStep;
|
|
420
|
+
/**
|
|
421
|
+
* Called when the component is ending.
|
|
422
|
+
*
|
|
423
|
+
* @param context Context for the current turn of conversation.
|
|
424
|
+
*/
|
|
425
|
+
protected onEndDialog(context: TurnContext): Promise<void>;
|
|
426
|
+
/**
|
|
427
|
+
* If a user is signed into multiple Teams clients, the Bot might receive a "signin/tokenExchange" from each client.
|
|
428
|
+
* Each token exchange request for a specific user login will have an identical activity.value.Id.
|
|
429
|
+
* Only one of these token exchange requests should be processed by the bot. For a distributed bot in production,
|
|
430
|
+
* this requires a distributed storage to ensure only one token exchange is processed.
|
|
431
|
+
* @param context Context for the current turn of conversation.
|
|
432
|
+
* @returns boolean value indicate whether the message should be removed
|
|
433
|
+
*/
|
|
434
|
+
private shouldDedup;
|
|
435
|
+
private getStorageKey;
|
|
436
|
+
private matchPattern;
|
|
437
|
+
private isPatternMatched;
|
|
438
|
+
private getMatchesCommandId;
|
|
439
|
+
/**
|
|
440
|
+
* Ensure bot is running in MS Teams since TeamsBotSsoPrompt is only supported in MS Teams channel.
|
|
441
|
+
* @param dc dialog context
|
|
442
|
+
* @throws {@link ErrorCode|ChannelNotSupported} if bot channel is not MS Teams
|
|
443
|
+
* @internal
|
|
444
|
+
*/
|
|
445
|
+
private ensureMsTeamsChannel;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
export declare type BotSsoExecutionDialogHandler = (context: TurnContext, tokenResponse: TeamsBotSsoPromptTokenResponse, message: CommandMessage) => Promise<void>;
|
|
449
|
+
|
|
274
450
|
/**
|
|
275
451
|
* A card action bot to respond to adaptive card universal actions.
|
|
276
452
|
*/
|
|
@@ -389,25 +565,39 @@ export declare class Channel implements NotificationTarget {
|
|
|
389
565
|
export declare class CommandBot {
|
|
390
566
|
private readonly adapter;
|
|
391
567
|
private readonly middleware;
|
|
568
|
+
private readonly ssoConfig;
|
|
392
569
|
/**
|
|
393
570
|
* Creates a new instance of the `CommandBot`.
|
|
394
571
|
*
|
|
395
572
|
* @param adapter The bound `BotFrameworkAdapter`.
|
|
396
573
|
* @param options - initialize options
|
|
397
574
|
*/
|
|
398
|
-
constructor(adapter: BotFrameworkAdapter, options?: CommandOptions);
|
|
575
|
+
constructor(adapter: BotFrameworkAdapter, options?: CommandOptions, ssoCommandActivityHandler?: BotSsoExecutionActivityHandler, ssoConfig?: BotSsoConfig);
|
|
399
576
|
/**
|
|
400
577
|
* Registers a command into the command bot.
|
|
401
578
|
*
|
|
402
|
-
* @param command The command to
|
|
579
|
+
* @param command The command to register.
|
|
403
580
|
*/
|
|
404
581
|
registerCommand(command: TeamsFxBotCommandHandler): void;
|
|
405
582
|
/**
|
|
406
583
|
* Registers commands into the command bot.
|
|
407
584
|
*
|
|
408
|
-
* @param commands The
|
|
585
|
+
* @param commands The commands to register.
|
|
409
586
|
*/
|
|
410
587
|
registerCommands(commands: TeamsFxBotCommandHandler[]): void;
|
|
588
|
+
/**
|
|
589
|
+
* Registers a sso command into the command bot.
|
|
590
|
+
*
|
|
591
|
+
* @param command The command to register.
|
|
592
|
+
*/
|
|
593
|
+
registerSsoCommand(ssoCommand: TeamsFxBotSsoCommandHandler): void;
|
|
594
|
+
/**
|
|
595
|
+
* Registers commands into the command bot.
|
|
596
|
+
*
|
|
597
|
+
* @param commands The commands to register.
|
|
598
|
+
*/
|
|
599
|
+
registerSsoCommands(ssoCommands: TeamsFxBotSsoCommandHandler[]): void;
|
|
600
|
+
private validateSsoActivityHandler;
|
|
411
601
|
}
|
|
412
602
|
|
|
413
603
|
/**
|
|
@@ -432,6 +622,10 @@ export declare interface CommandOptions {
|
|
|
432
622
|
* The commands to registered with the command bot. Each command should implement the interface {@link TeamsFxBotCommandHandler} so that it can be correctly handled by this command bot.
|
|
433
623
|
*/
|
|
434
624
|
commands?: TeamsFxBotCommandHandler[];
|
|
625
|
+
/**
|
|
626
|
+
* The commands to registered with the sso command bot. Each sso command should implement the interface {@link TeamsFxBotSsoCommandHandler} so that it can be correctly handled by this command bot.
|
|
627
|
+
*/
|
|
628
|
+
ssoCommands?: TeamsFxBotSsoCommandHandler[];
|
|
435
629
|
}
|
|
436
630
|
|
|
437
631
|
/**
|
|
@@ -533,7 +727,7 @@ export declare class ConversationBot {
|
|
|
533
727
|
* });
|
|
534
728
|
* ```
|
|
535
729
|
*/
|
|
536
|
-
requestHandler(req: WebRequest, res: WebResponse, logic?: (context:
|
|
730
|
+
requestHandler(req: WebRequest, res: WebResponse, logic?: (context: TurnContext) => Promise<any>): Promise<void>;
|
|
537
731
|
}
|
|
538
732
|
|
|
539
733
|
/**
|
|
@@ -558,6 +752,10 @@ export declare interface ConversationOptions {
|
|
|
558
752
|
adapterConfig?: {
|
|
559
753
|
[key: string]: unknown;
|
|
560
754
|
};
|
|
755
|
+
/**
|
|
756
|
+
* Configurations for sso command bot
|
|
757
|
+
*/
|
|
758
|
+
ssoConfig?: BotSsoConfig;
|
|
561
759
|
/**
|
|
562
760
|
* The command part.
|
|
563
761
|
*/
|
|
@@ -684,6 +882,59 @@ export declare function createPfxCertOption(pfx: string | Buffer, options?: {
|
|
|
684
882
|
passphrase?: string;
|
|
685
883
|
}): SecureContextOptions;
|
|
686
884
|
|
|
885
|
+
/**
|
|
886
|
+
* Default SSO execution activity handler
|
|
887
|
+
*/
|
|
888
|
+
export declare class DefaultBotSsoExecutionActivityHandler extends TeamsActivityHandler implements BotSsoExecutionActivityHandler {
|
|
889
|
+
private ssoExecutionDialog;
|
|
890
|
+
private userState;
|
|
891
|
+
private conversationState;
|
|
892
|
+
private dialogState;
|
|
893
|
+
/**
|
|
894
|
+
* Creates a new instance of the DefaultBotSsoExecutionActivityHandler.
|
|
895
|
+
* @param ssoConfig configuration for SSO command bot
|
|
896
|
+
*
|
|
897
|
+
* @remarks
|
|
898
|
+
* In the constructor, it uses BotSsoConfig parameter which from {@link ConversationBot} options to initialize {@link BotSsoExecutionDialog}.
|
|
899
|
+
* It also need to register an event handler for the message event which trigger {@link BotSsoExecutionDialog} instance.
|
|
900
|
+
*/
|
|
901
|
+
constructor(ssoConfig: BotSsoConfig);
|
|
902
|
+
/**
|
|
903
|
+
* Add TeamsFxBotSsoCommandHandler instance to SSO execution dialog
|
|
904
|
+
* @param handler {@link BotSsoExecutionDialogHandler} callback function
|
|
905
|
+
* @param triggerPatterns The trigger pattern
|
|
906
|
+
*
|
|
907
|
+
* @remarks
|
|
908
|
+
* This function is used to add SSO command to {@link BotSsoExecutionDialog} instance.
|
|
909
|
+
*/
|
|
910
|
+
addCommand(handler: BotSsoExecutionDialogHandler, triggerPatterns: TriggerPatterns): void;
|
|
911
|
+
/**
|
|
912
|
+
* Called to initiate the event emission process.
|
|
913
|
+
* @param context The context object for the current turn.
|
|
914
|
+
*/
|
|
915
|
+
run(context: TurnContext): Promise<void>;
|
|
916
|
+
/**
|
|
917
|
+
* Receives invoke activities with Activity name of 'signin/verifyState'.
|
|
918
|
+
* @param context A context object for this turn.
|
|
919
|
+
* @param query Signin state (part of signin action auth flow) verification invoke query.
|
|
920
|
+
* @returns A promise that represents the work queued.
|
|
921
|
+
*
|
|
922
|
+
* @remarks
|
|
923
|
+
* It should trigger {@link BotSsoExecutionDialog} instance to handle signin process
|
|
924
|
+
*/
|
|
925
|
+
handleTeamsSigninVerifyState(context: TurnContext, query: SigninStateVerificationQuery): Promise<void>;
|
|
926
|
+
/**
|
|
927
|
+
* Receives invoke activities with Activity name of 'signin/tokenExchange'
|
|
928
|
+
* @param context A context object for this turn.
|
|
929
|
+
* @param query Signin state (part of signin action auth flow) verification invoke query
|
|
930
|
+
* @returns A promise that represents the work queued.
|
|
931
|
+
*
|
|
932
|
+
* @remark
|
|
933
|
+
* It should trigger {@link BotSsoExecutionDialog} instance to handle signin process
|
|
934
|
+
*/
|
|
935
|
+
handleTeamsSigninTokenExchange(context: TurnContext, query: SigninStateVerificationQuery): Promise<void>;
|
|
936
|
+
}
|
|
937
|
+
|
|
687
938
|
/**
|
|
688
939
|
* Error code to trace the error types.
|
|
689
940
|
*/
|
|
@@ -708,6 +959,30 @@ export declare enum ErrorCode {
|
|
|
708
959
|
* Channel is not supported error.
|
|
709
960
|
*/
|
|
710
961
|
ChannelNotSupported = "ChannelNotSupported",
|
|
962
|
+
/**
|
|
963
|
+
* Failed to retrieve sso token
|
|
964
|
+
*/
|
|
965
|
+
FailedToRetrieveSsoToken = "FailedToRetrieveSsoToken",
|
|
966
|
+
/**
|
|
967
|
+
* Failed to process sso handler
|
|
968
|
+
*/
|
|
969
|
+
FailedToProcessSsoHandler = "FailedToProcessSsoHandler",
|
|
970
|
+
/**
|
|
971
|
+
* Cannot find command
|
|
972
|
+
*/
|
|
973
|
+
CannotFindCommand = "CannotFindCommand",
|
|
974
|
+
/**
|
|
975
|
+
* Failed to run sso step
|
|
976
|
+
*/
|
|
977
|
+
FailedToRunSsoStep = "FailedToRunSsoStep",
|
|
978
|
+
/**
|
|
979
|
+
* Failed to run dedup step
|
|
980
|
+
*/
|
|
981
|
+
FailedToRunDedupStep = "FailedToRunDedupStep",
|
|
982
|
+
/**
|
|
983
|
+
* Sso activity handler is undefined
|
|
984
|
+
*/
|
|
985
|
+
SsoActivityHandlerIsUndefined = "SsoActivityHandlerIsUndefined",
|
|
711
986
|
/**
|
|
712
987
|
* Runtime is not supported error.
|
|
713
988
|
*/
|
|
@@ -790,6 +1065,25 @@ export declare interface GetTeamsUserTokenOptions extends GetTokenOptions {
|
|
|
790
1065
|
*/
|
|
791
1066
|
export declare function getTediousConnectionConfig(teamsfx: TeamsFx, databaseName?: string): Promise<ConnectionConfig>;
|
|
792
1067
|
|
|
1068
|
+
/**
|
|
1069
|
+
* Users execute query in message extension with SSO or access token.
|
|
1070
|
+
*
|
|
1071
|
+
* @param {TurnContext} context - The context object for the current turn.
|
|
1072
|
+
* @param {AuthenticationConfiguration} config - User custom the message extension authentication configuration.
|
|
1073
|
+
* @param {string| string[]} scopes - The list of scopes for which the token will have access.
|
|
1074
|
+
* @param {function} logic - Business logic when executing the query in message extension with SSO or access token.
|
|
1075
|
+
*
|
|
1076
|
+
* @throws {@link ErrorCode|InternalError} when User invoke not response to message extension query.
|
|
1077
|
+
* @throws {@link ErrorCode|InternalError} when failed to get access token with unknown error.
|
|
1078
|
+
* @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
|
|
1079
|
+
* @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth server.
|
|
1080
|
+
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
1081
|
+
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
|
1082
|
+
*
|
|
1083
|
+
* @returns A MessageExtension Response for the activity. If the logic not return any, return void instead.
|
|
1084
|
+
*/
|
|
1085
|
+
export declare function handleMessageExtensionQueryWithToken(context: TurnContext, config: AuthenticationConfiguration | null, scopes: string | string[], logic: (token: MessageExtensionTokenResponse) => Promise<any>): Promise<MessagingExtensionResponse | void>;
|
|
1086
|
+
|
|
793
1087
|
/**
|
|
794
1088
|
* Identity type to use in authentication.
|
|
795
1089
|
*/
|
|
@@ -857,7 +1151,7 @@ export declare class InvokeResponseFactory {
|
|
|
857
1151
|
*
|
|
858
1152
|
* @returns {InvokeResponse} An InvokeResponse object.
|
|
859
1153
|
*/
|
|
860
|
-
static textMessage(message: string):
|
|
1154
|
+
static textMessage(message: string): InvokeResponse;
|
|
861
1155
|
/**
|
|
862
1156
|
* Create an invoke response from an adaptive card.
|
|
863
1157
|
*
|
|
@@ -869,7 +1163,7 @@ export declare class InvokeResponseFactory {
|
|
|
869
1163
|
*
|
|
870
1164
|
* @returns {InvokeResponse} An InvokeResponse object.
|
|
871
1165
|
*/
|
|
872
|
-
static adaptiveCard(card: IAdaptiveCard):
|
|
1166
|
+
static adaptiveCard(card: IAdaptiveCard): InvokeResponse;
|
|
873
1167
|
/**
|
|
874
1168
|
* Create an invoke response with error code and message.
|
|
875
1169
|
*
|
|
@@ -883,7 +1177,7 @@ export declare class InvokeResponseFactory {
|
|
|
883
1177
|
*
|
|
884
1178
|
* @returns {InvokeResponse} An InvokeResponse object.
|
|
885
1179
|
*/
|
|
886
|
-
static errorResponse(errorCode: InvokeResponseErrorCode, errorMessage: string):
|
|
1180
|
+
static errorResponse(errorCode: InvokeResponseErrorCode, errorMessage: string): InvokeResponse;
|
|
887
1181
|
/**
|
|
888
1182
|
* Create an invoke response with status code and response value.
|
|
889
1183
|
* @param statusCode The status code.
|
|
@@ -891,7 +1185,7 @@ export declare class InvokeResponseFactory {
|
|
|
891
1185
|
*
|
|
892
1186
|
* @returns {InvokeResponse} An InvokeResponse object.
|
|
893
1187
|
*/
|
|
894
|
-
static createInvokeResponse(statusCode: StatusCodes, body?: unknown):
|
|
1188
|
+
static createInvokeResponse(statusCode: StatusCodes, body?: unknown): InvokeResponse;
|
|
895
1189
|
}
|
|
896
1190
|
|
|
897
1191
|
/**
|
|
@@ -1032,14 +1326,14 @@ export declare class MessageBuilder {
|
|
|
1032
1326
|
* });
|
|
1033
1327
|
* ```
|
|
1034
1328
|
*/
|
|
1035
|
-
static attachAdaptiveCard<TData extends object>(cardTemplate: unknown, data: TData): Partial<
|
|
1329
|
+
static attachAdaptiveCard<TData extends object>(cardTemplate: unknown, data: TData): Partial<Activity>;
|
|
1036
1330
|
/**
|
|
1037
1331
|
* Build a bot message activity attached with an adaptive card.
|
|
1038
1332
|
*
|
|
1039
1333
|
* @param card The adaptive card content.
|
|
1040
1334
|
* @returns A bot message activity attached with an adaptive card.
|
|
1041
1335
|
*/
|
|
1042
|
-
static attachAdaptiveCardWithoutData(card: unknown): Partial<
|
|
1336
|
+
static attachAdaptiveCardWithoutData(card: unknown): Partial<Activity>;
|
|
1043
1337
|
/**
|
|
1044
1338
|
* Build a bot message activity attached with an hero card.
|
|
1045
1339
|
*
|
|
@@ -1060,7 +1354,7 @@ export declare class MessageBuilder {
|
|
|
1060
1354
|
* );
|
|
1061
1355
|
* ```
|
|
1062
1356
|
*/
|
|
1063
|
-
static attachHeroCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<HeroCard>): Partial<
|
|
1357
|
+
static attachHeroCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<HeroCard>): Partial<Activity>;
|
|
1064
1358
|
/**
|
|
1065
1359
|
* Returns an attachment for a sign-in card.
|
|
1066
1360
|
*
|
|
@@ -1073,20 +1367,20 @@ export declare class MessageBuilder {
|
|
|
1073
1367
|
* @remarks
|
|
1074
1368
|
* For channels that don't natively support sign-in cards, an alternative message is rendered.
|
|
1075
1369
|
*/
|
|
1076
|
-
static attachSigninCard(title: string, url: string, text?: string): Partial<
|
|
1370
|
+
static attachSigninCard(title: string, url: string, text?: string): Partial<Activity>;
|
|
1077
1371
|
/**
|
|
1078
1372
|
* Build a bot message activity attached with an Office 365 connector card.
|
|
1079
1373
|
*
|
|
1080
1374
|
* @param card A description of the Office 365 connector card.
|
|
1081
1375
|
* @returns A bot message activity attached with an Office 365 connector card.
|
|
1082
1376
|
*/
|
|
1083
|
-
static attachO365ConnectorCard(card: O365ConnectorCard): Partial<
|
|
1377
|
+
static attachO365ConnectorCard(card: O365ConnectorCard): Partial<Activity>;
|
|
1084
1378
|
/**
|
|
1085
1379
|
* Build a message activity attached with a receipt card.
|
|
1086
1380
|
* @param card A description of the receipt card.
|
|
1087
1381
|
* @returns A message activity attached with a receipt card.
|
|
1088
1382
|
*/
|
|
1089
|
-
static AttachReceiptCard(card: ReceiptCard): Partial<
|
|
1383
|
+
static AttachReceiptCard(card: ReceiptCard): Partial<Activity>;
|
|
1090
1384
|
/**
|
|
1091
1385
|
*
|
|
1092
1386
|
* @param title The card title.
|
|
@@ -1096,13 +1390,27 @@ export declare class MessageBuilder {
|
|
|
1096
1390
|
* @param other Optional. Any additional properties to include on the card.
|
|
1097
1391
|
* @returns A message activity attached with a thumbnail card
|
|
1098
1392
|
*/
|
|
1099
|
-
static attachThumbnailCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<ThumbnailCard>): Partial<
|
|
1393
|
+
static attachThumbnailCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<ThumbnailCard>): Partial<Activity>;
|
|
1100
1394
|
/**
|
|
1101
1395
|
* Add an attachement to a bot activity.
|
|
1102
1396
|
* @param attachement The attachment object to attach.
|
|
1103
1397
|
* @returns A message activity with an attachment.
|
|
1104
1398
|
*/
|
|
1105
|
-
static attachContent(attachement: Attachment): Partial<
|
|
1399
|
+
static attachContent(attachement: Attachment): Partial<Activity>;
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
/**
|
|
1403
|
+
* Token response provided by Teams Bot SSO prompt
|
|
1404
|
+
*/
|
|
1405
|
+
export declare interface MessageExtensionTokenResponse extends TokenResponse {
|
|
1406
|
+
/**
|
|
1407
|
+
* SSO token for user
|
|
1408
|
+
*/
|
|
1409
|
+
ssoToken: string;
|
|
1410
|
+
/**
|
|
1411
|
+
* Expire time of SSO token
|
|
1412
|
+
*/
|
|
1413
|
+
ssoTokenExpiration: string;
|
|
1106
1414
|
}
|
|
1107
1415
|
|
|
1108
1416
|
/**
|
|
@@ -1172,6 +1480,43 @@ export declare class NotificationBot {
|
|
|
1172
1480
|
* @returns - an array of {@link TeamsBotInstallation}.
|
|
1173
1481
|
*/
|
|
1174
1482
|
installations(): Promise<TeamsBotInstallation[]>;
|
|
1483
|
+
/**
|
|
1484
|
+
* Returns the first {@link Member} where predicate is true, and undefined otherwise.
|
|
1485
|
+
*
|
|
1486
|
+
* @param predicate find calls predicate once for each member of the installation,
|
|
1487
|
+
* until it finds one where predicate returns true. If such a member is found, find
|
|
1488
|
+
* immediately returns that member. Otherwise, find returns undefined.
|
|
1489
|
+
* @param scope the scope to find members from the installations
|
|
1490
|
+
* (personal chat, group chat, Teams channel).
|
|
1491
|
+
* @returns the first {@link Member} where predicate is true, and undefined otherwise.
|
|
1492
|
+
*/
|
|
1493
|
+
findMember(predicate: (member: Member) => Promise<boolean>, scope?: SearchScope): Promise<Member | undefined>;
|
|
1494
|
+
/**
|
|
1495
|
+
* Returns the first {@link Channel} where predicate is true, and undefined otherwise.
|
|
1496
|
+
*
|
|
1497
|
+
* @param predicate find calls predicate once for each channel of the installation,
|
|
1498
|
+
* until it finds one where predicate returns true. If such a channel is found, find
|
|
1499
|
+
* immediately returns that channel. Otherwise, find returns undefined.
|
|
1500
|
+
* @returns the first {@link Channel} where predicate is true, and undefined otherwise.
|
|
1501
|
+
*/
|
|
1502
|
+
findChannel(predicate: (channel: Channel, teamDetails: TeamDetails | undefined) => Promise<boolean>): Promise<Channel | undefined>;
|
|
1503
|
+
/**
|
|
1504
|
+
* Returns all {@link Member} where predicate is true, and empty array otherwise.
|
|
1505
|
+
*
|
|
1506
|
+
* @param predicate find calls predicate for each member of the installation.
|
|
1507
|
+
* @param scope the scope to find members from the installations
|
|
1508
|
+
* (personal chat, group chat, Teams channel).
|
|
1509
|
+
* @returns an array of {@link Member} where predicate is true, and empty array otherwise.
|
|
1510
|
+
*/
|
|
1511
|
+
findAllMembers(predicate: (member: Member) => Promise<boolean>, scope?: SearchScope): Promise<Member[]>;
|
|
1512
|
+
/**
|
|
1513
|
+
* Returns all {@link Channel} where predicate is true, and empty array otherwise.
|
|
1514
|
+
*
|
|
1515
|
+
* @param predicate find calls predicate for each channel of the installation.
|
|
1516
|
+
* @returns an array of {@link Channel} where predicate is true, and empty array otherwise.
|
|
1517
|
+
*/
|
|
1518
|
+
findAllChannels(predicate: (channel: Channel, teamDetails: TeamDetails | undefined) => Promise<boolean>): Promise<Channel[]>;
|
|
1519
|
+
private matchSearchScope;
|
|
1175
1520
|
}
|
|
1176
1521
|
|
|
1177
1522
|
/**
|
|
@@ -1361,6 +1706,30 @@ export declare class OnBehalfOfUserCredential implements TokenCredential {
|
|
|
1361
1706
|
private generateAuthServerError;
|
|
1362
1707
|
}
|
|
1363
1708
|
|
|
1709
|
+
/**
|
|
1710
|
+
* The search scope when calling {@link NotificationBot.findMember} and {@link NotificationBot.findAllMembers}.
|
|
1711
|
+
* The search scope is a flagged enum and it can be combined with `|`.
|
|
1712
|
+
* For example, to search from personal chat and group chat, use `SearchScope.Person | SearchScope.Group`.
|
|
1713
|
+
*/
|
|
1714
|
+
export declare enum SearchScope {
|
|
1715
|
+
/**
|
|
1716
|
+
* Search members from the installations in personal chat only.
|
|
1717
|
+
*/
|
|
1718
|
+
Person = 1,
|
|
1719
|
+
/**
|
|
1720
|
+
* Search members from the installations in group chat only.
|
|
1721
|
+
*/
|
|
1722
|
+
Group = 2,
|
|
1723
|
+
/**
|
|
1724
|
+
* Search members from the installations in Teams channel only.
|
|
1725
|
+
*/
|
|
1726
|
+
Channel = 4,
|
|
1727
|
+
/**
|
|
1728
|
+
* Search members from all installations including personal chat, group chat and Teams channel.
|
|
1729
|
+
*/
|
|
1730
|
+
All = 7
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1364
1733
|
/**
|
|
1365
1734
|
* Send an adaptive card message to a notification target.
|
|
1366
1735
|
*
|
|
@@ -1482,6 +1851,12 @@ export declare class TeamsBotInstallation implements NotificationTarget {
|
|
|
1482
1851
|
* @returns an array of members from where the bot is installed.
|
|
1483
1852
|
*/
|
|
1484
1853
|
members(): Promise<Member[]>;
|
|
1854
|
+
/**
|
|
1855
|
+
* Get team details from this bot installation
|
|
1856
|
+
*
|
|
1857
|
+
* @returns the team details if bot is installed into a team, otherwise returns undefined.
|
|
1858
|
+
*/
|
|
1859
|
+
getTeamDetails(): Promise<TeamDetails | undefined>;
|
|
1485
1860
|
}
|
|
1486
1861
|
|
|
1487
1862
|
/**
|
|
@@ -1809,6 +2184,26 @@ export declare interface TeamsFxBotCommandHandler {
|
|
|
1809
2184
|
handleCommandReceived(context: TurnContext, message: CommandMessage): Promise<string | Partial<Activity> | void>;
|
|
1810
2185
|
}
|
|
1811
2186
|
|
|
2187
|
+
/**
|
|
2188
|
+
* Interface for a command handler that can process sso command to a TeamsFx bot and return a response.
|
|
2189
|
+
*/
|
|
2190
|
+
export declare interface TeamsFxBotSsoCommandHandler {
|
|
2191
|
+
/**
|
|
2192
|
+
* The string or regular expression patterns that can trigger this handler.
|
|
2193
|
+
*/
|
|
2194
|
+
triggerPatterns: TriggerPatterns;
|
|
2195
|
+
/**
|
|
2196
|
+
* Handles a bot command received activity.
|
|
2197
|
+
*
|
|
2198
|
+
* @param context The bot context.
|
|
2199
|
+
* @param message The command message the user types from Teams.
|
|
2200
|
+
* @param ssoToken The sso token which can be used to exchange access token for the bot.
|
|
2201
|
+
* @returns A `Promise` representing an activity or text to send as the command response.
|
|
2202
|
+
* Or no return value if developers want to send the response activity by themselves in this method.
|
|
2203
|
+
*/
|
|
2204
|
+
handleCommandReceived(context: TurnContext, message: CommandMessage, ssoToken: TeamsBotSsoPromptTokenResponse): Promise<string | Partial<Activity> | void>;
|
|
2205
|
+
}
|
|
2206
|
+
|
|
1812
2207
|
/**
|
|
1813
2208
|
* TeamsFx interface that provides credential and configuration.
|
|
1814
2209
|
*/
|