@cosmotech/core 1.18.2 → 1.19.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.19.0** <sub><sup>2024-10-22 (07716f7...07716f7)</sup></sub>
2
+
3
+ ### Features
4
+
5
+ - add configuration option `rolesJwtClaim` in `AuthKeycloakRedirect` provider ([07716f7](https://github.com/Cosmo-Tech/webapp-component-core/commit/07716f7))
6
+
1
7
  ## **1.18.2** <sub><sup>2024-09-23 (e619d7e...e619d7e)</sup></sub>
2
8
 
3
9
  ### Bug Fixes
package/dist/index.cjs.js CHANGED
@@ -57422,13 +57422,24 @@ var _updateTokensInStorage = tokens => {
57422
57422
  }
57423
57423
  };
57424
57424
  var _extractRolesFromAccessToken = accessToken => {
57425
- var result = [];
57426
- if (accessToken) {
57427
- var decodedToken = JSON.parse(atob(accessToken.split('.')[1]));
57428
- // The exact key to use may depend from keycloak client & API configuration
57429
- if (decodedToken !== null && decodedToken !== void 0 && decodedToken.roles) result = decodedToken.roles;else if (decodedToken !== null && decodedToken !== void 0 && decodedToken.userRoles) result = decodedToken.userRoles;
57430
- }
57431
- return result;
57425
+ var _config2;
57426
+ if (!accessToken) return [];
57427
+ var decodedToken = JSON.parse(atob(accessToken.split('.')[1]));
57428
+ // The exact key to use may depend from keycloak client & Cosmo Tech API configuration (c.f. the value of
57429
+ // csm.platform.authorization.roles-jwt-claim in your k8s tenant secrets)
57430
+ var rolesTokenAttribute = (_config2 = config) === null || _config2 === void 0 ? void 0 : _config2.rolesJwtClaim;
57431
+ if (rolesTokenAttribute) {
57432
+ if (decodedToken !== null && decodedToken !== void 0 && decodedToken[rolesTokenAttribute]) return decodedToken === null || decodedToken === void 0 ? void 0 : decodedToken[rolesTokenAttribute];
57433
+ console.warn("Authentication provider configuration defined rolesJwtClaim=\"".concat(rolesTokenAttribute, "\" ") + 'but this key was not found in the access token. Please check your webapp and API configuration.');
57434
+ }
57435
+ if (decodedToken !== null && decodedToken !== void 0 && decodedToken.roles) return decodedToken.roles; // Legacy default key in token
57436
+
57437
+ if (decodedToken !== null && decodedToken !== void 0 && decodedToken.userRoles) {
57438
+ console.warn("DEPRECATED: the token claim for API roles was automatically found in 'userRoles', but the lookup " + 'for this specific key will be removed in a future version. Please update your webapp configuration to ' + "explicitly set AUTH_KEYCLOAK_ROLES_JWT_CLAIM to 'userRoles'.");
57439
+ return decodedToken.userRoles;
57440
+ }
57441
+ console.warn("Couldn't extract roles from access token. Please check your webapp and API configuration.");
57442
+ return [];
57432
57443
  };
57433
57444
  var isUserSignedIn = /*#__PURE__*/function () {
57434
57445
  var _ref4 = _asyncToGenerator(function* () {
@@ -57446,12 +57457,12 @@ var isUserSignedIn = /*#__PURE__*/function () {
57446
57457
  clearFromStorage('authInteractionInProgress');
57447
57458
  var locationHashParameters = new URLSearchParams(window.location.hash.substring(1));
57448
57459
  if (locationHashParameters.has('state')) {
57449
- var _config2;
57450
- 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)) {
57460
+ var _config3;
57461
+ if (locationHashParameters.has('iss', (_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)) {
57451
57462
  msalApp.handleRedirectPromise().then(handleResponse); // Resume redirect workflow process
57452
57463
  } else if (locationHashParameters.has('iss')) {
57453
- var _config3;
57454
- var configIssuer = (_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;
57464
+ var _config4;
57465
+ var configIssuer = (_config4 = config) === null || _config4 === void 0 || (_config4 = _config4.msalConfig) === null || _config4 === void 0 || (_config4 = _config4.auth) === null || _config4 === void 0 || (_config4 = _config4.authorityMetadata) === null || _config4 === void 0 ? void 0 : _config4.issuer;
57455
57466
  var urlIssuer = locationHashParameters.get('iss');
57456
57467
  console.warn("Issuer found in url \"".concat(urlIssuer, "\" does not match keycloak configuration: \"").concat(configIssuer, "\""));
57457
57468
  }
package/dist/index.esm.js CHANGED
@@ -57420,13 +57420,24 @@ var _updateTokensInStorage = tokens => {
57420
57420
  }
57421
57421
  };
57422
57422
  var _extractRolesFromAccessToken = accessToken => {
57423
- var result = [];
57424
- if (accessToken) {
57425
- var decodedToken = JSON.parse(atob(accessToken.split('.')[1]));
57426
- // The exact key to use may depend from keycloak client & API configuration
57427
- if (decodedToken !== null && decodedToken !== void 0 && decodedToken.roles) result = decodedToken.roles;else if (decodedToken !== null && decodedToken !== void 0 && decodedToken.userRoles) result = decodedToken.userRoles;
57428
- }
57429
- return result;
57423
+ var _config2;
57424
+ if (!accessToken) return [];
57425
+ var decodedToken = JSON.parse(atob(accessToken.split('.')[1]));
57426
+ // The exact key to use may depend from keycloak client & Cosmo Tech API configuration (c.f. the value of
57427
+ // csm.platform.authorization.roles-jwt-claim in your k8s tenant secrets)
57428
+ var rolesTokenAttribute = (_config2 = config) === null || _config2 === void 0 ? void 0 : _config2.rolesJwtClaim;
57429
+ if (rolesTokenAttribute) {
57430
+ if (decodedToken !== null && decodedToken !== void 0 && decodedToken[rolesTokenAttribute]) return decodedToken === null || decodedToken === void 0 ? void 0 : decodedToken[rolesTokenAttribute];
57431
+ console.warn("Authentication provider configuration defined rolesJwtClaim=\"".concat(rolesTokenAttribute, "\" ") + 'but this key was not found in the access token. Please check your webapp and API configuration.');
57432
+ }
57433
+ if (decodedToken !== null && decodedToken !== void 0 && decodedToken.roles) return decodedToken.roles; // Legacy default key in token
57434
+
57435
+ if (decodedToken !== null && decodedToken !== void 0 && decodedToken.userRoles) {
57436
+ console.warn("DEPRECATED: the token claim for API roles was automatically found in 'userRoles', but the lookup " + 'for this specific key will be removed in a future version. Please update your webapp configuration to ' + "explicitly set AUTH_KEYCLOAK_ROLES_JWT_CLAIM to 'userRoles'.");
57437
+ return decodedToken.userRoles;
57438
+ }
57439
+ console.warn("Couldn't extract roles from access token. Please check your webapp and API configuration.");
57440
+ return [];
57430
57441
  };
57431
57442
  var isUserSignedIn = /*#__PURE__*/function () {
57432
57443
  var _ref4 = _asyncToGenerator(function* () {
@@ -57444,12 +57455,12 @@ var isUserSignedIn = /*#__PURE__*/function () {
57444
57455
  clearFromStorage('authInteractionInProgress');
57445
57456
  var locationHashParameters = new URLSearchParams(window.location.hash.substring(1));
57446
57457
  if (locationHashParameters.has('state')) {
57447
- var _config2;
57448
- 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)) {
57458
+ var _config3;
57459
+ if (locationHashParameters.has('iss', (_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)) {
57449
57460
  msalApp.handleRedirectPromise().then(handleResponse); // Resume redirect workflow process
57450
57461
  } else if (locationHashParameters.has('iss')) {
57451
- var _config3;
57452
- var configIssuer = (_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;
57462
+ var _config4;
57463
+ var configIssuer = (_config4 = config) === null || _config4 === void 0 || (_config4 = _config4.msalConfig) === null || _config4 === void 0 || (_config4 = _config4.auth) === null || _config4 === void 0 || (_config4 = _config4.authorityMetadata) === null || _config4 === void 0 ? void 0 : _config4.issuer;
57453
57464
  var urlIssuer = locationHashParameters.get('iss');
57454
57465
  console.warn("Issuer found in url \"".concat(urlIssuer, "\" does not match keycloak configuration: \"").concat(configIssuer, "\""));
57455
57466
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmotech/core",
3
- "version": "1.18.2",
3
+ "version": "1.19.0",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",