@cosmotech/core 1.18.0-dev.0 → 1.18.0-dev.2

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$1(key, value) {
41314
+ function writeToStorage$2(key, value) {
41315
41315
  localStorage.setItem(key, value);
41316
41316
  }
41317
- function readFromStorage$2(key) {
41317
+ function readFromStorage$3(key) {
41318
41318
  return localStorage.getItem(key);
41319
41319
  }
41320
- function clearFromStorage$1(key) {
41320
+ function clearFromStorage$2(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$1('authProvider', providerName);
41356
+ writeToStorage$2('authProvider', providerName);
41357
41357
  }
41358
41358
  }
41359
41359
 
@@ -41362,32 +41362,32 @@ function setProvider(providerName) {
41362
41362
  // this provider will be selected
41363
41363
  function initProviderIfNull() {
41364
41364
  if (currentProvider === undefined) {
41365
- var newProviderName = readFromStorage$2('authProvider');
41365
+ var newProviderName = readFromStorage$3('authProvider');
41366
41366
  if (newProviderName !== undefined && newProviderName !== null) {
41367
41367
  setProvider(newProviderName);
41368
41368
  }
41369
41369
  }
41370
41370
  }
41371
- function signIn$2() {
41371
+ function signIn$3() {
41372
41372
  return currentProvider.signIn();
41373
41373
  }
41374
- function signOut$2() {
41374
+ function signOut$3() {
41375
41375
  initProviderIfNull();
41376
41376
  // Clear last auth provider used from local storage
41377
- clearFromStorage$1('authProvider');
41377
+ clearFromStorage$2('authProvider');
41378
41378
  return currentProvider.signOut();
41379
41379
  }
41380
41380
  function onAuthStateChanged(newCallback) {
41381
41381
  onAuthChangeCallbacks.push(newCallback);
41382
41382
  }
41383
- function isAsync$2() {
41383
+ function isAsync$3() {
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$2(callback) {
41390
+ function acquireTokens$3(callback) {
41391
41391
  initProviderIfNull();
41392
41392
  if (currentProvider === undefined) {
41393
41393
  return undefined;
@@ -41401,38 +41401,38 @@ function acquireTokensByRequest$2(tokenReq) {
41401
41401
  }
41402
41402
  return currentProvider.acquireTokensByRequest(tokenReq);
41403
41403
  }
41404
- function isUserSignedIn$2(callback) {
41404
+ function isUserSignedIn$3(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$2() {
41411
+ function getUserEmail$3() {
41412
41412
  if (currentProvider === undefined) {
41413
41413
  return undefined;
41414
41414
  }
41415
41415
  return currentProvider.getUserEmail();
41416
41416
  }
41417
- function getUserName$2() {
41417
+ function getUserName$3() {
41418
41418
  if (currentProvider === undefined) {
41419
41419
  return undefined;
41420
41420
  }
41421
41421
  return currentProvider.getUserName();
41422
41422
  }
41423
- function getUserRoles$2() {
41423
+ function getUserRoles$3() {
41424
41424
  if (currentProvider === undefined) {
41425
41425
  return undefined;
41426
41426
  }
41427
41427
  return currentProvider.getUserRoles();
41428
41428
  }
41429
- function getUserId$2() {
41429
+ function getUserId$3() {
41430
41430
  if (currentProvider === undefined) {
41431
41431
  return undefined;
41432
41432
  }
41433
41433
  return currentProvider.getUserId();
41434
41434
  }
41435
- function getUserPicUrl$2() {
41435
+ function getUserPicUrl$3() {
41436
41436
  if (currentProvider === undefined) {
41437
41437
  return undefined;
41438
41438
  }
@@ -41441,28 +41441,28 @@ function getUserPicUrl$2() {
41441
41441
  var Auth = {
41442
41442
  addProvider,
41443
41443
  setProvider,
41444
- signIn: signIn$2,
41445
- signOut: signOut$2,
41444
+ signIn: signIn$3,
41445
+ signOut: signOut$3,
41446
41446
  onAuthStateChanged,
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,
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
41455
  acquireTokensByRequest: acquireTokensByRequest$2
41456
41456
  };
41457
41457
 
41458
41458
  // Copyright (c) Cosmo Tech.
41459
41459
  // Licensed under the MIT license.
41460
41460
 
41461
- function readFromStorage$1(key) {
41461
+ function readFromStorage$2(key) {
41462
41462
  return localStorage.getItem(key);
41463
41463
  }
41464
- var name$3 = 'auth-dev';
41465
- var authData$1 = null;
41464
+ var name$4 = 'auth-dev';
41465
+ var authData$2 = null;
41466
41466
  var DEFAULT_AUTH_DATA = {
41467
41467
  authenticated: true,
41468
41468
  accountId: 'xxxxxxxx-xxxx-dave-xxxx-xxxxxxxxxxxx',
@@ -41473,74 +41473,74 @@ 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$1(authDataPatch) {
41477
- authData$1 = _objectSpread2(_objectSpread2({}, DEFAULT_AUTH_DATA), authDataPatch);
41476
+ function setConfig$2(authDataPatch) {
41477
+ authData$2 = _objectSpread2(_objectSpread2({}, DEFAULT_AUTH_DATA), authDataPatch);
41478
41478
  }
41479
41479
  function setDefaultUser() {
41480
- if (authData$1 != null) return;
41481
- authData$1 = DEFAULT_AUTH_DATA;
41480
+ if (authData$2 != null) return;
41481
+ authData$2 = DEFAULT_AUTH_DATA;
41482
41482
  }
41483
- function signIn$1() {
41483
+ function signIn$2() {
41484
41484
  setDefaultUser();
41485
41485
  window.location.href = '/';
41486
41486
  }
41487
- function signOut$1() {
41488
- authData$1 = null;
41487
+ function signOut$2() {
41488
+ authData$2 = null;
41489
41489
  window.location.href = '/';
41490
41490
  }
41491
- function isAsync$1() {
41491
+ function isAsync$2() {
41492
41492
  return false;
41493
41493
  }
41494
- function isUserSignedIn$1() {
41494
+ function isUserSignedIn$2() {
41495
41495
  setDefaultUser();
41496
41496
  return true;
41497
41497
  }
41498
- function getUserEmail$1() {
41498
+ function getUserEmail$2() {
41499
41499
  var _authData;
41500
- return (_authData = authData$1) === null || _authData === void 0 ? void 0 : _authData.userEmail;
41500
+ return (_authData = authData$2) === null || _authData === void 0 ? void 0 : _authData.userEmail;
41501
41501
  }
41502
- function getUserName$1() {
41502
+ function getUserName$2() {
41503
41503
  var _authData2;
41504
- return (_authData2 = authData$1) === null || _authData2 === void 0 ? void 0 : _authData2.userName;
41504
+ return (_authData2 = authData$2) === null || _authData2 === void 0 ? void 0 : _authData2.userName;
41505
41505
  }
41506
- function acquireTokens$1() {
41507
- var accessToken = readFromStorage$1('authAccessToken');
41506
+ function acquireTokens$2() {
41507
+ var accessToken = readFromStorage$2('authAccessToken');
41508
41508
  return accessToken ? {
41509
41509
  accessToken
41510
41510
  } : undefined;
41511
41511
  }
41512
41512
  function acquireTokensByRequest$1(tokenReq) {
41513
- var accessToken = readFromStorage$1('authAccessToken');
41513
+ var accessToken = readFromStorage$2('authAccessToken');
41514
41514
  return accessToken ? {
41515
41515
  accessToken
41516
41516
  } : undefined;
41517
41517
  }
41518
- function getUserId$1() {
41519
- if (authData$1) {
41520
- return authData$1.userId;
41518
+ function getUserId$2() {
41519
+ if (authData$2) {
41520
+ return authData$2.userId;
41521
41521
  }
41522
41522
  return undefined;
41523
41523
  }
41524
- function getUserRoles$1() {
41524
+ function getUserRoles$2() {
41525
41525
  var _authData3;
41526
- return (_authData3 = authData$1) === null || _authData3 === void 0 ? void 0 : _authData3.roles;
41526
+ return (_authData3 = authData$2) === null || _authData3 === void 0 ? void 0 : _authData3.roles;
41527
41527
  }
41528
- function getUserPicUrl$1() {
41528
+ function getUserPicUrl$2() {
41529
41529
  return undefined;
41530
41530
  }
41531
41531
  var AuthDev = {
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,
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
41544
  acquireTokensByRequest: acquireTokensByRequest$1
41545
41545
  };
41546
41546
 
@@ -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$2 = "@azure/msal-common";
44679
+ const name$3 = "@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$2, version$1);
45315
+ this.commonLogger = logger.clone(name$3, 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$2, version$1);
47282
+ this.logger = new Logger(this.config.loggerOptions, name$3, 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$1 = "@azure/msal-browser";
50198
+ const name$2 = "@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$1, version);
50273
+ this.logger = new Logger(loggerOptions, name$2, version);
50274
50274
  this.available = false;
50275
50275
  }
50276
50276
  /**
@@ -57267,55 +57267,55 @@ class PublicClientApplication {
57267
57267
  // Notes : local storage works on Chromium but not on Firefox if "Delete
57268
57268
  // cookies and site data when Firefox is closed" is selected (for more
57269
57269
  // details, see https://bugzilla.mozilla.org/show_bug.cgi?id=1453699)
57270
- var writeToStorage = (key, value) => {
57270
+ var writeToStorage$1 = (key, value) => {
57271
57271
  localStorage.setItem(key, value);
57272
57272
  };
57273
- var readFromStorage = key => {
57273
+ var readFromStorage$1 = key => {
57274
57274
  return localStorage.getItem(key);
57275
57275
  };
57276
- var clearFromStorage = key => {
57276
+ var clearFromStorage$1 = key => {
57277
57277
  localStorage.removeItem(key);
57278
57278
  };
57279
- var name = 'auth-keycloakExperimental';
57280
- var authData = {
57281
- authenticated: readFromStorage('authAuthenticated') === 'true',
57279
+ var name$1 = 'auth-keycloakPopupExperimental';
57280
+ var authData$1 = {
57281
+ authenticated: readFromStorage$1('authAuthenticated') === 'true',
57282
57282
  accountId: undefined,
57283
57283
  userEmail: undefined,
57284
57284
  username: undefined,
57285
57285
  userId: undefined,
57286
57286
  roles: []
57287
57287
  };
57288
- var config = null;
57289
- var msalApp = null;
57290
- var setConfig = /*#__PURE__*/function () {
57288
+ var config$1 = null;
57289
+ var msalApp$1 = null;
57290
+ var setConfig$1 = /*#__PURE__*/function () {
57291
57291
  var _ref = _asyncToGenerator(function* (newConfig) {
57292
- config = newConfig;
57293
- msalApp = new PublicClientApplication(config.msalConfig);
57294
- yield msalApp.initialize();
57292
+ config$1 = newConfig;
57293
+ msalApp$1 = new PublicClientApplication(config$1.msalConfig);
57294
+ yield msalApp$1.initialize();
57295
57295
  });
57296
57296
  return function setConfig(_x) {
57297
57297
  return _ref.apply(this, arguments);
57298
57298
  };
57299
57299
  }();
57300
- var checkInit = () => {
57301
- if (msalApp === null) {
57302
- console.error('AuthMSAL module has not been initialized. Make sure you ' + 'call the setConfig const when = you add the AuthMSAL provider.=> aa');
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
57303
  return false;
57304
57304
  }
57305
57305
  return true;
57306
57306
  };
57307
- var redirectOnAuthSuccess = () => {
57307
+ var redirectOnAuthSuccess$1 = () => {
57308
57308
  var _config$msalConfig$au, _config;
57309
- window.location.href = (_config$msalConfig$au = (_config = config) === 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 : '/';
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
57310
  };
57311
- var _acquireTokensByRequestAndAccount = /*#__PURE__*/function () {
57311
+ var _acquireTokensByRequestAndAccount$1 = /*#__PURE__*/function () {
57312
57312
  var _ref2 = _asyncToGenerator(function* (tokenReq, account) {
57313
57313
  if (!tokenReq) {
57314
57314
  console.warn('No base access token request provided');
57315
57315
  tokenReq = {};
57316
57316
  }
57317
57317
  tokenReq.account = account;
57318
- return yield msalApp.acquireTokenSilent(tokenReq).then(tokenRes => tokenRes).catch(silentTokenFetchError => {
57318
+ return yield msalApp$1.acquireTokenSilent(tokenReq).then(tokenRes => tokenRes).catch(silentTokenFetchError => {
57319
57319
  var _silentTokenFetchErro;
57320
57320
  if (silentTokenFetchError.errorCode === 'no_tokens_found') {
57321
57321
  // No token found during acquireTokenSilent, ignore this error, nothing to do
@@ -57324,7 +57324,7 @@ var _acquireTokensByRequestAndAccount = /*#__PURE__*/function () {
57324
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
57325
  return;
57326
57326
  } else if (((_silentTokenFetchErro = silentTokenFetchError.errorMessage) === null || _silentTokenFetchErro === void 0 ? void 0 : _silentTokenFetchErro.indexOf('interaction_required')) !== -1) {
57327
- msalApp.acquireTokenPopup(tokenReq).then(tokenRes => tokenRes) // Token acquired with interaction
57327
+ msalApp$1.acquireTokenPopup(tokenReq).then(tokenRes => tokenRes) // Token acquired with interaction
57328
57328
  .catch(popupTokenFetchError => popupTokenFetchError); // Token retrieval failed
57329
57329
  }
57330
57330
  throw silentTokenFetchError;
@@ -57334,25 +57334,25 @@ var _acquireTokensByRequestAndAccount = /*#__PURE__*/function () {
57334
57334
  return _ref2.apply(this, arguments);
57335
57335
  };
57336
57336
  }();
57337
- var acquireTokens = /*#__PURE__*/function () {
57337
+ var acquireTokens$1 = /*#__PURE__*/function () {
57338
57338
  var _ref3 = _asyncToGenerator(function* () {
57339
57339
  var _msalApp$getAllAccoun;
57340
- if (!checkInit()) return;
57341
- var idToken = readFromStorage('authIdToken');
57342
- var accessToken = readFromStorage('authAccessToken');
57343
- var authenticated = readFromStorage('authAuthenticated') === 'true';
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
57344
  if (authenticated && idToken != null && accessToken != null) {
57345
57345
  return {
57346
57346
  accessToken,
57347
57347
  idToken
57348
57348
  };
57349
57349
  }
57350
- var account = (_msalApp$getAllAccoun = msalApp.getAllAccounts()) === null || _msalApp$getAllAccoun === void 0 ? void 0 : _msalApp$getAllAccoun[0];
57351
- var tokenReq = config.accessRequest;
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
57352
  if (account === undefined) {
57353
57353
  return undefined;
57354
57354
  }
57355
- return yield _acquireTokensByRequestAndAccount(tokenReq, account);
57355
+ return yield _acquireTokensByRequestAndAccount$1(tokenReq, account);
57356
57356
  });
57357
57357
  return function acquireTokens() {
57358
57358
  return _ref3.apply(this, arguments);
@@ -57361,17 +57361,17 @@ var acquireTokens = /*#__PURE__*/function () {
57361
57361
  var acquireTokensByRequest = /*#__PURE__*/function () {
57362
57362
  var _ref4 = _asyncToGenerator(function* (tokenReq) {
57363
57363
  var _msalApp$getAllAccoun2;
57364
- if (!checkInit()) return;
57365
- var account = (_msalApp$getAllAccoun2 = msalApp.getAllAccounts()) === null || _msalApp$getAllAccoun2 === void 0 ? void 0 : _msalApp$getAllAccoun2[0];
57366
- return yield _acquireTokensByRequestAndAccount(tokenReq, account);
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
57367
  });
57368
57368
  return function acquireTokensByRequest(_x4) {
57369
57369
  return _ref4.apply(this, arguments);
57370
57370
  };
57371
57371
  }();
57372
57372
  var selectAccount = () => {
57373
- if (!checkInit()) return;
57374
- var accounts = msalApp.getAllAccounts();
57373
+ if (!checkInit$1()) return;
57374
+ var accounts = msalApp$1.getAllAccounts();
57375
57375
  if (accounts.length === 0) {
57376
57376
  return;
57377
57377
  }
@@ -57379,47 +57379,47 @@ var selectAccount = () => {
57379
57379
  if (accounts.length > 1) {
57380
57380
  console.warn('Several accounts detected, using the first one by default.');
57381
57381
  }
57382
- authData.authenticated = true;
57382
+ authData$1.authenticated = true;
57383
57383
  var account = accounts[0];
57384
- authData.accountId = account.homeAccountId;
57385
- authData.userEmail = account.username; // In MSAL account data, username property contains user email
57386
- authData.username = account.name;
57387
- authData.userId = account.localAccountId;
57388
- redirectOnAuthSuccess();
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
57389
  };
57390
- var handleResponse = response => {
57390
+ var handleResponse$1 = response => {
57391
57391
  if (response == null) {
57392
57392
  selectAccount();
57393
57393
  return;
57394
57394
  }
57395
- writeToStorage('authIdTokenPopup', response.idToken);
57396
- writeToStorage('authIdToken', response.idToken);
57397
- writeToStorage('authAccessToken', response.accessToken);
57398
- writeToStorage('authAuthenticated', 'true');
57399
- authData.authenticated = true;
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
57400
  var account = response.account;
57401
- authData.accountId = account.homeAccountId;
57402
- authData.userEmail = account.username; // In MSAL account data, username property contains user email
57403
- authData.username = account.name;
57404
- authData.userId = account.localAccountId;
57405
- redirectOnAuthSuccess();
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
57406
  };
57407
- var signIn = () => {
57408
- if (!checkInit()) return;
57407
+ var signIn$1 = () => {
57408
+ if (!checkInit$1()) return;
57409
57409
 
57410
57410
  // Force removal of MSAL interaction status if it exists in session storage (it happens sometimes after logout)
57411
57411
  var itemKey = 'msal.interaction.status';
57412
57412
  if (sessionStorage.getItem(itemKey)) {
57413
57413
  sessionStorage.removeItem(itemKey);
57414
57414
  }
57415
- return msalApp.loginPopup(config.loginRequest).then(handleResponse).catch(error => {
57415
+ return msalApp$1.loginPopup(config$1.loginRequest).then(handleResponse$1).catch(error => {
57416
57416
  var _error$errorMessage;
57417
57417
  // Error handling
57418
57418
  // Check for forgot password error
57419
57419
  // Learn more about AAD error codes at
57420
57420
  // https://docs.microsoft.com/en-us/azure/active-directory/develop/reference-aadsts-error-codes
57421
57421
  if (((_error$errorMessage = error.errorMessage) === null || _error$errorMessage === void 0 ? void 0 : _error$errorMessage.indexOf('AADB2C90118')) > -1) {
57422
- msalApp.loginPopup(config.b2cPolicies.authorities.forgotPassword).then(response => {
57422
+ msalApp$1.loginPopup(config$1.b2cPolicies.authorities.forgotPassword).then(response => {
57423
57423
  window.alert('Password has been reset successfully. \nPlease sign-in with your new password.');
57424
57424
  });
57425
57425
  } else if (error.errorCode === 'user_cancelled') ; else {
@@ -57427,20 +57427,240 @@ var signIn = () => {
57427
57427
  }
57428
57428
  });
57429
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,
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';
57538
+ var authData = {
57539
+ authenticated: readFromStorage('authAuthenticated') === 'true',
57540
+ accountId: undefined,
57541
+ userEmail: undefined,
57542
+ username: undefined,
57543
+ userId: undefined,
57544
+ roles: []
57545
+ };
57546
+ var config = null;
57547
+ var msalApp = null;
57548
+ var setConfig = /*#__PURE__*/function () {
57549
+ var _ref = _asyncToGenerator(function* (newConfig) {
57550
+ config = newConfig;
57551
+ msalApp = new PublicClientApplication(config.msalConfig);
57552
+ yield msalApp.initialize();
57553
+ });
57554
+ return function setConfig(_x) {
57555
+ return _ref.apply(this, arguments);
57556
+ };
57557
+ }();
57558
+ var checkInit = () => {
57559
+ if (msalApp === null) {
57560
+ console.error('AuthMSAL module has not been initialized. Make sure you ' + 'call the setConfig const when = you add the AuthMSAL provider.');
57561
+ return false;
57562
+ }
57563
+ return true;
57564
+ };
57565
+ var redirectOnAuthSuccess = () => {
57566
+ var _config$msalConfig$au, _config;
57567
+ window.location.href = (_config$msalConfig$au = (_config = config) === 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 : '/';
57568
+ };
57569
+ var _acquireTokensByRequestAndAccount = /*#__PURE__*/function () {
57570
+ var _ref2 = _asyncToGenerator(function* (tokenReq, account) {
57571
+ if (!tokenReq) {
57572
+ console.warn('No base access token request provided');
57573
+ tokenReq = {};
57574
+ }
57575
+ tokenReq.account = account;
57576
+ return yield msalApp.acquireTokenSilent(tokenReq).then(tokenRes => tokenRes).catch(silentTokenFetchError => {
57577
+ var _silentTokenFetchErro;
57578
+ if (silentTokenFetchError.errorCode === 'no_tokens_found') {
57579
+ // No token found during acquireTokenSilent, ignore this error, nothing to do
57580
+ return;
57581
+ } else if (silentTokenFetchError.errorCode === 'login_required') {
57582
+ 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.');
57583
+ return;
57584
+ } else if (((_silentTokenFetchErro = silentTokenFetchError.errorMessage) === null || _silentTokenFetchErro === void 0 ? void 0 : _silentTokenFetchErro.indexOf('interaction_required')) !== -1) {
57585
+ msalApp.acquireTokenRedirect(tokenReq).then(tokenRes => tokenRes) // Token acquired with interaction
57586
+ .catch(tokenRedirectError => tokenRedirectError); // Token retrieval failed
57587
+ }
57588
+ throw silentTokenFetchError;
57589
+ });
57590
+ });
57591
+ return function _acquireTokensByRequestAndAccount(_x2, _x3) {
57592
+ return _ref2.apply(this, arguments);
57593
+ };
57594
+ }();
57595
+ var acquireTokens = /*#__PURE__*/function () {
57596
+ var _ref3 = _asyncToGenerator(function* () {
57597
+ var _msalApp$getAllAccoun;
57598
+ if (!checkInit()) return;
57599
+ var idToken = readFromStorage('authIdToken');
57600
+ var accessToken = readFromStorage('authAccessToken');
57601
+ var authenticated = readFromStorage('authAuthenticated') === 'true';
57602
+ if (authenticated && idToken != null && accessToken != null) {
57603
+ return {
57604
+ accessToken,
57605
+ idToken
57606
+ };
57607
+ }
57608
+ var account = (_msalApp$getAllAccoun = msalApp.getAllAccounts()) === null || _msalApp$getAllAccoun === void 0 ? void 0 : _msalApp$getAllAccoun[0];
57609
+ var tokenReq = config.accessRequest;
57610
+ if (account === undefined) {
57611
+ return undefined;
57612
+ }
57613
+ return yield _acquireTokensByRequestAndAccount(tokenReq, account);
57614
+ });
57615
+ return function acquireTokens() {
57616
+ return _ref3.apply(this, arguments);
57617
+ };
57618
+ }();
57619
+ var handleResponse = response => {
57620
+ if (response != null) {
57621
+ var account = response.account;
57622
+ writeToStorage('authIdTokenPopup', response.idToken);
57623
+ writeToStorage('authIdToken', response.idToken);
57624
+ writeToStorage('authAccessToken', response.accessToken);
57625
+ writeToStorage('authAuthenticated', 'true');
57626
+ writeToStorage('authAccountId', account.homeAccountId);
57627
+ authData.authenticated = true;
57628
+ authData.accountId = account.homeAccountId;
57629
+ authData.userEmail = account.username; // In MSAL account data, username property contains user email
57630
+ authData.username = account.name;
57631
+ authData.userId = account.localAccountId;
57632
+ redirectOnAuthSuccess();
57633
+ return;
57634
+ }
57635
+ msalApp.loginRedirect(config.loginRequest);
57636
+ };
57637
+ var signIn = () => {
57638
+ if (!checkInit()) return;
57639
+
57640
+ // Set auth provider name in storage to declare that it has an interaction in progress
57641
+ setTimeout(() => {
57642
+ writeToStorage('authInteractionInProgress', name);
57643
+ }, 50);
57644
+ return msalApp.handleRedirectPromise().then(handleResponse);
57645
+ };
57430
57646
  var signOut = () => {
57647
+ var _authData$accountId;
57431
57648
  if (!checkInit()) return;
57649
+ var accountId = readFromStorage('authAccountId');
57650
+ var idToken = readFromStorage('authIdToken');
57432
57651
  clearFromStorage('authIdTokenPopup');
57433
57652
  clearFromStorage('authIdToken');
57434
57653
  clearFromStorage('authAccessToken');
57654
+ clearFromStorage('authAccountId');
57435
57655
  writeToStorage('authAuthenticated', 'false');
57436
- // return;
57437
57656
  var logoutRequest = {
57438
- account: msalApp.getAccountByHomeId(authData.accountId)
57657
+ account: msalApp.getAccountByHomeId((_authData$accountId = authData.accountId) !== null && _authData$accountId !== void 0 ? _authData$accountId : accountId),
57658
+ idTokenHint: idToken
57439
57659
  };
57440
57660
  msalApp.logoutRedirect(logoutRequest);
57441
57661
  };
57442
57662
 
57443
- // Returns a boolean value, stating whether the isUserSignedIn must be provided a callback const as = paramete=> aar
57663
+ // Returns a boolean value, stating whether the isUserSignedIn must be provided a callback
57444
57664
  var isAsync = () => {
57445
57665
  return false;
57446
57666
  };
@@ -57455,7 +57675,7 @@ var _extractRolesFromAccessToken = accessToken => {
57455
57675
  return result;
57456
57676
  };
57457
57677
  var isUserSignedIn = /*#__PURE__*/function () {
57458
- var _ref5 = _asyncToGenerator(function* () {
57678
+ var _ref4 = _asyncToGenerator(function* () {
57459
57679
  // Return true if already authenticated
57460
57680
  if (authData.authenticated) return true;
57461
57681
  if (readFromStorage('authAuthenticated') === 'true') {
@@ -57463,6 +57683,23 @@ var isUserSignedIn = /*#__PURE__*/function () {
57463
57683
  return true;
57464
57684
  }
57465
57685
 
57686
+ // Resume interaction if one is already in progress
57687
+ if (readFromStorage('authInteractionInProgress') === name) {
57688
+ clearFromStorage('authInteractionInProgress');
57689
+ var locationHashParameters = new URLSearchParams(window.location.hash.substring(1));
57690
+ if (locationHashParameters.has('state')) {
57691
+ var _config2;
57692
+ 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)) {
57693
+ // Resume redirect workflow process
57694
+ msalApp.handleRedirectPromise().then(handleResponse);
57695
+ // return true;
57696
+ } else if (locationHashParameters.has('iss')) {
57697
+ var _config3;
57698
+ 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') + '")');
57699
+ }
57700
+ }
57701
+ }
57702
+
57466
57703
  // Otherwise, try to acquire a token silently to implement SSO
57467
57704
  var tokens = yield acquireTokens();
57468
57705
  if ((tokens === null || tokens === void 0 ? void 0 : tokens.idToken) !== undefined) {
@@ -57477,24 +57714,24 @@ var isUserSignedIn = /*#__PURE__*/function () {
57477
57714
  return false;
57478
57715
  });
57479
57716
  return function isUserSignedIn() {
57480
- return _ref5.apply(this, arguments);
57717
+ return _ref4.apply(this, arguments);
57481
57718
  };
57482
57719
  }();
57483
57720
  var getUserEmail = () => {
57484
- var _authData$userEmail, _msalApp$getAllAccoun3;
57721
+ var _authData$userEmail, _msalApp$getAllAccoun2;
57485
57722
  if (!checkInit()) return;
57486
57723
  // Note: account data from MSAL seems to contain user email in the 'username' property
57487
- 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;
57724
+ 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;
57488
57725
  };
57489
57726
  var getUserName = () => {
57490
- var _authData$name, _msalApp$getAllAccoun4;
57727
+ var _authData$name, _msalApp$getAllAccoun3;
57491
57728
  if (!checkInit()) return;
57492
- 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;
57729
+ 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;
57493
57730
  };
57494
57731
  var getUserId = () => {
57495
- var _authData$userId, _msalApp$getAllAccoun5;
57732
+ var _authData$userId, _msalApp$getAllAccoun4;
57496
57733
  if (!checkInit()) return;
57497
- 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;
57734
+ 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;
57498
57735
  };
57499
57736
  var getUserRoles = () => {
57500
57737
  if (!checkInit()) return;
@@ -57504,10 +57741,9 @@ var getUserPicUrl = () => {
57504
57741
  return undefined;
57505
57742
  };
57506
57743
 
57507
- var AuthKeycloakExperimental = /*#__PURE__*/Object.freeze({
57744
+ var AuthKeycloakRedirectExperimental = /*#__PURE__*/Object.freeze({
57508
57745
  __proto__: null,
57509
57746
  acquireTokens: acquireTokens,
57510
- acquireTokensByRequest: acquireTokensByRequest,
57511
57747
  getUserEmail: getUserEmail,
57512
57748
  getUserId: getUserId,
57513
57749
  getUserName: getUserName,
@@ -57869,7 +58105,8 @@ var ResourceUtils = {
57869
58105
  exports.AgGridUtils = AgGridUtils;
57870
58106
  exports.Auth = Auth;
57871
58107
  exports.AuthDev = AuthDev;
57872
- exports.AuthKeycloakExperimental = AuthKeycloakExperimental;
58108
+ exports.AuthKeycloakPopupExperimental = AuthKeycloakPopupExperimental;
58109
+ exports.AuthKeycloakRedirectExperimental = AuthKeycloakRedirectExperimental;
57873
58110
  exports.CSVUtils = CSVUtils;
57874
58111
  exports.DatasetUtils = DatasetUtils;
57875
58112
  exports.DateUtils = DateUtils;