@microsoft/teamsfx 1.1.2-alpha.8882e735e.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 +279 -18
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +729 -33
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +303 -18
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +765 -30
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +7 -5
- package/types/teamsfx.d.ts +438 -29
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
|
*/
|
|
@@ -772,6 +1047,10 @@ export declare class ErrorWithCode extends Error {
|
|
|
772
1047
|
*/
|
|
773
1048
|
export declare function getLogLevel(): LogLevel | undefined;
|
|
774
1049
|
|
|
1050
|
+
export declare interface GetTeamsUserTokenOptions extends GetTokenOptions {
|
|
1051
|
+
resources?: string[];
|
|
1052
|
+
}
|
|
1053
|
+
|
|
775
1054
|
/**
|
|
776
1055
|
* Generate connection configuration consumed by tedious.
|
|
777
1056
|
*
|
|
@@ -786,6 +1065,25 @@ export declare function getLogLevel(): LogLevel | undefined;
|
|
|
786
1065
|
*/
|
|
787
1066
|
export declare function getTediousConnectionConfig(teamsfx: TeamsFx, databaseName?: string): Promise<ConnectionConfig>;
|
|
788
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
|
+
|
|
789
1087
|
/**
|
|
790
1088
|
* Identity type to use in authentication.
|
|
791
1089
|
*/
|
|
@@ -853,7 +1151,7 @@ export declare class InvokeResponseFactory {
|
|
|
853
1151
|
*
|
|
854
1152
|
* @returns {InvokeResponse} An InvokeResponse object.
|
|
855
1153
|
*/
|
|
856
|
-
static textMessage(message: string):
|
|
1154
|
+
static textMessage(message: string): InvokeResponse;
|
|
857
1155
|
/**
|
|
858
1156
|
* Create an invoke response from an adaptive card.
|
|
859
1157
|
*
|
|
@@ -865,7 +1163,7 @@ export declare class InvokeResponseFactory {
|
|
|
865
1163
|
*
|
|
866
1164
|
* @returns {InvokeResponse} An InvokeResponse object.
|
|
867
1165
|
*/
|
|
868
|
-
static adaptiveCard(card: IAdaptiveCard):
|
|
1166
|
+
static adaptiveCard(card: IAdaptiveCard): InvokeResponse;
|
|
869
1167
|
/**
|
|
870
1168
|
* Create an invoke response with error code and message.
|
|
871
1169
|
*
|
|
@@ -879,7 +1177,7 @@ export declare class InvokeResponseFactory {
|
|
|
879
1177
|
*
|
|
880
1178
|
* @returns {InvokeResponse} An InvokeResponse object.
|
|
881
1179
|
*/
|
|
882
|
-
static errorResponse(errorCode: InvokeResponseErrorCode, errorMessage: string):
|
|
1180
|
+
static errorResponse(errorCode: InvokeResponseErrorCode, errorMessage: string): InvokeResponse;
|
|
883
1181
|
/**
|
|
884
1182
|
* Create an invoke response with status code and response value.
|
|
885
1183
|
* @param statusCode The status code.
|
|
@@ -887,7 +1185,7 @@ export declare class InvokeResponseFactory {
|
|
|
887
1185
|
*
|
|
888
1186
|
* @returns {InvokeResponse} An InvokeResponse object.
|
|
889
1187
|
*/
|
|
890
|
-
static createInvokeResponse(statusCode: StatusCodes, body?: unknown):
|
|
1188
|
+
static createInvokeResponse(statusCode: StatusCodes, body?: unknown): InvokeResponse;
|
|
891
1189
|
}
|
|
892
1190
|
|
|
893
1191
|
/**
|
|
@@ -1028,14 +1326,14 @@ export declare class MessageBuilder {
|
|
|
1028
1326
|
* });
|
|
1029
1327
|
* ```
|
|
1030
1328
|
*/
|
|
1031
|
-
static attachAdaptiveCard<TData extends object>(cardTemplate: unknown, data: TData): Partial<
|
|
1329
|
+
static attachAdaptiveCard<TData extends object>(cardTemplate: unknown, data: TData): Partial<Activity>;
|
|
1032
1330
|
/**
|
|
1033
1331
|
* Build a bot message activity attached with an adaptive card.
|
|
1034
1332
|
*
|
|
1035
1333
|
* @param card The adaptive card content.
|
|
1036
1334
|
* @returns A bot message activity attached with an adaptive card.
|
|
1037
1335
|
*/
|
|
1038
|
-
static attachAdaptiveCardWithoutData(card: unknown): Partial<
|
|
1336
|
+
static attachAdaptiveCardWithoutData(card: unknown): Partial<Activity>;
|
|
1039
1337
|
/**
|
|
1040
1338
|
* Build a bot message activity attached with an hero card.
|
|
1041
1339
|
*
|
|
@@ -1056,7 +1354,7 @@ export declare class MessageBuilder {
|
|
|
1056
1354
|
* );
|
|
1057
1355
|
* ```
|
|
1058
1356
|
*/
|
|
1059
|
-
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>;
|
|
1060
1358
|
/**
|
|
1061
1359
|
* Returns an attachment for a sign-in card.
|
|
1062
1360
|
*
|
|
@@ -1069,20 +1367,20 @@ export declare class MessageBuilder {
|
|
|
1069
1367
|
* @remarks
|
|
1070
1368
|
* For channels that don't natively support sign-in cards, an alternative message is rendered.
|
|
1071
1369
|
*/
|
|
1072
|
-
static attachSigninCard(title: string, url: string, text?: string): Partial<
|
|
1370
|
+
static attachSigninCard(title: string, url: string, text?: string): Partial<Activity>;
|
|
1073
1371
|
/**
|
|
1074
1372
|
* Build a bot message activity attached with an Office 365 connector card.
|
|
1075
1373
|
*
|
|
1076
1374
|
* @param card A description of the Office 365 connector card.
|
|
1077
1375
|
* @returns A bot message activity attached with an Office 365 connector card.
|
|
1078
1376
|
*/
|
|
1079
|
-
static attachO365ConnectorCard(card: O365ConnectorCard): Partial<
|
|
1377
|
+
static attachO365ConnectorCard(card: O365ConnectorCard): Partial<Activity>;
|
|
1080
1378
|
/**
|
|
1081
1379
|
* Build a message activity attached with a receipt card.
|
|
1082
1380
|
* @param card A description of the receipt card.
|
|
1083
1381
|
* @returns A message activity attached with a receipt card.
|
|
1084
1382
|
*/
|
|
1085
|
-
static AttachReceiptCard(card: ReceiptCard): Partial<
|
|
1383
|
+
static AttachReceiptCard(card: ReceiptCard): Partial<Activity>;
|
|
1086
1384
|
/**
|
|
1087
1385
|
*
|
|
1088
1386
|
* @param title The card title.
|
|
@@ -1092,13 +1390,27 @@ export declare class MessageBuilder {
|
|
|
1092
1390
|
* @param other Optional. Any additional properties to include on the card.
|
|
1093
1391
|
* @returns A message activity attached with a thumbnail card
|
|
1094
1392
|
*/
|
|
1095
|
-
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>;
|
|
1096
1394
|
/**
|
|
1097
1395
|
* Add an attachement to a bot activity.
|
|
1098
1396
|
* @param attachement The attachment object to attach.
|
|
1099
1397
|
* @returns A message activity with an attachment.
|
|
1100
1398
|
*/
|
|
1101
|
-
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;
|
|
1102
1414
|
}
|
|
1103
1415
|
|
|
1104
1416
|
/**
|
|
@@ -1168,6 +1480,43 @@ export declare class NotificationBot {
|
|
|
1168
1480
|
* @returns - an array of {@link TeamsBotInstallation}.
|
|
1169
1481
|
*/
|
|
1170
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;
|
|
1171
1520
|
}
|
|
1172
1521
|
|
|
1173
1522
|
/**
|
|
@@ -1357,6 +1706,30 @@ export declare class OnBehalfOfUserCredential implements TokenCredential {
|
|
|
1357
1706
|
private generateAuthServerError;
|
|
1358
1707
|
}
|
|
1359
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
|
+
|
|
1360
1733
|
/**
|
|
1361
1734
|
* Send an adaptive card message to a notification target.
|
|
1362
1735
|
*
|
|
@@ -1478,6 +1851,12 @@ export declare class TeamsBotInstallation implements NotificationTarget {
|
|
|
1478
1851
|
* @returns an array of members from where the bot is installed.
|
|
1479
1852
|
*/
|
|
1480
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>;
|
|
1481
1860
|
}
|
|
1482
1861
|
|
|
1483
1862
|
/**
|
|
@@ -1671,7 +2050,7 @@ export declare class TeamsFx implements TeamsFxConfiguration {
|
|
|
1671
2050
|
*
|
|
1672
2051
|
* @throws {@link ErrorCode|IdentityTypeNotSupported} when setting app identity in browser.
|
|
1673
2052
|
*/
|
|
1674
|
-
constructor(identityType?: IdentityType, customConfig?: Record<string, string>);
|
|
2053
|
+
constructor(identityType?: IdentityType, customConfig?: Record<string, string> | AuthenticationConfiguration);
|
|
1675
2054
|
/**
|
|
1676
2055
|
* Identity type set by user.
|
|
1677
2056
|
*
|
|
@@ -1690,9 +2069,10 @@ export declare class TeamsFx implements TeamsFxConfiguration {
|
|
|
1690
2069
|
getCredential(): TokenCredential;
|
|
1691
2070
|
/**
|
|
1692
2071
|
* Get user information.
|
|
2072
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
1693
2073
|
* @returns UserInfo object.
|
|
1694
2074
|
*/
|
|
1695
|
-
getUserInfo(): Promise<UserInfo>;
|
|
2075
|
+
getUserInfo(resources?: string[]): Promise<UserInfo>;
|
|
1696
2076
|
/**
|
|
1697
2077
|
* Popup login page to get user's access token with specific scopes.
|
|
1698
2078
|
*
|
|
@@ -1707,13 +2087,14 @@ export declare class TeamsFx implements TeamsFxConfiguration {
|
|
|
1707
2087
|
* await teamsfx.login("https://graph.microsoft.com/User.Read Calendars.Read"); // multiple scopes using string
|
|
1708
2088
|
* ```
|
|
1709
2089
|
* @param scopes - The list of scopes for which the token will have access, before that, we will request user to consent.
|
|
2090
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
1710
2091
|
*
|
|
1711
2092
|
* @throws {@link ErrorCode|InternalError} when failed to login with unknown error.
|
|
1712
2093
|
* @throws {@link ErrorCode|ConsentFailed} when user canceled or failed to consent.
|
|
1713
2094
|
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
1714
2095
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
|
1715
2096
|
*/
|
|
1716
|
-
login(scopes: string | string[]): Promise<void>;
|
|
2097
|
+
login(scopes: string | string[], resources?: string[]): Promise<void>;
|
|
1717
2098
|
/**
|
|
1718
2099
|
* Set SSO token when using user identity in NodeJS.
|
|
1719
2100
|
* @param {string} ssoToken - used for on behalf of user flow.
|
|
@@ -1803,6 +2184,26 @@ export declare interface TeamsFxBotCommandHandler {
|
|
|
1803
2184
|
handleCommandReceived(context: TurnContext, message: CommandMessage): Promise<string | Partial<Activity> | void>;
|
|
1804
2185
|
}
|
|
1805
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
|
+
|
|
1806
2207
|
/**
|
|
1807
2208
|
* TeamsFx interface that provides credential and configuration.
|
|
1808
2209
|
*/
|
|
@@ -1825,9 +2226,10 @@ declare interface TeamsFxConfiguration {
|
|
|
1825
2226
|
getCredential(): TokenCredential;
|
|
1826
2227
|
/**
|
|
1827
2228
|
* Get user information.
|
|
2229
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
1828
2230
|
* @returns UserInfo object.
|
|
1829
2231
|
*/
|
|
1830
|
-
getUserInfo(): Promise<UserInfo>;
|
|
2232
|
+
getUserInfo(resources?: string[]): Promise<UserInfo>;
|
|
1831
2233
|
/**
|
|
1832
2234
|
* Popup login page to get user's access token with specific scopes.
|
|
1833
2235
|
*
|
|
@@ -1842,13 +2244,14 @@ declare interface TeamsFxConfiguration {
|
|
|
1842
2244
|
* await teamsfx.login("https://graph.microsoft.com/User.Read Calendars.Read"); // multiple scopes using string
|
|
1843
2245
|
* ```
|
|
1844
2246
|
* @param scopes - The list of scopes for which the token will have access, before that, we will request user to consent.
|
|
2247
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
1845
2248
|
*
|
|
1846
2249
|
* @throws {@link ErrorCode|InternalError} when failed to login with unknown error.
|
|
1847
2250
|
* @throws {@link ErrorCode|ConsentFailed} when user canceled or failed to consent.
|
|
1848
2251
|
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
1849
2252
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
|
1850
2253
|
*/
|
|
1851
|
-
login(scopes: string | string[]): Promise<void>;
|
|
2254
|
+
login(scopes: string | string[], resources?: string[]): Promise<void>;
|
|
1852
2255
|
/**
|
|
1853
2256
|
* Set SSO token when using user identity in NodeJS.
|
|
1854
2257
|
* @param {string} ssoToken - used for on behalf of user flow.
|
|
@@ -1889,10 +2292,13 @@ export declare class TeamsUserCredential implements TokenCredential {
|
|
|
1889
2292
|
constructor(authConfig: AuthenticationConfiguration);
|
|
1890
2293
|
/**
|
|
1891
2294
|
* Popup login page to get user's access token with specific scopes.
|
|
2295
|
+
*
|
|
2296
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
2297
|
+
*
|
|
1892
2298
|
* @remarks
|
|
1893
2299
|
* Can only be used within Teams.
|
|
1894
2300
|
*/
|
|
1895
|
-
login(scopes: string | string[]): Promise<void>;
|
|
2301
|
+
login(scopes: string | string[], resources?: string[]): Promise<void>;
|
|
1896
2302
|
/**
|
|
1897
2303
|
* Get access token from credential.
|
|
1898
2304
|
* @remarks
|
|
@@ -1901,10 +2307,13 @@ export declare class TeamsUserCredential implements TokenCredential {
|
|
|
1901
2307
|
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
|
|
1902
2308
|
/**
|
|
1903
2309
|
* Get basic user info from SSO token
|
|
2310
|
+
*
|
|
2311
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
2312
|
+
*
|
|
1904
2313
|
* @remarks
|
|
1905
2314
|
* Can only be used within Teams.
|
|
1906
2315
|
*/
|
|
1907
|
-
getUserInfo(): Promise<UserInfo>;
|
|
2316
|
+
getUserInfo(resources?: string[]): Promise<UserInfo>;
|
|
1908
2317
|
}
|
|
1909
2318
|
|
|
1910
2319
|
/**
|