@microsoft/teamsfx 3.0.0 → 3.0.1-alpha.068057a13.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.
@@ -1,1779 +1,16 @@
1
- import { jwtDecode } from 'jwt-decode';
2
- import { app, authentication } from '@microsoft/teams-js';
3
- import { PublicClientApplication } from '@azure/msal-browser';
4
- import axios from 'axios';
5
-
6
- // Copyright (c) Microsoft Corporation.
7
- // Licensed under the MIT license.
8
- /**
9
- * Error code to trace the error types.
10
- */
11
- var ErrorCode;
12
- (function (ErrorCode) {
13
- /**
14
- * Invalid parameter error.
15
- */
16
- ErrorCode["InvalidParameter"] = "InvalidParameter";
17
- /**
18
- * Invalid configuration error.
19
- */
20
- ErrorCode["InvalidConfiguration"] = "InvalidConfiguration";
21
- /**
22
- * Invalid certificate error.
23
- */
24
- ErrorCode["InvalidCertificate"] = "InvalidCertificate";
25
- /**
26
- * Internal error.
27
- */
28
- ErrorCode["InternalError"] = "InternalError";
29
- /**
30
- * Channel is not supported error.
31
- */
32
- ErrorCode["ChannelNotSupported"] = "ChannelNotSupported";
33
- /**
34
- * Failed to retrieve sso token
35
- */
36
- ErrorCode["FailedToRetrieveSsoToken"] = "FailedToRetrieveSsoToken";
37
- /**
38
- * Failed to process sso handler
39
- */
40
- ErrorCode["FailedToProcessSsoHandler"] = "FailedToProcessSsoHandler";
41
- /**
42
- * Cannot find command
43
- */
44
- ErrorCode["CannotFindCommand"] = "CannotFindCommand";
45
- /**
46
- * Failed to run sso step
47
- */
48
- ErrorCode["FailedToRunSsoStep"] = "FailedToRunSsoStep";
49
- /**
50
- * Failed to run dedup step
51
- */
52
- ErrorCode["FailedToRunDedupStep"] = "FailedToRunDedupStep";
53
- /**
54
- * Sso activity handler is undefined
55
- */
56
- ErrorCode["SsoActivityHandlerIsUndefined"] = "SsoActivityHandlerIsUndefined";
57
- /**
58
- * Runtime is not supported error.
59
- */
60
- ErrorCode["RuntimeNotSupported"] = "RuntimeNotSupported";
61
- /**
62
- * User failed to finish the AAD consent flow failed.
63
- */
64
- ErrorCode["ConsentFailed"] = "ConsentFailed";
65
- /**
66
- * The user or administrator has not consented to use the application error.
67
- */
68
- ErrorCode["UiRequiredError"] = "UiRequiredError";
69
- /**
70
- * Token is not within its valid time range error.
71
- */
72
- ErrorCode["TokenExpiredError"] = "TokenExpiredError";
73
- /**
74
- * Call service (AAD or simple authentication server) failed.
75
- */
76
- ErrorCode["ServiceError"] = "ServiceError";
77
- /**
78
- * Operation failed.
79
- */
80
- ErrorCode["FailedOperation"] = "FailedOperation";
81
- /**
82
- * Invalid response error.
83
- */
84
- ErrorCode["InvalidResponse"] = "InvalidResponse";
85
- /**
86
- * Authentication info already exists error.
87
- */
88
- ErrorCode["AuthorizationInfoAlreadyExists"] = "AuthorizationInfoAlreadyExists";
89
- })(ErrorCode || (ErrorCode = {}));
90
- /**
91
- * @internal
92
- */
93
- class ErrorMessage {
94
- }
95
- // InvalidConfiguration Error
96
- ErrorMessage.InvalidConfiguration = "{0} in configuration is invalid: {1}.";
97
- ErrorMessage.ConfigurationNotExists = "Configuration does not exist. {0}";
98
- ErrorMessage.ResourceConfigurationNotExists = "{0} resource configuration does not exist.";
99
- ErrorMessage.MissingResourceConfiguration = "Missing resource configuration with type: {0}, name: {1}.";
100
- ErrorMessage.AuthenticationConfigurationNotExists = "Authentication configuration does not exist.";
101
- // RuntimeNotSupported Error
102
- ErrorMessage.BrowserRuntimeNotSupported = "{0} is not supported in browser.";
103
- ErrorMessage.NodejsRuntimeNotSupported = "{0} is not supported in Node.";
104
- // Internal Error
105
- ErrorMessage.FailToAcquireTokenOnBehalfOfUser = "Failed to acquire access token on behalf of user: {0}";
106
- // ChannelNotSupported Error
107
- ErrorMessage.OnlyMSTeamsChannelSupported = "{0} is only supported in MS Teams Channel";
108
- ErrorMessage.FailedToProcessSsoHandler = "Failed to process sso handler: {0}";
109
- // FailedToRetrieveSsoToken Error
110
- ErrorMessage.FailedToRetrieveSsoToken = "Failed to retrieve sso token, user failed to finish the AAD consent flow.";
111
- // CannotFindCommand Error
112
- ErrorMessage.CannotFindCommand = "Cannot find command: {0}";
113
- ErrorMessage.FailedToRunSsoStep = "Failed to run dialog to retrieve sso token: {0}";
114
- ErrorMessage.FailedToRunDedupStep = "Failed to run dialog to remove duplicated messages: {0}";
115
- // SsoActivityHandlerIsUndefined Error
116
- ErrorMessage.SsoActivityHandlerIsNull = "Sso command can only be used or added when sso activity handler is not undefined";
117
- // AuthorizationInfoError
118
- ErrorMessage.AuthorizationHeaderAlreadyExists = "Authorization header already exists!";
119
- ErrorMessage.BasicCredentialAlreadyExists = "Basic credential already exists!";
120
- // InvalidParameter Error
121
- ErrorMessage.EmptyParameter = "Parameter {0} is empty";
122
- ErrorMessage.DuplicateHttpsOptionProperty = "Axios HTTPS agent already defined value for property {0}";
123
- ErrorMessage.DuplicateApiKeyInHeader = "The request already defined api key in request header with name {0}.";
124
- ErrorMessage.DuplicateApiKeyInQueryParam = "The request already defined api key in query parameter with name {0}.";
125
- ErrorMessage.OnlySupportInQueryActivity = "The handleMessageExtensionQueryWithToken only support in handleTeamsMessagingExtensionQuery with composeExtension/query type.";
126
- ErrorMessage.OnlySupportInLinkQueryActivity = "The handleMessageExtensionLinkQueryWithSSO only support in handleTeamsAppBasedLinkQuery with composeExtension/queryLink type.";
127
- /**
128
- * Error class with code and message thrown by the SDK.
129
- */
130
- class ErrorWithCode extends Error {
131
- /**
132
- * Constructor of ErrorWithCode.
133
- *
134
- * @param {string} message - error message.
135
- * @param {ErrorCode} code - error code.
136
- */
137
- constructor(message, code) {
138
- if (!code) {
139
- super(message);
140
- return this;
141
- }
142
- super(message);
143
- Object.setPrototypeOf(this, ErrorWithCode.prototype);
144
- this.name = `${new.target.name}.${code}`;
145
- this.code = code;
146
- }
147
- }
148
-
149
- // Copyright (c) Microsoft Corporation.
150
- // Licensed under the MIT license.
151
- /**
152
- * Log level.
153
- */
154
- var LogLevel;
155
- (function (LogLevel) {
156
- /**
157
- * Show verbose, information, warning and error message.
158
- */
159
- LogLevel[LogLevel["Verbose"] = 0] = "Verbose";
160
- /**
161
- * Show information, warning and error message.
162
- */
163
- LogLevel[LogLevel["Info"] = 1] = "Info";
164
- /**
165
- * Show warning and error message.
166
- */
167
- LogLevel[LogLevel["Warn"] = 2] = "Warn";
168
- /**
169
- * Show error message.
170
- */
171
- LogLevel[LogLevel["Error"] = 3] = "Error";
172
- })(LogLevel || (LogLevel = {}));
173
- /**
174
- * Update log level helper.
175
- *
176
- * @param { LogLevel } level - log level in configuration
177
- */
178
- function setLogLevel(level) {
179
- internalLogger.level = level;
180
- }
181
- /**
182
- * Get log level.
183
- *
184
- * @returns Log level
185
- */
186
- function getLogLevel() {
187
- return internalLogger.level;
188
- }
189
- class InternalLogger {
190
- constructor(name, logLevel) {
191
- this.level = undefined;
192
- this.defaultLogger = {
193
- verbose: console.debug,
194
- info: console.info,
195
- warn: console.warn,
196
- error: console.error,
197
- };
198
- this.name = name;
199
- this.level = logLevel;
200
- }
201
- error(message) {
202
- this.log(LogLevel.Error, (x) => x.error, message);
203
- }
204
- warn(message) {
205
- this.log(LogLevel.Warn, (x) => x.warn, message);
206
- }
207
- info(message) {
208
- this.log(LogLevel.Info, (x) => x.info, message);
209
- }
210
- verbose(message) {
211
- this.log(LogLevel.Verbose, (x) => x.verbose, message);
212
- }
213
- log(logLevel, logFunction, message) {
214
- if (message.trim() === "") {
215
- return;
216
- }
217
- const timestamp = new Date().toUTCString();
218
- let logHeader;
219
- if (this.name) {
220
- logHeader = `[${timestamp}] : @microsoft/teamsfx - ${this.name} : ${LogLevel[logLevel]} - `;
221
- }
222
- else {
223
- logHeader = `[${timestamp}] : @microsoft/teamsfx : ${LogLevel[logLevel]} - `;
224
- }
225
- const logMessage = `${logHeader}${message}`;
226
- if (this.level !== undefined && this.level <= logLevel) {
227
- if (this.customLogger) {
228
- logFunction(this.customLogger)(logMessage);
229
- }
230
- else if (this.customLogFunction) {
231
- this.customLogFunction(logLevel, logMessage);
232
- }
233
- else {
234
- logFunction(this.defaultLogger)(logMessage);
235
- }
236
- }
237
- }
238
- }
239
- /**
240
- * Logger instance used internally
241
- *
242
- * @internal
243
- */
244
- const internalLogger = new InternalLogger();
245
- /**
246
- * Set custom logger. Use the output functions if it's set. Priority is higher than setLogFunction.
247
- *
248
- * @param {Logger} logger - custom logger. If it's undefined, custom logger will be cleared.
249
- *
250
- * @example
251
- * ```typescript
252
- * setLogger({
253
- * verbose: console.debug,
254
- * info: console.info,
255
- * warn: console.warn,
256
- * error: console.error,
257
- * });
258
- * ```
259
- */
260
- function setLogger(logger) {
261
- internalLogger.customLogger = logger;
262
- }
263
- /**
264
- * Set custom log function. Use the function if it's set. Priority is lower than setLogger.
265
- *
266
- * @param {LogFunction} logFunction - custom log function. If it's undefined, custom log function will be cleared.
267
- *
268
- * @example
269
- * ```typescript
270
- * setLogFunction((level: LogLevel, message: string) => {
271
- * if (level === LogLevel.Error) {
272
- * console.log(message);
273
- * }
274
- * });
275
- * ```
276
- */
277
- function setLogFunction(logFunction) {
278
- internalLogger.customLogFunction = logFunction;
279
- }
280
-
281
- // Copyright (c) Microsoft Corporation.
282
- /**
283
- * Parse jwt token payload
284
- *
285
- * @param token
286
- *
287
- * @returns Payload object
288
- *
289
- * @internal
290
- */
291
- function parseJwt(token) {
292
- try {
293
- const tokenObj = jwtDecode(token);
294
- if (!tokenObj || !tokenObj.exp) {
295
- throw new ErrorWithCode("Decoded token is null or exp claim does not exists.", ErrorCode.InternalError);
296
- }
297
- return tokenObj;
298
- }
299
- catch (err) {
300
- const errorMsg = "Parse jwt token failed in node env with error: " + err.message;
301
- internalLogger.error(errorMsg);
302
- throw new ErrorWithCode(errorMsg, ErrorCode.InternalError);
303
- }
304
- }
305
- /**
306
- * @internal
307
- */
308
- function getUserInfoFromSsoToken(ssoToken) {
309
- if (!ssoToken) {
310
- const errorMsg = "SSO token is undefined.";
311
- internalLogger.error(errorMsg);
312
- throw new ErrorWithCode(errorMsg, ErrorCode.InvalidParameter);
313
- }
314
- const tokenObject = parseJwt(ssoToken);
315
- const userInfo = {
316
- displayName: tokenObject.name,
317
- objectId: tokenObject.oid,
318
- tenantId: tokenObject.tid,
319
- preferredUserName: "",
320
- };
321
- if (tokenObject.ver === "2.0") {
322
- userInfo.preferredUserName = tokenObject.preferred_username;
323
- }
324
- else if (tokenObject.ver === "1.0") {
325
- userInfo.preferredUserName = tokenObject.upn;
326
- }
327
- return userInfo;
328
- }
329
- /**
330
- * @internal
331
- */
332
- function getTenantIdAndLoginHintFromSsoToken(ssoToken) {
333
- if (!ssoToken) {
334
- const errorMsg = "SSO token is undefined.";
335
- internalLogger.error(errorMsg);
336
- throw new ErrorWithCode(errorMsg, ErrorCode.InvalidParameter);
337
- }
338
- const tokenObject = parseJwt(ssoToken);
339
- const userInfo = {
340
- tid: tokenObject.tid,
341
- loginHint: tokenObject.ver === "2.0"
342
- ? tokenObject.preferred_username
343
- : tokenObject.upn,
344
- };
345
- return userInfo;
346
- }
347
- /**
348
- * @internal
349
- */
350
- function parseAccessTokenFromAuthCodeTokenResponse(tokenResponse) {
351
- try {
352
- const tokenResponseObject = typeof tokenResponse == "string"
353
- ? JSON.parse(tokenResponse)
354
- : tokenResponse;
355
- if (!tokenResponseObject || !tokenResponseObject.accessToken) {
356
- const errorMsg = "Get empty access token from Auth Code token response.";
357
- internalLogger.error(errorMsg);
358
- throw new Error(errorMsg);
359
- }
360
- const token = tokenResponseObject.accessToken;
361
- const tokenObject = parseJwt(token);
362
- if (tokenObject.ver !== "1.0" && tokenObject.ver !== "2.0") {
363
- const errorMsg = "SSO token is not valid with an unknown version: " + tokenObject.ver;
364
- internalLogger.error(errorMsg);
365
- throw new Error(errorMsg);
366
- }
367
- const accessToken = {
368
- token: token,
369
- expiresOnTimestamp: tokenObject.exp * 1000,
370
- };
371
- return accessToken;
372
- }
373
- catch (error) {
374
- const errorMsg = "Parse access token failed from Auth Code token response in node env with error: " +
375
- error.message;
376
- internalLogger.error(errorMsg);
377
- throw new ErrorWithCode(errorMsg, ErrorCode.InternalError);
378
- }
379
- }
380
- /**
381
- * Format string template with replacements
382
- *
383
- * ```typescript
384
- * const template = "{0} and {1} are fruit. {0} is my favorite one."
385
- * const formattedStr = formatString(template, "apple", "pear"); // formattedStr: "apple and pear are fruit. apple is my favorite one."
386
- * ```
387
- *
388
- * @param str string template
389
- * @param replacements replacement string array
390
- * @returns Formatted string
391
- *
392
- * @internal
393
- */
394
- function formatString(str, ...replacements) {
395
- const args = replacements;
396
- return str.replace(/{(\d+)}/g, function (match, number) {
397
- return typeof args[number] != "undefined" ? args[number] : match;
398
- });
399
- }
400
- /**
401
- * @internal
402
- */
403
- function validateScopesType(value) {
404
- // string
405
- if (typeof value === "string" || value instanceof String) {
406
- return;
407
- }
408
- // empty array
409
- if (Array.isArray(value) && value.length === 0) {
410
- return;
411
- }
412
- // string array
413
- if (Array.isArray(value) && value.length > 0 && value.every((item) => typeof item === "string")) {
414
- return;
415
- }
416
- const errorMsg = "The type of scopes is not valid, it must be string or string array";
417
- internalLogger.error(errorMsg);
418
- throw new ErrorWithCode(errorMsg, ErrorCode.InvalidParameter);
419
- }
420
-
421
- // Copyright (c) Microsoft Corporation.
422
- /**
423
- * Represent Microsoft 365 tenant identity, and it is usually used when user is not involved.
424
- *
425
- * @remarks
426
- * Only works in in server side.
427
- */
428
- class AppCredential {
429
- /**
430
- * Constructor of AppCredential.
431
- *
432
- * @remarks
433
- * Only works in in server side.
434
- */
435
- constructor(authConfig) {
436
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "AppCredential"), ErrorCode.RuntimeNotSupported);
437
- }
438
- /**
439
- * Get access token for credential.
440
- *
441
- * @remarks
442
- * Only works in in server side.
443
- */
444
- getToken(scopes, options) {
445
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "AppCredential"), ErrorCode.RuntimeNotSupported));
446
- }
447
- }
448
-
449
- // Copyright (c) Microsoft Corporation.
450
- /**
451
- * Represent on-behalf-of flow to get user identity, and it is designed to be used in Azure Function or Bot scenarios.
452
- *
453
- * @remarks
454
- * Can only be used in server side.
455
- */
456
- class OnBehalfOfUserCredential {
457
- /**
458
- * Constructor of OnBehalfOfUserCredential
459
- *
460
- * @remarks
461
- * Can Only works in in server side.
462
- */
463
- constructor(ssoToken, config) {
464
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "OnBehalfOfUserCredential"), ErrorCode.RuntimeNotSupported);
465
- }
466
- /**
467
- * Get access token from credential.
468
- * @remarks
469
- * Can only be used in server side.
470
- */
471
- getToken(scopes, options) {
472
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "OnBehalfOfUserCredential"), ErrorCode.RuntimeNotSupported));
473
- }
474
- /**
475
- * Get basic user info from SSO token.
476
- * @remarks
477
- * Can only be used in server side.
478
- */
479
- getUserInfo() {
480
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "OnBehalfOfUserCredential"), ErrorCode.RuntimeNotSupported));
481
- }
482
- }
483
-
484
- /******************************************************************************
485
- Copyright (c) Microsoft Corporation.
486
-
487
- Permission to use, copy, modify, and/or distribute this software for any
488
- purpose with or without fee is hereby granted.
489
-
490
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
491
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
492
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
493
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
494
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
495
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
496
- PERFORMANCE OF THIS SOFTWARE.
497
- ***************************************************************************** */
498
-
499
- function __awaiter(thisArg, _arguments, P, generator) {
500
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
501
- return new (P || (P = Promise))(function (resolve, reject) {
502
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
503
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
504
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
505
- step((generator = generator.apply(thisArg, _arguments || [])).next());
506
- });
507
- }
508
-
509
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
510
- var e = new Error(message);
511
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
512
- };
513
-
514
- // Copyright (c) Microsoft Corporation.
515
- const tokenRefreshTimeSpanInMillisecond = 5 * 60 * 1000;
516
- const loginPageWidth = 600;
517
- const loginPageHeight = 535;
518
- /**
519
- * Represent Teams current user's identity, and it is used within Teams tab application.
520
- *
521
- * @remarks
522
- * Can only be used within Teams.
523
- */
524
- class TeamsUserCredential {
525
- // eslint-disable-next-line no-secrets/no-secrets
526
- /**
527
- * Constructor of TeamsUserCredential.
528
- *
529
- * @example
530
- * ```typescript
531
- * const config: TeamsUserCredentialAuthConfig = {
532
- * initiateLoginEndpoint: "https://localhost:3000/auth-start.html",
533
- * clientId: "xxx"
534
- * }
535
- * const credential = new TeamsUserCredential(config);
536
- * ```
537
- *
538
- * @param {TeamsUserCredentialAuthConfig} authConfig - The authentication configuration.
539
- *
540
- * @throws {@link ErrorCode|InvalidConfiguration} when client id, initiate login endpoint or simple auth endpoint is not found in config.
541
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
542
- */
543
- constructor(authConfig) {
544
- internalLogger.info("Create teams user credential");
545
- this.config = this.loadAndValidateConfig(authConfig);
546
- this.ssoToken = null;
547
- this.initialized = false;
548
- }
549
- /**
550
- * Popup login page to get user's access token with specific scopes.
551
- *
552
- * @remarks
553
- * Only works in Teams client APP. User will be redirected to the authorization page to login and consent.
554
- *
555
- * @example
556
- * ```typescript
557
- * await credential.login(["https://graph.microsoft.com/User.Read"]); // single scope using string array
558
- * await credential.login("https://graph.microsoft.com/User.Read"); // single scopes using string
559
- * await credential.login(["https://graph.microsoft.com/User.Read", "Calendars.Read"]); // multiple scopes using string array
560
- * await credential.login("https://graph.microsoft.com/User.Read Calendars.Read"); // multiple scopes using string
561
- * ```
562
- * @param scopes - The list of scopes for which the token will have access, before that, we will request user to consent.
563
- * @param { string[] } resources - The optional list of resources for full trust Teams apps.
564
- *
565
- * @throws {@link ErrorCode|InternalError} when failed to login with unknown error.
566
- * @throws {@link ErrorCode|ConsentFailed} when user canceled or failed to consent.
567
- * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
568
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
569
- */
570
- login(scopes, resources) {
571
- return __awaiter(this, void 0, void 0, function* () {
572
- validateScopesType(scopes);
573
- const scopesStr = typeof scopes === "string" ? scopes : scopes.join(" ");
574
- internalLogger.info(`Popup login page to get user's access token with scopes: ${scopesStr}`);
575
- if (!this.initialized) {
576
- yield this.init(resources);
577
- }
578
- yield app.initialize();
579
- let result;
580
- try {
581
- const params = {
582
- url: `${this.config.initiateLoginEndpoint ? this.config.initiateLoginEndpoint : ""}?clientId=${this.config.clientId ? this.config.clientId : ""}&scope=${encodeURI(scopesStr)}&loginHint=${this.loginHint ? this.loginHint : ""}`,
583
- width: loginPageWidth,
584
- height: loginPageHeight,
585
- };
586
- result = yield authentication.authenticate(params);
587
- if (!result) {
588
- const errorMsg = "Get empty authentication result from MSAL";
589
- internalLogger.error(errorMsg);
590
- throw new ErrorWithCode(errorMsg, ErrorCode.InternalError);
591
- }
592
- }
593
- catch (err) {
594
- const errorMsg = `Consent failed for the scope ${scopesStr} with error: ${err.message}`;
595
- internalLogger.error(errorMsg);
596
- throw new ErrorWithCode(errorMsg, ErrorCode.ConsentFailed);
597
- }
598
- let resultJson = {};
599
- try {
600
- resultJson = typeof result == "string" ? JSON.parse(result) : result;
601
- }
602
- catch (error) {
603
- // If can not parse result as Json, will throw error.
604
- const failedToParseResult = "Failed to parse response to Json.";
605
- internalLogger.error(failedToParseResult);
606
- throw new ErrorWithCode(failedToParseResult, ErrorCode.InvalidResponse);
607
- }
608
- // If code exists in result, user may using previous auth-start and auth-end page.
609
- if (resultJson.code) {
610
- const helpLink = "https://aka.ms/teamsfx-auth-code-flow";
611
- const usingPreviousAuthPage = "Found auth code in response. Auth code is not support for current version of SDK. " +
612
- `Please refer to the help link for how to fix the issue: ${helpLink}.`;
613
- internalLogger.error(usingPreviousAuthPage);
614
- throw new ErrorWithCode(usingPreviousAuthPage, ErrorCode.InvalidResponse);
615
- }
616
- // If sessionStorage exists in result, set the values in current session storage.
617
- if (resultJson.sessionStorage) {
618
- this.setSessionStorage(resultJson.sessionStorage);
619
- }
620
- });
621
- }
622
- /**
623
- * Get access token from credential.
624
- *
625
- * Important: Access tokens are stored in sessionStorage, read more here: https://aka.ms/teamsfx-session-storage-notice
626
- * Important: Full trust applications do not read the resource information from the webApplicationInfo section of the app
627
- * manifest. Instead, this resource (along with any additional resources from which to request tokens) must be provided
628
- * as a list of resources to the getToken() method through a GetTeamsUserTokenOptions object.
629
- *
630
- * @example
631
- * ```typescript
632
- * await credential.getToken([]) // Get SSO token using empty string array
633
- * await credential.getToken("") // Get SSO token using empty string
634
- * await credential.getToken([".default"]) // Get Graph access token with default scope using string array
635
- * await credential.getToken(".default") // Get Graph access token with default scope using string
636
- * await credential.getToken(["User.Read"]) // Get Graph access token for single scope using string array
637
- * await credential.getToken("User.Read") // Get Graph access token for single scope using string
638
- * await credential.getToken(["User.Read", "Application.Read.All"]) // Get Graph access token for multiple scopes using string array
639
- * await credential.getToken("User.Read Application.Read.All") // Get Graph access token for multiple scopes using space-separated string
640
- * await credential.getToken("https://graph.microsoft.com/User.Read") // Get Graph access token with full resource URI
641
- * await credential.getToken(["https://outlook.office.com/Mail.Read"]) // Get Outlook access token
642
- *
643
- * const options: GetTeamsUserTokenOptions = { resources: ["https://domain.example.com"] }; // set up resources for full trust apps.
644
- * await credential.getToken([], options) // Get sso token from teams client - only use this approach for full trust apps.
645
- * ```
646
- *
647
- * @param {string | string[]} scopes - The list of scopes for which the token will have access.
648
- * @param {GetTokenOptions} options - The options used to configure any requests this TokenCredential implementation might make.
649
- *
650
- * @throws {@link ErrorCode|InternalError} when failed to get access token with unknown error.
651
- * @throws {@link ErrorCode|UiRequiredError} when need user consent to get access token.
652
- * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
653
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
654
- *
655
- * @returns User access token of defined scopes.
656
- * If scopes is empty string or array, it returns SSO token.
657
- * If scopes is non-empty, it returns access token for target scope.
658
- * Throw error if get access token failed.
659
- */
660
- getToken(scopes, options) {
661
- return __awaiter(this, void 0, void 0, function* () {
662
- validateScopesType(scopes);
663
- const resources = options === null || options === void 0 ? void 0 : options.resources;
664
- const ssoToken = yield this.getSSOToken(resources);
665
- const scopeStr = typeof scopes === "string" ? scopes : scopes.join(" ");
666
- if (scopeStr === "") {
667
- internalLogger.info("Get SSO token");
668
- return ssoToken;
669
- }
670
- else {
671
- internalLogger.info("Get access token with scopes: " + scopeStr);
672
- if (!this.initialized) {
673
- yield this.init(resources);
674
- }
675
- let tokenResponse;
676
- const scopesArray = typeof scopes === "string" ? scopes.split(" ") : scopes;
677
- const domain = window.location.origin;
678
- // First try to get Access Token from cache.
679
- try {
680
- const account = this.msalInstance.getAccountByUsername(this.loginHint);
681
- const scopesRequestForAcquireTokenSilent = {
682
- scopes: scopesArray,
683
- account: account !== null && account !== void 0 ? account : undefined,
684
- redirectUri: `${domain}/blank-auth-end.html`,
685
- };
686
- tokenResponse = yield this.msalInstance.acquireTokenSilent(scopesRequestForAcquireTokenSilent);
687
- }
688
- catch (error) {
689
- const acquireTokenSilentFailedMessage = `Failed to call acquireTokenSilent. Reason: ${error === null || error === void 0 ? void 0 : error.message}. `;
690
- internalLogger.verbose(acquireTokenSilentFailedMessage);
691
- }
692
- if (!tokenResponse) {
693
- // If fail to get Access Token from cache, try to get Access token by silent login.
694
- try {
695
- const scopesRequestForSsoSilent = {
696
- scopes: scopesArray,
697
- loginHint: this.loginHint,
698
- redirectUri: `${domain}/blank-auth-end.html`,
699
- };
700
- tokenResponse = yield this.msalInstance.ssoSilent(scopesRequestForSsoSilent);
701
- }
702
- catch (error) {
703
- const ssoSilentFailedMessage = `Failed to call ssoSilent. Reason: ${error === null || error === void 0 ? void 0 : error.message}. `;
704
- internalLogger.verbose(ssoSilentFailedMessage);
705
- }
706
- }
707
- if (!tokenResponse) {
708
- const errorMsg = `Failed to get access token cache silently, please login first: you need login first before get access token.`;
709
- internalLogger.error(errorMsg);
710
- throw new ErrorWithCode(errorMsg, ErrorCode.UiRequiredError);
711
- }
712
- const accessToken = parseAccessTokenFromAuthCodeTokenResponse(tokenResponse);
713
- return accessToken;
714
- }
715
- });
716
- }
717
- /**
718
- * Get basic user info from SSO token
719
- *
720
- * @param {string[]} resources - The optional list of resources for full trust Teams apps.
721
- *
722
- * @example
723
- * ```typescript
724
- * const currentUser = await credential.getUserInfo();
725
- * ```
726
- *
727
- * @throws {@link ErrorCode|InternalError} when SSO token from Teams client is not valid.
728
- * @throws {@link ErrorCode|InvalidParameter} when SSO token from Teams client is empty.
729
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is nodeJS.
730
- *
731
- * @returns Basic user info with user displayName, objectId and preferredUserName.
732
- */
733
- getUserInfo(resources) {
734
- return __awaiter(this, void 0, void 0, function* () {
735
- internalLogger.info("Get basic user info from SSO token");
736
- const ssoToken = yield this.getSSOToken(resources);
737
- return getUserInfoFromSsoToken(ssoToken.token);
738
- });
739
- }
740
- init(resources) {
741
- return __awaiter(this, void 0, void 0, function* () {
742
- const ssoToken = yield this.getSSOToken(resources);
743
- const info = getTenantIdAndLoginHintFromSsoToken(ssoToken.token);
744
- this.loginHint = info.loginHint;
745
- this.tid = info.tid;
746
- const msalConfig = {
747
- auth: {
748
- clientId: this.config.clientId,
749
- authority: `https://login.microsoftonline.com/${this.tid}`,
750
- },
751
- cache: {
752
- cacheLocation: "sessionStorage",
753
- },
754
- };
755
- this.msalInstance = new PublicClientApplication(msalConfig);
756
- yield this.msalInstance.initialize();
757
- this.initialized = true;
758
- });
759
- }
760
- /**
761
- * Get SSO token using teams SDK
762
- * It will try to get SSO token from memory first, if SSO token doesn't exist or about to expired, then it will using teams SDK to get SSO token
763
- *
764
- * @param {string[]} resources - The optional list of resources for full trust Teams apps.
765
- *
766
- * @returns SSO token
767
- */
768
- getSSOToken(resources) {
769
- return __awaiter(this, void 0, void 0, function* () {
770
- if (this.ssoToken) {
771
- if (this.ssoToken.expiresOnTimestamp - Date.now() > tokenRefreshTimeSpanInMillisecond) {
772
- internalLogger.verbose("Get SSO token from memory cache");
773
- return this.ssoToken;
774
- }
775
- }
776
- const params = { resources: resources !== null && resources !== void 0 ? resources : [] };
777
- let token;
778
- try {
779
- yield app.initialize();
780
- }
781
- catch (err) {
782
- const errorMsg = "Initialize teams sdk failed due to not running inside Teams environment";
783
- internalLogger.error(errorMsg);
784
- throw new ErrorWithCode(errorMsg, ErrorCode.InternalError);
785
- }
786
- try {
787
- token = yield authentication.getAuthToken(params);
788
- }
789
- catch (err) {
790
- const errorMsg = "Get SSO token failed with error: " + err.message;
791
- internalLogger.error(errorMsg);
792
- throw new ErrorWithCode(errorMsg, ErrorCode.InternalError);
793
- }
794
- if (!token) {
795
- const errorMsg = "Get empty SSO token from Teams";
796
- internalLogger.error(errorMsg);
797
- throw new ErrorWithCode(errorMsg, ErrorCode.InternalError);
798
- }
799
- const tokenObject = parseJwt(token);
800
- if (tokenObject.ver !== "1.0" && tokenObject.ver !== "2.0") {
801
- const errorMsg = "SSO token is not valid with an unknown version: " + tokenObject.ver;
802
- internalLogger.error(errorMsg);
803
- throw new ErrorWithCode(errorMsg, ErrorCode.InternalError);
804
- }
805
- const ssoToken = {
806
- token,
807
- expiresOnTimestamp: tokenObject.exp * 1000,
808
- };
809
- this.ssoToken = ssoToken;
810
- return ssoToken;
811
- });
812
- }
813
- /**
814
- * Load and validate authentication configuration
815
- *
816
- * @param {AuthenticationConfiguration?} config - The authentication configuration. Use environment variables if not provided.
817
- *
818
- * @returns Authentication configuration
819
- */
820
- loadAndValidateConfig(config) {
821
- internalLogger.verbose("Validate authentication configuration");
822
- if (config.initiateLoginEndpoint && config.clientId) {
823
- return config;
824
- }
825
- const missingValues = [];
826
- if (!config.initiateLoginEndpoint) {
827
- missingValues.push("initiateLoginEndpoint");
828
- }
829
- if (!config.clientId) {
830
- missingValues.push("clientId");
831
- }
832
- const errorMsg = formatString(ErrorMessage.InvalidConfiguration, missingValues.join(", "), "undefined");
833
- internalLogger.error(errorMsg);
834
- throw new ErrorWithCode(errorMsg, ErrorCode.InvalidConfiguration);
835
- }
836
- setSessionStorage(sessionStorageValues) {
837
- try {
838
- const sessionStorageKeys = Object.keys(sessionStorageValues);
839
- sessionStorageKeys.forEach((key) => {
840
- sessionStorage.setItem(key, sessionStorageValues[key]);
841
- });
842
- }
843
- catch (error) {
844
- // Values in result.sessionStorage can not be set into session storage.
845
- // Throw error since this may block user.
846
- const errorMessage = `Failed to set values in session storage. Error: ${error.message}`;
847
- internalLogger.error(errorMessage);
848
- throw new ErrorWithCode(errorMessage, ErrorCode.InternalError);
849
- }
850
- }
851
- }
852
-
853
- // Copyright (c) Microsoft Corporation.
854
- /**
855
- * Creates a new prompt that leverage Teams Single Sign On (SSO) support for bot to automatically sign in user and
856
- * help receive oauth token, asks the user to consent if needed.
857
- *
858
- * @remarks
859
- * The prompt will attempt to retrieve the users current token of the desired scopes and store it in
860
- * the token store.
861
- *
862
- * User will be automatically signed in leveraging Teams support of Bot Single Sign On(SSO):
863
- * https://docs.microsoft.com/en-us/microsoftteams/platform/bots/how-to/authentication/auth-aad-sso-bots
864
- *
865
- * @example
866
- * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named
867
- * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either
868
- * `DialogContext.beginDialog()` or `DialogContext.prompt()`. The user will be prompted to sign in as
869
- * needed and their access token will be passed as an argument to the callers next waterfall step:
870
- *
871
- * ```JavaScript
872
- * const { ConversationState, MemoryStorage } = require('botbuilder');
873
- * const { DialogSet, WaterfallDialog } = require('botbuilder-dialogs');
874
- * const { TeamsBotSsoPrompt } = require('@microsoft/teamsfx');
875
- *
876
- * const convoState = new ConversationState(new MemoryStorage());
877
- * const dialogState = convoState.createProperty('dialogState');
878
- * const dialogs = new DialogSet(dialogState);
879
- *
880
- * dialogs.add(new TeamsBotSsoPrompt('TeamsBotSsoPrompt', {
881
- * scopes: ["User.Read"],
882
- * }));
883
- *
884
- * dialogs.add(new WaterfallDialog('taskNeedingLogin', [
885
- * async (step) => {
886
- * return await step.beginDialog('TeamsBotSsoPrompt');
887
- * },
888
- * async (step) => {
889
- * const token = step.result;
890
- * if (token) {
891
- *
892
- * // ... continue with task needing access token ...
893
- *
894
- * } else {
895
- * await step.context.sendActivity(`Sorry... We couldn't log you in. Try again later.`);
896
- * return await step.endDialog();
897
- * }
898
- * }
899
- * ]));
900
- * ```
901
- */
902
- class TeamsBotSsoPrompt {
903
- /**
904
- * Constructor of TeamsBotSsoPrompt.
905
- *
906
- * @param dialogId Unique ID of the dialog within its parent `DialogSet` or `ComponentDialog`.
907
- * @param settings Settings used to configure the prompt.
908
- *
909
- * @throws {@link ErrorCode|InvalidParameter} when scopes is not a valid string or string array.
910
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
911
- */
912
- constructor(authConfig, initiateLoginEndpoint, dialogId, settings) {
913
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotSsoPrompt"), ErrorCode.RuntimeNotSupported);
914
- }
915
- /**
916
- * Called when a prompt dialog is pushed onto the dialog stack and is being activated.
917
- * @remarks
918
- * If the task is successful, the result indicates whether the prompt is still
919
- * active after the turn has been processed by the prompt.
920
- *
921
- * @param dc The DialogContext for the current turn of the conversation.
922
- *
923
- * @throws {@link ErrorCode|InvalidParameter} when timeout property in teams bot sso prompt settings is not number or is not positive.
924
- * @throws {@link ErrorCode|ChannelNotSupported} when bot channel is not MS Teams.
925
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
926
- *
927
- * @returns A `Promise` representing the asynchronous operation.
928
- */
929
- beginDialog(dc) {
930
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotSsoPrompt"), ErrorCode.RuntimeNotSupported));
931
- }
932
- /**
933
- * Called when a prompt dialog is the active dialog and the user replied with a new activity.
934
- *
935
- * @remarks
936
- * If the task is successful, the result indicates whether the dialog is still
937
- * active after the turn has been processed by the dialog.
938
- * The prompt generally continues to receive the user's replies until it accepts the
939
- * user's reply as valid input for the prompt.
940
- *
941
- * @param dc The DialogContext for the current turn of the conversation.
942
- *
943
- * @returns A `Promise` representing the asynchronous operation.
944
- *
945
- * @throws {@link ErrorCode|ChannelNotSupported} when bot channel is not MS Teams.
946
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
947
- */
948
- continueDialog(dc) {
949
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotSsoPrompt"), ErrorCode.RuntimeNotSupported));
950
- }
951
- }
952
-
953
- // Copyright (c) Microsoft Corporation.
954
- /**
955
- * Initializes new Axios instance with specific auth provider
956
- *
957
- * @param apiEndpoint - Base url of the API
958
- * @param authProvider - Auth provider that injects authentication info to each request
959
- * @returns axios instance configured with specfic auth provider
960
- *
961
- * @example
962
- * ```typescript
963
- * const client = createApiClient("https://my-api-endpoint-base-url", new BasicAuthProvider("xxx","xxx"));
964
- * ```
965
- */
966
- function createApiClient(apiEndpoint, authProvider) {
967
- // Add a request interceptor
968
- const instance = axios.create({
969
- baseURL: apiEndpoint,
970
- });
971
- instance.interceptors.request.use(function (config) {
972
- return __awaiter(this, void 0, void 0, function* () {
973
- return (yield authProvider.AddAuthenticationInfo(config));
974
- });
975
- });
976
- return instance;
977
- }
978
-
979
- // Copyright (c) Microsoft Corporation.
980
- /**
981
- * Provider that handles Bearer Token authentication
982
- */
983
- class BearerTokenAuthProvider {
984
- /**
985
- * @param { () => Promise<string> } getToken - Function that returns the content of bearer token used in http request
986
- */
987
- constructor(getToken) {
988
- this.getToken = getToken;
989
- }
990
- /**
991
- * Adds authentication info to http requests
992
- *
993
- * @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
994
- * Refer https://axios-http.com/docs/req_config for detailed document.
995
- *
996
- * @returns Updated axios request config.
997
- *
998
- * @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header already exists in request configuration.
999
- */
1000
- AddAuthenticationInfo(config) {
1001
- return __awaiter(this, void 0, void 0, function* () {
1002
- const token = yield this.getToken();
1003
- if (!config.headers) {
1004
- config.headers = {};
1005
- }
1006
- if (config.headers["Authorization"]) {
1007
- throw new ErrorWithCode(ErrorMessage.AuthorizationHeaderAlreadyExists, ErrorCode.AuthorizationInfoAlreadyExists);
1008
- }
1009
- config.headers["Authorization"] = `Bearer ${token}`;
1010
- return config;
1011
- });
1012
- }
1013
- }
1014
-
1015
- // Copyright (c) Microsoft Corporation.
1016
- /**
1017
- * Provider that handles Basic authentication
1018
- */
1019
- class BasicAuthProvider {
1020
- /**
1021
- *
1022
- * @param { string } userName - Username used in basic auth
1023
- * @param { string } password - Password used in basic auth
1024
- *
1025
- * @throws {@link ErrorCode|InvalidParameter} - when username or password is empty.
1026
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1027
- */
1028
- constructor(userName, password) {
1029
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BasicAuthProvider"), ErrorCode.RuntimeNotSupported);
1030
- }
1031
- /**
1032
- * Adds authentication info to http requests
1033
- *
1034
- * @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
1035
- * Refer https://axios-http.com/docs/req_config for detailed document.
1036
- *
1037
- * @returns Updated axios request config.
1038
- *
1039
- * @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when Authorization header or auth property already exists in request configuration.
1040
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1041
- */
1042
- AddAuthenticationInfo(config) {
1043
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BasicAuthProvider"), ErrorCode.RuntimeNotSupported));
1044
- }
1045
- }
1046
-
1047
- // Copyright (c) Microsoft Corporation.
1048
- /**
1049
- * Provider that handles API Key authentication
1050
- */
1051
- class ApiKeyProvider {
1052
- /**
1053
- *
1054
- * @param { string } keyName - The name of request header or query parameter that specifies API Key
1055
- * @param { string } keyValue - The value of API Key
1056
- * @param { ApiKeyLocation } keyLocation - The location of API Key: request header or query parameter.
1057
- *
1058
- * @throws {@link ErrorCode|InvalidParameter} - when key name or key value is empty.
1059
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1060
- */
1061
- constructor(keyName, keyValue, keyLocation) {
1062
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ApiKeyProvider"), ErrorCode.RuntimeNotSupported);
1063
- }
1064
- /**
1065
- * Adds authentication info to http requests
1066
- *
1067
- * @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
1068
- * Refer https://axios-http.com/docs/req_config for detailed document.
1069
- *
1070
- * @returns Updated axios request config.
1071
- *
1072
- * @throws {@link ErrorCode|AuthorizationInfoAlreadyExists} - when API key already exists in request header or url query parameter.
1073
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1074
- */
1075
- AddAuthenticationInfo(config) {
1076
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ApiKeyProvider"), ErrorCode.RuntimeNotSupported));
1077
- }
1078
- }
1079
- /**
1080
- * Define available location for API Key location
1081
- */
1082
- var ApiKeyLocation;
1083
- (function (ApiKeyLocation) {
1084
- /**
1085
- * The API Key is placed in request header
1086
- */
1087
- ApiKeyLocation[ApiKeyLocation["Header"] = 0] = "Header";
1088
- /**
1089
- * The API Key is placed in query parameter
1090
- */
1091
- ApiKeyLocation[ApiKeyLocation["QueryParams"] = 1] = "QueryParams";
1092
- })(ApiKeyLocation || (ApiKeyLocation = {}));
1093
-
1094
- // Copyright (c) Microsoft Corporation.
1095
- /**
1096
- * Provider that handles Certificate authentication
1097
- */
1098
- class CertificateAuthProvider {
1099
- /**
1100
- *
1101
- * @param { SecureContextOptions } certOption - information about the cert used in http requests
1102
- */
1103
- constructor(certOption) {
1104
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CertificateAuthProvider"), ErrorCode.RuntimeNotSupported);
1105
- }
1106
- /**
1107
- * Adds authentication info to http requests.
1108
- *
1109
- * @param { AxiosRequestConfig } config - Contains all the request information and can be updated to include extra authentication info.
1110
- * Refer https://axios-http.com/docs/req_config for detailed document.
1111
- *
1112
- * @returns Updated axios request config.
1113
- *
1114
- * @throws {@link ErrorCode|InvalidParameter} - when custom httpsAgent in the request has duplicate properties with certOption provided in constructor.
1115
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1116
- */
1117
- AddAuthenticationInfo(config) {
1118
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CertificateAuthProvider"), ErrorCode.RuntimeNotSupported));
1119
- }
1120
- }
1121
- /**
1122
- * Helper to create SecureContextOptions from PEM format cert
1123
- *
1124
- * @param { string | Buffer } cert - The cert chain in PEM format
1125
- * @param { string | Buffer } key - The private key for the cert chain
1126
- * @param { {passphrase?: string; ca?: string | Buffer} } options - Optional settings when create the cert options.
1127
- *
1128
- * @returns Instance of SecureContextOptions
1129
- *
1130
- * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
1131
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1132
- *
1133
- */
1134
- function createPemCertOption(cert, key, options) {
1135
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPemCertOption"), ErrorCode.RuntimeNotSupported);
1136
- }
1137
- /**
1138
- * Helper to create SecureContextOptions from PFX format cert
1139
- *
1140
- * @param { string | Buffer } pfx - The content of .pfx file
1141
- * @param { {passphrase?: string} } options - Optional settings when create the cert options.
1142
- *
1143
- * @returns Instance of SecureContextOptions
1144
- *
1145
- * @throws {@link ErrorCode|InvalidParameter} - when any parameter is empty
1146
- * @throws {@link ErrorCode|RuntimeNotSupported} when runtime is browser.
1147
- *
1148
- */
1149
- function createPfxCertOption(pfx, options) {
1150
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "createPfxCertOption"), ErrorCode.RuntimeNotSupported);
1151
- }
1152
-
1153
- // Copyright (c) Microsoft Corporation.
1154
- // Licensed under the MIT license.
1155
- /**
1156
- * The target type where the notification will be sent to.
1157
- *
1158
- * @remarks
1159
- * - "Channel" means to a team channel. (By default, notification to a team will be sent to its "General" channel.)
1160
- * - "Group" means to a group chat.
1161
- * - "Person" means to a personal chat.
1162
- */
1163
- var NotificationTargetType;
1164
- (function (NotificationTargetType) {
1165
- /**
1166
- * The notification will be sent to a team channel.
1167
- * (By default, notification to a team will be sent to its "General" channel.)
1168
- */
1169
- NotificationTargetType["Channel"] = "Channel";
1170
- /**
1171
- * The notification will be sent to a group chat.
1172
- */
1173
- NotificationTargetType["Group"] = "Group";
1174
- /**
1175
- * The notification will be sent to a personal chat.
1176
- */
1177
- NotificationTargetType["Person"] = "Person";
1178
- })(NotificationTargetType || (NotificationTargetType = {}));
1179
- /**
1180
- * Options used to control how the response card will be sent to users.
1181
- */
1182
- var AdaptiveCardResponse;
1183
- (function (AdaptiveCardResponse) {
1184
- /**
1185
- * The response card will be replaced the current one for the interactor who trigger the action.
1186
- */
1187
- AdaptiveCardResponse[AdaptiveCardResponse["ReplaceForInteractor"] = 0] = "ReplaceForInteractor";
1188
- /**
1189
- * The response card will be replaced the current one for all users in the chat.
1190
- */
1191
- AdaptiveCardResponse[AdaptiveCardResponse["ReplaceForAll"] = 1] = "ReplaceForAll";
1192
- /**
1193
- * The response card will be sent as a new message for all users in the chat.
1194
- */
1195
- AdaptiveCardResponse[AdaptiveCardResponse["NewForAll"] = 2] = "NewForAll";
1196
- })(AdaptiveCardResponse || (AdaptiveCardResponse = {}));
1197
- /**
1198
- * Status code for an `application/vnd.microsoft.error` invoke response.
1199
- */
1200
- var InvokeResponseErrorCode;
1201
- (function (InvokeResponseErrorCode) {
1202
- /**
1203
- * Invalid request.
1204
- */
1205
- InvokeResponseErrorCode[InvokeResponseErrorCode["BadRequest"] = 400] = "BadRequest";
1206
- /**
1207
- * Internal server error.
1208
- */
1209
- InvokeResponseErrorCode[InvokeResponseErrorCode["InternalServerError"] = 500] = "InternalServerError";
1210
- })(InvokeResponseErrorCode || (InvokeResponseErrorCode = {}));
1211
-
1212
- // Copyright (c) Microsoft Corporation.
1213
- /*
1214
- * Sso execution dialog, use to handle sso command
1215
- */
1216
- class BotSsoExecutionDialog {
1217
- constructor(dedupStorage, ssoPromptSettings, authConfig, ...args) {
1218
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BotSsoExecutionDialog"), ErrorCode.RuntimeNotSupported);
1219
- }
1220
- // eslint-disable-next-line no-secrets/no-secrets
1221
- /**
1222
- * Add TeamsFxBotSsoCommandHandler instance
1223
- * @param handler {@link BotSsoExecutionDialogHandler} callback function
1224
- * @param triggerPatterns The trigger pattern
1225
- */
1226
- addCommand(handler, triggerPatterns) {
1227
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BotSsoExecutionDialog"), ErrorCode.RuntimeNotSupported);
1228
- }
1229
- /**
1230
- * The run method handles the incoming activity (in the form of a DialogContext) and passes it through the dialog system.
1231
- *
1232
- * @param context The context object for the current turn.
1233
- * @param accessor The instance of StatePropertyAccessor for dialog system.
1234
- */
1235
- run(context, accessor) {
1236
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BotSsoExecutionDialog"), ErrorCode.RuntimeNotSupported);
1237
- }
1238
- /**
1239
- * Called when the component is ending.
1240
- *
1241
- * @param context Context for the current turn of conversation.
1242
- */
1243
- onEndDialog(context) {
1244
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "BotSsoExecutionDialog"), ErrorCode.RuntimeNotSupported);
1245
- }
1246
- }
1247
-
1248
- /**
1249
- * Users execute query with SSO or Access Token.
1250
- * @remarks
1251
- * Only works in in server side.
1252
- */
1253
- function handleMessageExtensionQueryWithSSO(context, config, initiateLoginEndpoint, scopes, logic) {
1254
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "queryWithToken in message extension"), ErrorCode.RuntimeNotSupported);
1255
- }
1256
-
1257
- // Copyright (c) Microsoft Corporation.
1258
- /**
1259
- * Provide utilities for bot conversation, including:
1260
- * - handle command and response.
1261
- * - send notification to varies targets (e.g., member, group, channel).
1262
- *
1263
- * @remarks
1264
- * Only work on server side.
1265
- */
1266
- class ConversationBot {
1267
- /**
1268
- * Create new instance of the `ConversationBot`.
1269
- *
1270
- * @param options - The initialize options.
1271
- *
1272
- * @remarks
1273
- * Only work on server side.
1274
- */
1275
- constructor(options) {
1276
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ConversationBot"), ErrorCode.RuntimeNotSupported);
1277
- }
1278
- /**
1279
- * The request handler to integrate with web request.
1280
- *
1281
- * @param req - An incoming HTTP [Request](xref:botbuilder.Request).
1282
- * @param res - The corresponding HTTP [Response](xref:botbuilder.Response).
1283
- * @param logic - The additional function to handle bot context.
1284
- *
1285
- * @remarks
1286
- * Only work on server side.
1287
- */
1288
- requestHandler(req, res, logic) {
1289
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "ConversationBot"), ErrorCode.RuntimeNotSupported));
1290
- }
1291
- }
1292
-
1293
- // Copyright (c) Microsoft Corporation.
1294
- /**
1295
- * Send a plain text message to a notification target.
1296
- *
1297
- * @remarks
1298
- * Only work on server side.
1299
- *
1300
- * @param target - The notification target.
1301
- * @param text - The plain text message.
1302
- * @param onError - An optional error handler that can catch exceptions during message sending.
1303
- *
1304
- * @returns A `Promise` representing the asynchronous operation.
1305
- */
1306
- function sendMessage(target, text, onError) {
1307
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "sendMessage"), ErrorCode.RuntimeNotSupported));
1308
- }
1309
- /**
1310
- * Send an adaptive card message to a notification target.
1311
- *
1312
- * @remarks
1313
- * Only work on server side.
1314
- *
1315
- * @param target - The notification target.
1316
- * @param card - The adaptive card raw JSON.
1317
- * @param onError - An optional error handler that can catch exceptions during adaptive card sending.
1318
- *
1319
- * @returns A `Promise` representing the asynchronous operation.
1320
- */
1321
- function sendAdaptiveCard(target, card, onError) {
1322
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "sendAdaptiveCard"), ErrorCode.RuntimeNotSupported));
1323
- }
1324
- /**
1325
- * A {@link NotificationTarget} that represents a team channel.
1326
- *
1327
- * @remarks
1328
- * Only work on server side.
1329
- *
1330
- * It's recommended to get channels from {@link TeamsBotInstallation.channels()}.
1331
- */
1332
- class Channel {
1333
- /**
1334
- * Constructor.
1335
- *
1336
- * @remarks
1337
- * Only work on server side.
1338
- *
1339
- * It's recommended to get channels from {@link TeamsBotInstallation.channels()}, instead of using this constructor.
1340
- *
1341
- * @param parent - The parent {@link TeamsBotInstallation} where this channel is created from.
1342
- * @param info - Detailed channel information.
1343
- */
1344
- constructor(parent, info) {
1345
- /**
1346
- * Notification target type. For channel it's always "Channel".
1347
- *
1348
- * @remarks
1349
- * Only work on server side.
1350
- */
1351
- this.type = NotificationTargetType.Channel;
1352
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "Channel"), ErrorCode.RuntimeNotSupported);
1353
- }
1354
- /**
1355
- * Send a plain text message.
1356
- *
1357
- * @remarks
1358
- * Only work on server side.
1359
- *
1360
- * @param text - The plain text message.
1361
- * @param onError - An optional error handler that can catch exceptions during message sending.
1362
- *
1363
- * @returns The response of sending message.
1364
- */
1365
- sendMessage(text, onError) {
1366
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "Channel"), ErrorCode.RuntimeNotSupported));
1367
- }
1368
- /**
1369
- * Send an adaptive card message.
1370
- *
1371
- * @remarks
1372
- * Only work on server side.
1373
- *
1374
- * @param card - The adaptive card raw JSON.
1375
- * @param onError - An optional error handler that can catch exceptions during adaptive card sending.
1376
- *
1377
- * @returns The response of sending adaptive card message.
1378
- */
1379
- sendAdaptiveCard(card, onError) {
1380
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "Channel"), ErrorCode.RuntimeNotSupported));
1381
- }
1382
- }
1383
- /**
1384
- * A {@link NotificationTarget} that represents a team member.
1385
- *
1386
- * @remarks
1387
- * Only work on server side.
1388
- *
1389
- * It's recommended to get members from {@link TeamsBotInstallation.members()}.
1390
- */
1391
- class Member {
1392
- /**
1393
- * Constructor.
1394
- *
1395
- * @remarks
1396
- * Only work on server side.
1397
- *
1398
- * It's recommended to get members from {@link TeamsBotInstallation.members()}, instead of using this constructor.
1399
- *
1400
- * @param parent - The parent {@link TeamsBotInstallation} where this member is created from.
1401
- * @param account - Detailed member account information.
1402
- */
1403
- constructor(parent, account) {
1404
- /**
1405
- * Notification target type. For member it's always "Person".
1406
- *
1407
- * @remarks
1408
- * Only work on server side.
1409
- */
1410
- this.type = NotificationTargetType.Person;
1411
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "Member"), ErrorCode.RuntimeNotSupported);
1412
- }
1413
- /**
1414
- * Send a plain text message.
1415
- *
1416
- * @remarks
1417
- * Only work on server side.
1418
- *
1419
- * @param text - The plain text message.
1420
- * @param onError - An optional error handler that can catch exceptions during message sending.
1421
- *
1422
- * @returns The response of sending message.
1423
- */
1424
- sendMessage(text, onError) {
1425
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "Member"), ErrorCode.RuntimeNotSupported));
1426
- }
1427
- /**
1428
- * Send an adaptive card message.
1429
- *
1430
- * @remarks
1431
- * Only work on server side.
1432
- *
1433
- * @param card - The adaptive card raw JSON.
1434
- * @param onError - An optional error handler that can catch exceptions during adaptive card sending.
1435
- *
1436
- * @returns The response of sending adaptive card message.
1437
- */
1438
- sendAdaptiveCard(card, onError) {
1439
- return Promise.reject(Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "Member"), ErrorCode.RuntimeNotSupported)));
1440
- }
1441
- }
1442
- /**
1443
- * A {@link NotificationTarget} that represents a bot installation. Teams Bot could be installed into
1444
- * - Personal chat
1445
- * - Group chat
1446
- * - Team (by default the `General` channel)
1447
- *
1448
- * @remarks
1449
- * Only work on server side.
1450
- *
1451
- * It's recommended to get bot installations from {@link ConversationBot.installations()}.
1452
- */
1453
- class TeamsBotInstallation {
1454
- /**
1455
- * Constructor
1456
- *
1457
- * @remarks
1458
- * Only work on server side.
1459
- *
1460
- * It's recommended to get bot installations from {@link ConversationBot.installations()}, instead of using this constructor.
1461
- *
1462
- * @param adapter - The bound `CloudAdapter`.
1463
- * @param conversationReference - The bound `ConversationReference`.
1464
- */
1465
- constructor(adapter, conversationReference) {
1466
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotInstallation"), ErrorCode.RuntimeNotSupported);
1467
- }
1468
- /**
1469
- * Send a plain text message.
1470
- *
1471
- * @remarks
1472
- * Only work on server side.
1473
- *
1474
- * @param text - The plain text message.
1475
- * @param onError - An optional error handler that can catch exceptions during message sending.
1476
- *
1477
- * @returns The response of sending message.
1478
- */
1479
- sendMessage(text, onError) {
1480
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotInstallation"), ErrorCode.RuntimeNotSupported));
1481
- }
1482
- /**
1483
- * Send an adaptive card message.
1484
- *
1485
- * @remarks
1486
- * Only work on server side.
1487
- *
1488
- * @param card - The adaptive card raw JSON.
1489
- * @param onError - An optional error handler that can catch exceptions during adaptive card sending.
1490
- *
1491
- * @returns The response of sending adaptive card message.
1492
- */
1493
- sendAdaptiveCard(card, onError) {
1494
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotInstallation"), ErrorCode.RuntimeNotSupported));
1495
- }
1496
- /**
1497
- * Get channels from this bot installation.
1498
- *
1499
- * @remarks
1500
- * Only work on server side.
1501
- *
1502
- * @returns An array of channels if bot is installed into a team, otherwise returns an empty array.
1503
- */
1504
- channels() {
1505
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotInstallation"), ErrorCode.RuntimeNotSupported));
1506
- }
1507
- /**
1508
- * Get members from this bot installation.
1509
- *
1510
- * @remarks
1511
- * Only work on server side.
1512
- *
1513
- * @returns An array of members from where the bot is installed.
1514
- */
1515
- members() {
1516
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotInstallation"), ErrorCode.RuntimeNotSupported));
1517
- }
1518
- /**
1519
- * Get team details from this bot installation
1520
- *
1521
- * @returns The team details if bot is installed into a team, otherwise returns undefined.
1522
- */
1523
- getTeamDetails() {
1524
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotInstallation"), ErrorCode.RuntimeNotSupported));
1525
- }
1526
- }
1527
- /**
1528
- * Provide static utilities for bot notification.
1529
- *
1530
- * @remarks
1531
- * Only work on server side.
1532
- *
1533
- * @example
1534
- * Here's an example on how to send notification via Teams Bot.
1535
- * ```typescript
1536
- * // initialize (it's recommended to be called before handling any bot message)
1537
- * const notificationBot = new NotificationBot(adapter);
1538
- *
1539
- * // get all bot installations and send message
1540
- * for (const target of await notificationBot.installations()) {
1541
- * await target.sendMessage("Hello Notification");
1542
- * }
1543
- *
1544
- * // alternative - send message to all members
1545
- * for (const target of await notificationBot.installations()) {
1546
- * for (const member of await target.members()) {
1547
- * await member.sendMessage("Hello Notification");
1548
- * }
1549
- * }
1550
- * ```
1551
- */
1552
- class NotificationBot {
1553
- /**
1554
- * Constructor of the notification bot.
1555
- *
1556
- * @remarks
1557
- * Only work on server side.
1558
- *
1559
- * To ensure accuracy, it's recommended to initialize before handling any message.
1560
- *
1561
- * @param adapter - The bound `CloudAdapter`
1562
- * @param options - The initialize options
1563
- */
1564
- constructor(adapter, options) {
1565
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "NotificationBot"), ErrorCode.RuntimeNotSupported);
1566
- }
1567
- /**
1568
- * Get all targets where the bot is installed.
1569
- *
1570
- * @remarks
1571
- * Only work on server side.
1572
- *
1573
- * The result is retrieving from the persisted storage.
1574
- *
1575
- * @returns An array of {@link TeamsBotInstallation}.
1576
- */
1577
- static installations() {
1578
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "NotificationBot"), ErrorCode.RuntimeNotSupported));
1579
- }
1580
- /**
1581
- * Return the first {@link Member} where predicate is true, and undefined otherwise.
1582
- *
1583
- * @remarks
1584
- * Only work on server side.
1585
- *
1586
- * @param predicate find calls predicate once for each member of the installation,
1587
- * until it finds one where predicate returns true. If such a member is found,
1588
- * find immediately returns that member. Otherwise, find returns undefined.
1589
- * @param scope the scope to find members from the installations (personal chat, group chat, Teams channel).
1590
- *
1591
- * @returns The first {@link Member} where predicate is true, and undefined otherwise.
1592
- */
1593
- findMember(predicate, scope) {
1594
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "NotificationBot"), ErrorCode.RuntimeNotSupported));
1595
- }
1596
- /**
1597
- * Return the first {@link Channel} where predicate is true, and undefined otherwise.
1598
- * (Ensure the bot app is installed into the `General` channel, otherwise undefined will be returned.)
1599
- *
1600
- * @remarks
1601
- * Only work on server side.
1602
- *
1603
- * @param predicate - Find calls predicate once for each channel of the installation,
1604
- * until it finds one where predicate returns true. If such a channel is found, find
1605
- * immediately returns that channel. Otherwise, find returns undefined.
1606
- *
1607
- * @returns The first {@link Channel} where predicate is true, and `undefined` otherwise.
1608
- */
1609
- findChannel(predicate) {
1610
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "NotificationBot"), ErrorCode.RuntimeNotSupported));
1611
- }
1612
- /**
1613
- * Return all {@link Member} where predicate is true, and empty array otherwise.
1614
- *
1615
- * @remarks
1616
- * Only work on server side.
1617
- *
1618
- * @param predicate - Find calls predicate for each member of the installation.
1619
- * @param scope - The scope to find members from the installations.
1620
- * (personal chat, group chat, Teams channel).
1621
- *
1622
- * @returns An array of {@link Member} where predicate is true, and empty array otherwise.
1623
- */
1624
- findAllMembers(predicate, scope) {
1625
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "NotificationBot"), ErrorCode.RuntimeNotSupported));
1626
- }
1627
- /**
1628
- * Return all {@link Channel} where predicate is true, and empty array otherwise.
1629
- * (Ensure the bot app is installed into the `General` channel, otherwise empty array will be returned.)
1630
- *
1631
- * @remarks
1632
- * Only work on server side.
1633
- *
1634
- * @param predicate - Find calls predicate for each channel of the installation.
1635
- *
1636
- * @returns An array of {@link Channel} where predicate is true, and empty array otherwise.
1637
- */
1638
- findAllChannels(predicate) {
1639
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "NotificationBot"), ErrorCode.RuntimeNotSupported));
1640
- }
1641
- }
1642
- /**
1643
- * The search scope when calling {@link NotificationBot.findMember} and {@link NotificationBot.findAllMembers}.
1644
- * The search scope is a flagged enum and it can be combined with `|`.
1645
- * For example, to search from personal chat and group chat, use `SearchScope.Person | SearchScope.Group`.
1646
- */
1647
- var SearchScope;
1648
- (function (SearchScope) {
1649
- /**
1650
- * Search members from the installations in personal chat only.
1651
- */
1652
- SearchScope[SearchScope["Person"] = 1] = "Person";
1653
- /**
1654
- * Search members from the installations in group chat only.
1655
- */
1656
- SearchScope[SearchScope["Group"] = 2] = "Group";
1657
- /**
1658
- * Search members from the installations in Teams channel only.
1659
- */
1660
- SearchScope[SearchScope["Channel"] = 4] = "Channel";
1661
- /**
1662
- * Search members from all installations including personal chat, group chat and Teams channel.
1663
- */
1664
- SearchScope[SearchScope["All"] = 7] = "All";
1665
- })(SearchScope || (SearchScope = {}));
1666
-
1667
- // Copyright (c) Microsoft Corporation.
1668
- /**
1669
- * A command bot for receiving commands and sending responses in Teams.
1670
- *
1671
- * @remarks
1672
- * Only work on server side.
1673
- */
1674
- class CommandBot {
1675
- /**
1676
- * Create a new instance of the `CommandBot`.
1677
- *
1678
- * @param adapter - The bound `CloudAdapter`.
1679
- * @param commands - The commands to be registered with the command bot. Each command should implement the interface {@link TeamsFxBotCommandHandler} so that it can be correctly handled by this command bot.
1680
- */
1681
- constructor(adapter, commands) {
1682
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CommandBot"), ErrorCode.RuntimeNotSupported);
1683
- }
1684
- /**
1685
- * Register a command into the command bot.
1686
- *
1687
- * @param command - The command to be registered.
1688
- *
1689
- * @remarks
1690
- * Only work on server side.
1691
- */
1692
- registerCommand(command) {
1693
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CommandBot"), ErrorCode.RuntimeNotSupported);
1694
- }
1695
- /**
1696
- * Register commands into the command bot.
1697
- *
1698
- * @param commands - The commands to be registered.
1699
- *
1700
- * @remarks
1701
- * Only work on server side.
1702
- */
1703
- registerCommands(commands) {
1704
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CommandBot"), ErrorCode.RuntimeNotSupported);
1705
- }
1706
- /**
1707
- * Register a sso command into the command bot.
1708
- *
1709
- * @param ssoCommand - The sso command to be registered.
1710
- */
1711
- registerSsoCommand(ssoCommand) {
1712
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CommandBot"), ErrorCode.RuntimeNotSupported);
1713
- }
1714
- /**
1715
- * Register sso commands into the command bot.
1716
- *
1717
- * @param ssoCommands - The sso commands to be registered.
1718
- */
1719
- registerSsoCommands(ssoCommands) {
1720
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CommandBot"), ErrorCode.RuntimeNotSupported);
1721
- }
1722
- }
1723
-
1724
- /**
1725
- * A card action bot to respond to adaptive card universal actions.
1726
- *
1727
- * @remarks
1728
- * Only work on server side.
1729
- */
1730
- class CardActionBot {
1731
- /**
1732
- * Create a new instance of the `CardActionBot`.
1733
- *
1734
- * @param adapter - The bound `CloudAdapter`.
1735
- * @param options - The initialize options.
1736
- */
1737
- constructor(adapter, options) {
1738
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CardActionBot"), ErrorCode.RuntimeNotSupported);
1739
- }
1740
- /**
1741
- * Register a card action handler to the bot.
1742
- *
1743
- * @param actionHandler - A card action handler to be registered.
1744
- *
1745
- * @remarks
1746
- * Only work on server side.
1747
- */
1748
- registerHandler(actionHandler) {
1749
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CardActionBot"), ErrorCode.RuntimeNotSupported));
1750
- }
1751
- /**
1752
- * Register card action handlers to the bot.
1753
- *
1754
- * @param actionHandlers - A set of card action handlers to be registered.
1755
- *
1756
- * @remarks
1757
- * Only work on server side.
1758
- */
1759
- registerHandlers(actionHandlers) {
1760
- return Promise.reject(new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "CardActionBot"), ErrorCode.RuntimeNotSupported));
1761
- }
1762
- }
1763
-
1764
- var conversationWithCloudAdapter_browser = /*#__PURE__*/Object.freeze({
1765
- __proto__: null,
1766
- ConversationBot: ConversationBot,
1767
- BotSsoExecutionDialog: BotSsoExecutionDialog,
1768
- Channel: Channel,
1769
- Member: Member,
1770
- NotificationBot: NotificationBot,
1771
- sendAdaptiveCard: sendAdaptiveCard,
1772
- sendMessage: sendMessage,
1773
- TeamsBotInstallation: TeamsBotInstallation,
1774
- CommandBot: CommandBot,
1775
- CardActionBot: CardActionBot
1776
- });
1777
-
1778
- export { AdaptiveCardResponse, ApiKeyLocation, ApiKeyProvider, AppCredential, BasicAuthProvider, BearerTokenAuthProvider, conversationWithCloudAdapter_browser as BotBuilderCloudAdapter, BotSsoExecutionDialog, CertificateAuthProvider, ErrorCode, ErrorWithCode, InvokeResponseErrorCode, LogLevel, NotificationTargetType, OnBehalfOfUserCredential, TeamsBotSsoPrompt, TeamsUserCredential, createApiClient, createPemCertOption, createPfxCertOption, getLogLevel, handleMessageExtensionQueryWithSSO, setLogFunction, setLogLevel, setLogger };
1
+ import{jwtDecode as e}from"jwt-decode";import{app as t,authentication as o}from"@microsoft/teams-js";import{PublicClientApplication as r}from"@azure/msal-browser";import n from"axios";var i,s;!function(e){e.InvalidParameter="InvalidParameter",e.InvalidConfiguration="InvalidConfiguration",e.InvalidCertificate="InvalidCertificate",e.InternalError="InternalError",e.ChannelNotSupported="ChannelNotSupported",e.FailedToRetrieveSsoToken="FailedToRetrieveSsoToken",e.FailedToProcessSsoHandler="FailedToProcessSsoHandler",e.CannotFindCommand="CannotFindCommand",e.FailedToRunSsoStep="FailedToRunSsoStep",e.FailedToRunDedupStep="FailedToRunDedupStep",e.SsoActivityHandlerIsUndefined="SsoActivityHandlerIsUndefined",e.RuntimeNotSupported="RuntimeNotSupported",e.ConsentFailed="ConsentFailed",e.UiRequiredError="UiRequiredError",e.TokenExpiredError="TokenExpiredError",e.ServiceError="ServiceError",e.FailedOperation="FailedOperation",e.InvalidResponse="InvalidResponse",e.AuthorizationInfoAlreadyExists="AuthorizationInfoAlreadyExists"}(i||(i={}));class a{}a.InvalidConfiguration="{0} in configuration is invalid: {1}.",a.ConfigurationNotExists="Configuration does not exist. {0}",a.ResourceConfigurationNotExists="{0} resource configuration does not exist.",a.MissingResourceConfiguration="Missing resource configuration with type: {0}, name: {1}.",a.AuthenticationConfigurationNotExists="Authentication configuration does not exist.",a.BrowserRuntimeNotSupported="{0} is not supported in browser.",a.NodejsRuntimeNotSupported="{0} is not supported in Node.",a.FailToAcquireTokenOnBehalfOfUser="Failed to acquire access token on behalf of user: {0}",a.OnlyMSTeamsChannelSupported="{0} is only supported in MS Teams Channel",a.FailedToProcessSsoHandler="Failed to process sso handler: {0}",a.FailedToRetrieveSsoToken="Failed to retrieve sso token, user failed to finish the AAD consent flow.",a.CannotFindCommand="Cannot find command: {0}",a.FailedToRunSsoStep="Failed to run dialog to retrieve sso token: {0}",a.FailedToRunDedupStep="Failed to run dialog to remove duplicated messages: {0}",a.SsoActivityHandlerIsNull="Sso command can only be used or added when sso activity handler is not undefined",a.AuthorizationHeaderAlreadyExists="Authorization header already exists!",a.BasicCredentialAlreadyExists="Basic credential already exists!",a.EmptyParameter="Parameter {0} is empty",a.DuplicateHttpsOptionProperty="Axios HTTPS agent already defined value for property {0}",a.DuplicateApiKeyInHeader="The request already defined api key in request header with name {0}.",a.DuplicateApiKeyInQueryParam="The request already defined api key in query parameter with name {0}.",a.OnlySupportInQueryActivity="The handleMessageExtensionQueryWithToken only support in handleTeamsMessagingExtensionQuery with composeExtension/query type.",a.OnlySupportInLinkQueryActivity="The handleMessageExtensionLinkQueryWithSSO only support in handleTeamsAppBasedLinkQuery with composeExtension/queryLink type.";class u extends Error{constructor(e,t){if(!t)return super(e),this;super(e),Object.setPrototypeOf(this,u.prototype),this.name=`${new.target.name}.${t}`,this.code=t}}function d(e){c.level=e}function p(){return c.level}!function(e){e[e.Verbose=0]="Verbose",e[e.Info=1]="Info",e[e.Warn=2]="Warn",e[e.Error=3]="Error"}(s||(s={}));const c=new class{constructor(e,t){this.level=void 0,this.defaultLogger={verbose:console.debug,info:console.info,warn:console.warn,error:console.error},this.name=e,this.level=t}error(e){this.log(s.Error,(e=>e.error),e)}warn(e){this.log(s.Warn,(e=>e.warn),e)}info(e){this.log(s.Info,(e=>e.info),e)}verbose(e){this.log(s.Verbose,(e=>e.verbose),e)}log(e,t,o){if(""===o.trim())return;const r=(new Date).toUTCString();let n;n=this.name?`[${r}] : @microsoft/teamsfx - ${this.name} : ${s[e]} - `:`[${r}] : @microsoft/teamsfx : ${s[e]} - `;const i=`${n}${o}`;void 0!==this.level&&this.level<=e&&(this.customLogger?t(this.customLogger)(i):this.customLogFunction?this.customLogFunction(e,i):t(this.defaultLogger)(i))}};function l(e){c.customLogger=e}function m(e){c.customLogFunction=e}function h(t){try{const o=e(t);if(!o||!o.exp)throw new u("Decoded token is null or exp claim does not exists.",i.InternalError);return o}catch(e){const t="Parse jwt token failed in node env with error: "+e.message;throw c.error(t),new u(t,i.InternalError)}}function w(e,...t){const o=t;return e.replace(/{(\d+)}/g,(function(e,t){return void 0!==o[t]?o[t]:e}))}function f(e){if("string"==typeof e||e instanceof String)return;if(Array.isArray(e)&&0===e.length)return;if(Array.isArray(e)&&e.length>0&&e.every((e=>"string"==typeof e)))return;const t="The type of scopes is not valid, it must be string or string array";throw c.error(t),new u(t,i.InvalidParameter)}class S{constructor(e){throw new u(w(a.BrowserRuntimeNotSupported,"AppCredential"),i.RuntimeNotSupported)}getToken(e,t){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"AppCredential"),i.RuntimeNotSupported))}}class g{constructor(e,t){throw new u(w(a.BrowserRuntimeNotSupported,"OnBehalfOfUserCredential"),i.RuntimeNotSupported)}getToken(e,t){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"OnBehalfOfUserCredential"),i.RuntimeNotSupported))}getUserInfo(){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"OnBehalfOfUserCredential"),i.RuntimeNotSupported))}}
2
+ /*! *****************************************************************************
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
+ PERFORMANCE OF THIS SOFTWARE.
15
+ ***************************************************************************** */function R(e,t,o,r){return new(o||(o=Promise))((function(t,n){function i(e){try{a(r.next(e))}catch(e){n(e)}}function s(e){try{a(r.throw(e))}catch(e){n(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof o?r:new o((function(e){e(r)}))).then(i,s)}a((r=r.apply(e,[])).next())}))}class N{constructor(e){c.info("Create teams user credential"),this.config=this.loadAndValidateConfig(e),this.ssoToken=null,this.initialized=!1}login(e,r){return R(this,0,void 0,(function*(){f(e);const n="string"==typeof e?e:e.join(" ");let s;c.info(`Popup login page to get user's access token with scopes: ${n}`),this.initialized||(yield this.init(r)),yield t.initialize();try{const e={url:`${this.config.initiateLoginEndpoint?this.config.initiateLoginEndpoint:""}?clientId=${this.config.clientId?this.config.clientId:""}&scope=${encodeURI(n)}&loginHint=${this.loginHint?this.loginHint:""}`,width:600,height:535};if(s=yield o.authenticate(e),!s){const e="Get empty authentication result from MSAL";throw c.error(e),new u(e,i.InternalError)}}catch(e){const t=`Consent failed for the scope ${n} with error: ${e.message}`;throw c.error(t),new u(t,i.ConsentFailed)}let a={};try{a="string"==typeof s?JSON.parse(s):s}catch(e){const t="Failed to parse response to Json.";throw c.error(t),new u(t,i.InvalidResponse)}if(a.code){const e=`Found auth code in response. Auth code is not support for current version of SDK. Please refer to the help link for how to fix the issue: ${"https://aka.ms/teamsfx-auth-code-flow"}.`;throw c.error(e),new u(e,i.InvalidResponse)}a.sessionStorage&&this.setSessionStorage(a.sessionStorage)}))}getToken(e,t){return R(this,0,void 0,(function*(){f(e);const o=null==t?void 0:t.resources,r=yield this.getSSOToken(o),n="string"==typeof e?e:e.join(" ");if(""===n)return c.info("Get SSO token"),r;{let t;c.info("Get access token with scopes: "+n),this.initialized||(yield this.init(o));const r="string"==typeof e?e.split(" "):e,s=window.location.origin;try{const e=this.msalInstance.getAccountByUsername(this.loginHint),o={scopes:r,account:null!=e?e:void 0,redirectUri:`${s}/blank-auth-end.html`};t=yield this.msalInstance.acquireTokenSilent(o)}catch(e){const t=`Failed to call acquireTokenSilent. Reason: ${null==e?void 0:e.message}. `;c.verbose(t)}if(!t)try{const e={scopes:r,loginHint:this.loginHint,redirectUri:`${s}/blank-auth-end.html`};t=yield this.msalInstance.ssoSilent(e)}catch(e){const t=`Failed to call ssoSilent. Reason: ${null==e?void 0:e.message}. `;c.verbose(t)}if(!t){const e="Failed to get access token cache silently, please login first: you need login first before get access token.";throw c.error(e),new u(e,i.UiRequiredError)}const a=function(e){try{const t="string"==typeof e?JSON.parse(e):e;if(!t||!t.accessToken){const e="Get empty access token from Auth Code token response.";throw c.error(e),new Error(e)}const o=t.accessToken,r=h(o);if("1.0"!==r.ver&&"2.0"!==r.ver){const e="SSO token is not valid with an unknown version: "+r.ver;throw c.error(e),new Error(e)}return{token:o,expiresOnTimestamp:1e3*r.exp}}catch(e){const t="Parse access token failed from Auth Code token response in node env with error: "+e.message;throw c.error(t),new u(t,i.InternalError)}}(t);return a}}))}getUserInfo(e){return R(this,0,void 0,(function*(){c.info("Get basic user info from SSO token");return function(e){if(!e){const e="SSO token is undefined.";throw c.error(e),new u(e,i.InvalidParameter)}const t=h(e),o={displayName:t.name,objectId:t.oid,tenantId:t.tid,preferredUserName:""};return"2.0"===t.ver?o.preferredUserName=t.preferred_username:"1.0"===t.ver&&(o.preferredUserName=t.upn),o}((yield this.getSSOToken(e)).token)}))}init(e){return R(this,0,void 0,(function*(){const t=function(e){if(!e){const e="SSO token is undefined.";throw c.error(e),new u(e,i.InvalidParameter)}const t=h(e);return{tid:t.tid,loginHint:"2.0"===t.ver?t.preferred_username:t.upn}}((yield this.getSSOToken(e)).token);this.loginHint=t.loginHint,this.tid=t.tid;const o={auth:{clientId:this.config.clientId,authority:`https://login.microsoftonline.com/${this.tid}`},cache:{cacheLocation:"sessionStorage"}};this.msalInstance=new r(o),yield this.msalInstance.initialize(),this.initialized=!0}))}getSSOToken(e){return R(this,0,void 0,(function*(){if(this.ssoToken&&this.ssoToken.expiresOnTimestamp-Date.now()>3e5)return c.verbose("Get SSO token from memory cache"),this.ssoToken;const r={resources:null!=e?e:[]};let n;try{yield t.initialize()}catch(e){const t="Initialize teams sdk failed due to not running inside Teams environment";throw c.error(t),new u(t,i.InternalError)}try{n=yield o.getAuthToken(r)}catch(e){const t="Get SSO token failed with error: "+e.message;throw c.error(t),new u(t,i.InternalError)}if(!n){const e="Get empty SSO token from Teams";throw c.error(e),new u(e,i.InternalError)}const s=h(n);if("1.0"!==s.ver&&"2.0"!==s.ver){const e="SSO token is not valid with an unknown version: "+s.ver;throw c.error(e),new u(e,i.InternalError)}const a={token:n,expiresOnTimestamp:1e3*s.exp};return this.ssoToken=a,a}))}loadAndValidateConfig(e){if(c.verbose("Validate authentication configuration"),e.initiateLoginEndpoint&&e.clientId)return e;const t=[];e.initiateLoginEndpoint||t.push("initiateLoginEndpoint"),e.clientId||t.push("clientId");const o=w(a.InvalidConfiguration,t.join(", "),"undefined");throw c.error(o),new u(o,i.InvalidConfiguration)}setSessionStorage(e){try{Object.keys(e).forEach((t=>{sessionStorage.setItem(t,e[t])}))}catch(e){const t=`Failed to set values in session storage. Error: ${e.message}`;throw c.error(t),new u(t,i.InternalError)}}}class y{constructor(e,t,o,r){throw new u(w(a.BrowserRuntimeNotSupported,"TeamsBotSsoPrompt"),i.RuntimeNotSupported)}beginDialog(e){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"TeamsBotSsoPrompt"),i.RuntimeNotSupported))}continueDialog(e){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"TeamsBotSsoPrompt"),i.RuntimeNotSupported))}}function B(e,t){const o=n.create({baseURL:e});return o.interceptors.request.use((function(e){return R(this,0,void 0,(function*(){return yield t.AddAuthenticationInfo(e)}))})),o}class v{constructor(e){this.getToken=e}AddAuthenticationInfo(e){return R(this,0,void 0,(function*(){const t=yield this.getToken();if(e.headers||(e.headers={}),e.headers.Authorization)throw new u(a.AuthorizationHeaderAlreadyExists,i.AuthorizationInfoAlreadyExists);return e.headers.Authorization=`Bearer ${t}`,e}))}}class C{constructor(e,t){throw new u(w(a.BrowserRuntimeNotSupported,"BasicAuthProvider"),i.RuntimeNotSupported)}AddAuthenticationInfo(e){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"BasicAuthProvider"),i.RuntimeNotSupported))}}class A{constructor(e,t,o){throw new u(w(a.BrowserRuntimeNotSupported,"ApiKeyProvider"),i.RuntimeNotSupported)}AddAuthenticationInfo(e){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"ApiKeyProvider"),i.RuntimeNotSupported))}}var I,T,k,P,E;!function(e){e[e.Header=0]="Header",e[e.QueryParams=1]="QueryParams"}(I||(I={}));class x{constructor(e){throw new u(w(a.BrowserRuntimeNotSupported,"CertificateAuthProvider"),i.RuntimeNotSupported)}AddAuthenticationInfo(e){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"CertificateAuthProvider"),i.RuntimeNotSupported))}}function F(e,t,o){throw new u(w(a.BrowserRuntimeNotSupported,"createPemCertOption"),i.RuntimeNotSupported)}function j(e,t){throw new u(w(a.BrowserRuntimeNotSupported,"createPfxCertOption"),i.RuntimeNotSupported)}!function(e){e.Channel="Channel",e.Group="Group",e.Person="Person"}(T||(T={})),function(e){e[e.ReplaceForInteractor=0]="ReplaceForInteractor",e[e.ReplaceForAll=1]="ReplaceForAll",e[e.NewForAll=2]="NewForAll"}(k||(k={})),function(e){e[e.BadRequest=400]="BadRequest",e[e.InternalServerError=500]="InternalServerError"}(P||(P={}));class O{constructor(e,t,o,...r){throw new u(w(a.BrowserRuntimeNotSupported,"BotSsoExecutionDialog"),i.RuntimeNotSupported)}addCommand(e,t){throw new u(w(a.BrowserRuntimeNotSupported,"BotSsoExecutionDialog"),i.RuntimeNotSupported)}run(e,t){throw new u(w(a.BrowserRuntimeNotSupported,"BotSsoExecutionDialog"),i.RuntimeNotSupported)}onEndDialog(e){throw new u(w(a.BrowserRuntimeNotSupported,"BotSsoExecutionDialog"),i.RuntimeNotSupported)}}function b(e,t,o,r,n){throw new u(w(a.BrowserRuntimeNotSupported,"queryWithToken in message extension"),i.RuntimeNotSupported)}!function(e){e[e.Person=1]="Person",e[e.Group=2]="Group",e[e.Channel=4]="Channel",e[e.All=7]="All"}(E||(E={}));var H=Object.freeze({__proto__:null,BotSsoExecutionDialog:O,CardActionBot:class{constructor(e,t){throw new u(w(a.BrowserRuntimeNotSupported,"CardActionBot"),i.RuntimeNotSupported)}registerHandler(e){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"CardActionBot"),i.RuntimeNotSupported))}registerHandlers(e){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"CardActionBot"),i.RuntimeNotSupported))}},Channel:class{constructor(e,t){throw this.type=T.Channel,new u(w(a.BrowserRuntimeNotSupported,"Channel"),i.RuntimeNotSupported)}sendMessage(e,t){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"Channel"),i.RuntimeNotSupported))}sendAdaptiveCard(e,t){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"Channel"),i.RuntimeNotSupported))}},CommandBot:class{constructor(e,t){throw new u(w(a.BrowserRuntimeNotSupported,"CommandBot"),i.RuntimeNotSupported)}registerCommand(e){throw new u(w(a.BrowserRuntimeNotSupported,"CommandBot"),i.RuntimeNotSupported)}registerCommands(e){throw new u(w(a.BrowserRuntimeNotSupported,"CommandBot"),i.RuntimeNotSupported)}registerSsoCommand(e){throw new u(w(a.BrowserRuntimeNotSupported,"CommandBot"),i.RuntimeNotSupported)}registerSsoCommands(e){throw new u(w(a.BrowserRuntimeNotSupported,"CommandBot"),i.RuntimeNotSupported)}},ConversationBot:class{constructor(e){throw new u(w(a.BrowserRuntimeNotSupported,"ConversationBot"),i.RuntimeNotSupported)}requestHandler(e,t,o){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"ConversationBot"),i.RuntimeNotSupported))}},Member:class{constructor(e,t){throw this.type=T.Person,new u(w(a.BrowserRuntimeNotSupported,"Member"),i.RuntimeNotSupported)}sendMessage(e,t){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"Member"),i.RuntimeNotSupported))}sendAdaptiveCard(e,t){return Promise.reject(Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"Member"),i.RuntimeNotSupported)))}},NotificationBot:class{constructor(e,t){throw new u(w(a.BrowserRuntimeNotSupported,"NotificationBot"),i.RuntimeNotSupported)}static installations(){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"NotificationBot"),i.RuntimeNotSupported))}findMember(e,t){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"NotificationBot"),i.RuntimeNotSupported))}findChannel(e){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"NotificationBot"),i.RuntimeNotSupported))}findAllMembers(e,t){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"NotificationBot"),i.RuntimeNotSupported))}findAllChannels(e){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"NotificationBot"),i.RuntimeNotSupported))}},TeamsBotInstallation:class{constructor(e,t){throw new u(w(a.BrowserRuntimeNotSupported,"TeamsBotInstallation"),i.RuntimeNotSupported)}sendMessage(e,t){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"TeamsBotInstallation"),i.RuntimeNotSupported))}sendAdaptiveCard(e,t){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"TeamsBotInstallation"),i.RuntimeNotSupported))}channels(){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"TeamsBotInstallation"),i.RuntimeNotSupported))}members(){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"TeamsBotInstallation"),i.RuntimeNotSupported))}getTeamDetails(){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"TeamsBotInstallation"),i.RuntimeNotSupported))}},sendAdaptiveCard:function(e,t,o){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"sendAdaptiveCard"),i.RuntimeNotSupported))},sendMessage:function(e,t,o){return Promise.reject(new u(w(a.BrowserRuntimeNotSupported,"sendMessage"),i.RuntimeNotSupported))}});export{k as AdaptiveCardResponse,I as ApiKeyLocation,A as ApiKeyProvider,S as AppCredential,C as BasicAuthProvider,v as BearerTokenAuthProvider,H as BotBuilderCloudAdapter,O as BotSsoExecutionDialog,x as CertificateAuthProvider,i as ErrorCode,u as ErrorWithCode,P as InvokeResponseErrorCode,s as LogLevel,T as NotificationTargetType,g as OnBehalfOfUserCredential,y as TeamsBotSsoPrompt,N as TeamsUserCredential,B as createApiClient,F as createPemCertOption,j as createPfxCertOption,p as getLogLevel,b as handleMessageExtensionQueryWithSSO,m as setLogFunction,d as setLogLevel,l as setLogger};
1779
16
  //# sourceMappingURL=index.esm5.js.map