@7365admin1/core 3.142.0 → 3.143.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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +15 -1
- package/dist/index.js +115 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +113 -93
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/e2e/staff-access.e2e.test.mjs +14 -1
- package/test/staff-camera-status.test.mjs +7 -8
package/dist/index.mjs
CHANGED
|
@@ -4818,6 +4818,100 @@ import { ObjectId as ObjectId17 } from "mongodb";
|
|
|
4818
4818
|
// src/utils/super-admin.util.ts
|
|
4819
4819
|
import { useAtlas as useAtlas10 } from "@7365admin1/node-server-utils";
|
|
4820
4820
|
import { ObjectId as ObjectId16 } from "mongodb";
|
|
4821
|
+
|
|
4822
|
+
// src/utils/console-permission.util.ts
|
|
4823
|
+
var CONSOLE_PERMISSIONS = Object.freeze({
|
|
4824
|
+
organizations: Object.freeze([
|
|
4825
|
+
"see-all-organizations",
|
|
4826
|
+
"see-organization-details"
|
|
4827
|
+
]),
|
|
4828
|
+
"promo-codes": Object.freeze([
|
|
4829
|
+
"create-promo-code",
|
|
4830
|
+
"see-promo-code-details",
|
|
4831
|
+
"edit-promo-code-details",
|
|
4832
|
+
"change-promo-code-status",
|
|
4833
|
+
"delete-promo-code"
|
|
4834
|
+
]),
|
|
4835
|
+
users: Object.freeze(["see-all-users", "see-user-details"]),
|
|
4836
|
+
invitations: Object.freeze([
|
|
4837
|
+
"create-invitation",
|
|
4838
|
+
"view-invitations",
|
|
4839
|
+
"cancel-invitation"
|
|
4840
|
+
]),
|
|
4841
|
+
subscriptions: Object.freeze([
|
|
4842
|
+
"see-all-subscriptions",
|
|
4843
|
+
"see-subscription-details",
|
|
4844
|
+
"manage-subscription"
|
|
4845
|
+
]),
|
|
4846
|
+
"sp-approvals": Object.freeze([
|
|
4847
|
+
"see-all-sp-approvals",
|
|
4848
|
+
"approve-sp",
|
|
4849
|
+
"reject-sp",
|
|
4850
|
+
"delete-sp-approval"
|
|
4851
|
+
]),
|
|
4852
|
+
"marketplace-vendors": Object.freeze([
|
|
4853
|
+
"see-all-marketplace-vendors",
|
|
4854
|
+
"see-marketplace-vendor-details"
|
|
4855
|
+
]),
|
|
4856
|
+
"platform-terms": Object.freeze([
|
|
4857
|
+
"see-platform-terms",
|
|
4858
|
+
"edit-platform-terms"
|
|
4859
|
+
]),
|
|
4860
|
+
"activity-history": Object.freeze(["see-activity-history"]),
|
|
4861
|
+
members: Object.freeze([
|
|
4862
|
+
"view-members",
|
|
4863
|
+
"assign-member-role",
|
|
4864
|
+
"suspend-member",
|
|
4865
|
+
"activate-member",
|
|
4866
|
+
"delete-member"
|
|
4867
|
+
]),
|
|
4868
|
+
"roles-and-permissions": Object.freeze([
|
|
4869
|
+
"add-role",
|
|
4870
|
+
"see-all-roles",
|
|
4871
|
+
"see-role-details",
|
|
4872
|
+
"update-role",
|
|
4873
|
+
"delete-role"
|
|
4874
|
+
])
|
|
4875
|
+
});
|
|
4876
|
+
var RESOURCE_SPELLINGS = Object.freeze({
|
|
4877
|
+
"roles-and-permissions": Object.freeze([
|
|
4878
|
+
"roles-and-permissions",
|
|
4879
|
+
"roles"
|
|
4880
|
+
]),
|
|
4881
|
+
roles: Object.freeze(["roles", "roles-and-permissions"])
|
|
4882
|
+
});
|
|
4883
|
+
function consoleSpellings(resource, action) {
|
|
4884
|
+
const resources = RESOURCE_SPELLINGS[resource] ?? [resource];
|
|
4885
|
+
return resources.map((name2) => `${name2}:${action}`);
|
|
4886
|
+
}
|
|
4887
|
+
function consoleRoleAllowsAll(held) {
|
|
4888
|
+
if (!Array.isArray(held) || held.length === 0)
|
|
4889
|
+
return true;
|
|
4890
|
+
return held.includes("*");
|
|
4891
|
+
}
|
|
4892
|
+
function consoleRoleAllows(held, resource, action) {
|
|
4893
|
+
if (consoleRoleAllowsAll(held))
|
|
4894
|
+
return true;
|
|
4895
|
+
const actions = CONSOLE_PERMISSIONS[resource];
|
|
4896
|
+
if (!actions?.length)
|
|
4897
|
+
return false;
|
|
4898
|
+
const wanted = action ? actions.includes(action) ? [action] : [] : actions;
|
|
4899
|
+
return wanted.some(
|
|
4900
|
+
(name2) => consoleSpellings(resource, name2).some(
|
|
4901
|
+
(spelling) => held.includes(spelling)
|
|
4902
|
+
)
|
|
4903
|
+
);
|
|
4904
|
+
}
|
|
4905
|
+
var CROSS_CLIENT_GRANT = {
|
|
4906
|
+
resource: "organizations"
|
|
4907
|
+
};
|
|
4908
|
+
function staffMayBypass(actor, grant = CROSS_CLIENT_GRANT) {
|
|
4909
|
+
if (!actor.isSuperAdmin)
|
|
4910
|
+
return false;
|
|
4911
|
+
return consoleRoleAllows(actor.staffPermissions, grant.resource, grant.action);
|
|
4912
|
+
}
|
|
4913
|
+
|
|
4914
|
+
// src/utils/super-admin.util.ts
|
|
4821
4915
|
var LIVE_ROLE = { status: { $ne: "deleted" } };
|
|
4822
4916
|
async function resolveStaffRole(userId) {
|
|
4823
4917
|
const id = userId?.toString() ?? "";
|
|
@@ -4857,6 +4951,13 @@ async function isSuperAdmin(userId) {
|
|
|
4857
4951
|
async function isPlatformOwner(userId) {
|
|
4858
4952
|
return (await resolveStaffRole(userId))?.default === true;
|
|
4859
4953
|
}
|
|
4954
|
+
async function staffReachesEveryClient(userId) {
|
|
4955
|
+
const role = await resolveStaffRole(userId);
|
|
4956
|
+
if (!role)
|
|
4957
|
+
return false;
|
|
4958
|
+
return consoleRoleAllows(role.permissions, "organizations");
|
|
4959
|
+
}
|
|
4960
|
+
var STAFF_CLIENT_PERMISSIONS = Object.freeze(["*"]);
|
|
4860
4961
|
|
|
4861
4962
|
// src/utils/org-suspension.util.ts
|
|
4862
4963
|
var ORG_SUSPENDED_MESSAGE = "Your organisation's access is currently suspended. Please contact your administrator.";
|
|
@@ -11218,98 +11319,6 @@ async function recordConsoleAction(entry) {
|
|
|
11218
11319
|
}
|
|
11219
11320
|
}
|
|
11220
11321
|
|
|
11221
|
-
// src/utils/console-permission.util.ts
|
|
11222
|
-
var CONSOLE_PERMISSIONS = Object.freeze({
|
|
11223
|
-
organizations: Object.freeze([
|
|
11224
|
-
"see-all-organizations",
|
|
11225
|
-
"see-organization-details"
|
|
11226
|
-
]),
|
|
11227
|
-
"promo-codes": Object.freeze([
|
|
11228
|
-
"create-promo-code",
|
|
11229
|
-
"see-promo-code-details",
|
|
11230
|
-
"edit-promo-code-details",
|
|
11231
|
-
"change-promo-code-status",
|
|
11232
|
-
"delete-promo-code"
|
|
11233
|
-
]),
|
|
11234
|
-
users: Object.freeze(["see-all-users", "see-user-details"]),
|
|
11235
|
-
invitations: Object.freeze([
|
|
11236
|
-
"create-invitation",
|
|
11237
|
-
"view-invitations",
|
|
11238
|
-
"cancel-invitation"
|
|
11239
|
-
]),
|
|
11240
|
-
subscriptions: Object.freeze([
|
|
11241
|
-
"see-all-subscriptions",
|
|
11242
|
-
"see-subscription-details",
|
|
11243
|
-
"manage-subscription"
|
|
11244
|
-
]),
|
|
11245
|
-
"sp-approvals": Object.freeze([
|
|
11246
|
-
"see-all-sp-approvals",
|
|
11247
|
-
"approve-sp",
|
|
11248
|
-
"reject-sp",
|
|
11249
|
-
"delete-sp-approval"
|
|
11250
|
-
]),
|
|
11251
|
-
"marketplace-vendors": Object.freeze([
|
|
11252
|
-
"see-all-marketplace-vendors",
|
|
11253
|
-
"see-marketplace-vendor-details"
|
|
11254
|
-
]),
|
|
11255
|
-
"platform-terms": Object.freeze([
|
|
11256
|
-
"see-platform-terms",
|
|
11257
|
-
"edit-platform-terms"
|
|
11258
|
-
]),
|
|
11259
|
-
"activity-history": Object.freeze(["see-activity-history"]),
|
|
11260
|
-
members: Object.freeze([
|
|
11261
|
-
"view-members",
|
|
11262
|
-
"assign-member-role",
|
|
11263
|
-
"suspend-member",
|
|
11264
|
-
"activate-member",
|
|
11265
|
-
"delete-member"
|
|
11266
|
-
]),
|
|
11267
|
-
"roles-and-permissions": Object.freeze([
|
|
11268
|
-
"add-role",
|
|
11269
|
-
"see-all-roles",
|
|
11270
|
-
"see-role-details",
|
|
11271
|
-
"update-role",
|
|
11272
|
-
"delete-role"
|
|
11273
|
-
])
|
|
11274
|
-
});
|
|
11275
|
-
var RESOURCE_SPELLINGS = Object.freeze({
|
|
11276
|
-
"roles-and-permissions": Object.freeze([
|
|
11277
|
-
"roles-and-permissions",
|
|
11278
|
-
"roles"
|
|
11279
|
-
]),
|
|
11280
|
-
roles: Object.freeze(["roles", "roles-and-permissions"])
|
|
11281
|
-
});
|
|
11282
|
-
function consoleSpellings(resource, action) {
|
|
11283
|
-
const resources = RESOURCE_SPELLINGS[resource] ?? [resource];
|
|
11284
|
-
return resources.map((name2) => `${name2}:${action}`);
|
|
11285
|
-
}
|
|
11286
|
-
function consoleRoleAllowsAll(held) {
|
|
11287
|
-
if (!Array.isArray(held) || held.length === 0)
|
|
11288
|
-
return true;
|
|
11289
|
-
return held.includes("*");
|
|
11290
|
-
}
|
|
11291
|
-
function consoleRoleAllows(held, resource, action) {
|
|
11292
|
-
if (consoleRoleAllowsAll(held))
|
|
11293
|
-
return true;
|
|
11294
|
-
const actions = CONSOLE_PERMISSIONS[resource];
|
|
11295
|
-
if (!actions?.length)
|
|
11296
|
-
return false;
|
|
11297
|
-
const wanted = action ? actions.includes(action) ? [action] : [] : actions;
|
|
11298
|
-
return wanted.some(
|
|
11299
|
-
(name2) => consoleSpellings(resource, name2).some(
|
|
11300
|
-
(spelling) => held.includes(spelling)
|
|
11301
|
-
)
|
|
11302
|
-
);
|
|
11303
|
-
}
|
|
11304
|
-
var CROSS_CLIENT_GRANT = {
|
|
11305
|
-
resource: "organizations"
|
|
11306
|
-
};
|
|
11307
|
-
function staffMayBypass(actor, grant = CROSS_CLIENT_GRANT) {
|
|
11308
|
-
if (!actor.isSuperAdmin)
|
|
11309
|
-
return false;
|
|
11310
|
-
return consoleRoleAllows(actor.staffPermissions, grant.resource, grant.action);
|
|
11311
|
-
}
|
|
11312
|
-
|
|
11313
11322
|
// src/services/module-gate.service.ts
|
|
11314
11323
|
var idOf4 = (v) => v == null ? "" : String(v?._id ?? v).toLowerCase();
|
|
11315
11324
|
var isId = (v) => /^[0-9a-f]{24}$/i.test(v);
|
|
@@ -22270,6 +22279,9 @@ async function getUserPermissions(params) {
|
|
|
22270
22279
|
if (!db3) {
|
|
22271
22280
|
return [];
|
|
22272
22281
|
}
|
|
22282
|
+
if (await staffReachesEveryClient(user)) {
|
|
22283
|
+
return [...STAFF_CLIENT_PERMISSIONS];
|
|
22284
|
+
}
|
|
22273
22285
|
let roleId = grantingRole;
|
|
22274
22286
|
let memberSite = params.memberSite;
|
|
22275
22287
|
let memberId;
|
|
@@ -22410,6 +22422,12 @@ function useCameraViewService() {
|
|
|
22410
22422
|
engagedOrgs,
|
|
22411
22423
|
prefer: params.prefer
|
|
22412
22424
|
});
|
|
22425
|
+
if (!grant && await staffReachesEveryClient(params.userId)) {
|
|
22426
|
+
return {
|
|
22427
|
+
memberships,
|
|
22428
|
+
grant: { org: params.site?.orgId ?? params.site?.org, siteId: params.siteObjectId }
|
|
22429
|
+
};
|
|
22430
|
+
}
|
|
22413
22431
|
return { memberships, grant };
|
|
22414
22432
|
}
|
|
22415
22433
|
async function permissionsForGrant(userId, grant, memberships) {
|
|
@@ -25259,7 +25277,7 @@ function useServiceProviderInviteService() {
|
|
|
25259
25277
|
const runs = ObjectId57.isValid(id) && actor.memberships.some(
|
|
25260
25278
|
(m) => m.org === id && (m.companyWideRole === true || !m.siteId && m.orgLevelRole === true)
|
|
25261
25279
|
);
|
|
25262
|
-
if (!runs) {
|
|
25280
|
+
if (!runs && !staffMayBypass(actor)) {
|
|
25263
25281
|
throw new UnauthorizedError4(
|
|
25264
25282
|
"Only an administrator of that company can answer this invitation for it."
|
|
25265
25283
|
);
|
|
@@ -109809,6 +109827,7 @@ export {
|
|
|
109809
109827
|
SERVICE_TYPE_LABELS,
|
|
109810
109828
|
SITE_STATES_MAX,
|
|
109811
109829
|
SOFTWARE_VERSION_ENDPOINT,
|
|
109830
|
+
STAFF_CLIENT_PERMISSIONS,
|
|
109812
109831
|
STAFF_VIEW_APPS,
|
|
109813
109832
|
STAFF_VIEW_HISTORY_ACTIONS,
|
|
109814
109833
|
SUBCONTRACT_ADMIN_REFUSAL,
|
|
@@ -110424,6 +110443,7 @@ export {
|
|
|
110424
110443
|
snapshotRefusalReason,
|
|
110425
110444
|
splitRobotSn,
|
|
110426
110445
|
staffMayBypass,
|
|
110446
|
+
staffReachesEveryClient,
|
|
110427
110447
|
staffViewWriteAudit,
|
|
110428
110448
|
startDemoTracking,
|
|
110429
110449
|
startPadbotDrive,
|