@cosmotech/core 1.18.0-dev.2 → 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.
Binary file
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## **1.18.0** <sub><sup>2024-09-11 (cc08ecb...54ff3ae)</sup></sub>
2
+
3
+ ### Features
4
+
5
+ - add new provider AuthKeycloakRedirect ([2cb7fb9](https://github.com/Cosmo-Tech/webapp-component-core/commit/2cb7fb9))
6
+
1
7
  ## **1.17.0** <sub><sup>2024-07-29 (05224df...05224df)</sup></sub>
2
8
 
3
9
  ### Features
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$2(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$2
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$1(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$1
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 = /*#__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,
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,
@@ -57557,7 +57291,7 @@ var setConfig = /*#__PURE__*/function () {
57557
57291
  }();
57558
57292
  var checkInit = () => {
57559
57293
  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.');
57294
+ console.error('AuthKeycloakRedirect module has not been initialized. Make sure you ' + 'call the setConfig function when you add the AuthKeycloakRedirect provider.');
57561
57295
  return false;
57562
57296
  }
57563
57297
  return true;
@@ -57676,7 +57410,6 @@ var _extractRolesFromAccessToken = accessToken => {
57676
57410
  };
57677
57411
  var isUserSignedIn = /*#__PURE__*/function () {
57678
57412
  var _ref4 = _asyncToGenerator(function* () {
57679
- // Return true if already authenticated
57680
57413
  if (authData.authenticated) return true;
57681
57414
  if (readFromStorage('authAuthenticated') === 'true') {
57682
57415
  authData.authenticated = true;
@@ -57692,7 +57425,6 @@ var isUserSignedIn = /*#__PURE__*/function () {
57692
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)) {
57693
57426
  // Resume redirect workflow process
57694
57427
  msalApp.handleRedirectPromise().then(handleResponse);
57695
- // return true;
57696
57428
  } else if (locationHashParameters.has('iss')) {
57697
57429
  var _config3;
57698
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') + '")');
@@ -57741,7 +57473,7 @@ var getUserPicUrl = () => {
57741
57473
  return undefined;
57742
57474
  };
57743
57475
 
57744
- var AuthKeycloakRedirectExperimental = /*#__PURE__*/Object.freeze({
57476
+ var AuthKeycloakRedirect = /*#__PURE__*/Object.freeze({
57745
57477
  __proto__: null,
57746
57478
  acquireTokens: acquireTokens,
57747
57479
  getUserEmail: getUserEmail,
@@ -58105,8 +57837,7 @@ var ResourceUtils = {
58105
57837
  exports.AgGridUtils = AgGridUtils;
58106
57838
  exports.Auth = Auth;
58107
57839
  exports.AuthDev = AuthDev;
58108
- exports.AuthKeycloakPopupExperimental = AuthKeycloakPopupExperimental;
58109
- exports.AuthKeycloakRedirectExperimental = AuthKeycloakRedirectExperimental;
57840
+ exports.AuthKeycloakRedirect = AuthKeycloakRedirect;
58110
57841
  exports.CSVUtils = CSVUtils;
58111
57842
  exports.DatasetUtils = DatasetUtils;
58112
57843
  exports.DateUtils = DateUtils;
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$2(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$2
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$1(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$1
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 = /*#__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,
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,
@@ -57555,7 +57289,7 @@ var setConfig = /*#__PURE__*/function () {
57555
57289
  }();
57556
57290
  var checkInit = () => {
57557
57291
  if (msalApp === null) {
57558
- 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.');
57559
57293
  return false;
57560
57294
  }
57561
57295
  return true;
@@ -57674,7 +57408,6 @@ var _extractRolesFromAccessToken = accessToken => {
57674
57408
  };
57675
57409
  var isUserSignedIn = /*#__PURE__*/function () {
57676
57410
  var _ref4 = _asyncToGenerator(function* () {
57677
- // Return true if already authenticated
57678
57411
  if (authData.authenticated) return true;
57679
57412
  if (readFromStorage('authAuthenticated') === 'true') {
57680
57413
  authData.authenticated = true;
@@ -57690,7 +57423,6 @@ var isUserSignedIn = /*#__PURE__*/function () {
57690
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)) {
57691
57424
  // Resume redirect workflow process
57692
57425
  msalApp.handleRedirectPromise().then(handleResponse);
57693
- // return true;
57694
57426
  } else if (locationHashParameters.has('iss')) {
57695
57427
  var _config3;
57696
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') + '")');
@@ -57739,7 +57471,7 @@ var getUserPicUrl = () => {
57739
57471
  return undefined;
57740
57472
  };
57741
57473
 
57742
- var AuthKeycloakRedirectExperimental = /*#__PURE__*/Object.freeze({
57474
+ var AuthKeycloakRedirect = /*#__PURE__*/Object.freeze({
57743
57475
  __proto__: null,
57744
57476
  acquireTokens: acquireTokens,
57745
57477
  getUserEmail: getUserEmail,
@@ -58100,4 +57832,4 @@ var ResourceUtils = {
58100
57832
  getFirstRootResource
58101
57833
  };
58102
57834
 
58103
- 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmotech/core",
3
- "version": "1.18.0-dev.2",
3
+ "version": "1.18.0",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",