@microsoft/teamsfx 0.6.3-alpha.633d9d21e.0 → 0.6.3-alpha.6b8bcebfe.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm2017.js +117 -10
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +192 -35
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +121 -9
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +197 -33
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +3 -3
- package/types/teamsfx.d.ts +1366 -1262
package/types/teamsfx.d.ts
CHANGED
|
@@ -31,6 +31,59 @@ import { TurnContext as TurnContext_2 } from 'botbuilder';
|
|
|
31
31
|
import { WebRequest } from 'botbuilder';
|
|
32
32
|
import { WebResponse } from 'botbuilder';
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Define available location for API Key location
|
|
36
|
+
*
|
|
37
|
+
* @beta
|
|
38
|
+
*/
|
|
39
|
+
export declare enum ApiKeyLocation {
|
|
40
|
+
/**
|
|
41
|
+
* The API Key is placed in request header
|
|
42
|
+
*/
|
|
43
|
+
Header = 0,
|
|
44
|
+
/**
|
|
45
|
+
* The API Key is placed in query parameter
|
|
46
|
+
*/
|
|
47
|
+
QueryParams = 1
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Provider that handles API Key authentication
|
|
52
|
+
*
|
|
53
|
+
* @beta
|
|
54
|
+
*/
|
|
55
|
+
export declare class ApiKeyProvider implements AuthProvider {
|
|
56
|
+
private keyName;
|
|
57
|
+
private keyValue;
|
|
58
|
+
private keyLocation;
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @param { string } keyName - The name of request header or query parameter that specifies API Key
|
|
62
|
+
* @param { string } keyValue - The value of API Key
|
|
63
|
+
* @param { ApiKeyLocation } keyLocation - The location of API Key: request header or query parameter.
|
|
64
|
+
*
|
|
65
|
+
* @throws {@link ErrorCode|InvalidParameter} - when key name or key value is empty.
|
|
66
|
+
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
|
67
|
+
*
|
|
68
|
+
* @beta
|
|
69
|
+
*/
|
|
70
|
+
constructor(keyName: string, keyValue: string, keyLocation: ApiKeyLocation);
|
|
71
|
+
/**
|
|
72
|
+
* Adds authentication info to http requests
|
|
73
|
+
*
|
|
74
|
+
* @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
|
|
75
|
+
* Refer https://axios-http.com/docs/req_config for detailed document.
|
|
76
|
+
*
|
|
77
|
+
* @returns Updated axios request config.
|
|
78
|
+
*
|
|
79
|
+
* @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when API key already exists in request header or url query parameter.
|
|
80
|
+
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
|
81
|
+
*
|
|
82
|
+
* @beta
|
|
83
|
+
*/
|
|
84
|
+
AddAuthenticationInfo(config: AxiosRequestConfig): Promise<AxiosRequestConfig>;
|
|
85
|
+
}
|
|
86
|
+
|
|
34
87
|
/**
|
|
35
88
|
* Represent Microsoft 365 tenant identity, and it is usually used when user is not involved like time-triggered automation job.
|
|
36
89
|
*
|
|
@@ -154,7 +207,7 @@ export declare interface AuthProvider {
|
|
|
154
207
|
/**
|
|
155
208
|
* Adds authentication info to http requests
|
|
156
209
|
*
|
|
157
|
-
* @param config - Contains all the request information and can be updated to include extra authentication info.
|
|
210
|
+
* @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
|
|
158
211
|
* Refer https://axios-http.com/docs/req_config for detailed document.
|
|
159
212
|
*
|
|
160
213
|
* @beta
|
|
@@ -162,6 +215,43 @@ export declare interface AuthProvider {
|
|
|
162
215
|
AddAuthenticationInfo: (config: AxiosRequestConfig) => Promise<AxiosRequestConfig>;
|
|
163
216
|
}
|
|
164
217
|
|
|
218
|
+
export { AxiosInstance }
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Provider that handles Basic authentication
|
|
222
|
+
*
|
|
223
|
+
* @beta
|
|
224
|
+
*/
|
|
225
|
+
export declare class BasicAuthProvider implements AuthProvider {
|
|
226
|
+
private userName;
|
|
227
|
+
private password;
|
|
228
|
+
/**
|
|
229
|
+
*
|
|
230
|
+
* @param { string } userName - Username used in basic auth
|
|
231
|
+
* @param { string } password - Password used in basic auth
|
|
232
|
+
*
|
|
233
|
+
* @throws {@link ErrorCode|InvalidParameter} - when username or password is empty.
|
|
234
|
+
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
|
235
|
+
*
|
|
236
|
+
* @beta
|
|
237
|
+
*/
|
|
238
|
+
constructor(userName: string, password: string);
|
|
239
|
+
/**
|
|
240
|
+
* Adds authentication info to http requests
|
|
241
|
+
*
|
|
242
|
+
* @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
|
|
243
|
+
* Refer https://axios-http.com/docs/req_config for detailed document.
|
|
244
|
+
*
|
|
245
|
+
* @returns Updated axios request config.
|
|
246
|
+
*
|
|
247
|
+
* @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header or auth property already exists in request configuration.
|
|
248
|
+
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
|
249
|
+
*
|
|
250
|
+
* @beta
|
|
251
|
+
*/
|
|
252
|
+
AddAuthenticationInfo(config: AxiosRequestConfig): Promise<AxiosRequestConfig>;
|
|
253
|
+
}
|
|
254
|
+
|
|
165
255
|
/**
|
|
166
256
|
* Provider that handles Bearer Token authentication
|
|
167
257
|
*
|
|
@@ -170,7 +260,7 @@ export declare interface AuthProvider {
|
|
|
170
260
|
export declare class BearerTokenAuthProvider implements AuthProvider {
|
|
171
261
|
private getToken;
|
|
172
262
|
/**
|
|
173
|
-
* @param getToken Function that returns the content of bearer token used in http request
|
|
263
|
+
* @param { () => Promise<string> } getToken - Function that returns the content of bearer token used in http request
|
|
174
264
|
*
|
|
175
265
|
* @beta
|
|
176
266
|
*/
|
|
@@ -178,9 +268,13 @@ export declare class BearerTokenAuthProvider implements AuthProvider {
|
|
|
178
268
|
/**
|
|
179
269
|
* Adds authentication info to http requests
|
|
180
270
|
*
|
|
181
|
-
* @param config - Contains all the request information and can be updated to include extra authentication info.
|
|
271
|
+
* @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
|
|
182
272
|
* Refer https://axios-http.com/docs/req_config for detailed document.
|
|
183
273
|
*
|
|
274
|
+
* @returns Updated axios request config.
|
|
275
|
+
*
|
|
276
|
+
* @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header already exists in request configuration.
|
|
277
|
+
*
|
|
184
278
|
* @beta
|
|
185
279
|
*/
|
|
186
280
|
AddAuthenticationInfo(config: AxiosRequestConfig): Promise<AxiosRequestConfig>;
|
|
@@ -197,6 +291,8 @@ export declare class CertificateAuthProvider implements AuthProvider {
|
|
|
197
291
|
*
|
|
198
292
|
* @param { SecureContextOptions } certOption - information about the cert used in http requests
|
|
199
293
|
*
|
|
294
|
+
* @throws {@link ErrorCode|InvalidParameter} - when cert option is empty.
|
|
295
|
+
*
|
|
200
296
|
* @beta
|
|
201
297
|
*/
|
|
202
298
|
constructor(certOption: SecureContextOptions);
|
|
@@ -584,1275 +680,1283 @@ export declare function createMicrosoftGraphClient(teamsfx: TeamsFxConfiguration
|
|
|
584
680
|
*
|
|
585
681
|
* @param { string | Buffer } cert - The cert chain in PEM format
|
|
586
682
|
* @param { string | Buffer } key - The private key for the cert chain
|
|
587
|
-
* @param { string
|
|
588
|
-
*
|
|
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
|
|
589
781
|
*
|
|
590
|
-
* @
|
|
782
|
+
* @readonly
|
|
783
|
+
*/
|
|
784
|
+
code: string | undefined;
|
|
785
|
+
/**
|
|
786
|
+
* Constructor of ErrorWithCode.
|
|
591
787
|
*
|
|
592
|
-
* @
|
|
788
|
+
* @param {string} message - error message.
|
|
789
|
+
* @param {ErrorCode} code - error code.
|
|
593
790
|
*
|
|
791
|
+
* @beta
|
|
594
792
|
*/
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
/**
|
|
598
|
-
* Helper to create SecureContextOptions from PFX format cert
|
|
599
|
-
*
|
|
600
|
-
* @param { string | Buffer } pfx - The content of .pfx file
|
|
601
|
-
* @param { string? } passphrase - Optional. The passphrase of .pfx file
|
|
602
|
-
*
|
|
603
|
-
* @returns Instance of SecureContextOptions
|
|
604
|
-
*
|
|
605
|
-
* @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
|
|
606
|
-
*
|
|
607
|
-
*/
|
|
608
|
-
export declare function createPfxCertOption(pfx: string | Buffer, passphrase?: string): SecureContextOptions;
|
|
609
|
-
|
|
610
|
-
/**
|
|
611
|
-
* Error code to trace the error types.
|
|
612
|
-
* @beta
|
|
613
|
-
*/
|
|
614
|
-
export declare enum ErrorCode {
|
|
615
|
-
/**
|
|
616
|
-
* Invalid parameter error.
|
|
617
|
-
*/
|
|
618
|
-
InvalidParameter = "InvalidParameter",
|
|
619
|
-
/**
|
|
620
|
-
* Invalid configuration error.
|
|
621
|
-
*/
|
|
622
|
-
InvalidConfiguration = "InvalidConfiguration",
|
|
623
|
-
/**
|
|
624
|
-
* Invalid certificate error.
|
|
625
|
-
*/
|
|
626
|
-
InvalidCertificate = "InvalidCertificate",
|
|
627
|
-
/**
|
|
628
|
-
* Internal error.
|
|
629
|
-
*/
|
|
630
|
-
InternalError = "InternalError",
|
|
631
|
-
/**
|
|
632
|
-
* Channel is not supported error.
|
|
633
|
-
*/
|
|
634
|
-
ChannelNotSupported = "ChannelNotSupported",
|
|
635
|
-
/**
|
|
636
|
-
* Runtime is not supported error.
|
|
637
|
-
*/
|
|
638
|
-
RuntimeNotSupported = "RuntimeNotSupported",
|
|
639
|
-
/**
|
|
640
|
-
* User failed to finish the AAD consent flow failed.
|
|
641
|
-
*/
|
|
642
|
-
ConsentFailed = "ConsentFailed",
|
|
643
|
-
/**
|
|
644
|
-
* The user or administrator has not consented to use the application error.
|
|
645
|
-
*/
|
|
646
|
-
UiRequiredError = "UiRequiredError",
|
|
647
|
-
/**
|
|
648
|
-
* Token is not within its valid time range error.
|
|
649
|
-
*/
|
|
650
|
-
TokenExpiredError = "TokenExpiredError",
|
|
651
|
-
/**
|
|
652
|
-
* Call service (AAD or simple authentication server) failed.
|
|
653
|
-
*/
|
|
654
|
-
ServiceError = "ServiceError",
|
|
655
|
-
/**
|
|
656
|
-
* Operation failed.
|
|
657
|
-
*/
|
|
658
|
-
FailedOperation = "FailedOperation",
|
|
659
|
-
/**
|
|
660
|
-
* Invalid response error.
|
|
661
|
-
*/
|
|
662
|
-
InvalidResponse = "InvalidResponse",
|
|
663
|
-
/**
|
|
664
|
-
* Identity type error.
|
|
665
|
-
*/
|
|
666
|
-
IdentityTypeNotSupported = "IdentityTypeNotSupported"
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
/**
|
|
670
|
-
* Error class with code and message thrown by the SDK.
|
|
671
|
-
*
|
|
672
|
-
* @beta
|
|
673
|
-
*/
|
|
674
|
-
export declare class ErrorWithCode extends Error {
|
|
675
|
-
/**
|
|
676
|
-
* Error code
|
|
677
|
-
*
|
|
678
|
-
* @readonly
|
|
679
|
-
*/
|
|
680
|
-
code: string | undefined;
|
|
681
|
-
/**
|
|
682
|
-
* Constructor of ErrorWithCode.
|
|
683
|
-
*
|
|
684
|
-
* @param {string} message - error message.
|
|
685
|
-
* @param {ErrorCode} code - error code.
|
|
686
|
-
*
|
|
687
|
-
* @beta
|
|
688
|
-
*/
|
|
689
|
-
constructor(message?: string, code?: ErrorCode);
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
/**
|
|
693
|
-
* Get log level.
|
|
694
|
-
*
|
|
695
|
-
* @returns Log level
|
|
696
|
-
*
|
|
697
|
-
* @beta
|
|
698
|
-
*/
|
|
699
|
-
export declare function getLogLevel(): LogLevel | undefined;
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* Generate connection configuration consumed by tedious.
|
|
703
|
-
*
|
|
704
|
-
* @param {TeamsFx} teamsfx - Used to provide configuration and auth
|
|
705
|
-
* @param { string? } databaseName - specify database name to override default one if there are multiple databases.
|
|
706
|
-
*
|
|
707
|
-
* @returns Connection configuration of tedious for the SQL.
|
|
708
|
-
*
|
|
709
|
-
* @throws {@link ErrorCode|InvalidConfiguration} when SQL config resource configuration is invalid.
|
|
710
|
-
* @throws {@link ErrorCode|InternalError} when get user MSI token failed or MSI token is invalid.
|
|
711
|
-
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
|
712
|
-
*
|
|
713
|
-
* @beta
|
|
714
|
-
*/
|
|
715
|
-
export declare function getTediousConnectionConfig(teamsfx: TeamsFx, databaseName?: string): Promise<ConnectionConfig>;
|
|
716
|
-
|
|
717
|
-
/**
|
|
718
|
-
* Identity type to use in authentication.
|
|
719
|
-
*
|
|
720
|
-
* @beta
|
|
721
|
-
*/
|
|
722
|
-
export declare enum IdentityType {
|
|
723
|
-
/**
|
|
724
|
-
* Represents the current user of Teams.
|
|
725
|
-
*/
|
|
726
|
-
User = "User",
|
|
727
|
-
/**
|
|
728
|
-
* Represents the application itself.
|
|
729
|
-
*/
|
|
730
|
-
App = "Application"
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
/**
|
|
734
|
-
* Log function for customized logging.
|
|
735
|
-
*
|
|
736
|
-
* @beta
|
|
737
|
-
*/
|
|
738
|
-
export declare type LogFunction = (level: LogLevel, message: string) => void;
|
|
739
|
-
|
|
740
|
-
/**
|
|
741
|
-
* Interface for customized logger.
|
|
742
|
-
* @beta
|
|
743
|
-
*/
|
|
744
|
-
export declare interface Logger {
|
|
745
|
-
/**
|
|
746
|
-
* Writes to error level logging or lower.
|
|
747
|
-
*/
|
|
748
|
-
error(message: string): void;
|
|
749
|
-
/**
|
|
750
|
-
* Writes to warning level logging or lower.
|
|
751
|
-
*/
|
|
752
|
-
warn(message: string): void;
|
|
753
|
-
/**
|
|
754
|
-
* Writes to info level logging or lower.
|
|
755
|
-
*/
|
|
756
|
-
info(message: string): void;
|
|
757
|
-
/**
|
|
758
|
-
* Writes to verbose level logging.
|
|
759
|
-
*/
|
|
760
|
-
verbose(message: string): void;
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
/**
|
|
764
|
-
* Log level.
|
|
765
|
-
*
|
|
766
|
-
* @beta
|
|
767
|
-
*/
|
|
768
|
-
export declare enum LogLevel {
|
|
769
|
-
/**
|
|
770
|
-
* Show verbose, information, warning and error message.
|
|
771
|
-
*/
|
|
772
|
-
Verbose = 0,
|
|
773
|
-
/**
|
|
774
|
-
* Show information, warning and error message.
|
|
775
|
-
*/
|
|
776
|
-
Info = 1,
|
|
777
|
-
/**
|
|
778
|
-
* Show warning and error message.
|
|
779
|
-
*/
|
|
780
|
-
Warn = 2,
|
|
781
|
-
/**
|
|
782
|
-
* Show error message.
|
|
783
|
-
*/
|
|
784
|
-
Error = 3
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
/**
|
|
788
|
-
* A {@link NotificationTarget} that represents a team member.
|
|
789
|
-
*
|
|
790
|
-
* @remarks
|
|
791
|
-
* It's recommended to get members from {@link TeamsBotInstallation.members()}.
|
|
792
|
-
*
|
|
793
|
-
* @beta
|
|
794
|
-
*/
|
|
795
|
-
export declare class Member implements NotificationTarget {
|
|
796
|
-
/**
|
|
797
|
-
* The parent {@link TeamsBotInstallation} where this member is created from.
|
|
798
|
-
*
|
|
799
|
-
* @beta
|
|
800
|
-
*/
|
|
801
|
-
readonly parent: TeamsBotInstallation;
|
|
802
|
-
/**
|
|
803
|
-
* Detailed member account information.
|
|
804
|
-
*
|
|
805
|
-
* @beta
|
|
806
|
-
*/
|
|
807
|
-
readonly account: TeamsChannelAccount;
|
|
808
|
-
/**
|
|
809
|
-
* Notification target type. For member it's always "Person".
|
|
810
|
-
*
|
|
811
|
-
* @beta
|
|
812
|
-
*/
|
|
813
|
-
readonly type: NotificationTargetType;
|
|
814
|
-
/**
|
|
815
|
-
* Constuctor.
|
|
816
|
-
*
|
|
817
|
-
* @remarks
|
|
818
|
-
* It's recommended to get members from {@link TeamsBotInstallation.members()}, instead of using this constructor.
|
|
819
|
-
*
|
|
820
|
-
* @param parent - The parent {@link TeamsBotInstallation} where this member is created from.
|
|
821
|
-
* @param account - Detailed member account information.
|
|
822
|
-
*
|
|
823
|
-
* @beta
|
|
824
|
-
*/
|
|
825
|
-
constructor(parent: TeamsBotInstallation, account: TeamsChannelAccount);
|
|
826
|
-
/**
|
|
827
|
-
* Send a plain text message.
|
|
828
|
-
*
|
|
829
|
-
* @param text - the plain text message.
|
|
830
|
-
* @returns A `Promise` representing the asynchronous operation.
|
|
831
|
-
*
|
|
832
|
-
* @beta
|
|
833
|
-
*/
|
|
834
|
-
sendMessage(text: string): Promise<void>;
|
|
835
|
-
/**
|
|
836
|
-
* Send an adaptive card message.
|
|
837
|
-
*
|
|
838
|
-
* @param card - the adaptive card raw JSON.
|
|
839
|
-
* @returns A `Promise` representing the asynchronous operation.
|
|
840
|
-
*
|
|
841
|
-
* @beta
|
|
842
|
-
*/
|
|
843
|
-
sendAdaptiveCard(card: unknown): Promise<void>;
|
|
844
|
-
/**
|
|
845
|
-
* @internal
|
|
846
|
-
*/
|
|
847
|
-
private newConversation;
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
/**
|
|
851
|
-
* Provides utility method to build bot message with cards that supported in Teams.
|
|
852
|
-
*/
|
|
853
|
-
export declare class MessageBuilder {
|
|
854
|
-
/**
|
|
855
|
-
* Build a bot message activity attached with adaptive card.
|
|
856
|
-
*
|
|
857
|
-
* @param getCardData Function to prepare your card data.
|
|
858
|
-
* @param cardTemplate The adaptive card template.
|
|
859
|
-
* @returns A bot message activity attached with an adaptive card.
|
|
860
|
-
*
|
|
861
|
-
* @example
|
|
862
|
-
* ```javascript
|
|
863
|
-
* const cardTemplate = {
|
|
864
|
-
* type: "AdaptiveCard",
|
|
865
|
-
* body: [
|
|
866
|
-
* {
|
|
867
|
-
* "type": "TextBlock",
|
|
868
|
-
* "text": "${title}",
|
|
869
|
-
* "size": "Large"
|
|
870
|
-
* },
|
|
871
|
-
* {
|
|
872
|
-
* "type": "TextBlock",
|
|
873
|
-
* "text": "${description}"
|
|
874
|
-
* }],
|
|
875
|
-
* $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
|
|
876
|
-
* version: "1.4"
|
|
877
|
-
* };
|
|
878
|
-
*
|
|
879
|
-
* type CardData = {
|
|
880
|
-
* title: string,
|
|
881
|
-
* description: string
|
|
882
|
-
* };
|
|
883
|
-
* const card = MessageBuilder.attachAdaptiveCard<CardData>(() => {
|
|
884
|
-
* return {
|
|
885
|
-
* title: "sample card title",
|
|
886
|
-
* description: "sample card description"
|
|
887
|
-
* }}, cardTemplate);
|
|
888
|
-
* ```
|
|
889
|
-
*
|
|
890
|
-
* @beta
|
|
891
|
-
*/
|
|
892
|
-
static attachAdaptiveCard<TData>(getCardData: () => TData, cardTemplate: any): Partial<Activity_2>;
|
|
893
|
-
/**
|
|
894
|
-
* Build a bot message activity attached with an adaptive card.
|
|
895
|
-
*
|
|
896
|
-
* @param card The adaptive card content.
|
|
897
|
-
* @returns A bot message activity attached with an adaptive card.
|
|
898
|
-
*
|
|
899
|
-
* @beta
|
|
900
|
-
*/
|
|
901
|
-
static attachAdaptiveCardWithoutData(card: any): Partial<Activity_2>;
|
|
902
|
-
/**
|
|
903
|
-
* Build a bot message activity attached with an hero card.
|
|
904
|
-
*
|
|
905
|
-
* @param title The card title.
|
|
906
|
-
* @param images Optional. The array of images to include on the card.
|
|
907
|
-
* @param buttons Optional. The array of buttons to include on the card. Each `string` in the array
|
|
908
|
-
* is converted to an `imBack` button with a title and value set to the value of the string.
|
|
909
|
-
* @param other Optional. Any additional properties to include on the card.
|
|
910
|
-
*
|
|
911
|
-
* @returns A bot message activity attached with a hero card.
|
|
912
|
-
*
|
|
913
|
-
* @example
|
|
914
|
-
* ```javascript
|
|
915
|
-
* const message = MessageBuilder.attachHeroCard(
|
|
916
|
-
* 'sample title',
|
|
917
|
-
* ['https://example.com/sample.jpg'],
|
|
918
|
-
* ['action']
|
|
919
|
-
* );
|
|
920
|
-
* ```
|
|
921
|
-
*
|
|
922
|
-
* @beta
|
|
923
|
-
*/
|
|
924
|
-
static attachHeroCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<HeroCard>): Partial<Activity_2>;
|
|
925
|
-
/**
|
|
926
|
-
* Returns an attachment for a sign-in card.
|
|
927
|
-
*
|
|
928
|
-
* @param title The title for the card's sign-in button.
|
|
929
|
-
* @param url The URL of the sign-in page to use.
|
|
930
|
-
* @param text Optional. Additional text to include on the card.
|
|
931
|
-
*
|
|
932
|
-
* @returns A bot message activity attached with a sign-in card.
|
|
933
|
-
*
|
|
934
|
-
* @remarks
|
|
935
|
-
* For channels that don't natively support sign-in cards, an alternative message is rendered.
|
|
936
|
-
*
|
|
937
|
-
* @beta
|
|
938
|
-
*/
|
|
939
|
-
static attachSigninCard(title: string, url: string, text?: string): Partial<Activity_2>;
|
|
940
|
-
/**
|
|
941
|
-
* Build a bot message activity attached with an Office 365 connector card.
|
|
942
|
-
*
|
|
943
|
-
* @param card A description of the Office 365 connector card.
|
|
944
|
-
* @returns A bot message activity attached with an Office 365 connector card.
|
|
945
|
-
*
|
|
946
|
-
* @beta
|
|
947
|
-
*/
|
|
948
|
-
static attachO365ConnectorCard(card: O365ConnectorCard): Partial<Activity_2>;
|
|
949
|
-
/**
|
|
950
|
-
* Build a message activity attached with a receipt card.
|
|
951
|
-
* @param card A description of the receipt card.
|
|
952
|
-
* @returns A message activity attached with a receipt card.
|
|
953
|
-
*
|
|
954
|
-
* @beta
|
|
955
|
-
*/
|
|
956
|
-
static AttachReceiptCard(card: ReceiptCard): Partial<Activity_2>;
|
|
957
|
-
/**
|
|
958
|
-
*
|
|
959
|
-
* @param title The card title.
|
|
960
|
-
* @param images Optional. The array of images to include on the card.
|
|
961
|
-
* @param buttons Optional. The array of buttons to include on the card. Each `string` in the array
|
|
962
|
-
* is converted to an `imBack` button with a title and value set to the value of the string.
|
|
963
|
-
* @param other Optional. Any additional properties to include on the card.
|
|
964
|
-
* @returns A message activity attached with a thumbnail card
|
|
965
|
-
*
|
|
966
|
-
* @beta
|
|
967
|
-
*/
|
|
968
|
-
static attachThumbnailCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<ThumbnailCard>): Partial<Activity_2>;
|
|
969
|
-
/**
|
|
970
|
-
* Add an attachement to a bot activity.
|
|
971
|
-
* @param attachement The attachment object to attach.
|
|
972
|
-
* @returns A message activity with an attachment.
|
|
973
|
-
*
|
|
974
|
-
* @beta
|
|
975
|
-
*/
|
|
976
|
-
static attachContent(attachement: Attachment): Partial<Activity_2>;
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
/**
|
|
980
|
-
* Microsoft Graph auth provider for Teams Framework
|
|
981
|
-
*
|
|
982
|
-
* @beta
|
|
983
|
-
*/
|
|
984
|
-
export declare class MsGraphAuthProvider implements AuthenticationProvider {
|
|
985
|
-
private teamsfx;
|
|
986
|
-
private scopes;
|
|
987
|
-
/**
|
|
988
|
-
* Constructor of MsGraphAuthProvider.
|
|
989
|
-
*
|
|
990
|
-
* @param {TeamsFx} teamsfx - Used to provide configuration and auth.
|
|
991
|
-
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
|
992
|
-
*
|
|
993
|
-
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
994
|
-
*
|
|
995
|
-
* @returns An instance of MsGraphAuthProvider.
|
|
996
|
-
*
|
|
997
|
-
* @beta
|
|
998
|
-
*/
|
|
999
|
-
constructor(teamsfx: TeamsFxConfiguration, scopes?: string | string[]);
|
|
1000
|
-
/**
|
|
1001
|
-
* Get access token for Microsoft Graph API requests.
|
|
1002
|
-
*
|
|
1003
|
-
* @throws {@link ErrorCode|InternalError} when get access token failed due to empty token or unknown other problems.
|
|
1004
|
-
* @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
|
|
1005
|
-
* @throws {@link ErrorCode|UiRequiredError} when need user consent to get access token.
|
|
1006
|
-
* @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth or AAD server.
|
|
1007
|
-
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
1008
|
-
*
|
|
1009
|
-
* @returns Access token from the credential.
|
|
1010
|
-
*
|
|
1011
|
-
*/
|
|
1012
|
-
getAccessToken(): Promise<string>;
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
/**
|
|
1016
|
-
* Provide utilities to send notification to varies targets (e.g., member, group, channel).
|
|
1017
|
-
*
|
|
1018
|
-
* @beta
|
|
1019
|
-
*/
|
|
1020
|
-
export declare class NotificationBot {
|
|
1021
|
-
private readonly conversationReferenceStore;
|
|
1022
|
-
private readonly adapter;
|
|
1023
|
-
/**
|
|
1024
|
-
* constructor of the notification bot.
|
|
1025
|
-
*
|
|
1026
|
-
* @remarks
|
|
1027
|
-
* To ensure accuracy, it's recommended to initialize before handling any message.
|
|
1028
|
-
*
|
|
1029
|
-
* @param adapter - the bound `BotFrameworkAdapter`
|
|
1030
|
-
* @param options - initialize options
|
|
1031
|
-
*
|
|
1032
|
-
* @beta
|
|
1033
|
-
*/
|
|
1034
|
-
constructor(adapter: BotFrameworkAdapter, options?: NotificationOptions_2);
|
|
1035
|
-
/**
|
|
1036
|
-
* Get all targets where the bot is installed.
|
|
1037
|
-
*
|
|
1038
|
-
* @remarks
|
|
1039
|
-
* The result is retrieving from the persisted storage.
|
|
1040
|
-
*
|
|
1041
|
-
* @returns - an array of {@link TeamsBotInstallation}.
|
|
1042
|
-
*
|
|
1043
|
-
* @beta
|
|
1044
|
-
*/
|
|
1045
|
-
installations(): Promise<TeamsBotInstallation[]>;
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
/**
|
|
1049
|
-
* Options to initialize {@link NotificationBot}.
|
|
1050
|
-
*
|
|
1051
|
-
* @beta
|
|
1052
|
-
*/
|
|
1053
|
-
declare interface NotificationOptions_2 {
|
|
1054
|
-
/**
|
|
1055
|
-
* An optional storage to persist bot notification connections.
|
|
1056
|
-
*
|
|
1057
|
-
* @remarks
|
|
1058
|
-
* If `storage` is not provided, a default local file storage will be used,
|
|
1059
|
-
* which stores notification connections into:
|
|
1060
|
-
* - ".notification.localstore.json" if running locally
|
|
1061
|
-
* - "${process.env.TEMP}/.notification.localstore.json" if `process.env.RUNNING_ON_AZURE` is set to "1"
|
|
1062
|
-
*
|
|
1063
|
-
* It's recommended to use your own shared storage for production environment.
|
|
1064
|
-
*
|
|
1065
|
-
* @beta
|
|
1066
|
-
*/
|
|
1067
|
-
storage?: NotificationTargetStorage;
|
|
1068
|
-
}
|
|
1069
|
-
export { NotificationOptions_2 as NotificationOptions }
|
|
1070
|
-
|
|
1071
|
-
/**
|
|
1072
|
-
* Represent a notification target.
|
|
1073
|
-
*
|
|
1074
|
-
* @beta
|
|
1075
|
-
*/
|
|
1076
|
-
export declare interface NotificationTarget {
|
|
1077
|
-
/**
|
|
1078
|
-
* The type of target, could be "Channel" or "Group" or "Person".
|
|
1079
|
-
*
|
|
1080
|
-
* @beta
|
|
1081
|
-
*/
|
|
1082
|
-
readonly type?: NotificationTargetType;
|
|
1083
|
-
/**
|
|
1084
|
-
* Send a plain text message.
|
|
1085
|
-
*
|
|
1086
|
-
* @param text - the plain text message.
|
|
1087
|
-
*
|
|
1088
|
-
* @beta
|
|
1089
|
-
*/
|
|
1090
|
-
sendMessage(text: string): Promise<void>;
|
|
1091
|
-
/**
|
|
1092
|
-
* Send an adaptive card message.
|
|
1093
|
-
*
|
|
1094
|
-
* @param card - the adaptive card raw JSON.
|
|
1095
|
-
*
|
|
1096
|
-
* @beta
|
|
1097
|
-
*/
|
|
1098
|
-
sendAdaptiveCard(card: unknown): Promise<void>;
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
/**
|
|
1102
|
-
* Interface for a storage provider that stores and retrieves notification target references.
|
|
1103
|
-
*
|
|
1104
|
-
* @beta
|
|
1105
|
-
*/
|
|
1106
|
-
export declare interface NotificationTargetStorage {
|
|
1107
|
-
/**
|
|
1108
|
-
* Read one notification target by its key.
|
|
1109
|
-
*
|
|
1110
|
-
* @param key - the key of a notification target.
|
|
1111
|
-
*
|
|
1112
|
-
* @returns - the notification target. Or undefined if not found.
|
|
1113
|
-
*
|
|
1114
|
-
* @beta
|
|
1115
|
-
*/
|
|
1116
|
-
read(key: string): Promise<{
|
|
1117
|
-
[key: string]: unknown;
|
|
1118
|
-
} | undefined>;
|
|
1119
|
-
/**
|
|
1120
|
-
* List all stored notification targets.
|
|
1121
|
-
*
|
|
1122
|
-
* @returns - an array of notification target. Or an empty array if nothing is stored.
|
|
1123
|
-
*
|
|
1124
|
-
* @beta
|
|
1125
|
-
*/
|
|
1126
|
-
list(): Promise<{
|
|
1127
|
-
[key: string]: unknown;
|
|
1128
|
-
}[]>;
|
|
1129
|
-
/**
|
|
1130
|
-
* Write one notification target by its key.
|
|
1131
|
-
*
|
|
1132
|
-
* @param key - the key of a notification target.
|
|
1133
|
-
* @param object - the notification target.
|
|
1134
|
-
*
|
|
1135
|
-
* @beta
|
|
1136
|
-
*/
|
|
1137
|
-
write(key: string, object: {
|
|
1138
|
-
[key: string]: unknown;
|
|
1139
|
-
}): Promise<void>;
|
|
1140
|
-
/**
|
|
1141
|
-
* Delete one notificaton target by its key.
|
|
1142
|
-
*
|
|
1143
|
-
* @param key - the key of a notification target.
|
|
1144
|
-
*
|
|
1145
|
-
* @beta
|
|
1146
|
-
*/
|
|
1147
|
-
delete(key: string): Promise<void>;
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
/**
|
|
1151
|
-
* The target type where the notification will be sent to.
|
|
1152
|
-
*
|
|
1153
|
-
* @remarks
|
|
1154
|
-
* - "Channel" means to a team channel. (By default, notification to a team will be sent to its "General" channel.)
|
|
1155
|
-
* - "Group" means to a group chat.
|
|
1156
|
-
* - "Person" means to a personal chat.
|
|
1157
|
-
*
|
|
1158
|
-
* @beta
|
|
1159
|
-
*/
|
|
1160
|
-
export declare type NotificationTargetType = "Channel" | "Group" | "Person";
|
|
1161
|
-
|
|
1162
|
-
/**
|
|
1163
|
-
* Represent on-behalf-of flow to get user identity, and it is designed to be used in server side.
|
|
1164
|
-
*
|
|
1165
|
-
* @example
|
|
1166
|
-
* ```typescript
|
|
1167
|
-
* const credential = new OnBehalfOfUserCredential(ssoToken);
|
|
1168
|
-
* ```
|
|
1169
|
-
*
|
|
1170
|
-
* @remarks
|
|
1171
|
-
* Can only be used in server side.
|
|
1172
|
-
*
|
|
1173
|
-
* @beta
|
|
1174
|
-
*/
|
|
1175
|
-
export declare class OnBehalfOfUserCredential implements TokenCredential {
|
|
1176
|
-
private msalClient;
|
|
1177
|
-
private ssoToken;
|
|
1178
|
-
/**
|
|
1179
|
-
* Constructor of OnBehalfOfUserCredential
|
|
1180
|
-
*
|
|
1181
|
-
* @remarks
|
|
1182
|
-
* Only works in in server side.
|
|
1183
|
-
*
|
|
1184
|
-
* @param {string} ssoToken - User token provided by Teams SSO feature.
|
|
1185
|
-
* @param {AuthenticationConfiguration} config - The authentication configuration. Use environment variables if not provided.
|
|
1186
|
-
*
|
|
1187
|
-
* @throws {@link ErrorCode|InvalidConfiguration} when client id, client secret, certificate content, authority host or tenant id is not found in config.
|
|
1188
|
-
* @throws {@link ErrorCode|InternalError} when SSO token is not valid.
|
|
1189
|
-
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
|
1190
|
-
*
|
|
1191
|
-
* @beta
|
|
1192
|
-
*/
|
|
1193
|
-
constructor(ssoToken: string, config: AuthenticationConfiguration);
|
|
1194
|
-
/**
|
|
1195
|
-
* Get access token from credential.
|
|
1196
|
-
*
|
|
1197
|
-
* @example
|
|
1198
|
-
* ```typescript
|
|
1199
|
-
* await credential.getToken([]) // Get SSO token using empty string array
|
|
1200
|
-
* await credential.getToken("") // Get SSO token using empty string
|
|
1201
|
-
* await credential.getToken([".default"]) // Get Graph access token with default scope using string array
|
|
1202
|
-
* await credential.getToken(".default") // Get Graph access token with default scope using string
|
|
1203
|
-
* await credential.getToken(["User.Read"]) // Get Graph access token for single scope using string array
|
|
1204
|
-
* await credential.getToken("User.Read") // Get Graph access token for single scope using string
|
|
1205
|
-
* await credential.getToken(["User.Read", "Application.Read.All"]) // Get Graph access token for multiple scopes using string array
|
|
1206
|
-
* await credential.getToken("User.Read Application.Read.All") // Get Graph access token for multiple scopes using space-separated string
|
|
1207
|
-
* await credential.getToken("https://graph.microsoft.com/User.Read") // Get Graph access token with full resource URI
|
|
1208
|
-
* await credential.getToken(["https://outlook.office.com/Mail.Read"]) // Get Outlook access token
|
|
1209
|
-
* ```
|
|
1210
|
-
*
|
|
1211
|
-
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
|
1212
|
-
* @param {GetTokenOptions} options - The options used to configure any requests this TokenCredential implementation might make.
|
|
1213
|
-
*
|
|
1214
|
-
* @throws {@link ErrorCode|InternalError} when failed to acquire access token on behalf of user with unknown error.
|
|
1215
|
-
* @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
|
|
1216
|
-
* @throws {@link ErrorCode|UiRequiredError} when need user consent to get access token.
|
|
1217
|
-
* @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth server.
|
|
1218
|
-
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
1219
|
-
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
|
1220
|
-
*
|
|
1221
|
-
* @returns Access token with expected scopes.
|
|
1222
|
-
*
|
|
1223
|
-
* @remarks
|
|
1224
|
-
* If scopes is empty string or array, it returns SSO token.
|
|
1225
|
-
* If scopes is non-empty, it returns access token for target scope.
|
|
1226
|
-
*
|
|
1227
|
-
* @beta
|
|
1228
|
-
*/
|
|
1229
|
-
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
|
|
1230
|
-
/**
|
|
1231
|
-
* Get basic user info from SSO token.
|
|
1232
|
-
*
|
|
1233
|
-
* @example
|
|
1234
|
-
* ```typescript
|
|
1235
|
-
* const currentUser = getUserInfo();
|
|
1236
|
-
* ```
|
|
1237
|
-
*
|
|
1238
|
-
* @throws {@link ErrorCode|InternalError} when SSO token is not valid.
|
|
1239
|
-
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
|
1240
|
-
*
|
|
1241
|
-
* @returns Basic user info with user displayName, objectId and preferredUserName.
|
|
1242
|
-
*
|
|
1243
|
-
* @beta
|
|
1244
|
-
*/
|
|
1245
|
-
getUserInfo(): UserInfo;
|
|
1246
|
-
private generateAuthServerError;
|
|
1247
|
-
}
|
|
1248
|
-
|
|
1249
|
-
/**
|
|
1250
|
-
* Send an adaptive card message to a notification target.
|
|
1251
|
-
*
|
|
1252
|
-
* @param target - the notification target.
|
|
1253
|
-
* @param card - the adaptive card raw JSON.
|
|
1254
|
-
* @returns A `Promise` representing the asynchronous operation.
|
|
1255
|
-
*
|
|
1256
|
-
* @beta
|
|
1257
|
-
*/
|
|
1258
|
-
export declare function sendAdaptiveCard(target: NotificationTarget, card: unknown): Promise<void>;
|
|
1259
|
-
|
|
1260
|
-
/**
|
|
1261
|
-
* Send a plain text message to a notification target.
|
|
1262
|
-
*
|
|
1263
|
-
* @param target - the notification target.
|
|
1264
|
-
* @param text - the plain text message.
|
|
1265
|
-
* @returns A `Promise` representing the asynchronous operation.
|
|
1266
|
-
*
|
|
1267
|
-
* @beta
|
|
1268
|
-
*/
|
|
1269
|
-
export declare function sendMessage(target: NotificationTarget, text: string): Promise<void>;
|
|
1270
|
-
|
|
1271
|
-
/**
|
|
1272
|
-
* Set custom log function. Use the function if it's set. Priority is lower than setLogger.
|
|
1273
|
-
*
|
|
1274
|
-
* @param {LogFunction} logFunction - custom log function. If it's undefined, custom log function will be cleared.
|
|
1275
|
-
*
|
|
1276
|
-
* @example
|
|
1277
|
-
* ```typescript
|
|
1278
|
-
* setLogFunction((level: LogLevel, message: string) => {
|
|
1279
|
-
* if (level === LogLevel.Error) {
|
|
1280
|
-
* console.log(message);
|
|
1281
|
-
* }
|
|
1282
|
-
* });
|
|
1283
|
-
* ```
|
|
1284
|
-
*
|
|
1285
|
-
* @beta
|
|
1286
|
-
*/
|
|
1287
|
-
export declare function setLogFunction(logFunction?: LogFunction): void;
|
|
1288
|
-
|
|
1289
|
-
/**
|
|
1290
|
-
* Set custom logger. Use the output functions if it's set. Priority is higher than setLogFunction.
|
|
1291
|
-
*
|
|
1292
|
-
* @param {Logger} logger - custom logger. If it's undefined, custom logger will be cleared.
|
|
1293
|
-
*
|
|
1294
|
-
* @example
|
|
1295
|
-
* ```typescript
|
|
1296
|
-
* setLogger({
|
|
1297
|
-
* verbose: console.debug,
|
|
1298
|
-
* info: console.info,
|
|
1299
|
-
* warn: console.warn,
|
|
1300
|
-
* error: console.error,
|
|
1301
|
-
* });
|
|
1302
|
-
* ```
|
|
1303
|
-
*
|
|
1304
|
-
* @beta
|
|
1305
|
-
*/
|
|
1306
|
-
export declare function setLogger(logger?: Logger): void;
|
|
1307
|
-
|
|
1308
|
-
/**
|
|
1309
|
-
* Update log level helper.
|
|
1310
|
-
*
|
|
1311
|
-
* @param { LogLevel } level - log level in configuration
|
|
1312
|
-
*
|
|
1313
|
-
* @beta
|
|
1314
|
-
*/
|
|
1315
|
-
export declare function setLogLevel(level: LogLevel): void;
|
|
1316
|
-
|
|
1317
|
-
/**
|
|
1318
|
-
* A {@link NotificationTarget} that represents a bot installation. Teams Bot could be installed into
|
|
1319
|
-
* - Personal chat
|
|
1320
|
-
* - Group chat
|
|
1321
|
-
* - Team (by default the `General` channel)
|
|
1322
|
-
*
|
|
1323
|
-
* @remarks
|
|
1324
|
-
* It's recommended to get bot installations from {@link ConversationBot.installations()}.
|
|
1325
|
-
*
|
|
1326
|
-
* @beta
|
|
1327
|
-
*/
|
|
1328
|
-
export declare class TeamsBotInstallation implements NotificationTarget {
|
|
1329
|
-
/**
|
|
1330
|
-
* The bound `BotFrameworkAdapter`.
|
|
1331
|
-
*
|
|
1332
|
-
* @beta
|
|
1333
|
-
*/
|
|
1334
|
-
readonly adapter: BotFrameworkAdapter;
|
|
1335
|
-
/**
|
|
1336
|
-
* The bound `ConversationReference`.
|
|
1337
|
-
*
|
|
1338
|
-
* @beta
|
|
1339
|
-
*/
|
|
1340
|
-
readonly conversationReference: Partial<ConversationReference>;
|
|
1341
|
-
/**
|
|
1342
|
-
* Notification target type.
|
|
1343
|
-
*
|
|
1344
|
-
* @remarks
|
|
1345
|
-
* - "Channel" means bot is installed into a team and notification will be sent to its "General" channel.
|
|
1346
|
-
* - "Group" means bot is installed into a group chat.
|
|
1347
|
-
* - "Person" means bot is installed into a personal scope and notification will be sent to personal chat.
|
|
1348
|
-
*
|
|
1349
|
-
* @beta
|
|
1350
|
-
*/
|
|
1351
|
-
readonly type?: NotificationTargetType;
|
|
1352
|
-
/**
|
|
1353
|
-
* Constructor
|
|
1354
|
-
*
|
|
1355
|
-
* @remarks
|
|
1356
|
-
* It's recommended to get bot installations from {@link ConversationBot.installations()}, instead of using this constructor.
|
|
1357
|
-
*
|
|
1358
|
-
* @param adapter - the bound `BotFrameworkAdapter`.
|
|
1359
|
-
* @param conversationReference - the bound `ConversationReference`.
|
|
1360
|
-
*
|
|
1361
|
-
* @beta
|
|
1362
|
-
*/
|
|
1363
|
-
constructor(adapter: BotFrameworkAdapter, conversationReference: Partial<ConversationReference>);
|
|
1364
|
-
/**
|
|
1365
|
-
* Send a plain text message.
|
|
1366
|
-
*
|
|
1367
|
-
* @param text - the plain text message.
|
|
1368
|
-
* @returns A `Promise` representing the asynchronous operation.
|
|
1369
|
-
*
|
|
1370
|
-
* @beta
|
|
1371
|
-
*/
|
|
1372
|
-
sendMessage(text: string): Promise<void>;
|
|
1373
|
-
/**
|
|
1374
|
-
* Send an adaptive card message.
|
|
1375
|
-
*
|
|
1376
|
-
* @param card - the adaptive card raw JSON.
|
|
1377
|
-
* @returns A `Promise` representing the asynchronous operation.
|
|
1378
|
-
*
|
|
1379
|
-
* @beta
|
|
1380
|
-
*/
|
|
1381
|
-
sendAdaptiveCard(card: unknown): Promise<void>;
|
|
1382
|
-
/**
|
|
1383
|
-
* Get channels from this bot installation.
|
|
1384
|
-
*
|
|
1385
|
-
* @returns an array of channels if bot is installed into a team, otherwise returns an empty array.
|
|
1386
|
-
*
|
|
1387
|
-
* @beta
|
|
1388
|
-
*/
|
|
1389
|
-
channels(): Promise<Channel[]>;
|
|
1390
|
-
/**
|
|
1391
|
-
* Get members from this bot installation.
|
|
1392
|
-
*
|
|
1393
|
-
* @returns an array of members from where the bot is installed.
|
|
1394
|
-
*
|
|
1395
|
-
* @beta
|
|
1396
|
-
*/
|
|
1397
|
-
members(): Promise<Member[]>;
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
/**
|
|
1401
|
-
* Creates a new prompt that leverage Teams Single Sign On (SSO) support for bot to automatically sign in user and
|
|
1402
|
-
* help receive oauth token, asks the user to consent if needed.
|
|
1403
|
-
*
|
|
1404
|
-
* @remarks
|
|
1405
|
-
* The prompt will attempt to retrieve the users current token of the desired scopes and store it in
|
|
1406
|
-
* the token store.
|
|
1407
|
-
*
|
|
1408
|
-
* User will be automatically signed in leveraging Teams support of Bot Single Sign On(SSO):
|
|
1409
|
-
* https://docs.microsoft.com/en-us/microsoftteams/platform/bots/how-to/authentication/auth-aad-sso-bots
|
|
1410
|
-
*
|
|
1411
|
-
* @example
|
|
1412
|
-
* When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named
|
|
1413
|
-
* dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either
|
|
1414
|
-
* `DialogContext.beginDialog()` or `DialogContext.prompt()`. The user will be prompted to sign in as
|
|
1415
|
-
* needed and their access token will be passed as an argument to the callers next waterfall step:
|
|
1416
|
-
*
|
|
1417
|
-
* ```JavaScript
|
|
1418
|
-
* const { ConversationState, MemoryStorage } = require('botbuilder');
|
|
1419
|
-
* const { DialogSet, WaterfallDialog } = require('botbuilder-dialogs');
|
|
1420
|
-
* const { TeamsBotSsoPrompt } = require('@microsoft/teamsfx');
|
|
1421
|
-
*
|
|
1422
|
-
* const convoState = new ConversationState(new MemoryStorage());
|
|
1423
|
-
* const dialogState = convoState.createProperty('dialogState');
|
|
1424
|
-
* const dialogs = new DialogSet(dialogState);
|
|
1425
|
-
*
|
|
1426
|
-
* dialogs.add(new TeamsBotSsoPrompt('TeamsBotSsoPrompt', {
|
|
1427
|
-
* scopes: ["User.Read"],
|
|
1428
|
-
* }));
|
|
1429
|
-
*
|
|
1430
|
-
* dialogs.add(new WaterfallDialog('taskNeedingLogin', [
|
|
1431
|
-
* async (step) => {
|
|
1432
|
-
* return await step.beginDialog('TeamsBotSsoPrompt');
|
|
1433
|
-
* },
|
|
1434
|
-
* async (step) => {
|
|
1435
|
-
* const token = step.result;
|
|
1436
|
-
* if (token) {
|
|
1437
|
-
*
|
|
1438
|
-
* // ... continue with task needing access token ...
|
|
1439
|
-
*
|
|
1440
|
-
* } else {
|
|
1441
|
-
* await step.context.sendActivity(`Sorry... We couldn't log you in. Try again later.`);
|
|
1442
|
-
* return await step.endDialog();
|
|
1443
|
-
* }
|
|
1444
|
-
* }
|
|
1445
|
-
* ]));
|
|
1446
|
-
* ```
|
|
1447
|
-
*
|
|
1448
|
-
* @beta
|
|
1449
|
-
*/
|
|
1450
|
-
export declare class TeamsBotSsoPrompt extends Dialog {
|
|
1451
|
-
private teamsfx;
|
|
1452
|
-
private settings;
|
|
1453
|
-
/**
|
|
1454
|
-
* Constructor of TeamsBotSsoPrompt.
|
|
1455
|
-
*
|
|
1456
|
-
* @param {TeamsFx} teamsfx - Used to provide configuration and auth
|
|
1457
|
-
* @param dialogId Unique ID of the dialog within its parent `DialogSet` or `ComponentDialog`.
|
|
1458
|
-
* @param settings Settings used to configure the prompt.
|
|
1459
|
-
*
|
|
1460
|
-
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
1461
|
-
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
|
1462
|
-
*
|
|
1463
|
-
* @beta
|
|
1464
|
-
*/
|
|
1465
|
-
constructor(teamsfx: TeamsFx, dialogId: string, settings: TeamsBotSsoPromptSettings);
|
|
1466
|
-
/**
|
|
1467
|
-
* Called when a prompt dialog is pushed onto the dialog stack and is being activated.
|
|
1468
|
-
* @remarks
|
|
1469
|
-
* If the task is successful, the result indicates whether the prompt is still
|
|
1470
|
-
* active after the turn has been processed by the prompt.
|
|
1471
|
-
*
|
|
1472
|
-
* @param dc The DialogContext for the current turn of the conversation.
|
|
1473
|
-
*
|
|
1474
|
-
* @throws {@link ErrorCode|InvalidParameter} when timeout property in teams bot sso prompt settings is not number or is not positive.
|
|
1475
|
-
* @throws {@link ErrorCode|ChannelNotSupported} when bot channel is not MS Teams.
|
|
1476
|
-
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
|
1477
|
-
*
|
|
1478
|
-
* @returns A `Promise` representing the asynchronous operation.
|
|
1479
|
-
*
|
|
1480
|
-
* @beta
|
|
1481
|
-
*/
|
|
1482
|
-
beginDialog(dc: DialogContext): Promise<DialogTurnResult>;
|
|
1483
|
-
/**
|
|
1484
|
-
* Called when a prompt dialog is the active dialog and the user replied with a new activity.
|
|
1485
|
-
*
|
|
1486
|
-
* @remarks
|
|
1487
|
-
* If the task is successful, the result indicates whether the dialog is still
|
|
1488
|
-
* active after the turn has been processed by the dialog.
|
|
1489
|
-
* The prompt generally continues to receive the user's replies until it accepts the
|
|
1490
|
-
* user's reply as valid input for the prompt.
|
|
1491
|
-
*
|
|
1492
|
-
* @param dc The DialogContext for the current turn of the conversation.
|
|
1493
|
-
*
|
|
1494
|
-
* @returns A `Promise` representing the asynchronous operation.
|
|
1495
|
-
*
|
|
1496
|
-
* @throws {@link ErrorCode|ChannelNotSupported} when bot channel is not MS Teams.
|
|
1497
|
-
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
|
1498
|
-
*
|
|
1499
|
-
* @beta
|
|
1500
|
-
*/
|
|
1501
|
-
continueDialog(dc: DialogContext): Promise<DialogTurnResult>;
|
|
1502
|
-
private loadAndValidateConfig;
|
|
1503
|
-
/**
|
|
1504
|
-
* Ensure bot is running in MS Teams since TeamsBotSsoPrompt is only supported in MS Teams channel.
|
|
1505
|
-
* @param dc dialog context
|
|
1506
|
-
* @throws {@link ErrorCode|ChannelNotSupported} if bot channel is not MS Teams
|
|
1507
|
-
* @internal
|
|
1508
|
-
*/
|
|
1509
|
-
private ensureMsTeamsChannel;
|
|
1510
|
-
/**
|
|
1511
|
-
* Send OAuthCard that tells Teams to obtain an authentication token for the bot application.
|
|
1512
|
-
* For details see https://docs.microsoft.com/en-us/microsoftteams/platform/bots/how-to/authentication/auth-aad-sso-bots.
|
|
1513
|
-
*
|
|
1514
|
-
* @internal
|
|
1515
|
-
*/
|
|
1516
|
-
private sendOAuthCardAsync;
|
|
1517
|
-
/**
|
|
1518
|
-
* Get sign in resource.
|
|
1519
|
-
*
|
|
1520
|
-
* @throws {@link ErrorCode|InvalidConfiguration} if client id, tenant id or initiate login endpoint is not found in config.
|
|
1521
|
-
*
|
|
1522
|
-
* @internal
|
|
1523
|
-
*/
|
|
1524
|
-
private getSignInResource;
|
|
1525
|
-
/**
|
|
1526
|
-
* @internal
|
|
1527
|
-
*/
|
|
1528
|
-
private recognizeToken;
|
|
1529
|
-
/**
|
|
1530
|
-
* @internal
|
|
1531
|
-
*/
|
|
1532
|
-
private getTokenExchangeInvokeResponse;
|
|
1533
|
-
/**
|
|
1534
|
-
* @internal
|
|
1535
|
-
*/
|
|
1536
|
-
private isTeamsVerificationInvoke;
|
|
1537
|
-
/**
|
|
1538
|
-
* @internal
|
|
1539
|
-
*/
|
|
1540
|
-
private isTokenExchangeRequestInvoke;
|
|
1541
|
-
/**
|
|
1542
|
-
* @internal
|
|
1543
|
-
*/
|
|
1544
|
-
private isTokenExchangeRequest;
|
|
1545
|
-
}
|
|
793
|
+
constructor(message?: string, code?: ErrorCode);
|
|
794
|
+
}
|
|
1546
795
|
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
*/
|
|
1556
|
-
scopes: string[];
|
|
1557
|
-
/**
|
|
1558
|
-
* (Optional) number of milliseconds the prompt will wait for the user to authenticate.
|
|
1559
|
-
* Defaults to a value `900,000` (15 minutes.)
|
|
1560
|
-
*/
|
|
1561
|
-
timeout?: number;
|
|
1562
|
-
/**
|
|
1563
|
-
* (Optional) value indicating whether the TeamsBotSsoPrompt should end upon receiving an
|
|
1564
|
-
* invalid message. Generally the TeamsBotSsoPrompt will end the auth flow when receives user
|
|
1565
|
-
* message not related to the auth flow. Setting the flag to false ignores the user's message instead.
|
|
1566
|
-
* Defaults to value `true`
|
|
1567
|
-
*/
|
|
1568
|
-
endOnInvalidMessage?: boolean;
|
|
1569
|
-
}
|
|
796
|
+
/**
|
|
797
|
+
* Get log level.
|
|
798
|
+
*
|
|
799
|
+
* @returns Log level
|
|
800
|
+
*
|
|
801
|
+
* @beta
|
|
802
|
+
*/
|
|
803
|
+
export declare function getLogLevel(): LogLevel | undefined;
|
|
1570
804
|
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
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>;
|
|
1586
820
|
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
* @throws {@link ErrorCode|IdentityTypeNotSupported} when setting app identity in browser.
|
|
1603
|
-
*
|
|
1604
|
-
* @beta
|
|
1605
|
-
*/
|
|
1606
|
-
constructor(identityType?: IdentityType, customConfig?: Record<string, string>);
|
|
1607
|
-
/**
|
|
1608
|
-
* Identity type set by user.
|
|
1609
|
-
*
|
|
1610
|
-
* @returns identity type.
|
|
1611
|
-
* @beta
|
|
1612
|
-
*/
|
|
1613
|
-
getIdentityType(): IdentityType;
|
|
1614
|
-
/**
|
|
1615
|
-
* Credential instance according to identity type choice.
|
|
1616
|
-
*
|
|
1617
|
-
* @remarks If user identity is chose, will return {@link TeamsUserCredential}
|
|
1618
|
-
* in browser environment and {@link OnBehalfOfUserCredential} in NodeJS. If app
|
|
1619
|
-
* identity is chose, will return {@link AppCredential}.
|
|
1620
|
-
*
|
|
1621
|
-
* @returns instance implements TokenCredential interface.
|
|
1622
|
-
* @beta
|
|
1623
|
-
*/
|
|
1624
|
-
getCredential(): TokenCredential;
|
|
1625
|
-
/**
|
|
1626
|
-
* Get user information.
|
|
1627
|
-
* @returns UserInfo object.
|
|
1628
|
-
* @beta
|
|
1629
|
-
*/
|
|
1630
|
-
getUserInfo(): Promise<UserInfo>;
|
|
1631
|
-
/**
|
|
1632
|
-
* Popup login page to get user's access token with specific scopes.
|
|
1633
|
-
*
|
|
1634
|
-
* @remarks
|
|
1635
|
-
* Only works in Teams client APP. User will be redirected to the authorization page to login and consent.
|
|
1636
|
-
*
|
|
1637
|
-
* @example
|
|
1638
|
-
* ```typescript
|
|
1639
|
-
* await teamsfx.login(["https://graph.microsoft.com/User.Read"]); // single scope using string array
|
|
1640
|
-
* await teamsfx.login("https://graph.microsoft.com/User.Read"); // single scopes using string
|
|
1641
|
-
* await teamsfx.login(["https://graph.microsoft.com/User.Read", "Calendars.Read"]); // multiple scopes using string array
|
|
1642
|
-
* await teamsfx.login("https://graph.microsoft.com/User.Read Calendars.Read"); // multiple scopes using string
|
|
1643
|
-
* ```
|
|
1644
|
-
* @param scopes - The list of scopes for which the token will have access, before that, we will request user to consent.
|
|
1645
|
-
*
|
|
1646
|
-
* @throws {@link ErrorCode|InternalError} when failed to login with unknown error.
|
|
1647
|
-
* @throws {@link ErrorCode|ConsentFailed} when user canceled or failed to consent.
|
|
1648
|
-
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
1649
|
-
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
|
1650
|
-
*
|
|
1651
|
-
* @beta
|
|
1652
|
-
*/
|
|
1653
|
-
login(scopes: string | string[]): Promise<void>;
|
|
1654
|
-
/**
|
|
1655
|
-
* Set SSO token when using user identity in NodeJS.
|
|
1656
|
-
* @param {string} ssoToken - used for on behalf of user flow.
|
|
1657
|
-
* @returns self instance.
|
|
1658
|
-
* @beta
|
|
1659
|
-
*/
|
|
1660
|
-
setSsoToken(ssoToken: string): TeamsFx;
|
|
1661
|
-
/**
|
|
1662
|
-
* Usually used by service plugins to retrieve specific config
|
|
1663
|
-
* @param {string} key - configuration key.
|
|
1664
|
-
* @returns value in configuration.
|
|
1665
|
-
* @beta
|
|
1666
|
-
*/
|
|
1667
|
-
getConfig(key: string): string;
|
|
1668
|
-
/**
|
|
1669
|
-
* Check the value of specific key.
|
|
1670
|
-
* @param {string} key - configuration key.
|
|
1671
|
-
* @returns true if corresponding value is not empty string.
|
|
1672
|
-
* @beta
|
|
1673
|
-
*/
|
|
1674
|
-
hasConfig(key: string): boolean;
|
|
1675
|
-
/**
|
|
1676
|
-
* Get all configurations.
|
|
1677
|
-
* @returns key value mappings.
|
|
1678
|
-
* @beta
|
|
1679
|
-
*/
|
|
1680
|
-
getConfigs(): Record<string, string>;
|
|
1681
|
-
/**
|
|
1682
|
-
* Load configuration from environment variables.
|
|
1683
|
-
*/
|
|
1684
|
-
private loadFromEnv;
|
|
1685
|
-
}
|
|
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
|
+
}
|
|
1686
836
|
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
/**
|
|
1694
|
-
* The string or regular expression patterns that can trigger this handler.
|
|
1695
|
-
*/
|
|
1696
|
-
triggerPatterns: TriggerPatterns;
|
|
1697
|
-
/**
|
|
1698
|
-
* Handles a bot command received activity.
|
|
1699
|
-
*
|
|
1700
|
-
* @param context The bot context.
|
|
1701
|
-
* @param message The command message the user types from Teams.
|
|
1702
|
-
* @returns A `Promise` representing an activity or text to send as the command response.
|
|
1703
|
-
*/
|
|
1704
|
-
handleCommandReceived(context: TurnContext, message: CommandMessage): Promise<string | Partial<Activity>>;
|
|
1705
|
-
}
|
|
837
|
+
/**
|
|
838
|
+
* Log function for customized logging.
|
|
839
|
+
*
|
|
840
|
+
* @beta
|
|
841
|
+
*/
|
|
842
|
+
export declare type LogFunction = (level: LogLevel, message: string) => void;
|
|
1706
843
|
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
declare interface
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
getCredential(): TokenCredential;
|
|
1730
|
-
/**
|
|
1731
|
-
* Get user information.
|
|
1732
|
-
* @returns UserInfo object.
|
|
1733
|
-
* @beta
|
|
1734
|
-
*/
|
|
1735
|
-
getUserInfo(): Promise<UserInfo>;
|
|
1736
|
-
/**
|
|
1737
|
-
* Popup login page to get user's access token with specific scopes.
|
|
1738
|
-
*
|
|
1739
|
-
* @remarks
|
|
1740
|
-
* Only works in Teams client APP. User will be redirected to the authorization page to login and consent.
|
|
1741
|
-
*
|
|
1742
|
-
* @example
|
|
1743
|
-
* ```typescript
|
|
1744
|
-
* await teamsfx.login(["https://graph.microsoft.com/User.Read"]); // single scope using string array
|
|
1745
|
-
* await teamsfx.login("https://graph.microsoft.com/User.Read"); // single scopes using string
|
|
1746
|
-
* await teamsfx.login(["https://graph.microsoft.com/User.Read", "Calendars.Read"]); // multiple scopes using string array
|
|
1747
|
-
* await teamsfx.login("https://graph.microsoft.com/User.Read Calendars.Read"); // multiple scopes using string
|
|
1748
|
-
* ```
|
|
1749
|
-
* @param scopes - The list of scopes for which the token will have access, before that, we will request user to consent.
|
|
1750
|
-
*
|
|
1751
|
-
* @throws {@link ErrorCode|InternalError} when failed to login with unknown error.
|
|
1752
|
-
* @throws {@link ErrorCode|ConsentFailed} when user canceled or failed to consent.
|
|
1753
|
-
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
1754
|
-
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
|
1755
|
-
*
|
|
1756
|
-
* @beta
|
|
1757
|
-
*/
|
|
1758
|
-
login(scopes: string | string[]): Promise<void>;
|
|
1759
|
-
/**
|
|
1760
|
-
* Set SSO token when using user identity in NodeJS.
|
|
1761
|
-
* @param {string} ssoToken - used for on behalf of user flow.
|
|
1762
|
-
* @returns self instance.
|
|
1763
|
-
* @beta
|
|
1764
|
-
*/
|
|
1765
|
-
setSsoToken(ssoToken: string): TeamsFxConfiguration;
|
|
1766
|
-
/**
|
|
1767
|
-
* Usually used by service plugins to retrieve specific config
|
|
1768
|
-
* @param {string} key - configuration key.
|
|
1769
|
-
* @returns value in configuration.
|
|
1770
|
-
* @beta
|
|
1771
|
-
*/
|
|
1772
|
-
getConfig(key: string): string;
|
|
1773
|
-
/**
|
|
1774
|
-
* Check the value of specific key.
|
|
1775
|
-
* @param {string} key - configuration key.
|
|
1776
|
-
* @returns true if corresponding value is not empty string.
|
|
1777
|
-
* @beta
|
|
1778
|
-
*/
|
|
1779
|
-
hasConfig(key: string): boolean;
|
|
1780
|
-
/**
|
|
1781
|
-
* Get all configurations.
|
|
1782
|
-
* @returns key value mappings.
|
|
1783
|
-
* @beta
|
|
1784
|
-
*/
|
|
1785
|
-
getConfigs(): Record<string, string>;
|
|
1786
|
-
}
|
|
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
|
+
}
|
|
1787
866
|
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
/**
|
|
1812
|
-
* Get access token from credential.
|
|
1813
|
-
* @remarks
|
|
1814
|
-
* Can only be used within Teams.
|
|
1815
|
-
* @beta
|
|
1816
|
-
*/
|
|
1817
|
-
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
|
|
1818
|
-
/**
|
|
1819
|
-
* Get basic user info from SSO token
|
|
1820
|
-
* @remarks
|
|
1821
|
-
* Can only be used within Teams.
|
|
1822
|
-
* @beta
|
|
1823
|
-
*/
|
|
1824
|
-
getUserInfo(): Promise<UserInfo>;
|
|
1825
|
-
}
|
|
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
|
+
}
|
|
1826
890
|
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
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
|
+
}
|
|
1831
953
|
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
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
|
+
}
|
|
1082
|
+
|
|
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
|
+
}
|
|
1118
|
+
|
|
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
|
+
}
|
|
1151
|
+
|
|
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 }
|
|
1174
|
+
|
|
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
|
+
}
|
|
1204
|
+
|
|
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
|
+
}
|
|
1253
|
+
|
|
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";
|
|
1265
|
+
|
|
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
|
+
}
|
|
1352
|
+
|
|
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>;
|
|
1363
|
+
|
|
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>;
|
|
1374
|
+
|
|
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;
|
|
1392
|
+
|
|
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;
|
|
1411
|
+
|
|
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;
|
|
1420
|
+
|
|
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
|
+
}
|
|
1503
|
+
|
|
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
|
+
}
|
|
1650
|
+
|
|
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
|
+
}
|
|
1674
|
+
|
|
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
|
+
}
|
|
1690
|
+
|
|
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
|
+
}
|
|
1891
|
+
|
|
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
|
+
}
|
|
1857
1961
|
|
|
1858
|
-
|
|
1962
|
+
export { }
|