dash-button-web 0.0.21 → 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.
- package/dist/cjs/dash-button.cjs.entry.js +50 -17
- package/dist/cjs/dash-button.cjs.entry.js.map +1 -1
- package/dist/collection/components/my-component/dash-button.js +30 -13
- package/dist/collection/components/my-component/dash-button.js.map +1 -1
- package/dist/collection/services/config.js +2 -0
- package/dist/collection/services/config.js.map +1 -1
- package/dist/collection/services/menu.js +18 -4
- package/dist/collection/services/menu.js.map +1 -1
- package/dist/components/dash-button.js +50 -17
- package/dist/components/dash-button.js.map +1 -1
- package/dist/esm/dash-button.entry.js +50 -17
- package/dist/esm/dash-button.entry.js.map +1 -1
- package/dist/types/services/config.d.ts +2 -0
- package/dist/web-compnont/p-2e8505f3.entry.js +10 -0
- package/dist/web-compnont/p-2e8505f3.entry.js.map +1 -0
- package/dist/web-compnont/web-compnont.esm.js +1 -1
- package/package.json +1 -1
- package/readme.md +25 -19
- package/dist/web-compnont/p-fc02a292.entry.js +0 -10
- package/dist/web-compnont/p-fc02a292.entry.js.map +0 -1
|
@@ -3895,6 +3895,8 @@ const DEFAULT_CONFIG = {
|
|
|
3895
3895
|
isLoading: true,
|
|
3896
3896
|
duration: 800
|
|
3897
3897
|
},
|
|
3898
|
+
allowedGlobalDomain: '',
|
|
3899
|
+
whitelistedUrls: ''
|
|
3898
3900
|
};
|
|
3899
3901
|
// Fetch config from API
|
|
3900
3902
|
class ConfigService {
|
|
@@ -3930,9 +3932,23 @@ class ConfigService {
|
|
|
3930
3932
|
}
|
|
3931
3933
|
const configService = ConfigService.getInstance();
|
|
3932
3934
|
|
|
3935
|
+
// const getRootDomain = (hostOrUrl: string): string => {
|
|
3936
|
+
// // Ensure we can parse it with URL
|
|
3937
|
+
// const url = hostOrUrl.startsWith("http") ? new URL(hostOrUrl) : new URL(`https://${hostOrUrl}`);
|
|
3938
|
+
// const hostname = url.hostname;
|
|
3939
|
+
// const port = url.port ? `:${url.port}` : "";
|
|
3940
|
+
// const parts = hostname.split(".");
|
|
3941
|
+
// // localhost → return with port
|
|
3942
|
+
// if (hostname === "localhost") return hostname + port;
|
|
3943
|
+
// // sslip.io → keep last 3 parts
|
|
3944
|
+
// if (hostname.endsWith(".sslip.io")) return parts.slice(-5).join(".") + port;
|
|
3945
|
+
// // Normal domains → remove first label
|
|
3946
|
+
// return parts.slice(1).join(".") + port;
|
|
3947
|
+
// };
|
|
3933
3948
|
const getRootDomain = (hostOrUrl) => {
|
|
3934
|
-
|
|
3935
|
-
|
|
3949
|
+
const url = hostOrUrl.startsWith("http")
|
|
3950
|
+
? new URL(hostOrUrl)
|
|
3951
|
+
: new URL(`https://${hostOrUrl}`);
|
|
3936
3952
|
const hostname = url.hostname;
|
|
3937
3953
|
const port = url.port ? `:${url.port}` : "";
|
|
3938
3954
|
const parts = hostname.split(".");
|
|
@@ -3942,8 +3958,8 @@ const getRootDomain = (hostOrUrl) => {
|
|
|
3942
3958
|
// sslip.io → keep last 3 parts
|
|
3943
3959
|
if (hostname.endsWith(".sslip.io"))
|
|
3944
3960
|
return parts.slice(-5).join(".") + port;
|
|
3945
|
-
//
|
|
3946
|
-
return
|
|
3961
|
+
// Keep full hostname
|
|
3962
|
+
return hostname + port;
|
|
3947
3963
|
};
|
|
3948
3964
|
const getUrlProtocol = (url, defaultProtocol = "https://") => {
|
|
3949
3965
|
if (!url)
|
|
@@ -4104,27 +4120,44 @@ const DashButtonComponent = class {
|
|
|
4104
4120
|
}
|
|
4105
4121
|
}
|
|
4106
4122
|
}
|
|
4123
|
+
// First, check global links
|
|
4124
|
+
// Then, check the token's organization URL
|
|
4125
|
+
// Finally, check against dashbutton configuration: allowedGlobalDomain and whitelistedUrls
|
|
4107
4126
|
validateAppAccessByUrl() {
|
|
4108
|
-
var _a, _b, _c, _d;
|
|
4109
|
-
const
|
|
4110
|
-
const
|
|
4127
|
+
var _a, _b, _c, _d, _e, _f;
|
|
4128
|
+
const normalizeUrl = (url) => url.replace(/\/+$/, '');
|
|
4129
|
+
const currentUrl = normalizeUrl(window.location.href);
|
|
4130
|
+
const currentOrigin = normalizeUrl(window.location.origin);
|
|
4111
4131
|
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) || [];
|
|
4112
|
-
|
|
4132
|
+
const allowedGlobalDomain = ((_d = this.config) === null || _d === void 0 ? void 0 : _d.allowedGlobalDomain) || '';
|
|
4133
|
+
const whitelistedUrls = ((_e = this.config) === null || _e === void 0 ? void 0 : _e.whitelistedUrls) || '';
|
|
4134
|
+
// First, check global links
|
|
4113
4135
|
const matchGlobal = globalLinks.some(link => {
|
|
4114
4136
|
try {
|
|
4115
|
-
const linkOrigin = new URL(link.url).origin;
|
|
4137
|
+
const linkOrigin = normalizeUrl(new URL(link.url).origin);
|
|
4116
4138
|
return currentOrigin === linkOrigin;
|
|
4117
4139
|
}
|
|
4118
4140
|
catch (_a) {
|
|
4119
4141
|
return false;
|
|
4120
4142
|
}
|
|
4121
4143
|
});
|
|
4122
|
-
//
|
|
4123
|
-
const tokenParsed = (
|
|
4144
|
+
// Then check the token organization URL
|
|
4145
|
+
const tokenParsed = (_f = this.keycloak) === null || _f === void 0 ? void 0 : _f.tokenParsed;
|
|
4124
4146
|
const allowedOrg = tokenParsed === null || tokenParsed === void 0 ? void 0 : tokenParsed.organizationUrl;
|
|
4125
|
-
const matchOrganization = allowedOrg && currentUrl.includes(allowedOrg);
|
|
4126
|
-
//
|
|
4127
|
-
const
|
|
4147
|
+
const matchOrganization = allowedOrg && currentUrl.includes(normalizeUrl(allowedOrg));
|
|
4148
|
+
// Check allowedGlobalDomain (single domain)
|
|
4149
|
+
const matchAllowedDomain = allowedGlobalDomain &&
|
|
4150
|
+
currentOrigin.includes(normalizeUrl(allowedGlobalDomain));
|
|
4151
|
+
// Check whitelistedUrls (comma-separated string)
|
|
4152
|
+
const whitelistedArray = whitelistedUrls
|
|
4153
|
+
? whitelistedUrls.split(',').map(url => normalizeUrl(url.trim()))
|
|
4154
|
+
: [];
|
|
4155
|
+
const matchWhitelisted = whitelistedArray.some(url => currentUrl.includes(url));
|
|
4156
|
+
// Final validation
|
|
4157
|
+
const isAllowed = matchGlobal ||
|
|
4158
|
+
matchOrganization ||
|
|
4159
|
+
matchAllowedDomain ||
|
|
4160
|
+
matchWhitelisted;
|
|
4128
4161
|
this.isRestricted = !isAllowed;
|
|
4129
4162
|
}
|
|
4130
4163
|
login() {
|
|
@@ -4146,7 +4179,7 @@ const DashButtonComponent = class {
|
|
|
4146
4179
|
}
|
|
4147
4180
|
render() {
|
|
4148
4181
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
4149
|
-
return h("div", { key: '
|
|
4182
|
+
return h("div", { key: '370786aa472fafd2bf9509a18bd62c87ac2893c7' }, h("div", { key: 'c0b091b19e7981ecc48e95c03c8d91e77e7a88df' }, (() => {
|
|
4150
4183
|
var _a, _b, _c, _d, _e, _f;
|
|
4151
4184
|
// GLOBAL LOADING SPINNER
|
|
4152
4185
|
if (this.isLoading) {
|
|
@@ -4173,7 +4206,7 @@ const DashButtonComponent = class {
|
|
|
4173
4206
|
else {
|
|
4174
4207
|
return (h("button", { style: { background: this.primaryColor != undefined ? this.primaryColor : "" }, onClick: this.login.bind(this), id: "login-btn", type: "button", class: "button" }, h("span", { style: { color: this.accentColor != undefined ? this.accentColor : "" }, class: "button-text" }, "Login")));
|
|
4175
4208
|
}
|
|
4176
|
-
})()), h("div", { key: '
|
|
4209
|
+
})()), h("div", { key: 'f98304920ef08f842700c5d26fe62a51cbbade96', id: "appListModal", class: "modal" }, h("div", { key: '2c4024b83e3cd0d638f4482d0e8907687ac12dd0', class: "modal-content" }, h("span", { key: '42a44145a7d7c33cae95344f02229d8163cc9607', onClick: this.closeModal.bind(this), class: "close" }, "\u00D7"), h("div", { key: 'ec3dbe646c76818ee90ec28e19671880670a2754', class: "box" }, h("input", { type: "radio", class: "tab-toggle", name: "tab-toggle", id: "tab1", checked: true }), h("ul", { key: 'c7dbcfd1b183bc6845cab0f17ef6f81dee30867f', class: "tab-list" }, h("li", { class: "tab-item" }, h("label", { class: "tab-trigger", htmlFor: "tab1" }, h("i", { class: "fa-solid fa-table-list menu-bar-icons" }), " ", this.config.menu.local.name))), h("div", { key: 'dc58df8e838c8babe3c679c6f1c498e286448cf3', class: "tab-container" }, h("div", { key: '486acbf570543ef0a92bd919e1c9c7973c87b3a7', class: "tab-content" }, 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) ? (
|
|
4177
4210
|
// <div>{this.localMenuLinks}</div>
|
|
4178
4211
|
(_d = this.localMenuLinks) === null || _d === void 0 ? void 0 : _d.map((app, index) => {
|
|
4179
4212
|
const isDisabled = !app.url;
|
|
@@ -4181,7 +4214,7 @@ const DashButtonComponent = class {
|
|
|
4181
4214
|
})) : ((_e = this.config.menu.local.links) === null || _e === void 0 ? void 0 : _e.map((app, index) => (h("a", { key: index, class: "external-app-link", target: "_blank", rel: "noopener noreferrer", href: app.url }, h("div", { class: "modal-app" }, h("div", null, app.name)))))), !this.organizationUrl ? (h("div", null, h("h3", { class: "gray-text" }, "Organization Domain URL not set"), 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) &&
|
|
4182
4215
|
((_k = (_j = this.localMenuLinks) === null || _j === void 0 ? void 0 : _j.length) !== null && _k !== void 0 ? _k : 0) === 0) ||
|
|
4183
4216
|
(((_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) &&
|
|
4184
|
-
((_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)) && (h("div", null, 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."), h("p", { class: "gray-text" }, "Please contact administration.")))))))))), h("div", { key: '
|
|
4217
|
+
((_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)) && (h("div", null, 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."), h("p", { class: "gray-text" }, "Please contact administration.")))))))))), h("div", { key: '349c7ff69d94c988a278677f497c0a9fef85c59c', id: "appPermissionErrorModal", class: "modal" }, h("div", { key: '788004858cf2f55f4e79cce0c023895274bab9ab', class: "modal-content" }, h("img", { key: '57ea43b0a21086eeaebe0585b9501967099ec999', src: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAGD0lEQVR4nO2cbU8TWRTH/W5WEAmF4nNiieFFoeBjYhQUWzUWYkpbDfGFCR9CoolvQF9aWgG3kMCG8LACC1ikuCuUh7bH/M/MmW131S2ZqTDjPcmkd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32AxjXS06QFLgZKUH9aPct7O3RVFfXf+BlHj6kZG2tBq+j47tpGs5LoYKrNpGI9v74cfsDHNazg+/dvFl4sNzmprHz2x5g8l9LWMTuzsePli7bYkMBgqVMfb39l3CqpeXbm0g8XhF439xEgkGjOmN7GTOjA4XU2Be8zs6y4MFmnzzRpJLfXypjenrsK6Qnvd4SSQGxCyFtNbxiIb1+/74mpL1e+wrp7NISp1ElqZwuZZB2WQkPZqRyevz7Eg5zCc22qVxxMUGWMRL94sTfKnjYfd+dPq15261bpcWEq1fJvuWsoSEt/3W7tRZlNMolJylxWQEPJTGRP6lTpwz5YpSz3ryxcUE1nzcaSeieFTeArIKH3Fq8GSX9koJqc7O9C6owNL0lO5CKsZTfzS7bqTt3+LPxornxKu2Cz6Oj5IymUkTLCOB54iWAKOIaMRE7JXbS/zOMwYYhMQ9/gOLOnPxBZh8/dlhb06+Vs9B6FIi4cYmJInGgEyGIkbHgc8idkWHgHHRecVsTMU/mwuuY3tYcv3TJWW1NGJrdJY113WtkdxaJU84BqSK7rRFXdc/Dd+w5rbFeDHG8rc2IiQj2UmwQsY1iKFIxlKSg46AjARfnkGGISOZHO6JRnkNiHjzPsY92iGFZoultLNu6OtZs+3m4CCIZnxGpIjGvUsv2UAEUQ9NblrSUoNDDQP4KT+TH2/QWJT/eFgjwNaRnnGHI4x3NzRXZbQ89QBg0GsQ2Wo+SnZR1uFycYbBI3kdv2XEAiw35KqQMGkDoYaCeaDzi29jIuziuYYyVua1jANrFFECTpgCaNAXQpCmAJk0BNGkKoElTACsNUB39ZTFQAMMW/78xypQpU6ZMmbIjP9e+AkAlsBlIjsPOAAAAAElFTkSuQmCC" }), h("h2", { key: 'c7663fb1503a0f0713350ac2ff2e52708c5425f9', class: "green-text margin-b" }, "You don't have permission to access this application."), h("h3", { key: '925b21fffdee5437664f690254821ffa63d736cb', class: "green-text" }, "Please contact the administration."), (this.config.defaultLink.url && this.showUnauthorizedModal) ?
|
|
4185
4218
|
h("div", null, h("h4", { class: "gray-text" }, "You will be automatically redirected to the portal."), h("div", { id: "countdown" }, h("div", { id: "countdown-number" }), h("svg", null, h("circle", { r: "18", cx: "20", cy: "20" }))))
|
|
4186
4219
|
: h("div", null))));
|
|
4187
4220
|
}
|