@microsoft/teamsfx 0.6.3-alpha.b31d198d3.0 → 0.6.3-alpha.d14f471d8.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.
@@ -680,1279 +680,1283 @@ export declare function createMicrosoftGraphClient(teamsfx: TeamsFxConfiguration
680
680
  *
681
681
  * @param { string | Buffer } cert - The cert chain in PEM format
682
682
  * @param { string | Buffer } key - The private key for the cert chain
683
- * @param { string? } passphrase - The passphrase for private key
684
- * @param { string? | Buffer? } ca - Overrides the trusted CA certificates
683
+ * @param { {passphrase?: string; ca?: string | Buffer} } options - Optional settings when create the cert options.
684
+ *
685
+ * @returns Instance of SecureContextOptions
686
+ *
687
+ * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
688
+ *
689
+ */
690
+ export declare function createPemCertOption(cert: string | Buffer, key: string | Buffer, options?: {
691
+ passphrase?: string;
692
+ ca?: string | Buffer;
693
+ }): SecureContextOptions;
694
+
695
+ /**
696
+ * Helper to create SecureContextOptions from PFX format cert
697
+ *
698
+ * @param { string | Buffer } pfx - The content of .pfx file
699
+ * @param { {passphrase?: string} } options - Optional settings when create the cert options.
700
+ *
701
+ * @returns Instance of SecureContextOptions
702
+ *
703
+ * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
704
+ *
705
+ */
706
+ export declare function createPfxCertOption(pfx: string | Buffer, options?: {
707
+ passphrase?: string;
708
+ }): SecureContextOptions;
709
+
710
+ /**
711
+ * Error code to trace the error types.
712
+ * @beta
713
+ */
714
+ export declare enum ErrorCode {
715
+ /**
716
+ * Invalid parameter error.
717
+ */
718
+ InvalidParameter = "InvalidParameter",
719
+ /**
720
+ * Invalid configuration error.
721
+ */
722
+ InvalidConfiguration = "InvalidConfiguration",
723
+ /**
724
+ * Invalid certificate error.
725
+ */
726
+ InvalidCertificate = "InvalidCertificate",
727
+ /**
728
+ * Internal error.
729
+ */
730
+ InternalError = "InternalError",
731
+ /**
732
+ * Channel is not supported error.
733
+ */
734
+ ChannelNotSupported = "ChannelNotSupported",
735
+ /**
736
+ * Runtime is not supported error.
737
+ */
738
+ RuntimeNotSupported = "RuntimeNotSupported",
739
+ /**
740
+ * User failed to finish the AAD consent flow failed.
741
+ */
742
+ ConsentFailed = "ConsentFailed",
743
+ /**
744
+ * The user or administrator has not consented to use the application error.
745
+ */
746
+ UiRequiredError = "UiRequiredError",
747
+ /**
748
+ * Token is not within its valid time range error.
749
+ */
750
+ TokenExpiredError = "TokenExpiredError",
751
+ /**
752
+ * Call service (AAD or simple authentication server) failed.
753
+ */
754
+ ServiceError = "ServiceError",
755
+ /**
756
+ * Operation failed.
757
+ */
758
+ FailedOperation = "FailedOperation",
759
+ /**
760
+ * Invalid response error.
761
+ */
762
+ InvalidResponse = "InvalidResponse",
763
+ /**
764
+ * Identity type error.
765
+ */
766
+ IdentityTypeNotSupported = "IdentityTypeNotSupported",
767
+ /**
768
+ * Authentication info already exists error.
769
+ */
770
+ AuthorizationInfoAlreadyExists = "AuthorizationInfoAlreadyExists"
771
+ }
772
+
773
+ /**
774
+ * Error class with code and message thrown by the SDK.
775
+ *
776
+ * @beta
777
+ */
778
+ export declare class ErrorWithCode extends Error {
779
+ /**
780
+ * Error code
685
781
  *
686
- * @returns Instance of SecureContextOptions
782
+ * @readonly
783
+ */
784
+ code: string | undefined;
785
+ /**
786
+ * Constructor of ErrorWithCode.
687
787
  *
688
- * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
788
+ * @param {string} message - error message.
789
+ * @param {ErrorCode} code - error code.
689
790
  *
791
+ * @beta
690
792
  */
691
- export declare function createPemCertOption(cert: string | Buffer, key: string | Buffer, passphrase?: string, ca?: string | Buffer): SecureContextOptions;
692
-
693
- /**
694
- * Helper to create SecureContextOptions from PFX format cert
695
- *
696
- * @param { string | Buffer } pfx - The content of .pfx file
697
- * @param { string? } passphrase - Optional. The passphrase of .pfx file
698
- *
699
- * @returns Instance of SecureContextOptions
700
- *
701
- * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
702
- *
703
- */
704
- export declare function createPfxCertOption(pfx: string | Buffer, passphrase?: string): SecureContextOptions;
705
-
706
- /**
707
- * Error code to trace the error types.
708
- * @beta
709
- */
710
- export declare enum ErrorCode {
711
- /**
712
- * Invalid parameter error.
713
- */
714
- InvalidParameter = "InvalidParameter",
715
- /**
716
- * Invalid configuration error.
717
- */
718
- InvalidConfiguration = "InvalidConfiguration",
719
- /**
720
- * Invalid certificate error.
721
- */
722
- InvalidCertificate = "InvalidCertificate",
723
- /**
724
- * Internal error.
725
- */
726
- InternalError = "InternalError",
727
- /**
728
- * Channel is not supported error.
729
- */
730
- ChannelNotSupported = "ChannelNotSupported",
731
- /**
732
- * Runtime is not supported error.
733
- */
734
- RuntimeNotSupported = "RuntimeNotSupported",
735
- /**
736
- * User failed to finish the AAD consent flow failed.
737
- */
738
- ConsentFailed = "ConsentFailed",
739
- /**
740
- * The user or administrator has not consented to use the application error.
741
- */
742
- UiRequiredError = "UiRequiredError",
743
- /**
744
- * Token is not within its valid time range error.
745
- */
746
- TokenExpiredError = "TokenExpiredError",
747
- /**
748
- * Call service (AAD or simple authentication server) failed.
749
- */
750
- ServiceError = "ServiceError",
751
- /**
752
- * Operation failed.
753
- */
754
- FailedOperation = "FailedOperation",
755
- /**
756
- * Invalid response error.
757
- */
758
- InvalidResponse = "InvalidResponse",
759
- /**
760
- * Identity type error.
761
- */
762
- IdentityTypeNotSupported = "IdentityTypeNotSupported",
763
- /**
764
- * Authentication info already exists error.
765
- */
766
- AuthorizationInfoAlreadyExists = "AuthorizationInfoAlreadyExists"
767
- }
768
-
769
- /**
770
- * Error class with code and message thrown by the SDK.
771
- *
772
- * @beta
773
- */
774
- export declare class ErrorWithCode extends Error {
775
- /**
776
- * Error code
777
- *
778
- * @readonly
779
- */
780
- code: string | undefined;
781
- /**
782
- * Constructor of ErrorWithCode.
783
- *
784
- * @param {string} message - error message.
785
- * @param {ErrorCode} code - error code.
786
- *
787
- * @beta
788
- */
789
- constructor(message?: string, code?: ErrorCode);
790
- }
791
-
792
- /**
793
- * Get log level.
794
- *
795
- * @returns Log level
796
- *
797
- * @beta
798
- */
799
- export declare function getLogLevel(): LogLevel | undefined;
800
-
801
- /**
802
- * Generate connection configuration consumed by tedious.
803
- *
804
- * @param {TeamsFx} teamsfx - Used to provide configuration and auth
805
- * @param { string? } databaseName - specify database name to override default one if there are multiple databases.
806
- *
807
- * @returns Connection configuration of tedious for the SQL.
808
- *
809
- * @throws {@link ErrorCode|InvalidConfiguration} when SQL config resource configuration is invalid.
810
- * @throws {@link ErrorCode|InternalError} when get user MSI token failed or MSI token is invalid.
811
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
812
- *
813
- * @beta
814
- */
815
- export declare function getTediousConnectionConfig(teamsfx: TeamsFx, databaseName?: string): Promise<ConnectionConfig>;
816
-
817
- /**
818
- * Identity type to use in authentication.
819
- *
820
- * @beta
821
- */
822
- export declare enum IdentityType {
823
- /**
824
- * Represents the current user of Teams.
825
- */
826
- User = "User",
827
- /**
828
- * Represents the application itself.
829
- */
830
- App = "Application"
831
- }
832
-
833
- /**
834
- * Log function for customized logging.
835
- *
836
- * @beta
837
- */
838
- export declare type LogFunction = (level: LogLevel, message: string) => void;
793
+ constructor(message?: string, code?: ErrorCode);
794
+ }
839
795
 
840
- /**
841
- * Interface for customized logger.
842
- * @beta
843
- */
844
- export declare interface Logger {
845
- /**
846
- * Writes to error level logging or lower.
847
- */
848
- error(message: string): void;
849
- /**
850
- * Writes to warning level logging or lower.
851
- */
852
- warn(message: string): void;
853
- /**
854
- * Writes to info level logging or lower.
855
- */
856
- info(message: string): void;
857
- /**
858
- * Writes to verbose level logging.
859
- */
860
- verbose(message: string): void;
861
- }
796
+ /**
797
+ * Get log level.
798
+ *
799
+ * @returns Log level
800
+ *
801
+ * @beta
802
+ */
803
+ export declare function getLogLevel(): LogLevel | undefined;
862
804
 
863
- /**
864
- * Log level.
865
- *
866
- * @beta
867
- */
868
- export declare enum LogLevel {
869
- /**
870
- * Show verbose, information, warning and error message.
871
- */
872
- Verbose = 0,
873
- /**
874
- * Show information, warning and error message.
875
- */
876
- Info = 1,
877
- /**
878
- * Show warning and error message.
879
- */
880
- Warn = 2,
881
- /**
882
- * Show error message.
883
- */
884
- Error = 3
885
- }
805
+ /**
806
+ * Generate connection configuration consumed by tedious.
807
+ *
808
+ * @param {TeamsFx} teamsfx - Used to provide configuration and auth
809
+ * @param { string? } databaseName - specify database name to override default one if there are multiple databases.
810
+ *
811
+ * @returns Connection configuration of tedious for the SQL.
812
+ *
813
+ * @throws {@link ErrorCode|InvalidConfiguration} when SQL config resource configuration is invalid.
814
+ * @throws {@link ErrorCode|InternalError} when get user MSI token failed or MSI token is invalid.
815
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
816
+ *
817
+ * @beta
818
+ */
819
+ export declare function getTediousConnectionConfig(teamsfx: TeamsFx, databaseName?: string): Promise<ConnectionConfig>;
886
820
 
887
- /**
888
- * A {@link NotificationTarget} that represents a team member.
889
- *
890
- * @remarks
891
- * It's recommended to get members from {@link TeamsBotInstallation.members()}.
892
- *
893
- * @beta
894
- */
895
- export declare class Member implements NotificationTarget {
896
- /**
897
- * The parent {@link TeamsBotInstallation} where this member is created from.
898
- *
899
- * @beta
900
- */
901
- readonly parent: TeamsBotInstallation;
902
- /**
903
- * Detailed member account information.
904
- *
905
- * @beta
906
- */
907
- readonly account: TeamsChannelAccount;
908
- /**
909
- * Notification target type. For member it's always "Person".
910
- *
911
- * @beta
912
- */
913
- readonly type: NotificationTargetType;
914
- /**
915
- * Constuctor.
916
- *
917
- * @remarks
918
- * It's recommended to get members from {@link TeamsBotInstallation.members()}, instead of using this constructor.
919
- *
920
- * @param parent - The parent {@link TeamsBotInstallation} where this member is created from.
921
- * @param account - Detailed member account information.
922
- *
923
- * @beta
924
- */
925
- constructor(parent: TeamsBotInstallation, account: TeamsChannelAccount);
926
- /**
927
- * Send a plain text message.
928
- *
929
- * @param text - the plain text message.
930
- * @returns A `Promise` representing the asynchronous operation.
931
- *
932
- * @beta
933
- */
934
- sendMessage(text: string): Promise<void>;
935
- /**
936
- * Send an adaptive card message.
937
- *
938
- * @param card - the adaptive card raw JSON.
939
- * @returns A `Promise` representing the asynchronous operation.
940
- *
941
- * @beta
942
- */
943
- sendAdaptiveCard(card: unknown): Promise<void>;
944
- /**
945
- * @internal
946
- */
947
- private newConversation;
948
- }
821
+ /**
822
+ * Identity type to use in authentication.
823
+ *
824
+ * @beta
825
+ */
826
+ export declare enum IdentityType {
827
+ /**
828
+ * Represents the current user of Teams.
829
+ */
830
+ User = "User",
831
+ /**
832
+ * Represents the application itself.
833
+ */
834
+ App = "Application"
835
+ }
949
836
 
950
- /**
951
- * Provides utility method to build bot message with cards that supported in Teams.
952
- */
953
- export declare class MessageBuilder {
954
- /**
955
- * Build a bot message activity attached with adaptive card.
956
- *
957
- * @param cardTemplate The adaptive card template.
958
- * @param data card data used to render the template.
959
- * @returns A bot message activity attached with an adaptive card.
960
- *
961
- * @example
962
- * ```javascript
963
- * const cardTemplate = {
964
- * type: "AdaptiveCard",
965
- * body: [
966
- * {
967
- * "type": "TextBlock",
968
- * "text": "${title}",
969
- * "size": "Large"
970
- * },
971
- * {
972
- * "type": "TextBlock",
973
- * "text": "${description}"
974
- * }],
975
- * $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
976
- * version: "1.4"
977
- * };
978
- *
979
- * type CardData = {
980
- * title: string,
981
- * description: string
982
- * };
983
- * const card = MessageBuilder.attachAdaptiveCard<CardData>(
984
- * cardTemplate, {
985
- * title: "sample card title",
986
- * description: "sample card description"
987
- * });
988
- * ```
989
- *
990
- * @beta
991
- */
992
- static attachAdaptiveCard<TData>(cardTemplate: any, data: TData): Partial<Activity_2>;
993
- /**
994
- * Build a bot message activity attached with an adaptive card.
995
- *
996
- * @param card The adaptive card content.
997
- * @returns A bot message activity attached with an adaptive card.
998
- *
999
- * @beta
1000
- */
1001
- static attachAdaptiveCardWithoutData(card: any): Partial<Activity_2>;
1002
- /**
1003
- * Build a bot message activity attached with an hero card.
1004
- *
1005
- * @param title The card title.
1006
- * @param images Optional. The array of images to include on the card.
1007
- * @param buttons Optional. The array of buttons to include on the card. Each `string` in the array
1008
- * is converted to an `imBack` button with a title and value set to the value of the string.
1009
- * @param other Optional. Any additional properties to include on the card.
1010
- *
1011
- * @returns A bot message activity attached with a hero card.
1012
- *
1013
- * @example
1014
- * ```javascript
1015
- * const message = MessageBuilder.attachHeroCard(
1016
- * 'sample title',
1017
- * ['https://example.com/sample.jpg'],
1018
- * ['action']
1019
- * );
1020
- * ```
1021
- *
1022
- * @beta
1023
- */
1024
- static attachHeroCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<HeroCard>): Partial<Activity_2>;
1025
- /**
1026
- * Returns an attachment for a sign-in card.
1027
- *
1028
- * @param title The title for the card's sign-in button.
1029
- * @param url The URL of the sign-in page to use.
1030
- * @param text Optional. Additional text to include on the card.
1031
- *
1032
- * @returns A bot message activity attached with a sign-in card.
1033
- *
1034
- * @remarks
1035
- * For channels that don't natively support sign-in cards, an alternative message is rendered.
1036
- *
1037
- * @beta
1038
- */
1039
- static attachSigninCard(title: string, url: string, text?: string): Partial<Activity_2>;
1040
- /**
1041
- * Build a bot message activity attached with an Office 365 connector card.
1042
- *
1043
- * @param card A description of the Office 365 connector card.
1044
- * @returns A bot message activity attached with an Office 365 connector card.
1045
- *
1046
- * @beta
1047
- */
1048
- static attachO365ConnectorCard(card: O365ConnectorCard): Partial<Activity_2>;
1049
- /**
1050
- * Build a message activity attached with a receipt card.
1051
- * @param card A description of the receipt card.
1052
- * @returns A message activity attached with a receipt card.
1053
- *
1054
- * @beta
1055
- */
1056
- static AttachReceiptCard(card: ReceiptCard): Partial<Activity_2>;
1057
- /**
1058
- *
1059
- * @param title The card title.
1060
- * @param images Optional. The array of images to include on the card.
1061
- * @param buttons Optional. The array of buttons to include on the card. Each `string` in the array
1062
- * is converted to an `imBack` button with a title and value set to the value of the string.
1063
- * @param other Optional. Any additional properties to include on the card.
1064
- * @returns A message activity attached with a thumbnail card
1065
- *
1066
- * @beta
1067
- */
1068
- static attachThumbnailCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<ThumbnailCard>): Partial<Activity_2>;
1069
- /**
1070
- * Add an attachement to a bot activity.
1071
- * @param attachement The attachment object to attach.
1072
- * @returns A message activity with an attachment.
1073
- *
1074
- * @beta
1075
- */
1076
- static attachContent(attachement: Attachment): Partial<Activity_2>;
1077
- }
837
+ /**
838
+ * Log function for customized logging.
839
+ *
840
+ * @beta
841
+ */
842
+ export declare type LogFunction = (level: LogLevel, message: string) => void;
1078
843
 
1079
- /**
1080
- * Microsoft Graph auth provider for Teams Framework
1081
- *
1082
- * @beta
1083
- */
1084
- export declare class MsGraphAuthProvider implements AuthenticationProvider {
1085
- private teamsfx;
1086
- private scopes;
1087
- /**
1088
- * Constructor of MsGraphAuthProvider.
1089
- *
1090
- * @param {TeamsFx} teamsfx - Used to provide configuration and auth.
1091
- * @param {string | string[]} scopes - The list of scopes for which the token will have access.
1092
- *
1093
- * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1094
- *
1095
- * @returns An instance of MsGraphAuthProvider.
1096
- *
1097
- * @beta
1098
- */
1099
- constructor(teamsfx: TeamsFxConfiguration, scopes?: string | string[]);
1100
- /**
1101
- * Get access token for Microsoft Graph API requests.
1102
- *
1103
- * @throws {@link ErrorCode|InternalError} when get access token failed due to empty token or unknown other problems.
1104
- * @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
1105
- * @throws {@link ErrorCode|UiRequiredError} when need user consent to get access token.
1106
- * @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth or AAD server.
1107
- * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1108
- *
1109
- * @returns Access token from the credential.
1110
- *
1111
- */
1112
- getAccessToken(): Promise<string>;
1113
- }
844
+ /**
845
+ * Interface for customized logger.
846
+ * @beta
847
+ */
848
+ export declare interface Logger {
849
+ /**
850
+ * Writes to error level logging or lower.
851
+ */
852
+ error(message: string): void;
853
+ /**
854
+ * Writes to warning level logging or lower.
855
+ */
856
+ warn(message: string): void;
857
+ /**
858
+ * Writes to info level logging or lower.
859
+ */
860
+ info(message: string): void;
861
+ /**
862
+ * Writes to verbose level logging.
863
+ */
864
+ verbose(message: string): void;
865
+ }
1114
866
 
1115
- /**
1116
- * Provide utilities to send notification to varies targets (e.g., member, group, channel).
1117
- *
1118
- * @beta
1119
- */
1120
- export declare class NotificationBot {
1121
- private readonly conversationReferenceStore;
1122
- private readonly adapter;
1123
- /**
1124
- * constructor of the notification bot.
1125
- *
1126
- * @remarks
1127
- * To ensure accuracy, it's recommended to initialize before handling any message.
1128
- *
1129
- * @param adapter - the bound `BotFrameworkAdapter`
1130
- * @param options - initialize options
1131
- *
1132
- * @beta
1133
- */
1134
- constructor(adapter: BotFrameworkAdapter, options?: NotificationOptions_2);
1135
- /**
1136
- * Get all targets where the bot is installed.
1137
- *
1138
- * @remarks
1139
- * The result is retrieving from the persisted storage.
1140
- *
1141
- * @returns - an array of {@link TeamsBotInstallation}.
1142
- *
1143
- * @beta
1144
- */
1145
- installations(): Promise<TeamsBotInstallation[]>;
1146
- }
867
+ /**
868
+ * Log level.
869
+ *
870
+ * @beta
871
+ */
872
+ export declare enum LogLevel {
873
+ /**
874
+ * Show verbose, information, warning and error message.
875
+ */
876
+ Verbose = 0,
877
+ /**
878
+ * Show information, warning and error message.
879
+ */
880
+ Info = 1,
881
+ /**
882
+ * Show warning and error message.
883
+ */
884
+ Warn = 2,
885
+ /**
886
+ * Show error message.
887
+ */
888
+ Error = 3
889
+ }
1147
890
 
1148
- /**
1149
- * Options to initialize {@link NotificationBot}.
1150
- *
1151
- * @beta
1152
- */
1153
- declare interface NotificationOptions_2 {
1154
- /**
1155
- * An optional storage to persist bot notification connections.
1156
- *
1157
- * @remarks
1158
- * If `storage` is not provided, a default local file storage will be used,
1159
- * which stores notification connections into:
1160
- * - ".notification.localstore.json" if running locally
1161
- * - "${process.env.TEMP}/.notification.localstore.json" if `process.env.RUNNING_ON_AZURE` is set to "1"
1162
- *
1163
- * It's recommended to use your own shared storage for production environment.
1164
- *
1165
- * @beta
1166
- */
1167
- storage?: NotificationTargetStorage;
1168
- }
1169
- export { NotificationOptions_2 as NotificationOptions }
891
+ /**
892
+ * A {@link NotificationTarget} that represents a team member.
893
+ *
894
+ * @remarks
895
+ * It's recommended to get members from {@link TeamsBotInstallation.members()}.
896
+ *
897
+ * @beta
898
+ */
899
+ export declare class Member implements NotificationTarget {
900
+ /**
901
+ * The parent {@link TeamsBotInstallation} where this member is created from.
902
+ *
903
+ * @beta
904
+ */
905
+ readonly parent: TeamsBotInstallation;
906
+ /**
907
+ * Detailed member account information.
908
+ *
909
+ * @beta
910
+ */
911
+ readonly account: TeamsChannelAccount;
912
+ /**
913
+ * Notification target type. For member it's always "Person".
914
+ *
915
+ * @beta
916
+ */
917
+ readonly type: NotificationTargetType;
918
+ /**
919
+ * Constuctor.
920
+ *
921
+ * @remarks
922
+ * It's recommended to get members from {@link TeamsBotInstallation.members()}, instead of using this constructor.
923
+ *
924
+ * @param parent - The parent {@link TeamsBotInstallation} where this member is created from.
925
+ * @param account - Detailed member account information.
926
+ *
927
+ * @beta
928
+ */
929
+ constructor(parent: TeamsBotInstallation, account: TeamsChannelAccount);
930
+ /**
931
+ * Send a plain text message.
932
+ *
933
+ * @param text - the plain text message.
934
+ * @returns A `Promise` representing the asynchronous operation.
935
+ *
936
+ * @beta
937
+ */
938
+ sendMessage(text: string): Promise<void>;
939
+ /**
940
+ * Send an adaptive card message.
941
+ *
942
+ * @param card - the adaptive card raw JSON.
943
+ * @returns A `Promise` representing the asynchronous operation.
944
+ *
945
+ * @beta
946
+ */
947
+ sendAdaptiveCard(card: unknown): Promise<void>;
948
+ /**
949
+ * @internal
950
+ */
951
+ private newConversation;
952
+ }
1170
953
 
1171
- /**
1172
- * Represent a notification target.
1173
- *
1174
- * @beta
1175
- */
1176
- export declare interface NotificationTarget {
1177
- /**
1178
- * The type of target, could be "Channel" or "Group" or "Person".
1179
- *
1180
- * @beta
1181
- */
1182
- readonly type?: NotificationTargetType;
1183
- /**
1184
- * Send a plain text message.
1185
- *
1186
- * @param text - the plain text message.
1187
- *
1188
- * @beta
1189
- */
1190
- sendMessage(text: string): Promise<void>;
1191
- /**
1192
- * Send an adaptive card message.
1193
- *
1194
- * @param card - the adaptive card raw JSON.
1195
- *
1196
- * @beta
1197
- */
1198
- sendAdaptiveCard(card: unknown): Promise<void>;
1199
- }
954
+ /**
955
+ * Provides utility method to build bot message with cards that supported in Teams.
956
+ */
957
+ export declare class MessageBuilder {
958
+ /**
959
+ * Build a bot message activity attached with adaptive card.
960
+ *
961
+ * @param cardTemplate The adaptive card template.
962
+ * @param data card data used to render the template.
963
+ * @returns A bot message activity attached with an adaptive card.
964
+ *
965
+ * @example
966
+ * ```javascript
967
+ * const cardTemplate = {
968
+ * type: "AdaptiveCard",
969
+ * body: [
970
+ * {
971
+ * "type": "TextBlock",
972
+ * "text": "${title}",
973
+ * "size": "Large"
974
+ * },
975
+ * {
976
+ * "type": "TextBlock",
977
+ * "text": "${description}"
978
+ * }],
979
+ * $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
980
+ * version: "1.4"
981
+ * };
982
+ *
983
+ * type CardData = {
984
+ * title: string,
985
+ * description: string
986
+ * };
987
+ * const card = MessageBuilder.attachAdaptiveCard<CardData>(
988
+ * cardTemplate, {
989
+ * title: "sample card title",
990
+ * description: "sample card description"
991
+ * });
992
+ * ```
993
+ *
994
+ * @beta
995
+ */
996
+ static attachAdaptiveCard<TData>(cardTemplate: any, data: TData): Partial<Activity_2>;
997
+ /**
998
+ * Build a bot message activity attached with an adaptive card.
999
+ *
1000
+ * @param card The adaptive card content.
1001
+ * @returns A bot message activity attached with an adaptive card.
1002
+ *
1003
+ * @beta
1004
+ */
1005
+ static attachAdaptiveCardWithoutData(card: any): Partial<Activity_2>;
1006
+ /**
1007
+ * Build a bot message activity attached with an hero card.
1008
+ *
1009
+ * @param title The card title.
1010
+ * @param images Optional. The array of images to include on the card.
1011
+ * @param buttons Optional. The array of buttons to include on the card. Each `string` in the array
1012
+ * is converted to an `imBack` button with a title and value set to the value of the string.
1013
+ * @param other Optional. Any additional properties to include on the card.
1014
+ *
1015
+ * @returns A bot message activity attached with a hero card.
1016
+ *
1017
+ * @example
1018
+ * ```javascript
1019
+ * const message = MessageBuilder.attachHeroCard(
1020
+ * 'sample title',
1021
+ * ['https://example.com/sample.jpg'],
1022
+ * ['action']
1023
+ * );
1024
+ * ```
1025
+ *
1026
+ * @beta
1027
+ */
1028
+ static attachHeroCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<HeroCard>): Partial<Activity_2>;
1029
+ /**
1030
+ * Returns an attachment for a sign-in card.
1031
+ *
1032
+ * @param title The title for the card's sign-in button.
1033
+ * @param url The URL of the sign-in page to use.
1034
+ * @param text Optional. Additional text to include on the card.
1035
+ *
1036
+ * @returns A bot message activity attached with a sign-in card.
1037
+ *
1038
+ * @remarks
1039
+ * For channels that don't natively support sign-in cards, an alternative message is rendered.
1040
+ *
1041
+ * @beta
1042
+ */
1043
+ static attachSigninCard(title: string, url: string, text?: string): Partial<Activity_2>;
1044
+ /**
1045
+ * Build a bot message activity attached with an Office 365 connector card.
1046
+ *
1047
+ * @param card A description of the Office 365 connector card.
1048
+ * @returns A bot message activity attached with an Office 365 connector card.
1049
+ *
1050
+ * @beta
1051
+ */
1052
+ static attachO365ConnectorCard(card: O365ConnectorCard): Partial<Activity_2>;
1053
+ /**
1054
+ * Build a message activity attached with a receipt card.
1055
+ * @param card A description of the receipt card.
1056
+ * @returns A message activity attached with a receipt card.
1057
+ *
1058
+ * @beta
1059
+ */
1060
+ static AttachReceiptCard(card: ReceiptCard): Partial<Activity_2>;
1061
+ /**
1062
+ *
1063
+ * @param title The card title.
1064
+ * @param images Optional. The array of images to include on the card.
1065
+ * @param buttons Optional. The array of buttons to include on the card. Each `string` in the array
1066
+ * is converted to an `imBack` button with a title and value set to the value of the string.
1067
+ * @param other Optional. Any additional properties to include on the card.
1068
+ * @returns A message activity attached with a thumbnail card
1069
+ *
1070
+ * @beta
1071
+ */
1072
+ static attachThumbnailCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<ThumbnailCard>): Partial<Activity_2>;
1073
+ /**
1074
+ * Add an attachement to a bot activity.
1075
+ * @param attachement The attachment object to attach.
1076
+ * @returns A message activity with an attachment.
1077
+ *
1078
+ * @beta
1079
+ */
1080
+ static attachContent(attachement: Attachment): Partial<Activity_2>;
1081
+ }
1200
1082
 
1201
- /**
1202
- * Interface for a storage provider that stores and retrieves notification target references.
1203
- *
1204
- * @beta
1205
- */
1206
- export declare interface NotificationTargetStorage {
1207
- /**
1208
- * Read one notification target by its key.
1209
- *
1210
- * @param key - the key of a notification target.
1211
- *
1212
- * @returns - the notification target. Or undefined if not found.
1213
- *
1214
- * @beta
1215
- */
1216
- read(key: string): Promise<{
1217
- [key: string]: unknown;
1218
- } | undefined>;
1219
- /**
1220
- * List all stored notification targets.
1221
- *
1222
- * @returns - an array of notification target. Or an empty array if nothing is stored.
1223
- *
1224
- * @beta
1225
- */
1226
- list(): Promise<{
1227
- [key: string]: unknown;
1228
- }[]>;
1229
- /**
1230
- * Write one notification target by its key.
1231
- *
1232
- * @param key - the key of a notification target.
1233
- * @param object - the notification target.
1234
- *
1235
- * @beta
1236
- */
1237
- write(key: string, object: {
1238
- [key: string]: unknown;
1239
- }): Promise<void>;
1240
- /**
1241
- * Delete one notificaton target by its key.
1242
- *
1243
- * @param key - the key of a notification target.
1244
- *
1245
- * @beta
1246
- */
1247
- delete(key: string): Promise<void>;
1248
- }
1083
+ /**
1084
+ * Microsoft Graph auth provider for Teams Framework
1085
+ *
1086
+ * @beta
1087
+ */
1088
+ export declare class MsGraphAuthProvider implements AuthenticationProvider {
1089
+ private teamsfx;
1090
+ private scopes;
1091
+ /**
1092
+ * Constructor of MsGraphAuthProvider.
1093
+ *
1094
+ * @param {TeamsFx} teamsfx - Used to provide configuration and auth.
1095
+ * @param {string | string[]} scopes - The list of scopes for which the token will have access.
1096
+ *
1097
+ * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1098
+ *
1099
+ * @returns An instance of MsGraphAuthProvider.
1100
+ *
1101
+ * @beta
1102
+ */
1103
+ constructor(teamsfx: TeamsFxConfiguration, scopes?: string | string[]);
1104
+ /**
1105
+ * Get access token for Microsoft Graph API requests.
1106
+ *
1107
+ * @throws {@link ErrorCode|InternalError} when get access token failed due to empty token or unknown other problems.
1108
+ * @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
1109
+ * @throws {@link ErrorCode|UiRequiredError} when need user consent to get access token.
1110
+ * @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth or AAD server.
1111
+ * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1112
+ *
1113
+ * @returns Access token from the credential.
1114
+ *
1115
+ */
1116
+ getAccessToken(): Promise<string>;
1117
+ }
1249
1118
 
1250
- /**
1251
- * The target type where the notification will be sent to.
1252
- *
1253
- * @remarks
1254
- * - "Channel" means to a team channel. (By default, notification to a team will be sent to its "General" channel.)
1255
- * - "Group" means to a group chat.
1256
- * - "Person" means to a personal chat.
1257
- *
1258
- * @beta
1259
- */
1260
- export declare type NotificationTargetType = "Channel" | "Group" | "Person";
1119
+ /**
1120
+ * Provide utilities to send notification to varies targets (e.g., member, group, channel).
1121
+ *
1122
+ * @beta
1123
+ */
1124
+ export declare class NotificationBot {
1125
+ private readonly conversationReferenceStore;
1126
+ private readonly adapter;
1127
+ /**
1128
+ * constructor of the notification bot.
1129
+ *
1130
+ * @remarks
1131
+ * To ensure accuracy, it's recommended to initialize before handling any message.
1132
+ *
1133
+ * @param adapter - the bound `BotFrameworkAdapter`
1134
+ * @param options - initialize options
1135
+ *
1136
+ * @beta
1137
+ */
1138
+ constructor(adapter: BotFrameworkAdapter, options?: NotificationOptions_2);
1139
+ /**
1140
+ * Get all targets where the bot is installed.
1141
+ *
1142
+ * @remarks
1143
+ * The result is retrieving from the persisted storage.
1144
+ *
1145
+ * @returns - an array of {@link TeamsBotInstallation}.
1146
+ *
1147
+ * @beta
1148
+ */
1149
+ installations(): Promise<TeamsBotInstallation[]>;
1150
+ }
1261
1151
 
1262
- /**
1263
- * Represent on-behalf-of flow to get user identity, and it is designed to be used in server side.
1264
- *
1265
- * @example
1266
- * ```typescript
1267
- * const credential = new OnBehalfOfUserCredential(ssoToken);
1268
- * ```
1269
- *
1270
- * @remarks
1271
- * Can only be used in server side.
1272
- *
1273
- * @beta
1274
- */
1275
- export declare class OnBehalfOfUserCredential implements TokenCredential {
1276
- private msalClient;
1277
- private ssoToken;
1278
- /**
1279
- * Constructor of OnBehalfOfUserCredential
1280
- *
1281
- * @remarks
1282
- * Only works in in server side.
1283
- *
1284
- * @param {string} ssoToken - User token provided by Teams SSO feature.
1285
- * @param {AuthenticationConfiguration} config - The authentication configuration. Use environment variables if not provided.
1286
- *
1287
- * @throws {@link ErrorCode|InvalidConfiguration} when client id, client secret, certificate content, authority host or tenant id is not found in config.
1288
- * @throws {@link ErrorCode|InternalError} when SSO token is not valid.
1289
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1290
- *
1291
- * @beta
1292
- */
1293
- constructor(ssoToken: string, config: AuthenticationConfiguration);
1294
- /**
1295
- * Get access token from credential.
1296
- *
1297
- * @example
1298
- * ```typescript
1299
- * await credential.getToken([]) // Get SSO token using empty string array
1300
- * await credential.getToken("") // Get SSO token using empty string
1301
- * await credential.getToken([".default"]) // Get Graph access token with default scope using string array
1302
- * await credential.getToken(".default") // Get Graph access token with default scope using string
1303
- * await credential.getToken(["User.Read"]) // Get Graph access token for single scope using string array
1304
- * await credential.getToken("User.Read") // Get Graph access token for single scope using string
1305
- * await credential.getToken(["User.Read", "Application.Read.All"]) // Get Graph access token for multiple scopes using string array
1306
- * await credential.getToken("User.Read Application.Read.All") // Get Graph access token for multiple scopes using space-separated string
1307
- * await credential.getToken("https://graph.microsoft.com/User.Read") // Get Graph access token with full resource URI
1308
- * await credential.getToken(["https://outlook.office.com/Mail.Read"]) // Get Outlook access token
1309
- * ```
1310
- *
1311
- * @param {string | string[]} scopes - The list of scopes for which the token will have access.
1312
- * @param {GetTokenOptions} options - The options used to configure any requests this TokenCredential implementation might make.
1313
- *
1314
- * @throws {@link ErrorCode|InternalError} when failed to acquire access token on behalf of user with unknown error.
1315
- * @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
1316
- * @throws {@link ErrorCode|UiRequiredError} when need user consent to get access token.
1317
- * @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth server.
1318
- * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1319
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1320
- *
1321
- * @returns Access token with expected scopes.
1322
- *
1323
- * @remarks
1324
- * If scopes is empty string or array, it returns SSO token.
1325
- * If scopes is non-empty, it returns access token for target scope.
1326
- *
1327
- * @beta
1328
- */
1329
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
1330
- /**
1331
- * Get basic user info from SSO token.
1332
- *
1333
- * @example
1334
- * ```typescript
1335
- * const currentUser = getUserInfo();
1336
- * ```
1337
- *
1338
- * @throws {@link ErrorCode|InternalError} when SSO token is not valid.
1339
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1340
- *
1341
- * @returns Basic user info with user displayName, objectId and preferredUserName.
1342
- *
1343
- * @beta
1344
- */
1345
- getUserInfo(): UserInfo;
1346
- private generateAuthServerError;
1347
- }
1152
+ /**
1153
+ * Options to initialize {@link NotificationBot}.
1154
+ *
1155
+ * @beta
1156
+ */
1157
+ declare interface NotificationOptions_2 {
1158
+ /**
1159
+ * An optional storage to persist bot notification connections.
1160
+ *
1161
+ * @remarks
1162
+ * If `storage` is not provided, a default local file storage will be used,
1163
+ * which stores notification connections into:
1164
+ * - ".notification.localstore.json" if running locally
1165
+ * - "${process.env.TEMP}/.notification.localstore.json" if `process.env.RUNNING_ON_AZURE` is set to "1"
1166
+ *
1167
+ * It's recommended to use your own shared storage for production environment.
1168
+ *
1169
+ * @beta
1170
+ */
1171
+ storage?: NotificationTargetStorage;
1172
+ }
1173
+ export { NotificationOptions_2 as NotificationOptions }
1348
1174
 
1349
- /**
1350
- * Send an adaptive card message to a notification target.
1351
- *
1352
- * @param target - the notification target.
1353
- * @param card - the adaptive card raw JSON.
1354
- * @returns A `Promise` representing the asynchronous operation.
1355
- *
1356
- * @beta
1357
- */
1358
- export declare function sendAdaptiveCard(target: NotificationTarget, card: unknown): Promise<void>;
1175
+ /**
1176
+ * Represent a notification target.
1177
+ *
1178
+ * @beta
1179
+ */
1180
+ export declare interface NotificationTarget {
1181
+ /**
1182
+ * The type of target, could be "Channel" or "Group" or "Person".
1183
+ *
1184
+ * @beta
1185
+ */
1186
+ readonly type?: NotificationTargetType;
1187
+ /**
1188
+ * Send a plain text message.
1189
+ *
1190
+ * @param text - the plain text message.
1191
+ *
1192
+ * @beta
1193
+ */
1194
+ sendMessage(text: string): Promise<void>;
1195
+ /**
1196
+ * Send an adaptive card message.
1197
+ *
1198
+ * @param card - the adaptive card raw JSON.
1199
+ *
1200
+ * @beta
1201
+ */
1202
+ sendAdaptiveCard(card: unknown): Promise<void>;
1203
+ }
1359
1204
 
1360
- /**
1361
- * Send a plain text message to a notification target.
1362
- *
1363
- * @param target - the notification target.
1364
- * @param text - the plain text message.
1365
- * @returns A `Promise` representing the asynchronous operation.
1366
- *
1367
- * @beta
1368
- */
1369
- export declare function sendMessage(target: NotificationTarget, text: string): Promise<void>;
1205
+ /**
1206
+ * Interface for a storage provider that stores and retrieves notification target references.
1207
+ *
1208
+ * @beta
1209
+ */
1210
+ export declare interface NotificationTargetStorage {
1211
+ /**
1212
+ * Read one notification target by its key.
1213
+ *
1214
+ * @param key - the key of a notification target.
1215
+ *
1216
+ * @returns - the notification target. Or undefined if not found.
1217
+ *
1218
+ * @beta
1219
+ */
1220
+ read(key: string): Promise<{
1221
+ [key: string]: unknown;
1222
+ } | undefined>;
1223
+ /**
1224
+ * List all stored notification targets.
1225
+ *
1226
+ * @returns - an array of notification target. Or an empty array if nothing is stored.
1227
+ *
1228
+ * @beta
1229
+ */
1230
+ list(): Promise<{
1231
+ [key: string]: unknown;
1232
+ }[]>;
1233
+ /**
1234
+ * Write one notification target by its key.
1235
+ *
1236
+ * @param key - the key of a notification target.
1237
+ * @param object - the notification target.
1238
+ *
1239
+ * @beta
1240
+ */
1241
+ write(key: string, object: {
1242
+ [key: string]: unknown;
1243
+ }): Promise<void>;
1244
+ /**
1245
+ * Delete one notificaton target by its key.
1246
+ *
1247
+ * @param key - the key of a notification target.
1248
+ *
1249
+ * @beta
1250
+ */
1251
+ delete(key: string): Promise<void>;
1252
+ }
1370
1253
 
1371
- /**
1372
- * Set custom log function. Use the function if it's set. Priority is lower than setLogger.
1373
- *
1374
- * @param {LogFunction} logFunction - custom log function. If it's undefined, custom log function will be cleared.
1375
- *
1376
- * @example
1377
- * ```typescript
1378
- * setLogFunction((level: LogLevel, message: string) => {
1379
- * if (level === LogLevel.Error) {
1380
- * console.log(message);
1381
- * }
1382
- * });
1383
- * ```
1384
- *
1385
- * @beta
1386
- */
1387
- export declare function setLogFunction(logFunction?: LogFunction): void;
1254
+ /**
1255
+ * The target type where the notification will be sent to.
1256
+ *
1257
+ * @remarks
1258
+ * - "Channel" means to a team channel. (By default, notification to a team will be sent to its "General" channel.)
1259
+ * - "Group" means to a group chat.
1260
+ * - "Person" means to a personal chat.
1261
+ *
1262
+ * @beta
1263
+ */
1264
+ export declare type NotificationTargetType = "Channel" | "Group" | "Person";
1388
1265
 
1389
- /**
1390
- * Set custom logger. Use the output functions if it's set. Priority is higher than setLogFunction.
1391
- *
1392
- * @param {Logger} logger - custom logger. If it's undefined, custom logger will be cleared.
1393
- *
1394
- * @example
1395
- * ```typescript
1396
- * setLogger({
1397
- * verbose: console.debug,
1398
- * info: console.info,
1399
- * warn: console.warn,
1400
- * error: console.error,
1401
- * });
1402
- * ```
1403
- *
1404
- * @beta
1405
- */
1406
- export declare function setLogger(logger?: Logger): void;
1266
+ /**
1267
+ * Represent on-behalf-of flow to get user identity, and it is designed to be used in server side.
1268
+ *
1269
+ * @example
1270
+ * ```typescript
1271
+ * const credential = new OnBehalfOfUserCredential(ssoToken);
1272
+ * ```
1273
+ *
1274
+ * @remarks
1275
+ * Can only be used in server side.
1276
+ *
1277
+ * @beta
1278
+ */
1279
+ export declare class OnBehalfOfUserCredential implements TokenCredential {
1280
+ private msalClient;
1281
+ private ssoToken;
1282
+ /**
1283
+ * Constructor of OnBehalfOfUserCredential
1284
+ *
1285
+ * @remarks
1286
+ * Only works in in server side.
1287
+ *
1288
+ * @param {string} ssoToken - User token provided by Teams SSO feature.
1289
+ * @param {AuthenticationConfiguration} config - The authentication configuration. Use environment variables if not provided.
1290
+ *
1291
+ * @throws {@link ErrorCode|InvalidConfiguration} when client id, client secret, certificate content, authority host or tenant id is not found in config.
1292
+ * @throws {@link ErrorCode|InternalError} when SSO token is not valid.
1293
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1294
+ *
1295
+ * @beta
1296
+ */
1297
+ constructor(ssoToken: string, config: AuthenticationConfiguration);
1298
+ /**
1299
+ * Get access token from credential.
1300
+ *
1301
+ * @example
1302
+ * ```typescript
1303
+ * await credential.getToken([]) // Get SSO token using empty string array
1304
+ * await credential.getToken("") // Get SSO token using empty string
1305
+ * await credential.getToken([".default"]) // Get Graph access token with default scope using string array
1306
+ * await credential.getToken(".default") // Get Graph access token with default scope using string
1307
+ * await credential.getToken(["User.Read"]) // Get Graph access token for single scope using string array
1308
+ * await credential.getToken("User.Read") // Get Graph access token for single scope using string
1309
+ * await credential.getToken(["User.Read", "Application.Read.All"]) // Get Graph access token for multiple scopes using string array
1310
+ * await credential.getToken("User.Read Application.Read.All") // Get Graph access token for multiple scopes using space-separated string
1311
+ * await credential.getToken("https://graph.microsoft.com/User.Read") // Get Graph access token with full resource URI
1312
+ * await credential.getToken(["https://outlook.office.com/Mail.Read"]) // Get Outlook access token
1313
+ * ```
1314
+ *
1315
+ * @param {string | string[]} scopes - The list of scopes for which the token will have access.
1316
+ * @param {GetTokenOptions} options - The options used to configure any requests this TokenCredential implementation might make.
1317
+ *
1318
+ * @throws {@link ErrorCode|InternalError} when failed to acquire access token on behalf of user with unknown error.
1319
+ * @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
1320
+ * @throws {@link ErrorCode|UiRequiredError} when need user consent to get access token.
1321
+ * @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth server.
1322
+ * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1323
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1324
+ *
1325
+ * @returns Access token with expected scopes.
1326
+ *
1327
+ * @remarks
1328
+ * If scopes is empty string or array, it returns SSO token.
1329
+ * If scopes is non-empty, it returns access token for target scope.
1330
+ *
1331
+ * @beta
1332
+ */
1333
+ getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
1334
+ /**
1335
+ * Get basic user info from SSO token.
1336
+ *
1337
+ * @example
1338
+ * ```typescript
1339
+ * const currentUser = getUserInfo();
1340
+ * ```
1341
+ *
1342
+ * @throws {@link ErrorCode|InternalError} when SSO token is not valid.
1343
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1344
+ *
1345
+ * @returns Basic user info with user displayName, objectId and preferredUserName.
1346
+ *
1347
+ * @beta
1348
+ */
1349
+ getUserInfo(): UserInfo;
1350
+ private generateAuthServerError;
1351
+ }
1407
1352
 
1408
- /**
1409
- * Update log level helper.
1410
- *
1411
- * @param { LogLevel } level - log level in configuration
1412
- *
1413
- * @beta
1414
- */
1415
- export declare function setLogLevel(level: LogLevel): void;
1353
+ /**
1354
+ * Send an adaptive card message to a notification target.
1355
+ *
1356
+ * @param target - the notification target.
1357
+ * @param card - the adaptive card raw JSON.
1358
+ * @returns A `Promise` representing the asynchronous operation.
1359
+ *
1360
+ * @beta
1361
+ */
1362
+ export declare function sendAdaptiveCard(target: NotificationTarget, card: unknown): Promise<void>;
1416
1363
 
1417
- /**
1418
- * A {@link NotificationTarget} that represents a bot installation. Teams Bot could be installed into
1419
- * - Personal chat
1420
- * - Group chat
1421
- * - Team (by default the `General` channel)
1422
- *
1423
- * @remarks
1424
- * It's recommended to get bot installations from {@link ConversationBot.installations()}.
1425
- *
1426
- * @beta
1427
- */
1428
- export declare class TeamsBotInstallation implements NotificationTarget {
1429
- /**
1430
- * The bound `BotFrameworkAdapter`.
1431
- *
1432
- * @beta
1433
- */
1434
- readonly adapter: BotFrameworkAdapter;
1435
- /**
1436
- * The bound `ConversationReference`.
1437
- *
1438
- * @beta
1439
- */
1440
- readonly conversationReference: Partial<ConversationReference>;
1441
- /**
1442
- * Notification target type.
1443
- *
1444
- * @remarks
1445
- * - "Channel" means bot is installed into a team and notification will be sent to its "General" channel.
1446
- * - "Group" means bot is installed into a group chat.
1447
- * - "Person" means bot is installed into a personal scope and notification will be sent to personal chat.
1448
- *
1449
- * @beta
1450
- */
1451
- readonly type?: NotificationTargetType;
1452
- /**
1453
- * Constructor
1454
- *
1455
- * @remarks
1456
- * It's recommended to get bot installations from {@link ConversationBot.installations()}, instead of using this constructor.
1457
- *
1458
- * @param adapter - the bound `BotFrameworkAdapter`.
1459
- * @param conversationReference - the bound `ConversationReference`.
1460
- *
1461
- * @beta
1462
- */
1463
- constructor(adapter: BotFrameworkAdapter, conversationReference: Partial<ConversationReference>);
1464
- /**
1465
- * Send a plain text message.
1466
- *
1467
- * @param text - the plain text message.
1468
- * @returns A `Promise` representing the asynchronous operation.
1469
- *
1470
- * @beta
1471
- */
1472
- sendMessage(text: string): Promise<void>;
1473
- /**
1474
- * Send an adaptive card message.
1475
- *
1476
- * @param card - the adaptive card raw JSON.
1477
- * @returns A `Promise` representing the asynchronous operation.
1478
- *
1479
- * @beta
1480
- */
1481
- sendAdaptiveCard(card: unknown): Promise<void>;
1482
- /**
1483
- * Get channels from this bot installation.
1484
- *
1485
- * @returns an array of channels if bot is installed into a team, otherwise returns an empty array.
1486
- *
1487
- * @beta
1488
- */
1489
- channels(): Promise<Channel[]>;
1490
- /**
1491
- * Get members from this bot installation.
1492
- *
1493
- * @returns an array of members from where the bot is installed.
1494
- *
1495
- * @beta
1496
- */
1497
- members(): Promise<Member[]>;
1498
- }
1364
+ /**
1365
+ * Send a plain text message to a notification target.
1366
+ *
1367
+ * @param target - the notification target.
1368
+ * @param text - the plain text message.
1369
+ * @returns A `Promise` representing the asynchronous operation.
1370
+ *
1371
+ * @beta
1372
+ */
1373
+ export declare function sendMessage(target: NotificationTarget, text: string): Promise<void>;
1499
1374
 
1500
- /**
1501
- * Creates a new prompt that leverage Teams Single Sign On (SSO) support for bot to automatically sign in user and
1502
- * help receive oauth token, asks the user to consent if needed.
1503
- *
1504
- * @remarks
1505
- * The prompt will attempt to retrieve the users current token of the desired scopes and store it in
1506
- * the token store.
1507
- *
1508
- * User will be automatically signed in leveraging Teams support of Bot Single Sign On(SSO):
1509
- * https://docs.microsoft.com/en-us/microsoftteams/platform/bots/how-to/authentication/auth-aad-sso-bots
1510
- *
1511
- * @example
1512
- * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named
1513
- * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either
1514
- * `DialogContext.beginDialog()` or `DialogContext.prompt()`. The user will be prompted to sign in as
1515
- * needed and their access token will be passed as an argument to the callers next waterfall step:
1516
- *
1517
- * ```JavaScript
1518
- * const { ConversationState, MemoryStorage } = require('botbuilder');
1519
- * const { DialogSet, WaterfallDialog } = require('botbuilder-dialogs');
1520
- * const { TeamsBotSsoPrompt } = require('@microsoft/teamsfx');
1521
- *
1522
- * const convoState = new ConversationState(new MemoryStorage());
1523
- * const dialogState = convoState.createProperty('dialogState');
1524
- * const dialogs = new DialogSet(dialogState);
1525
- *
1526
- * dialogs.add(new TeamsBotSsoPrompt('TeamsBotSsoPrompt', {
1527
- * scopes: ["User.Read"],
1528
- * }));
1529
- *
1530
- * dialogs.add(new WaterfallDialog('taskNeedingLogin', [
1531
- * async (step) => {
1532
- * return await step.beginDialog('TeamsBotSsoPrompt');
1533
- * },
1534
- * async (step) => {
1535
- * const token = step.result;
1536
- * if (token) {
1537
- *
1538
- * // ... continue with task needing access token ...
1539
- *
1540
- * } else {
1541
- * await step.context.sendActivity(`Sorry... We couldn't log you in. Try again later.`);
1542
- * return await step.endDialog();
1543
- * }
1544
- * }
1545
- * ]));
1546
- * ```
1547
- *
1548
- * @beta
1549
- */
1550
- export declare class TeamsBotSsoPrompt extends Dialog {
1551
- private teamsfx;
1552
- private settings;
1553
- /**
1554
- * Constructor of TeamsBotSsoPrompt.
1555
- *
1556
- * @param {TeamsFx} teamsfx - Used to provide configuration and auth
1557
- * @param dialogId Unique ID of the dialog within its parent `DialogSet` or `ComponentDialog`.
1558
- * @param settings Settings used to configure the prompt.
1559
- *
1560
- * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1561
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1562
- *
1563
- * @beta
1564
- */
1565
- constructor(teamsfx: TeamsFx, dialogId: string, settings: TeamsBotSsoPromptSettings);
1566
- /**
1567
- * Called when a prompt dialog is pushed onto the dialog stack and is being activated.
1568
- * @remarks
1569
- * If the task is successful, the result indicates whether the prompt is still
1570
- * active after the turn has been processed by the prompt.
1571
- *
1572
- * @param dc The DialogContext for the current turn of the conversation.
1573
- *
1574
- * @throws {@link ErrorCode|InvalidParameter} when timeout property in teams bot sso prompt settings is not number or is not positive.
1575
- * @throws {@link ErrorCode|ChannelNotSupported} when bot channel is not MS Teams.
1576
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1577
- *
1578
- * @returns A `Promise` representing the asynchronous operation.
1579
- *
1580
- * @beta
1581
- */
1582
- beginDialog(dc: DialogContext): Promise<DialogTurnResult>;
1583
- /**
1584
- * Called when a prompt dialog is the active dialog and the user replied with a new activity.
1585
- *
1586
- * @remarks
1587
- * If the task is successful, the result indicates whether the dialog is still
1588
- * active after the turn has been processed by the dialog.
1589
- * The prompt generally continues to receive the user's replies until it accepts the
1590
- * user's reply as valid input for the prompt.
1591
- *
1592
- * @param dc The DialogContext for the current turn of the conversation.
1593
- *
1594
- * @returns A `Promise` representing the asynchronous operation.
1595
- *
1596
- * @throws {@link ErrorCode|ChannelNotSupported} when bot channel is not MS Teams.
1597
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1598
- *
1599
- * @beta
1600
- */
1601
- continueDialog(dc: DialogContext): Promise<DialogTurnResult>;
1602
- private loadAndValidateConfig;
1603
- /**
1604
- * Ensure bot is running in MS Teams since TeamsBotSsoPrompt is only supported in MS Teams channel.
1605
- * @param dc dialog context
1606
- * @throws {@link ErrorCode|ChannelNotSupported} if bot channel is not MS Teams
1607
- * @internal
1608
- */
1609
- private ensureMsTeamsChannel;
1610
- /**
1611
- * Send OAuthCard that tells Teams to obtain an authentication token for the bot application.
1612
- * For details see https://docs.microsoft.com/en-us/microsoftteams/platform/bots/how-to/authentication/auth-aad-sso-bots.
1613
- *
1614
- * @internal
1615
- */
1616
- private sendOAuthCardAsync;
1617
- /**
1618
- * Get sign in resource.
1619
- *
1620
- * @throws {@link ErrorCode|InvalidConfiguration} if client id, tenant id or initiate login endpoint is not found in config.
1621
- *
1622
- * @internal
1623
- */
1624
- private getSignInResource;
1625
- /**
1626
- * @internal
1627
- */
1628
- private recognizeToken;
1629
- /**
1630
- * @internal
1631
- */
1632
- private getTokenExchangeInvokeResponse;
1633
- /**
1634
- * @internal
1635
- */
1636
- private isTeamsVerificationInvoke;
1637
- /**
1638
- * @internal
1639
- */
1640
- private isTokenExchangeRequestInvoke;
1641
- /**
1642
- * @internal
1643
- */
1644
- private isTokenExchangeRequest;
1645
- }
1375
+ /**
1376
+ * Set custom log function. Use the function if it's set. Priority is lower than setLogger.
1377
+ *
1378
+ * @param {LogFunction} logFunction - custom log function. If it's undefined, custom log function will be cleared.
1379
+ *
1380
+ * @example
1381
+ * ```typescript
1382
+ * setLogFunction((level: LogLevel, message: string) => {
1383
+ * if (level === LogLevel.Error) {
1384
+ * console.log(message);
1385
+ * }
1386
+ * });
1387
+ * ```
1388
+ *
1389
+ * @beta
1390
+ */
1391
+ export declare function setLogFunction(logFunction?: LogFunction): void;
1646
1392
 
1647
- /**
1648
- * Settings used to configure an TeamsBotSsoPrompt instance.
1649
- *
1650
- * @beta
1651
- */
1652
- export declare interface TeamsBotSsoPromptSettings {
1653
- /**
1654
- * The array of strings that declare the desired permissions and the resources requested.
1655
- */
1656
- scopes: string[];
1657
- /**
1658
- * (Optional) number of milliseconds the prompt will wait for the user to authenticate.
1659
- * Defaults to a value `900,000` (15 minutes.)
1660
- */
1661
- timeout?: number;
1662
- /**
1663
- * (Optional) value indicating whether the TeamsBotSsoPrompt should end upon receiving an
1664
- * invalid message. Generally the TeamsBotSsoPrompt will end the auth flow when receives user
1665
- * message not related to the auth flow. Setting the flag to false ignores the user's message instead.
1666
- * Defaults to value `true`
1667
- */
1668
- endOnInvalidMessage?: boolean;
1669
- }
1393
+ /**
1394
+ * Set custom logger. Use the output functions if it's set. Priority is higher than setLogFunction.
1395
+ *
1396
+ * @param {Logger} logger - custom logger. If it's undefined, custom logger will be cleared.
1397
+ *
1398
+ * @example
1399
+ * ```typescript
1400
+ * setLogger({
1401
+ * verbose: console.debug,
1402
+ * info: console.info,
1403
+ * warn: console.warn,
1404
+ * error: console.error,
1405
+ * });
1406
+ * ```
1407
+ *
1408
+ * @beta
1409
+ */
1410
+ export declare function setLogger(logger?: Logger): void;
1670
1411
 
1671
- /**
1672
- * Token response provided by Teams Bot SSO prompt
1673
- *
1674
- * @beta
1675
- */
1676
- export declare interface TeamsBotSsoPromptTokenResponse extends TokenResponse {
1677
- /**
1678
- * SSO token for user
1679
- */
1680
- ssoToken: string;
1681
- /**
1682
- * Expire time of SSO token
1683
- */
1684
- ssoTokenExpiration: string;
1685
- }
1412
+ /**
1413
+ * Update log level helper.
1414
+ *
1415
+ * @param { LogLevel } level - log level in configuration
1416
+ *
1417
+ * @beta
1418
+ */
1419
+ export declare function setLogLevel(level: LogLevel): void;
1686
1420
 
1687
- /**
1688
- * A class providing credential and configuration.
1689
- * @beta
1690
- */
1691
- export declare class TeamsFx implements TeamsFxConfiguration {
1692
- private configuration;
1693
- private oboUserCredential?;
1694
- private appCredential?;
1695
- private identityType;
1696
- /**
1697
- * Constructor of TeamsFx
1698
- *
1699
- * @param {IdentityType} identityType - Choose user or app identity
1700
- * @param customConfig - key/value pairs of customized configuration that overrides default ones.
1701
- *
1702
- * @throws {@link ErrorCode|IdentityTypeNotSupported} when setting app identity in browser.
1703
- *
1704
- * @beta
1705
- */
1706
- constructor(identityType?: IdentityType, customConfig?: Record<string, string>);
1707
- /**
1708
- * Identity type set by user.
1709
- *
1710
- * @returns identity type.
1711
- * @beta
1712
- */
1713
- getIdentityType(): IdentityType;
1714
- /**
1715
- * Credential instance according to identity type choice.
1716
- *
1717
- * @remarks If user identity is chose, will return {@link TeamsUserCredential}
1718
- * in browser environment and {@link OnBehalfOfUserCredential} in NodeJS. If app
1719
- * identity is chose, will return {@link AppCredential}.
1720
- *
1721
- * @returns instance implements TokenCredential interface.
1722
- * @beta
1723
- */
1724
- getCredential(): TokenCredential;
1725
- /**
1726
- * Get user information.
1727
- * @returns UserInfo object.
1728
- * @beta
1729
- */
1730
- getUserInfo(): Promise<UserInfo>;
1731
- /**
1732
- * Popup login page to get user's access token with specific scopes.
1733
- *
1734
- * @remarks
1735
- * Only works in Teams client APP. User will be redirected to the authorization page to login and consent.
1736
- *
1737
- * @example
1738
- * ```typescript
1739
- * await teamsfx.login(["https://graph.microsoft.com/User.Read"]); // single scope using string array
1740
- * await teamsfx.login("https://graph.microsoft.com/User.Read"); // single scopes using string
1741
- * await teamsfx.login(["https://graph.microsoft.com/User.Read", "Calendars.Read"]); // multiple scopes using string array
1742
- * await teamsfx.login("https://graph.microsoft.com/User.Read Calendars.Read"); // multiple scopes using string
1743
- * ```
1744
- * @param scopes - The list of scopes for which the token will have access, before that, we will request user to consent.
1745
- *
1746
- * @throws {@link ErrorCode|InternalError} when failed to login with unknown error.
1747
- * @throws {@link ErrorCode|ConsentFailed} when user canceled or failed to consent.
1748
- * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1749
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
1750
- *
1751
- * @beta
1752
- */
1753
- login(scopes: string | string[]): Promise<void>;
1754
- /**
1755
- * Set SSO token when using user identity in NodeJS.
1756
- * @param {string} ssoToken - used for on behalf of user flow.
1757
- * @returns self instance.
1758
- * @beta
1759
- */
1760
- setSsoToken(ssoToken: string): TeamsFx;
1761
- /**
1762
- * Usually used by service plugins to retrieve specific config
1763
- * @param {string} key - configuration key.
1764
- * @returns value in configuration.
1765
- * @beta
1766
- */
1767
- getConfig(key: string): string;
1768
- /**
1769
- * Check the value of specific key.
1770
- * @param {string} key - configuration key.
1771
- * @returns true if corresponding value is not empty string.
1772
- * @beta
1773
- */
1774
- hasConfig(key: string): boolean;
1775
- /**
1776
- * Get all configurations.
1777
- * @returns key value mappings.
1778
- * @beta
1779
- */
1780
- getConfigs(): Record<string, string>;
1781
- /**
1782
- * Load configuration from environment variables.
1783
- */
1784
- private loadFromEnv;
1785
- }
1421
+ /**
1422
+ * A {@link NotificationTarget} that represents a bot installation. Teams Bot could be installed into
1423
+ * - Personal chat
1424
+ * - Group chat
1425
+ * - Team (by default the `General` channel)
1426
+ *
1427
+ * @remarks
1428
+ * It's recommended to get bot installations from {@link ConversationBot.installations()}.
1429
+ *
1430
+ * @beta
1431
+ */
1432
+ export declare class TeamsBotInstallation implements NotificationTarget {
1433
+ /**
1434
+ * The bound `BotFrameworkAdapter`.
1435
+ *
1436
+ * @beta
1437
+ */
1438
+ readonly adapter: BotFrameworkAdapter;
1439
+ /**
1440
+ * The bound `ConversationReference`.
1441
+ *
1442
+ * @beta
1443
+ */
1444
+ readonly conversationReference: Partial<ConversationReference>;
1445
+ /**
1446
+ * Notification target type.
1447
+ *
1448
+ * @remarks
1449
+ * - "Channel" means bot is installed into a team and notification will be sent to its "General" channel.
1450
+ * - "Group" means bot is installed into a group chat.
1451
+ * - "Person" means bot is installed into a personal scope and notification will be sent to personal chat.
1452
+ *
1453
+ * @beta
1454
+ */
1455
+ readonly type?: NotificationTargetType;
1456
+ /**
1457
+ * Constructor
1458
+ *
1459
+ * @remarks
1460
+ * It's recommended to get bot installations from {@link ConversationBot.installations()}, instead of using this constructor.
1461
+ *
1462
+ * @param adapter - the bound `BotFrameworkAdapter`.
1463
+ * @param conversationReference - the bound `ConversationReference`.
1464
+ *
1465
+ * @beta
1466
+ */
1467
+ constructor(adapter: BotFrameworkAdapter, conversationReference: Partial<ConversationReference>);
1468
+ /**
1469
+ * Send a plain text message.
1470
+ *
1471
+ * @param text - the plain text message.
1472
+ * @returns A `Promise` representing the asynchronous operation.
1473
+ *
1474
+ * @beta
1475
+ */
1476
+ sendMessage(text: string): Promise<void>;
1477
+ /**
1478
+ * Send an adaptive card message.
1479
+ *
1480
+ * @param card - the adaptive card raw JSON.
1481
+ * @returns A `Promise` representing the asynchronous operation.
1482
+ *
1483
+ * @beta
1484
+ */
1485
+ sendAdaptiveCard(card: unknown): Promise<void>;
1486
+ /**
1487
+ * Get channels from this bot installation.
1488
+ *
1489
+ * @returns an array of channels if bot is installed into a team, otherwise returns an empty array.
1490
+ *
1491
+ * @beta
1492
+ */
1493
+ channels(): Promise<Channel[]>;
1494
+ /**
1495
+ * Get members from this bot installation.
1496
+ *
1497
+ * @returns an array of members from where the bot is installed.
1498
+ *
1499
+ * @beta
1500
+ */
1501
+ members(): Promise<Member[]>;
1502
+ }
1786
1503
 
1787
- /**
1788
- * Interface for a command handler that can process command to a TeamsFx bot and return a response.
1789
- *
1790
- * @beta
1791
- */
1792
- export declare interface TeamsFxBotCommandHandler {
1793
- /**
1794
- * The string or regular expression patterns that can trigger this handler.
1795
- */
1796
- triggerPatterns: TriggerPatterns;
1797
- /**
1798
- * Handles a bot command received activity.
1799
- *
1800
- * @param context The bot context.
1801
- * @param message The command message the user types from Teams.
1802
- * @returns A `Promise` representing an activity or text to send as the command response.
1803
- */
1804
- handleCommandReceived(context: TurnContext, message: CommandMessage): Promise<string | Partial<Activity>>;
1805
- }
1504
+ /**
1505
+ * Creates a new prompt that leverage Teams Single Sign On (SSO) support for bot to automatically sign in user and
1506
+ * help receive oauth token, asks the user to consent if needed.
1507
+ *
1508
+ * @remarks
1509
+ * The prompt will attempt to retrieve the users current token of the desired scopes and store it in
1510
+ * the token store.
1511
+ *
1512
+ * User will be automatically signed in leveraging Teams support of Bot Single Sign On(SSO):
1513
+ * https://docs.microsoft.com/en-us/microsoftteams/platform/bots/how-to/authentication/auth-aad-sso-bots
1514
+ *
1515
+ * @example
1516
+ * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named
1517
+ * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either
1518
+ * `DialogContext.beginDialog()` or `DialogContext.prompt()`. The user will be prompted to sign in as
1519
+ * needed and their access token will be passed as an argument to the callers next waterfall step:
1520
+ *
1521
+ * ```JavaScript
1522
+ * const { ConversationState, MemoryStorage } = require('botbuilder');
1523
+ * const { DialogSet, WaterfallDialog } = require('botbuilder-dialogs');
1524
+ * const { TeamsBotSsoPrompt } = require('@microsoft/teamsfx');
1525
+ *
1526
+ * const convoState = new ConversationState(new MemoryStorage());
1527
+ * const dialogState = convoState.createProperty('dialogState');
1528
+ * const dialogs = new DialogSet(dialogState);
1529
+ *
1530
+ * dialogs.add(new TeamsBotSsoPrompt('TeamsBotSsoPrompt', {
1531
+ * scopes: ["User.Read"],
1532
+ * }));
1533
+ *
1534
+ * dialogs.add(new WaterfallDialog('taskNeedingLogin', [
1535
+ * async (step) => {
1536
+ * return await step.beginDialog('TeamsBotSsoPrompt');
1537
+ * },
1538
+ * async (step) => {
1539
+ * const token = step.result;
1540
+ * if (token) {
1541
+ *
1542
+ * // ... continue with task needing access token ...
1543
+ *
1544
+ * } else {
1545
+ * await step.context.sendActivity(`Sorry... We couldn't log you in. Try again later.`);
1546
+ * return await step.endDialog();
1547
+ * }
1548
+ * }
1549
+ * ]));
1550
+ * ```
1551
+ *
1552
+ * @beta
1553
+ */
1554
+ export declare class TeamsBotSsoPrompt extends Dialog {
1555
+ private teamsfx;
1556
+ private settings;
1557
+ /**
1558
+ * Constructor of TeamsBotSsoPrompt.
1559
+ *
1560
+ * @param {TeamsFx} teamsfx - Used to provide configuration and auth
1561
+ * @param dialogId Unique ID of the dialog within its parent `DialogSet` or `ComponentDialog`.
1562
+ * @param settings Settings used to configure the prompt.
1563
+ *
1564
+ * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1565
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1566
+ *
1567
+ * @beta
1568
+ */
1569
+ constructor(teamsfx: TeamsFx, dialogId: string, settings: TeamsBotSsoPromptSettings);
1570
+ /**
1571
+ * Called when a prompt dialog is pushed onto the dialog stack and is being activated.
1572
+ * @remarks
1573
+ * If the task is successful, the result indicates whether the prompt is still
1574
+ * active after the turn has been processed by the prompt.
1575
+ *
1576
+ * @param dc The DialogContext for the current turn of the conversation.
1577
+ *
1578
+ * @throws {@link ErrorCode|InvalidParameter} when timeout property in teams bot sso prompt settings is not number or is not positive.
1579
+ * @throws {@link ErrorCode|ChannelNotSupported} when bot channel is not MS Teams.
1580
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1581
+ *
1582
+ * @returns A `Promise` representing the asynchronous operation.
1583
+ *
1584
+ * @beta
1585
+ */
1586
+ beginDialog(dc: DialogContext): Promise<DialogTurnResult>;
1587
+ /**
1588
+ * Called when a prompt dialog is the active dialog and the user replied with a new activity.
1589
+ *
1590
+ * @remarks
1591
+ * If the task is successful, the result indicates whether the dialog is still
1592
+ * active after the turn has been processed by the dialog.
1593
+ * The prompt generally continues to receive the user's replies until it accepts the
1594
+ * user's reply as valid input for the prompt.
1595
+ *
1596
+ * @param dc The DialogContext for the current turn of the conversation.
1597
+ *
1598
+ * @returns A `Promise` representing the asynchronous operation.
1599
+ *
1600
+ * @throws {@link ErrorCode|ChannelNotSupported} when bot channel is not MS Teams.
1601
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1602
+ *
1603
+ * @beta
1604
+ */
1605
+ continueDialog(dc: DialogContext): Promise<DialogTurnResult>;
1606
+ private loadAndValidateConfig;
1607
+ /**
1608
+ * Ensure bot is running in MS Teams since TeamsBotSsoPrompt is only supported in MS Teams channel.
1609
+ * @param dc dialog context
1610
+ * @throws {@link ErrorCode|ChannelNotSupported} if bot channel is not MS Teams
1611
+ * @internal
1612
+ */
1613
+ private ensureMsTeamsChannel;
1614
+ /**
1615
+ * Send OAuthCard that tells Teams to obtain an authentication token for the bot application.
1616
+ * For details see https://docs.microsoft.com/en-us/microsoftteams/platform/bots/how-to/authentication/auth-aad-sso-bots.
1617
+ *
1618
+ * @internal
1619
+ */
1620
+ private sendOAuthCardAsync;
1621
+ /**
1622
+ * Get sign in resource.
1623
+ *
1624
+ * @throws {@link ErrorCode|InvalidConfiguration} if client id, tenant id or initiate login endpoint is not found in config.
1625
+ *
1626
+ * @internal
1627
+ */
1628
+ private getSignInResource;
1629
+ /**
1630
+ * @internal
1631
+ */
1632
+ private recognizeToken;
1633
+ /**
1634
+ * @internal
1635
+ */
1636
+ private getTokenExchangeInvokeResponse;
1637
+ /**
1638
+ * @internal
1639
+ */
1640
+ private isTeamsVerificationInvoke;
1641
+ /**
1642
+ * @internal
1643
+ */
1644
+ private isTokenExchangeRequestInvoke;
1645
+ /**
1646
+ * @internal
1647
+ */
1648
+ private isTokenExchangeRequest;
1649
+ }
1806
1650
 
1807
- /**
1808
- * TeamsFx interface that provides credential and configuration.
1809
- * @beta
1810
- */
1811
- declare interface TeamsFxConfiguration {
1812
- /**
1813
- * Identity type set by user.
1814
- *
1815
- * @returns identity type.
1816
- * @beta
1817
- */
1818
- getIdentityType(): IdentityType;
1819
- /**
1820
- * Credential instance according to identity type choice.
1821
- *
1822
- * @remarks If user identity is chose, will return {@link TeamsUserCredential}
1823
- * in browser environment and {@link OnBehalfOfUserCredential} in NodeJS. If app
1824
- * identity is chose, will return {@link AppCredential}.
1825
- *
1826
- * @returns instance implements TokenCredential interface.
1827
- * @beta
1828
- */
1829
- getCredential(): TokenCredential;
1830
- /**
1831
- * Get user information.
1832
- * @returns UserInfo object.
1833
- * @beta
1834
- */
1835
- getUserInfo(): Promise<UserInfo>;
1836
- /**
1837
- * Popup login page to get user's access token with specific scopes.
1838
- *
1839
- * @remarks
1840
- * Only works in Teams client APP. User will be redirected to the authorization page to login and consent.
1841
- *
1842
- * @example
1843
- * ```typescript
1844
- * await teamsfx.login(["https://graph.microsoft.com/User.Read"]); // single scope using string array
1845
- * await teamsfx.login("https://graph.microsoft.com/User.Read"); // single scopes using string
1846
- * await teamsfx.login(["https://graph.microsoft.com/User.Read", "Calendars.Read"]); // multiple scopes using string array
1847
- * await teamsfx.login("https://graph.microsoft.com/User.Read Calendars.Read"); // multiple scopes using string
1848
- * ```
1849
- * @param scopes - The list of scopes for which the token will have access, before that, we will request user to consent.
1850
- *
1851
- * @throws {@link ErrorCode|InternalError} when failed to login with unknown error.
1852
- * @throws {@link ErrorCode|ConsentFailed} when user canceled or failed to consent.
1853
- * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1854
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
1855
- *
1856
- * @beta
1857
- */
1858
- login(scopes: string | string[]): Promise<void>;
1859
- /**
1860
- * Set SSO token when using user identity in NodeJS.
1861
- * @param {string} ssoToken - used for on behalf of user flow.
1862
- * @returns self instance.
1863
- * @beta
1864
- */
1865
- setSsoToken(ssoToken: string): TeamsFxConfiguration;
1866
- /**
1867
- * Usually used by service plugins to retrieve specific config
1868
- * @param {string} key - configuration key.
1869
- * @returns value in configuration.
1870
- * @beta
1871
- */
1872
- getConfig(key: string): string;
1873
- /**
1874
- * Check the value of specific key.
1875
- * @param {string} key - configuration key.
1876
- * @returns true if corresponding value is not empty string.
1877
- * @beta
1878
- */
1879
- hasConfig(key: string): boolean;
1880
- /**
1881
- * Get all configurations.
1882
- * @returns key value mappings.
1883
- * @beta
1884
- */
1885
- getConfigs(): Record<string, string>;
1886
- }
1651
+ /**
1652
+ * Settings used to configure an TeamsBotSsoPrompt instance.
1653
+ *
1654
+ * @beta
1655
+ */
1656
+ export declare interface TeamsBotSsoPromptSettings {
1657
+ /**
1658
+ * The array of strings that declare the desired permissions and the resources requested.
1659
+ */
1660
+ scopes: string[];
1661
+ /**
1662
+ * (Optional) number of milliseconds the prompt will wait for the user to authenticate.
1663
+ * Defaults to a value `900,000` (15 minutes.)
1664
+ */
1665
+ timeout?: number;
1666
+ /**
1667
+ * (Optional) value indicating whether the TeamsBotSsoPrompt should end upon receiving an
1668
+ * invalid message. Generally the TeamsBotSsoPrompt will end the auth flow when receives user
1669
+ * message not related to the auth flow. Setting the flag to false ignores the user's message instead.
1670
+ * Defaults to value `true`
1671
+ */
1672
+ endOnInvalidMessage?: boolean;
1673
+ }
1887
1674
 
1888
- /**
1889
- * Represent Teams current user's identity, and it is used within Teams client applications.
1890
- *
1891
- * @remarks
1892
- * Can only be used within Teams.
1893
- *
1894
- * @beta
1895
- */
1896
- export declare class TeamsUserCredential implements TokenCredential {
1897
- /**
1898
- * Constructor of TeamsUserCredential.
1899
- * @remarks
1900
- * Can only be used within Teams.
1901
- * @beta
1902
- */
1903
- constructor(authConfig: AuthenticationConfiguration);
1904
- /**
1905
- * Popup login page to get user's access token with specific scopes.
1906
- * @remarks
1907
- * Can only be used within Teams.
1908
- * @beta
1909
- */
1910
- login(scopes: string | string[]): Promise<void>;
1911
- /**
1912
- * Get access token from credential.
1913
- * @remarks
1914
- * Can only be used within Teams.
1915
- * @beta
1916
- */
1917
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
1918
- /**
1919
- * Get basic user info from SSO token
1920
- * @remarks
1921
- * Can only be used within Teams.
1922
- * @beta
1923
- */
1924
- getUserInfo(): Promise<UserInfo>;
1925
- }
1675
+ /**
1676
+ * Token response provided by Teams Bot SSO prompt
1677
+ *
1678
+ * @beta
1679
+ */
1680
+ export declare interface TeamsBotSsoPromptTokenResponse extends TokenResponse {
1681
+ /**
1682
+ * SSO token for user
1683
+ */
1684
+ ssoToken: string;
1685
+ /**
1686
+ * Expire time of SSO token
1687
+ */
1688
+ ssoTokenExpiration: string;
1689
+ }
1926
1690
 
1927
- /**
1928
- * The trigger pattern used to trigger a {@link TeamsFxBotCommandHandler} instance.
1929
- */
1930
- export declare type TriggerPatterns = string | RegExp | (string | RegExp)[];
1691
+ /**
1692
+ * A class providing credential and configuration.
1693
+ * @beta
1694
+ */
1695
+ export declare class TeamsFx implements TeamsFxConfiguration {
1696
+ private configuration;
1697
+ private oboUserCredential?;
1698
+ private appCredential?;
1699
+ private identityType;
1700
+ /**
1701
+ * Constructor of TeamsFx
1702
+ *
1703
+ * @param {IdentityType} identityType - Choose user or app identity
1704
+ * @param customConfig - key/value pairs of customized configuration that overrides default ones.
1705
+ *
1706
+ * @throws {@link ErrorCode|IdentityTypeNotSupported} when setting app identity in browser.
1707
+ *
1708
+ * @beta
1709
+ */
1710
+ constructor(identityType?: IdentityType, customConfig?: Record<string, string>);
1711
+ /**
1712
+ * Identity type set by user.
1713
+ *
1714
+ * @returns identity type.
1715
+ * @beta
1716
+ */
1717
+ getIdentityType(): IdentityType;
1718
+ /**
1719
+ * Credential instance according to identity type choice.
1720
+ *
1721
+ * @remarks If user identity is chose, will return {@link TeamsUserCredential}
1722
+ * in browser environment and {@link OnBehalfOfUserCredential} in NodeJS. If app
1723
+ * identity is chose, will return {@link AppCredential}.
1724
+ *
1725
+ * @returns instance implements TokenCredential interface.
1726
+ * @beta
1727
+ */
1728
+ getCredential(): TokenCredential;
1729
+ /**
1730
+ * Get user information.
1731
+ * @returns UserInfo object.
1732
+ * @beta
1733
+ */
1734
+ getUserInfo(): Promise<UserInfo>;
1735
+ /**
1736
+ * Popup login page to get user's access token with specific scopes.
1737
+ *
1738
+ * @remarks
1739
+ * Only works in Teams client APP. User will be redirected to the authorization page to login and consent.
1740
+ *
1741
+ * @example
1742
+ * ```typescript
1743
+ * await teamsfx.login(["https://graph.microsoft.com/User.Read"]); // single scope using string array
1744
+ * await teamsfx.login("https://graph.microsoft.com/User.Read"); // single scopes using string
1745
+ * await teamsfx.login(["https://graph.microsoft.com/User.Read", "Calendars.Read"]); // multiple scopes using string array
1746
+ * await teamsfx.login("https://graph.microsoft.com/User.Read Calendars.Read"); // multiple scopes using string
1747
+ * ```
1748
+ * @param scopes - The list of scopes for which the token will have access, before that, we will request user to consent.
1749
+ *
1750
+ * @throws {@link ErrorCode|InternalError} when failed to login with unknown error.
1751
+ * @throws {@link ErrorCode|ConsentFailed} when user canceled or failed to consent.
1752
+ * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1753
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
1754
+ *
1755
+ * @beta
1756
+ */
1757
+ login(scopes: string | string[]): Promise<void>;
1758
+ /**
1759
+ * Set SSO token when using user identity in NodeJS.
1760
+ * @param {string} ssoToken - used for on behalf of user flow.
1761
+ * @returns self instance.
1762
+ * @beta
1763
+ */
1764
+ setSsoToken(ssoToken: string): TeamsFx;
1765
+ /**
1766
+ * Usually used by service plugins to retrieve specific config
1767
+ * @param {string} key - configuration key.
1768
+ * @returns value in configuration.
1769
+ * @beta
1770
+ */
1771
+ getConfig(key: string): string;
1772
+ /**
1773
+ * Check the value of specific key.
1774
+ * @param {string} key - configuration key.
1775
+ * @returns true if corresponding value is not empty string.
1776
+ * @beta
1777
+ */
1778
+ hasConfig(key: string): boolean;
1779
+ /**
1780
+ * Get all configurations.
1781
+ * @returns key value mappings.
1782
+ * @beta
1783
+ */
1784
+ getConfigs(): Record<string, string>;
1785
+ /**
1786
+ * Load configuration from environment variables.
1787
+ */
1788
+ private loadFromEnv;
1789
+ }
1790
+
1791
+ /**
1792
+ * Interface for a command handler that can process command to a TeamsFx bot and return a response.
1793
+ *
1794
+ * @beta
1795
+ */
1796
+ export declare interface TeamsFxBotCommandHandler {
1797
+ /**
1798
+ * The string or regular expression patterns that can trigger this handler.
1799
+ */
1800
+ triggerPatterns: TriggerPatterns;
1801
+ /**
1802
+ * Handles a bot command received activity.
1803
+ *
1804
+ * @param context The bot context.
1805
+ * @param message The command message the user types from Teams.
1806
+ * @returns A `Promise` representing an activity or text to send as the command response.
1807
+ */
1808
+ handleCommandReceived(context: TurnContext, message: CommandMessage): Promise<string | Partial<Activity>>;
1809
+ }
1810
+
1811
+ /**
1812
+ * TeamsFx interface that provides credential and configuration.
1813
+ * @beta
1814
+ */
1815
+ declare interface TeamsFxConfiguration {
1816
+ /**
1817
+ * Identity type set by user.
1818
+ *
1819
+ * @returns identity type.
1820
+ * @beta
1821
+ */
1822
+ getIdentityType(): IdentityType;
1823
+ /**
1824
+ * Credential instance according to identity type choice.
1825
+ *
1826
+ * @remarks If user identity is chose, will return {@link TeamsUserCredential}
1827
+ * in browser environment and {@link OnBehalfOfUserCredential} in NodeJS. If app
1828
+ * identity is chose, will return {@link AppCredential}.
1829
+ *
1830
+ * @returns instance implements TokenCredential interface.
1831
+ * @beta
1832
+ */
1833
+ getCredential(): TokenCredential;
1834
+ /**
1835
+ * Get user information.
1836
+ * @returns UserInfo object.
1837
+ * @beta
1838
+ */
1839
+ getUserInfo(): Promise<UserInfo>;
1840
+ /**
1841
+ * Popup login page to get user's access token with specific scopes.
1842
+ *
1843
+ * @remarks
1844
+ * Only works in Teams client APP. User will be redirected to the authorization page to login and consent.
1845
+ *
1846
+ * @example
1847
+ * ```typescript
1848
+ * await teamsfx.login(["https://graph.microsoft.com/User.Read"]); // single scope using string array
1849
+ * await teamsfx.login("https://graph.microsoft.com/User.Read"); // single scopes using string
1850
+ * await teamsfx.login(["https://graph.microsoft.com/User.Read", "Calendars.Read"]); // multiple scopes using string array
1851
+ * await teamsfx.login("https://graph.microsoft.com/User.Read Calendars.Read"); // multiple scopes using string
1852
+ * ```
1853
+ * @param scopes - The list of scopes for which the token will have access, before that, we will request user to consent.
1854
+ *
1855
+ * @throws {@link ErrorCode|InternalError} when failed to login with unknown error.
1856
+ * @throws {@link ErrorCode|ConsentFailed} when user canceled or failed to consent.
1857
+ * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
1858
+ * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
1859
+ *
1860
+ * @beta
1861
+ */
1862
+ login(scopes: string | string[]): Promise<void>;
1863
+ /**
1864
+ * Set SSO token when using user identity in NodeJS.
1865
+ * @param {string} ssoToken - used for on behalf of user flow.
1866
+ * @returns self instance.
1867
+ * @beta
1868
+ */
1869
+ setSsoToken(ssoToken: string): TeamsFxConfiguration;
1870
+ /**
1871
+ * Usually used by service plugins to retrieve specific config
1872
+ * @param {string} key - configuration key.
1873
+ * @returns value in configuration.
1874
+ * @beta
1875
+ */
1876
+ getConfig(key: string): string;
1877
+ /**
1878
+ * Check the value of specific key.
1879
+ * @param {string} key - configuration key.
1880
+ * @returns true if corresponding value is not empty string.
1881
+ * @beta
1882
+ */
1883
+ hasConfig(key: string): boolean;
1884
+ /**
1885
+ * Get all configurations.
1886
+ * @returns key value mappings.
1887
+ * @beta
1888
+ */
1889
+ getConfigs(): Record<string, string>;
1890
+ }
1931
1891
 
1932
- /**
1933
- * UserInfo with user displayName, objectId and preferredUserName.
1934
- *
1935
- * @beta
1936
- */
1937
- export declare interface UserInfo {
1938
- /**
1939
- * User Display Name.
1940
- *
1941
- * @readonly
1942
- */
1943
- displayName: string;
1944
- /**
1945
- * User unique reference within the Azure Active Directory domain.
1946
- *
1947
- * @readonly
1948
- */
1949
- objectId: string;
1950
- /**
1951
- * Usually be the email address.
1952
- *
1953
- * @readonly
1954
- */
1955
- preferredUserName: string;
1956
- }
1892
+ /**
1893
+ * Represent Teams current user's identity, and it is used within Teams client applications.
1894
+ *
1895
+ * @remarks
1896
+ * Can only be used within Teams.
1897
+ *
1898
+ * @beta
1899
+ */
1900
+ export declare class TeamsUserCredential implements TokenCredential {
1901
+ /**
1902
+ * Constructor of TeamsUserCredential.
1903
+ * @remarks
1904
+ * Can only be used within Teams.
1905
+ * @beta
1906
+ */
1907
+ constructor(authConfig: AuthenticationConfiguration);
1908
+ /**
1909
+ * Popup login page to get user's access token with specific scopes.
1910
+ * @remarks
1911
+ * Can only be used within Teams.
1912
+ * @beta
1913
+ */
1914
+ login(scopes: string | string[]): Promise<void>;
1915
+ /**
1916
+ * Get access token from credential.
1917
+ * @remarks
1918
+ * Can only be used within Teams.
1919
+ * @beta
1920
+ */
1921
+ getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
1922
+ /**
1923
+ * Get basic user info from SSO token
1924
+ * @remarks
1925
+ * Can only be used within Teams.
1926
+ * @beta
1927
+ */
1928
+ getUserInfo(): Promise<UserInfo>;
1929
+ }
1930
+
1931
+ /**
1932
+ * The trigger pattern used to trigger a {@link TeamsFxBotCommandHandler} instance.
1933
+ */
1934
+ export declare type TriggerPatterns = string | RegExp | (string | RegExp)[];
1935
+
1936
+ /**
1937
+ * UserInfo with user displayName, objectId and preferredUserName.
1938
+ *
1939
+ * @beta
1940
+ */
1941
+ export declare interface UserInfo {
1942
+ /**
1943
+ * User Display Name.
1944
+ *
1945
+ * @readonly
1946
+ */
1947
+ displayName: string;
1948
+ /**
1949
+ * User unique reference within the Azure Active Directory domain.
1950
+ *
1951
+ * @readonly
1952
+ */
1953
+ objectId: string;
1954
+ /**
1955
+ * Usually be the email address.
1956
+ *
1957
+ * @readonly
1958
+ */
1959
+ preferredUserName: string;
1960
+ }
1957
1961
 
1958
- export { }
1962
+ export { }