@feedmepos/mf-common 1.8.40 → 1.9.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.
- package/dist/App.vue.d.ts.map +1 -1
- package/dist/app.d.ts +2 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +988 -31
- package/dist/permission/permission.d.ts +101 -0
- package/dist/permission/permission.d.ts.map +1 -0
- package/dist/store.d.ts +28 -12
- package/dist/store.d.ts.map +1 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/package.json +3 -2
package/dist/app.js
CHANGED
@@ -485,6 +485,9 @@ FeedMeAuth._token = null;
|
|
485
485
|
FeedMeAuth.authStateChangeCallBackId = 1;
|
486
486
|
window.FeedMeAuthGlobal = FeedMeAuth;
|
487
487
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
488
|
+
function getDefaultExportFromCjs(x) {
|
489
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
490
|
+
}
|
488
491
|
function getAugmentedNamespace(n) {
|
489
492
|
if (n.__esModule)
|
490
493
|
return n;
|
@@ -44878,14 +44881,14 @@ var __importDefault = commonjsGlobal && commonjsGlobal.__importDefault || functi
|
|
44878
44881
|
return mod && mod.__esModule ? mod : { "default": mod };
|
44879
44882
|
};
|
44880
44883
|
Object.defineProperty(utils$3, "__esModule", { value: true });
|
44881
|
-
utils$3.clone = clone;
|
44884
|
+
utils$3.clone = clone$1;
|
44882
44885
|
utils$3.randomString = randomString;
|
44883
44886
|
utils$3.encode = encode$2;
|
44884
44887
|
utils$3.decode = decode;
|
44885
44888
|
utils$3.hexStringToBase64 = hexStringToBase64;
|
44886
44889
|
utils$3.base64ToHexString = base64ToHexString;
|
44887
44890
|
const fn_1 = __importDefault(fn$1);
|
44888
|
-
function clone(param) {
|
44891
|
+
function clone$1(param) {
|
44889
44892
|
return JSON.parse(JSON.stringify(param));
|
44890
44893
|
}
|
44891
44894
|
function randomString(length = 10) {
|
@@ -47561,6 +47564,7 @@ class FmpUser {
|
|
47561
47564
|
__publicField(this, "photoURL");
|
47562
47565
|
__publicField(this, "displayName");
|
47563
47566
|
__publicField(this, "phoneNumber");
|
47567
|
+
__publicField(this, "_role");
|
47564
47568
|
__publicField(this, "role");
|
47565
47569
|
__publicField(this, "_adminPermissions", []);
|
47566
47570
|
__publicField(this, "_permissions", []);
|
@@ -47569,6 +47573,7 @@ class FmpUser {
|
|
47569
47573
|
this.photoURL = user2.photoURL;
|
47570
47574
|
this.displayName = user2.displayName;
|
47571
47575
|
this.phoneNumber = user2.phoneNumber;
|
47576
|
+
this._role = role;
|
47572
47577
|
this.role = {
|
47573
47578
|
isAdmin: role === "admin",
|
47574
47579
|
isStaff: role === "staff",
|
@@ -47611,12 +47616,15 @@ const coreStore = defineStore("portal-core", () => {
|
|
47611
47616
|
throw new Error("User already logged in");
|
47612
47617
|
}
|
47613
47618
|
await new Promise((resolve) => {
|
47614
|
-
|
47615
|
-
if (!user2)
|
47616
|
-
|
47617
|
-
|
47618
|
-
|
47619
|
-
|
47619
|
+
FeedMeAuth.onAuthStateChanged(async (user2) => {
|
47620
|
+
if (sessionUser.value && !user2) {
|
47621
|
+
window.location.reload();
|
47622
|
+
} else if (!sessionUser.value && user2) {
|
47623
|
+
await setUser(user2);
|
47624
|
+
resolve(user2);
|
47625
|
+
} else if (user2) {
|
47626
|
+
await setUser(user2);
|
47627
|
+
}
|
47620
47628
|
});
|
47621
47629
|
FeedMeAuth.signIn({ waitForInitialAuthState: true });
|
47622
47630
|
});
|
@@ -47627,7 +47635,6 @@ const coreStore = defineStore("portal-core", () => {
|
|
47627
47635
|
}
|
47628
47636
|
async function signOut() {
|
47629
47637
|
FeedMeAuth.signOut();
|
47630
|
-
await setUser(null);
|
47631
47638
|
}
|
47632
47639
|
async function setUser(user2) {
|
47633
47640
|
if (user2) {
|
@@ -47636,31 +47643,29 @@ const coreStore = defineStore("portal-core", () => {
|
|
47636
47643
|
}
|
47637
47644
|
const { customClaims } = await FeedMeAuth.getUserClaims();
|
47638
47645
|
const agents = await readAvailableAgents();
|
47639
|
-
|
47646
|
+
const _sessionUser = new FmpUser(user2, customClaims ?? {}, agents);
|
47640
47647
|
await readBusinesses();
|
47641
|
-
await fetchUserAdminPermissions();
|
47642
|
-
|
47648
|
+
await Promise.all([fetchUserAdminPermissions(_sessionUser), fetchUserPermissions(_sessionUser)]);
|
47649
|
+
sessionUser.value = _sessionUser;
|
47643
47650
|
} else {
|
47644
47651
|
sessionUser.value = null;
|
47645
47652
|
businesses.value = [];
|
47646
47653
|
changeBusiness(void 0);
|
47647
47654
|
}
|
47648
47655
|
}
|
47649
|
-
async function fetchUserAdminPermissions() {
|
47650
|
-
const user2 = sessionUser.value;
|
47656
|
+
async function fetchUserAdminPermissions(_sessionUser) {
|
47657
|
+
const user2 = _sessionUser || sessionUser.value;
|
47651
47658
|
if (!user2)
|
47652
47659
|
return;
|
47653
47660
|
const adminPermissions = await readUserAdminPermission();
|
47654
47661
|
user2.setAdminPermisssions(adminPermissions);
|
47655
|
-
sessionUser.value = user2;
|
47656
47662
|
}
|
47657
|
-
async function fetchUserPermissions() {
|
47658
|
-
const user2 = sessionUser.value;
|
47663
|
+
async function fetchUserPermissions(_sessionUser) {
|
47664
|
+
const user2 = _sessionUser || sessionUser.value;
|
47659
47665
|
if (!user2 || !currentBusiness.value)
|
47660
47666
|
return;
|
47661
47667
|
const businessPermissions = await readUserBusinessPermission(currentBusiness.value._id);
|
47662
47668
|
user2.setPermissions(businessPermissions);
|
47663
|
-
sessionUser.value = user2;
|
47664
47669
|
}
|
47665
47670
|
const namespace = ref("dev");
|
47666
47671
|
function setNamespace(ns) {
|
@@ -50850,9 +50855,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
50850
50855
|
}
|
50851
50856
|
async function logout() {
|
50852
50857
|
await coreStore2.signOut();
|
50853
|
-
window.location.replace(
|
50854
|
-
`${FeedMeAuth.baseUrl}/login?fm_redirect=${encodeURIComponent(window.location.href)}`
|
50855
|
-
);
|
50856
50858
|
}
|
50857
50859
|
async function gotoPortalV2() {
|
50858
50860
|
const isDev = coreStore2.namespace.value === "dev";
|
@@ -50860,16 +50862,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
50860
50862
|
}
|
50861
50863
|
const dropdownOpened = ref(false);
|
50862
50864
|
const router = useRouter();
|
50863
|
-
onMounted(async () => {
|
50864
|
-
FeedMeAuth.onAuthStateChanged(async (user22) => {
|
50865
|
-
var _a;
|
50866
|
-
if (((_a = coreStore2.sessionUser.value) == null ? void 0 : _a.id) === (user22 == null ? void 0 : user22.id))
|
50867
|
-
return;
|
50868
|
-
await coreStore2.setUser(user22);
|
50869
|
-
});
|
50870
|
-
if (!coreStore2.sessionUser.value)
|
50871
|
-
signIn();
|
50872
|
-
});
|
50873
50865
|
function onSelectApp(app) {
|
50874
50866
|
if (app.external) {
|
50875
50867
|
window.location.href = app.path;
|
@@ -50911,6 +50903,964 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
50911
50903
|
};
|
50912
50904
|
}
|
50913
50905
|
});
|
50906
|
+
var sift_csp_min = { exports: {} };
|
50907
|
+
(function(module, exports) {
|
50908
|
+
!function(n, t) {
|
50909
|
+
module.exports = t();
|
50910
|
+
}(commonjsGlobal, function() {
|
50911
|
+
return function(n) {
|
50912
|
+
var t = {};
|
50913
|
+
function r(e) {
|
50914
|
+
if (t[e])
|
50915
|
+
return t[e].exports;
|
50916
|
+
var o = t[e] = { i: e, l: false, exports: {} };
|
50917
|
+
return n[e].call(o.exports, o, o.exports, r), o.l = true, o.exports;
|
50918
|
+
}
|
50919
|
+
return r.m = n, r.c = t, r.d = function(n2, t2, e) {
|
50920
|
+
r.o(n2, t2) || Object.defineProperty(n2, t2, { enumerable: true, get: e });
|
50921
|
+
}, r.r = function(n2) {
|
50922
|
+
"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(n2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(n2, "__esModule", { value: true });
|
50923
|
+
}, r.t = function(n2, t2) {
|
50924
|
+
if (1 & t2 && (n2 = r(n2)), 8 & t2)
|
50925
|
+
return n2;
|
50926
|
+
if (4 & t2 && "object" == typeof n2 && n2 && n2.__esModule)
|
50927
|
+
return n2;
|
50928
|
+
var e = /* @__PURE__ */ Object.create(null);
|
50929
|
+
if (r.r(e), Object.defineProperty(e, "default", { enumerable: true, value: n2 }), 2 & t2 && "string" != typeof n2)
|
50930
|
+
for (var o in n2)
|
50931
|
+
r.d(
|
50932
|
+
e,
|
50933
|
+
o,
|
50934
|
+
(function(t3) {
|
50935
|
+
return n2[t3];
|
50936
|
+
}).bind(null, o)
|
50937
|
+
);
|
50938
|
+
return e;
|
50939
|
+
}, r.n = function(n2) {
|
50940
|
+
var t2 = n2 && n2.__esModule ? function() {
|
50941
|
+
return n2.default;
|
50942
|
+
} : function() {
|
50943
|
+
return n2;
|
50944
|
+
};
|
50945
|
+
return r.d(t2, "a", t2), t2;
|
50946
|
+
}, r.o = function(n2, t2) {
|
50947
|
+
return Object.prototype.hasOwnProperty.call(n2, t2);
|
50948
|
+
}, r.p = "", r(r.s = 0);
|
50949
|
+
}([
|
50950
|
+
function(n, t, r) {
|
50951
|
+
n.exports = r(1);
|
50952
|
+
},
|
50953
|
+
function(n, t, r) {
|
50954
|
+
function e(n2) {
|
50955
|
+
return (e = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(n3) {
|
50956
|
+
return typeof n3;
|
50957
|
+
} : function(n3) {
|
50958
|
+
return n3 && "function" == typeof Symbol && n3.constructor === Symbol && n3 !== Symbol.prototype ? "symbol" : typeof n3;
|
50959
|
+
})(n2);
|
50960
|
+
}
|
50961
|
+
function o(n2) {
|
50962
|
+
var t2 = "[object " + n2 + "]";
|
50963
|
+
return function(n3) {
|
50964
|
+
return Object.prototype.toString.call(n3) === t2;
|
50965
|
+
};
|
50966
|
+
}
|
50967
|
+
r.r(t), r.d(t, "default", function() {
|
50968
|
+
return m;
|
50969
|
+
}), r.d(t, "compare", function() {
|
50970
|
+
return j;
|
50971
|
+
}), r.d(t, "comparable", function() {
|
50972
|
+
return O;
|
50973
|
+
});
|
50974
|
+
var u = o("Array"), i = o("Object"), f = o("Function");
|
50975
|
+
function c(n2, t2) {
|
50976
|
+
return f(n2.get) ? n2.get(t2) : n2[t2];
|
50977
|
+
}
|
50978
|
+
function a(n2) {
|
50979
|
+
return function(t2, r2) {
|
50980
|
+
if (!u(r2) || !r2.length)
|
50981
|
+
return n2(t2, r2);
|
50982
|
+
for (var e2 = 0, o2 = r2.length; e2 < o2; e2++)
|
50983
|
+
if (n2(t2, c(r2, e2)))
|
50984
|
+
return true;
|
50985
|
+
return false;
|
50986
|
+
};
|
50987
|
+
}
|
50988
|
+
function l(n2) {
|
50989
|
+
return function(t2, r2) {
|
50990
|
+
if (!u(r2) || !r2.length)
|
50991
|
+
return n2(t2, r2);
|
50992
|
+
for (var e2 = 0, o2 = r2.length; e2 < o2; e2++)
|
50993
|
+
if (!n2(t2, c(r2, e2)))
|
50994
|
+
return false;
|
50995
|
+
return true;
|
50996
|
+
};
|
50997
|
+
}
|
50998
|
+
function p(n2, t2, r2, e2) {
|
50999
|
+
return n2.validate(n2.options, t2, r2, e2);
|
51000
|
+
}
|
51001
|
+
var s = {
|
51002
|
+
$eq: a(function(n2, t2) {
|
51003
|
+
return n2(t2);
|
51004
|
+
}),
|
51005
|
+
$ne: l(function(n2, t2) {
|
51006
|
+
return n2(t2);
|
51007
|
+
}),
|
51008
|
+
$gt: a(function(n2, t2) {
|
51009
|
+
return n2(t2);
|
51010
|
+
}),
|
51011
|
+
$gte: a(function(n2, t2) {
|
51012
|
+
return n2(t2);
|
51013
|
+
}),
|
51014
|
+
$lt: a(function(n2, t2) {
|
51015
|
+
return n2(t2);
|
51016
|
+
}),
|
51017
|
+
$lte: a(function(n2, t2) {
|
51018
|
+
return n2(t2);
|
51019
|
+
}),
|
51020
|
+
$mod: a(function(n2, t2) {
|
51021
|
+
return n2(t2);
|
51022
|
+
}),
|
51023
|
+
$in: function(n2, t2) {
|
51024
|
+
return n2(t2);
|
51025
|
+
},
|
51026
|
+
$nin: function(n2, t2) {
|
51027
|
+
return n2(t2);
|
51028
|
+
},
|
51029
|
+
$not: function(n2, t2, r2, e2) {
|
51030
|
+
return n2(t2, r2, e2);
|
51031
|
+
},
|
51032
|
+
$type: function(n2, t2) {
|
51033
|
+
return n2(t2);
|
51034
|
+
},
|
51035
|
+
$all: function(n2, t2, r2, e2) {
|
51036
|
+
return s.$and(n2, t2, r2, e2);
|
51037
|
+
},
|
51038
|
+
$size: function(n2, t2) {
|
51039
|
+
return !!t2 && n2 === t2.length;
|
51040
|
+
},
|
51041
|
+
$or: function(n2, t2, r2, e2) {
|
51042
|
+
for (var o2 = 0, u2 = n2.length; o2 < u2; o2++)
|
51043
|
+
if (p(c(n2, o2), t2, r2, e2))
|
51044
|
+
return true;
|
51045
|
+
return false;
|
51046
|
+
},
|
51047
|
+
$nor: function(n2, t2, r2, e2) {
|
51048
|
+
return !s.$or(n2, t2, r2, e2);
|
51049
|
+
},
|
51050
|
+
$and: function(n2, t2, r2, e2) {
|
51051
|
+
for (var o2 = 0, u2 = n2.length; o2 < u2; o2++)
|
51052
|
+
if (!p(c(n2, o2), t2, r2, e2))
|
51053
|
+
return false;
|
51054
|
+
return true;
|
51055
|
+
},
|
51056
|
+
$regex: a(function(n2, t2) {
|
51057
|
+
return "string" == typeof t2 && n2.test(t2);
|
51058
|
+
}),
|
51059
|
+
$where: function(n2, t2, r2, e2) {
|
51060
|
+
return n2.call(t2, t2, r2, e2);
|
51061
|
+
},
|
51062
|
+
$elemMatch: function(n2, t2, r2, e2) {
|
51063
|
+
return u(t2) ? !!~function(n3, t3) {
|
51064
|
+
for (var r3 = 0; r3 < n3.length; r3++) {
|
51065
|
+
c(n3, r3);
|
51066
|
+
if (p(t3, c(n3, r3)))
|
51067
|
+
return r3;
|
51068
|
+
}
|
51069
|
+
return -1;
|
51070
|
+
}(t2, n2) : p(n2, t2, r2, e2);
|
51071
|
+
},
|
51072
|
+
$exists: function(n2, t2, r2, e2) {
|
51073
|
+
return e2.hasOwnProperty(r2) === n2;
|
51074
|
+
}
|
51075
|
+
}, g = {
|
51076
|
+
$eq: function(n2, t2, r2) {
|
51077
|
+
var e2 = r2.comparable, o2 = r2.compare;
|
51078
|
+
return n2 instanceof RegExp ? a(function(t3) {
|
51079
|
+
return "string" == typeof t3 && n2.test(t3);
|
51080
|
+
}) : n2 instanceof Function ? a(n2) : u(n2) && !n2.length ? a(function(n3) {
|
51081
|
+
return u(n3) && !n3.length;
|
51082
|
+
}) : a(
|
51083
|
+
null === n2 ? function(n3) {
|
51084
|
+
return null == n3;
|
51085
|
+
} : function(t3) {
|
51086
|
+
return 0 === o2(e2(t3), e2(n2));
|
51087
|
+
}
|
51088
|
+
);
|
51089
|
+
},
|
51090
|
+
$gt: function(n2, t2, r2) {
|
51091
|
+
var e2 = r2.comparable, o2 = r2.compare;
|
51092
|
+
return function(t3) {
|
51093
|
+
return o2(e2(t3), e2(n2)) > 0;
|
51094
|
+
};
|
51095
|
+
},
|
51096
|
+
$gte: function(n2, t2, r2) {
|
51097
|
+
var e2 = r2.comparable, o2 = r2.compare;
|
51098
|
+
return function(t3) {
|
51099
|
+
return o2(e2(t3), e2(n2)) >= 0;
|
51100
|
+
};
|
51101
|
+
},
|
51102
|
+
$lt: function(n2, t2, r2) {
|
51103
|
+
var e2 = r2.comparable, o2 = r2.compare;
|
51104
|
+
return function(t3) {
|
51105
|
+
return o2(e2(t3), e2(n2)) < 0;
|
51106
|
+
};
|
51107
|
+
},
|
51108
|
+
$lte: function(n2, t2, r2) {
|
51109
|
+
var e2 = r2.comparable, o2 = r2.compare;
|
51110
|
+
return function(t3) {
|
51111
|
+
return o2(e2(t3), e2(n2)) <= 0;
|
51112
|
+
};
|
51113
|
+
},
|
51114
|
+
$in: function(n2, t2, r2) {
|
51115
|
+
var o2 = r2.comparable;
|
51116
|
+
return function(t3) {
|
51117
|
+
if (!(t3 instanceof Array)) {
|
51118
|
+
var u2 = o2(t3);
|
51119
|
+
if (u2 === t3 && "object" === e(t3)) {
|
51120
|
+
for (f2 = n2.length; f2--; )
|
51121
|
+
if (String(n2[f2]) === String(t3) && "[object Object]" !== String(t3))
|
51122
|
+
return true;
|
51123
|
+
}
|
51124
|
+
if (void 0 === u2) {
|
51125
|
+
for (f2 = n2.length; f2--; )
|
51126
|
+
if (null == n2[f2])
|
51127
|
+
return true;
|
51128
|
+
}
|
51129
|
+
for (f2 = n2.length; f2--; ) {
|
51130
|
+
var i2 = p(h(c(n2, f2), r2), u2, f2, n2);
|
51131
|
+
if (i2 && "[object Object]" !== String(i2) && "[object Object]" !== String(u2))
|
51132
|
+
return true;
|
51133
|
+
}
|
51134
|
+
return !!~n2.indexOf(u2);
|
51135
|
+
}
|
51136
|
+
for (var f2 = t3.length; f2--; )
|
51137
|
+
if (~n2.indexOf(o2(c(t3, f2))))
|
51138
|
+
return true;
|
51139
|
+
return false;
|
51140
|
+
};
|
51141
|
+
},
|
51142
|
+
$nin: function(n2, t2, r2) {
|
51143
|
+
var e2 = g.$in(n2, t2, r2);
|
51144
|
+
return function(n3, t3, r3, o2) {
|
51145
|
+
return !e2(n3, t3, r3, o2);
|
51146
|
+
};
|
51147
|
+
},
|
51148
|
+
$mod: function(n2) {
|
51149
|
+
return function(t2) {
|
51150
|
+
return t2 % n2[0] == n2[1];
|
51151
|
+
};
|
51152
|
+
},
|
51153
|
+
$ne: function(n2, t2, r2) {
|
51154
|
+
var e2 = g.$eq(n2, t2, r2);
|
51155
|
+
return l(function(n3, t3, r3, o2) {
|
51156
|
+
return !e2(n3, t3, r3, o2);
|
51157
|
+
});
|
51158
|
+
},
|
51159
|
+
$and: function(n2, t2, r2) {
|
51160
|
+
return n2.map(d(r2));
|
51161
|
+
},
|
51162
|
+
$all: function(n2, t2, r2) {
|
51163
|
+
return g.$and(n2, t2, r2);
|
51164
|
+
},
|
51165
|
+
$or: function(n2, t2, r2) {
|
51166
|
+
return n2.map(d(r2));
|
51167
|
+
},
|
51168
|
+
$nor: function(n2, t2, r2) {
|
51169
|
+
return n2.map(d(r2));
|
51170
|
+
},
|
51171
|
+
$not: function(n2, t2, r2) {
|
51172
|
+
var e2 = d(r2)(n2);
|
51173
|
+
return function(n3, t3, r3) {
|
51174
|
+
return !p(e2, n3, t3, r3);
|
51175
|
+
};
|
51176
|
+
},
|
51177
|
+
$type: function(n2) {
|
51178
|
+
return function(t2, r2, e2) {
|
51179
|
+
return null != t2 && (t2 instanceof n2 || t2.constructor == n2);
|
51180
|
+
};
|
51181
|
+
},
|
51182
|
+
$regex: function(n2, t2) {
|
51183
|
+
return new RegExp(n2, t2.$options);
|
51184
|
+
},
|
51185
|
+
$where: function(n2) {
|
51186
|
+
if ("function" == typeof n2)
|
51187
|
+
return n2;
|
51188
|
+
throw new Error(
|
51189
|
+
'In CSP mode, sift does not support strings in "$where" condition'
|
51190
|
+
);
|
51191
|
+
},
|
51192
|
+
$elemMatch: function(n2, t2, r2) {
|
51193
|
+
return d(r2)(n2);
|
51194
|
+
},
|
51195
|
+
$exists: function(n2) {
|
51196
|
+
return !!n2;
|
51197
|
+
}
|
51198
|
+
};
|
51199
|
+
function v(n2, t2) {
|
51200
|
+
return { options: n2, validate: t2 };
|
51201
|
+
}
|
51202
|
+
function $(n2, t2) {
|
51203
|
+
var r2 = n2.keyPath, e2 = n2.child, o2 = n2.query, i2 = [];
|
51204
|
+
if (function n3(t3, r3, e3, o3, i3) {
|
51205
|
+
if (e3 === r3.length || null == t3)
|
51206
|
+
return void i3.push([t3, r3[e3 - 1], o3]);
|
51207
|
+
var f3 = c(r3, e3);
|
51208
|
+
if (u(t3) && isNaN(Number(f3)))
|
51209
|
+
for (var a3 = 0, l3 = t3.length; a3 < l3; a3++)
|
51210
|
+
n3(c(t3, a3), r3, e3, t3, i3);
|
51211
|
+
else
|
51212
|
+
n3(c(t3, f3), r3, e3 + 1, t3, i3);
|
51213
|
+
}(t2, r2, 0, t2, i2), 1 === i2.length) {
|
51214
|
+
var f2 = i2[0];
|
51215
|
+
return p(e2, f2[0], f2[1], f2[2]);
|
51216
|
+
}
|
51217
|
+
for (var a2 = o2 && void 0 !== o2.$ne, l2 = a2, s2 = 0; s2 < i2.length; s2++) {
|
51218
|
+
var g2 = i2[s2], v2 = p(e2, g2[0], g2[1], g2[2]);
|
51219
|
+
a2 ? l2 &= v2 : l2 |= v2;
|
51220
|
+
}
|
51221
|
+
return l2;
|
51222
|
+
}
|
51223
|
+
function b(n2, t2, r2) {
|
51224
|
+
return v({ keyPath: n2, child: t2, query: r2 }, $);
|
51225
|
+
}
|
51226
|
+
function d(n2) {
|
51227
|
+
var t2 = n2.comparable, r2 = n2.expressions, e2 = function(n3) {
|
51228
|
+
var t3;
|
51229
|
+
return (!n3 || (!(t3 = n3) || t3.constructor !== Object && t3.constructor !== Array && "function Object() { [native code] }" !== t3.constructor.toString() && "function Array() { [native code] }" !== t3.constructor.toString() || t3.toJSON)) && (n3 = { $eq: n3 }), n3;
|
51230
|
+
}, o2 = function(e3) {
|
51231
|
+
e3 = t2(e3);
|
51232
|
+
var o3 = [];
|
51233
|
+
for (var i2 in e3) {
|
51234
|
+
var f2 = e3[i2];
|
51235
|
+
if ("$options" !== i2) {
|
51236
|
+
var c2 = s[i2] || n2 && r2 && r2[i2];
|
51237
|
+
if (c2)
|
51238
|
+
g[i2] && (f2 = g[i2](f2, e3, n2)), o3.push(v(t2(f2), c2));
|
51239
|
+
else {
|
51240
|
+
if (36 === i2.charCodeAt(0))
|
51241
|
+
throw new Error("Unknown operation " + i2);
|
51242
|
+
var a2 = i2.split(".");
|
51243
|
+
o3.push(b(a2, u2(f2), f2));
|
51244
|
+
}
|
51245
|
+
}
|
51246
|
+
}
|
51247
|
+
return 1 === o3.length ? o3[0] : v(o3, s.$and);
|
51248
|
+
}, u2 = function(n3) {
|
51249
|
+
return n3 = e2(n3), -1 === function n4(t3, r3) {
|
51250
|
+
if (!i(t3))
|
51251
|
+
return r3;
|
51252
|
+
for (var e3 in t3)
|
51253
|
+
r3.push(e3), n4(t3[e3], r3);
|
51254
|
+
return r3;
|
51255
|
+
}(n3, []).join(",").search(/[$.]/) ? v(n3, y) : o2(n3);
|
51256
|
+
};
|
51257
|
+
return function(n3) {
|
51258
|
+
return o2(e2(n3));
|
51259
|
+
};
|
51260
|
+
}
|
51261
|
+
function y(n2, t2) {
|
51262
|
+
if (Object.prototype.toString.call(n2) !== Object.prototype.toString.call(t2))
|
51263
|
+
return false;
|
51264
|
+
if (i(n2)) {
|
51265
|
+
if (Object.keys(n2).length !== Object.keys(t2).length)
|
51266
|
+
return false;
|
51267
|
+
for (var r2 in n2)
|
51268
|
+
if (!y(n2[r2], t2[r2]))
|
51269
|
+
return false;
|
51270
|
+
return true;
|
51271
|
+
}
|
51272
|
+
if (u(n2)) {
|
51273
|
+
if (n2.length !== t2.length)
|
51274
|
+
return false;
|
51275
|
+
for (var e2 = 0, o2 = n2.length; e2 < o2; e2++)
|
51276
|
+
if (!y(n2[e2], t2[e2]))
|
51277
|
+
return false;
|
51278
|
+
return true;
|
51279
|
+
}
|
51280
|
+
return n2 === t2;
|
51281
|
+
}
|
51282
|
+
function h(n2, t2) {
|
51283
|
+
var r2 = d(t2)(n2);
|
51284
|
+
return t2 && t2.select && (r2 = {
|
51285
|
+
options: r2,
|
51286
|
+
validate: function(n3, r3, e2, o2) {
|
51287
|
+
return p(n3, r3 && t2.select(r3), e2, o2);
|
51288
|
+
}
|
51289
|
+
}), r2;
|
51290
|
+
}
|
51291
|
+
function m(n2, t2) {
|
51292
|
+
var r2 = h(n2, t2 = Object.assign({ compare: j, comparable: O }, t2));
|
51293
|
+
return function(n3, t3, e2) {
|
51294
|
+
return p(r2, n3, t3, e2);
|
51295
|
+
};
|
51296
|
+
}
|
51297
|
+
function j(n2, t2) {
|
51298
|
+
if (y(n2, t2))
|
51299
|
+
return 0;
|
51300
|
+
if (e(n2) === e(t2)) {
|
51301
|
+
if (n2 > t2)
|
51302
|
+
return 1;
|
51303
|
+
if (n2 < t2)
|
51304
|
+
return -1;
|
51305
|
+
}
|
51306
|
+
}
|
51307
|
+
function O(n2) {
|
51308
|
+
return n2 instanceof Date ? n2.getTime() : u(n2) ? n2.map(O) : n2 && "function" == typeof n2.toJSON ? n2.toJSON() : n2;
|
51309
|
+
}
|
51310
|
+
}
|
51311
|
+
]);
|
51312
|
+
});
|
51313
|
+
})(sift_csp_min);
|
51314
|
+
var sift_csp_minExports = sift_csp_min.exports;
|
51315
|
+
const sift = /* @__PURE__ */ getDefaultExportFromCjs(sift_csp_minExports);
|
51316
|
+
function _defineProperties(target, props) {
|
51317
|
+
for (var i = 0; i < props.length; i++) {
|
51318
|
+
var descriptor = props[i];
|
51319
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
51320
|
+
descriptor.configurable = true;
|
51321
|
+
if ("value" in descriptor)
|
51322
|
+
descriptor.writable = true;
|
51323
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
51324
|
+
}
|
51325
|
+
}
|
51326
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
51327
|
+
if (protoProps)
|
51328
|
+
_defineProperties(Constructor.prototype, protoProps);
|
51329
|
+
if (staticProps)
|
51330
|
+
_defineProperties(Constructor, staticProps);
|
51331
|
+
return Constructor;
|
51332
|
+
}
|
51333
|
+
function _inheritsLoose(subClass, superClass) {
|
51334
|
+
subClass.prototype = Object.create(superClass.prototype);
|
51335
|
+
subClass.prototype.constructor = subClass;
|
51336
|
+
subClass.__proto__ = superClass;
|
51337
|
+
}
|
51338
|
+
function _getPrototypeOf(o) {
|
51339
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o2) {
|
51340
|
+
return o2.__proto__ || Object.getPrototypeOf(o2);
|
51341
|
+
};
|
51342
|
+
return _getPrototypeOf(o);
|
51343
|
+
}
|
51344
|
+
function _setPrototypeOf(o, p) {
|
51345
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
|
51346
|
+
o2.__proto__ = p2;
|
51347
|
+
return o2;
|
51348
|
+
};
|
51349
|
+
return _setPrototypeOf(o, p);
|
51350
|
+
}
|
51351
|
+
function isNativeReflectConstruct() {
|
51352
|
+
if (typeof Reflect === "undefined" || !Reflect.construct)
|
51353
|
+
return false;
|
51354
|
+
if (Reflect.construct.sham)
|
51355
|
+
return false;
|
51356
|
+
if (typeof Proxy === "function")
|
51357
|
+
return true;
|
51358
|
+
try {
|
51359
|
+
Date.prototype.toString.call(Reflect.construct(Date, [], function() {
|
51360
|
+
}));
|
51361
|
+
return true;
|
51362
|
+
} catch (e) {
|
51363
|
+
return false;
|
51364
|
+
}
|
51365
|
+
}
|
51366
|
+
function _construct(Parent, args, Class) {
|
51367
|
+
if (isNativeReflectConstruct()) {
|
51368
|
+
_construct = Reflect.construct;
|
51369
|
+
} else {
|
51370
|
+
_construct = function _construct2(Parent2, args2, Class2) {
|
51371
|
+
var a = [null];
|
51372
|
+
a.push.apply(a, args2);
|
51373
|
+
var Constructor = Function.bind.apply(Parent2, a);
|
51374
|
+
var instance = new Constructor();
|
51375
|
+
if (Class2)
|
51376
|
+
_setPrototypeOf(instance, Class2.prototype);
|
51377
|
+
return instance;
|
51378
|
+
};
|
51379
|
+
}
|
51380
|
+
return _construct.apply(null, arguments);
|
51381
|
+
}
|
51382
|
+
function _isNativeFunction(fn2) {
|
51383
|
+
return Function.toString.call(fn2).indexOf("[native code]") !== -1;
|
51384
|
+
}
|
51385
|
+
function _wrapNativeSuper(Class) {
|
51386
|
+
var _cache = typeof Map === "function" ? /* @__PURE__ */ new Map() : void 0;
|
51387
|
+
_wrapNativeSuper = function _wrapNativeSuper2(Class2) {
|
51388
|
+
if (Class2 === null || !_isNativeFunction(Class2))
|
51389
|
+
return Class2;
|
51390
|
+
if (typeof Class2 !== "function") {
|
51391
|
+
throw new TypeError("Super expression must either be null or a function");
|
51392
|
+
}
|
51393
|
+
if (typeof _cache !== "undefined") {
|
51394
|
+
if (_cache.has(Class2))
|
51395
|
+
return _cache.get(Class2);
|
51396
|
+
_cache.set(Class2, Wrapper);
|
51397
|
+
}
|
51398
|
+
function Wrapper() {
|
51399
|
+
return _construct(Class2, arguments, _getPrototypeOf(this).constructor);
|
51400
|
+
}
|
51401
|
+
Wrapper.prototype = Object.create(Class2.prototype, {
|
51402
|
+
constructor: {
|
51403
|
+
value: Wrapper,
|
51404
|
+
enumerable: false,
|
51405
|
+
writable: true,
|
51406
|
+
configurable: true
|
51407
|
+
}
|
51408
|
+
});
|
51409
|
+
return _setPrototypeOf(Wrapper, Class2);
|
51410
|
+
};
|
51411
|
+
return _wrapNativeSuper(Class);
|
51412
|
+
}
|
51413
|
+
function _assertThisInitialized(self2) {
|
51414
|
+
if (self2 === void 0) {
|
51415
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
51416
|
+
}
|
51417
|
+
return self2;
|
51418
|
+
}
|
51419
|
+
var getDefaultMessage = function getDefaultMessage2(error) {
|
51420
|
+
return 'Cannot execute "' + error.action + '" on "' + error.subjectName + '"';
|
51421
|
+
};
|
51422
|
+
var defaultErrorMessage = getDefaultMessage;
|
51423
|
+
var ForbiddenError = /* @__PURE__ */ function(_Error) {
|
51424
|
+
_inheritsLoose(ForbiddenError2, _Error);
|
51425
|
+
ForbiddenError2.setDefaultMessage = function setDefaultMessage(messageOrFn) {
|
51426
|
+
if (messageOrFn === null) {
|
51427
|
+
defaultErrorMessage = getDefaultMessage;
|
51428
|
+
} else {
|
51429
|
+
defaultErrorMessage = typeof messageOrFn === "string" ? function() {
|
51430
|
+
return messageOrFn;
|
51431
|
+
} : messageOrFn;
|
51432
|
+
}
|
51433
|
+
};
|
51434
|
+
ForbiddenError2.from = function from(ability) {
|
51435
|
+
var error = new this("");
|
51436
|
+
Object.defineProperty(error, "ability", {
|
51437
|
+
value: ability
|
51438
|
+
});
|
51439
|
+
return error;
|
51440
|
+
};
|
51441
|
+
function ForbiddenError2(message, options) {
|
51442
|
+
var _this;
|
51443
|
+
if (options === void 0) {
|
51444
|
+
options = {};
|
51445
|
+
}
|
51446
|
+
_this = _Error.call(this, message) || this;
|
51447
|
+
_this._setMetadata(options);
|
51448
|
+
_this.message = message || defaultErrorMessage(_assertThisInitialized(_this));
|
51449
|
+
_this._customMessage = null;
|
51450
|
+
if (typeof Error.captureStackTrace === "function") {
|
51451
|
+
_this.name = _this.constructor.name;
|
51452
|
+
Error.captureStackTrace(_assertThisInitialized(_this), _this.constructor);
|
51453
|
+
}
|
51454
|
+
return _this;
|
51455
|
+
}
|
51456
|
+
var _proto = ForbiddenError2.prototype;
|
51457
|
+
_proto.setMessage = function setMessage(message) {
|
51458
|
+
this._customMessage = message;
|
51459
|
+
return this;
|
51460
|
+
};
|
51461
|
+
_proto.throwUnlessCan = function throwUnlessCan(action, subject, field) {
|
51462
|
+
if (!this.ability) {
|
51463
|
+
throw new ReferenceError("Cannot throw FordiddenError without respective ability instance");
|
51464
|
+
}
|
51465
|
+
var rule = this.ability.relevantRuleFor(action, subject, field);
|
51466
|
+
if (rule && !rule.inverted) {
|
51467
|
+
return;
|
51468
|
+
}
|
51469
|
+
this._setMetadata({
|
51470
|
+
action,
|
51471
|
+
subject,
|
51472
|
+
field,
|
51473
|
+
subjectName: this.ability.subjectName(subject)
|
51474
|
+
});
|
51475
|
+
var reason = rule ? rule.reason : "";
|
51476
|
+
this.message = this._customMessage || reason || defaultErrorMessage(this);
|
51477
|
+
throw this;
|
51478
|
+
};
|
51479
|
+
_proto._setMetadata = function _setMetadata(options) {
|
51480
|
+
this.subject = options.subject;
|
51481
|
+
this.subjectName = options.subjectName;
|
51482
|
+
this.action = options.action;
|
51483
|
+
this.field = options.field;
|
51484
|
+
};
|
51485
|
+
return ForbiddenError2;
|
51486
|
+
}(_wrapNativeSuper(Error));
|
51487
|
+
function wrapArray(value) {
|
51488
|
+
return Array.isArray(value) ? value : [value];
|
51489
|
+
}
|
51490
|
+
function getSubjectName(subject) {
|
51491
|
+
if (!subject || typeof subject === "string") {
|
51492
|
+
return subject;
|
51493
|
+
}
|
51494
|
+
var Type = typeof subject === "object" ? subject.constructor : subject;
|
51495
|
+
return Type.modelName || Type.name;
|
51496
|
+
}
|
51497
|
+
function clone(object) {
|
51498
|
+
return JSON.parse(JSON.stringify(object));
|
51499
|
+
}
|
51500
|
+
var REGEXP_SPECIAL_CHARS = /[-/\\^$+?.()|[\]{}]/g;
|
51501
|
+
var REGEXP_ANY = /\.?\*+\.?/g;
|
51502
|
+
var REGEXP_STARS = /\*+/;
|
51503
|
+
var REGEXP_DOT = /\./g;
|
51504
|
+
function detectRegexpPattern(match, index, string) {
|
51505
|
+
var quantifier = string[0] === "*" || match[0] === "." && match[match.length - 1] === "." ? "+" : "*";
|
51506
|
+
var matcher = match.indexOf("**") === -1 ? "[^.]" : ".";
|
51507
|
+
var pattern = match.replace(REGEXP_DOT, "\\$&").replace(REGEXP_STARS, matcher + quantifier);
|
51508
|
+
return index + match.length === string.length ? "(?:" + pattern + ")?" : pattern;
|
51509
|
+
}
|
51510
|
+
function escapeRegexp(match, index, string) {
|
51511
|
+
if (match === "." && (string[index - 1] === "*" || string[index + 1] === "*")) {
|
51512
|
+
return match;
|
51513
|
+
}
|
51514
|
+
return "\\" + match;
|
51515
|
+
}
|
51516
|
+
function createPattern(fields) {
|
51517
|
+
var patterns = fields.map(function(field) {
|
51518
|
+
return field.replace(REGEXP_SPECIAL_CHARS, escapeRegexp).replace(REGEXP_ANY, detectRegexpPattern);
|
51519
|
+
});
|
51520
|
+
var pattern = patterns.length > 1 ? "(?:" + patterns.join("|") + ")" : patterns[0];
|
51521
|
+
return new RegExp("^" + pattern + "$");
|
51522
|
+
}
|
51523
|
+
var Rule = /* @__PURE__ */ function() {
|
51524
|
+
function Rule2(params) {
|
51525
|
+
this.actions = params.actions || params.action;
|
51526
|
+
this.subject = params.subject;
|
51527
|
+
this.fields = !params.fields || params.fields.length === 0 ? void 0 : wrapArray(params.fields);
|
51528
|
+
Object.defineProperty(this, "_fieldsPattern", {
|
51529
|
+
writable: true
|
51530
|
+
});
|
51531
|
+
this.inverted = !!params.inverted;
|
51532
|
+
this.conditions = params.conditions;
|
51533
|
+
Object.defineProperty(this, "_matches", {
|
51534
|
+
writable: true,
|
51535
|
+
value: this.conditions ? sift(this.conditions) : void 0
|
51536
|
+
});
|
51537
|
+
this.reason = params.reason;
|
51538
|
+
}
|
51539
|
+
var _proto = Rule2.prototype;
|
51540
|
+
_proto.matches = function matches(object) {
|
51541
|
+
if (!this._matches) {
|
51542
|
+
return true;
|
51543
|
+
}
|
51544
|
+
if (typeof object === "string") {
|
51545
|
+
return !this.inverted;
|
51546
|
+
}
|
51547
|
+
return this._matches(object);
|
51548
|
+
};
|
51549
|
+
_proto.isRelevantFor = function isRelevantFor(object, field) {
|
51550
|
+
if (!this.fields) {
|
51551
|
+
return true;
|
51552
|
+
}
|
51553
|
+
if (!field) {
|
51554
|
+
return !this.inverted;
|
51555
|
+
}
|
51556
|
+
return this.matchesField(field);
|
51557
|
+
};
|
51558
|
+
_proto.matchesField = function matchesField(field) {
|
51559
|
+
if (typeof this._fieldsPattern === "undefined") {
|
51560
|
+
this._fieldsPattern = this.fields.join("").indexOf("*") === -1 ? null : createPattern(this.fields);
|
51561
|
+
}
|
51562
|
+
if (this._fieldsPattern === null || field.indexOf("*") !== -1) {
|
51563
|
+
return this.fields.indexOf(field) !== -1;
|
51564
|
+
}
|
51565
|
+
return this._fieldsPattern.test(field);
|
51566
|
+
};
|
51567
|
+
return Rule2;
|
51568
|
+
}();
|
51569
|
+
var PRIVATE_FIELD = typeof Symbol !== "undefined" ? Symbol("private") : "__" + Date.now();
|
51570
|
+
var DEFAULT_ALIASES = {
|
51571
|
+
crud: ["create", "read", "update", "delete"]
|
51572
|
+
};
|
51573
|
+
function hasAction(action, actions) {
|
51574
|
+
return action === actions || Array.isArray(actions) && actions.indexOf(action) !== -1;
|
51575
|
+
}
|
51576
|
+
var Ability = /* @__PURE__ */ function() {
|
51577
|
+
Ability2.addAlias = function addAlias(alias, actions) {
|
51578
|
+
if (alias === "manage" || hasAction("manage", actions)) {
|
51579
|
+
throw new Error('Cannot add alias for "manage" action because it represents any action');
|
51580
|
+
}
|
51581
|
+
if (hasAction(alias, actions)) {
|
51582
|
+
throw new Error("Attempt to alias action to itself: " + alias + " -> " + actions.toString());
|
51583
|
+
}
|
51584
|
+
DEFAULT_ALIASES[alias] = actions;
|
51585
|
+
return this;
|
51586
|
+
};
|
51587
|
+
function Ability2(rules, options) {
|
51588
|
+
if (options === void 0) {
|
51589
|
+
options = {};
|
51590
|
+
}
|
51591
|
+
Object.defineProperty(this, "subjectName", {
|
51592
|
+
value: options.subjectName || getSubjectName
|
51593
|
+
});
|
51594
|
+
this[PRIVATE_FIELD] = {
|
51595
|
+
RuleType: options.RuleType || Rule,
|
51596
|
+
originalRules: rules || [],
|
51597
|
+
hasPerFieldRules: false,
|
51598
|
+
indexedRules: /* @__PURE__ */ Object.create(null),
|
51599
|
+
mergedRules: /* @__PURE__ */ Object.create(null),
|
51600
|
+
events: {},
|
51601
|
+
aliases: clone(DEFAULT_ALIASES)
|
51602
|
+
};
|
51603
|
+
this.update(rules);
|
51604
|
+
}
|
51605
|
+
var _proto = Ability2.prototype;
|
51606
|
+
_proto.update = function update(rules) {
|
51607
|
+
if (!Array.isArray(rules)) {
|
51608
|
+
return this;
|
51609
|
+
}
|
51610
|
+
var payload = {
|
51611
|
+
rules,
|
51612
|
+
ability: this
|
51613
|
+
};
|
51614
|
+
this.emit("update", payload);
|
51615
|
+
this[PRIVATE_FIELD].originalRules = rules.slice(0);
|
51616
|
+
this[PRIVATE_FIELD].mergedRules = /* @__PURE__ */ Object.create(null);
|
51617
|
+
var index = this.buildIndexFor(rules);
|
51618
|
+
if (process.env.NODE_ENV !== "production" && index.isAllInverted && rules.length) {
|
51619
|
+
console.warn("[casl]: Ability contains only inverted rules. That means user will not be able to do any actions. This will be changed to Error throw in the next major version");
|
51620
|
+
}
|
51621
|
+
this[PRIVATE_FIELD].indexedRules = index.rules;
|
51622
|
+
this[PRIVATE_FIELD].hasPerFieldRules = index.hasPerFieldRules;
|
51623
|
+
this.emit("updated", payload);
|
51624
|
+
return this;
|
51625
|
+
};
|
51626
|
+
_proto.buildIndexFor = function buildIndexFor(rules) {
|
51627
|
+
var indexedRules = /* @__PURE__ */ Object.create(null);
|
51628
|
+
var RuleType = this[PRIVATE_FIELD].RuleType;
|
51629
|
+
var isAllInverted = true;
|
51630
|
+
var hasPerFieldRules = false;
|
51631
|
+
for (var i = 0; i < rules.length; i++) {
|
51632
|
+
var rule = new RuleType(rules[i]);
|
51633
|
+
var actions = this.expandActions(rule.actions);
|
51634
|
+
var subjects = wrapArray(rule.subject);
|
51635
|
+
var priority = rules.length - i - 1;
|
51636
|
+
isAllInverted = !!(isAllInverted && rule.inverted);
|
51637
|
+
if (!hasPerFieldRules && rule.fields) {
|
51638
|
+
hasPerFieldRules = true;
|
51639
|
+
}
|
51640
|
+
for (var k = 0; k < subjects.length; k++) {
|
51641
|
+
var subject = subjects[k];
|
51642
|
+
indexedRules[subject] = indexedRules[subject] || /* @__PURE__ */ Object.create(null);
|
51643
|
+
for (var j = 0; j < actions.length; j++) {
|
51644
|
+
var action = actions[j];
|
51645
|
+
indexedRules[subject][action] = indexedRules[subject][action] || /* @__PURE__ */ Object.create(null);
|
51646
|
+
indexedRules[subject][action][priority] = rule;
|
51647
|
+
}
|
51648
|
+
}
|
51649
|
+
}
|
51650
|
+
return {
|
51651
|
+
isAllInverted,
|
51652
|
+
hasPerFieldRules,
|
51653
|
+
rules: indexedRules
|
51654
|
+
};
|
51655
|
+
};
|
51656
|
+
_proto.expandActions = function expandActions(rawActions) {
|
51657
|
+
var aliases = this[PRIVATE_FIELD].aliases;
|
51658
|
+
var actions = wrapArray(rawActions);
|
51659
|
+
var i = 0;
|
51660
|
+
while (i < actions.length) {
|
51661
|
+
var action = actions[i++];
|
51662
|
+
if (aliases.hasOwnProperty(action)) {
|
51663
|
+
actions = actions.concat(aliases[action]);
|
51664
|
+
}
|
51665
|
+
}
|
51666
|
+
return actions;
|
51667
|
+
};
|
51668
|
+
_proto.can = function can(action, subject, field) {
|
51669
|
+
if (field && typeof field !== "string") {
|
51670
|
+
throw new Error("Ability.can expects 3rd parameter to be a string. See https://stalniy.github.io/casl/abilities/2017/07/21/check-abilities.html#checking-fields for details");
|
51671
|
+
}
|
51672
|
+
var rule = this.relevantRuleFor(action, subject, field);
|
51673
|
+
return !!rule && !rule.inverted;
|
51674
|
+
};
|
51675
|
+
_proto.relevantRuleFor = function relevantRuleFor(action, subject, field) {
|
51676
|
+
var rules = this.rulesFor(action, subject, field);
|
51677
|
+
for (var i = 0; i < rules.length; i++) {
|
51678
|
+
if (rules[i].matches(subject)) {
|
51679
|
+
return rules[i];
|
51680
|
+
}
|
51681
|
+
}
|
51682
|
+
return null;
|
51683
|
+
};
|
51684
|
+
_proto.possibleRulesFor = function possibleRulesFor(action, subject) {
|
51685
|
+
var subjectName = this.subjectName(subject);
|
51686
|
+
var mergedRules = this[PRIVATE_FIELD].mergedRules;
|
51687
|
+
var key = subjectName + "_" + action;
|
51688
|
+
if (!mergedRules[key]) {
|
51689
|
+
mergedRules[key] = this.mergeRulesFor(action, subjectName);
|
51690
|
+
}
|
51691
|
+
return mergedRules[key];
|
51692
|
+
};
|
51693
|
+
_proto.mergeRulesFor = function mergeRulesFor(action, subjectName) {
|
51694
|
+
var indexedRules = this[PRIVATE_FIELD].indexedRules;
|
51695
|
+
var mergedRules = [subjectName, "all"].reduce(function(rules, subjectType) {
|
51696
|
+
var subjectRules = indexedRules[subjectType];
|
51697
|
+
if (!subjectRules) {
|
51698
|
+
return rules;
|
51699
|
+
}
|
51700
|
+
return Object.assign(rules, subjectRules[action], subjectRules.manage);
|
51701
|
+
}, []);
|
51702
|
+
return mergedRules.filter(Boolean);
|
51703
|
+
};
|
51704
|
+
_proto.rulesFor = function rulesFor(action, subject, field) {
|
51705
|
+
var rules = this.possibleRulesFor(action, subject);
|
51706
|
+
if (!this[PRIVATE_FIELD].hasPerFieldRules) {
|
51707
|
+
return rules;
|
51708
|
+
}
|
51709
|
+
return rules.filter(function(rule) {
|
51710
|
+
return rule.isRelevantFor(subject, field);
|
51711
|
+
});
|
51712
|
+
};
|
51713
|
+
_proto.cannot = function cannot() {
|
51714
|
+
return !this.can.apply(this, arguments);
|
51715
|
+
};
|
51716
|
+
_proto.throwUnlessCan = function throwUnlessCan() {
|
51717
|
+
var _ForbiddenError$from;
|
51718
|
+
console.warn('\n Ability.throwUnlessCan is deprecated and will be removed in 4.x version.\n Please use "ForbiddenError.from(ability).throwUnlessCan(...)" instead.\n '.trim());
|
51719
|
+
(_ForbiddenError$from = ForbiddenError.from(this)).throwUnlessCan.apply(_ForbiddenError$from, arguments);
|
51720
|
+
};
|
51721
|
+
_proto.on = function on(event, handler) {
|
51722
|
+
var events = this[PRIVATE_FIELD].events;
|
51723
|
+
var isAttached = true;
|
51724
|
+
if (!events[event]) {
|
51725
|
+
events[event] = [];
|
51726
|
+
}
|
51727
|
+
events[event].push(handler);
|
51728
|
+
return function() {
|
51729
|
+
if (isAttached) {
|
51730
|
+
var index = events[event].indexOf(handler);
|
51731
|
+
events[event].splice(index, 1);
|
51732
|
+
isAttached = false;
|
51733
|
+
}
|
51734
|
+
};
|
51735
|
+
};
|
51736
|
+
_proto.emit = function emit(event, payload) {
|
51737
|
+
var handlers = this[PRIVATE_FIELD].events[event];
|
51738
|
+
if (handlers) {
|
51739
|
+
handlers.slice(0).forEach(function(handler) {
|
51740
|
+
return handler(payload);
|
51741
|
+
});
|
51742
|
+
}
|
51743
|
+
};
|
51744
|
+
_createClass(Ability2, [{
|
51745
|
+
key: "rules",
|
51746
|
+
get: function get() {
|
51747
|
+
return this[PRIVATE_FIELD].originalRules;
|
51748
|
+
}
|
51749
|
+
}]);
|
51750
|
+
return Ability2;
|
51751
|
+
}();
|
51752
|
+
var Permission;
|
51753
|
+
((Permission2) => {
|
51754
|
+
((Level2) => {
|
51755
|
+
Level2[Level2["feedMe"] = 0] = "feedMe";
|
51756
|
+
Level2[Level2["business"] = 1] = "business";
|
51757
|
+
Level2[Level2["restaurant"] = 2] = "restaurant";
|
51758
|
+
})(Permission2.Level || (Permission2.Level = {}));
|
51759
|
+
((Action2) => {
|
51760
|
+
Action2["manage"] = "manage";
|
51761
|
+
Action2["create"] = "create";
|
51762
|
+
Action2["read"] = "read";
|
51763
|
+
Action2["update"] = "update";
|
51764
|
+
Action2["delete"] = "delete";
|
51765
|
+
})(Permission2.Action || (Permission2.Action = {}));
|
51766
|
+
})(Permission || (Permission = {}));
|
51767
|
+
((Permission2) => {
|
51768
|
+
((Subject2) => {
|
51769
|
+
((Feedme2) => {
|
51770
|
+
Feedme2["all"] = "all";
|
51771
|
+
Feedme2["restaurant"] = "restaurant";
|
51772
|
+
Feedme2["business"] = "business";
|
51773
|
+
Feedme2["delivery"] = "delivery";
|
51774
|
+
Feedme2["agent"] = "agent";
|
51775
|
+
})(Subject2.Feedme || (Subject2.Feedme = {}));
|
51776
|
+
((FeedmeBusinessField2) => {
|
51777
|
+
FeedmeBusinessField2["quota"] = "quota";
|
51778
|
+
FeedmeBusinessField2["owner"] = "owner";
|
51779
|
+
})(Subject2.FeedmeBusinessField || (Subject2.FeedmeBusinessField = {}));
|
51780
|
+
((Business2) => {
|
51781
|
+
Business2["profile"] = "business::profile";
|
51782
|
+
Business2["restaurant"] = "business::restaurant";
|
51783
|
+
Business2["menu"] = "business::menu";
|
51784
|
+
Business2["promotion"] = "business::promotion";
|
51785
|
+
Business2["voucher"] = "business::voucher";
|
51786
|
+
Business2["membership"] = "business::membership";
|
51787
|
+
Business2["stock"] = "business::stock";
|
51788
|
+
Business2["permission"] = "business::permission";
|
51789
|
+
Business2["role"] = "business::role";
|
51790
|
+
})(Subject2.Business || (Subject2.Business = {}));
|
51791
|
+
((Restaurant2) => {
|
51792
|
+
Restaurant2["restaurant"] = "restaurant";
|
51793
|
+
})(Subject2.Restaurant || (Subject2.Restaurant = {}));
|
51794
|
+
})(Permission2.Subject || (Permission2.Subject = {}));
|
51795
|
+
})(Permission || (Permission = {}));
|
51796
|
+
async function validate(params) {
|
51797
|
+
const { sessionUser, validationManifest } = params;
|
51798
|
+
const { requiredRoles, requiredCaslPermissions, customValidationFunction } = validationManifest;
|
51799
|
+
if (!sessionUser) {
|
51800
|
+
return { canAccess: false };
|
51801
|
+
}
|
51802
|
+
if (requiredRoles && requiredRoles.length > 0) {
|
51803
|
+
if (!requiredRoles.includes(sessionUser._role || "")) {
|
51804
|
+
return Promise.resolve({
|
51805
|
+
canAccess: false,
|
51806
|
+
message: "User does not have permission to access"
|
51807
|
+
});
|
51808
|
+
}
|
51809
|
+
}
|
51810
|
+
if (requiredCaslPermissions && requiredCaslPermissions.length > 0) {
|
51811
|
+
const ability = new Ability(sessionUser.permissions);
|
51812
|
+
if (requiredCaslPermissions.every(
|
51813
|
+
(permission) => !ability.can(permission.action, permission.subject, permission.field)
|
51814
|
+
)) {
|
51815
|
+
return Promise.resolve({
|
51816
|
+
canAccess: false,
|
51817
|
+
message: "User does not have permission to access"
|
51818
|
+
});
|
51819
|
+
}
|
51820
|
+
}
|
51821
|
+
if (customValidationFunction) {
|
51822
|
+
const customValidationResult = await customValidationFunction();
|
51823
|
+
if (!customValidationResult.canAccess) {
|
51824
|
+
return customValidationResult;
|
51825
|
+
}
|
51826
|
+
}
|
51827
|
+
return Promise.resolve({ canAccess: true });
|
51828
|
+
}
|
51829
|
+
const ACCESS_DENIED_ROUTE = "access-denied";
|
51830
|
+
async function validateRoute(route) {
|
51831
|
+
for (const matched of route.matched) {
|
51832
|
+
if (matched.meta.validationManifest) {
|
51833
|
+
const validationResult = await validate({
|
51834
|
+
sessionUser: useCoreStore().sessionUser.value,
|
51835
|
+
validationManifest: matched.meta.validationManifest
|
51836
|
+
});
|
51837
|
+
if (!validationResult.canAccess) {
|
51838
|
+
return {
|
51839
|
+
canAccess: false,
|
51840
|
+
message: validationResult.message,
|
51841
|
+
redirectTo: ACCESS_DENIED_ROUTE
|
51842
|
+
};
|
51843
|
+
}
|
51844
|
+
}
|
51845
|
+
}
|
51846
|
+
return {
|
51847
|
+
canAccess: true
|
51848
|
+
};
|
51849
|
+
}
|
51850
|
+
function installRouteValidation(router) {
|
51851
|
+
router.beforeEach(async (to, _, next) => {
|
51852
|
+
const validationResult = await validateRoute(to);
|
51853
|
+
if (!validationResult.canAccess) {
|
51854
|
+
if (validationResult.redirectTo) {
|
51855
|
+
next({ name: validationResult.redirectTo });
|
51856
|
+
} else {
|
51857
|
+
next({ name: ACCESS_DENIED_ROUTE });
|
51858
|
+
}
|
51859
|
+
} else {
|
51860
|
+
next();
|
51861
|
+
}
|
51862
|
+
});
|
51863
|
+
}
|
50914
51864
|
function initialize(clientId, namespace) {
|
50915
51865
|
namespace && useCoreStore().setNamespace(namespace);
|
50916
51866
|
const DEBUG_ACCOUNT_URL = "DEBUG_ACCOUNT_URL";
|
@@ -50919,14 +51869,21 @@ function initialize(clientId, namespace) {
|
|
50919
51869
|
FeedMeAuth.setBaseUrl(debugAccountUrl);
|
50920
51870
|
}
|
50921
51871
|
FeedMeAuth.initialize({ clientId, loginMode: "iframe", oneTapMode: "full_screen" });
|
51872
|
+
const coreStore2 = useCoreStore();
|
51873
|
+
if (!coreStore2.sessionUser.value) {
|
51874
|
+
coreStore2.signIn();
|
51875
|
+
}
|
50922
51876
|
}
|
50923
51877
|
const onAuthStateChanged = FeedMeAuth.onAuthStateChanged;
|
50924
51878
|
export {
|
50925
51879
|
CountryOptions,
|
50926
51880
|
FeedMeAuth,
|
50927
51881
|
_sfc_main as FmNavBar,
|
51882
|
+
FmpUser,
|
51883
|
+
Permission,
|
50928
51884
|
baseClientInstance,
|
50929
51885
|
initialize,
|
51886
|
+
installRouteValidation,
|
50930
51887
|
onAuthStateChanged,
|
50931
51888
|
useCoreStore
|
50932
51889
|
};
|