@microsoft/teamsfx 0.6.3-alpha.8d048e1f1.0 → 0.6.3-alpha.99edddd1f.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/teamsfx",
3
- "version": "0.6.3-alpha.8d048e1f1.0",
3
+ "version": "0.6.3-alpha.99edddd1f.0",
4
4
  "description": "Microsoft Teams Framework for Node.js and browser.",
5
5
  "main": "dist/index.node.cjs.js",
6
6
  "browser": "dist/index.esm2017.js",
@@ -49,7 +49,7 @@
49
49
  "@azure/identity": "^2.0.1",
50
50
  "@azure/msal-browser": "^2.21.0",
51
51
  "@azure/msal-node": "~1.1.0",
52
- "@microsoft/adaptivecards-tools": "0.1.6-alpha.8d048e1f1.0",
52
+ "@microsoft/adaptivecards-tools": "0.1.6-alpha.99edddd1f.0",
53
53
  "@microsoft/microsoft-graph-client": "^3.0.1",
54
54
  "axios": "^0.24.0",
55
55
  "botbuilder": ">=4.15.0 <5.0.0",
@@ -128,7 +128,7 @@
128
128
  "webpack": "^5.62.1",
129
129
  "yargs": "^17.2.1"
130
130
  },
131
- "gitHead": "d55f232456a8deb251fe611625ca23ead1d7421a",
131
+ "gitHead": "61cd724dac104531901eedb4f815c19d0a7775e4",
132
132
  "publishConfig": {
133
133
  "access": "public"
134
134
  },
@@ -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.
176
272
  * Refer https://axios-http.com/docs/req_config for detailed document.
177
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.
303
+ * Refer https://axios-http.com/docs/req_config for detailed document.
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 triggerPatterns} in a {@link TeamsFxBotCommandHandler} instance.
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, channel, incoming wehbook).
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
- * options: {
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 notificaations at any time.
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.options.storage` in {@link ConversationOptions} to use your own storage implementation.
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 with BOT_ID and BOT_PASSWORD from environment variables.
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: boolean;
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: boolean;
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
 
@@ -514,6 +675,38 @@ export declare function createApiClient(apiEndpoint: string, authProvider: AuthP
514
675
  */
515
676
  export declare function createMicrosoftGraphClient(teamsfx: TeamsFxConfiguration, scopes?: string | string[]): Client;
516
677
 
678
+ /**
679
+ * Helper to create SecureContextOptions from PEM format cert
680
+ *
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 { {passphrase?: string; ca?: string | Buffer} } options - Optional settings when create the cert options.
684
+ *
685
+ * @returns Instance of SecureContextOptions
686
+ *
687
+ * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
688
+ *
689
+ */
690
+ export declare function createPemCertOption(cert: string | Buffer, key: string | Buffer, options?: {
691
+ passphrase?: string;
692
+ ca?: string | Buffer;
693
+ }): SecureContextOptions;
694
+
695
+ /**
696
+ * Helper to create SecureContextOptions from PFX format cert
697
+ *
698
+ * @param { string | Buffer } pfx - The content of .pfx file
699
+ * @param { {passphrase?: string} } options - Optional settings when create the cert options.
700
+ *
701
+ * @returns Instance of SecureContextOptions
702
+ *
703
+ * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
704
+ *
705
+ */
706
+ export declare function createPfxCertOption(pfx: string | Buffer, options?: {
707
+ passphrase?: string;
708
+ }): SecureContextOptions;
709
+
517
710
  /**
518
711
  * Error code to trace the error types.
519
712
  * @beta
@@ -570,7 +763,11 @@ export declare enum ErrorCode {
570
763
  /**
571
764
  * Identity type error.
572
765
  */
573
- IdentityTypeNotSupported = "IdentityTypeNotSupported"
766
+ IdentityTypeNotSupported = "IdentityTypeNotSupported",
767
+ /**
768
+ * Authentication info already exists error.
769
+ */
770
+ AuthorizationInfoAlreadyExists = "AuthorizationInfoAlreadyExists"
574
771
  }
575
772
 
576
773
  /**
@@ -761,8 +958,8 @@ export declare class MessageBuilder {
761
958
  /**
762
959
  * Build a bot message activity attached with adaptive card.
763
960
  *
764
- * @param getCardData Function to prepare your card data.
765
961
  * @param cardTemplate The adaptive card template.
962
+ * @param data card data used to render the template.
766
963
  * @returns A bot message activity attached with an adaptive card.
767
964
  *
768
965
  * @example
@@ -787,16 +984,16 @@ export declare class MessageBuilder {
787
984
  * title: string,
788
985
  * description: string
789
986
  * };
790
- * const card = MessageBuilder.attachAdaptiveCard<CardData>(() => {
791
- * return {
792
- * title: "sample card title",
793
- * description: "sample card description"
794
- * }}, cardTemplate);
987
+ * const card = MessageBuilder.attachAdaptiveCard<CardData>(
988
+ * cardTemplate, {
989
+ * title: "sample card title",
990
+ * description: "sample card description"
991
+ * });
795
992
  * ```
796
993
  *
797
994
  * @beta
798
995
  */
799
- static attachAdaptiveCard<TData>(getCardData: () => TData, cardTemplate: any): Partial<Activity_2>;
996
+ static attachAdaptiveCard<TData>(cardTemplate: any, data: TData): Partial<Activity_2>;
800
997
  /**
801
998
  * Build a bot message activity attached with an adaptive card.
802
999
  *
@@ -920,7 +1117,7 @@ export declare class MsGraphAuthProvider implements AuthenticationProvider {
920
1117
  }
921
1118
 
922
1119
  /**
923
- * Provide utilities to send notification to varies targets (e.g., member, channel, incoming wehbook).
1120
+ * Provide utilities to send notification to varies targets (e.g., member, group, channel).
924
1121
  *
925
1122
  * @beta
926
1123
  */