@microsoft/teamsfx 0.3.0-alpha.def66483.0 → 0.3.0-rc.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/README.md +42 -17
- package/dist/index.js +127 -53
- package/dist/index.js.map +1 -1
- package/dist/teamsfx.js +30 -0
- package/dist/teamsfx.js.map +1 -0
- package/dist-esm/src/bot/teamsBotSsoPrompt.js +7 -4
- package/dist-esm/src/bot/teamsBotSsoPrompt.js.map +1 -1
- package/dist-esm/src/core/errors.js +4 -0
- package/dist-esm/src/core/errors.js.map +1 -1
- package/dist-esm/src/credential/m365TenantCredential.js +19 -21
- package/dist-esm/src/credential/m365TenantCredential.js.map +1 -1
- package/dist-esm/src/credential/onBehalfOfUserCredential.js +8 -17
- package/dist-esm/src/credential/onBehalfOfUserCredential.js.map +1 -1
- package/dist-esm/src/credential/teamsUserCredential.browser.js.map +1 -1
- package/dist-esm/src/models/configuration.js.map +1 -1
- package/dist-esm/src/util/logger.js +22 -3
- package/dist-esm/src/util/logger.js.map +1 -1
- package/dist-esm/src/util/utils.js +38 -0
- package/dist-esm/src/util/utils.js.map +1 -1
- package/dist-esm/src/util/utils.node.js +23 -0
- package/dist-esm/src/util/utils.node.js.map +1 -0
- package/package.json +24 -19
- package/types/teamsfx.d.ts +900 -871
package/types/teamsfx.d.ts
CHANGED
|
@@ -1,871 +1,900 @@
|
|
|
1
|
-
import { AccessToken } from '@azure/identity';
|
|
2
|
-
import { AuthenticationProvider } from '@microsoft/microsoft-graph-client';
|
|
3
|
-
import { Client } from '@microsoft/microsoft-graph-client';
|
|
4
|
-
import { ConnectionConfig } from 'tedious';
|
|
5
|
-
import { Dialog } from 'botbuilder-dialogs';
|
|
6
|
-
import { DialogContext } from 'botbuilder-dialogs';
|
|
7
|
-
import { DialogTurnResult } from 'botbuilder-dialogs';
|
|
8
|
-
import { GetTokenOptions } from '@azure/identity';
|
|
9
|
-
import { TokenCredential } from '@azure/identity';
|
|
10
|
-
import { TokenResponse } from 'botframework-schema';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Authentication related configuration.
|
|
14
|
-
* @beta
|
|
15
|
-
*/
|
|
16
|
-
export declare interface AuthenticationConfiguration {
|
|
17
|
-
/**
|
|
18
|
-
* Hostname of AAD authority. Default value comes from M365_AUTHORITY_HOST environment variable.
|
|
19
|
-
*
|
|
20
|
-
* @readonly
|
|
21
|
-
*/
|
|
22
|
-
readonly authorityHost?: string;
|
|
23
|
-
/**
|
|
24
|
-
* AAD tenant id, default value comes from M365_TENANT_ID environment variable.
|
|
25
|
-
*
|
|
26
|
-
* @readonly
|
|
27
|
-
*/
|
|
28
|
-
readonly tenantId?: string;
|
|
29
|
-
/**
|
|
30
|
-
* The client (application) ID of an App Registration in the tenant, default value comes from M365_CLIENT_ID environment variable
|
|
31
|
-
*
|
|
32
|
-
* @readonly
|
|
33
|
-
*/
|
|
34
|
-
readonly clientId?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Secret string that the application uses when requesting a token. Only used in confidential client applications. Can be created in the Azure app registration portal. Default value comes from M365_CLIENT_SECRET environment variable
|
|
37
|
-
*
|
|
38
|
-
* @readonly
|
|
39
|
-
*/
|
|
40
|
-
readonly clientSecret?: string;
|
|
41
|
-
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* @readonly
|
|
45
|
-
*/
|
|
46
|
-
readonly
|
|
47
|
-
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* @readonly
|
|
51
|
-
*/
|
|
52
|
-
readonly
|
|
53
|
-
/**
|
|
54
|
-
*
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* @readonly
|
|
74
|
-
*/
|
|
75
|
-
readonly
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* const
|
|
93
|
-
* const
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* const
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* const
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* @
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
*
|
|
133
|
-
* @
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
* @
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
* @
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
*
|
|
166
|
-
* @
|
|
167
|
-
*
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
* @
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
* @
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
* @
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
* @
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
* @
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
*
|
|
421
|
-
* @
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
private
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
* @throws {@link ErrorCode|
|
|
451
|
-
*
|
|
452
|
-
* @
|
|
453
|
-
*
|
|
454
|
-
* @
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
*
|
|
491
|
-
*
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
* @
|
|
498
|
-
*
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
*
|
|
509
|
-
*
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
*
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
* @
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
* @
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
*
|
|
532
|
-
*
|
|
533
|
-
* @
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
*
|
|
537
|
-
*
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
* @
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
*
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
/**
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
*
|
|
607
|
-
*
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
*
|
|
613
|
-
*
|
|
614
|
-
*
|
|
615
|
-
*
|
|
616
|
-
*
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
*
|
|
623
|
-
*
|
|
624
|
-
* @
|
|
625
|
-
*
|
|
626
|
-
*
|
|
627
|
-
*
|
|
628
|
-
*
|
|
629
|
-
*
|
|
630
|
-
*
|
|
631
|
-
*
|
|
632
|
-
*
|
|
633
|
-
*
|
|
634
|
-
*
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
*
|
|
642
|
-
*
|
|
643
|
-
*
|
|
644
|
-
*
|
|
645
|
-
*
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
*
|
|
651
|
-
*
|
|
652
|
-
*
|
|
653
|
-
*
|
|
654
|
-
*
|
|
655
|
-
*
|
|
656
|
-
*
|
|
657
|
-
*
|
|
658
|
-
*
|
|
659
|
-
*
|
|
660
|
-
*
|
|
661
|
-
*
|
|
662
|
-
*
|
|
663
|
-
*
|
|
664
|
-
*
|
|
665
|
-
*
|
|
666
|
-
*
|
|
667
|
-
*
|
|
668
|
-
*
|
|
669
|
-
* @
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
/**
|
|
703
|
-
*
|
|
704
|
-
*
|
|
705
|
-
* @
|
|
706
|
-
*
|
|
707
|
-
*
|
|
708
|
-
*
|
|
709
|
-
*
|
|
710
|
-
*
|
|
711
|
-
* @
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
*
|
|
716
|
-
* @
|
|
717
|
-
*
|
|
718
|
-
*
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
*
|
|
723
|
-
* @
|
|
724
|
-
* @throws {@link ErrorCode|
|
|
725
|
-
*
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
*
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
*
|
|
737
|
-
*
|
|
738
|
-
*
|
|
739
|
-
*
|
|
740
|
-
* @
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
* @
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
* @
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
*
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
*
|
|
778
|
-
*/
|
|
779
|
-
|
|
780
|
-
/**
|
|
781
|
-
*
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
*
|
|
826
|
-
*/
|
|
827
|
-
|
|
828
|
-
/**
|
|
829
|
-
*
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
*
|
|
853
|
-
*
|
|
854
|
-
* @
|
|
855
|
-
*/
|
|
856
|
-
|
|
857
|
-
/**
|
|
858
|
-
*
|
|
859
|
-
*
|
|
860
|
-
*
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
*
|
|
866
|
-
* @
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
1
|
+
import { AccessToken } from '@azure/identity';
|
|
2
|
+
import { AuthenticationProvider } from '@microsoft/microsoft-graph-client';
|
|
3
|
+
import { Client } from '@microsoft/microsoft-graph-client';
|
|
4
|
+
import { ConnectionConfig } from 'tedious';
|
|
5
|
+
import { Dialog } from 'botbuilder-dialogs';
|
|
6
|
+
import { DialogContext } from 'botbuilder-dialogs';
|
|
7
|
+
import { DialogTurnResult } from 'botbuilder-dialogs';
|
|
8
|
+
import { GetTokenOptions } from '@azure/identity';
|
|
9
|
+
import { TokenCredential } from '@azure/identity';
|
|
10
|
+
import { TokenResponse } from 'botframework-schema';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Authentication related configuration.
|
|
14
|
+
* @beta
|
|
15
|
+
*/
|
|
16
|
+
export declare interface AuthenticationConfiguration {
|
|
17
|
+
/**
|
|
18
|
+
* Hostname of AAD authority. Default value comes from M365_AUTHORITY_HOST environment variable.
|
|
19
|
+
*
|
|
20
|
+
* @readonly
|
|
21
|
+
*/
|
|
22
|
+
readonly authorityHost?: string;
|
|
23
|
+
/**
|
|
24
|
+
* AAD tenant id, default value comes from M365_TENANT_ID environment variable.
|
|
25
|
+
*
|
|
26
|
+
* @readonly
|
|
27
|
+
*/
|
|
28
|
+
readonly tenantId?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The client (application) ID of an App Registration in the tenant, default value comes from M365_CLIENT_ID environment variable
|
|
31
|
+
*
|
|
32
|
+
* @readonly
|
|
33
|
+
*/
|
|
34
|
+
readonly clientId?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Secret string that the application uses when requesting a token. Only used in confidential client applications. Can be created in the Azure app registration portal. Default value comes from M365_CLIENT_SECRET environment variable
|
|
37
|
+
*
|
|
38
|
+
* @readonly
|
|
39
|
+
*/
|
|
40
|
+
readonly clientSecret?: string;
|
|
41
|
+
/**
|
|
42
|
+
* The content of a PEM-encoded public/private key certificate.
|
|
43
|
+
*
|
|
44
|
+
* @readonly
|
|
45
|
+
*/
|
|
46
|
+
readonly certificateContent?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Endpoint of auth service provisioned by Teams Framework. Default value comes from SIMPLE_AUTH_ENDPOINT environment variable.
|
|
49
|
+
*
|
|
50
|
+
* @readonly
|
|
51
|
+
*/
|
|
52
|
+
readonly simpleAuthEndpoint?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Login page for Teams to redirect to. Default value comes from INITIATE_LOGIN_ENDPOINT environment variable.
|
|
55
|
+
*
|
|
56
|
+
* @readonly
|
|
57
|
+
*/
|
|
58
|
+
readonly initiateLoginEndpoint?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Application ID URI. Default value comes from M365_APPLICATION_ID_URI environment variable.
|
|
61
|
+
*/
|
|
62
|
+
readonly applicationIdUri?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Configuration for current environment.
|
|
67
|
+
* @beta
|
|
68
|
+
*/
|
|
69
|
+
export declare interface Configuration {
|
|
70
|
+
/**
|
|
71
|
+
* Authentication related configuration.
|
|
72
|
+
*
|
|
73
|
+
* @readonly
|
|
74
|
+
*/
|
|
75
|
+
readonly authentication?: AuthenticationConfiguration;
|
|
76
|
+
/**
|
|
77
|
+
* Configuration for resources.
|
|
78
|
+
*
|
|
79
|
+
* @readonly
|
|
80
|
+
*/
|
|
81
|
+
readonly resources?: ResourceConfiguration[];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Get Microsoft graph client.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* Get Microsoft graph client by TokenCredential
|
|
89
|
+
* ```typescript
|
|
90
|
+
* // Sso token example (Azure Function)
|
|
91
|
+
* const ssoToken = "YOUR_TOKEN_STRING";
|
|
92
|
+
* const options = {"AAD_APP_ID", "AAD_APP_SECRET"};
|
|
93
|
+
* const credential = new OnBehalfOfAADUserCredential(ssoToken, options);
|
|
94
|
+
* const graphClient = await createMicrosoftGraphClient(credential);
|
|
95
|
+
* const profile = await graphClient.api("/me").get();
|
|
96
|
+
*
|
|
97
|
+
* // TeamsBotSsoPrompt example (Bot Application)
|
|
98
|
+
* const requiredScopes = ["User.Read"];
|
|
99
|
+
* const config: Configuration = {
|
|
100
|
+
* loginUrl: loginUrl,
|
|
101
|
+
* clientId: clientId,
|
|
102
|
+
* clientSecret: clientSecret,
|
|
103
|
+
* tenantId: tenantId
|
|
104
|
+
* };
|
|
105
|
+
* const prompt = new TeamsBotSsoPrompt(dialogId, {
|
|
106
|
+
* config: config
|
|
107
|
+
* scopes: '["User.Read"],
|
|
108
|
+
* });
|
|
109
|
+
* this.addDialog(prompt);
|
|
110
|
+
*
|
|
111
|
+
* const oboCredential = new OnBehalfOfAADUserCredential(
|
|
112
|
+
* getUserId(dialogContext),
|
|
113
|
+
* {
|
|
114
|
+
* clientId: "AAD_APP_ID",
|
|
115
|
+
* clientSecret: "AAD_APP_SECRET"
|
|
116
|
+
* });
|
|
117
|
+
* try {
|
|
118
|
+
* const graphClient = await createMicrosoftGraphClient(credential);
|
|
119
|
+
* const profile = await graphClient.api("/me").get();
|
|
120
|
+
* } catch (e) {
|
|
121
|
+
* dialogContext.beginDialog(dialogId);
|
|
122
|
+
* return Dialog.endOfTurn();
|
|
123
|
+
* }
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* @param {TokenCredential} credential - token credential instance.
|
|
127
|
+
* @param scopes - The array of Microsoft Token scope of access. Default value is `[.default]`.
|
|
128
|
+
*
|
|
129
|
+
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
130
|
+
*
|
|
131
|
+
* @returns Graph client with specified scopes.
|
|
132
|
+
*
|
|
133
|
+
* @beta
|
|
134
|
+
*/
|
|
135
|
+
export declare function createMicrosoftGraphClient(credential: TokenCredential, scopes?: string | string[]): Client;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* SQL connection configuration instance.
|
|
139
|
+
* @remarks
|
|
140
|
+
* Only works in in server side.
|
|
141
|
+
*
|
|
142
|
+
* @beta
|
|
143
|
+
*
|
|
144
|
+
*/
|
|
145
|
+
export declare class DefaultTediousConnectionConfiguration {
|
|
146
|
+
/**
|
|
147
|
+
* MSSQL default scope
|
|
148
|
+
* https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-connect-msi
|
|
149
|
+
*/
|
|
150
|
+
private readonly defaultSQLScope;
|
|
151
|
+
/**
|
|
152
|
+
* Generate connection configuration consumed by tedious.
|
|
153
|
+
*
|
|
154
|
+
* @returns Connection configuration of tedious for the SQL.
|
|
155
|
+
*
|
|
156
|
+
* @throws {@link ErrorCode|InvalidConfiguration} when SQL config resource configuration is invalid.
|
|
157
|
+
* @throws {@link ErrorCode|InternalError} when get user MSI token failed or MSI token is invalid.
|
|
158
|
+
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
|
159
|
+
*
|
|
160
|
+
* @beta
|
|
161
|
+
*/
|
|
162
|
+
getConfig(): Promise<ConnectionConfig>;
|
|
163
|
+
/**
|
|
164
|
+
* Check SQL use MSI identity or username and password.
|
|
165
|
+
*
|
|
166
|
+
* @returns false - login with SQL MSI identity, true - login with username and password.
|
|
167
|
+
* @internal
|
|
168
|
+
*/
|
|
169
|
+
private isMsiAuthentication;
|
|
170
|
+
/**
|
|
171
|
+
* check configuration is an available configurations.
|
|
172
|
+
* @param { SqlConfiguration } sqlConfig
|
|
173
|
+
*
|
|
174
|
+
* @returns true - SQL configuration has a valid SQL endpoints, SQL username with password or identity ID.
|
|
175
|
+
* false - configuration is not valid.
|
|
176
|
+
* @internal
|
|
177
|
+
*/
|
|
178
|
+
private isSQLConfigurationValid;
|
|
179
|
+
/**
|
|
180
|
+
* Generate tedious connection configuration with default authentication type.
|
|
181
|
+
*
|
|
182
|
+
* @param { SqlConfiguration } SQL configuration with username and password.
|
|
183
|
+
*
|
|
184
|
+
* @returns Tedious connection configuration with username and password.
|
|
185
|
+
* @internal
|
|
186
|
+
*/
|
|
187
|
+
private generateDefaultConfig;
|
|
188
|
+
/**
|
|
189
|
+
* Generate tedious connection configuration with azure-active-directory-access-token authentication type.
|
|
190
|
+
*
|
|
191
|
+
* @param { SqlConfiguration } SQL configuration with AAD access token.
|
|
192
|
+
*
|
|
193
|
+
* @returns Tedious connection configuration with access token.
|
|
194
|
+
* @internal
|
|
195
|
+
*/
|
|
196
|
+
private generateTokenConfig;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Error code to trace the error types.
|
|
201
|
+
* @beta
|
|
202
|
+
*/
|
|
203
|
+
export declare enum ErrorCode {
|
|
204
|
+
/**
|
|
205
|
+
* Invalid parameter error.
|
|
206
|
+
*/
|
|
207
|
+
InvalidParameter = "InvalidParameter",
|
|
208
|
+
/**
|
|
209
|
+
* Invalid configuration error.
|
|
210
|
+
*/
|
|
211
|
+
InvalidConfiguration = "InvalidConfiguration",
|
|
212
|
+
/**
|
|
213
|
+
* Invalid certificate error.
|
|
214
|
+
*/
|
|
215
|
+
InvalidCertificate = "InvalidCertificate",
|
|
216
|
+
/**
|
|
217
|
+
* Internal error.
|
|
218
|
+
*/
|
|
219
|
+
InternalError = "InternalError",
|
|
220
|
+
/**
|
|
221
|
+
* Channel is not supported error.
|
|
222
|
+
*/
|
|
223
|
+
ChannelNotSupported = "ChannelNotSupported",
|
|
224
|
+
/**
|
|
225
|
+
* Runtime is not supported error.
|
|
226
|
+
*/
|
|
227
|
+
RuntimeNotSupported = "RuntimeNotSupported",
|
|
228
|
+
/**
|
|
229
|
+
* User failed to finish the AAD consent flow failed.
|
|
230
|
+
*/
|
|
231
|
+
ConsentFailed = "ConsentFailed",
|
|
232
|
+
/**
|
|
233
|
+
* The user or administrator has not consented to use the application error.
|
|
234
|
+
*/
|
|
235
|
+
UiRequiredError = "UiRequiredError",
|
|
236
|
+
/**
|
|
237
|
+
* Token is not within its valid time range error.
|
|
238
|
+
*/
|
|
239
|
+
TokenExpiredError = "TokenExpiredError",
|
|
240
|
+
/**
|
|
241
|
+
* Call service (AAD or simple authentication server) failed.
|
|
242
|
+
*/
|
|
243
|
+
ServiceError = "ServiceError",
|
|
244
|
+
/**
|
|
245
|
+
* Operation failed.
|
|
246
|
+
*/
|
|
247
|
+
FailedOperation = "FailedOperation"
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Error class with code and message thrown by the SDK.
|
|
252
|
+
*
|
|
253
|
+
* @beta
|
|
254
|
+
*/
|
|
255
|
+
export declare class ErrorWithCode extends Error {
|
|
256
|
+
/**
|
|
257
|
+
* Error code
|
|
258
|
+
*
|
|
259
|
+
* @readonly
|
|
260
|
+
*/
|
|
261
|
+
code: string | undefined;
|
|
262
|
+
/**
|
|
263
|
+
* Constructor of ErrorWithCode.
|
|
264
|
+
*
|
|
265
|
+
* @param {string} message - error message.
|
|
266
|
+
* @param {ErrorCode} code - error code.
|
|
267
|
+
*
|
|
268
|
+
* @beta
|
|
269
|
+
*/
|
|
270
|
+
constructor(message?: string, code?: ErrorCode);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Get configuration for authentication.
|
|
275
|
+
*
|
|
276
|
+
* @returns Authentication configuration from global configuration instance, the value may be undefined if no authentication config exists in current environment.
|
|
277
|
+
*
|
|
278
|
+
* @throws {@link ErrorCode|InvalidConfiguration} when global configuration does not exist
|
|
279
|
+
*
|
|
280
|
+
* @beta
|
|
281
|
+
*/
|
|
282
|
+
export declare function getAuthenticationConfiguration(): AuthenticationConfiguration | undefined;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Get log level.
|
|
286
|
+
*
|
|
287
|
+
* @returns Log level
|
|
288
|
+
*
|
|
289
|
+
* @beta
|
|
290
|
+
*/
|
|
291
|
+
export declare function getLogLevel(): LogLevel | undefined;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Get configuration for a specific resource.
|
|
295
|
+
* @param {ResourceType} resourceType - The type of resource
|
|
296
|
+
* @param {string} resourceName - The name of resource, default value is "default".
|
|
297
|
+
*
|
|
298
|
+
* @returns Resource configuration for target resource from global configuration instance.
|
|
299
|
+
*
|
|
300
|
+
* @throws {@link ErrorCode|InvalidConfiguration} when resource configuration with the specific type and name is not found
|
|
301
|
+
*
|
|
302
|
+
* @beta
|
|
303
|
+
*/
|
|
304
|
+
export declare function getResourceConfiguration(resourceType: ResourceType, resourceName?: string): {
|
|
305
|
+
[index: string]: any;
|
|
306
|
+
};
|
|
307
|
+
export { GetTokenOptions }
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Initialize configuration from environment variables or configuration object and set the global instance
|
|
311
|
+
*
|
|
312
|
+
* @param {Configuration} configuration - Optional configuration that overrides the default configuration values. The override depth is 1.
|
|
313
|
+
*
|
|
314
|
+
* @throws {@link ErrorCode|InvalidParameter} when configuration is not passed in browser environment
|
|
315
|
+
*
|
|
316
|
+
* @beta
|
|
317
|
+
*/
|
|
318
|
+
export declare function loadConfiguration(configuration?: Configuration): void;
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Log function for customized logging.
|
|
322
|
+
*
|
|
323
|
+
* @beta
|
|
324
|
+
*/
|
|
325
|
+
export declare type LogFunction = (level: LogLevel, message: string) => void;
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Interface for customized logger.
|
|
329
|
+
* @beta
|
|
330
|
+
*/
|
|
331
|
+
export declare interface Logger {
|
|
332
|
+
/**
|
|
333
|
+
* Writes to error level logging or lower.
|
|
334
|
+
*/
|
|
335
|
+
error(message: string): void;
|
|
336
|
+
/**
|
|
337
|
+
* Writes to warning level logging or lower.
|
|
338
|
+
*/
|
|
339
|
+
warn(message: string): void;
|
|
340
|
+
/**
|
|
341
|
+
* Writes to info level logging or lower.
|
|
342
|
+
*/
|
|
343
|
+
info(message: string): void;
|
|
344
|
+
/**
|
|
345
|
+
* Writes to verbose level logging.
|
|
346
|
+
*/
|
|
347
|
+
verbose(message: string): void;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Log level.
|
|
352
|
+
*
|
|
353
|
+
* @beta
|
|
354
|
+
*/
|
|
355
|
+
export declare enum LogLevel {
|
|
356
|
+
/**
|
|
357
|
+
* Show verbose, information, warning and error message.
|
|
358
|
+
*/
|
|
359
|
+
Verbose = 0,
|
|
360
|
+
/**
|
|
361
|
+
* Show information, warning and error message.
|
|
362
|
+
*/
|
|
363
|
+
Info = 1,
|
|
364
|
+
/**
|
|
365
|
+
* Show warning and error message.
|
|
366
|
+
*/
|
|
367
|
+
Warn = 2,
|
|
368
|
+
/**
|
|
369
|
+
* Show error message.
|
|
370
|
+
*/
|
|
371
|
+
Error = 3
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Represent Microsoft 365 tenant identity, and it is usually used when user is not involved like time-triggered automation job.
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* ```typescript
|
|
379
|
+
* loadConfiguration(); // load configuration from environment variables
|
|
380
|
+
* const credential = new M365TenantCredential();
|
|
381
|
+
* ```
|
|
382
|
+
*
|
|
383
|
+
* @remarks
|
|
384
|
+
* Only works in in server side.
|
|
385
|
+
*
|
|
386
|
+
* @beta
|
|
387
|
+
*/
|
|
388
|
+
export declare class M365TenantCredential implements TokenCredential {
|
|
389
|
+
private readonly msalClient;
|
|
390
|
+
/**
|
|
391
|
+
* Constructor of M365TenantCredential.
|
|
392
|
+
*
|
|
393
|
+
* @remarks
|
|
394
|
+
* Only works in in server side.
|
|
395
|
+
*
|
|
396
|
+
* @throws {@link ErrorCode|InvalidConfiguration} when client id, client secret or tenant id is not found in config.
|
|
397
|
+
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
|
398
|
+
*
|
|
399
|
+
* @beta
|
|
400
|
+
*/
|
|
401
|
+
constructor();
|
|
402
|
+
/**
|
|
403
|
+
* Get access token for credential.
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* ```typescript
|
|
407
|
+
* await credential.getToken(["User.Read.All"]) // Get Graph access token for single scope using string array
|
|
408
|
+
* await credential.getToken("User.Read.All") // Get Graph access token for single scope using string
|
|
409
|
+
* await credential.getToken(["User.Read.All", "Calendars.Read"]) // Get Graph access token for multiple scopes using string array
|
|
410
|
+
* await credential.getToken("User.Read.All Calendars.Read") // Get Graph access token for multiple scopes using space-separated string
|
|
411
|
+
* await credential.getToken("https://graph.microsoft.com/User.Read.All") // Get Graph access token with full resource URI
|
|
412
|
+
* await credential.getToken(["https://outlook.office.com/Mail.Read"]) // Get Outlook access token
|
|
413
|
+
* ```
|
|
414
|
+
*
|
|
415
|
+
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
|
416
|
+
* @param {GetTokenOptions} options - The options used to configure any requests this TokenCredential implementation might make.
|
|
417
|
+
*
|
|
418
|
+
* @throws {@link ErrorCode|ServiceError} when get access token with authentication error.
|
|
419
|
+
* @throws {@link ErrorCode|InternalError} when get access token with unknown error.
|
|
420
|
+
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
421
|
+
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
|
|
422
|
+
*
|
|
423
|
+
* @returns Access token with expected scopes.
|
|
424
|
+
* Throw error if get access token failed.
|
|
425
|
+
*
|
|
426
|
+
* @beta
|
|
427
|
+
*/
|
|
428
|
+
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
|
|
429
|
+
/**
|
|
430
|
+
* Load and validate authentication configuration
|
|
431
|
+
* @returns Authentication configuration
|
|
432
|
+
*/
|
|
433
|
+
private loadAndValidateConfig;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Microsoft Graph auth provider for Teams Framework
|
|
438
|
+
*
|
|
439
|
+
* @beta
|
|
440
|
+
*/
|
|
441
|
+
export declare class MsGraphAuthProvider implements AuthenticationProvider {
|
|
442
|
+
private credential;
|
|
443
|
+
private scopes;
|
|
444
|
+
/**
|
|
445
|
+
* Constructor of MsGraphAuthProvider.
|
|
446
|
+
*
|
|
447
|
+
* @param {TokenCredential} credential - Credential used to invoke Microsoft Graph APIs.
|
|
448
|
+
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
|
449
|
+
*
|
|
450
|
+
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
451
|
+
*
|
|
452
|
+
* @returns An instance of MsGraphAuthProvider.
|
|
453
|
+
*
|
|
454
|
+
* @beta
|
|
455
|
+
*/
|
|
456
|
+
constructor(credential: TokenCredential, scopes?: string | string[]);
|
|
457
|
+
/**
|
|
458
|
+
* Get access token for Microsoft Graph API requests.
|
|
459
|
+
*
|
|
460
|
+
* @throws {@link ErrorCode|InternalError} when get access token failed due to empty token or unknown other problems.
|
|
461
|
+
* @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
|
|
462
|
+
* @throws {@link ErrorCode|UiRequiredError} when need user consent to get access token.
|
|
463
|
+
* @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth or AAD server.
|
|
464
|
+
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
465
|
+
*
|
|
466
|
+
* @returns Access token from the credential.
|
|
467
|
+
*
|
|
468
|
+
*/
|
|
469
|
+
getAccessToken(): Promise<string>;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Represent on-behalf-of flow to get user identity, and it is designed to be used in server side.
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* ```typescript
|
|
477
|
+
* loadConfiguration(); // load configuration from environment variables
|
|
478
|
+
* const credential = new OnBehalfOfUserCredential(ssoToken);
|
|
479
|
+
* ```
|
|
480
|
+
*
|
|
481
|
+
* @remarks
|
|
482
|
+
* Can only be used in server side.
|
|
483
|
+
*
|
|
484
|
+
* @beta
|
|
485
|
+
*/
|
|
486
|
+
export declare class OnBehalfOfUserCredential implements TokenCredential {
|
|
487
|
+
private msalClient;
|
|
488
|
+
private ssoToken;
|
|
489
|
+
/**
|
|
490
|
+
* Constructor of OnBehalfOfUserCredential
|
|
491
|
+
*
|
|
492
|
+
* @remarks
|
|
493
|
+
* Only works in in server side.
|
|
494
|
+
*
|
|
495
|
+
* @param {string} ssoToken - User token provided by Teams SSO feature.
|
|
496
|
+
*
|
|
497
|
+
* @throws {@link ErrorCode|InvalidConfiguration} when client id, client secret, certificate content, authority host or tenant id is not found in config.
|
|
498
|
+
* @throws {@link ErrorCode|InternalError} when SSO token is not valid.
|
|
499
|
+
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
|
500
|
+
*
|
|
501
|
+
* @beta
|
|
502
|
+
*/
|
|
503
|
+
constructor(ssoToken: string);
|
|
504
|
+
/**
|
|
505
|
+
* Get access token from credential.
|
|
506
|
+
*
|
|
507
|
+
* @example
|
|
508
|
+
* ```typescript
|
|
509
|
+
* await credential.getToken([]) // Get SSO token using empty string array
|
|
510
|
+
* await credential.getToken("") // Get SSO token using empty string
|
|
511
|
+
* await credential.getToken([".default"]) // Get Graph access token with default scope using string array
|
|
512
|
+
* await credential.getToken(".default") // Get Graph access token with default scope using string
|
|
513
|
+
* await credential.getToken(["User.Read"]) // Get Graph access token for single scope using string array
|
|
514
|
+
* await credential.getToken("User.Read") // Get Graph access token for single scope using string
|
|
515
|
+
* await credential.getToken(["User.Read", "Application.Read.All"]) // Get Graph access token for multiple scopes using string array
|
|
516
|
+
* await credential.getToken("User.Read Application.Read.All") // Get Graph access token for multiple scopes using space-separated string
|
|
517
|
+
* await credential.getToken("https://graph.microsoft.com/User.Read") // Get Graph access token with full resource URI
|
|
518
|
+
* await credential.getToken(["https://outlook.office.com/Mail.Read"]) // Get Outlook access token
|
|
519
|
+
* ```
|
|
520
|
+
*
|
|
521
|
+
* @param {string | string[]} scopes - The list of scopes for which the token will have access.
|
|
522
|
+
* @param {GetTokenOptions} options - The options used to configure any requests this TokenCredential implementation might make.
|
|
523
|
+
*
|
|
524
|
+
* @throws {@link ErrorCode|InternalError} when failed to acquire access token on behalf of user with unknown error.
|
|
525
|
+
* @throws {@link ErrorCode|TokenExpiredError} when SSO token has already expired.
|
|
526
|
+
* @throws {@link ErrorCode|UiRequiredError} when need user consent to get access token.
|
|
527
|
+
* @throws {@link ErrorCode|ServiceError} when failed to get access token from simple auth server.
|
|
528
|
+
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
529
|
+
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
|
530
|
+
*
|
|
531
|
+
* @returns Access token with expected scopes.
|
|
532
|
+
*
|
|
533
|
+
* @remarks
|
|
534
|
+
* If scopes is empty string or array, it returns SSO token.
|
|
535
|
+
* If scopes is non-empty, it returns access token for target scope.
|
|
536
|
+
*
|
|
537
|
+
* @beta
|
|
538
|
+
*/
|
|
539
|
+
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
|
|
540
|
+
/**
|
|
541
|
+
* Get basic user info from SSO token.
|
|
542
|
+
*
|
|
543
|
+
* @example
|
|
544
|
+
* ```typescript
|
|
545
|
+
* const currentUser = getUserInfo();
|
|
546
|
+
* ```
|
|
547
|
+
*
|
|
548
|
+
* @throws {@link ErrorCode|InternalError} when SSO token is not valid.
|
|
549
|
+
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
|
550
|
+
*
|
|
551
|
+
* @returns Basic user info with user displayName, objectId and preferredUserName.
|
|
552
|
+
*
|
|
553
|
+
* @beta
|
|
554
|
+
*/
|
|
555
|
+
getUserInfo(): UserInfo;
|
|
556
|
+
private generateAuthServerError;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Configuration for resources.
|
|
561
|
+
* @beta
|
|
562
|
+
*/
|
|
563
|
+
export declare interface ResourceConfiguration {
|
|
564
|
+
/**
|
|
565
|
+
* Resource type.
|
|
566
|
+
*
|
|
567
|
+
* @readonly
|
|
568
|
+
*/
|
|
569
|
+
readonly type: ResourceType;
|
|
570
|
+
/**
|
|
571
|
+
* Resource name.
|
|
572
|
+
*
|
|
573
|
+
* @readonly
|
|
574
|
+
*/
|
|
575
|
+
readonly name: string;
|
|
576
|
+
/**
|
|
577
|
+
* Config for the resource.
|
|
578
|
+
*
|
|
579
|
+
* @readonly
|
|
580
|
+
*/
|
|
581
|
+
readonly properties: {
|
|
582
|
+
[index: string]: any;
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Available resource type.
|
|
588
|
+
* @beta
|
|
589
|
+
*/
|
|
590
|
+
export declare enum ResourceType {
|
|
591
|
+
/**
|
|
592
|
+
* SQL database.
|
|
593
|
+
*
|
|
594
|
+
*/
|
|
595
|
+
SQL = 0,
|
|
596
|
+
/**
|
|
597
|
+
* Rest API.
|
|
598
|
+
*
|
|
599
|
+
*/
|
|
600
|
+
API = 1
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Set custom log function. Use the function if it's set. Priority is lower than setLogger.
|
|
605
|
+
*
|
|
606
|
+
* @param {LogFunction} logFunction - custom log function. If it's undefined, custom log function will be cleared.
|
|
607
|
+
*
|
|
608
|
+
* @example
|
|
609
|
+
* ```typescript
|
|
610
|
+
* setLogFunction((level: LogLevel, message: string) => {
|
|
611
|
+
* if (level === LogLevel.Error) {
|
|
612
|
+
* console.log(message);
|
|
613
|
+
* }
|
|
614
|
+
* });
|
|
615
|
+
* ```
|
|
616
|
+
*
|
|
617
|
+
* @beta
|
|
618
|
+
*/
|
|
619
|
+
export declare function setLogFunction(logFunction?: LogFunction): void;
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Set custom logger. Use the output functions if it's set. Priority is higher than setLogFunction.
|
|
623
|
+
*
|
|
624
|
+
* @param {Logger} logger - custom logger. If it's undefined, custom logger will be cleared.
|
|
625
|
+
*
|
|
626
|
+
* @example
|
|
627
|
+
* ```typescript
|
|
628
|
+
* setLogger({
|
|
629
|
+
* verbose: console.debug,
|
|
630
|
+
* info: console.info,
|
|
631
|
+
* warn: console.warn,
|
|
632
|
+
* error: console.error,
|
|
633
|
+
* });
|
|
634
|
+
* ```
|
|
635
|
+
*
|
|
636
|
+
* @beta
|
|
637
|
+
*/
|
|
638
|
+
export declare function setLogger(logger?: Logger): void;
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Update log level helper.
|
|
642
|
+
*
|
|
643
|
+
* @param { LogLevel } level - log level in configuration
|
|
644
|
+
*
|
|
645
|
+
* @beta
|
|
646
|
+
*/
|
|
647
|
+
export declare function setLogLevel(level: LogLevel): void;
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Creates a new prompt that leverage Teams Single Sign On (SSO) support for bot to automatically sign in user and
|
|
651
|
+
* help receive oauth token, asks the user to consent if needed.
|
|
652
|
+
*
|
|
653
|
+
* @remarks
|
|
654
|
+
* The prompt will attempt to retrieve the users current token of the desired scopes and store it in
|
|
655
|
+
* the token store.
|
|
656
|
+
*
|
|
657
|
+
* User will be automatically signed in leveraging Teams support of Bot Single Sign On(SSO):
|
|
658
|
+
* https://docs.microsoft.com/en-us/microsoftteams/platform/bots/how-to/authentication/auth-aad-sso-bots
|
|
659
|
+
*
|
|
660
|
+
* @example
|
|
661
|
+
* When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named
|
|
662
|
+
* dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either
|
|
663
|
+
* `DialogContext.beginDialog()` or `DialogContext.prompt()`. The user will be prompted to sign in as
|
|
664
|
+
* needed and their access token will be passed as an argument to the callers next waterfall step:
|
|
665
|
+
*
|
|
666
|
+
* ```JavaScript
|
|
667
|
+
* const { ConversationState, MemoryStorage } = require('botbuilder');
|
|
668
|
+
* const { DialogSet, WaterfallDialog } = require('botbuilder-dialogs');
|
|
669
|
+
* const { TeamsBotSsoPrompt } = require('@microsoft/teamsfx');
|
|
670
|
+
*
|
|
671
|
+
* const convoState = new ConversationState(new MemoryStorage());
|
|
672
|
+
* const dialogState = convoState.createProperty('dialogState');
|
|
673
|
+
* const dialogs = new DialogSet(dialogState);
|
|
674
|
+
*
|
|
675
|
+
* loadConfiguration();
|
|
676
|
+
* dialogs.add(new TeamsBotSsoPrompt('TeamsBotSsoPrompt', {
|
|
677
|
+
* scopes: ["User.Read"],
|
|
678
|
+
* }));
|
|
679
|
+
*
|
|
680
|
+
* dialogs.add(new WaterfallDialog('taskNeedingLogin', [
|
|
681
|
+
* async (step) => {
|
|
682
|
+
* return await step.beginDialog('TeamsBotSsoPrompt');
|
|
683
|
+
* },
|
|
684
|
+
* async (step) => {
|
|
685
|
+
* const token = step.result;
|
|
686
|
+
* if (token) {
|
|
687
|
+
*
|
|
688
|
+
* // ... continue with task needing access token ...
|
|
689
|
+
*
|
|
690
|
+
* } else {
|
|
691
|
+
* await step.context.sendActivity(`Sorry... We couldn't log you in. Try again later.`);
|
|
692
|
+
* return await step.endDialog();
|
|
693
|
+
* }
|
|
694
|
+
* }
|
|
695
|
+
* ]));
|
|
696
|
+
* ```
|
|
697
|
+
*
|
|
698
|
+
* @beta
|
|
699
|
+
*/
|
|
700
|
+
export declare class TeamsBotSsoPrompt extends Dialog {
|
|
701
|
+
private settings;
|
|
702
|
+
/**
|
|
703
|
+
* Constructor of TeamsBotSsoPrompt.
|
|
704
|
+
*
|
|
705
|
+
* @param dialogId Unique ID of the dialog within its parent `DialogSet` or `ComponentDialog`.
|
|
706
|
+
* @param settings Settings used to configure the prompt.
|
|
707
|
+
*
|
|
708
|
+
* @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
|
|
709
|
+
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
|
710
|
+
*
|
|
711
|
+
* @beta
|
|
712
|
+
*/
|
|
713
|
+
constructor(dialogId: string, settings: TeamsBotSsoPromptSettings);
|
|
714
|
+
/**
|
|
715
|
+
* Called when a prompt dialog is pushed onto the dialog stack and is being activated.
|
|
716
|
+
* @remarks
|
|
717
|
+
* If the task is successful, the result indicates whether the prompt is still
|
|
718
|
+
* active after the turn has been processed by the prompt.
|
|
719
|
+
*
|
|
720
|
+
* @param dc The DialogContext for the current turn of the conversation.
|
|
721
|
+
*
|
|
722
|
+
* @throws {@link ErrorCode|InvalidParameter} when timeout property in teams bot sso prompt settings is not number or is not positive.
|
|
723
|
+
* @throws {@link ErrorCode|ChannelNotSupported} when bot channel is not MS Teams.
|
|
724
|
+
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
|
725
|
+
*
|
|
726
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
727
|
+
*
|
|
728
|
+
* @beta
|
|
729
|
+
*/
|
|
730
|
+
beginDialog(dc: DialogContext): Promise<DialogTurnResult>;
|
|
731
|
+
/**
|
|
732
|
+
* Called when a prompt dialog is the active dialog and the user replied with a new activity.
|
|
733
|
+
*
|
|
734
|
+
* @remarks
|
|
735
|
+
* If the task is successful, the result indicates whether the dialog is still
|
|
736
|
+
* active after the turn has been processed by the dialog.
|
|
737
|
+
* The prompt generally continues to receive the user's replies until it accepts the
|
|
738
|
+
* user's reply as valid input for the prompt.
|
|
739
|
+
*
|
|
740
|
+
* @param dc The DialogContext for the current turn of the conversation.
|
|
741
|
+
*
|
|
742
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
743
|
+
*
|
|
744
|
+
* @throws {@link ErrorCode|ChannelNotSupported} when bot channel is not MS Teams.
|
|
745
|
+
* @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
|
|
746
|
+
*
|
|
747
|
+
* @beta
|
|
748
|
+
*/
|
|
749
|
+
continueDialog(dc: DialogContext): Promise<DialogTurnResult>;
|
|
750
|
+
/**
|
|
751
|
+
* Ensure bot is running in MS Teams since TeamsBotSsoPrompt is only supported in MS Teams channel.
|
|
752
|
+
* @param dc dialog context
|
|
753
|
+
* @throws {@link ErrorCode|ChannelNotSupported} if bot channel is not MS Teams
|
|
754
|
+
* @internal
|
|
755
|
+
*/
|
|
756
|
+
private ensureMsTeamsChannel;
|
|
757
|
+
/**
|
|
758
|
+
* Send OAuthCard that tells Teams to obtain an authentication token for the bot application.
|
|
759
|
+
* For details see https://docs.microsoft.com/en-us/microsoftteams/platform/bots/how-to/authentication/auth-aad-sso-bots.
|
|
760
|
+
*
|
|
761
|
+
* @internal
|
|
762
|
+
*/
|
|
763
|
+
private sendOAuthCardAsync;
|
|
764
|
+
/**
|
|
765
|
+
* Get sign in resource.
|
|
766
|
+
*
|
|
767
|
+
* @throws {@link ErrorCode|InvalidConfiguration} if client id, tenant id or initiate login endpoint is not found in config.
|
|
768
|
+
*
|
|
769
|
+
* @internal
|
|
770
|
+
*/
|
|
771
|
+
private getSignInResource;
|
|
772
|
+
/**
|
|
773
|
+
* @internal
|
|
774
|
+
*/
|
|
775
|
+
private recognizeToken;
|
|
776
|
+
/**
|
|
777
|
+
* @internal
|
|
778
|
+
*/
|
|
779
|
+
private getTokenExchangeInvokeResponse;
|
|
780
|
+
/**
|
|
781
|
+
* @internal
|
|
782
|
+
*/
|
|
783
|
+
private isTeamsVerificationInvoke;
|
|
784
|
+
/**
|
|
785
|
+
* @internal
|
|
786
|
+
*/
|
|
787
|
+
private isTokenExchangeRequestInvoke;
|
|
788
|
+
/**
|
|
789
|
+
* @internal
|
|
790
|
+
*/
|
|
791
|
+
private isTokenExchangeRequest;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* Settings used to configure an TeamsBotSsoPrompt instance.
|
|
796
|
+
*
|
|
797
|
+
* @beta
|
|
798
|
+
*/
|
|
799
|
+
export declare interface TeamsBotSsoPromptSettings {
|
|
800
|
+
/**
|
|
801
|
+
* The array of strings that declare the desired permissions and the resources requested.
|
|
802
|
+
*/
|
|
803
|
+
scopes: string[];
|
|
804
|
+
/**
|
|
805
|
+
* (Optional) number of milliseconds the prompt will wait for the user to authenticate.
|
|
806
|
+
* Defaults to a value `900,000` (15 minutes.)
|
|
807
|
+
*/
|
|
808
|
+
timeout?: number;
|
|
809
|
+
/**
|
|
810
|
+
* (Optional) value indicating whether the TeamsBotSsoPrompt should end upon receiving an
|
|
811
|
+
* invalid message. Generally the TeamsBotSsoPrompt will end the auth flow when receives user
|
|
812
|
+
* message not related to the auth flow. Setting the flag to false ignores the user's message instead.
|
|
813
|
+
* Defaults to value `true`
|
|
814
|
+
*/
|
|
815
|
+
endOnInvalidMessage?: boolean;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Token response provided by Teams Bot SSO prompt
|
|
820
|
+
*
|
|
821
|
+
* @beta
|
|
822
|
+
*/
|
|
823
|
+
export declare interface TeamsBotSsoPromptTokenResponse extends TokenResponse {
|
|
824
|
+
/**
|
|
825
|
+
* SSO token for user
|
|
826
|
+
*/
|
|
827
|
+
ssoToken: string;
|
|
828
|
+
/**
|
|
829
|
+
* Expire time of SSO token
|
|
830
|
+
*/
|
|
831
|
+
ssoTokenExpiration: string;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* Represent Teams current user's identity, and it is used within Teams client applications.
|
|
836
|
+
*
|
|
837
|
+
* @remarks
|
|
838
|
+
* Can only be used within Teams.
|
|
839
|
+
*
|
|
840
|
+
* @beta
|
|
841
|
+
*/
|
|
842
|
+
export declare class TeamsUserCredential implements TokenCredential {
|
|
843
|
+
/**
|
|
844
|
+
* Constructor of TeamsUserCredential.
|
|
845
|
+
* @remarks
|
|
846
|
+
* Can only be used within Teams.
|
|
847
|
+
* @beta
|
|
848
|
+
*/
|
|
849
|
+
constructor();
|
|
850
|
+
/**
|
|
851
|
+
* Popup login page to get user's access token with specific scopes.
|
|
852
|
+
* @remarks
|
|
853
|
+
* Can only be used within Teams.
|
|
854
|
+
* @beta
|
|
855
|
+
*/
|
|
856
|
+
login(scopes: string | string[]): Promise<void>;
|
|
857
|
+
/**
|
|
858
|
+
* Get access token from credential.
|
|
859
|
+
* @remarks
|
|
860
|
+
* Can only be used within Teams.
|
|
861
|
+
* @beta
|
|
862
|
+
*/
|
|
863
|
+
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
|
|
864
|
+
/**
|
|
865
|
+
* Get basic user info from SSO token
|
|
866
|
+
* @remarks
|
|
867
|
+
* Can only be used within Teams.
|
|
868
|
+
* @beta
|
|
869
|
+
*/
|
|
870
|
+
getUserInfo(): Promise<UserInfo>;
|
|
871
|
+
}
|
|
872
|
+
export { TokenCredential }
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* UserInfo with user displayName, objectId and preferredUserName.
|
|
876
|
+
*
|
|
877
|
+
* @beta
|
|
878
|
+
*/
|
|
879
|
+
export declare interface UserInfo {
|
|
880
|
+
/**
|
|
881
|
+
* User Display Name.
|
|
882
|
+
*
|
|
883
|
+
* @readonly
|
|
884
|
+
*/
|
|
885
|
+
displayName: string;
|
|
886
|
+
/**
|
|
887
|
+
* User unique reference within the Azure Active Directory domain.
|
|
888
|
+
*
|
|
889
|
+
* @readonly
|
|
890
|
+
*/
|
|
891
|
+
objectId: string;
|
|
892
|
+
/**
|
|
893
|
+
* Usually be the email address.
|
|
894
|
+
*
|
|
895
|
+
* @readonly
|
|
896
|
+
*/
|
|
897
|
+
preferredUserName: string;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
export { }
|