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