bruce-models 4.5.3 → 4.5.4
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/bruce-models.es5.js +70 -30
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +70 -30
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/api/api.js +1 -0
- package/dist/lib/api/api.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -1
- package/dist/lib/user/session.js +66 -27
- package/dist/lib/user/session.js.map +1 -1
- package/dist/lib/user/user.js +1 -1
- package/dist/lib/user/user.js.map +1 -1
- package/dist/types/api/api.d.ts +1 -0
- package/dist/types/bruce-models.d.ts +1 -1
- package/dist/types/user/session.d.ts +3 -2
- package/dist/types/user/user.d.ts +2 -1
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -90,6 +90,7 @@
|
|
|
90
90
|
Api.DEFAULT_CACHE_DURATION = 60 * 1000;
|
|
91
91
|
// The template client account is a container for default settings to reference.
|
|
92
92
|
Api.TEMPLATE_ACCOUNT_ID = "template";
|
|
93
|
+
Api.SUPER_ACCOUNT_ID = "hypeportal";
|
|
93
94
|
// Default session token header.
|
|
94
95
|
Api.ACCESS_TOKEN_HEADER = "X-Access-Token";
|
|
95
96
|
/**
|
|
@@ -10749,27 +10750,53 @@
|
|
|
10749
10750
|
* @returns
|
|
10750
10751
|
*/
|
|
10751
10752
|
function IsPermEnabled(params) {
|
|
10752
|
-
var _a, _b;
|
|
10753
|
+
var _a, _b, _c, _d, _e, _f;
|
|
10753
10754
|
let { session, accountId, perm } = params;
|
|
10754
10755
|
if (!perm) {
|
|
10755
10756
|
throw ("Perm is required.");
|
|
10756
10757
|
}
|
|
10757
10758
|
perm = perm.toLocaleUpperCase();
|
|
10758
|
-
|
|
10759
|
+
accountId = accountId.toLowerCase();
|
|
10760
|
+
// First we'll scan the user object for the account ID.
|
|
10761
|
+
if ((_b = (_a = session === null || session === void 0 ? void 0 : session.User) === null || _a === void 0 ? void 0 : _a.AccessPermissions) === null || _b === void 0 ? void 0 : _b.length) {
|
|
10762
|
+
for (let i = 0; i < session.User.AccessPermissions.length; i++) {
|
|
10763
|
+
const aPerms = session.User.AccessPermissions[i];
|
|
10764
|
+
const permsAccountId = String(aPerms["ClientAccount.ID"]).toLowerCase();
|
|
10765
|
+
// Found account, woo.
|
|
10766
|
+
if (permsAccountId == accountId) {
|
|
10767
|
+
// Check against the loaded perm array.
|
|
10768
|
+
// In newer version this always exists, but in some legacy versions it MIGHT not,
|
|
10769
|
+
//therefor we also do a group check after..
|
|
10770
|
+
if ((_c = aPerms.EnabledFeatures) === null || _c === void 0 ? void 0 : _c.length) {
|
|
10771
|
+
return aPerms.EnabledFeatures.findIndex(x => x.toLocaleUpperCase() == perm) > -1;
|
|
10772
|
+
}
|
|
10773
|
+
// Fallback to group check.
|
|
10774
|
+
if (((_d = aPerms.UserGroups) === null || _d === void 0 ? void 0 : _d.length) && typeof aPerms.UserGroups[0] != "string") {
|
|
10775
|
+
for (let j = 0; j < aPerms.UserGroups.length; j++) {
|
|
10776
|
+
const group = aPerms.UserGroups[j];
|
|
10777
|
+
if ((_e = group === null || group === void 0 ? void 0 : group.Features) === null || _e === void 0 ? void 0 : _e.length) {
|
|
10778
|
+
const gPerms = group.Features;
|
|
10779
|
+
if (gPerms && gPerms.findIndex(x => x.toLocaleUpperCase() == perm) > -1) {
|
|
10780
|
+
return true;
|
|
10781
|
+
}
|
|
10782
|
+
}
|
|
10783
|
+
}
|
|
10784
|
+
}
|
|
10785
|
+
}
|
|
10786
|
+
}
|
|
10787
|
+
}
|
|
10788
|
+
// Fallback to the session perm info.
|
|
10789
|
+
// This is deprecated and old as it's only for one account.
|
|
10790
|
+
const perms = session === null || session === void 0 ? void 0 : session.AccessPermissions;
|
|
10759
10791
|
if (!perms) {
|
|
10760
10792
|
return false;
|
|
10761
10793
|
}
|
|
10762
|
-
|
|
10763
|
-
|
|
10794
|
+
const pAccountId = String(perms["ClientAccount.ID"]).toLowerCase();
|
|
10795
|
+
if (pAccountId != accountId) {
|
|
10796
|
+
return false;
|
|
10764
10797
|
}
|
|
10765
|
-
|
|
10766
|
-
|
|
10767
|
-
if (typeof group != "string") {
|
|
10768
|
-
const features = group.Features;
|
|
10769
|
-
if (features && features.findIndex(x => x.toLocaleUpperCase() == perm) > -1) {
|
|
10770
|
-
return true;
|
|
10771
|
-
}
|
|
10772
|
-
}
|
|
10798
|
+
if ((_f = perms.EnabledFeatures) === null || _f === void 0 ? void 0 : _f.length) {
|
|
10799
|
+
return perms.EnabledFeatures.findIndex(x => x.toLocaleUpperCase() == perm) > -1;
|
|
10773
10800
|
}
|
|
10774
10801
|
return false;
|
|
10775
10802
|
}
|
|
@@ -10791,22 +10818,35 @@
|
|
|
10791
10818
|
return false;
|
|
10792
10819
|
}
|
|
10793
10820
|
perm = perm.toLocaleUpperCase();
|
|
10794
|
-
//
|
|
10795
|
-
|
|
10796
|
-
|
|
10797
|
-
return
|
|
10798
|
-
}
|
|
10799
|
-
//
|
|
10800
|
-
|
|
10801
|
-
|
|
10802
|
-
|
|
10803
|
-
|
|
10804
|
-
|
|
10805
|
-
|
|
10806
|
-
|
|
10807
|
-
|
|
10808
|
-
|
|
10809
|
-
|
|
10821
|
+
// First we'll scan the included super perms.
|
|
10822
|
+
const superPerms = session.HypeportalAccessPermisssions;
|
|
10823
|
+
if ((_a = superPerms === null || superPerms === void 0 ? void 0 : superPerms.EnabledFeatures) === null || _a === void 0 ? void 0 : _a.length) {
|
|
10824
|
+
return superPerms.EnabledFeatures.findIndex(x => x.toLocaleUpperCase() == perm) > -1;
|
|
10825
|
+
}
|
|
10826
|
+
// Now we'll fallback to digging through group to find the super group.
|
|
10827
|
+
if ((_c = (_b = session === null || session === void 0 ? void 0 : session.User) === null || _b === void 0 ? void 0 : _b.AccessPermissions) === null || _c === void 0 ? void 0 : _c.length) {
|
|
10828
|
+
for (let i = 0; i < session.User.AccessPermissions.length; i++) {
|
|
10829
|
+
const perms = session.User.AccessPermissions[i];
|
|
10830
|
+
// Newer API versions always specify accountId in the collections.
|
|
10831
|
+
// If it's set we can do a super account check early.
|
|
10832
|
+
if (perms["ClientAccount.ID"] != null) {
|
|
10833
|
+
const pAccountId = String(perms["ClientAccount.ID"]).toLowerCase();
|
|
10834
|
+
if (pAccountId != exports.Api.SUPER_ACCOUNT_ID) {
|
|
10835
|
+
continue;
|
|
10836
|
+
}
|
|
10837
|
+
}
|
|
10838
|
+
if ((_d = perms === null || perms === void 0 ? void 0 : perms.UserGroups) === null || _d === void 0 ? void 0 : _d.length) {
|
|
10839
|
+
for (let j = 0; j < perms.UserGroups.length; j++) {
|
|
10840
|
+
const group = perms.UserGroups[j];
|
|
10841
|
+
if (typeof group != "string") {
|
|
10842
|
+
const gAccountId = String(group["ClientAccount.ID"]).toLowerCase();
|
|
10843
|
+
if (gAccountId != exports.Api.SUPER_ACCOUNT_ID) {
|
|
10844
|
+
continue;
|
|
10845
|
+
}
|
|
10846
|
+
const features = group.Features;
|
|
10847
|
+
if (features && features.findIndex(x => x.toLocaleUpperCase() == perm) > -1) {
|
|
10848
|
+
return true;
|
|
10849
|
+
}
|
|
10810
10850
|
}
|
|
10811
10851
|
}
|
|
10812
10852
|
}
|
|
@@ -11066,7 +11106,7 @@
|
|
|
11066
11106
|
if ((_a = data.AccessPermissions) === null || _a === void 0 ? void 0 : _a.length) {
|
|
11067
11107
|
for (let i = 0; i < data.AccessPermissions.length; i++) {
|
|
11068
11108
|
const perm = data.AccessPermissions[i];
|
|
11069
|
-
if (!perm["UserGroup.ID"] && perm.UserGroups) {
|
|
11109
|
+
if (!perm["UserGroup.ID"] && perm.UserGroups && typeof perm.UserGroups != "string") {
|
|
11070
11110
|
perm["UserGroup.ID"] = [];
|
|
11071
11111
|
for (let j = 0; j < perm.UserGroups.length; j++) {
|
|
11072
11112
|
perm["UserGroup.ID"].push(perm.UserGroups[j].ID);
|
|
@@ -13415,7 +13455,7 @@
|
|
|
13415
13455
|
})(exports.DataSource || (exports.DataSource = {}));
|
|
13416
13456
|
|
|
13417
13457
|
// This is updated with the package.json version on build.
|
|
13418
|
-
const VERSION = "4.5.
|
|
13458
|
+
const VERSION = "4.5.4";
|
|
13419
13459
|
|
|
13420
13460
|
exports.VERSION = VERSION;
|
|
13421
13461
|
exports.AbstractApi = AbstractApi;
|