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