@cosmotech/core 1.18.0-dev.1 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -41309,13 +41309,13 @@ var PathUtils = {
41309
41309
  // Notes : local storage works on Chromium but not on Firefox if "Delete
41310
41310
  // cookies and site data when Firefox is closed" is selected (for more
41311
41311
  // details, see https://bugzilla.mozilla.org/show_bug.cgi?id=1453699)
41312
- function writeToStorage$2(key, value) {
41312
+ function writeToStorage$1(key, value) {
41313
41313
  localStorage.setItem(key, value);
41314
41314
  }
41315
- function readFromStorage$3(key) {
41315
+ function readFromStorage$2(key) {
41316
41316
  return localStorage.getItem(key);
41317
41317
  }
41318
- function clearFromStorage$2(key) {
41318
+ function clearFromStorage$1(key) {
41319
41319
  localStorage.removeItem(key);
41320
41320
  }
41321
41321
 
@@ -41351,7 +41351,7 @@ function setProvider(providerName) {
41351
41351
  currentProvider.setAuthChangeCallbacks(onAuthChangeCallbacks);
41352
41352
  }
41353
41353
  // Store the provider used in local storage
41354
- writeToStorage$2('authProvider', providerName);
41354
+ writeToStorage$1('authProvider', providerName);
41355
41355
  }
41356
41356
  }
41357
41357
 
@@ -41360,77 +41360,77 @@ function setProvider(providerName) {
41360
41360
  // this provider will be selected
41361
41361
  function initProviderIfNull() {
41362
41362
  if (currentProvider === undefined) {
41363
- var newProviderName = readFromStorage$3('authProvider');
41363
+ var newProviderName = readFromStorage$2('authProvider');
41364
41364
  if (newProviderName !== undefined && newProviderName !== null) {
41365
41365
  setProvider(newProviderName);
41366
41366
  }
41367
41367
  }
41368
41368
  }
41369
- function signIn$3() {
41369
+ function signIn$2() {
41370
41370
  return currentProvider.signIn();
41371
41371
  }
41372
- function signOut$3() {
41372
+ function signOut$2() {
41373
41373
  initProviderIfNull();
41374
41374
  // Clear last auth provider used from local storage
41375
- clearFromStorage$2('authProvider');
41375
+ clearFromStorage$1('authProvider');
41376
41376
  return currentProvider.signOut();
41377
41377
  }
41378
41378
  function onAuthStateChanged(newCallback) {
41379
41379
  onAuthChangeCallbacks.push(newCallback);
41380
41380
  }
41381
- function isAsync$3() {
41381
+ function isAsync$2() {
41382
41382
  initProviderIfNull();
41383
41383
  if (currentProvider && currentProvider.isAsync) {
41384
41384
  return currentProvider.isAsync();
41385
41385
  }
41386
41386
  return false;
41387
41387
  }
41388
- function acquireTokens$3(callback) {
41388
+ function acquireTokens$2(callback) {
41389
41389
  initProviderIfNull();
41390
41390
  if (currentProvider === undefined) {
41391
41391
  return undefined;
41392
41392
  }
41393
41393
  return currentProvider.acquireTokens(callback);
41394
41394
  }
41395
- function acquireTokensByRequest$3(tokenReq) {
41395
+ function acquireTokensByRequest$1(tokenReq) {
41396
41396
  initProviderIfNull();
41397
41397
  if (currentProvider === undefined) {
41398
41398
  return undefined;
41399
41399
  }
41400
41400
  return currentProvider.acquireTokensByRequest(tokenReq);
41401
41401
  }
41402
- function isUserSignedIn$3(callback) {
41402
+ function isUserSignedIn$2(callback) {
41403
41403
  initProviderIfNull();
41404
41404
  if (currentProvider === undefined) {
41405
41405
  return false;
41406
41406
  }
41407
41407
  return currentProvider.isUserSignedIn(callback);
41408
41408
  }
41409
- function getUserEmail$3() {
41409
+ function getUserEmail$2() {
41410
41410
  if (currentProvider === undefined) {
41411
41411
  return undefined;
41412
41412
  }
41413
41413
  return currentProvider.getUserEmail();
41414
41414
  }
41415
- function getUserName$3() {
41415
+ function getUserName$2() {
41416
41416
  if (currentProvider === undefined) {
41417
41417
  return undefined;
41418
41418
  }
41419
41419
  return currentProvider.getUserName();
41420
41420
  }
41421
- function getUserRoles$3() {
41421
+ function getUserRoles$2() {
41422
41422
  if (currentProvider === undefined) {
41423
41423
  return undefined;
41424
41424
  }
41425
41425
  return currentProvider.getUserRoles();
41426
41426
  }
41427
- function getUserId$3() {
41427
+ function getUserId$2() {
41428
41428
  if (currentProvider === undefined) {
41429
41429
  return undefined;
41430
41430
  }
41431
41431
  return currentProvider.getUserId();
41432
41432
  }
41433
- function getUserPicUrl$3() {
41433
+ function getUserPicUrl$2() {
41434
41434
  if (currentProvider === undefined) {
41435
41435
  return undefined;
41436
41436
  }
@@ -41439,28 +41439,28 @@ function getUserPicUrl$3() {
41439
41439
  var Auth = {
41440
41440
  addProvider,
41441
41441
  setProvider,
41442
- signIn: signIn$3,
41443
- signOut: signOut$3,
41442
+ signIn: signIn$2,
41443
+ signOut: signOut$2,
41444
41444
  onAuthStateChanged,
41445
- isUserSignedIn: isUserSignedIn$3,
41446
- getUserEmail: getUserEmail$3,
41447
- getUserName: getUserName$3,
41448
- getUserId: getUserId$3,
41449
- getUserRoles: getUserRoles$3,
41450
- getUserPicUrl: getUserPicUrl$3,
41451
- isAsync: isAsync$3,
41452
- acquireTokens: acquireTokens$3,
41453
- acquireTokensByRequest: acquireTokensByRequest$3
41445
+ isUserSignedIn: isUserSignedIn$2,
41446
+ getUserEmail: getUserEmail$2,
41447
+ getUserName: getUserName$2,
41448
+ getUserId: getUserId$2,
41449
+ getUserRoles: getUserRoles$2,
41450
+ getUserPicUrl: getUserPicUrl$2,
41451
+ isAsync: isAsync$2,
41452
+ acquireTokens: acquireTokens$2,
41453
+ acquireTokensByRequest: acquireTokensByRequest$1
41454
41454
  };
41455
41455
 
41456
41456
  // Copyright (c) Cosmo Tech.
41457
41457
  // Licensed under the MIT license.
41458
41458
 
41459
- function readFromStorage$2(key) {
41459
+ function readFromStorage$1(key) {
41460
41460
  return localStorage.getItem(key);
41461
41461
  }
41462
- var name$4 = 'auth-dev';
41463
- var authData$2 = null;
41462
+ var name$3 = 'auth-dev';
41463
+ var authData$1 = null;
41464
41464
  var DEFAULT_AUTH_DATA = {
41465
41465
  authenticated: true,
41466
41466
  accountId: 'xxxxxxxx-xxxx-dave-xxxx-xxxxxxxxxxxx',
@@ -41471,75 +41471,75 @@ var DEFAULT_AUTH_DATA = {
41471
41471
  };
41472
41472
 
41473
41473
  // Optional configuration method to overwrite default values such as accountId, userEmail, userId, userName and roles
41474
- function setConfig$2(authDataPatch) {
41475
- authData$2 = _objectSpread2(_objectSpread2({}, DEFAULT_AUTH_DATA), authDataPatch);
41474
+ function setConfig$1(authDataPatch) {
41475
+ authData$1 = _objectSpread2(_objectSpread2({}, DEFAULT_AUTH_DATA), authDataPatch);
41476
41476
  }
41477
41477
  function setDefaultUser() {
41478
- if (authData$2 != null) return;
41479
- authData$2 = DEFAULT_AUTH_DATA;
41478
+ if (authData$1 != null) return;
41479
+ authData$1 = DEFAULT_AUTH_DATA;
41480
41480
  }
41481
- function signIn$2() {
41481
+ function signIn$1() {
41482
41482
  setDefaultUser();
41483
41483
  window.location.href = '/';
41484
41484
  }
41485
- function signOut$2() {
41486
- authData$2 = null;
41485
+ function signOut$1() {
41486
+ authData$1 = null;
41487
41487
  window.location.href = '/';
41488
41488
  }
41489
- function isAsync$2() {
41489
+ function isAsync$1() {
41490
41490
  return false;
41491
41491
  }
41492
- function isUserSignedIn$2() {
41492
+ function isUserSignedIn$1() {
41493
41493
  setDefaultUser();
41494
41494
  return true;
41495
41495
  }
41496
- function getUserEmail$2() {
41496
+ function getUserEmail$1() {
41497
41497
  var _authData;
41498
- return (_authData = authData$2) === null || _authData === void 0 ? void 0 : _authData.userEmail;
41498
+ return (_authData = authData$1) === null || _authData === void 0 ? void 0 : _authData.userEmail;
41499
41499
  }
41500
- function getUserName$2() {
41500
+ function getUserName$1() {
41501
41501
  var _authData2;
41502
- return (_authData2 = authData$2) === null || _authData2 === void 0 ? void 0 : _authData2.userName;
41502
+ return (_authData2 = authData$1) === null || _authData2 === void 0 ? void 0 : _authData2.userName;
41503
41503
  }
41504
- function acquireTokens$2() {
41505
- var accessToken = readFromStorage$2('authAccessToken');
41504
+ function acquireTokens$1() {
41505
+ var accessToken = readFromStorage$1('authAccessToken');
41506
41506
  return accessToken ? {
41507
41507
  accessToken
41508
41508
  } : undefined;
41509
41509
  }
41510
- function acquireTokensByRequest$2(tokenReq) {
41511
- var accessToken = readFromStorage$2('authAccessToken');
41510
+ function acquireTokensByRequest(tokenReq) {
41511
+ var accessToken = readFromStorage$1('authAccessToken');
41512
41512
  return accessToken ? {
41513
41513
  accessToken
41514
41514
  } : undefined;
41515
41515
  }
41516
- function getUserId$2() {
41517
- if (authData$2) {
41518
- return authData$2.userId;
41516
+ function getUserId$1() {
41517
+ if (authData$1) {
41518
+ return authData$1.userId;
41519
41519
  }
41520
41520
  return undefined;
41521
41521
  }
41522
- function getUserRoles$2() {
41522
+ function getUserRoles$1() {
41523
41523
  var _authData3;
41524
- return (_authData3 = authData$2) === null || _authData3 === void 0 ? void 0 : _authData3.roles;
41524
+ return (_authData3 = authData$1) === null || _authData3 === void 0 ? void 0 : _authData3.roles;
41525
41525
  }
41526
- function getUserPicUrl$2() {
41526
+ function getUserPicUrl$1() {
41527
41527
  return undefined;
41528
41528
  }
41529
41529
  var AuthDev = {
41530
- name: name$4,
41531
- signIn: signIn$2,
41532
- signOut: signOut$2,
41533
- isUserSignedIn: isUserSignedIn$2,
41534
- getUserEmail: getUserEmail$2,
41535
- getUserName: getUserName$2,
41536
- getUserRoles: getUserRoles$2,
41537
- getUserId: getUserId$2,
41538
- getUserPicUrl: getUserPicUrl$2,
41539
- isAsync: isAsync$2,
41540
- setConfig: setConfig$2,
41541
- acquireTokens: acquireTokens$2,
41542
- acquireTokensByRequest: acquireTokensByRequest$2
41530
+ name: name$3,
41531
+ signIn: signIn$1,
41532
+ signOut: signOut$1,
41533
+ isUserSignedIn: isUserSignedIn$1,
41534
+ getUserEmail: getUserEmail$1,
41535
+ getUserName: getUserName$1,
41536
+ getUserRoles: getUserRoles$1,
41537
+ getUserId: getUserId$1,
41538
+ getUserPicUrl: getUserPicUrl$1,
41539
+ isAsync: isAsync$1,
41540
+ setConfig: setConfig$1,
41541
+ acquireTokens: acquireTokens$1,
41542
+ acquireTokensByRequest
41543
41543
  };
41544
41544
 
41545
41545
  /*! @azure/msal-common v14.14.0 2024-07-23 */
@@ -44674,7 +44674,7 @@ class Logger {
44674
44674
 
44675
44675
  /*! @azure/msal-common v14.14.0 2024-07-23 */
44676
44676
  /* eslint-disable header/header */
44677
- const name$3 = "@azure/msal-common";
44677
+ const name$2 = "@azure/msal-common";
44678
44678
  const version$1 = "14.14.0";
44679
44679
 
44680
44680
  /*! @azure/msal-common v14.14.0 2024-07-23 */
@@ -45310,7 +45310,7 @@ class CacheManager {
45310
45310
  constructor(clientId, cryptoImpl, logger, staticAuthorityOptions) {
45311
45311
  this.clientId = clientId;
45312
45312
  this.cryptoImpl = cryptoImpl;
45313
- this.commonLogger = logger.clone(name$3, version$1);
45313
+ this.commonLogger = logger.clone(name$2, version$1);
45314
45314
  this.staticAuthorityOptions = staticAuthorityOptions;
45315
45315
  }
45316
45316
  /**
@@ -47277,7 +47277,7 @@ class BaseClient {
47277
47277
  // Set the configuration
47278
47278
  this.config = buildClientConfiguration(configuration);
47279
47279
  // Initialize the logger
47280
- this.logger = new Logger(this.config.loggerOptions, name$3, version$1);
47280
+ this.logger = new Logger(this.config.loggerOptions, name$2, version$1);
47281
47281
  // Initialize crypto
47282
47282
  this.cryptoUtils = this.config.cryptoInterface;
47283
47283
  // Initialize storage interface
@@ -50193,7 +50193,7 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
50193
50193
 
50194
50194
  /*! @azure/msal-browser v3.20.0 2024-07-23 */
50195
50195
  /* eslint-disable header/header */
50196
- const name$2 = "@azure/msal-browser";
50196
+ const name$1 = "@azure/msal-browser";
50197
50197
  const version = "3.20.0";
50198
50198
 
50199
50199
  /*! @azure/msal-browser v3.20.0 2024-07-23 */
@@ -50268,7 +50268,7 @@ class BaseOperatingContext {
50268
50268
  if (piiLoggingEnabled !== undefined) {
50269
50269
  loggerOptions.piiLoggingEnabled = piiLoggingEnabled;
50270
50270
  }
50271
- this.logger = new Logger(loggerOptions, name$2, version);
50271
+ this.logger = new Logger(loggerOptions, name$1, version);
50272
50272
  this.available = false;
50273
50273
  }
50274
50274
  /**
@@ -57261,278 +57261,12 @@ class PublicClientApplication {
57261
57261
  }
57262
57262
  }
57263
57263
 
57264
- // Functions to read & write from storage.
57265
- // Notes : local storage works on Chromium but not on Firefox if "Delete
57266
- // cookies and site data when Firefox is closed" is selected (for more
57267
- // details, see https://bugzilla.mozilla.org/show_bug.cgi?id=1453699)
57268
- var writeToStorage$1 = (key, value) => {
57269
- localStorage.setItem(key, value);
57270
- };
57271
- var readFromStorage$1 = key => {
57272
- return localStorage.getItem(key);
57273
- };
57274
- var clearFromStorage$1 = key => {
57275
- localStorage.removeItem(key);
57276
- };
57277
- var name$1 = 'auth-keycloakPopupExperimental';
57278
- var authData$1 = {
57279
- authenticated: readFromStorage$1('authAuthenticated') === 'true',
57280
- accountId: undefined,
57281
- userEmail: undefined,
57282
- username: undefined,
57283
- userId: undefined,
57284
- roles: []
57285
- };
57286
- var config$1 = null;
57287
- var msalApp$1 = null;
57288
- var setConfig$1 = /*#__PURE__*/function () {
57289
- var _ref = _asyncToGenerator(function* (newConfig) {
57290
- config$1 = newConfig;
57291
- msalApp$1 = new PublicClientApplication(config$1.msalConfig);
57292
- yield msalApp$1.initialize();
57293
- });
57294
- return function setConfig(_x) {
57295
- return _ref.apply(this, arguments);
57296
- };
57297
- }();
57298
- var checkInit$1 = () => {
57299
- if (msalApp$1 === null) {
57300
- console.error('AuthMSAL module has not been initialized. Make sure you ' + 'call the setConfig const when = you add the AuthMSAL provider.');
57301
- return false;
57302
- }
57303
- return true;
57304
- };
57305
- var redirectOnAuthSuccess$1 = () => {
57306
- var _config$msalConfig$au, _config;
57307
- window.location.href = (_config$msalConfig$au = (_config = config$1) === null || _config === void 0 || (_config = _config.msalConfig) === null || _config === void 0 || (_config = _config.auth) === null || _config === void 0 ? void 0 : _config.redirectUri) !== null && _config$msalConfig$au !== void 0 ? _config$msalConfig$au : '/';
57308
- };
57309
- var _acquireTokensByRequestAndAccount$1 = /*#__PURE__*/function () {
57310
- var _ref2 = _asyncToGenerator(function* (tokenReq, account) {
57311
- if (!tokenReq) {
57312
- console.warn('No base access token request provided');
57313
- tokenReq = {};
57314
- }
57315
- tokenReq.account = account;
57316
- return yield msalApp$1.acquireTokenSilent(tokenReq).then(tokenRes => tokenRes).catch(silentTokenFetchError => {
57317
- var _silentTokenFetchErro;
57318
- if (silentTokenFetchError.errorCode === 'no_tokens_found') {
57319
- // No token found during acquireTokenSilent, ignore this error, nothing to do
57320
- return;
57321
- } else if (silentTokenFetchError.errorCode === 'login_required') {
57322
- console.warn('Silent authentication not possible, user is not logged in. This usually happens when the user session ' + 'has expired. Please try to log in again.');
57323
- return;
57324
- } else if (((_silentTokenFetchErro = silentTokenFetchError.errorMessage) === null || _silentTokenFetchErro === void 0 ? void 0 : _silentTokenFetchErro.indexOf('interaction_required')) !== -1) {
57325
- msalApp$1.acquireTokenPopup(tokenReq).then(tokenRes => tokenRes) // Token acquired with interaction
57326
- .catch(popupTokenFetchError => popupTokenFetchError); // Token retrieval failed
57327
- }
57328
- throw silentTokenFetchError;
57329
- });
57330
- });
57331
- return function _acquireTokensByRequestAndAccount(_x2, _x3) {
57332
- return _ref2.apply(this, arguments);
57333
- };
57334
- }();
57335
- var acquireTokens$1 = /*#__PURE__*/function () {
57336
- var _ref3 = _asyncToGenerator(function* () {
57337
- var _msalApp$getAllAccoun;
57338
- if (!checkInit$1()) return;
57339
- var idToken = readFromStorage$1('authIdToken');
57340
- var accessToken = readFromStorage$1('authAccessToken');
57341
- var authenticated = readFromStorage$1('authAuthenticated') === 'true';
57342
- if (authenticated && idToken != null && accessToken != null) {
57343
- return {
57344
- accessToken,
57345
- idToken
57346
- };
57347
- }
57348
- var account = (_msalApp$getAllAccoun = msalApp$1.getAllAccounts()) === null || _msalApp$getAllAccoun === void 0 ? void 0 : _msalApp$getAllAccoun[0];
57349
- var tokenReq = config$1.accessRequest;
57350
- if (account === undefined) {
57351
- return undefined;
57352
- }
57353
- return yield _acquireTokensByRequestAndAccount$1(tokenReq, account);
57354
- });
57355
- return function acquireTokens() {
57356
- return _ref3.apply(this, arguments);
57357
- };
57358
- }();
57359
- var acquireTokensByRequest$1 = /*#__PURE__*/function () {
57360
- var _ref4 = _asyncToGenerator(function* (tokenReq) {
57361
- var _msalApp$getAllAccoun2;
57362
- if (!checkInit$1()) return;
57363
- var account = (_msalApp$getAllAccoun2 = msalApp$1.getAllAccounts()) === null || _msalApp$getAllAccoun2 === void 0 ? void 0 : _msalApp$getAllAccoun2[0];
57364
- return yield _acquireTokensByRequestAndAccount$1(tokenReq, account);
57365
- });
57366
- return function acquireTokensByRequest(_x4) {
57367
- return _ref4.apply(this, arguments);
57368
- };
57369
- }();
57370
- var selectAccount = () => {
57371
- if (!checkInit$1()) return;
57372
- var accounts = msalApp$1.getAllAccounts();
57373
- if (accounts.length === 0) {
57374
- return;
57375
- }
57376
- // Select the 1st account if more than one is detected
57377
- if (accounts.length > 1) {
57378
- console.warn('Several accounts detected, using the first one by default.');
57379
- }
57380
- authData$1.authenticated = true;
57381
- var account = accounts[0];
57382
- authData$1.accountId = account.homeAccountId;
57383
- authData$1.userEmail = account.username; // In MSAL account data, username property contains user email
57384
- authData$1.username = account.name;
57385
- authData$1.userId = account.localAccountId;
57386
- redirectOnAuthSuccess$1();
57387
- };
57388
- var handleResponse$1 = response => {
57389
- if (response == null) {
57390
- selectAccount();
57391
- return;
57392
- }
57393
- writeToStorage$1('authIdTokenPopup', response.idToken);
57394
- writeToStorage$1('authIdToken', response.idToken);
57395
- writeToStorage$1('authAccessToken', response.accessToken);
57396
- writeToStorage$1('authAuthenticated', 'true');
57397
- authData$1.authenticated = true;
57398
- var account = response.account;
57399
- authData$1.accountId = account.homeAccountId;
57400
- authData$1.userEmail = account.username; // In MSAL account data, username property contains user email
57401
- authData$1.username = account.name;
57402
- authData$1.userId = account.localAccountId;
57403
- redirectOnAuthSuccess$1();
57404
- };
57405
- var signIn$1 = () => {
57406
- if (!checkInit$1()) return;
57407
-
57408
- // Force removal of MSAL interaction status if it exists in session storage (it happens sometimes after logout)
57409
- var itemKey = 'msal.interaction.status';
57410
- if (sessionStorage.getItem(itemKey)) {
57411
- sessionStorage.removeItem(itemKey);
57412
- }
57413
- return msalApp$1.loginPopup(config$1.loginRequest).then(handleResponse$1).catch(error => {
57414
- var _error$errorMessage;
57415
- // Error handling
57416
- // Check for forgot password error
57417
- // Learn more about AAD error codes at
57418
- // https://docs.microsoft.com/en-us/azure/active-directory/develop/reference-aadsts-error-codes
57419
- if (((_error$errorMessage = error.errorMessage) === null || _error$errorMessage === void 0 ? void 0 : _error$errorMessage.indexOf('AADB2C90118')) > -1) {
57420
- msalApp$1.loginPopup(config$1.b2cPolicies.authorities.forgotPassword).then(response => {
57421
- window.alert('Password has been reset successfully. \nPlease sign-in with your new password.');
57422
- });
57423
- } else if (error.errorCode === 'user_cancelled') ; else {
57424
- throw error;
57425
- }
57426
- });
57427
- };
57428
- var signOut$1 = () => {
57429
- if (!checkInit$1()) return;
57430
- clearFromStorage$1('authIdTokenPopup');
57431
- clearFromStorage$1('authIdToken');
57432
- clearFromStorage$1('authAccessToken');
57433
- writeToStorage$1('authAuthenticated', 'false');
57434
- // return;
57435
- var logoutRequest = {
57436
- account: msalApp$1.getAccountByHomeId(authData$1.accountId)
57437
- };
57438
- msalApp$1.logoutRedirect(logoutRequest);
57439
- };
57440
-
57441
- // Returns a boolean value, stating whether the isUserSignedIn must be provided a callback
57442
- var isAsync$1 = () => {
57443
- return false;
57444
- };
57445
- var _extractRolesFromAccessToken$1 = accessToken => {
57446
- var result = [];
57447
- if (accessToken) {
57448
- var decodedToken = JSON.parse(atob(accessToken.split('.')[1]));
57449
- if (decodedToken !== null && decodedToken !== void 0 && decodedToken.roles) {
57450
- result = decodedToken === null || decodedToken === void 0 ? void 0 : decodedToken.roles;
57451
- }
57452
- }
57453
- return result;
57454
- };
57455
- var isUserSignedIn$1 = /*#__PURE__*/function () {
57456
- var _ref5 = _asyncToGenerator(function* () {
57457
- // Return true if already authenticated
57458
- if (authData$1.authenticated) return true;
57459
- if (readFromStorage$1('authAuthenticated') === 'true') {
57460
- authData$1.authenticated = true;
57461
- return true;
57462
- }
57463
-
57464
- // Otherwise, try to acquire a token silently to implement SSO
57465
- var tokens = yield acquireTokens$1();
57466
- if ((tokens === null || tokens === void 0 ? void 0 : tokens.idToken) !== undefined) {
57467
- writeToStorage$1('authIdToken', tokens.idToken);
57468
- }
57469
- if ((tokens === null || tokens === void 0 ? void 0 : tokens.accessToken) !== undefined) {
57470
- var accessToken = tokens.accessToken;
57471
- authData$1.roles = _extractRolesFromAccessToken$1(accessToken);
57472
- writeToStorage$1('authAccessToken', accessToken);
57473
- return true;
57474
- }
57475
- return false;
57476
- });
57477
- return function isUserSignedIn() {
57478
- return _ref5.apply(this, arguments);
57479
- };
57480
- }();
57481
- var getUserEmail$1 = () => {
57482
- var _authData$userEmail, _msalApp$getAllAccoun3;
57483
- if (!checkInit$1()) return;
57484
- // Note: account data from MSAL seems to contain user email in the 'username' property
57485
- return (_authData$userEmail = authData$1 === null || authData$1 === void 0 ? void 0 : authData$1.userEmail) !== null && _authData$userEmail !== void 0 ? _authData$userEmail : (_msalApp$getAllAccoun3 = msalApp$1.getAllAccounts()) === null || _msalApp$getAllAccoun3 === void 0 || (_msalApp$getAllAccoun3 = _msalApp$getAllAccoun3[0]) === null || _msalApp$getAllAccoun3 === void 0 ? void 0 : _msalApp$getAllAccoun3.username;
57486
- };
57487
- var getUserName$1 = () => {
57488
- var _authData$name, _msalApp$getAllAccoun4;
57489
- if (!checkInit$1()) return;
57490
- return (_authData$name = authData$1 === null || authData$1 === void 0 ? void 0 : authData$1.name) !== null && _authData$name !== void 0 ? _authData$name : (_msalApp$getAllAccoun4 = msalApp$1.getAllAccounts()) === null || _msalApp$getAllAccoun4 === void 0 || (_msalApp$getAllAccoun4 = _msalApp$getAllAccoun4[0]) === null || _msalApp$getAllAccoun4 === void 0 ? void 0 : _msalApp$getAllAccoun4.name;
57491
- };
57492
- var getUserId$1 = () => {
57493
- var _authData$userId, _msalApp$getAllAccoun5;
57494
- if (!checkInit$1()) return;
57495
- return (_authData$userId = authData$1 === null || authData$1 === void 0 ? void 0 : authData$1.userId) !== null && _authData$userId !== void 0 ? _authData$userId : (_msalApp$getAllAccoun5 = msalApp$1.getAllAccounts()) === null || _msalApp$getAllAccoun5 === void 0 || (_msalApp$getAllAccoun5 = _msalApp$getAllAccoun5[0]) === null || _msalApp$getAllAccoun5 === void 0 ? void 0 : _msalApp$getAllAccoun5.localAccountId;
57496
- };
57497
- var getUserRoles$1 = () => {
57498
- if (!checkInit$1()) return;
57499
- return authData$1.roles;
57500
- };
57501
- var getUserPicUrl$1 = () => {
57502
- return undefined;
57503
- };
57504
-
57505
- var AuthKeycloakPopupExperimental = /*#__PURE__*/Object.freeze({
57506
- __proto__: null,
57507
- acquireTokens: acquireTokens$1,
57508
- acquireTokensByRequest: acquireTokensByRequest$1,
57509
- getUserEmail: getUserEmail$1,
57510
- getUserId: getUserId$1,
57511
- getUserName: getUserName$1,
57512
- getUserPicUrl: getUserPicUrl$1,
57513
- getUserRoles: getUserRoles$1,
57514
- isAsync: isAsync$1,
57515
- isUserSignedIn: isUserSignedIn$1,
57516
- name: name$1,
57517
- setConfig: setConfig$1,
57518
- signIn: signIn$1,
57519
- signOut: signOut$1
57520
- });
57521
-
57522
- // Functions to read & write from storage.
57523
- // Notes : local storage works on Chromium but not on Firefox if "Delete
57524
- // cookies and site data when Firefox is closed" is selected (for more
57525
- // details, see https://bugzilla.mozilla.org/show_bug.cgi?id=1453699)
57526
- var writeToStorage = (key, value) => {
57527
- localStorage.setItem(key, value);
57528
- };
57529
- var readFromStorage = key => {
57530
- return localStorage.getItem(key);
57531
- };
57532
- var clearFromStorage = key => {
57533
- localStorage.removeItem(key);
57534
- };
57535
- var name = 'auth-keycloakRedirectExperimental';
57264
+ // Note: local storage works on Chromium but not on Firefox if "Delete cookies and site data when Firefox is closed" is
57265
+ // selected (for more details, see https://bugzilla.mozilla.org/show_bug.cgi?id=1453699)
57266
+ var writeToStorage = (key, value) => localStorage.setItem(key, value);
57267
+ var readFromStorage = key => localStorage.getItem(key);
57268
+ var clearFromStorage = key => localStorage.removeItem(key);
57269
+ var name = 'auth-keycloakRedirect';
57536
57270
  var authData = {
57537
57271
  authenticated: readFromStorage('authAuthenticated') === 'true',
57538
57272
  accountId: undefined,
@@ -57548,10 +57282,6 @@ var setConfig = /*#__PURE__*/function () {
57548
57282
  config = newConfig;
57549
57283
  msalApp = new PublicClientApplication(config.msalConfig);
57550
57284
  yield msalApp.initialize();
57551
- //
57552
- // if (await isUserSignedIn()) {
57553
- // console.log('already signed in!');
57554
- // }
57555
57285
  });
57556
57286
  return function setConfig(_x) {
57557
57287
  return _ref.apply(this, arguments);
@@ -57559,7 +57289,7 @@ var setConfig = /*#__PURE__*/function () {
57559
57289
  }();
57560
57290
  var checkInit = () => {
57561
57291
  if (msalApp === null) {
57562
- console.error('AuthMSAL module has not been initialized. Make sure you ' + 'call the setConfig const when = you add the AuthMSAL provider.');
57292
+ console.error('AuthKeycloakRedirect module has not been initialized. Make sure you ' + 'call the setConfig function when you add the AuthKeycloakRedirect provider.');
57563
57293
  return false;
57564
57294
  }
57565
57295
  return true;
@@ -57618,26 +57348,15 @@ var acquireTokens = /*#__PURE__*/function () {
57618
57348
  return _ref3.apply(this, arguments);
57619
57349
  };
57620
57350
  }();
57621
- var acquireTokensByRequest = /*#__PURE__*/function () {
57622
- var _ref4 = _asyncToGenerator(function* (tokenReq) {
57623
- var _msalApp$getAllAccoun2;
57624
- if (!checkInit()) return;
57625
- var account = (_msalApp$getAllAccoun2 = msalApp.getAllAccounts()) === null || _msalApp$getAllAccoun2 === void 0 ? void 0 : _msalApp$getAllAccoun2[0];
57626
- return yield _acquireTokensByRequestAndAccount(tokenReq, account);
57627
- });
57628
- return function acquireTokensByRequest(_x4) {
57629
- return _ref4.apply(this, arguments);
57630
- };
57631
- }();
57632
57351
  var handleResponse = response => {
57633
- if (response !== null) {
57634
- response.account.homeAccountId;
57352
+ if (response != null) {
57353
+ var account = response.account;
57635
57354
  writeToStorage('authIdTokenPopup', response.idToken);
57636
57355
  writeToStorage('authIdToken', response.idToken);
57637
57356
  writeToStorage('authAccessToken', response.accessToken);
57638
57357
  writeToStorage('authAuthenticated', 'true');
57358
+ writeToStorage('authAccountId', account.homeAccountId);
57639
57359
  authData.authenticated = true;
57640
- var account = response.account;
57641
57360
  authData.accountId = account.homeAccountId;
57642
57361
  authData.userEmail = account.username; // In MSAL account data, username property contains user email
57643
57362
  authData.username = account.name;
@@ -57645,41 +57364,30 @@ var handleResponse = response => {
57645
57364
  redirectOnAuthSuccess();
57646
57365
  return;
57647
57366
  }
57648
-
57649
- // In case multiple accounts exist, you can select
57650
- var currentAccounts = msalApp.getAllAccounts();
57651
- if (currentAccounts.length === 0) {
57652
- // no accounts signed-in, attempt to sign a user in
57653
- msalApp.loginRedirect(config.loginRequest);
57654
- } else if (currentAccounts.length > 1) ; else if (currentAccounts.length === 1) {
57655
- currentAccounts[0].homeAccountId;
57656
- }
57367
+ msalApp.loginRedirect(config.loginRequest);
57657
57368
  };
57658
- var signIn = /*#__PURE__*/function () {
57659
- var _ref5 = _asyncToGenerator(function* () {
57660
- if (!checkInit()) return;
57661
-
57662
- // Force removal of MSAL interaction status if it exists in session storage (it happens sometimes after logout)
57663
- // const itemKey = 'msal.interaction.status';
57664
- // if (sessionStorage.getItem(itemKey)) {
57665
- // sessionStorage.removeItem(itemKey);
57666
- // }
57369
+ var signIn = () => {
57370
+ if (!checkInit()) return;
57667
57371
 
57668
- msalApp.handleRedirectPromise().then(handleResponse);
57669
- });
57670
- return function signIn() {
57671
- return _ref5.apply(this, arguments);
57672
- };
57673
- }();
57372
+ // Set auth provider name in storage to declare that it has an interaction in progress
57373
+ setTimeout(() => {
57374
+ writeToStorage('authInteractionInProgress', name);
57375
+ }, 50);
57376
+ return msalApp.handleRedirectPromise().then(handleResponse);
57377
+ };
57674
57378
  var signOut = () => {
57379
+ var _authData$accountId;
57675
57380
  if (!checkInit()) return;
57381
+ var accountId = readFromStorage('authAccountId');
57382
+ var idToken = readFromStorage('authIdToken');
57676
57383
  clearFromStorage('authIdTokenPopup');
57677
57384
  clearFromStorage('authIdToken');
57678
57385
  clearFromStorage('authAccessToken');
57386
+ clearFromStorage('authAccountId');
57679
57387
  writeToStorage('authAuthenticated', 'false');
57680
- // return;
57681
57388
  var logoutRequest = {
57682
- account: msalApp.getAccountByHomeId(authData.accountId)
57389
+ account: msalApp.getAccountByHomeId((_authData$accountId = authData.accountId) !== null && _authData$accountId !== void 0 ? _authData$accountId : accountId),
57390
+ idTokenHint: idToken
57683
57391
  };
57684
57392
  msalApp.logoutRedirect(logoutRequest);
57685
57393
  };
@@ -57699,14 +57407,29 @@ var _extractRolesFromAccessToken = accessToken => {
57699
57407
  return result;
57700
57408
  };
57701
57409
  var isUserSignedIn = /*#__PURE__*/function () {
57702
- var _ref6 = _asyncToGenerator(function* () {
57703
- // Return true if already authenticated
57410
+ var _ref4 = _asyncToGenerator(function* () {
57704
57411
  if (authData.authenticated) return true;
57705
57412
  if (readFromStorage('authAuthenticated') === 'true') {
57706
57413
  authData.authenticated = true;
57707
57414
  return true;
57708
57415
  }
57709
57416
 
57417
+ // Resume interaction if one is already in progress
57418
+ if (readFromStorage('authInteractionInProgress') === name) {
57419
+ clearFromStorage('authInteractionInProgress');
57420
+ var locationHashParameters = new URLSearchParams(window.location.hash.substring(1));
57421
+ if (locationHashParameters.has('state')) {
57422
+ var _config2;
57423
+ if (locationHashParameters.has('iss', (_config2 = config) === null || _config2 === void 0 || (_config2 = _config2.msalConfig) === null || _config2 === void 0 || (_config2 = _config2.auth) === null || _config2 === void 0 || (_config2 = _config2.authorityMetadata) === null || _config2 === void 0 ? void 0 : _config2.issuer)) {
57424
+ // Resume redirect workflow process
57425
+ msalApp.handleRedirectPromise().then(handleResponse);
57426
+ } else if (locationHashParameters.has('iss')) {
57427
+ var _config3;
57428
+ console.warn('Issuer found in url ("' + ((_config3 = config) === null || _config3 === void 0 || (_config3 = _config3.msalConfig) === null || _config3 === void 0 || (_config3 = _config3.auth) === null || _config3 === void 0 || (_config3 = _config3.authorityMetadata) === null || _config3 === void 0 ? void 0 : _config3.issuer) + '") does not match the keycloak configuration ("' + locationHashParameters.get('iss') + '")');
57429
+ }
57430
+ }
57431
+ }
57432
+
57710
57433
  // Otherwise, try to acquire a token silently to implement SSO
57711
57434
  var tokens = yield acquireTokens();
57712
57435
  if ((tokens === null || tokens === void 0 ? void 0 : tokens.idToken) !== undefined) {
@@ -57721,24 +57444,24 @@ var isUserSignedIn = /*#__PURE__*/function () {
57721
57444
  return false;
57722
57445
  });
57723
57446
  return function isUserSignedIn() {
57724
- return _ref6.apply(this, arguments);
57447
+ return _ref4.apply(this, arguments);
57725
57448
  };
57726
57449
  }();
57727
57450
  var getUserEmail = () => {
57728
- var _authData$userEmail, _msalApp$getAllAccoun3;
57451
+ var _authData$userEmail, _msalApp$getAllAccoun2;
57729
57452
  if (!checkInit()) return;
57730
57453
  // Note: account data from MSAL seems to contain user email in the 'username' property
57731
- return (_authData$userEmail = authData === null || authData === void 0 ? void 0 : authData.userEmail) !== null && _authData$userEmail !== void 0 ? _authData$userEmail : (_msalApp$getAllAccoun3 = msalApp.getAllAccounts()) === null || _msalApp$getAllAccoun3 === void 0 || (_msalApp$getAllAccoun3 = _msalApp$getAllAccoun3[0]) === null || _msalApp$getAllAccoun3 === void 0 ? void 0 : _msalApp$getAllAccoun3.username;
57454
+ return (_authData$userEmail = authData === null || authData === void 0 ? void 0 : authData.userEmail) !== null && _authData$userEmail !== void 0 ? _authData$userEmail : (_msalApp$getAllAccoun2 = msalApp.getAllAccounts()) === null || _msalApp$getAllAccoun2 === void 0 || (_msalApp$getAllAccoun2 = _msalApp$getAllAccoun2[0]) === null || _msalApp$getAllAccoun2 === void 0 ? void 0 : _msalApp$getAllAccoun2.username;
57732
57455
  };
57733
57456
  var getUserName = () => {
57734
- var _authData$name, _msalApp$getAllAccoun4;
57457
+ var _authData$name, _msalApp$getAllAccoun3;
57735
57458
  if (!checkInit()) return;
57736
- return (_authData$name = authData === null || authData === void 0 ? void 0 : authData.name) !== null && _authData$name !== void 0 ? _authData$name : (_msalApp$getAllAccoun4 = msalApp.getAllAccounts()) === null || _msalApp$getAllAccoun4 === void 0 || (_msalApp$getAllAccoun4 = _msalApp$getAllAccoun4[0]) === null || _msalApp$getAllAccoun4 === void 0 ? void 0 : _msalApp$getAllAccoun4.name;
57459
+ return (_authData$name = authData === null || authData === void 0 ? void 0 : authData.name) !== null && _authData$name !== void 0 ? _authData$name : (_msalApp$getAllAccoun3 = msalApp.getAllAccounts()) === null || _msalApp$getAllAccoun3 === void 0 || (_msalApp$getAllAccoun3 = _msalApp$getAllAccoun3[0]) === null || _msalApp$getAllAccoun3 === void 0 ? void 0 : _msalApp$getAllAccoun3.name;
57737
57460
  };
57738
57461
  var getUserId = () => {
57739
- var _authData$userId, _msalApp$getAllAccoun5;
57462
+ var _authData$userId, _msalApp$getAllAccoun4;
57740
57463
  if (!checkInit()) return;
57741
- return (_authData$userId = authData === null || authData === void 0 ? void 0 : authData.userId) !== null && _authData$userId !== void 0 ? _authData$userId : (_msalApp$getAllAccoun5 = msalApp.getAllAccounts()) === null || _msalApp$getAllAccoun5 === void 0 || (_msalApp$getAllAccoun5 = _msalApp$getAllAccoun5[0]) === null || _msalApp$getAllAccoun5 === void 0 ? void 0 : _msalApp$getAllAccoun5.localAccountId;
57464
+ return (_authData$userId = authData === null || authData === void 0 ? void 0 : authData.userId) !== null && _authData$userId !== void 0 ? _authData$userId : (_msalApp$getAllAccoun4 = msalApp.getAllAccounts()) === null || _msalApp$getAllAccoun4 === void 0 || (_msalApp$getAllAccoun4 = _msalApp$getAllAccoun4[0]) === null || _msalApp$getAllAccoun4 === void 0 ? void 0 : _msalApp$getAllAccoun4.localAccountId;
57742
57465
  };
57743
57466
  var getUserRoles = () => {
57744
57467
  if (!checkInit()) return;
@@ -57748,10 +57471,9 @@ var getUserPicUrl = () => {
57748
57471
  return undefined;
57749
57472
  };
57750
57473
 
57751
- var AuthKeycloakRedirectExperimental = /*#__PURE__*/Object.freeze({
57474
+ var AuthKeycloakRedirect = /*#__PURE__*/Object.freeze({
57752
57475
  __proto__: null,
57753
57476
  acquireTokens: acquireTokens,
57754
- acquireTokensByRequest: acquireTokensByRequest,
57755
57477
  getUserEmail: getUserEmail,
57756
57478
  getUserId: getUserId,
57757
57479
  getUserName: getUserName,
@@ -58110,4 +57832,4 @@ var ResourceUtils = {
58110
57832
  getFirstRootResource
58111
57833
  };
58112
57834
 
58113
- export { AgGridUtils, Auth, AuthDev, AuthKeycloakPopupExperimental, AuthKeycloakRedirectExperimental, CSVUtils, DatasetUtils, DateUtils, Error$1 as Error, FileBlobUtils, PathUtils, ResourceUtils, ScenarioUtils, ValidationUtils, XLSXUtils };
57835
+ export { AgGridUtils, Auth, AuthDev, AuthKeycloakRedirect, CSVUtils, DatasetUtils, DateUtils, Error$1 as Error, FileBlobUtils, PathUtils, ResourceUtils, ScenarioUtils, ValidationUtils, XLSXUtils };