@microsoft/teamsfx 0.6.3-alpha.8d048e1f1.0 → 0.6.3-alpha.f018de6e6.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.
@@ -1,3 +1,5 @@
1
+ /// <reference types="node" />
2
+
1
3
  import { AccessToken } from '@azure/identity';
2
4
  import { Activity } from 'botbuilder-core';
3
5
  import { Activity as Activity_2 } from 'botbuilder';
@@ -19,11 +21,15 @@ import { GetTokenOptions } from '@azure/identity';
19
21
  import { HeroCard } from 'botbuilder';
20
22
  import { O365ConnectorCard } from 'botbuilder';
21
23
  import { ReceiptCard } from 'botbuilder';
24
+ import { SecureContextOptions } from 'tls';
22
25
  import { TeamsChannelAccount } from 'botbuilder';
23
26
  import { ThumbnailCard } from 'botbuilder';
24
27
  import { TokenCredential } from '@azure/identity';
25
28
  import { TokenResponse } from 'botframework-schema';
26
29
  import { TurnContext } from 'botbuilder-core';
30
+ import { TurnContext as TurnContext_2 } from 'botbuilder';
31
+ import { WebRequest } from 'botbuilder';
32
+ import { WebResponse } from 'botbuilder';
27
33
 
28
34
  /**
29
35
  * Represent Microsoft 365 tenant identity, and it is usually used when user is not involved like time-triggered automation job.
@@ -156,6 +162,39 @@ export declare interface AuthProvider {
156
162
  AddAuthenticationInfo: (config: AxiosRequestConfig) => Promise<AxiosRequestConfig>;
157
163
  }
158
164
 
165
+ export { AxiosInstance }
166
+
167
+ /**
168
+ * Provider that handles Basic authentication
169
+ *
170
+ * @beta
171
+ */
172
+ export declare class BasicAuthProvider implements AuthProvider {
173
+ private userName;
174
+ private password;
175
+ /**
176
+ *
177
+ * @param userName - Username used in basic auth
178
+ * @param password - Password used in basic auth
179
+ *
180
+ * @beta
181
+ */
182
+ constructor(userName: string, password: string);
183
+ /**
184
+ * Adds authentication info to http requests
185
+ *
186
+ * @param config - Contains all the request information and can be updated to include extra authentication info.
187
+ * Refer https://axios-http.com/docs/req_config for detailed document.
188
+ *
189
+ * @returns Updated axios request config.
190
+ *
191
+ * @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header or auth property already exists in request configuration.
192
+ *
193
+ * @beta
194
+ */
195
+ AddAuthenticationInfo(config: AxiosRequestConfig): Promise<AxiosRequestConfig>;
196
+ }
197
+
159
198
  /**
160
199
  * Provider that handles Bearer Token authentication
161
200
  *
@@ -175,6 +214,39 @@ export declare class BearerTokenAuthProvider implements AuthProvider {
175
214
  * @param config - Contains all the request information and can be updated to include extra authentication info.
176
215
  * Refer https://axios-http.com/docs/req_config for detailed document.
177
216
  *
217
+ * @returns Updated axios request config.
218
+ *
219
+ * @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header already exists in request configuration.
220
+ *
221
+ * @beta
222
+ */
223
+ AddAuthenticationInfo(config: AxiosRequestConfig): Promise<AxiosRequestConfig>;
224
+ }
225
+
226
+ /**
227
+ * Provider that handles Certificate authentication
228
+ *
229
+ * @beta
230
+ */
231
+ export declare class CertificateAuthProvider implements AuthProvider {
232
+ private certOption;
233
+ /**
234
+ *
235
+ * @param { SecureContextOptions } certOption - information about the cert used in http requests
236
+ *
237
+ * @beta
238
+ */
239
+ constructor(certOption: SecureContextOptions);
240
+ /**
241
+ * Adds authentication info to http requests.
242
+ *
243
+ * @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
244
+ * Refer https://axios-http.com/docs/req_config for detailed document.
245
+ *
246
+ * @returns Updated axios request config.
247
+ *
248
+ * @throws {@link ErrorCode|InvalidParameter} - when custom httpsAgent in the request has duplicate properties with certOption provided in constructor.
249
+ *
178
250
  * @beta
179
251
  */
180
252
  AddAuthenticationInfo(config: AxiosRequestConfig): Promise<AxiosRequestConfig>;
@@ -290,7 +362,7 @@ export declare interface CommandMessage {
290
362
  */
291
363
  text: string;
292
364
  /**
293
- * The capture groups that matched to the {@link triggerPatterns} in a {@link TeamsFxBotCommandHandler} instance.
365
+ * The capture groups that matched to the {@link TriggerPatterns} in a {@link TeamsFxBotCommandHandler} instance.
294
366
  */
295
367
  matches?: RegExpMatchArray;
296
368
  }
@@ -312,7 +384,7 @@ export declare interface CommandOptions {
312
384
  /**
313
385
  * Provide utilities for bot conversation, including:
314
386
  * - handle command and response.
315
- * - send notification to varies targets (e.g., member, channel, incoming wehbook).
387
+ * - send notification to varies targets (e.g., member, group, channel).
316
388
  *
317
389
  * @example
318
390
  * For command and response, you can register your commands through the constructor, or use the `registerCommand` and `registerCommands` API to add commands later.
@@ -322,9 +394,7 @@ export declare interface CommandOptions {
322
394
  * const conversationBot = new ConversationBot({
323
395
  * command: {
324
396
  * enabled: true,
325
- * options: {
326
- * commands: [ new HelloWorldCommandHandler() ],
327
- * },
397
+ * commands: [ new HelloWorldCommandHandler() ],
328
398
  * },
329
399
  * });
330
400
  *
@@ -332,7 +402,7 @@ export declare interface CommandOptions {
332
402
  * conversationBot.command.registerCommand(new HelpCommandHandler());
333
403
  * ```
334
404
  *
335
- * For notification, you can enable notification at initialization, then send notificaations at any time.
405
+ * For notification, you can enable notification at initialization, then send notifications at any time.
336
406
  *
337
407
  * ```typescript
338
408
  * // enable through constructor
@@ -360,7 +430,7 @@ export declare interface CommandOptions {
360
430
  *
361
431
  * For command and response, ensure each command should ONLY be registered with the command once, otherwise it'll cause unexpected behavior if you register the same command more than once.
362
432
  *
363
- * For notification, set `notification.options.storage` in {@link ConversationOptions} to use your own storage implementation.
433
+ * For notification, set `notification.storage` in {@link ConversationOptions} to use your own storage implementation.
364
434
  *
365
435
  * @beta
366
436
  */
@@ -386,11 +456,39 @@ export declare class ConversationBot {
386
456
  /**
387
457
  * Creates new instance of the `ConversationBot`.
388
458
  *
459
+ * @remarks
460
+ * It's recommended to create your own adapter and storage for production environment instead of the default one.
461
+ *
389
462
  * @param options - initialize options
390
463
  *
391
464
  * @beta
392
465
  */
393
466
  constructor(options: ConversationOptions);
467
+ private createDefaultAdapter;
468
+ /**
469
+ * The request handler to integrate with web request.
470
+ *
471
+ * @param req - an Express or Restify style request object.
472
+ * @param res - an Express or Restify style response object.
473
+ * @param logic - the additional function to handle bot context.
474
+ *
475
+ * @example
476
+ * For example, to use with Restify:
477
+ * ``` typescript
478
+ * // The default/empty behavior
479
+ * server.post("api/messages", conversationBot.requestHandler);
480
+ *
481
+ * // Or, add your own logic
482
+ * server.post("api/messages", async (req, res) => {
483
+ * await conversationBot.requestHandler(req, res, async (context) => {
484
+ * // your-own-context-logic
485
+ * });
486
+ * });
487
+ * ```
488
+ *
489
+ * @beta
490
+ */
491
+ requestHandler(req: WebRequest, res: WebResponse, logic?: (context: TurnContext_2) => Promise<any>): Promise<void>;
394
492
  }
395
493
 
396
494
  /**
@@ -400,48 +498,52 @@ export declare class ConversationBot {
400
498
  */
401
499
  export declare interface ConversationOptions {
402
500
  /**
403
- * The bot adapter. If not provided, a default adapter will be created with BOT_ID and BOT_PASSWORD from environment variables.
501
+ * The bot adapter. If not provided, a default adapter will be created:
502
+ * - with `adapterConfig` as constructor parameter.
503
+ * - with a default error handler that logs error to console, sends trace activity, and sends error message to user.
504
+ *
505
+ * @remarks
506
+ * If neither `adapter` nor `adapterConfig` is provided, will use BOT_ID and BOT_PASSWORD from environment variables.
404
507
  *
405
508
  * @beta
406
509
  */
407
510
  adapter?: BotFrameworkAdapter;
511
+ /**
512
+ * If `adapter` is not provided, this `adapterConfig` will be passed to the new `BotFrameworkAdapter` when created internally.
513
+ *
514
+ * @remarks
515
+ * If neither `adapter` nor `adapterConfig` is provided, will use BOT_ID and BOT_PASSWORD from environment variables.
516
+ *
517
+ * @beta
518
+ */
519
+ adapterConfig?: {
520
+ [key: string]: unknown;
521
+ };
408
522
  /**
409
523
  * The command part.
410
524
  *
411
525
  * @beta
412
526
  */
413
- command: {
527
+ command?: CommandOptions & {
414
528
  /**
415
529
  * Whether to enable command or not.
416
530
  *
417
531
  * @beta
418
532
  */
419
- enabled: boolean;
420
- /**
421
- * The command options if command is enabled.
422
- *
423
- * @beta
424
- */
425
- options: CommandOptions;
533
+ enabled?: boolean;
426
534
  };
427
535
  /**
428
536
  * The notification part.
429
537
  *
430
538
  * @beta
431
539
  */
432
- notification: {
540
+ notification?: NotificationOptions_2 & {
433
541
  /**
434
542
  * Whether to enable notification or not.
435
543
  *
436
544
  * @beta
437
545
  */
438
- enabled: boolean;
439
- /**
440
- * The notification options if notification is enabled.
441
- *
442
- * @beta
443
- */
444
- options: NotificationOptions_2;
546
+ enabled?: boolean;
445
547
  };
446
548
  }
447
549
 
@@ -515,1251 +617,1283 @@ export declare function createApiClient(apiEndpoint: string, authProvider: AuthP
515
617
  export declare function createMicrosoftGraphClient(teamsfx: TeamsFxConfiguration, scopes?: string | string[]): Client;
516
618
 
517
619
  /**
518
- * Error code to trace the error types.
519
- * @beta
520
- */
521
- export declare enum ErrorCode {
522
- /**
523
- * Invalid parameter error.
524
- */
525
- InvalidParameter = "InvalidParameter",
526
- /**
527
- * Invalid configuration error.
528
- */
529
- InvalidConfiguration = "InvalidConfiguration",
530
- /**
531
- * Invalid certificate error.
532
- */
533
- InvalidCertificate = "InvalidCertificate",
534
- /**
535
- * Internal error.
536
- */
537
- InternalError = "InternalError",
538
- /**
539
- * Channel is not supported error.
540
- */
541
- ChannelNotSupported = "ChannelNotSupported",
542
- /**
543
- * Runtime is not supported error.
544
- */
545
- RuntimeNotSupported = "RuntimeNotSupported",
546
- /**
547
- * User failed to finish the AAD consent flow failed.
548
- */
549
- ConsentFailed = "ConsentFailed",
550
- /**
551
- * The user or administrator has not consented to use the application error.
552
- */
553
- UiRequiredError = "UiRequiredError",
554
- /**
555
- * Token is not within its valid time range error.
556
- */
557
- TokenExpiredError = "TokenExpiredError",
558
- /**
559
- * Call service (AAD or simple authentication server) failed.
560
- */
561
- ServiceError = "ServiceError",
562
- /**
563
- * Operation failed.
564
- */
565
- FailedOperation = "FailedOperation",
566
- /**
567
- * Invalid response error.
568
- */
569
- InvalidResponse = "InvalidResponse",
570
- /**
571
- * Identity type error.
572
- */
573
- IdentityTypeNotSupported = "IdentityTypeNotSupported"
574
- }
575
-
576
- /**
577
- * Error class with code and message thrown by the SDK.
620
+ * Helper to create SecureContextOptions from PEM format cert
578
621
  *
579
- * @beta
580
- */
581
- export declare class ErrorWithCode extends Error {
582
- /**
583
- * Error code
622
+ * @param { string | Buffer } cert - The cert chain in PEM format
623
+ * @param { string | Buffer } key - The private key for the cert chain
624
+ * @param { string? } passphrase - The passphrase for private key
625
+ * @param { string? | Buffer? } ca - Overrides the trusted CA certificates
584
626
  *
585
- * @readonly
586
- */
587
- code: string | undefined;
588
- /**
589
- * Constructor of ErrorWithCode.
627
+ * @returns Instance of SecureContextOptions
590
628
  *
591
- * @param {string} message - error message.
592
- * @param {ErrorCode} code - error code.
629
+ * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
593
630
  *
594
- * @beta
595
631
  */
596
- constructor(message?: string, code?: ErrorCode);
597
- }
632
+ export declare function createPemCertOption(cert: string | Buffer, key: string | Buffer, passphrase?: string, ca?: string | Buffer): SecureContextOptions;
598
633
 
599
- /**
600
- * Get log level.
601
- *
602
- * @returns Log level
603
- *
604
- * @beta
605
- */
606
- export declare function getLogLevel(): LogLevel | undefined;
634
+ /**
635
+ * Helper to create SecureContextOptions from PFX format cert
636
+ *
637
+ * @param { string | Buffer } pfx - The content of .pfx file
638
+ * @param { string? } passphrase - Optional. The passphrase of .pfx file
639
+ *
640
+ * @returns Instance of SecureContextOptions
641
+ *
642
+ * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
643
+ *
644
+ */
645
+ export declare function createPfxCertOption(pfx: string | Buffer, passphrase?: string): SecureContextOptions;
607
646
 
608
- /**
609
- * Generate connection configuration consumed by tedious.
610
- *
611
- * @param {TeamsFx} teamsfx - Used to provide configuration and auth
612
- * @param { string? } databaseName - specify database name to override default one if there are multiple databases.
613
- *
614
- * @returns Connection configuration of tedious for the SQL.
615
- *
616
- * @throws {@link ErrorCode|InvalidConfiguration} when SQL config resource configuration is invalid.
617
- * @throws {@link ErrorCode|InternalError} when get user MSI token failed or MSI token is invalid.
618
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
619
- *
620
- * @beta
621
- */
622
- export declare function getTediousConnectionConfig(teamsfx: TeamsFx, databaseName?: string): Promise<ConnectionConfig>;
647
+ /**
648
+ * Error code to trace the error types.
649
+ * @beta
650
+ */
651
+ export declare enum ErrorCode {
652
+ /**
653
+ * Invalid parameter error.
654
+ */
655
+ InvalidParameter = "InvalidParameter",
656
+ /**
657
+ * Invalid configuration error.
658
+ */
659
+ InvalidConfiguration = "InvalidConfiguration",
660
+ /**
661
+ * Invalid certificate error.
662
+ */
663
+ InvalidCertificate = "InvalidCertificate",
664
+ /**
665
+ * Internal error.
666
+ */
667
+ InternalError = "InternalError",
668
+ /**
669
+ * Channel is not supported error.
670
+ */
671
+ ChannelNotSupported = "ChannelNotSupported",
672
+ /**
673
+ * Runtime is not supported error.
674
+ */
675
+ RuntimeNotSupported = "RuntimeNotSupported",
676
+ /**
677
+ * User failed to finish the AAD consent flow failed.
678
+ */
679
+ ConsentFailed = "ConsentFailed",
680
+ /**
681
+ * The user or administrator has not consented to use the application error.
682
+ */
683
+ UiRequiredError = "UiRequiredError",
684
+ /**
685
+ * Token is not within its valid time range error.
686
+ */
687
+ TokenExpiredError = "TokenExpiredError",
688
+ /**
689
+ * Call service (AAD or simple authentication server) failed.
690
+ */
691
+ ServiceError = "ServiceError",
692
+ /**
693
+ * Operation failed.
694
+ */
695
+ FailedOperation = "FailedOperation",
696
+ /**
697
+ * Invalid response error.
698
+ */
699
+ InvalidResponse = "InvalidResponse",
700
+ /**
701
+ * Identity type error.
702
+ */
703
+ IdentityTypeNotSupported = "IdentityTypeNotSupported",
704
+ /**
705
+ * Authentication info already exists error.
706
+ */
707
+ AuthorizationInfoAlreadyExists = "AuthorizationInfoAlreadyExists"
708
+ }
623
709
 
624
- /**
625
- * Identity type to use in authentication.
626
- *
627
- * @beta
628
- */
629
- export declare enum IdentityType {
630
- /**
631
- * Represents the current user of Teams.
632
- */
633
- User = "User",
634
- /**
635
- * Represents the application itself.
636
- */
637
- App = "Application"
638
- }
710
+ /**
711
+ * Error class with code and message thrown by the SDK.
712
+ *
713
+ * @beta
714
+ */
715
+ export declare class ErrorWithCode extends Error {
716
+ /**
717
+ * Error code
718
+ *
719
+ * @readonly
720
+ */
721
+ code: string | undefined;
722
+ /**
723
+ * Constructor of ErrorWithCode.
724
+ *
725
+ * @param {string} message - error message.
726
+ * @param {ErrorCode} code - error code.
727
+ *
728
+ * @beta
729
+ */
730
+ constructor(message?: string, code?: ErrorCode);
731
+ }
639
732
 
640
- /**
641
- * Log function for customized logging.
642
- *
643
- * @beta
644
- */
645
- export declare type LogFunction = (level: LogLevel, message: string) => void;
733
+ /**
734
+ * Get log level.
735
+ *
736
+ * @returns Log level
737
+ *
738
+ * @beta
739
+ */
740
+ export declare function getLogLevel(): LogLevel | undefined;
646
741
 
647
- /**
648
- * Interface for customized logger.
649
- * @beta
650
- */
651
- export declare interface Logger {
652
- /**
653
- * Writes to error level logging or lower.
654
- */
655
- error(message: string): void;
656
- /**
657
- * Writes to warning level logging or lower.
658
- */
659
- warn(message: string): void;
660
- /**
661
- * Writes to info level logging or lower.
662
- */
663
- info(message: string): void;
664
- /**
665
- * Writes to verbose level logging.
666
- */
667
- verbose(message: string): void;
668
- }
742
+ /**
743
+ * Generate connection configuration consumed by tedious.
744
+ *
745
+ * @param {TeamsFx} teamsfx - Used to provide configuration and auth
746
+ * @param { string? } databaseName - specify database name to override default one if there are multiple databases.
747
+ *
748
+ * @returns Connection configuration of tedious for the SQL.
749
+ *
750
+ * @throws {@link ErrorCode|InvalidConfiguration} when SQL config resource configuration is invalid.
751
+ * @throws {@link ErrorCode|InternalError} when get user MSI token failed or MSI token is invalid.
752
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
753
+ *
754
+ * @beta
755
+ */
756
+ export declare function getTediousConnectionConfig(teamsfx: TeamsFx, databaseName?: string): Promise<ConnectionConfig>;
669
757
 
670
- /**
671
- * Log level.
672
- *
673
- * @beta
674
- */
675
- export declare enum LogLevel {
676
- /**
677
- * Show verbose, information, warning and error message.
678
- */
679
- Verbose = 0,
680
- /**
681
- * Show information, warning and error message.
682
- */
683
- Info = 1,
684
- /**
685
- * Show warning and error message.
686
- */
687
- Warn = 2,
688
- /**
689
- * Show error message.
690
- */
691
- Error = 3
692
- }
758
+ /**
759
+ * Identity type to use in authentication.
760
+ *
761
+ * @beta
762
+ */
763
+ export declare enum IdentityType {
764
+ /**
765
+ * Represents the current user of Teams.
766
+ */
767
+ User = "User",
768
+ /**
769
+ * Represents the application itself.
770
+ */
771
+ App = "Application"
772
+ }
693
773
 
694
- /**
695
- * A {@link NotificationTarget} that represents a team member.
696
- *
697
- * @remarks
698
- * It's recommended to get members from {@link TeamsBotInstallation.members()}.
699
- *
700
- * @beta
701
- */
702
- export declare class Member implements NotificationTarget {
703
- /**
704
- * The parent {@link TeamsBotInstallation} where this member is created from.
705
- *
706
- * @beta
707
- */
708
- readonly parent: TeamsBotInstallation;
709
- /**
710
- * Detailed member account information.
711
- *
712
- * @beta
713
- */
714
- readonly account: TeamsChannelAccount;
715
- /**
716
- * Notification target type. For member it's always "Person".
717
- *
718
- * @beta
719
- */
720
- readonly type: NotificationTargetType;
721
- /**
722
- * Constuctor.
723
- *
724
- * @remarks
725
- * It's recommended to get members from {@link TeamsBotInstallation.members()}, instead of using this constructor.
726
- *
727
- * @param parent - The parent {@link TeamsBotInstallation} where this member is created from.
728
- * @param account - Detailed member account information.
729
- *
730
- * @beta
731
- */
732
- constructor(parent: TeamsBotInstallation, account: TeamsChannelAccount);
733
- /**
734
- * Send a plain text message.
735
- *
736
- * @param text - the plain text message.
737
- * @returns A `Promise` representing the asynchronous operation.
738
- *
739
- * @beta
740
- */
741
- sendMessage(text: string): Promise<void>;
742
- /**
743
- * Send an adaptive card message.
744
- *
745
- * @param card - the adaptive card raw JSON.
746
- * @returns A `Promise` representing the asynchronous operation.
747
- *
748
- * @beta
749
- */
750
- sendAdaptiveCard(card: unknown): Promise<void>;
751
- /**
752
- * @internal
753
- */
754
- private newConversation;
755
- }
774
+ /**
775
+ * Log function for customized logging.
776
+ *
777
+ * @beta
778
+ */
779
+ export declare type LogFunction = (level: LogLevel, message: string) => void;
756
780
 
757
- /**
758
- * Provides utility method to build bot message with cards that supported in Teams.
759
- */
760
- export declare class MessageBuilder {
761
- /**
762
- * Build a bot message activity attached with adaptive card.
763
- *
764
- * @param getCardData Function to prepare your card data.
765
- * @param cardTemplate The adaptive card template.
766
- * @returns A bot message activity attached with an adaptive card.
767
- *
768
- * @example
769
- * ```javascript
770
- * const cardTemplate = {
771
- * type: "AdaptiveCard",
772
- * body: [
773
- * {
774
- * "type": "TextBlock",
775
- * "text": "${title}",
776
- * "size": "Large"
777
- * },
778
- * {
779
- * "type": "TextBlock",
780
- * "text": "${description}"
781
- * }],
782
- * $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
783
- * version: "1.4"
784
- * };
785
- *
786
- * type CardData = {
787
- * title: string,
788
- * description: string
789
- * };
790
- * const card = MessageBuilder.attachAdaptiveCard<CardData>(() => {
791
- * return {
792
- * title: "sample card title",
793
- * description: "sample card description"
794
- * }}, cardTemplate);
795
- * ```
796
- *
797
- * @beta
798
- */
799
- static attachAdaptiveCard<TData>(getCardData: () => TData, cardTemplate: any): Partial<Activity_2>;
800
- /**
801
- * Build a bot message activity attached with an adaptive card.
802
- *
803
- * @param card The adaptive card content.
804
- * @returns A bot message activity attached with an adaptive card.
805
- *
806
- * @beta
807
- */
808
- static attachAdaptiveCardWithoutData(card: any): Partial<Activity_2>;
809
- /**
810
- * Build a bot message activity attached with an hero card.
811
- *
812
- * @param title The card title.
813
- * @param images Optional. The array of images to include on the card.
814
- * @param buttons Optional. The array of buttons to include on the card. Each `string` in the array
815
- * is converted to an `imBack` button with a title and value set to the value of the string.
816
- * @param other Optional. Any additional properties to include on the card.
817
- *
818
- * @returns A bot message activity attached with a hero card.
819
- *
820
- * @example
821
- * ```javascript
822
- * const message = MessageBuilder.attachHeroCard(
823
- * 'sample title',
824
- * ['https://example.com/sample.jpg'],
825
- * ['action']
826
- * );
827
- * ```
828
- *
829
- * @beta
830
- */
831
- static attachHeroCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<HeroCard>): Partial<Activity_2>;
832
- /**
833
- * Returns an attachment for a sign-in card.
834
- *
835
- * @param title The title for the card's sign-in button.
836
- * @param url The URL of the sign-in page to use.
837
- * @param text Optional. Additional text to include on the card.
838
- *
839
- * @returns A bot message activity attached with a sign-in card.
840
- *
841
- * @remarks
842
- * For channels that don't natively support sign-in cards, an alternative message is rendered.
843
- *
844
- * @beta
845
- */
846
- static attachSigninCard(title: string, url: string, text?: string): Partial<Activity_2>;
847
- /**
848
- * Build a bot message activity attached with an Office 365 connector card.
849
- *
850
- * @param card A description of the Office 365 connector card.
851
- * @returns A bot message activity attached with an Office 365 connector card.
852
- *
853
- * @beta
854
- */
855
- static attachO365ConnectorCard(card: O365ConnectorCard): Partial<Activity_2>;
856
- /**
857
- * Build a message activity attached with a receipt card.
858
- * @param card A description of the receipt card.
859
- * @returns A message activity attached with a receipt card.
860
- *
861
- * @beta
862
- */
863
- static AttachReceiptCard(card: ReceiptCard): Partial<Activity_2>;
864
- /**
865
- *
866
- * @param title The card title.
867
- * @param images Optional. The array of images to include on the card.
868
- * @param buttons Optional. The array of buttons to include on the card. Each `string` in the array
869
- * is converted to an `imBack` button with a title and value set to the value of the string.
870
- * @param other Optional. Any additional properties to include on the card.
871
- * @returns A message activity attached with a thumbnail card
872
- *
873
- * @beta
874
- */
875
- static attachThumbnailCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<ThumbnailCard>): Partial<Activity_2>;
876
- /**
877
- * Add an attachement to a bot activity.
878
- * @param attachement The attachment object to attach.
879
- * @returns A message activity with an attachment.
880
- *
881
- * @beta
882
- */
883
- static attachContent(attachement: Attachment): Partial<Activity_2>;
884
- }
781
+ /**
782
+ * Interface for customized logger.
783
+ * @beta
784
+ */
785
+ export declare interface Logger {
786
+ /**
787
+ * Writes to error level logging or lower.
788
+ */
789
+ error(message: string): void;
790
+ /**
791
+ * Writes to warning level logging or lower.
792
+ */
793
+ warn(message: string): void;
794
+ /**
795
+ * Writes to info level logging or lower.
796
+ */
797
+ info(message: string): void;
798
+ /**
799
+ * Writes to verbose level logging.
800
+ */
801
+ verbose(message: string): void;
802
+ }
885
803
 
886
- /**
887
- * Microsoft Graph auth provider for Teams Framework
888
- *
889
- * @beta
890
- */
891
- export declare class MsGraphAuthProvider implements AuthenticationProvider {
892
- private teamsfx;
893
- private scopes;
894
- /**
895
- * Constructor of MsGraphAuthProvider.
896
- *
897
- * @param {TeamsFx} teamsfx - Used to provide configuration and auth.
898
- * @param {string | string[]} scopes - The list of scopes for which the token will have access.
899
- *
900
- * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
901
- *
902
- * @returns An instance of MsGraphAuthProvider.
903
- *
904
- * @beta
905
- */
906
- constructor(teamsfx: TeamsFxConfiguration, scopes?: string | string[]);
907
- /**
908
- * Get access token for Microsoft Graph API requests.
909
- *
910
- * @throws {@link ErrorCode|InternalError} when get access token failed due to empty token or unknown other problems.
911
- * @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
912
- * @throws {@link ErrorCode|UiRequiredError} when need user consent to get access token.
913
- * @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth or AAD server.
914
- * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
915
- *
916
- * @returns Access token from the credential.
917
- *
918
- */
919
- getAccessToken(): Promise<string>;
920
- }
804
+ /**
805
+ * Log level.
806
+ *
807
+ * @beta
808
+ */
809
+ export declare enum LogLevel {
810
+ /**
811
+ * Show verbose, information, warning and error message.
812
+ */
813
+ Verbose = 0,
814
+ /**
815
+ * Show information, warning and error message.
816
+ */
817
+ Info = 1,
818
+ /**
819
+ * Show warning and error message.
820
+ */
821
+ Warn = 2,
822
+ /**
823
+ * Show error message.
824
+ */
825
+ Error = 3
826
+ }
921
827
 
922
- /**
923
- * Provide utilities to send notification to varies targets (e.g., member, channel, incoming wehbook).
924
- *
925
- * @beta
926
- */
927
- export declare class NotificationBot {
928
- private readonly conversationReferenceStore;
929
- private readonly adapter;
930
- /**
931
- * constructor of the notification bot.
932
- *
933
- * @remarks
934
- * To ensure accuracy, it's recommended to initialize before handling any message.
935
- *
936
- * @param adapter - the bound `BotFrameworkAdapter`
937
- * @param options - initialize options
938
- *
939
- * @beta
940
- */
941
- constructor(adapter: BotFrameworkAdapter, options?: NotificationOptions_2);
942
- /**
943
- * Get all targets where the bot is installed.
944
- *
945
- * @remarks
946
- * The result is retrieving from the persisted storage.
947
- *
948
- * @returns - an array of {@link TeamsBotInstallation}.
949
- *
950
- * @beta
951
- */
952
- installations(): Promise<TeamsBotInstallation[]>;
953
- }
828
+ /**
829
+ * A {@link NotificationTarget} that represents a team member.
830
+ *
831
+ * @remarks
832
+ * It's recommended to get members from {@link TeamsBotInstallation.members()}.
833
+ *
834
+ * @beta
835
+ */
836
+ export declare class Member implements NotificationTarget {
837
+ /**
838
+ * The parent {@link TeamsBotInstallation} where this member is created from.
839
+ *
840
+ * @beta
841
+ */
842
+ readonly parent: TeamsBotInstallation;
843
+ /**
844
+ * Detailed member account information.
845
+ *
846
+ * @beta
847
+ */
848
+ readonly account: TeamsChannelAccount;
849
+ /**
850
+ * Notification target type. For member it's always "Person".
851
+ *
852
+ * @beta
853
+ */
854
+ readonly type: NotificationTargetType;
855
+ /**
856
+ * Constuctor.
857
+ *
858
+ * @remarks
859
+ * It's recommended to get members from {@link TeamsBotInstallation.members()}, instead of using this constructor.
860
+ *
861
+ * @param parent - The parent {@link TeamsBotInstallation} where this member is created from.
862
+ * @param account - Detailed member account information.
863
+ *
864
+ * @beta
865
+ */
866
+ constructor(parent: TeamsBotInstallation, account: TeamsChannelAccount);
867
+ /**
868
+ * Send a plain text message.
869
+ *
870
+ * @param text - the plain text message.
871
+ * @returns A `Promise` representing the asynchronous operation.
872
+ *
873
+ * @beta
874
+ */
875
+ sendMessage(text: string): Promise<void>;
876
+ /**
877
+ * Send an adaptive card message.
878
+ *
879
+ * @param card - the adaptive card raw JSON.
880
+ * @returns A `Promise` representing the asynchronous operation.
881
+ *
882
+ * @beta
883
+ */
884
+ sendAdaptiveCard(card: unknown): Promise<void>;
885
+ /**
886
+ * @internal
887
+ */
888
+ private newConversation;
889
+ }
954
890
 
955
- /**
956
- * Options to initialize {@link NotificationBot}.
957
- *
958
- * @beta
959
- */
960
- declare interface NotificationOptions_2 {
961
- /**
962
- * An optional storage to persist bot notification connections.
963
- *
964
- * @remarks
965
- * If `storage` is not provided, a default local file storage will be used,
966
- * which stores notification connections into:
967
- * - ".notification.localstore.json" if running locally
968
- * - "${process.env.TEMP}/.notification.localstore.json" if `process.env.RUNNING_ON_AZURE` is set to "1"
969
- *
970
- * It's recommended to use your own shared storage for production environment.
971
- *
972
- * @beta
973
- */
974
- storage?: NotificationTargetStorage;
975
- }
976
- export { NotificationOptions_2 as NotificationOptions }
891
+ /**
892
+ * Provides utility method to build bot message with cards that supported in Teams.
893
+ */
894
+ export declare class MessageBuilder {
895
+ /**
896
+ * Build a bot message activity attached with adaptive card.
897
+ *
898
+ * @param cardTemplate The adaptive card template.
899
+ * @param data card data used to render the template.
900
+ * @returns A bot message activity attached with an adaptive card.
901
+ *
902
+ * @example
903
+ * ```javascript
904
+ * const cardTemplate = {
905
+ * type: "AdaptiveCard",
906
+ * body: [
907
+ * {
908
+ * "type": "TextBlock",
909
+ * "text": "${title}",
910
+ * "size": "Large"
911
+ * },
912
+ * {
913
+ * "type": "TextBlock",
914
+ * "text": "${description}"
915
+ * }],
916
+ * $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
917
+ * version: "1.4"
918
+ * };
919
+ *
920
+ * type CardData = {
921
+ * title: string,
922
+ * description: string
923
+ * };
924
+ * const card = MessageBuilder.attachAdaptiveCard<CardData>(
925
+ * cardTemplate, {
926
+ * title: "sample card title",
927
+ * description: "sample card description"
928
+ * });
929
+ * ```
930
+ *
931
+ * @beta
932
+ */
933
+ static attachAdaptiveCard<TData>(cardTemplate: any, data: TData): Partial<Activity_2>;
934
+ /**
935
+ * Build a bot message activity attached with an adaptive card.
936
+ *
937
+ * @param card The adaptive card content.
938
+ * @returns A bot message activity attached with an adaptive card.
939
+ *
940
+ * @beta
941
+ */
942
+ static attachAdaptiveCardWithoutData(card: any): Partial<Activity_2>;
943
+ /**
944
+ * Build a bot message activity attached with an hero card.
945
+ *
946
+ * @param title The card title.
947
+ * @param images Optional. The array of images to include on the card.
948
+ * @param buttons Optional. The array of buttons to include on the card. Each `string` in the array
949
+ * is converted to an `imBack` button with a title and value set to the value of the string.
950
+ * @param other Optional. Any additional properties to include on the card.
951
+ *
952
+ * @returns A bot message activity attached with a hero card.
953
+ *
954
+ * @example
955
+ * ```javascript
956
+ * const message = MessageBuilder.attachHeroCard(
957
+ * 'sample title',
958
+ * ['https://example.com/sample.jpg'],
959
+ * ['action']
960
+ * );
961
+ * ```
962
+ *
963
+ * @beta
964
+ */
965
+ static attachHeroCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<HeroCard>): Partial<Activity_2>;
966
+ /**
967
+ * Returns an attachment for a sign-in card.
968
+ *
969
+ * @param title The title for the card's sign-in button.
970
+ * @param url The URL of the sign-in page to use.
971
+ * @param text Optional. Additional text to include on the card.
972
+ *
973
+ * @returns A bot message activity attached with a sign-in card.
974
+ *
975
+ * @remarks
976
+ * For channels that don't natively support sign-in cards, an alternative message is rendered.
977
+ *
978
+ * @beta
979
+ */
980
+ static attachSigninCard(title: string, url: string, text?: string): Partial<Activity_2>;
981
+ /**
982
+ * Build a bot message activity attached with an Office 365 connector card.
983
+ *
984
+ * @param card A description of the Office 365 connector card.
985
+ * @returns A bot message activity attached with an Office 365 connector card.
986
+ *
987
+ * @beta
988
+ */
989
+ static attachO365ConnectorCard(card: O365ConnectorCard): Partial<Activity_2>;
990
+ /**
991
+ * Build a message activity attached with a receipt card.
992
+ * @param card A description of the receipt card.
993
+ * @returns A message activity attached with a receipt card.
994
+ *
995
+ * @beta
996
+ */
997
+ static AttachReceiptCard(card: ReceiptCard): Partial<Activity_2>;
998
+ /**
999
+ *
1000
+ * @param title The card title.
1001
+ * @param images Optional. The array of images to include on the card.
1002
+ * @param buttons Optional. The array of buttons to include on the card. Each `string` in the array
1003
+ * is converted to an `imBack` button with a title and value set to the value of the string.
1004
+ * @param other Optional. Any additional properties to include on the card.
1005
+ * @returns A message activity attached with a thumbnail card
1006
+ *
1007
+ * @beta
1008
+ */
1009
+ static attachThumbnailCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<ThumbnailCard>): Partial<Activity_2>;
1010
+ /**
1011
+ * Add an attachement to a bot activity.
1012
+ * @param attachement The attachment object to attach.
1013
+ * @returns A message activity with an attachment.
1014
+ *
1015
+ * @beta
1016
+ */
1017
+ static attachContent(attachement: Attachment): Partial<Activity_2>;
1018
+ }
977
1019
 
978
- /**
979
- * Represent a notification target.
980
- *
981
- * @beta
982
- */
983
- export declare interface NotificationTarget {
984
- /**
985
- * The type of target, could be "Channel" or "Group" or "Person".
986
- *
987
- * @beta
988
- */
989
- readonly type?: NotificationTargetType;
990
- /**
991
- * Send a plain text message.
992
- *
993
- * @param text - the plain text message.
994
- *
995
- * @beta
996
- */
997
- sendMessage(text: string): Promise<void>;
998
- /**
999
- * Send an adaptive card message.
1000
- *
1001
- * @param card - the adaptive card raw JSON.
1002
- *
1003
- * @beta
1004
- */
1005
- sendAdaptiveCard(card: unknown): Promise<void>;
1006
- }
1020
+ /**
1021
+ * Microsoft Graph auth provider for Teams Framework
1022
+ *
1023
+ * @beta
1024
+ */
1025
+ export declare class MsGraphAuthProvider implements AuthenticationProvider {
1026
+ private teamsfx;
1027
+ private scopes;
1028
+ /**
1029
+ * Constructor of MsGraphAuthProvider.
1030
+ *
1031
+ * @param {TeamsFx} teamsfx - Used to provide configuration and auth.
1032
+ * @param {string | string[]} scopes - The list of scopes for which the token will have access.
1033
+ *
1034
+ * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1035
+ *
1036
+ * @returns An instance of MsGraphAuthProvider.
1037
+ *
1038
+ * @beta
1039
+ */
1040
+ constructor(teamsfx: TeamsFxConfiguration, scopes?: string | string[]);
1041
+ /**
1042
+ * Get access token for Microsoft Graph API requests.
1043
+ *
1044
+ * @throws {@link ErrorCode|InternalError} when get access token failed due to empty token or unknown other problems.
1045
+ * @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
1046
+ * @throws {@link ErrorCode|UiRequiredError} when need user consent to get access token.
1047
+ * @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth or AAD server.
1048
+ * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1049
+ *
1050
+ * @returns Access token from the credential.
1051
+ *
1052
+ */
1053
+ getAccessToken(): Promise<string>;
1054
+ }
1007
1055
 
1008
- /**
1009
- * Interface for a storage provider that stores and retrieves notification target references.
1010
- *
1011
- * @beta
1012
- */
1013
- export declare interface NotificationTargetStorage {
1014
- /**
1015
- * Read one notification target by its key.
1016
- *
1017
- * @param key - the key of a notification target.
1018
- *
1019
- * @returns - the notification target. Or undefined if not found.
1020
- *
1021
- * @beta
1022
- */
1023
- read(key: string): Promise<{
1024
- [key: string]: unknown;
1025
- } | undefined>;
1026
- /**
1027
- * List all stored notification targets.
1028
- *
1029
- * @returns - an array of notification target. Or an empty array if nothing is stored.
1030
- *
1031
- * @beta
1032
- */
1033
- list(): Promise<{
1034
- [key: string]: unknown;
1035
- }[]>;
1036
- /**
1037
- * Write one notification target by its key.
1038
- *
1039
- * @param key - the key of a notification target.
1040
- * @param object - the notification target.
1041
- *
1042
- * @beta
1043
- */
1044
- write(key: string, object: {
1045
- [key: string]: unknown;
1046
- }): Promise<void>;
1047
- /**
1048
- * Delete one notificaton target by its key.
1049
- *
1050
- * @param key - the key of a notification target.
1051
- *
1052
- * @beta
1053
- */
1054
- delete(key: string): Promise<void>;
1055
- }
1056
+ /**
1057
+ * Provide utilities to send notification to varies targets (e.g., member, group, channel).
1058
+ *
1059
+ * @beta
1060
+ */
1061
+ export declare class NotificationBot {
1062
+ private readonly conversationReferenceStore;
1063
+ private readonly adapter;
1064
+ /**
1065
+ * constructor of the notification bot.
1066
+ *
1067
+ * @remarks
1068
+ * To ensure accuracy, it's recommended to initialize before handling any message.
1069
+ *
1070
+ * @param adapter - the bound `BotFrameworkAdapter`
1071
+ * @param options - initialize options
1072
+ *
1073
+ * @beta
1074
+ */
1075
+ constructor(adapter: BotFrameworkAdapter, options?: NotificationOptions_2);
1076
+ /**
1077
+ * Get all targets where the bot is installed.
1078
+ *
1079
+ * @remarks
1080
+ * The result is retrieving from the persisted storage.
1081
+ *
1082
+ * @returns - an array of {@link TeamsBotInstallation}.
1083
+ *
1084
+ * @beta
1085
+ */
1086
+ installations(): Promise<TeamsBotInstallation[]>;
1087
+ }
1056
1088
 
1057
- /**
1058
- * The target type where the notification will be sent to.
1059
- *
1060
- * @remarks
1061
- * - "Channel" means to a team channel. (By default, notification to a team will be sent to its "General" channel.)
1062
- * - "Group" means to a group chat.
1063
- * - "Person" means to a personal chat.
1064
- *
1065
- * @beta
1066
- */
1067
- export declare type NotificationTargetType = "Channel" | "Group" | "Person";
1089
+ /**
1090
+ * Options to initialize {@link NotificationBot}.
1091
+ *
1092
+ * @beta
1093
+ */
1094
+ declare interface NotificationOptions_2 {
1095
+ /**
1096
+ * An optional storage to persist bot notification connections.
1097
+ *
1098
+ * @remarks
1099
+ * If `storage` is not provided, a default local file storage will be used,
1100
+ * which stores notification connections into:
1101
+ * - ".notification.localstore.json" if running locally
1102
+ * - "${process.env.TEMP}/.notification.localstore.json" if `process.env.RUNNING_ON_AZURE` is set to "1"
1103
+ *
1104
+ * It's recommended to use your own shared storage for production environment.
1105
+ *
1106
+ * @beta
1107
+ */
1108
+ storage?: NotificationTargetStorage;
1109
+ }
1110
+ export { NotificationOptions_2 as NotificationOptions }
1068
1111
 
1069
- /**
1070
- * Represent on-behalf-of flow to get user identity, and it is designed to be used in server side.
1071
- *
1072
- * @example
1073
- * ```typescript
1074
- * const credential = new OnBehalfOfUserCredential(ssoToken);
1075
- * ```
1076
- *
1077
- * @remarks
1078
- * Can only be used in server side.
1079
- *
1080
- * @beta
1081
- */
1082
- export declare class OnBehalfOfUserCredential implements TokenCredential {
1083
- private msalClient;
1084
- private ssoToken;
1085
- /**
1086
- * Constructor of OnBehalfOfUserCredential
1087
- *
1088
- * @remarks
1089
- * Only works in in server side.
1090
- *
1091
- * @param {string} ssoToken - User token provided by Teams SSO feature.
1092
- * @param {AuthenticationConfiguration} config - The authentication configuration. Use environment variables if not provided.
1093
- *
1094
- * @throws {@link ErrorCode|InvalidConfiguration} when client id, client secret, certificate content, authority host or tenant id is not found in config.
1095
- * @throws {@link ErrorCode|InternalError} when SSO token is not valid.
1096
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1097
- *
1098
- * @beta
1099
- */
1100
- constructor(ssoToken: string, config: AuthenticationConfiguration);
1101
- /**
1102
- * Get access token from credential.
1103
- *
1104
- * @example
1105
- * ```typescript
1106
- * await credential.getToken([]) // Get SSO token using empty string array
1107
- * await credential.getToken("") // Get SSO token using empty string
1108
- * await credential.getToken([".default"]) // Get Graph access token with default scope using string array
1109
- * await credential.getToken(".default") // Get Graph access token with default scope using string
1110
- * await credential.getToken(["User.Read"]) // Get Graph access token for single scope using string array
1111
- * await credential.getToken("User.Read") // Get Graph access token for single scope using string
1112
- * await credential.getToken(["User.Read", "Application.Read.All"]) // Get Graph access token for multiple scopes using string array
1113
- * await credential.getToken("User.Read Application.Read.All") // Get Graph access token for multiple scopes using space-separated string
1114
- * await credential.getToken("https://graph.microsoft.com/User.Read") // Get Graph access token with full resource URI
1115
- * await credential.getToken(["https://outlook.office.com/Mail.Read"]) // Get Outlook access token
1116
- * ```
1117
- *
1118
- * @param {string | string[]} scopes - The list of scopes for which the token will have access.
1119
- * @param {GetTokenOptions} options - The options used to configure any requests this TokenCredential implementation might make.
1120
- *
1121
- * @throws {@link ErrorCode|InternalError} when failed to acquire access token on behalf of user with unknown error.
1122
- * @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
1123
- * @throws {@link ErrorCode|UiRequiredError} when need user consent to get access token.
1124
- * @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth server.
1125
- * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1126
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1127
- *
1128
- * @returns Access token with expected scopes.
1129
- *
1130
- * @remarks
1131
- * If scopes is empty string or array, it returns SSO token.
1132
- * If scopes is non-empty, it returns access token for target scope.
1133
- *
1134
- * @beta
1135
- */
1136
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
1137
- /**
1138
- * Get basic user info from SSO token.
1139
- *
1140
- * @example
1141
- * ```typescript
1142
- * const currentUser = getUserInfo();
1143
- * ```
1144
- *
1145
- * @throws {@link ErrorCode|InternalError} when SSO token is not valid.
1146
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1147
- *
1148
- * @returns Basic user info with user displayName, objectId and preferredUserName.
1149
- *
1150
- * @beta
1151
- */
1152
- getUserInfo(): UserInfo;
1153
- private generateAuthServerError;
1154
- }
1112
+ /**
1113
+ * Represent a notification target.
1114
+ *
1115
+ * @beta
1116
+ */
1117
+ export declare interface NotificationTarget {
1118
+ /**
1119
+ * The type of target, could be "Channel" or "Group" or "Person".
1120
+ *
1121
+ * @beta
1122
+ */
1123
+ readonly type?: NotificationTargetType;
1124
+ /**
1125
+ * Send a plain text message.
1126
+ *
1127
+ * @param text - the plain text message.
1128
+ *
1129
+ * @beta
1130
+ */
1131
+ sendMessage(text: string): Promise<void>;
1132
+ /**
1133
+ * Send an adaptive card message.
1134
+ *
1135
+ * @param card - the adaptive card raw JSON.
1136
+ *
1137
+ * @beta
1138
+ */
1139
+ sendAdaptiveCard(card: unknown): Promise<void>;
1140
+ }
1155
1141
 
1156
- /**
1157
- * Send an adaptive card message to a notification target.
1158
- *
1159
- * @param target - the notification target.
1160
- * @param card - the adaptive card raw JSON.
1161
- * @returns A `Promise` representing the asynchronous operation.
1162
- *
1163
- * @beta
1164
- */
1165
- export declare function sendAdaptiveCard(target: NotificationTarget, card: unknown): Promise<void>;
1142
+ /**
1143
+ * Interface for a storage provider that stores and retrieves notification target references.
1144
+ *
1145
+ * @beta
1146
+ */
1147
+ export declare interface NotificationTargetStorage {
1148
+ /**
1149
+ * Read one notification target by its key.
1150
+ *
1151
+ * @param key - the key of a notification target.
1152
+ *
1153
+ * @returns - the notification target. Or undefined if not found.
1154
+ *
1155
+ * @beta
1156
+ */
1157
+ read(key: string): Promise<{
1158
+ [key: string]: unknown;
1159
+ } | undefined>;
1160
+ /**
1161
+ * List all stored notification targets.
1162
+ *
1163
+ * @returns - an array of notification target. Or an empty array if nothing is stored.
1164
+ *
1165
+ * @beta
1166
+ */
1167
+ list(): Promise<{
1168
+ [key: string]: unknown;
1169
+ }[]>;
1170
+ /**
1171
+ * Write one notification target by its key.
1172
+ *
1173
+ * @param key - the key of a notification target.
1174
+ * @param object - the notification target.
1175
+ *
1176
+ * @beta
1177
+ */
1178
+ write(key: string, object: {
1179
+ [key: string]: unknown;
1180
+ }): Promise<void>;
1181
+ /**
1182
+ * Delete one notificaton target by its key.
1183
+ *
1184
+ * @param key - the key of a notification target.
1185
+ *
1186
+ * @beta
1187
+ */
1188
+ delete(key: string): Promise<void>;
1189
+ }
1166
1190
 
1167
- /**
1168
- * Send a plain text message to a notification target.
1169
- *
1170
- * @param target - the notification target.
1171
- * @param text - the plain text message.
1172
- * @returns A `Promise` representing the asynchronous operation.
1173
- *
1174
- * @beta
1175
- */
1176
- export declare function sendMessage(target: NotificationTarget, text: string): Promise<void>;
1191
+ /**
1192
+ * The target type where the notification will be sent to.
1193
+ *
1194
+ * @remarks
1195
+ * - "Channel" means to a team channel. (By default, notification to a team will be sent to its "General" channel.)
1196
+ * - "Group" means to a group chat.
1197
+ * - "Person" means to a personal chat.
1198
+ *
1199
+ * @beta
1200
+ */
1201
+ export declare type NotificationTargetType = "Channel" | "Group" | "Person";
1177
1202
 
1178
- /**
1179
- * Set custom log function. Use the function if it's set. Priority is lower than setLogger.
1180
- *
1181
- * @param {LogFunction} logFunction - custom log function. If it's undefined, custom log function will be cleared.
1182
- *
1183
- * @example
1184
- * ```typescript
1185
- * setLogFunction((level: LogLevel, message: string) => {
1186
- * if (level === LogLevel.Error) {
1187
- * console.log(message);
1188
- * }
1189
- * });
1190
- * ```
1191
- *
1192
- * @beta
1193
- */
1194
- export declare function setLogFunction(logFunction?: LogFunction): void;
1203
+ /**
1204
+ * Represent on-behalf-of flow to get user identity, and it is designed to be used in server side.
1205
+ *
1206
+ * @example
1207
+ * ```typescript
1208
+ * const credential = new OnBehalfOfUserCredential(ssoToken);
1209
+ * ```
1210
+ *
1211
+ * @remarks
1212
+ * Can only be used in server side.
1213
+ *
1214
+ * @beta
1215
+ */
1216
+ export declare class OnBehalfOfUserCredential implements TokenCredential {
1217
+ private msalClient;
1218
+ private ssoToken;
1219
+ /**
1220
+ * Constructor of OnBehalfOfUserCredential
1221
+ *
1222
+ * @remarks
1223
+ * Only works in in server side.
1224
+ *
1225
+ * @param {string} ssoToken - User token provided by Teams SSO feature.
1226
+ * @param {AuthenticationConfiguration} config - The authentication configuration. Use environment variables if not provided.
1227
+ *
1228
+ * @throws {@link ErrorCode|InvalidConfiguration} when client id, client secret, certificate content, authority host or tenant id is not found in config.
1229
+ * @throws {@link ErrorCode|InternalError} when SSO token is not valid.
1230
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1231
+ *
1232
+ * @beta
1233
+ */
1234
+ constructor(ssoToken: string, config: AuthenticationConfiguration);
1235
+ /**
1236
+ * Get access token from credential.
1237
+ *
1238
+ * @example
1239
+ * ```typescript
1240
+ * await credential.getToken([]) // Get SSO token using empty string array
1241
+ * await credential.getToken("") // Get SSO token using empty string
1242
+ * await credential.getToken([".default"]) // Get Graph access token with default scope using string array
1243
+ * await credential.getToken(".default") // Get Graph access token with default scope using string
1244
+ * await credential.getToken(["User.Read"]) // Get Graph access token for single scope using string array
1245
+ * await credential.getToken("User.Read") // Get Graph access token for single scope using string
1246
+ * await credential.getToken(["User.Read", "Application.Read.All"]) // Get Graph access token for multiple scopes using string array
1247
+ * await credential.getToken("User.Read Application.Read.All") // Get Graph access token for multiple scopes using space-separated string
1248
+ * await credential.getToken("https://graph.microsoft.com/User.Read") // Get Graph access token with full resource URI
1249
+ * await credential.getToken(["https://outlook.office.com/Mail.Read"]) // Get Outlook access token
1250
+ * ```
1251
+ *
1252
+ * @param {string | string[]} scopes - The list of scopes for which the token will have access.
1253
+ * @param {GetTokenOptions} options - The options used to configure any requests this TokenCredential implementation might make.
1254
+ *
1255
+ * @throws {@link ErrorCode|InternalError} when failed to acquire access token on behalf of user with unknown error.
1256
+ * @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
1257
+ * @throws {@link ErrorCode|UiRequiredError} when need user consent to get access token.
1258
+ * @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth server.
1259
+ * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1260
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1261
+ *
1262
+ * @returns Access token with expected scopes.
1263
+ *
1264
+ * @remarks
1265
+ * If scopes is empty string or array, it returns SSO token.
1266
+ * If scopes is non-empty, it returns access token for target scope.
1267
+ *
1268
+ * @beta
1269
+ */
1270
+ getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
1271
+ /**
1272
+ * Get basic user info from SSO token.
1273
+ *
1274
+ * @example
1275
+ * ```typescript
1276
+ * const currentUser = getUserInfo();
1277
+ * ```
1278
+ *
1279
+ * @throws {@link ErrorCode|InternalError} when SSO token is not valid.
1280
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1281
+ *
1282
+ * @returns Basic user info with user displayName, objectId and preferredUserName.
1283
+ *
1284
+ * @beta
1285
+ */
1286
+ getUserInfo(): UserInfo;
1287
+ private generateAuthServerError;
1288
+ }
1195
1289
 
1196
- /**
1197
- * Set custom logger. Use the output functions if it's set. Priority is higher than setLogFunction.
1198
- *
1199
- * @param {Logger} logger - custom logger. If it's undefined, custom logger will be cleared.
1200
- *
1201
- * @example
1202
- * ```typescript
1203
- * setLogger({
1204
- * verbose: console.debug,
1205
- * info: console.info,
1206
- * warn: console.warn,
1207
- * error: console.error,
1208
- * });
1209
- * ```
1210
- *
1211
- * @beta
1212
- */
1213
- export declare function setLogger(logger?: Logger): void;
1290
+ /**
1291
+ * Send an adaptive card message to a notification target.
1292
+ *
1293
+ * @param target - the notification target.
1294
+ * @param card - the adaptive card raw JSON.
1295
+ * @returns A `Promise` representing the asynchronous operation.
1296
+ *
1297
+ * @beta
1298
+ */
1299
+ export declare function sendAdaptiveCard(target: NotificationTarget, card: unknown): Promise<void>;
1214
1300
 
1215
- /**
1216
- * Update log level helper.
1217
- *
1218
- * @param { LogLevel } level - log level in configuration
1219
- *
1220
- * @beta
1221
- */
1222
- export declare function setLogLevel(level: LogLevel): void;
1301
+ /**
1302
+ * Send a plain text message to a notification target.
1303
+ *
1304
+ * @param target - the notification target.
1305
+ * @param text - the plain text message.
1306
+ * @returns A `Promise` representing the asynchronous operation.
1307
+ *
1308
+ * @beta
1309
+ */
1310
+ export declare function sendMessage(target: NotificationTarget, text: string): Promise<void>;
1223
1311
 
1224
- /**
1225
- * A {@link NotificationTarget} that represents a bot installation. Teams Bot could be installed into
1226
- * - Personal chat
1227
- * - Group chat
1228
- * - Team (by default the `General` channel)
1229
- *
1230
- * @remarks
1231
- * It's recommended to get bot installations from {@link ConversationBot.installations()}.
1232
- *
1233
- * @beta
1234
- */
1235
- export declare class TeamsBotInstallation implements NotificationTarget {
1236
- /**
1237
- * The bound `BotFrameworkAdapter`.
1238
- *
1239
- * @beta
1240
- */
1241
- readonly adapter: BotFrameworkAdapter;
1242
- /**
1243
- * The bound `ConversationReference`.
1244
- *
1245
- * @beta
1246
- */
1247
- readonly conversationReference: Partial<ConversationReference>;
1248
- /**
1249
- * Notification target type.
1250
- *
1251
- * @remarks
1252
- * - "Channel" means bot is installed into a team and notification will be sent to its "General" channel.
1253
- * - "Group" means bot is installed into a group chat.
1254
- * - "Person" means bot is installed into a personal scope and notification will be sent to personal chat.
1255
- *
1256
- * @beta
1257
- */
1258
- readonly type?: NotificationTargetType;
1259
- /**
1260
- * Constructor
1261
- *
1262
- * @remarks
1263
- * It's recommended to get bot installations from {@link ConversationBot.installations()}, instead of using this constructor.
1264
- *
1265
- * @param adapter - the bound `BotFrameworkAdapter`.
1266
- * @param conversationReference - the bound `ConversationReference`.
1267
- *
1268
- * @beta
1269
- */
1270
- constructor(adapter: BotFrameworkAdapter, conversationReference: Partial<ConversationReference>);
1271
- /**
1272
- * Send a plain text message.
1273
- *
1274
- * @param text - the plain text message.
1275
- * @returns A `Promise` representing the asynchronous operation.
1276
- *
1277
- * @beta
1278
- */
1279
- sendMessage(text: string): Promise<void>;
1280
- /**
1281
- * Send an adaptive card message.
1282
- *
1283
- * @param card - the adaptive card raw JSON.
1284
- * @returns A `Promise` representing the asynchronous operation.
1285
- *
1286
- * @beta
1287
- */
1288
- sendAdaptiveCard(card: unknown): Promise<void>;
1289
- /**
1290
- * Get channels from this bot installation.
1291
- *
1292
- * @returns an array of channels if bot is installed into a team, otherwise returns an empty array.
1293
- *
1294
- * @beta
1295
- */
1296
- channels(): Promise<Channel[]>;
1297
- /**
1298
- * Get members from this bot installation.
1299
- *
1300
- * @returns an array of members from where the bot is installed.
1301
- *
1302
- * @beta
1303
- */
1304
- members(): Promise<Member[]>;
1305
- }
1312
+ /**
1313
+ * Set custom log function. Use the function if it's set. Priority is lower than setLogger.
1314
+ *
1315
+ * @param {LogFunction} logFunction - custom log function. If it's undefined, custom log function will be cleared.
1316
+ *
1317
+ * @example
1318
+ * ```typescript
1319
+ * setLogFunction((level: LogLevel, message: string) => {
1320
+ * if (level === LogLevel.Error) {
1321
+ * console.log(message);
1322
+ * }
1323
+ * });
1324
+ * ```
1325
+ *
1326
+ * @beta
1327
+ */
1328
+ export declare function setLogFunction(logFunction?: LogFunction): void;
1306
1329
 
1307
- /**
1308
- * Creates a new prompt that leverage Teams Single Sign On (SSO) support for bot to automatically sign in user and
1309
- * help receive oauth token, asks the user to consent if needed.
1310
- *
1311
- * @remarks
1312
- * The prompt will attempt to retrieve the users current token of the desired scopes and store it in
1313
- * the token store.
1314
- *
1315
- * User will be automatically signed in leveraging Teams support of Bot Single Sign On(SSO):
1316
- * https://docs.microsoft.com/en-us/microsoftteams/platform/bots/how-to/authentication/auth-aad-sso-bots
1317
- *
1318
- * @example
1319
- * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named
1320
- * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either
1321
- * `DialogContext.beginDialog()` or `DialogContext.prompt()`. The user will be prompted to sign in as
1322
- * needed and their access token will be passed as an argument to the callers next waterfall step:
1323
- *
1324
- * ```JavaScript
1325
- * const { ConversationState, MemoryStorage } = require('botbuilder');
1326
- * const { DialogSet, WaterfallDialog } = require('botbuilder-dialogs');
1327
- * const { TeamsBotSsoPrompt } = require('@microsoft/teamsfx');
1328
- *
1329
- * const convoState = new ConversationState(new MemoryStorage());
1330
- * const dialogState = convoState.createProperty('dialogState');
1331
- * const dialogs = new DialogSet(dialogState);
1332
- *
1333
- * dialogs.add(new TeamsBotSsoPrompt('TeamsBotSsoPrompt', {
1334
- * scopes: ["User.Read"],
1335
- * }));
1336
- *
1337
- * dialogs.add(new WaterfallDialog('taskNeedingLogin', [
1338
- * async (step) => {
1339
- * return await step.beginDialog('TeamsBotSsoPrompt');
1340
- * },
1341
- * async (step) => {
1342
- * const token = step.result;
1343
- * if (token) {
1344
- *
1345
- * // ... continue with task needing access token ...
1346
- *
1347
- * } else {
1348
- * await step.context.sendActivity(`Sorry... We couldn't log you in. Try again later.`);
1349
- * return await step.endDialog();
1350
- * }
1351
- * }
1352
- * ]));
1353
- * ```
1354
- *
1355
- * @beta
1356
- */
1357
- export declare class TeamsBotSsoPrompt extends Dialog {
1358
- private teamsfx;
1359
- private settings;
1360
- /**
1361
- * Constructor of TeamsBotSsoPrompt.
1362
- *
1363
- * @param {TeamsFx} teamsfx - Used to provide configuration and auth
1364
- * @param dialogId Unique ID of the dialog within its parent `DialogSet` or `ComponentDialog`.
1365
- * @param settings Settings used to configure the prompt.
1366
- *
1367
- * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1368
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1369
- *
1370
- * @beta
1371
- */
1372
- constructor(teamsfx: TeamsFx, dialogId: string, settings: TeamsBotSsoPromptSettings);
1373
- /**
1374
- * Called when a prompt dialog is pushed onto the dialog stack and is being activated.
1375
- * @remarks
1376
- * If the task is successful, the result indicates whether the prompt is still
1377
- * active after the turn has been processed by the prompt.
1378
- *
1379
- * @param dc The DialogContext for the current turn of the conversation.
1380
- *
1381
- * @throws {@link ErrorCode|InvalidParameter} when timeout property in teams bot sso prompt settings is not number or is not positive.
1382
- * @throws {@link ErrorCode|ChannelNotSupported} when bot channel is not MS Teams.
1383
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1384
- *
1385
- * @returns A `Promise` representing the asynchronous operation.
1386
- *
1387
- * @beta
1388
- */
1389
- beginDialog(dc: DialogContext): Promise<DialogTurnResult>;
1390
- /**
1391
- * Called when a prompt dialog is the active dialog and the user replied with a new activity.
1392
- *
1393
- * @remarks
1394
- * If the task is successful, the result indicates whether the dialog is still
1395
- * active after the turn has been processed by the dialog.
1396
- * The prompt generally continues to receive the user's replies until it accepts the
1397
- * user's reply as valid input for the prompt.
1398
- *
1399
- * @param dc The DialogContext for the current turn of the conversation.
1400
- *
1401
- * @returns A `Promise` representing the asynchronous operation.
1402
- *
1403
- * @throws {@link ErrorCode|ChannelNotSupported} when bot channel is not MS Teams.
1404
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1405
- *
1406
- * @beta
1407
- */
1408
- continueDialog(dc: DialogContext): Promise<DialogTurnResult>;
1409
- private loadAndValidateConfig;
1410
- /**
1411
- * Ensure bot is running in MS Teams since TeamsBotSsoPrompt is only supported in MS Teams channel.
1412
- * @param dc dialog context
1413
- * @throws {@link ErrorCode|ChannelNotSupported} if bot channel is not MS Teams
1414
- * @internal
1415
- */
1416
- private ensureMsTeamsChannel;
1417
- /**
1418
- * Send OAuthCard that tells Teams to obtain an authentication token for the bot application.
1419
- * For details see https://docs.microsoft.com/en-us/microsoftteams/platform/bots/how-to/authentication/auth-aad-sso-bots.
1420
- *
1421
- * @internal
1422
- */
1423
- private sendOAuthCardAsync;
1424
- /**
1425
- * Get sign in resource.
1426
- *
1427
- * @throws {@link ErrorCode|InvalidConfiguration} if client id, tenant id or initiate login endpoint is not found in config.
1428
- *
1429
- * @internal
1430
- */
1431
- private getSignInResource;
1432
- /**
1433
- * @internal
1434
- */
1435
- private recognizeToken;
1436
- /**
1437
- * @internal
1438
- */
1439
- private getTokenExchangeInvokeResponse;
1440
- /**
1441
- * @internal
1442
- */
1443
- private isTeamsVerificationInvoke;
1444
- /**
1445
- * @internal
1446
- */
1447
- private isTokenExchangeRequestInvoke;
1448
- /**
1449
- * @internal
1450
- */
1451
- private isTokenExchangeRequest;
1452
- }
1330
+ /**
1331
+ * Set custom logger. Use the output functions if it's set. Priority is higher than setLogFunction.
1332
+ *
1333
+ * @param {Logger} logger - custom logger. If it's undefined, custom logger will be cleared.
1334
+ *
1335
+ * @example
1336
+ * ```typescript
1337
+ * setLogger({
1338
+ * verbose: console.debug,
1339
+ * info: console.info,
1340
+ * warn: console.warn,
1341
+ * error: console.error,
1342
+ * });
1343
+ * ```
1344
+ *
1345
+ * @beta
1346
+ */
1347
+ export declare function setLogger(logger?: Logger): void;
1453
1348
 
1454
- /**
1455
- * Settings used to configure an TeamsBotSsoPrompt instance.
1456
- *
1457
- * @beta
1458
- */
1459
- export declare interface TeamsBotSsoPromptSettings {
1460
- /**
1461
- * The array of strings that declare the desired permissions and the resources requested.
1462
- */
1463
- scopes: string[];
1464
- /**
1465
- * (Optional) number of milliseconds the prompt will wait for the user to authenticate.
1466
- * Defaults to a value `900,000` (15 minutes.)
1467
- */
1468
- timeout?: number;
1469
- /**
1470
- * (Optional) value indicating whether the TeamsBotSsoPrompt should end upon receiving an
1471
- * invalid message. Generally the TeamsBotSsoPrompt will end the auth flow when receives user
1472
- * message not related to the auth flow. Setting the flag to false ignores the user's message instead.
1473
- * Defaults to value `true`
1474
- */
1475
- endOnInvalidMessage?: boolean;
1476
- }
1349
+ /**
1350
+ * Update log level helper.
1351
+ *
1352
+ * @param { LogLevel } level - log level in configuration
1353
+ *
1354
+ * @beta
1355
+ */
1356
+ export declare function setLogLevel(level: LogLevel): void;
1477
1357
 
1478
- /**
1479
- * Token response provided by Teams Bot SSO prompt
1480
- *
1481
- * @beta
1482
- */
1483
- export declare interface TeamsBotSsoPromptTokenResponse extends TokenResponse {
1484
- /**
1485
- * SSO token for user
1486
- */
1487
- ssoToken: string;
1488
- /**
1489
- * Expire time of SSO token
1490
- */
1491
- ssoTokenExpiration: string;
1492
- }
1358
+ /**
1359
+ * A {@link NotificationTarget} that represents a bot installation. Teams Bot could be installed into
1360
+ * - Personal chat
1361
+ * - Group chat
1362
+ * - Team (by default the `General` channel)
1363
+ *
1364
+ * @remarks
1365
+ * It's recommended to get bot installations from {@link ConversationBot.installations()}.
1366
+ *
1367
+ * @beta
1368
+ */
1369
+ export declare class TeamsBotInstallation implements NotificationTarget {
1370
+ /**
1371
+ * The bound `BotFrameworkAdapter`.
1372
+ *
1373
+ * @beta
1374
+ */
1375
+ readonly adapter: BotFrameworkAdapter;
1376
+ /**
1377
+ * The bound `ConversationReference`.
1378
+ *
1379
+ * @beta
1380
+ */
1381
+ readonly conversationReference: Partial<ConversationReference>;
1382
+ /**
1383
+ * Notification target type.
1384
+ *
1385
+ * @remarks
1386
+ * - "Channel" means bot is installed into a team and notification will be sent to its "General" channel.
1387
+ * - "Group" means bot is installed into a group chat.
1388
+ * - "Person" means bot is installed into a personal scope and notification will be sent to personal chat.
1389
+ *
1390
+ * @beta
1391
+ */
1392
+ readonly type?: NotificationTargetType;
1393
+ /**
1394
+ * Constructor
1395
+ *
1396
+ * @remarks
1397
+ * It's recommended to get bot installations from {@link ConversationBot.installations()}, instead of using this constructor.
1398
+ *
1399
+ * @param adapter - the bound `BotFrameworkAdapter`.
1400
+ * @param conversationReference - the bound `ConversationReference`.
1401
+ *
1402
+ * @beta
1403
+ */
1404
+ constructor(adapter: BotFrameworkAdapter, conversationReference: Partial<ConversationReference>);
1405
+ /**
1406
+ * Send a plain text message.
1407
+ *
1408
+ * @param text - the plain text message.
1409
+ * @returns A `Promise` representing the asynchronous operation.
1410
+ *
1411
+ * @beta
1412
+ */
1413
+ sendMessage(text: string): Promise<void>;
1414
+ /**
1415
+ * Send an adaptive card message.
1416
+ *
1417
+ * @param card - the adaptive card raw JSON.
1418
+ * @returns A `Promise` representing the asynchronous operation.
1419
+ *
1420
+ * @beta
1421
+ */
1422
+ sendAdaptiveCard(card: unknown): Promise<void>;
1423
+ /**
1424
+ * Get channels from this bot installation.
1425
+ *
1426
+ * @returns an array of channels if bot is installed into a team, otherwise returns an empty array.
1427
+ *
1428
+ * @beta
1429
+ */
1430
+ channels(): Promise<Channel[]>;
1431
+ /**
1432
+ * Get members from this bot installation.
1433
+ *
1434
+ * @returns an array of members from where the bot is installed.
1435
+ *
1436
+ * @beta
1437
+ */
1438
+ members(): Promise<Member[]>;
1439
+ }
1493
1440
 
1494
- /**
1495
- * A class providing credential and configuration.
1496
- * @beta
1497
- */
1498
- export declare class TeamsFx implements TeamsFxConfiguration {
1499
- private configuration;
1500
- private oboUserCredential?;
1501
- private appCredential?;
1502
- private identityType;
1503
- /**
1504
- * Constructor of TeamsFx
1505
- *
1506
- * @param {IdentityType} identityType - Choose user or app identity
1507
- * @param customConfig - key/value pairs of customized configuration that overrides default ones.
1508
- *
1509
- * @throws {@link ErrorCode|IdentityTypeNotSupported} when setting app identity in browser.
1510
- *
1511
- * @beta
1512
- */
1513
- constructor(identityType?: IdentityType, customConfig?: Record<string, string>);
1514
- /**
1515
- * Identity type set by user.
1516
- *
1517
- * @returns identity type.
1518
- * @beta
1519
- */
1520
- getIdentityType(): IdentityType;
1521
- /**
1522
- * Credential instance according to identity type choice.
1523
- *
1524
- * @remarks If user identity is chose, will return {@link TeamsUserCredential}
1525
- * in browser environment and {@link OnBehalfOfUserCredential} in NodeJS. If app
1526
- * identity is chose, will return {@link AppCredential}.
1527
- *
1528
- * @returns instance implements TokenCredential interface.
1529
- * @beta
1530
- */
1531
- getCredential(): TokenCredential;
1532
- /**
1533
- * Get user information.
1534
- * @returns UserInfo object.
1535
- * @beta
1536
- */
1537
- getUserInfo(): Promise<UserInfo>;
1538
- /**
1539
- * Popup login page to get user's access token with specific scopes.
1540
- *
1541
- * @remarks
1542
- * Only works in Teams client APP. User will be redirected to the authorization page to login and consent.
1543
- *
1544
- * @example
1545
- * ```typescript
1546
- * await teamsfx.login(["https://graph.microsoft.com/User.Read"]); // single scope using string array
1547
- * await teamsfx.login("https://graph.microsoft.com/User.Read"); // single scopes using string
1548
- * await teamsfx.login(["https://graph.microsoft.com/User.Read", "Calendars.Read"]); // multiple scopes using string array
1549
- * await teamsfx.login("https://graph.microsoft.com/User.Read Calendars.Read"); // multiple scopes using string
1550
- * ```
1551
- * @param scopes - The list of scopes for which the token will have access, before that, we will request user to consent.
1552
- *
1553
- * @throws {@link ErrorCode|InternalError} when failed to login with unknown error.
1554
- * @throws {@link ErrorCode|ConsentFailed} when user canceled or failed to consent.
1555
- * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1556
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
1557
- *
1558
- * @beta
1559
- */
1560
- login(scopes: string | string[]): Promise<void>;
1561
- /**
1562
- * Set SSO token when using user identity in NodeJS.
1563
- * @param {string} ssoToken - used for on behalf of user flow.
1564
- * @returns self instance.
1565
- * @beta
1566
- */
1567
- setSsoToken(ssoToken: string): TeamsFx;
1568
- /**
1569
- * Usually used by service plugins to retrieve specific config
1570
- * @param {string} key - configuration key.
1571
- * @returns value in configuration.
1572
- * @beta
1573
- */
1574
- getConfig(key: string): string;
1575
- /**
1576
- * Check the value of specific key.
1577
- * @param {string} key - configuration key.
1578
- * @returns true if corresponding value is not empty string.
1579
- * @beta
1580
- */
1581
- hasConfig(key: string): boolean;
1582
- /**
1583
- * Get all configurations.
1584
- * @returns key value mappings.
1585
- * @beta
1586
- */
1587
- getConfigs(): Record<string, string>;
1588
- /**
1589
- * Load configuration from environment variables.
1590
- */
1591
- private loadFromEnv;
1592
- }
1441
+ /**
1442
+ * Creates a new prompt that leverage Teams Single Sign On (SSO) support for bot to automatically sign in user and
1443
+ * help receive oauth token, asks the user to consent if needed.
1444
+ *
1445
+ * @remarks
1446
+ * The prompt will attempt to retrieve the users current token of the desired scopes and store it in
1447
+ * the token store.
1448
+ *
1449
+ * User will be automatically signed in leveraging Teams support of Bot Single Sign On(SSO):
1450
+ * https://docs.microsoft.com/en-us/microsoftteams/platform/bots/how-to/authentication/auth-aad-sso-bots
1451
+ *
1452
+ * @example
1453
+ * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named
1454
+ * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either
1455
+ * `DialogContext.beginDialog()` or `DialogContext.prompt()`. The user will be prompted to sign in as
1456
+ * needed and their access token will be passed as an argument to the callers next waterfall step:
1457
+ *
1458
+ * ```JavaScript
1459
+ * const { ConversationState, MemoryStorage } = require('botbuilder');
1460
+ * const { DialogSet, WaterfallDialog } = require('botbuilder-dialogs');
1461
+ * const { TeamsBotSsoPrompt } = require('@microsoft/teamsfx');
1462
+ *
1463
+ * const convoState = new ConversationState(new MemoryStorage());
1464
+ * const dialogState = convoState.createProperty('dialogState');
1465
+ * const dialogs = new DialogSet(dialogState);
1466
+ *
1467
+ * dialogs.add(new TeamsBotSsoPrompt('TeamsBotSsoPrompt', {
1468
+ * scopes: ["User.Read"],
1469
+ * }));
1470
+ *
1471
+ * dialogs.add(new WaterfallDialog('taskNeedingLogin', [
1472
+ * async (step) => {
1473
+ * return await step.beginDialog('TeamsBotSsoPrompt');
1474
+ * },
1475
+ * async (step) => {
1476
+ * const token = step.result;
1477
+ * if (token) {
1478
+ *
1479
+ * // ... continue with task needing access token ...
1480
+ *
1481
+ * } else {
1482
+ * await step.context.sendActivity(`Sorry... We couldn't log you in. Try again later.`);
1483
+ * return await step.endDialog();
1484
+ * }
1485
+ * }
1486
+ * ]));
1487
+ * ```
1488
+ *
1489
+ * @beta
1490
+ */
1491
+ export declare class TeamsBotSsoPrompt extends Dialog {
1492
+ private teamsfx;
1493
+ private settings;
1494
+ /**
1495
+ * Constructor of TeamsBotSsoPrompt.
1496
+ *
1497
+ * @param {TeamsFx} teamsfx - Used to provide configuration and auth
1498
+ * @param dialogId Unique ID of the dialog within its parent `DialogSet` or `ComponentDialog`.
1499
+ * @param settings Settings used to configure the prompt.
1500
+ *
1501
+ * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1502
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1503
+ *
1504
+ * @beta
1505
+ */
1506
+ constructor(teamsfx: TeamsFx, dialogId: string, settings: TeamsBotSsoPromptSettings);
1507
+ /**
1508
+ * Called when a prompt dialog is pushed onto the dialog stack and is being activated.
1509
+ * @remarks
1510
+ * If the task is successful, the result indicates whether the prompt is still
1511
+ * active after the turn has been processed by the prompt.
1512
+ *
1513
+ * @param dc The DialogContext for the current turn of the conversation.
1514
+ *
1515
+ * @throws {@link ErrorCode|InvalidParameter} when timeout property in teams bot sso prompt settings is not number or is not positive.
1516
+ * @throws {@link ErrorCode|ChannelNotSupported} when bot channel is not MS Teams.
1517
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1518
+ *
1519
+ * @returns A `Promise` representing the asynchronous operation.
1520
+ *
1521
+ * @beta
1522
+ */
1523
+ beginDialog(dc: DialogContext): Promise<DialogTurnResult>;
1524
+ /**
1525
+ * Called when a prompt dialog is the active dialog and the user replied with a new activity.
1526
+ *
1527
+ * @remarks
1528
+ * If the task is successful, the result indicates whether the dialog is still
1529
+ * active after the turn has been processed by the dialog.
1530
+ * The prompt generally continues to receive the user's replies until it accepts the
1531
+ * user's reply as valid input for the prompt.
1532
+ *
1533
+ * @param dc The DialogContext for the current turn of the conversation.
1534
+ *
1535
+ * @returns A `Promise` representing the asynchronous operation.
1536
+ *
1537
+ * @throws {@link ErrorCode|ChannelNotSupported} when bot channel is not MS Teams.
1538
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1539
+ *
1540
+ * @beta
1541
+ */
1542
+ continueDialog(dc: DialogContext): Promise<DialogTurnResult>;
1543
+ private loadAndValidateConfig;
1544
+ /**
1545
+ * Ensure bot is running in MS Teams since TeamsBotSsoPrompt is only supported in MS Teams channel.
1546
+ * @param dc dialog context
1547
+ * @throws {@link ErrorCode|ChannelNotSupported} if bot channel is not MS Teams
1548
+ * @internal
1549
+ */
1550
+ private ensureMsTeamsChannel;
1551
+ /**
1552
+ * Send OAuthCard that tells Teams to obtain an authentication token for the bot application.
1553
+ * For details see https://docs.microsoft.com/en-us/microsoftteams/platform/bots/how-to/authentication/auth-aad-sso-bots.
1554
+ *
1555
+ * @internal
1556
+ */
1557
+ private sendOAuthCardAsync;
1558
+ /**
1559
+ * Get sign in resource.
1560
+ *
1561
+ * @throws {@link ErrorCode|InvalidConfiguration} if client id, tenant id or initiate login endpoint is not found in config.
1562
+ *
1563
+ * @internal
1564
+ */
1565
+ private getSignInResource;
1566
+ /**
1567
+ * @internal
1568
+ */
1569
+ private recognizeToken;
1570
+ /**
1571
+ * @internal
1572
+ */
1573
+ private getTokenExchangeInvokeResponse;
1574
+ /**
1575
+ * @internal
1576
+ */
1577
+ private isTeamsVerificationInvoke;
1578
+ /**
1579
+ * @internal
1580
+ */
1581
+ private isTokenExchangeRequestInvoke;
1582
+ /**
1583
+ * @internal
1584
+ */
1585
+ private isTokenExchangeRequest;
1586
+ }
1593
1587
 
1594
- /**
1595
- * Interface for a command handler that can process command to a TeamsFx bot and return a response.
1596
- *
1597
- * @beta
1598
- */
1599
- export declare interface TeamsFxBotCommandHandler {
1600
- /**
1601
- * The string or regular expression patterns that can trigger this handler.
1602
- */
1603
- triggerPatterns: TriggerPatterns;
1604
- /**
1605
- * Handles a bot command received activity.
1606
- *
1607
- * @param context The bot context.
1608
- * @param message The command message the user types from Teams.
1609
- * @returns A `Promise` representing an activity or text to send as the command response.
1610
- */
1611
- handleCommandReceived(context: TurnContext, message: CommandMessage): Promise<string | Partial<Activity>>;
1612
- }
1588
+ /**
1589
+ * Settings used to configure an TeamsBotSsoPrompt instance.
1590
+ *
1591
+ * @beta
1592
+ */
1593
+ export declare interface TeamsBotSsoPromptSettings {
1594
+ /**
1595
+ * The array of strings that declare the desired permissions and the resources requested.
1596
+ */
1597
+ scopes: string[];
1598
+ /**
1599
+ * (Optional) number of milliseconds the prompt will wait for the user to authenticate.
1600
+ * Defaults to a value `900,000` (15 minutes.)
1601
+ */
1602
+ timeout?: number;
1603
+ /**
1604
+ * (Optional) value indicating whether the TeamsBotSsoPrompt should end upon receiving an
1605
+ * invalid message. Generally the TeamsBotSsoPrompt will end the auth flow when receives user
1606
+ * message not related to the auth flow. Setting the flag to false ignores the user's message instead.
1607
+ * Defaults to value `true`
1608
+ */
1609
+ endOnInvalidMessage?: boolean;
1610
+ }
1613
1611
 
1614
- /**
1615
- * TeamsFx interface that provides credential and configuration.
1616
- * @beta
1617
- */
1618
- declare interface TeamsFxConfiguration {
1619
- /**
1620
- * Identity type set by user.
1621
- *
1622
- * @returns identity type.
1623
- * @beta
1624
- */
1625
- getIdentityType(): IdentityType;
1626
- /**
1627
- * Credential instance according to identity type choice.
1628
- *
1629
- * @remarks If user identity is chose, will return {@link TeamsUserCredential}
1630
- * in browser environment and {@link OnBehalfOfUserCredential} in NodeJS. If app
1631
- * identity is chose, will return {@link AppCredential}.
1632
- *
1633
- * @returns instance implements TokenCredential interface.
1634
- * @beta
1635
- */
1636
- getCredential(): TokenCredential;
1637
- /**
1638
- * Get user information.
1639
- * @returns UserInfo object.
1640
- * @beta
1641
- */
1642
- getUserInfo(): Promise<UserInfo>;
1643
- /**
1644
- * Popup login page to get user's access token with specific scopes.
1645
- *
1646
- * @remarks
1647
- * Only works in Teams client APP. User will be redirected to the authorization page to login and consent.
1648
- *
1649
- * @example
1650
- * ```typescript
1651
- * await teamsfx.login(["https://graph.microsoft.com/User.Read"]); // single scope using string array
1652
- * await teamsfx.login("https://graph.microsoft.com/User.Read"); // single scopes using string
1653
- * await teamsfx.login(["https://graph.microsoft.com/User.Read", "Calendars.Read"]); // multiple scopes using string array
1654
- * await teamsfx.login("https://graph.microsoft.com/User.Read Calendars.Read"); // multiple scopes using string
1655
- * ```
1656
- * @param scopes - The list of scopes for which the token will have access, before that, we will request user to consent.
1657
- *
1658
- * @throws {@link ErrorCode|InternalError} when failed to login with unknown error.
1659
- * @throws {@link ErrorCode|ConsentFailed} when user canceled or failed to consent.
1660
- * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1661
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
1662
- *
1663
- * @beta
1664
- */
1665
- login(scopes: string | string[]): Promise<void>;
1666
- /**
1667
- * Set SSO token when using user identity in NodeJS.
1668
- * @param {string} ssoToken - used for on behalf of user flow.
1669
- * @returns self instance.
1670
- * @beta
1671
- */
1672
- setSsoToken(ssoToken: string): TeamsFxConfiguration;
1673
- /**
1674
- * Usually used by service plugins to retrieve specific config
1675
- * @param {string} key - configuration key.
1676
- * @returns value in configuration.
1677
- * @beta
1678
- */
1679
- getConfig(key: string): string;
1680
- /**
1681
- * Check the value of specific key.
1682
- * @param {string} key - configuration key.
1683
- * @returns true if corresponding value is not empty string.
1684
- * @beta
1685
- */
1686
- hasConfig(key: string): boolean;
1687
- /**
1688
- * Get all configurations.
1689
- * @returns key value mappings.
1690
- * @beta
1691
- */
1692
- getConfigs(): Record<string, string>;
1693
- }
1612
+ /**
1613
+ * Token response provided by Teams Bot SSO prompt
1614
+ *
1615
+ * @beta
1616
+ */
1617
+ export declare interface TeamsBotSsoPromptTokenResponse extends TokenResponse {
1618
+ /**
1619
+ * SSO token for user
1620
+ */
1621
+ ssoToken: string;
1622
+ /**
1623
+ * Expire time of SSO token
1624
+ */
1625
+ ssoTokenExpiration: string;
1626
+ }
1694
1627
 
1695
- /**
1696
- * Represent Teams current user's identity, and it is used within Teams client applications.
1697
- *
1698
- * @remarks
1699
- * Can only be used within Teams.
1700
- *
1701
- * @beta
1702
- */
1703
- export declare class TeamsUserCredential implements TokenCredential {
1704
- /**
1705
- * Constructor of TeamsUserCredential.
1706
- * @remarks
1707
- * Can only be used within Teams.
1708
- * @beta
1709
- */
1710
- constructor(authConfig: AuthenticationConfiguration);
1711
- /**
1712
- * Popup login page to get user's access token with specific scopes.
1713
- * @remarks
1714
- * Can only be used within Teams.
1715
- * @beta
1716
- */
1717
- login(scopes: string | string[]): Promise<void>;
1718
- /**
1719
- * Get access token from credential.
1720
- * @remarks
1721
- * Can only be used within Teams.
1722
- * @beta
1723
- */
1724
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
1725
- /**
1726
- * Get basic user info from SSO token
1727
- * @remarks
1728
- * Can only be used within Teams.
1729
- * @beta
1730
- */
1731
- getUserInfo(): Promise<UserInfo>;
1732
- }
1628
+ /**
1629
+ * A class providing credential and configuration.
1630
+ * @beta
1631
+ */
1632
+ export declare class TeamsFx implements TeamsFxConfiguration {
1633
+ private configuration;
1634
+ private oboUserCredential?;
1635
+ private appCredential?;
1636
+ private identityType;
1637
+ /**
1638
+ * Constructor of TeamsFx
1639
+ *
1640
+ * @param {IdentityType} identityType - Choose user or app identity
1641
+ * @param customConfig - key/value pairs of customized configuration that overrides default ones.
1642
+ *
1643
+ * @throws {@link ErrorCode|IdentityTypeNotSupported} when setting app identity in browser.
1644
+ *
1645
+ * @beta
1646
+ */
1647
+ constructor(identityType?: IdentityType, customConfig?: Record<string, string>);
1648
+ /**
1649
+ * Identity type set by user.
1650
+ *
1651
+ * @returns identity type.
1652
+ * @beta
1653
+ */
1654
+ getIdentityType(): IdentityType;
1655
+ /**
1656
+ * Credential instance according to identity type choice.
1657
+ *
1658
+ * @remarks If user identity is chose, will return {@link TeamsUserCredential}
1659
+ * in browser environment and {@link OnBehalfOfUserCredential} in NodeJS. If app
1660
+ * identity is chose, will return {@link AppCredential}.
1661
+ *
1662
+ * @returns instance implements TokenCredential interface.
1663
+ * @beta
1664
+ */
1665
+ getCredential(): TokenCredential;
1666
+ /**
1667
+ * Get user information.
1668
+ * @returns UserInfo object.
1669
+ * @beta
1670
+ */
1671
+ getUserInfo(): Promise<UserInfo>;
1672
+ /**
1673
+ * Popup login page to get user's access token with specific scopes.
1674
+ *
1675
+ * @remarks
1676
+ * Only works in Teams client APP. User will be redirected to the authorization page to login and consent.
1677
+ *
1678
+ * @example
1679
+ * ```typescript
1680
+ * await teamsfx.login(["https://graph.microsoft.com/User.Read"]); // single scope using string array
1681
+ * await teamsfx.login("https://graph.microsoft.com/User.Read"); // single scopes using string
1682
+ * await teamsfx.login(["https://graph.microsoft.com/User.Read", "Calendars.Read"]); // multiple scopes using string array
1683
+ * await teamsfx.login("https://graph.microsoft.com/User.Read Calendars.Read"); // multiple scopes using string
1684
+ * ```
1685
+ * @param scopes - The list of scopes for which the token will have access, before that, we will request user to consent.
1686
+ *
1687
+ * @throws {@link ErrorCode|InternalError} when failed to login with unknown error.
1688
+ * @throws {@link ErrorCode|ConsentFailed} when user canceled or failed to consent.
1689
+ * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1690
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
1691
+ *
1692
+ * @beta
1693
+ */
1694
+ login(scopes: string | string[]): Promise<void>;
1695
+ /**
1696
+ * Set SSO token when using user identity in NodeJS.
1697
+ * @param {string} ssoToken - used for on behalf of user flow.
1698
+ * @returns self instance.
1699
+ * @beta
1700
+ */
1701
+ setSsoToken(ssoToken: string): TeamsFx;
1702
+ /**
1703
+ * Usually used by service plugins to retrieve specific config
1704
+ * @param {string} key - configuration key.
1705
+ * @returns value in configuration.
1706
+ * @beta
1707
+ */
1708
+ getConfig(key: string): string;
1709
+ /**
1710
+ * Check the value of specific key.
1711
+ * @param {string} key - configuration key.
1712
+ * @returns true if corresponding value is not empty string.
1713
+ * @beta
1714
+ */
1715
+ hasConfig(key: string): boolean;
1716
+ /**
1717
+ * Get all configurations.
1718
+ * @returns key value mappings.
1719
+ * @beta
1720
+ */
1721
+ getConfigs(): Record<string, string>;
1722
+ /**
1723
+ * Load configuration from environment variables.
1724
+ */
1725
+ private loadFromEnv;
1726
+ }
1733
1727
 
1734
- /**
1735
- * The trigger pattern used to trigger a {@link TeamsFxBotCommandHandler} instance.
1736
- */
1737
- export declare type TriggerPatterns = string | RegExp | (string | RegExp)[];
1728
+ /**
1729
+ * Interface for a command handler that can process command to a TeamsFx bot and return a response.
1730
+ *
1731
+ * @beta
1732
+ */
1733
+ export declare interface TeamsFxBotCommandHandler {
1734
+ /**
1735
+ * The string or regular expression patterns that can trigger this handler.
1736
+ */
1737
+ triggerPatterns: TriggerPatterns;
1738
+ /**
1739
+ * Handles a bot command received activity.
1740
+ *
1741
+ * @param context The bot context.
1742
+ * @param message The command message the user types from Teams.
1743
+ * @returns A `Promise` representing an activity or text to send as the command response.
1744
+ */
1745
+ handleCommandReceived(context: TurnContext, message: CommandMessage): Promise<string | Partial<Activity>>;
1746
+ }
1738
1747
 
1739
- /**
1740
- * UserInfo with user displayName, objectId and preferredUserName.
1741
- *
1742
- * @beta
1743
- */
1744
- export declare interface UserInfo {
1745
- /**
1746
- * User Display Name.
1747
- *
1748
- * @readonly
1749
- */
1750
- displayName: string;
1751
- /**
1752
- * User unique reference within the Azure Active Directory domain.
1753
- *
1754
- * @readonly
1755
- */
1756
- objectId: string;
1757
- /**
1758
- * Usually be the email address.
1759
- *
1760
- * @readonly
1761
- */
1762
- preferredUserName: string;
1763
- }
1748
+ /**
1749
+ * TeamsFx interface that provides credential and configuration.
1750
+ * @beta
1751
+ */
1752
+ declare interface TeamsFxConfiguration {
1753
+ /**
1754
+ * Identity type set by user.
1755
+ *
1756
+ * @returns identity type.
1757
+ * @beta
1758
+ */
1759
+ getIdentityType(): IdentityType;
1760
+ /**
1761
+ * Credential instance according to identity type choice.
1762
+ *
1763
+ * @remarks If user identity is chose, will return {@link TeamsUserCredential}
1764
+ * in browser environment and {@link OnBehalfOfUserCredential} in NodeJS. If app
1765
+ * identity is chose, will return {@link AppCredential}.
1766
+ *
1767
+ * @returns instance implements TokenCredential interface.
1768
+ * @beta
1769
+ */
1770
+ getCredential(): TokenCredential;
1771
+ /**
1772
+ * Get user information.
1773
+ * @returns UserInfo object.
1774
+ * @beta
1775
+ */
1776
+ getUserInfo(): Promise<UserInfo>;
1777
+ /**
1778
+ * Popup login page to get user's access token with specific scopes.
1779
+ *
1780
+ * @remarks
1781
+ * Only works in Teams client APP. User will be redirected to the authorization page to login and consent.
1782
+ *
1783
+ * @example
1784
+ * ```typescript
1785
+ * await teamsfx.login(["https://graph.microsoft.com/User.Read"]); // single scope using string array
1786
+ * await teamsfx.login("https://graph.microsoft.com/User.Read"); // single scopes using string
1787
+ * await teamsfx.login(["https://graph.microsoft.com/User.Read", "Calendars.Read"]); // multiple scopes using string array
1788
+ * await teamsfx.login("https://graph.microsoft.com/User.Read Calendars.Read"); // multiple scopes using string
1789
+ * ```
1790
+ * @param scopes - The list of scopes for which the token will have access, before that, we will request user to consent.
1791
+ *
1792
+ * @throws {@link ErrorCode|InternalError} when failed to login with unknown error.
1793
+ * @throws {@link ErrorCode|ConsentFailed} when user canceled or failed to consent.
1794
+ * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1795
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
1796
+ *
1797
+ * @beta
1798
+ */
1799
+ login(scopes: string | string[]): Promise<void>;
1800
+ /**
1801
+ * Set SSO token when using user identity in NodeJS.
1802
+ * @param {string} ssoToken - used for on behalf of user flow.
1803
+ * @returns self instance.
1804
+ * @beta
1805
+ */
1806
+ setSsoToken(ssoToken: string): TeamsFxConfiguration;
1807
+ /**
1808
+ * Usually used by service plugins to retrieve specific config
1809
+ * @param {string} key - configuration key.
1810
+ * @returns value in configuration.
1811
+ * @beta
1812
+ */
1813
+ getConfig(key: string): string;
1814
+ /**
1815
+ * Check the value of specific key.
1816
+ * @param {string} key - configuration key.
1817
+ * @returns true if corresponding value is not empty string.
1818
+ * @beta
1819
+ */
1820
+ hasConfig(key: string): boolean;
1821
+ /**
1822
+ * Get all configurations.
1823
+ * @returns key value mappings.
1824
+ * @beta
1825
+ */
1826
+ getConfigs(): Record<string, string>;
1827
+ }
1828
+
1829
+ /**
1830
+ * Represent Teams current user's identity, and it is used within Teams client applications.
1831
+ *
1832
+ * @remarks
1833
+ * Can only be used within Teams.
1834
+ *
1835
+ * @beta
1836
+ */
1837
+ export declare class TeamsUserCredential implements TokenCredential {
1838
+ /**
1839
+ * Constructor of TeamsUserCredential.
1840
+ * @remarks
1841
+ * Can only be used within Teams.
1842
+ * @beta
1843
+ */
1844
+ constructor(authConfig: AuthenticationConfiguration);
1845
+ /**
1846
+ * Popup login page to get user's access token with specific scopes.
1847
+ * @remarks
1848
+ * Can only be used within Teams.
1849
+ * @beta
1850
+ */
1851
+ login(scopes: string | string[]): Promise<void>;
1852
+ /**
1853
+ * Get access token from credential.
1854
+ * @remarks
1855
+ * Can only be used within Teams.
1856
+ * @beta
1857
+ */
1858
+ getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
1859
+ /**
1860
+ * Get basic user info from SSO token
1861
+ * @remarks
1862
+ * Can only be used within Teams.
1863
+ * @beta
1864
+ */
1865
+ getUserInfo(): Promise<UserInfo>;
1866
+ }
1867
+
1868
+ /**
1869
+ * The trigger pattern used to trigger a {@link TeamsFxBotCommandHandler} instance.
1870
+ */
1871
+ export declare type TriggerPatterns = string | RegExp | (string | RegExp)[];
1872
+
1873
+ /**
1874
+ * UserInfo with user displayName, objectId and preferredUserName.
1875
+ *
1876
+ * @beta
1877
+ */
1878
+ export declare interface UserInfo {
1879
+ /**
1880
+ * User Display Name.
1881
+ *
1882
+ * @readonly
1883
+ */
1884
+ displayName: string;
1885
+ /**
1886
+ * User unique reference within the Azure Active Directory domain.
1887
+ *
1888
+ * @readonly
1889
+ */
1890
+ objectId: string;
1891
+ /**
1892
+ * Usually be the email address.
1893
+ *
1894
+ * @readonly
1895
+ */
1896
+ preferredUserName: string;
1897
+ }
1764
1898
 
1765
- export { }
1899
+ export { }