@microsoft/teamsfx 1.1.2-alpha.efe3d972e.0 → 1.2.0-rc.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 +221 -18
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +732 -34
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +237 -18
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +767 -31
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +7 -5
- package/types/teamsfx.d.ts +384 -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,32 @@ 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';
|
|
29
34
|
import { TeamsChannelAccount } from 'botbuilder';
|
|
30
35
|
import { ThumbnailCard } from 'botbuilder';
|
|
31
36
|
import { TokenCredential } from '@azure/identity';
|
|
32
37
|
import { TokenResponse } from 'botframework-schema';
|
|
33
|
-
import { TurnContext } from 'botbuilder
|
|
34
|
-
import {
|
|
38
|
+
import { TurnContext } from 'botbuilder';
|
|
39
|
+
import { UserState } from 'botbuilder';
|
|
35
40
|
import { WebRequest } from 'botbuilder';
|
|
36
41
|
import { WebResponse } from 'botbuilder';
|
|
37
42
|
|
|
@@ -271,6 +276,176 @@ export declare class BearerTokenAuthProvider implements AuthProvider {
|
|
|
271
276
|
AddAuthenticationInfo(config: AxiosRequestConfig): Promise<AxiosRequestConfig>;
|
|
272
277
|
}
|
|
273
278
|
|
|
279
|
+
/**
|
|
280
|
+
* Interface for SSO configuration for Bot SSO
|
|
281
|
+
*/
|
|
282
|
+
export declare interface BotSsoConfig {
|
|
283
|
+
/**
|
|
284
|
+
* aad related configurations
|
|
285
|
+
*/
|
|
286
|
+
aad: {
|
|
287
|
+
/**
|
|
288
|
+
* The list of scopes for which the token will have access
|
|
289
|
+
*/
|
|
290
|
+
scopes: string[];
|
|
291
|
+
} & AuthenticationConfiguration;
|
|
292
|
+
dialog?: {
|
|
293
|
+
/**
|
|
294
|
+
* Custom sso execution activity handler class which should implement the interface {@link BotSsoExecutionActivityHandler}. If not provided, it will use {@link DefaultBotSsoExecutionActivityHandler} by default
|
|
295
|
+
*/
|
|
296
|
+
CustomBotSsoExecutionActivityHandler?: new (ssoConfig: BotSsoConfig) => BotSsoExecutionActivityHandler;
|
|
297
|
+
/**
|
|
298
|
+
* Conversation state for sso command bot, if not provided, it will use internal memory storage to create a new one.
|
|
299
|
+
*/
|
|
300
|
+
conversationState?: ConversationState;
|
|
301
|
+
/**
|
|
302
|
+
* User state for sso command bot, if not provided, it will use internal memory storage to create a new one.
|
|
303
|
+
*/
|
|
304
|
+
userState?: UserState;
|
|
305
|
+
/**
|
|
306
|
+
* Used by {@link BotSsoExecutionDialog} to remove duplicated messages, if not provided, it will use internal memory storage
|
|
307
|
+
*/
|
|
308
|
+
dedupStorage?: Storage_2;
|
|
309
|
+
/**
|
|
310
|
+
* Settings used to configure an teams sso prompt dialog.
|
|
311
|
+
*/
|
|
312
|
+
ssoPromptConfig?: {
|
|
313
|
+
/**
|
|
314
|
+
* Number of milliseconds the prompt will wait for the user to authenticate.
|
|
315
|
+
* Defaults to a value `900,000` (15 minutes.)
|
|
316
|
+
*/
|
|
317
|
+
timeout?: number;
|
|
318
|
+
/**
|
|
319
|
+
* Value indicating whether the TeamsBotSsoPrompt should end upon receiving an
|
|
320
|
+
* invalid message. Generally the TeamsBotSsoPrompt will end the auth flow when receives user
|
|
321
|
+
* message not related to the auth flow. Setting the flag to false ignores the user's message instead.
|
|
322
|
+
* Defaults to value `true`
|
|
323
|
+
*/
|
|
324
|
+
endOnInvalidMessage?: boolean;
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Interface for user to customize SSO execution activity handler
|
|
331
|
+
*
|
|
332
|
+
* @remarks
|
|
333
|
+
* Bot SSO execution activity handler is to handle SSO login process and trigger SSO command using {@link BotSsoExecutionDialog}.
|
|
334
|
+
* You can use this interface to implement your own SSO execution dialog, and pass it to ConversationBot options:
|
|
335
|
+
*
|
|
336
|
+
* ```typescript
|
|
337
|
+
* export const commandBot = new ConversationBot({
|
|
338
|
+
* ...
|
|
339
|
+
* ssoConfig: {
|
|
340
|
+
* ...
|
|
341
|
+
* dialog: {
|
|
342
|
+
* CustomBotSsoExecutionActivityHandler: YourCustomBotSsoExecutionActivityHandler,
|
|
343
|
+
* }
|
|
344
|
+
* },
|
|
345
|
+
* ...
|
|
346
|
+
* });
|
|
347
|
+
* ```
|
|
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
|
|
349
|
+
*/
|
|
350
|
+
export declare interface BotSsoExecutionActivityHandler {
|
|
351
|
+
/**
|
|
352
|
+
* Add {@link TeamsFxBotSsoCommandHandler} instance to {@link BotSsoExecutionDialog}
|
|
353
|
+
* @param handler {@link BotSsoExecutionDialogHandler} callback function
|
|
354
|
+
* @param triggerPatterns The trigger pattern
|
|
355
|
+
*
|
|
356
|
+
* @remarks
|
|
357
|
+
* This function is used to add SSO command to {@link BotSsoExecutionDialog} instance.
|
|
358
|
+
*/
|
|
359
|
+
addCommand(handler: BotSsoExecutionDialogHandler, triggerPatterns: TriggerPatterns): void;
|
|
360
|
+
/**
|
|
361
|
+
* Called to initiate the event emission process.
|
|
362
|
+
* @param context The context object for the current turn.
|
|
363
|
+
*/
|
|
364
|
+
run(context: TurnContext): Promise<void>;
|
|
365
|
+
/**
|
|
366
|
+
* Receives invoke activities with Activity name of 'signin/verifyState'.
|
|
367
|
+
* @param context A context object for this turn.
|
|
368
|
+
* @param query Signin state (part of signin action auth flow) verification invoke query.
|
|
369
|
+
* @returns A promise that represents the work queued.
|
|
370
|
+
*
|
|
371
|
+
* @remarks
|
|
372
|
+
* It should trigger {@link BotSsoExecutionDialog} instance to handle signin process
|
|
373
|
+
*/
|
|
374
|
+
handleTeamsSigninVerifyState(context: TurnContext, query: SigninStateVerificationQuery): Promise<void>;
|
|
375
|
+
/**
|
|
376
|
+
* Receives invoke activities with Activity name of 'signin/tokenExchange'
|
|
377
|
+
* @param context A context object for this turn.
|
|
378
|
+
* @param query Signin state (part of signin action auth flow) verification invoke query
|
|
379
|
+
* @returns A promise that represents the work queued.
|
|
380
|
+
*
|
|
381
|
+
* @remark
|
|
382
|
+
* It should trigger {@link BotSsoExecutionDialog} instance to handle signin process
|
|
383
|
+
*/
|
|
384
|
+
handleTeamsSigninTokenExchange(context: TurnContext, query: SigninStateVerificationQuery): Promise<void>;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Sso execution dialog, use to handle sso command
|
|
389
|
+
*/
|
|
390
|
+
export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
391
|
+
private dedupStorage;
|
|
392
|
+
private dedupStorageKeys;
|
|
393
|
+
private commandMapping;
|
|
394
|
+
/**
|
|
395
|
+
* Creates a new instance of the BotSsoExecutionDialog.
|
|
396
|
+
* @param dedupStorage Helper storage to remove duplicated messages
|
|
397
|
+
* @param settings The list of scopes for which the token will have access
|
|
398
|
+
* @param teamsfx {@link TeamsFx} instance for authentication
|
|
399
|
+
*/
|
|
400
|
+
constructor(dedupStorage: Storage_2, ssoPromptSettings: TeamsBotSsoPromptSettings, teamsfx: TeamsFx, dialogName?: string);
|
|
401
|
+
/**
|
|
402
|
+
* Add TeamsFxBotSsoCommandHandler instance
|
|
403
|
+
* @param handler {@link BotSsoExecutionDialogHandler} callback function
|
|
404
|
+
* @param triggerPatterns The trigger pattern
|
|
405
|
+
*/
|
|
406
|
+
addCommand(handler: BotSsoExecutionDialogHandler, triggerPatterns: TriggerPatterns): void;
|
|
407
|
+
private getCommandHash;
|
|
408
|
+
/**
|
|
409
|
+
* The run method handles the incoming activity (in the form of a DialogContext) and passes it through the dialog system.
|
|
410
|
+
*
|
|
411
|
+
* @param context The context object for the current turn.
|
|
412
|
+
* @param accessor The instance of StatePropertyAccessor for dialog system.
|
|
413
|
+
*/
|
|
414
|
+
run(context: TurnContext, accessor: StatePropertyAccessor): Promise<void>;
|
|
415
|
+
private getActivityText;
|
|
416
|
+
private commandRouteStep;
|
|
417
|
+
private ssoStep;
|
|
418
|
+
private dedupStep;
|
|
419
|
+
/**
|
|
420
|
+
* Called when the component is ending.
|
|
421
|
+
*
|
|
422
|
+
* @param context Context for the current turn of conversation.
|
|
423
|
+
*/
|
|
424
|
+
protected onEndDialog(context: TurnContext): Promise<void>;
|
|
425
|
+
/**
|
|
426
|
+
* If a user is signed into multiple Teams clients, the Bot might receive a "signin/tokenExchange" from each client.
|
|
427
|
+
* Each token exchange request for a specific user login will have an identical activity.value.Id.
|
|
428
|
+
* Only one of these token exchange requests should be processed by the bot. For a distributed bot in production,
|
|
429
|
+
* this requires a distributed storage to ensure only one token exchange is processed.
|
|
430
|
+
* @param context Context for the current turn of conversation.
|
|
431
|
+
* @returns boolean value indicate whether the message should be removed
|
|
432
|
+
*/
|
|
433
|
+
private shouldDedup;
|
|
434
|
+
private getStorageKey;
|
|
435
|
+
private matchPattern;
|
|
436
|
+
private isPatternMatched;
|
|
437
|
+
private getMatchesCommandId;
|
|
438
|
+
/**
|
|
439
|
+
* Ensure bot is running in MS Teams since TeamsBotSsoPrompt is only supported in MS Teams channel.
|
|
440
|
+
* @param dc dialog context
|
|
441
|
+
* @throws {@link ErrorCode|ChannelNotSupported} if bot channel is not MS Teams
|
|
442
|
+
* @internal
|
|
443
|
+
*/
|
|
444
|
+
private ensureMsTeamsChannel;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
export declare type BotSsoExecutionDialogHandler = (context: TurnContext, tokenResponse: TeamsBotSsoPromptTokenResponse, message: CommandMessage) => Promise<void>;
|
|
448
|
+
|
|
274
449
|
/**
|
|
275
450
|
* A card action bot to respond to adaptive card universal actions.
|
|
276
451
|
*/
|
|
@@ -389,25 +564,39 @@ export declare class Channel implements NotificationTarget {
|
|
|
389
564
|
export declare class CommandBot {
|
|
390
565
|
private readonly adapter;
|
|
391
566
|
private readonly middleware;
|
|
567
|
+
private readonly ssoConfig;
|
|
392
568
|
/**
|
|
393
569
|
* Creates a new instance of the `CommandBot`.
|
|
394
570
|
*
|
|
395
571
|
* @param adapter The bound `BotFrameworkAdapter`.
|
|
396
572
|
* @param options - initialize options
|
|
397
573
|
*/
|
|
398
|
-
constructor(adapter: BotFrameworkAdapter, options?: CommandOptions);
|
|
574
|
+
constructor(adapter: BotFrameworkAdapter, options?: CommandOptions, ssoCommandActivityHandler?: BotSsoExecutionActivityHandler, ssoConfig?: BotSsoConfig);
|
|
399
575
|
/**
|
|
400
576
|
* Registers a command into the command bot.
|
|
401
577
|
*
|
|
402
|
-
* @param command The command to
|
|
578
|
+
* @param command The command to register.
|
|
403
579
|
*/
|
|
404
580
|
registerCommand(command: TeamsFxBotCommandHandler): void;
|
|
405
581
|
/**
|
|
406
582
|
* Registers commands into the command bot.
|
|
407
583
|
*
|
|
408
|
-
* @param commands The
|
|
584
|
+
* @param commands The commands to register.
|
|
409
585
|
*/
|
|
410
586
|
registerCommands(commands: TeamsFxBotCommandHandler[]): void;
|
|
587
|
+
/**
|
|
588
|
+
* Registers a sso command into the command bot.
|
|
589
|
+
*
|
|
590
|
+
* @param command The command to register.
|
|
591
|
+
*/
|
|
592
|
+
registerSsoCommand(ssoCommand: TeamsFxBotSsoCommandHandler): void;
|
|
593
|
+
/**
|
|
594
|
+
* Registers commands into the command bot.
|
|
595
|
+
*
|
|
596
|
+
* @param commands The commands to register.
|
|
597
|
+
*/
|
|
598
|
+
registerSsoCommands(ssoCommands: TeamsFxBotSsoCommandHandler[]): void;
|
|
599
|
+
private validateSsoActivityHandler;
|
|
411
600
|
}
|
|
412
601
|
|
|
413
602
|
/**
|
|
@@ -432,6 +621,10 @@ export declare interface CommandOptions {
|
|
|
432
621
|
* 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
622
|
*/
|
|
434
623
|
commands?: TeamsFxBotCommandHandler[];
|
|
624
|
+
/**
|
|
625
|
+
* 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.
|
|
626
|
+
*/
|
|
627
|
+
ssoCommands?: TeamsFxBotSsoCommandHandler[];
|
|
435
628
|
}
|
|
436
629
|
|
|
437
630
|
/**
|
|
@@ -533,7 +726,7 @@ export declare class ConversationBot {
|
|
|
533
726
|
* });
|
|
534
727
|
* ```
|
|
535
728
|
*/
|
|
536
|
-
requestHandler(req: WebRequest, res: WebResponse, logic?: (context:
|
|
729
|
+
requestHandler(req: WebRequest, res: WebResponse, logic?: (context: TurnContext) => Promise<any>): Promise<void>;
|
|
537
730
|
}
|
|
538
731
|
|
|
539
732
|
/**
|
|
@@ -558,6 +751,10 @@ export declare interface ConversationOptions {
|
|
|
558
751
|
adapterConfig?: {
|
|
559
752
|
[key: string]: unknown;
|
|
560
753
|
};
|
|
754
|
+
/**
|
|
755
|
+
* Configurations for sso command bot
|
|
756
|
+
*/
|
|
757
|
+
ssoConfig?: BotSsoConfig;
|
|
561
758
|
/**
|
|
562
759
|
* The command part.
|
|
563
760
|
*/
|
|
@@ -708,6 +905,30 @@ export declare enum ErrorCode {
|
|
|
708
905
|
* Channel is not supported error.
|
|
709
906
|
*/
|
|
710
907
|
ChannelNotSupported = "ChannelNotSupported",
|
|
908
|
+
/**
|
|
909
|
+
* Failed to retrieve sso token
|
|
910
|
+
*/
|
|
911
|
+
FailedToRetrieveSsoToken = "FailedToRetrieveSsoToken",
|
|
912
|
+
/**
|
|
913
|
+
* Failed to process sso handler
|
|
914
|
+
*/
|
|
915
|
+
FailedToProcessSsoHandler = "FailedToProcessSsoHandler",
|
|
916
|
+
/**
|
|
917
|
+
* Cannot find command
|
|
918
|
+
*/
|
|
919
|
+
CannotFindCommand = "CannotFindCommand",
|
|
920
|
+
/**
|
|
921
|
+
* Failed to run sso step
|
|
922
|
+
*/
|
|
923
|
+
FailedToRunSsoStep = "FailedToRunSsoStep",
|
|
924
|
+
/**
|
|
925
|
+
* Failed to run dedup step
|
|
926
|
+
*/
|
|
927
|
+
FailedToRunDedupStep = "FailedToRunDedupStep",
|
|
928
|
+
/**
|
|
929
|
+
* Sso activity handler is undefined
|
|
930
|
+
*/
|
|
931
|
+
SsoActivityHandlerIsUndefined = "SsoActivityHandlerIsUndefined",
|
|
711
932
|
/**
|
|
712
933
|
* Runtime is not supported error.
|
|
713
934
|
*/
|
|
@@ -772,6 +993,10 @@ export declare class ErrorWithCode extends Error {
|
|
|
772
993
|
*/
|
|
773
994
|
export declare function getLogLevel(): LogLevel | undefined;
|
|
774
995
|
|
|
996
|
+
export declare interface GetTeamsUserTokenOptions extends GetTokenOptions {
|
|
997
|
+
resources?: string[];
|
|
998
|
+
}
|
|
999
|
+
|
|
775
1000
|
/**
|
|
776
1001
|
* Generate connection configuration consumed by tedious.
|
|
777
1002
|
*
|
|
@@ -786,6 +1011,25 @@ export declare function getLogLevel(): LogLevel | undefined;
|
|
|
786
1011
|
*/
|
|
787
1012
|
export declare function getTediousConnectionConfig(teamsfx: TeamsFx, databaseName?: string): Promise<ConnectionConfig>;
|
|
788
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
|
+
|
|
789
1033
|
/**
|
|
790
1034
|
* Identity type to use in authentication.
|
|
791
1035
|
*/
|
|
@@ -853,7 +1097,7 @@ export declare class InvokeResponseFactory {
|
|
|
853
1097
|
*
|
|
854
1098
|
* @returns {InvokeResponse} An InvokeResponse object.
|
|
855
1099
|
*/
|
|
856
|
-
static textMessage(message: string):
|
|
1100
|
+
static textMessage(message: string): InvokeResponse;
|
|
857
1101
|
/**
|
|
858
1102
|
* Create an invoke response from an adaptive card.
|
|
859
1103
|
*
|
|
@@ -865,7 +1109,7 @@ export declare class InvokeResponseFactory {
|
|
|
865
1109
|
*
|
|
866
1110
|
* @returns {InvokeResponse} An InvokeResponse object.
|
|
867
1111
|
*/
|
|
868
|
-
static adaptiveCard(card: IAdaptiveCard):
|
|
1112
|
+
static adaptiveCard(card: IAdaptiveCard): InvokeResponse;
|
|
869
1113
|
/**
|
|
870
1114
|
* Create an invoke response with error code and message.
|
|
871
1115
|
*
|
|
@@ -879,7 +1123,7 @@ export declare class InvokeResponseFactory {
|
|
|
879
1123
|
*
|
|
880
1124
|
* @returns {InvokeResponse} An InvokeResponse object.
|
|
881
1125
|
*/
|
|
882
|
-
static errorResponse(errorCode: InvokeResponseErrorCode, errorMessage: string):
|
|
1126
|
+
static errorResponse(errorCode: InvokeResponseErrorCode, errorMessage: string): InvokeResponse;
|
|
883
1127
|
/**
|
|
884
1128
|
* Create an invoke response with status code and response value.
|
|
885
1129
|
* @param statusCode The status code.
|
|
@@ -887,7 +1131,7 @@ export declare class InvokeResponseFactory {
|
|
|
887
1131
|
*
|
|
888
1132
|
* @returns {InvokeResponse} An InvokeResponse object.
|
|
889
1133
|
*/
|
|
890
|
-
static createInvokeResponse(statusCode: StatusCodes, body?: unknown):
|
|
1134
|
+
static createInvokeResponse(statusCode: StatusCodes, body?: unknown): InvokeResponse;
|
|
891
1135
|
}
|
|
892
1136
|
|
|
893
1137
|
/**
|
|
@@ -1028,14 +1272,14 @@ export declare class MessageBuilder {
|
|
|
1028
1272
|
* });
|
|
1029
1273
|
* ```
|
|
1030
1274
|
*/
|
|
1031
|
-
static attachAdaptiveCard<TData extends object>(cardTemplate: unknown, data: TData): Partial<
|
|
1275
|
+
static attachAdaptiveCard<TData extends object>(cardTemplate: unknown, data: TData): Partial<Activity>;
|
|
1032
1276
|
/**
|
|
1033
1277
|
* Build a bot message activity attached with an adaptive card.
|
|
1034
1278
|
*
|
|
1035
1279
|
* @param card The adaptive card content.
|
|
1036
1280
|
* @returns A bot message activity attached with an adaptive card.
|
|
1037
1281
|
*/
|
|
1038
|
-
static attachAdaptiveCardWithoutData(card: unknown): Partial<
|
|
1282
|
+
static attachAdaptiveCardWithoutData(card: unknown): Partial<Activity>;
|
|
1039
1283
|
/**
|
|
1040
1284
|
* Build a bot message activity attached with an hero card.
|
|
1041
1285
|
*
|
|
@@ -1056,7 +1300,7 @@ export declare class MessageBuilder {
|
|
|
1056
1300
|
* );
|
|
1057
1301
|
* ```
|
|
1058
1302
|
*/
|
|
1059
|
-
static attachHeroCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<HeroCard>): Partial<
|
|
1303
|
+
static attachHeroCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<HeroCard>): Partial<Activity>;
|
|
1060
1304
|
/**
|
|
1061
1305
|
* Returns an attachment for a sign-in card.
|
|
1062
1306
|
*
|
|
@@ -1069,20 +1313,20 @@ export declare class MessageBuilder {
|
|
|
1069
1313
|
* @remarks
|
|
1070
1314
|
* For channels that don't natively support sign-in cards, an alternative message is rendered.
|
|
1071
1315
|
*/
|
|
1072
|
-
static attachSigninCard(title: string, url: string, text?: string): Partial<
|
|
1316
|
+
static attachSigninCard(title: string, url: string, text?: string): Partial<Activity>;
|
|
1073
1317
|
/**
|
|
1074
1318
|
* Build a bot message activity attached with an Office 365 connector card.
|
|
1075
1319
|
*
|
|
1076
1320
|
* @param card A description of the Office 365 connector card.
|
|
1077
1321
|
* @returns A bot message activity attached with an Office 365 connector card.
|
|
1078
1322
|
*/
|
|
1079
|
-
static attachO365ConnectorCard(card: O365ConnectorCard): Partial<
|
|
1323
|
+
static attachO365ConnectorCard(card: O365ConnectorCard): Partial<Activity>;
|
|
1080
1324
|
/**
|
|
1081
1325
|
* Build a message activity attached with a receipt card.
|
|
1082
1326
|
* @param card A description of the receipt card.
|
|
1083
1327
|
* @returns A message activity attached with a receipt card.
|
|
1084
1328
|
*/
|
|
1085
|
-
static AttachReceiptCard(card: ReceiptCard): Partial<
|
|
1329
|
+
static AttachReceiptCard(card: ReceiptCard): Partial<Activity>;
|
|
1086
1330
|
/**
|
|
1087
1331
|
*
|
|
1088
1332
|
* @param title The card title.
|
|
@@ -1092,13 +1336,27 @@ export declare class MessageBuilder {
|
|
|
1092
1336
|
* @param other Optional. Any additional properties to include on the card.
|
|
1093
1337
|
* @returns A message activity attached with a thumbnail card
|
|
1094
1338
|
*/
|
|
1095
|
-
static attachThumbnailCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<ThumbnailCard>): Partial<
|
|
1339
|
+
static attachThumbnailCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<ThumbnailCard>): Partial<Activity>;
|
|
1096
1340
|
/**
|
|
1097
1341
|
* Add an attachement to a bot activity.
|
|
1098
1342
|
* @param attachement The attachment object to attach.
|
|
1099
1343
|
* @returns A message activity with an attachment.
|
|
1100
1344
|
*/
|
|
1101
|
-
static attachContent(attachement: Attachment): Partial<
|
|
1345
|
+
static attachContent(attachement: Attachment): Partial<Activity>;
|
|
1346
|
+
}
|
|
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;
|
|
1102
1360
|
}
|
|
1103
1361
|
|
|
1104
1362
|
/**
|
|
@@ -1168,6 +1426,43 @@ export declare class NotificationBot {
|
|
|
1168
1426
|
* @returns - an array of {@link TeamsBotInstallation}.
|
|
1169
1427
|
*/
|
|
1170
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;
|
|
1171
1466
|
}
|
|
1172
1467
|
|
|
1173
1468
|
/**
|
|
@@ -1357,6 +1652,30 @@ export declare class OnBehalfOfUserCredential implements TokenCredential {
|
|
|
1357
1652
|
private generateAuthServerError;
|
|
1358
1653
|
}
|
|
1359
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
|
+
|
|
1360
1679
|
/**
|
|
1361
1680
|
* Send an adaptive card message to a notification target.
|
|
1362
1681
|
*
|
|
@@ -1478,6 +1797,12 @@ export declare class TeamsBotInstallation implements NotificationTarget {
|
|
|
1478
1797
|
* @returns an array of members from where the bot is installed.
|
|
1479
1798
|
*/
|
|
1480
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>;
|
|
1481
1806
|
}
|
|
1482
1807
|
|
|
1483
1808
|
/**
|
|
@@ -1671,7 +1996,7 @@ export declare class TeamsFx implements TeamsFxConfiguration {
|
|
|
1671
1996
|
*
|
|
1672
1997
|
* @throws {@link ErrorCode|IdentityTypeNotSupported} when setting app identity in browser.
|
|
1673
1998
|
*/
|
|
1674
|
-
constructor(identityType?: IdentityType, customConfig?: Record<string, string>);
|
|
1999
|
+
constructor(identityType?: IdentityType, customConfig?: Record<string, string> | AuthenticationConfiguration);
|
|
1675
2000
|
/**
|
|
1676
2001
|
* Identity type set by user.
|
|
1677
2002
|
*
|
|
@@ -1690,9 +2015,10 @@ export declare class TeamsFx implements TeamsFxConfiguration {
|
|
|
1690
2015
|
getCredential(): TokenCredential;
|
|
1691
2016
|
/**
|
|
1692
2017
|
* Get user information.
|
|
2018
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
1693
2019
|
* @returns UserInfo object.
|
|
1694
2020
|
*/
|
|
1695
|
-
getUserInfo(): Promise<UserInfo>;
|
|
2021
|
+
getUserInfo(resources?: string[]): Promise<UserInfo>;
|
|
1696
2022
|
/**
|
|
1697
2023
|
* Popup login page to get user's access token with specific scopes.
|
|
1698
2024
|
*
|
|
@@ -1707,13 +2033,14 @@ export declare class TeamsFx implements TeamsFxConfiguration {
|
|
|
1707
2033
|
* await teamsfx.login("https://graph.microsoft.com/User.Read Calendars.Read"); // multiple scopes using string
|
|
1708
2034
|
* ```
|
|
1709
2035
|
* @param scopes - The list of scopes for which the token will have access, before that, we will request user to consent.
|
|
2036
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
1710
2037
|
*
|
|
1711
2038
|
* @throws {@link ErrorCode|InternalError} when failed to login with unknown error.
|
|
1712
2039
|
* @throws {@link ErrorCode|ConsentFailed} when user canceled or failed to consent.
|
|
1713
2040
|
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
1714
2041
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
|
1715
2042
|
*/
|
|
1716
|
-
login(scopes: string | string[]): Promise<void>;
|
|
2043
|
+
login(scopes: string | string[], resources?: string[]): Promise<void>;
|
|
1717
2044
|
/**
|
|
1718
2045
|
* Set SSO token when using user identity in NodeJS.
|
|
1719
2046
|
* @param {string} ssoToken - used for on behalf of user flow.
|
|
@@ -1803,6 +2130,26 @@ export declare interface TeamsFxBotCommandHandler {
|
|
|
1803
2130
|
handleCommandReceived(context: TurnContext, message: CommandMessage): Promise<string | Partial<Activity> | void>;
|
|
1804
2131
|
}
|
|
1805
2132
|
|
|
2133
|
+
/**
|
|
2134
|
+
* Interface for a command handler that can process sso command to a TeamsFx bot and return a response.
|
|
2135
|
+
*/
|
|
2136
|
+
export declare interface TeamsFxBotSsoCommandHandler {
|
|
2137
|
+
/**
|
|
2138
|
+
* The string or regular expression patterns that can trigger this handler.
|
|
2139
|
+
*/
|
|
2140
|
+
triggerPatterns: TriggerPatterns;
|
|
2141
|
+
/**
|
|
2142
|
+
* Handles a bot command received activity.
|
|
2143
|
+
*
|
|
2144
|
+
* @param context The bot context.
|
|
2145
|
+
* @param message The command message the user types from Teams.
|
|
2146
|
+
* @param tokenResponse The tokenResponse which contains sso token that can be used to exchange access token for the bot.
|
|
2147
|
+
* @returns A `Promise` representing an activity or text to send as the command response.
|
|
2148
|
+
* Or no return value if developers want to send the response activity by themselves in this method.
|
|
2149
|
+
*/
|
|
2150
|
+
handleCommandReceived(context: TurnContext, message: CommandMessage, tokenResponse: TeamsBotSsoPromptTokenResponse): Promise<string | Partial<Activity> | void>;
|
|
2151
|
+
}
|
|
2152
|
+
|
|
1806
2153
|
/**
|
|
1807
2154
|
* TeamsFx interface that provides credential and configuration.
|
|
1808
2155
|
*/
|
|
@@ -1825,9 +2172,10 @@ declare interface TeamsFxConfiguration {
|
|
|
1825
2172
|
getCredential(): TokenCredential;
|
|
1826
2173
|
/**
|
|
1827
2174
|
* Get user information.
|
|
2175
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
1828
2176
|
* @returns UserInfo object.
|
|
1829
2177
|
*/
|
|
1830
|
-
getUserInfo(): Promise<UserInfo>;
|
|
2178
|
+
getUserInfo(resources?: string[]): Promise<UserInfo>;
|
|
1831
2179
|
/**
|
|
1832
2180
|
* Popup login page to get user's access token with specific scopes.
|
|
1833
2181
|
*
|
|
@@ -1842,13 +2190,14 @@ declare interface TeamsFxConfiguration {
|
|
|
1842
2190
|
* await teamsfx.login("https://graph.microsoft.com/User.Read Calendars.Read"); // multiple scopes using string
|
|
1843
2191
|
* ```
|
|
1844
2192
|
* @param scopes - The list of scopes for which the token will have access, before that, we will request user to consent.
|
|
2193
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
1845
2194
|
*
|
|
1846
2195
|
* @throws {@link ErrorCode|InternalError} when failed to login with unknown error.
|
|
1847
2196
|
* @throws {@link ErrorCode|ConsentFailed} when user canceled or failed to consent.
|
|
1848
2197
|
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
1849
2198
|
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
|
1850
2199
|
*/
|
|
1851
|
-
login(scopes: string | string[]): Promise<void>;
|
|
2200
|
+
login(scopes: string | string[], resources?: string[]): Promise<void>;
|
|
1852
2201
|
/**
|
|
1853
2202
|
* Set SSO token when using user identity in NodeJS.
|
|
1854
2203
|
* @param {string} ssoToken - used for on behalf of user flow.
|
|
@@ -1889,10 +2238,13 @@ export declare class TeamsUserCredential implements TokenCredential {
|
|
|
1889
2238
|
constructor(authConfig: AuthenticationConfiguration);
|
|
1890
2239
|
/**
|
|
1891
2240
|
* Popup login page to get user's access token with specific scopes.
|
|
2241
|
+
*
|
|
2242
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
2243
|
+
*
|
|
1892
2244
|
* @remarks
|
|
1893
2245
|
* Can only be used within Teams.
|
|
1894
2246
|
*/
|
|
1895
|
-
login(scopes: string | string[]): Promise<void>;
|
|
2247
|
+
login(scopes: string | string[], resources?: string[]): Promise<void>;
|
|
1896
2248
|
/**
|
|
1897
2249
|
* Get access token from credential.
|
|
1898
2250
|
* @remarks
|
|
@@ -1901,10 +2253,13 @@ export declare class TeamsUserCredential implements TokenCredential {
|
|
|
1901
2253
|
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
|
|
1902
2254
|
/**
|
|
1903
2255
|
* Get basic user info from SSO token
|
|
2256
|
+
*
|
|
2257
|
+
* @param {string[]} resources - The optional list of resources for full trust Teams apps.
|
|
2258
|
+
*
|
|
1904
2259
|
* @remarks
|
|
1905
2260
|
* Can only be used within Teams.
|
|
1906
2261
|
*/
|
|
1907
|
-
getUserInfo(): Promise<UserInfo>;
|
|
2262
|
+
getUserInfo(resources?: string[]): Promise<UserInfo>;
|
|
1908
2263
|
}
|
|
1909
2264
|
|
|
1910
2265
|
/**
|