dash-button-web 0.0.22 → 0.0.23

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.
@@ -3899,6 +3899,8 @@ const DEFAULT_CONFIG = {
3899
3899
  isLoading: true,
3900
3900
  duration: 800
3901
3901
  },
3902
+ allowedGlobalDomain: '',
3903
+ whitelistedUrls: ''
3902
3904
  };
3903
3905
  // Fetch config from API
3904
3906
  class ConfigService {
@@ -4122,27 +4124,44 @@ const DashButtonComponent = class {
4122
4124
  }
4123
4125
  }
4124
4126
  }
4127
+ // First, check global links
4128
+ // Then, check the token's organization URL
4129
+ // Finally, check against dashbutton configuration: allowedGlobalDomain and whitelistedUrls
4125
4130
  validateAppAccessByUrl() {
4126
- var _a, _b, _c, _d;
4127
- const currentUrl = window.location.href;
4128
- const currentOrigin = window.location.origin;
4131
+ var _a, _b, _c, _d, _e, _f;
4132
+ const normalizeUrl = (url) => url.replace(/\/+$/, '');
4133
+ const currentUrl = normalizeUrl(window.location.href);
4134
+ const currentOrigin = normalizeUrl(window.location.origin);
4129
4135
  const globalLinks = ((_c = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.menu) === null || _b === void 0 ? void 0 : _b.global) === null || _c === void 0 ? void 0 : _c.links) || [];
4130
- // Check Global Links
4136
+ const allowedGlobalDomain = ((_d = this.config) === null || _d === void 0 ? void 0 : _d.allowedGlobalDomain) || '';
4137
+ const whitelistedUrls = ((_e = this.config) === null || _e === void 0 ? void 0 : _e.whitelistedUrls) || '';
4138
+ // First, check global links
4131
4139
  const matchGlobal = globalLinks.some(link => {
4132
4140
  try {
4133
- const linkOrigin = new URL(link.url).origin;
4141
+ const linkOrigin = normalizeUrl(new URL(link.url).origin);
4134
4142
  return currentOrigin === linkOrigin;
4135
4143
  }
4136
4144
  catch (_a) {
4137
4145
  return false;
4138
4146
  }
4139
4147
  });
4140
- // Check Token organizationUrl
4141
- const tokenParsed = (_d = this.keycloak) === null || _d === void 0 ? void 0 : _d.tokenParsed;
4148
+ // Then check the token organization URL
4149
+ const tokenParsed = (_f = this.keycloak) === null || _f === void 0 ? void 0 : _f.tokenParsed;
4142
4150
  const allowedOrg = tokenParsed === null || tokenParsed === void 0 ? void 0 : tokenParsed.organizationUrl;
4143
- const matchOrganization = allowedOrg && currentUrl.includes(allowedOrg);
4144
- // global and org url validations
4145
- const isAllowed = matchGlobal || matchOrganization;
4151
+ const matchOrganization = allowedOrg && currentUrl.includes(normalizeUrl(allowedOrg));
4152
+ // Check allowedGlobalDomain (single domain)
4153
+ const matchAllowedDomain = allowedGlobalDomain &&
4154
+ currentOrigin.includes(normalizeUrl(allowedGlobalDomain));
4155
+ // Check whitelistedUrls (comma-separated string)
4156
+ const whitelistedArray = whitelistedUrls
4157
+ ? whitelistedUrls.split(',').map(url => normalizeUrl(url.trim()))
4158
+ : [];
4159
+ const matchWhitelisted = whitelistedArray.some(url => currentUrl.includes(url));
4160
+ // Final validation
4161
+ const isAllowed = matchGlobal ||
4162
+ matchOrganization ||
4163
+ matchAllowedDomain ||
4164
+ matchWhitelisted;
4146
4165
  this.isRestricted = !isAllowed;
4147
4166
  }
4148
4167
  login() {
@@ -4164,7 +4183,7 @@ const DashButtonComponent = class {
4164
4183
  }
4165
4184
  render() {
4166
4185
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
4167
- return index.h("div", { key: 'd186318626a3fbd1d011d3532559901d1c36859e' }, index.h("div", { key: 'a5887ec423aabb35ca7988169cfa7a9f0bd588e6' }, (() => {
4186
+ return index.h("div", { key: '370786aa472fafd2bf9509a18bd62c87ac2893c7' }, index.h("div", { key: 'c0b091b19e7981ecc48e95c03c8d91e77e7a88df' }, (() => {
4168
4187
  var _a, _b, _c, _d, _e, _f;
4169
4188
  // GLOBAL LOADING SPINNER
4170
4189
  if (this.isLoading) {
@@ -4191,7 +4210,7 @@ const DashButtonComponent = class {
4191
4210
  else {
4192
4211
  return (index.h("button", { style: { background: this.primaryColor != undefined ? this.primaryColor : "" }, onClick: this.login.bind(this), id: "login-btn", type: "button", class: "button" }, index.h("span", { style: { color: this.accentColor != undefined ? this.accentColor : "" }, class: "button-text" }, "Login")));
4193
4212
  }
4194
- })()), index.h("div", { key: '1ad6675f4e190df28410c54f7ad9f097578e0403', id: "appListModal", class: "modal" }, index.h("div", { key: '655f51c1d18372eca86610750d1ac3c8e1eeeefa', class: "modal-content" }, index.h("span", { key: 'bb850ddc02afdbbc04b5fbc6258d6ab2b1e92bfb', onClick: this.closeModal.bind(this), class: "close" }, "\u00D7"), index.h("div", { key: '4fdec67f888e554e1c8a3328ae2b55fb1a0fea4d', class: "box" }, index.h("input", { type: "radio", class: "tab-toggle", name: "tab-toggle", id: "tab1", checked: true }), index.h("ul", { key: '4317ec4e90f682b549aea49971d12426aaa5c0ef', class: "tab-list" }, index.h("li", { class: "tab-item" }, index.h("label", { class: "tab-trigger", htmlFor: "tab1" }, index.h("i", { class: "fa-solid fa-table-list menu-bar-icons" }), " ", this.config.menu.local.name))), index.h("div", { key: '8f1b8e0ec034d45a9c04776b90afcbd3cd9fea3e', class: "tab-container" }, index.h("div", { key: 'e59e81838b0c2fa419314503ab0c2d56143496cb', class: "tab-content" }, index.h("div", { key: 'f393c5497bfeddae25469d2d4475f9aacdf13629', class: "modal-body" }, !((_c = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.menu) === null || _b === void 0 ? void 0 : _b.local) === null || _c === void 0 ? void 0 : _c.enableCustomLocalMenu) ? (
4213
+ })()), index.h("div", { key: 'f98304920ef08f842700c5d26fe62a51cbbade96', id: "appListModal", class: "modal" }, index.h("div", { key: '2c4024b83e3cd0d638f4482d0e8907687ac12dd0', class: "modal-content" }, index.h("span", { key: '42a44145a7d7c33cae95344f02229d8163cc9607', onClick: this.closeModal.bind(this), class: "close" }, "\u00D7"), index.h("div", { key: 'ec3dbe646c76818ee90ec28e19671880670a2754', class: "box" }, index.h("input", { type: "radio", class: "tab-toggle", name: "tab-toggle", id: "tab1", checked: true }), index.h("ul", { key: 'c7dbcfd1b183bc6845cab0f17ef6f81dee30867f', class: "tab-list" }, index.h("li", { class: "tab-item" }, index.h("label", { class: "tab-trigger", htmlFor: "tab1" }, index.h("i", { class: "fa-solid fa-table-list menu-bar-icons" }), " ", this.config.menu.local.name))), index.h("div", { key: 'dc58df8e838c8babe3c679c6f1c498e286448cf3', class: "tab-container" }, index.h("div", { key: '486acbf570543ef0a92bd919e1c9c7973c87b3a7', class: "tab-content" }, index.h("div", { key: 'c9e093ce8d745097147405749e88ba35b1fc8679', class: "modal-body" }, !((_c = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.menu) === null || _b === void 0 ? void 0 : _b.local) === null || _c === void 0 ? void 0 : _c.enableCustomLocalMenu) ? (
4195
4214
  // <div>{this.localMenuLinks}</div>
4196
4215
  (_d = this.localMenuLinks) === null || _d === void 0 ? void 0 : _d.map((app, index$1) => {
4197
4216
  const isDisabled = !app.url;
@@ -4199,7 +4218,7 @@ const DashButtonComponent = class {
4199
4218
  })) : ((_e = this.config.menu.local.links) === null || _e === void 0 ? void 0 : _e.map((app, index$1) => (index.h("a", { key: index$1, class: "external-app-link", target: "_blank", rel: "noopener noreferrer", href: app.url }, index.h("div", { class: "modal-app" }, index.h("div", null, app.name)))))), !this.organizationUrl ? (index.h("div", null, index.h("h3", { class: "gray-text" }, "Organization Domain URL not set"), index.h("p", { class: "gray-text" }, "Please set your Organization Domain URL on the Portal profile page."))) : (((!((_h = (_g = (_f = this.config) === null || _f === void 0 ? void 0 : _f.menu) === null || _g === void 0 ? void 0 : _g.local) === null || _h === void 0 ? void 0 : _h.enableCustomLocalMenu) &&
4200
4219
  ((_k = (_j = this.localMenuLinks) === null || _j === void 0 ? void 0 : _j.length) !== null && _k !== void 0 ? _k : 0) === 0) ||
4201
4220
  (((_o = (_m = (_l = this.config) === null || _l === void 0 ? void 0 : _l.menu) === null || _m === void 0 ? void 0 : _m.local) === null || _o === void 0 ? void 0 : _o.enableCustomLocalMenu) &&
4202
- ((_t = (_s = (_r = (_q = (_p = this.config) === null || _p === void 0 ? void 0 : _p.menu) === null || _q === void 0 ? void 0 : _q.local) === null || _r === void 0 ? void 0 : _r.links) === null || _s === void 0 ? void 0 : _s.length) !== null && _t !== void 0 ? _t : 0) === 0)) && (index.h("div", null, index.h("h3", { class: "gray-text" }, "No installed ", ((_w = (_v = (_u = this.config) === null || _u === void 0 ? void 0 : _u.menu) === null || _v === void 0 ? void 0 : _v.local) === null || _w === void 0 ? void 0 : _w.name) || "menu", " found."), index.h("p", { class: "gray-text" }, "Please contact administration.")))))))))), index.h("div", { key: 'c47c1a2e57cbd3d42fcb19d559343a7104e092c0', id: "appPermissionErrorModal", class: "modal" }, index.h("div", { key: 'cd8a0b1837afc3089bda1bd4d9e7ec0c2a7c3f45', class: "modal-content" }, index.h("img", { key: 'e21aa2b61cbedff394e4cbbc6993fd06b3c3906e', src: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAGD0lEQVR4nO2cbU8TWRTH/W5WEAmF4nNiieFFoeBjYhQUWzUWYkpbDfGFCR9CoolvQF9aWgG3kMCG8LACC1ikuCuUh7bH/M/MmW131S2ZqTDjPcmkdub2tvPj3HP/55yJR44oU6ZMmTJlyg7YOsL9pI7+shkogGFzDqMAhhVAOsiQozwwrACS8sCwfXd+tYTDCiApDwwf/FJUSzisAJKjNhFlPzYF0KQpgCZNATRpCqBJUwBNmgJo0hRAk6YAmjQF0KkAs4uLtPz8OU2HQpRqaaFkQwPFq6v5SHo8fA7XVgYGKLu0dGC/81ABLORylB4cpInLl+nt0aP7OiauXKH00BAV8vlfE2AmkaCxpiYDSKK6mqaammjx+nX6FAzS348e0VYkwgf+jXO4Nun18lj53PuLF2kjmfx1AOa3t2mmt9cAkDxxghauXaPN3l7KxmJlHRgLmKNutzHPTCTCczsa4G4mQ6nWVr7h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Fq8GSX9koJqc7O9C6owNL0lO5CKsZTfzS7bqTt3+LPxornxKu2Cz6Oj5IymUkTLCOB54iWAKOIaMRE7JXbS/zOMwYYhMQ9/gOLOnPxBZh8/dlhb06+Vs9B6FIi4cYmJInGgEyGIkbHgc8idkWHgHHRecVsTMU/mwuuY3tYcv3TJWW1NGJrdJY113WtkdxaJU84BqSK7rRFXdc/Dd+w5rbFeDHG8rc2IiQj2UmwQsY1iKFIxlKSg46AjARfnkGGISOZHO6JRnkNiHjzPsY92iGFZoultLNu6OtZs+3m4CCIZnxGpIjGvUsv2UAEUQ9NblrSUoNDDQP4KT+TH2/QWJT/eFgjwNaRnnGHI4x3NzRXZbQ89QBg0GsQ2Wo+SnZR1uFycYbBI3kdv2XEAiw35KqQMGkDoYaCeaDzi29jIuziuYYyVua1jANrFFECTpgCaNAXQpCmAJk0BNGkKoElTACsNUB39ZTFQAMMW/78xypQpU6ZMmbIjP9e+AkAlsBlIjsPOAAAAAElFTkSuQmCC" }), index.h("h2", { key: '0ea76a87518b2a0c2a171bc0f40cb4767f6683e9', class: "green-text margin-b" }, "You don't have permission to access this application."), index.h("h3", { key: '1dc9d8f8f2ef3a34bf8cb887679c574a59fe5a75', class: "green-text" }, "Please contact the administration."), (this.config.defaultLink.url && this.showUnauthorizedModal) ?
4221
+ ((_t = (_s = (_r = (_q = (_p = this.config) === null || _p === void 0 ? void 0 : _p.menu) === null || _q === void 0 ? void 0 : _q.local) === null || _r === void 0 ? void 0 : _r.links) === null || _s === void 0 ? void 0 : _s.length) !== null && _t !== void 0 ? _t : 0) === 0)) && (index.h("div", null, index.h("h3", { class: "gray-text" }, "No installed ", ((_w = (_v = (_u = this.config) === null || _u === void 0 ? void 0 : _u.menu) === null || _v === void 0 ? void 0 : _v.local) === null || _w === void 0 ? void 0 : _w.name) || "menu", " found."), index.h("p", { class: "gray-text" }, "Please contact administration.")))))))))), index.h("div", { key: '349c7ff69d94c988a278677f497c0a9fef85c59c', id: "appPermissionErrorModal", class: "modal" }, index.h("div", { key: '788004858cf2f55f4e79cce0c023895274bab9ab', class: "modal-content" }, index.h("img", { key: '57ea43b0a21086eeaebe0585b9501967099ec999', src: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAGD0lEQVR4nO2cbU8TWRTH/W5WEAmF4nNiieFFoeBjYhQUWzUWYkpbDfGFCR9CoolvQF9aWgG3kMCG8LACC1ikuCuUh7bH/M/MmW131S2ZqTDjPcmkdub2tvPj3HP/55yJR44oU6ZMmTJlyg7YOsL9pI7+shkogGFzDqMAhhVAOsiQozwwrACS8sCwfXd+tYTDCiApDwwf/FJUSzisAJKjNhFlPzYF0KQpgCZNATRpCqBJUwBNmgJo0hRAk6YAmjQF0KkAs4uLtPz8OU2HQpRqaaFkQwPFq6v5SHo8fA7XVgYGKLu0dGC/81ABLORylB4cpInLl+nt0aP7OiauXKH00BAV8vlfE2AmkaCxpiYDSKK6mqaammjx+nX6FAzS348e0VYkwgf+jXO4Nun18lj53PuLF2kjmfx1AOa3t2mmt9cAkDxxghauXaPN3l7KxmJlHRgLmKNutzHPTCTCczsa4G4mQ6nWVr7h4WPHaL6trQTc+r17NOf30/iZMzTmdtNwVRWPA2Scm/H56FMgQNlolMfDO/9ob+cxmDPl99PuxoYzAe5mMrzcxOvWAALgolFauXmTxurry45/gPvnjRsG+LW7d3lOWdKVhHggAPPb24bnvW9ooL96evjGP4dC9NvJkwaY0fPnaa6vjzLJJG19+ED5bJY/u5NOUyYep/lnz2jk3Ll/4p/Hw/B4ru5unls8Mb+z4xyAM3rMg5cIvHRXFyVqavg8oKy+elXWjooxqy9f0luXy5gTm4xAFE+cjcWcATCTSGgxr6rKWLaAF9fj1u+BAOW2tsqeL7+7S5OdnRq8mhpaf/CA5xSI8EiJiRsjI/YGWMjlDKmCDUOWrXje3NOnRIWCaXh45biqL+f59nYjHlqtE38qwPTgoLHMeLeNRo2YB8+zEp7ExK1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zi29jIuziuYYyVua1jANrFFECTpgCaNAXQpCmAJk0BNGkKoElTACsNUB39ZTFQAMMW/78xypQpU6ZMmbIjP9e+AkAlsBlIjsPOAAAAAElFTkSuQmCC" }), index.h("h2", { key: 'c7663fb1503a0f0713350ac2ff2e52708c5425f9', class: "green-text margin-b" }, "You don't have permission to access this application."), index.h("h3", { key: '925b21fffdee5437664f690254821ffa63d736cb', class: "green-text" }, "Please contact the administration."), (this.config.defaultLink.url && this.showUnauthorizedModal) ?
4203
4222
  index.h("div", null, index.h("h4", { class: "gray-text" }, "You will be automatically redirected to the portal."), index.h("div", { id: "countdown" }, index.h("div", { id: "countdown-number" }), index.h("svg", null, index.h("circle", { r: "18", cx: "20", cy: "20" }))))
4204
4223
  : index.h("div", null))));
4205
4224
  }