@microsoft/teamsfx 0.4.2-alpha.eb4575da.0 → 0.5.1-alpha.3194a88e.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,10 +1,11 @@
1
- import { __extends, __awaiter, __generator } from 'tslib';
2
1
  import jwt_decode from 'jwt-decode';
2
+ import { __awaiter } from 'tslib';
3
3
  import * as microsoftTeams from '@microsoft/teams-js';
4
4
  import { PublicClientApplication } from '@azure/msal-browser';
5
5
  import { Client } from '@microsoft/microsoft-graph-client';
6
6
 
7
7
  // Copyright (c) Microsoft Corporation.
8
+ // Licensed under the MIT license.
8
9
  /**
9
10
  * Error code to trace the error types.
10
11
  * @beta
@@ -55,35 +56,35 @@ var ErrorCode;
55
56
  * Operation failed.
56
57
  */
57
58
  ErrorCode["FailedOperation"] = "FailedOperation";
59
+ /**
60
+ * Invalid response error.
61
+ */
62
+ ErrorCode["InvalidResponse"] = "InvalidResponse";
58
63
  })(ErrorCode || (ErrorCode = {}));
59
64
  /**
60
65
  * @internal
61
66
  */
62
- var ErrorMessage = /** @class */ (function () {
63
- function ErrorMessage() {
64
- }
65
- // InvalidConfiguration Error
66
- ErrorMessage.InvalidConfiguration = "{0} in configuration is invalid: {1}.";
67
- ErrorMessage.ConfigurationNotExists = "Configuration does not exist. {0}";
68
- ErrorMessage.ResourceConfigurationNotExists = "{0} resource configuration does not exist.";
69
- ErrorMessage.MissingResourceConfiguration = "Missing resource configuration with type: {0}, name: {1}.";
70
- ErrorMessage.AuthenticationConfigurationNotExists = "Authentication configuration does not exist.";
71
- // RuntimeNotSupported Error
72
- ErrorMessage.BrowserRuntimeNotSupported = "{0} is not supported in browser.";
73
- ErrorMessage.NodejsRuntimeNotSupported = "{0} is not supported in Node.";
74
- // Internal Error
75
- ErrorMessage.FailToAcquireTokenOnBehalfOfUser = "Failed to acquire access token on behalf of user: {0}";
76
- // ChannelNotSupported Error
77
- ErrorMessage.OnlyMSTeamsChannelSupported = "{0} is only supported in MS Teams Channel";
78
- return ErrorMessage;
79
- }());
67
+ class ErrorMessage {
68
+ }
69
+ // InvalidConfiguration Error
70
+ ErrorMessage.InvalidConfiguration = "{0} in configuration is invalid: {1}.";
71
+ ErrorMessage.ConfigurationNotExists = "Configuration does not exist. {0}";
72
+ ErrorMessage.ResourceConfigurationNotExists = "{0} resource configuration does not exist.";
73
+ ErrorMessage.MissingResourceConfiguration = "Missing resource configuration with type: {0}, name: {1}.";
74
+ ErrorMessage.AuthenticationConfigurationNotExists = "Authentication configuration does not exist.";
75
+ // RuntimeNotSupported Error
76
+ ErrorMessage.BrowserRuntimeNotSupported = "{0} is not supported in browser.";
77
+ ErrorMessage.NodejsRuntimeNotSupported = "{0} is not supported in Node.";
78
+ // Internal Error
79
+ ErrorMessage.FailToAcquireTokenOnBehalfOfUser = "Failed to acquire access token on behalf of user: {0}";
80
+ // ChannelNotSupported Error
81
+ ErrorMessage.OnlyMSTeamsChannelSupported = "{0} is only supported in MS Teams Channel";
80
82
  /**
81
83
  * Error class with code and message thrown by the SDK.
82
84
  *
83
85
  * @beta
84
86
  */
85
- var ErrorWithCode = /** @class */ (function (_super) {
86
- __extends(ErrorWithCode, _super);
87
+ class ErrorWithCode extends Error {
87
88
  /**
88
89
  * Constructor of ErrorWithCode.
89
90
  *
@@ -92,21 +93,17 @@ var ErrorWithCode = /** @class */ (function (_super) {
92
93
  *
93
94
  * @beta
94
95
  */
95
- function ErrorWithCode(message, code) {
96
- var _newTarget = this.constructor;
97
- var _this = this;
96
+ constructor(message, code) {
98
97
  if (!code) {
99
- _this = _super.call(this, message) || this;
100
- return _this;
98
+ super(message);
99
+ return this;
101
100
  }
102
- _this = _super.call(this, message) || this;
103
- Object.setPrototypeOf(_this, ErrorWithCode.prototype);
104
- _this.name = _newTarget.name + "." + code;
105
- _this.code = code;
106
- return _this;
101
+ super(message);
102
+ Object.setPrototypeOf(this, ErrorWithCode.prototype);
103
+ this.name = `${new.target.name}.${code}`;
104
+ this.code = code;
107
105
  }
108
- return ErrorWithCode;
109
- }(Error));
106
+ }
110
107
 
111
108
  // Copyright (c) Microsoft Corporation.
112
109
  // Licensed under the MIT license.
@@ -174,8 +171,8 @@ function setLogLevel(level) {
174
171
  function getLogLevel() {
175
172
  return internalLogger.level;
176
173
  }
177
- var InternalLogger = /** @class */ (function () {
178
- function InternalLogger(name, logLevel) {
174
+ class InternalLogger {
175
+ constructor(name, logLevel) {
179
176
  this.level = undefined;
180
177
  this.defaultLogger = {
181
178
  verbose: console.debug,
@@ -186,31 +183,31 @@ var InternalLogger = /** @class */ (function () {
186
183
  this.name = name;
187
184
  this.level = logLevel;
188
185
  }
189
- InternalLogger.prototype.error = function (message) {
190
- this.log(LogLevel.Error, function (x) { return x.error; }, message);
191
- };
192
- InternalLogger.prototype.warn = function (message) {
193
- this.log(LogLevel.Warn, function (x) { return x.warn; }, message);
194
- };
195
- InternalLogger.prototype.info = function (message) {
196
- this.log(LogLevel.Info, function (x) { return x.info; }, message);
197
- };
198
- InternalLogger.prototype.verbose = function (message) {
199
- this.log(LogLevel.Verbose, function (x) { return x.verbose; }, message);
200
- };
201
- InternalLogger.prototype.log = function (logLevel, logFunction, message) {
186
+ error(message) {
187
+ this.log(LogLevel.Error, (x) => x.error, message);
188
+ }
189
+ warn(message) {
190
+ this.log(LogLevel.Warn, (x) => x.warn, message);
191
+ }
192
+ info(message) {
193
+ this.log(LogLevel.Info, (x) => x.info, message);
194
+ }
195
+ verbose(message) {
196
+ this.log(LogLevel.Verbose, (x) => x.verbose, message);
197
+ }
198
+ log(logLevel, logFunction, message) {
202
199
  if (message.trim() === "") {
203
200
  return;
204
201
  }
205
- var timestamp = new Date().toUTCString();
206
- var logHeader;
202
+ const timestamp = new Date().toUTCString();
203
+ let logHeader;
207
204
  if (this.name) {
208
- logHeader = "[" + timestamp + "] : @microsoft/teamsfx - " + this.name + " : " + LogLevel[logLevel] + " - ";
205
+ logHeader = `[${timestamp}] : @microsoft/teamsfx - ${this.name} : ${LogLevel[logLevel]} - `;
209
206
  }
210
207
  else {
211
- logHeader = "[" + timestamp + "] : @microsoft/teamsfx : " + LogLevel[logLevel] + " - ";
208
+ logHeader = `[${timestamp}] : @microsoft/teamsfx : ${LogLevel[logLevel]} - `;
212
209
  }
213
- var logMessage = "" + logHeader + message;
210
+ const logMessage = `${logHeader}${message}`;
214
211
  if (this.level !== undefined && this.level <= logLevel) {
215
212
  if (this.customLogger) {
216
213
  logFunction(this.customLogger)(logMessage);
@@ -222,15 +219,14 @@ var InternalLogger = /** @class */ (function () {
222
219
  logFunction(this.defaultLogger)(logMessage);
223
220
  }
224
221
  }
225
- };
226
- return InternalLogger;
227
- }());
222
+ }
223
+ }
228
224
  /**
229
225
  * Logger instance used internally
230
226
  *
231
227
  * @internal
232
228
  */
233
- var internalLogger = new InternalLogger();
229
+ const internalLogger = new InternalLogger();
234
230
  /**
235
231
  * Set custom logger. Use the output functions if it's set. Priority is higher than setLogFunction.
236
232
  *
@@ -283,14 +279,14 @@ function setLogFunction(logFunction) {
283
279
  */
284
280
  function parseJwt(token) {
285
281
  try {
286
- var tokenObj = jwt_decode(token);
282
+ const tokenObj = jwt_decode(token);
287
283
  if (!tokenObj || !tokenObj.exp) {
288
284
  throw new ErrorWithCode("Decoded token is null or exp claim does not exists.", ErrorCode.InternalError);
289
285
  }
290
286
  return tokenObj;
291
287
  }
292
288
  catch (err) {
293
- var errorMsg = "Parse jwt token failed in node env with error: " + err.message;
289
+ const errorMsg = "Parse jwt token failed in node env with error: " + err.message;
294
290
  internalLogger.error(errorMsg);
295
291
  throw new ErrorWithCode(errorMsg, ErrorCode.InternalError);
296
292
  }
@@ -300,12 +296,12 @@ function parseJwt(token) {
300
296
  */
301
297
  function getUserInfoFromSsoToken(ssoToken) {
302
298
  if (!ssoToken) {
303
- var errorMsg = "SSO token is undefined.";
299
+ const errorMsg = "SSO token is undefined.";
304
300
  internalLogger.error(errorMsg);
305
301
  throw new ErrorWithCode(errorMsg, ErrorCode.InvalidParameter);
306
302
  }
307
- var tokenObject = parseJwt(ssoToken);
308
- var userInfo = {
303
+ const tokenObject = parseJwt(ssoToken);
304
+ const userInfo = {
309
305
  displayName: tokenObject.name,
310
306
  objectId: tokenObject.oid,
311
307
  preferredUserName: "",
@@ -323,12 +319,12 @@ function getUserInfoFromSsoToken(ssoToken) {
323
319
  */
324
320
  function getTenantIdAndLoginHintFromSsoToken(ssoToken) {
325
321
  if (!ssoToken) {
326
- var errorMsg = "SSO token is undefined.";
322
+ const errorMsg = "SSO token is undefined.";
327
323
  internalLogger.error(errorMsg);
328
324
  throw new ErrorWithCode(errorMsg, ErrorCode.InvalidParameter);
329
325
  }
330
- var tokenObject = parseJwt(ssoToken);
331
- var userInfo = {
326
+ const tokenObject = parseJwt(ssoToken);
327
+ const userInfo = {
332
328
  tid: tokenObject.tid,
333
329
  loginHint: tokenObject.ver === "2.0"
334
330
  ? tokenObject.preferred_username
@@ -341,29 +337,29 @@ function getTenantIdAndLoginHintFromSsoToken(ssoToken) {
341
337
  */
342
338
  function parseAccessTokenFromAuthCodeTokenResponse(tokenResponse) {
343
339
  try {
344
- var tokenResponseObject = typeof tokenResponse == "string"
340
+ const tokenResponseObject = typeof tokenResponse == "string"
345
341
  ? JSON.parse(tokenResponse)
346
342
  : tokenResponse;
347
343
  if (!tokenResponseObject || !tokenResponseObject.accessToken) {
348
- var errorMsg = "Get empty access token from Auth Code token response.";
344
+ const errorMsg = "Get empty access token from Auth Code token response.";
349
345
  internalLogger.error(errorMsg);
350
346
  throw new Error(errorMsg);
351
347
  }
352
- var token = tokenResponseObject.accessToken;
353
- var tokenObject = parseJwt(token);
348
+ const token = tokenResponseObject.accessToken;
349
+ const tokenObject = parseJwt(token);
354
350
  if (tokenObject.ver !== "1.0" && tokenObject.ver !== "2.0") {
355
- var errorMsg = "SSO token is not valid with an unknown version: " + tokenObject.ver;
351
+ const errorMsg = "SSO token is not valid with an unknown version: " + tokenObject.ver;
356
352
  internalLogger.error(errorMsg);
357
353
  throw new Error(errorMsg);
358
354
  }
359
- var accessToken = {
355
+ const accessToken = {
360
356
  token: token,
361
357
  expiresOnTimestamp: tokenObject.exp * 1000,
362
358
  };
363
359
  return accessToken;
364
360
  }
365
361
  catch (error) {
366
- var errorMsg = "Parse access token failed from Auth Code token response in node env with error: " +
362
+ const errorMsg = "Parse access token failed from Auth Code token response in node env with error: " +
367
363
  error.message;
368
364
  internalLogger.error(errorMsg);
369
365
  throw new ErrorWithCode(errorMsg, ErrorCode.InternalError);
@@ -383,12 +379,8 @@ function parseAccessTokenFromAuthCodeTokenResponse(tokenResponse) {
383
379
  *
384
380
  * @internal
385
381
  */
386
- function formatString(str) {
387
- var replacements = [];
388
- for (var _i = 1; _i < arguments.length; _i++) {
389
- replacements[_i - 1] = arguments[_i];
390
- }
391
- var args = replacements;
382
+ function formatString(str, ...replacements) {
383
+ const args = replacements;
392
384
  return str.replace(/{(\d+)}/g, function (match, number) {
393
385
  return typeof args[number] != "undefined" ? args[number] : match;
394
386
  });
@@ -406,17 +398,17 @@ function validateScopesType(value) {
406
398
  return;
407
399
  }
408
400
  // string array
409
- if (Array.isArray(value) && value.length > 0 && value.every(function (item) { return typeof item === "string"; })) {
401
+ if (Array.isArray(value) && value.length > 0 && value.every((item) => typeof item === "string")) {
410
402
  return;
411
403
  }
412
- var errorMsg = "The type of scopes is not valid, it must be string or string array";
404
+ const errorMsg = "The type of scopes is not valid, it must be string or string array";
413
405
  internalLogger.error(errorMsg);
414
406
  throw new ErrorWithCode(errorMsg, ErrorCode.InvalidParameter);
415
407
  }
416
408
  /**
417
409
  * @internal
418
410
  */
419
- var isNode = typeof process !== "undefined" &&
411
+ const isNode = typeof process !== "undefined" &&
420
412
  !!process.version &&
421
413
  !!process.versions &&
422
414
  !!process.versions.node;
@@ -426,7 +418,7 @@ var isNode = typeof process !== "undefined" &&
426
418
  * Global configuration instance
427
419
  *
428
420
  */
429
- var config;
421
+ let config;
430
422
  /**
431
423
  * Initialize configuration from environment variables or configuration object and set the global instance
432
424
  *
@@ -441,7 +433,7 @@ function loadConfiguration(configuration) {
441
433
  // browser environment
442
434
  if (!isNode) {
443
435
  if (!configuration) {
444
- var errorMsg = "You are running the code in browser. Configuration must be passed in.";
436
+ const errorMsg = "You are running the code in browser. Configuration must be passed in.";
445
437
  internalLogger.error(errorMsg);
446
438
  throw new ErrorWithCode(errorMsg, ErrorCode.InvalidParameter);
447
439
  }
@@ -449,9 +441,9 @@ function loadConfiguration(configuration) {
449
441
  return;
450
442
  }
451
443
  // node environment
452
- var newAuthentication;
453
- var newResources = [];
454
- var defaultResourceName = "default";
444
+ let newAuthentication;
445
+ let newResources = [];
446
+ const defaultResourceName = "default";
455
447
  if (configuration === null || configuration === void 0 ? void 0 : configuration.authentication) {
456
448
  newAuthentication = configuration.authentication;
457
449
  }
@@ -509,15 +501,14 @@ function loadConfiguration(configuration) {
509
501
  *
510
502
  * @beta
511
503
  */
512
- function getResourceConfiguration(resourceType, resourceName) {
504
+ function getResourceConfiguration(resourceType, resourceName = "default") {
513
505
  var _a;
514
- if (resourceName === void 0) { resourceName = "default"; }
515
- internalLogger.info("Get resource configuration of " + ResourceType[resourceType] + " from " + resourceName);
516
- var result = (_a = config.resources) === null || _a === void 0 ? void 0 : _a.find(function (item) { return item.type === resourceType && item.name === resourceName; });
506
+ internalLogger.info(`Get resource configuration of ${ResourceType[resourceType]} from ${resourceName}`);
507
+ const result = (_a = config.resources) === null || _a === void 0 ? void 0 : _a.find((item) => item.type === resourceType && item.name === resourceName);
517
508
  if (result) {
518
509
  return result.properties;
519
510
  }
520
- var errorMsg = formatString(ErrorMessage.MissingResourceConfiguration, ResourceType[resourceType], resourceName);
511
+ const errorMsg = formatString(ErrorMessage.MissingResourceConfiguration, ResourceType[resourceType], resourceName);
521
512
  internalLogger.error(errorMsg);
522
513
  throw new ErrorWithCode(errorMsg, ErrorCode.InvalidConfiguration);
523
514
  }
@@ -535,7 +526,7 @@ function getAuthenticationConfiguration() {
535
526
  if (config) {
536
527
  return config.authentication;
537
528
  }
538
- var errorMsg = "Please call loadConfiguration() first before calling getAuthenticationConfiguration().";
529
+ const errorMsg = "Please call loadConfiguration() first before calling getAuthenticationConfiguration().";
539
530
  internalLogger.error(errorMsg);
540
531
  throw new ErrorWithCode(formatString(ErrorMessage.ConfigurationNotExists, errorMsg), ErrorCode.InvalidConfiguration);
541
532
  }
@@ -549,7 +540,7 @@ function getAuthenticationConfiguration() {
549
540
  *
550
541
  * @beta
551
542
  */
552
- var M365TenantCredential = /** @class */ (function () {
543
+ class M365TenantCredential {
553
544
  /**
554
545
  * Constructor of M365TenantCredential.
555
546
  *
@@ -557,7 +548,7 @@ var M365TenantCredential = /** @class */ (function () {
557
548
  * Only works in in server side.
558
549
  * @beta
559
550
  */
560
- function M365TenantCredential() {
551
+ constructor() {
561
552
  throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "M365TenantCredential"), ErrorCode.RuntimeNotSupported);
562
553
  }
563
554
  /**
@@ -567,15 +558,12 @@ var M365TenantCredential = /** @class */ (function () {
567
558
  * Only works in in server side.
568
559
  * @beta
569
560
  */
570
- M365TenantCredential.prototype.getToken = function (scopes, options) {
571
- return __awaiter(this, void 0, void 0, function () {
572
- return __generator(this, function (_a) {
573
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "M365TenantCredential"), ErrorCode.RuntimeNotSupported);
574
- });
561
+ getToken(scopes, options) {
562
+ return __awaiter(this, void 0, void 0, function* () {
563
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "M365TenantCredential"), ErrorCode.RuntimeNotSupported);
575
564
  });
576
- };
577
- return M365TenantCredential;
578
- }());
565
+ }
566
+ }
579
567
 
580
568
  // Copyright (c) Microsoft Corporation.
581
569
  /**
@@ -586,7 +574,7 @@ var M365TenantCredential = /** @class */ (function () {
586
574
  *
587
575
  * @beta
588
576
  */
589
- var OnBehalfOfUserCredential = /** @class */ (function () {
577
+ class OnBehalfOfUserCredential {
590
578
  /**
591
579
  * Constructor of OnBehalfOfUserCredential
592
580
  *
@@ -594,7 +582,7 @@ var OnBehalfOfUserCredential = /** @class */ (function () {
594
582
  * Can Only works in in server side.
595
583
  * @beta
596
584
  */
597
- function OnBehalfOfUserCredential(ssoToken) {
585
+ constructor(ssoToken) {
598
586
  throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "OnBehalfOfUserCredential"), ErrorCode.RuntimeNotSupported);
599
587
  }
600
588
  /**
@@ -603,30 +591,26 @@ var OnBehalfOfUserCredential = /** @class */ (function () {
603
591
  * Can only be used in server side.
604
592
  * @beta
605
593
  */
606
- OnBehalfOfUserCredential.prototype.getToken = function (scopes, options) {
607
- return __awaiter(this, void 0, void 0, function () {
608
- return __generator(this, function (_a) {
609
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "OnBehalfOfUserCredential"), ErrorCode.RuntimeNotSupported);
610
- });
594
+ getToken(scopes, options) {
595
+ return __awaiter(this, void 0, void 0, function* () {
596
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "OnBehalfOfUserCredential"), ErrorCode.RuntimeNotSupported);
611
597
  });
612
- };
598
+ }
613
599
  /**
614
600
  * Get basic user info from SSO token.
615
601
  * @remarks
616
602
  * Can only be used in server side.
617
603
  * @beta
618
604
  */
619
- OnBehalfOfUserCredential.prototype.getUserInfo = function () {
605
+ getUserInfo() {
620
606
  throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "OnBehalfOfUserCredential"), ErrorCode.RuntimeNotSupported);
621
- };
622
- return OnBehalfOfUserCredential;
623
- }());
607
+ }
608
+ }
624
609
 
625
610
  // Copyright (c) Microsoft Corporation.
626
- var tokenRefreshTimeSpanInMillisecond = 5 * 60 * 1000;
627
- var initializeTeamsSdkTimeoutInMillisecond = 5000;
628
- var loginPageWidth = 600;
629
- var loginPageHeight = 535;
611
+ const tokenRefreshTimeSpanInMillisecond = 5 * 60 * 1000;
612
+ const loginPageWidth = 600;
613
+ const loginPageHeight = 535;
630
614
  /**
631
615
  * Represent Teams current user's identity, and it is used within Teams tab application.
632
616
  *
@@ -635,7 +619,7 @@ var loginPageHeight = 535;
635
619
  *
636
620
  * @beta
637
621
  */
638
- var TeamsUserCredential = /** @class */ (function () {
622
+ class TeamsUserCredential {
639
623
  /**
640
624
  * Constructor of TeamsUserCredential.
641
625
  * Developer need to call loadConfiguration(config) before using this class.
@@ -657,7 +641,7 @@ var TeamsUserCredential = /** @class */ (function () {
657
641
  *
658
642
  * @beta
659
643
  */
660
- function TeamsUserCredential() {
644
+ constructor() {
661
645
  internalLogger.info("Create teams user credential");
662
646
  this.config = this.loadAndValidateConfig();
663
647
  this.ssoToken = null;
@@ -685,58 +669,61 @@ var TeamsUserCredential = /** @class */ (function () {
685
669
  *
686
670
  * @beta
687
671
  */
688
- TeamsUserCredential.prototype.login = function (scopes) {
689
- return __awaiter(this, void 0, void 0, function () {
690
- var scopesStr;
691
- var _this = this;
692
- return __generator(this, function (_a) {
693
- switch (_a.label) {
694
- case 0:
695
- validateScopesType(scopes);
696
- scopesStr = typeof scopes === "string" ? scopes : scopes.join(" ");
697
- internalLogger.info("Popup login page to get user's access token with scopes: " + scopesStr);
698
- if (!!this.initialized) return [3 /*break*/, 2];
699
- return [4 /*yield*/, this.init()];
700
- case 1:
701
- _a.sent();
702
- _a.label = 2;
703
- case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
704
- microsoftTeams.initialize(function () {
705
- microsoftTeams.authentication.authenticate({
706
- url: _this.config.initiateLoginEndpoint + "?clientId=" + _this.config.clientId + "&scope=" + encodeURI(scopesStr) + "&loginHint=" + _this.loginHint,
707
- width: loginPageWidth,
708
- height: loginPageHeight,
709
- successCallback: function (result) { return __awaiter(_this, void 0, void 0, function () {
710
- var errorMsg, accessToken;
711
- return __generator(this, function (_a) {
712
- if (!result) {
713
- errorMsg = "Get empty authentication result from MSAL";
714
- internalLogger.error(errorMsg);
715
- reject(new ErrorWithCode(errorMsg, ErrorCode.InternalError));
716
- return [2 /*return*/];
717
- }
718
- try {
719
- accessToken = parseAccessTokenFromAuthCodeTokenResponse(result);
720
- resolve(accessToken);
721
- }
722
- catch (error) {
723
- reject(error);
724
- }
725
- return [2 /*return*/];
726
- });
727
- }); },
728
- failureCallback: function (reason) {
729
- var errorMsg = "Consent failed for the scope " + scopesStr + " with error: " + reason;
730
- internalLogger.error(errorMsg);
731
- reject(new ErrorWithCode(errorMsg, ErrorCode.ConsentFailed));
732
- },
733
- });
734
- });
735
- })];
736
- }
672
+ login(scopes) {
673
+ return __awaiter(this, void 0, void 0, function* () {
674
+ validateScopesType(scopes);
675
+ const scopesStr = typeof scopes === "string" ? scopes : scopes.join(" ");
676
+ internalLogger.info(`Popup login page to get user's access token with scopes: ${scopesStr}`);
677
+ if (!this.initialized) {
678
+ yield this.init();
679
+ }
680
+ return new Promise((resolve, reject) => {
681
+ microsoftTeams.initialize(() => {
682
+ microsoftTeams.authentication.authenticate({
683
+ url: `${this.config.initiateLoginEndpoint}?clientId=${this.config.clientId}&scope=${encodeURI(scopesStr)}&loginHint=${this.loginHint}`,
684
+ width: loginPageWidth,
685
+ height: loginPageHeight,
686
+ successCallback: (result) => __awaiter(this, void 0, void 0, function* () {
687
+ if (!result) {
688
+ const errorMsg = "Get empty authentication result from MSAL";
689
+ internalLogger.error(errorMsg);
690
+ reject(new ErrorWithCode(errorMsg, ErrorCode.InternalError));
691
+ return;
692
+ }
693
+ let resultJson = {};
694
+ try {
695
+ resultJson = JSON.parse(result);
696
+ }
697
+ catch (error) {
698
+ // If can not parse result as Json, will throw error.
699
+ const failedToParseResult = "Failed to parse response to Json.";
700
+ internalLogger.error(failedToParseResult);
701
+ reject(new ErrorWithCode(failedToParseResult, ErrorCode.InvalidResponse));
702
+ }
703
+ // If code exists in result, user may using previous auth-start and auth-end page.
704
+ if (resultJson.code) {
705
+ const helpLink = "https://aka.ms/teamsfx-auth-code-flow";
706
+ const usingPreviousAuthPage = "Found auth code in response. Auth code is not support for current version of SDK. " +
707
+ `Please refer to the help link for how to fix the issue: ${helpLink}.`;
708
+ internalLogger.error(usingPreviousAuthPage);
709
+ reject(new ErrorWithCode(usingPreviousAuthPage, ErrorCode.InvalidResponse));
710
+ }
711
+ // If sessionStorage exists in result, set the values in current session storage.
712
+ if (resultJson.sessionStorage) {
713
+ this.setSessionStorage(resultJson.sessionStorage);
714
+ }
715
+ resolve();
716
+ }),
717
+ failureCallback: (reason) => {
718
+ const errorMsg = `Consent failed for the scope ${scopesStr} with error: ${reason}`;
719
+ internalLogger.error(errorMsg);
720
+ reject(new ErrorWithCode(errorMsg, ErrorCode.ConsentFailed));
721
+ },
722
+ });
723
+ });
737
724
  });
738
725
  });
739
- };
726
+ }
740
727
  /**
741
728
  * Get access token from credential.
742
729
  *
@@ -771,80 +758,62 @@ var TeamsUserCredential = /** @class */ (function () {
771
758
  *
772
759
  * @beta
773
760
  */
774
- TeamsUserCredential.prototype.getToken = function (scopes, options) {
775
- return __awaiter(this, void 0, void 0, function () {
776
- var ssoToken, scopeStr, tokenResponse, scopesArray, domain, account, scopesRequestForAcquireTokenSilent, error_1, acquireTokenSilentFailedMessage, scopesRequestForSsoSilent, error_2, ssoSilentFailedMessage, errorMsg, accessToken;
777
- return __generator(this, function (_a) {
778
- switch (_a.label) {
779
- case 0:
780
- validateScopesType(scopes);
781
- return [4 /*yield*/, this.getSSOToken()];
782
- case 1:
783
- ssoToken = _a.sent();
784
- scopeStr = typeof scopes === "string" ? scopes : scopes.join(" ");
785
- if (!(scopeStr === "")) return [3 /*break*/, 2];
786
- internalLogger.info("Get SSO token");
787
- return [2 /*return*/, ssoToken];
788
- case 2:
789
- internalLogger.info("Get access token with scopes: " + scopeStr);
790
- if (!!this.initialized) return [3 /*break*/, 4];
791
- return [4 /*yield*/, this.init()];
792
- case 3:
793
- _a.sent();
794
- _a.label = 4;
795
- case 4:
796
- tokenResponse = void 0;
797
- scopesArray = typeof scopes === "string" ? scopes.split(" ") : scopes;
798
- domain = window.location.origin;
799
- _a.label = 5;
800
- case 5:
801
- _a.trys.push([5, 7, , 8]);
802
- account = this.msalInstance.getAccountByUsername(this.loginHint);
803
- scopesRequestForAcquireTokenSilent = {
804
- scopes: scopesArray,
805
- account: account !== null && account !== void 0 ? account : undefined,
806
- redirectUri: domain + "/blank-auth-end.html",
807
- };
808
- return [4 /*yield*/, this.msalInstance.acquireTokenSilent(scopesRequestForAcquireTokenSilent)];
809
- case 6:
810
- tokenResponse = _a.sent();
811
- return [3 /*break*/, 8];
812
- case 7:
813
- error_1 = _a.sent();
814
- acquireTokenSilentFailedMessage = "Failed to call acquireTokenSilent. Reason: " + (error_1 === null || error_1 === void 0 ? void 0 : error_1.message) + ". ";
815
- internalLogger.verbose(acquireTokenSilentFailedMessage);
816
- return [3 /*break*/, 8];
817
- case 8:
818
- if (!!tokenResponse) return [3 /*break*/, 12];
819
- _a.label = 9;
820
- case 9:
821
- _a.trys.push([9, 11, , 12]);
822
- scopesRequestForSsoSilent = {
761
+ getToken(scopes, options) {
762
+ return __awaiter(this, void 0, void 0, function* () {
763
+ validateScopesType(scopes);
764
+ const ssoToken = yield this.getSSOToken();
765
+ const scopeStr = typeof scopes === "string" ? scopes : scopes.join(" ");
766
+ if (scopeStr === "") {
767
+ internalLogger.info("Get SSO token");
768
+ return ssoToken;
769
+ }
770
+ else {
771
+ internalLogger.info("Get access token with scopes: " + scopeStr);
772
+ if (!this.initialized) {
773
+ yield this.init();
774
+ }
775
+ let tokenResponse;
776
+ const scopesArray = typeof scopes === "string" ? scopes.split(" ") : scopes;
777
+ const domain = window.location.origin;
778
+ // First try to get Access Token from cache.
779
+ try {
780
+ const account = this.msalInstance.getAccountByUsername(this.loginHint);
781
+ const scopesRequestForAcquireTokenSilent = {
782
+ scopes: scopesArray,
783
+ account: account !== null && account !== void 0 ? account : undefined,
784
+ redirectUri: `${domain}/blank-auth-end.html`,
785
+ };
786
+ tokenResponse = yield this.msalInstance.acquireTokenSilent(scopesRequestForAcquireTokenSilent);
787
+ }
788
+ catch (error) {
789
+ const acquireTokenSilentFailedMessage = `Failed to call acquireTokenSilent. Reason: ${error === null || error === void 0 ? void 0 : error.message}. `;
790
+ internalLogger.verbose(acquireTokenSilentFailedMessage);
791
+ }
792
+ if (!tokenResponse) {
793
+ // If fail to get Access Token from cache, try to get Access token by silent login.
794
+ try {
795
+ const scopesRequestForSsoSilent = {
823
796
  scopes: scopesArray,
824
797
  loginHint: this.loginHint,
825
- redirectUri: domain + "/blank-auth-end.html",
798
+ redirectUri: `${domain}/blank-auth-end.html`,
826
799
  };
827
- return [4 /*yield*/, this.msalInstance.ssoSilent(scopesRequestForSsoSilent)];
828
- case 10:
829
- tokenResponse = _a.sent();
830
- return [3 /*break*/, 12];
831
- case 11:
832
- error_2 = _a.sent();
833
- ssoSilentFailedMessage = "Failed to call ssoSilent. Reason: " + (error_2 === null || error_2 === void 0 ? void 0 : error_2.message) + ". ";
800
+ tokenResponse = yield this.msalInstance.ssoSilent(scopesRequestForSsoSilent);
801
+ }
802
+ catch (error) {
803
+ const ssoSilentFailedMessage = `Failed to call ssoSilent. Reason: ${error === null || error === void 0 ? void 0 : error.message}. `;
834
804
  internalLogger.verbose(ssoSilentFailedMessage);
835
- return [3 /*break*/, 12];
836
- case 12:
837
- if (!tokenResponse) {
838
- errorMsg = "Failed to get access token cache silently, please login first: you need login first before get access token.";
839
- internalLogger.error(errorMsg);
840
- throw new ErrorWithCode(errorMsg, ErrorCode.UiRequiredError);
841
- }
842
- accessToken = parseAccessTokenFromAuthCodeTokenResponse(tokenResponse);
843
- return [2 /*return*/, accessToken];
805
+ }
844
806
  }
845
- });
807
+ if (!tokenResponse) {
808
+ const errorMsg = `Failed to get access token cache silently, please login first: you need login first before get access token.`;
809
+ internalLogger.error(errorMsg);
810
+ throw new ErrorWithCode(errorMsg, ErrorCode.UiRequiredError);
811
+ }
812
+ const accessToken = parseAccessTokenFromAuthCodeTokenResponse(tokenResponse);
813
+ return accessToken;
814
+ }
846
815
  });
847
- };
816
+ }
848
817
  /**
849
818
  * Get basic user info from SSO token
850
819
  *
@@ -861,113 +830,93 @@ var TeamsUserCredential = /** @class */ (function () {
861
830
  *
862
831
  * @beta
863
832
  */
864
- TeamsUserCredential.prototype.getUserInfo = function () {
865
- return __awaiter(this, void 0, void 0, function () {
866
- var ssoToken;
867
- return __generator(this, function (_a) {
868
- switch (_a.label) {
869
- case 0:
870
- internalLogger.info("Get basic user info from SSO token");
871
- return [4 /*yield*/, this.getSSOToken()];
872
- case 1:
873
- ssoToken = _a.sent();
874
- return [2 /*return*/, getUserInfoFromSsoToken(ssoToken.token)];
875
- }
876
- });
833
+ getUserInfo() {
834
+ return __awaiter(this, void 0, void 0, function* () {
835
+ internalLogger.info("Get basic user info from SSO token");
836
+ const ssoToken = yield this.getSSOToken();
837
+ return getUserInfoFromSsoToken(ssoToken.token);
877
838
  });
878
- };
879
- TeamsUserCredential.prototype.init = function () {
880
- return __awaiter(this, void 0, void 0, function () {
881
- var ssoToken, info, msalConfig;
882
- return __generator(this, function (_a) {
883
- switch (_a.label) {
884
- case 0: return [4 /*yield*/, this.getSSOToken()];
885
- case 1:
886
- ssoToken = _a.sent();
887
- info = getTenantIdAndLoginHintFromSsoToken(ssoToken.token);
888
- this.loginHint = info.loginHint;
889
- this.tid = info.tid;
890
- msalConfig = {
891
- auth: {
892
- clientId: this.config.clientId,
893
- authority: "https://login.microsoftonline.com/" + this.tid,
894
- },
895
- cache: {
896
- cacheLocation: "sessionStorage",
897
- },
898
- };
899
- this.msalInstance = new PublicClientApplication(msalConfig);
900
- this.initialized = true;
901
- return [2 /*return*/];
902
- }
903
- });
839
+ }
840
+ init() {
841
+ return __awaiter(this, void 0, void 0, function* () {
842
+ const ssoToken = yield this.getSSOToken();
843
+ const info = getTenantIdAndLoginHintFromSsoToken(ssoToken.token);
844
+ this.loginHint = info.loginHint;
845
+ this.tid = info.tid;
846
+ const msalConfig = {
847
+ auth: {
848
+ clientId: this.config.clientId,
849
+ authority: `https://login.microsoftonline.com/${this.tid}`,
850
+ },
851
+ cache: {
852
+ cacheLocation: "sessionStorage",
853
+ },
854
+ };
855
+ this.msalInstance = new PublicClientApplication(msalConfig);
856
+ this.initialized = true;
904
857
  });
905
- };
858
+ }
906
859
  /**
907
860
  * Get SSO token using teams SDK
908
861
  * 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
909
862
  * @returns SSO token
910
863
  */
911
- TeamsUserCredential.prototype.getSSOToken = function () {
912
- var _this = this;
913
- return new Promise(function (resolve, reject) {
914
- if (_this.ssoToken) {
915
- if (_this.ssoToken.expiresOnTimestamp - Date.now() > tokenRefreshTimeSpanInMillisecond) {
864
+ getSSOToken() {
865
+ return new Promise((resolve, reject) => {
866
+ if (this.ssoToken) {
867
+ if (this.ssoToken.expiresOnTimestamp - Date.now() > tokenRefreshTimeSpanInMillisecond) {
916
868
  internalLogger.verbose("Get SSO token from memory cache");
917
- resolve(_this.ssoToken);
869
+ resolve(this.ssoToken);
918
870
  return;
919
871
  }
920
872
  }
921
- var initialized = false;
922
- microsoftTeams.initialize(function () {
923
- initialized = true;
924
- microsoftTeams.authentication.getAuthToken({
925
- successCallback: function (token) {
926
- if (!token) {
927
- var errorMsg = "Get empty SSO token from Teams";
928
- internalLogger.error(errorMsg);
929
- reject(new ErrorWithCode(errorMsg, ErrorCode.InternalError));
930
- return;
931
- }
932
- var tokenObject = parseJwt(token);
933
- if (tokenObject.ver !== "1.0" && tokenObject.ver !== "2.0") {
934
- var errorMsg = "SSO token is not valid with an unknown version: " + tokenObject.ver;
873
+ if (this.checkInTeams()) {
874
+ microsoftTeams.initialize(() => {
875
+ microsoftTeams.authentication.getAuthToken({
876
+ successCallback: (token) => {
877
+ if (!token) {
878
+ const errorMsg = "Get empty SSO token from Teams";
879
+ internalLogger.error(errorMsg);
880
+ reject(new ErrorWithCode(errorMsg, ErrorCode.InternalError));
881
+ return;
882
+ }
883
+ const tokenObject = parseJwt(token);
884
+ if (tokenObject.ver !== "1.0" && tokenObject.ver !== "2.0") {
885
+ const errorMsg = "SSO token is not valid with an unknown version: " + tokenObject.ver;
886
+ internalLogger.error(errorMsg);
887
+ reject(new ErrorWithCode(errorMsg, ErrorCode.InternalError));
888
+ return;
889
+ }
890
+ const ssoToken = {
891
+ token,
892
+ expiresOnTimestamp: tokenObject.exp * 1000,
893
+ };
894
+ this.ssoToken = ssoToken;
895
+ resolve(ssoToken);
896
+ },
897
+ failureCallback: (errMessage) => {
898
+ const errorMsg = "Get SSO token failed with error: " + errMessage;
935
899
  internalLogger.error(errorMsg);
936
900
  reject(new ErrorWithCode(errorMsg, ErrorCode.InternalError));
937
- return;
938
- }
939
- var ssoToken = {
940
- token: token,
941
- expiresOnTimestamp: tokenObject.exp * 1000,
942
- };
943
- _this.ssoToken = ssoToken;
944
- resolve(ssoToken);
945
- },
946
- failureCallback: function (errMessage) {
947
- var errorMsg = "Get SSO token failed with error: " + errMessage;
948
- internalLogger.error(errorMsg);
949
- reject(new ErrorWithCode(errorMsg, ErrorCode.InternalError));
950
- },
951
- resources: [],
901
+ },
902
+ resources: [],
903
+ });
952
904
  });
953
- });
954
- // If the code not running in Teams, the initialize callback function would never trigger
955
- setTimeout(function () {
956
- if (!initialized) {
957
- var errorMsg = "Initialize teams sdk timeout, maybe the code is not running inside Teams";
958
- internalLogger.error(errorMsg);
959
- reject(new ErrorWithCode(errorMsg, ErrorCode.InternalError));
960
- }
961
- }, initializeTeamsSdkTimeoutInMillisecond);
905
+ }
906
+ else {
907
+ const errorMsg = "Initialize teams sdk failed due to not running inside Teams";
908
+ internalLogger.error(errorMsg);
909
+ reject(new ErrorWithCode(errorMsg, ErrorCode.InternalError));
910
+ }
962
911
  });
963
- };
912
+ }
964
913
  /**
965
914
  * Load and validate authentication configuration
966
915
  * @returns Authentication configuration
967
916
  */
968
- TeamsUserCredential.prototype.loadAndValidateConfig = function () {
917
+ loadAndValidateConfig() {
969
918
  internalLogger.verbose("Validate authentication configuration");
970
- var config = getAuthenticationConfiguration();
919
+ const config = getAuthenticationConfiguration();
971
920
  if (!config) {
972
921
  internalLogger.error(ErrorMessage.AuthenticationConfigurationNotExists);
973
922
  throw new ErrorWithCode(ErrorMessage.AuthenticationConfigurationNotExists, ErrorCode.InvalidConfiguration);
@@ -975,28 +924,52 @@ var TeamsUserCredential = /** @class */ (function () {
975
924
  if (config.initiateLoginEndpoint && config.clientId) {
976
925
  return config;
977
926
  }
978
- var missingValues = [];
927
+ const missingValues = [];
979
928
  if (!config.initiateLoginEndpoint) {
980
929
  missingValues.push("initiateLoginEndpoint");
981
930
  }
982
931
  if (!config.clientId) {
983
932
  missingValues.push("clientId");
984
933
  }
985
- var errorMsg = formatString(ErrorMessage.InvalidConfiguration, missingValues.join(", "), "undefined");
934
+ const errorMsg = formatString(ErrorMessage.InvalidConfiguration, missingValues.join(", "), "undefined");
986
935
  internalLogger.error(errorMsg);
987
936
  throw new ErrorWithCode(errorMsg, ErrorCode.InvalidConfiguration);
988
- };
989
- return TeamsUserCredential;
990
- }());
937
+ }
938
+ setSessionStorage(sessionStorageValues) {
939
+ try {
940
+ const sessionStorageKeys = Object.keys(sessionStorageValues);
941
+ sessionStorageKeys.forEach((key) => {
942
+ sessionStorage.setItem(key, sessionStorageValues[key]);
943
+ });
944
+ }
945
+ catch (error) {
946
+ // Values in result.sessionStorage can not be set into session storage.
947
+ // Throw error since this may block user.
948
+ const errorMessage = `Failed to set values in session storage. Error: ${error.message}`;
949
+ internalLogger.error(errorMessage);
950
+ throw new ErrorWithCode(errorMessage, ErrorCode.InternalError);
951
+ }
952
+ }
953
+ // Come from here: https://github.com/wictorwilen/msteams-react-base-component/blob/master/src/useTeams.ts
954
+ checkInTeams() {
955
+ if ((window.parent === window.self && window.nativeInterface) ||
956
+ window.navigator.userAgent.includes("Teams/") ||
957
+ window.name === "embedded-page-container" ||
958
+ window.name === "extension-tab-frame") {
959
+ return true;
960
+ }
961
+ return false;
962
+ }
963
+ }
991
964
 
992
965
  // Copyright (c) Microsoft Corporation.
993
- var defaultScope = "https://graph.microsoft.com/.default";
966
+ const defaultScope = "https://graph.microsoft.com/.default";
994
967
  /**
995
968
  * Microsoft Graph auth provider for Teams Framework
996
969
  *
997
970
  * @beta
998
971
  */
999
- var MsGraphAuthProvider = /** @class */ (function () {
972
+ class MsGraphAuthProvider {
1000
973
  /**
1001
974
  * Constructor of MsGraphAuthProvider.
1002
975
  *
@@ -1009,9 +982,9 @@ var MsGraphAuthProvider = /** @class */ (function () {
1009
982
  *
1010
983
  * @beta
1011
984
  */
1012
- function MsGraphAuthProvider(credential, scopes) {
985
+ constructor(credential, scopes) {
1013
986
  this.credential = credential;
1014
- var scopesStr = defaultScope;
987
+ let scopesStr = defaultScope;
1015
988
  if (scopes) {
1016
989
  validateScopesType(scopes);
1017
990
  scopesStr = typeof scopes === "string" ? scopes : scopes.join(" ");
@@ -1019,7 +992,7 @@ var MsGraphAuthProvider = /** @class */ (function () {
1019
992
  scopesStr = defaultScope;
1020
993
  }
1021
994
  }
1022
- internalLogger.info("Create Microsoft Graph Authentication Provider with scopes: '" + scopesStr + "'");
995
+ internalLogger.info(`Create Microsoft Graph Authentication Provider with scopes: '${scopesStr}'`);
1023
996
  this.scopes = scopesStr;
1024
997
  }
1025
998
  /**
@@ -1034,32 +1007,23 @@ var MsGraphAuthProvider = /** @class */ (function () {
1034
1007
  * @returns Access token from the credential.
1035
1008
  *
1036
1009
  */
1037
- MsGraphAuthProvider.prototype.getAccessToken = function () {
1038
- return __awaiter(this, void 0, void 0, function () {
1039
- var accessToken;
1040
- return __generator(this, function (_a) {
1041
- switch (_a.label) {
1042
- case 0:
1043
- internalLogger.info("Get Graph Access token with scopes: '" + this.scopes + "'");
1044
- return [4 /*yield*/, this.credential.getToken(this.scopes)];
1045
- case 1:
1046
- accessToken = _a.sent();
1047
- return [2 /*return*/, new Promise(function (resolve, reject) {
1048
- if (accessToken) {
1049
- resolve(accessToken.token);
1050
- }
1051
- else {
1052
- var errorMsg = "Graph access token is undefined or empty";
1053
- internalLogger.error(errorMsg);
1054
- reject(new ErrorWithCode(errorMsg, ErrorCode.InternalError));
1055
- }
1056
- })];
1010
+ getAccessToken() {
1011
+ return __awaiter(this, void 0, void 0, function* () {
1012
+ internalLogger.info(`Get Graph Access token with scopes: '${this.scopes}'`);
1013
+ const accessToken = yield this.credential.getToken(this.scopes);
1014
+ return new Promise((resolve, reject) => {
1015
+ if (accessToken) {
1016
+ resolve(accessToken.token);
1017
+ }
1018
+ else {
1019
+ const errorMsg = "Graph access token is undefined or empty";
1020
+ internalLogger.error(errorMsg);
1021
+ reject(new ErrorWithCode(errorMsg, ErrorCode.InternalError));
1057
1022
  }
1058
1023
  });
1059
1024
  });
1060
- };
1061
- return MsGraphAuthProvider;
1062
- }());
1025
+ }
1026
+ }
1063
1027
 
1064
1028
  // Copyright (c) Microsoft Corporation.
1065
1029
  /**
@@ -1115,9 +1079,9 @@ var MsGraphAuthProvider = /** @class */ (function () {
1115
1079
  */
1116
1080
  function createMicrosoftGraphClient(credential, scopes) {
1117
1081
  internalLogger.info("Create Microsoft Graph Client");
1118
- var authProvider = new MsGraphAuthProvider(credential, scopes);
1119
- var graphClient = Client.initWithMiddleware({
1120
- authProvider: authProvider,
1082
+ const authProvider = new MsGraphAuthProvider(credential, scopes);
1083
+ const graphClient = Client.initWithMiddleware({
1084
+ authProvider,
1121
1085
  });
1122
1086
  return graphClient;
1123
1087
  }
@@ -1128,8 +1092,8 @@ function createMicrosoftGraphClient(credential, scopes) {
1128
1092
  * Only works in in server side.
1129
1093
  * @beta
1130
1094
  */
1131
- var DefaultTediousConnectionConfiguration = /** @class */ (function () {
1132
- function DefaultTediousConnectionConfiguration() {
1095
+ class DefaultTediousConnectionConfiguration {
1096
+ constructor() {
1133
1097
  throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "DefaultTediousConnectionConfiguration"), ErrorCode.RuntimeNotSupported);
1134
1098
  }
1135
1099
  /**
@@ -1138,15 +1102,12 @@ var DefaultTediousConnectionConfiguration = /** @class */ (function () {
1138
1102
  * Only works in in server side.
1139
1103
  * @beta
1140
1104
  */
1141
- DefaultTediousConnectionConfiguration.prototype.getConfig = function () {
1142
- return __awaiter(this, void 0, void 0, function () {
1143
- return __generator(this, function (_a) {
1144
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "DefaultTediousConnectionConfiguration"), ErrorCode.RuntimeNotSupported);
1145
- });
1105
+ getConfig(databaseName) {
1106
+ return __awaiter(this, void 0, void 0, function* () {
1107
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "DefaultTediousConnectionConfiguration"), ErrorCode.RuntimeNotSupported);
1146
1108
  });
1147
- };
1148
- return DefaultTediousConnectionConfiguration;
1149
- }());
1109
+ }
1110
+ }
1150
1111
 
1151
1112
  // Copyright (c) Microsoft Corporation.
1152
1113
  /**
@@ -1200,7 +1161,7 @@ var DefaultTediousConnectionConfiguration = /** @class */ (function () {
1200
1161
  *
1201
1162
  * @beta
1202
1163
  */
1203
- var TeamsBotSsoPrompt = /** @class */ (function () {
1164
+ class TeamsBotSsoPrompt {
1204
1165
  /**
1205
1166
  * Constructor of TeamsBotSsoPrompt.
1206
1167
  *
@@ -1212,7 +1173,7 @@ var TeamsBotSsoPrompt = /** @class */ (function () {
1212
1173
  *
1213
1174
  * @beta
1214
1175
  */
1215
- function TeamsBotSsoPrompt(dialogId, settings) {
1176
+ constructor(dialogId, settings) {
1216
1177
  this.settings = settings;
1217
1178
  throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotSsoPrompt"), ErrorCode.RuntimeNotSupported);
1218
1179
  }
@@ -1232,13 +1193,11 @@ var TeamsBotSsoPrompt = /** @class */ (function () {
1232
1193
  *
1233
1194
  * @beta
1234
1195
  */
1235
- TeamsBotSsoPrompt.prototype.beginDialog = function (dc) {
1236
- return __awaiter(this, void 0, void 0, function () {
1237
- return __generator(this, function (_a) {
1238
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotSsoPrompt"), ErrorCode.RuntimeNotSupported);
1239
- });
1196
+ beginDialog(dc) {
1197
+ return __awaiter(this, void 0, void 0, function* () {
1198
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotSsoPrompt"), ErrorCode.RuntimeNotSupported);
1240
1199
  });
1241
- };
1200
+ }
1242
1201
  /**
1243
1202
  * Called when a prompt dialog is the active dialog and the user replied with a new activity.
1244
1203
  *
@@ -1257,15 +1216,12 @@ var TeamsBotSsoPrompt = /** @class */ (function () {
1257
1216
  *
1258
1217
  * @beta
1259
1218
  */
1260
- TeamsBotSsoPrompt.prototype.continueDialog = function (dc) {
1261
- return __awaiter(this, void 0, void 0, function () {
1262
- return __generator(this, function (_a) {
1263
- throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotSsoPrompt"), ErrorCode.RuntimeNotSupported);
1264
- });
1219
+ continueDialog(dc) {
1220
+ return __awaiter(this, void 0, void 0, function* () {
1221
+ throw new ErrorWithCode(formatString(ErrorMessage.BrowserRuntimeNotSupported, "TeamsBotSsoPrompt"), ErrorCode.RuntimeNotSupported);
1265
1222
  });
1266
- };
1267
- return TeamsBotSsoPrompt;
1268
- }());
1223
+ }
1224
+ }
1269
1225
 
1270
1226
  export { DefaultTediousConnectionConfiguration, ErrorCode, ErrorWithCode, LogLevel, M365TenantCredential, MsGraphAuthProvider, OnBehalfOfUserCredential, ResourceType, TeamsBotSsoPrompt, TeamsUserCredential, createMicrosoftGraphClient, getAuthenticationConfiguration, getLogLevel, getResourceConfiguration, loadConfiguration, setLogFunction, setLogLevel, setLogger };
1271
1227
  //# sourceMappingURL=index.esm5.js.map