@objectstack/core 12.6.0 → 14.3.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/index.cjs +14 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +15 -14
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -4235,7 +4235,7 @@ async function tryFind(ql, object, where, limit = 100) {
|
|
|
4235
4235
|
async function resolveAuthzContext(input) {
|
|
4236
4236
|
const { ql, headers } = input;
|
|
4237
4237
|
const ctx = {
|
|
4238
|
-
|
|
4238
|
+
positions: [],
|
|
4239
4239
|
permissions: [],
|
|
4240
4240
|
systemPermissions: [],
|
|
4241
4241
|
org_user_ids: []
|
|
@@ -4284,16 +4284,16 @@ async function resolveAuthzContext(input) {
|
|
|
4284
4284
|
if (m.role && typeof m.role === "string") {
|
|
4285
4285
|
for (const raw of m.role.split(",").map((s) => s.trim()).filter(Boolean)) {
|
|
4286
4286
|
const r = (0, import_spec.mapMembershipRole)(raw);
|
|
4287
|
-
if (!ctx.
|
|
4287
|
+
if (!ctx.positions.includes(r)) ctx.positions.push(r);
|
|
4288
4288
|
}
|
|
4289
4289
|
}
|
|
4290
4290
|
}
|
|
4291
|
-
const
|
|
4292
|
-
for (const ur of
|
|
4291
|
+
const userPositionRows = await tryFind(ql, "sys_user_position", { user_id: userId }, 200);
|
|
4292
|
+
for (const ur of userPositionRows) {
|
|
4293
4293
|
const org = ur.organization_id ?? null;
|
|
4294
4294
|
if (org && tenantId && org !== tenantId) continue;
|
|
4295
|
-
const r = ur.
|
|
4296
|
-
if (typeof r === "string" && r && !ctx.
|
|
4295
|
+
const r = ur.position;
|
|
4296
|
+
if (typeof r === "string" && r && !ctx.positions.includes(r)) ctx.positions.push(r);
|
|
4297
4297
|
}
|
|
4298
4298
|
if (tenantId) {
|
|
4299
4299
|
const orgMembers = await tryFind(ql, "sys_member", { organization_id: tenantId }, 1e3);
|
|
@@ -4316,11 +4316,12 @@ async function resolveAuthzContext(input) {
|
|
|
4316
4316
|
upsRows.filter((r) => (r.organization_id ?? r.organizationId ?? null) === null).map((r) => r.permission_set_id ?? r.permissionSetId).filter(Boolean)
|
|
4317
4317
|
);
|
|
4318
4318
|
let hasPlatformAdminGrant = false;
|
|
4319
|
-
if (ctx.
|
|
4320
|
-
|
|
4321
|
-
const
|
|
4322
|
-
|
|
4323
|
-
|
|
4319
|
+
if (!ctx.positions.includes("everyone")) ctx.positions.push("everyone");
|
|
4320
|
+
if (ctx.positions.length > 0) {
|
|
4321
|
+
const positionRows = await tryFind(ql, "sys_position", { name: { $in: ctx.positions } }, 100);
|
|
4322
|
+
const positionIds = positionRows.map((r) => r.id).filter(Boolean);
|
|
4323
|
+
if (positionIds.length > 0) {
|
|
4324
|
+
const rpsRows = await tryFind(ql, "sys_position_permission_set", { position_id: { $in: positionIds } }, 500);
|
|
4324
4325
|
for (const r of rpsRows) {
|
|
4325
4326
|
const id = r.permission_set_id ?? r.permissionSetId;
|
|
4326
4327
|
if (id) psIds.add(id);
|
|
@@ -4353,8 +4354,8 @@ async function resolveAuthzContext(input) {
|
|
|
4353
4354
|
}
|
|
4354
4355
|
if (Object.keys(mergedTabs).length > 0) ctx.tabPermissions = mergedTabs;
|
|
4355
4356
|
}
|
|
4356
|
-
if (hasPlatformAdminGrant && !ctx.
|
|
4357
|
-
ctx.
|
|
4357
|
+
if (hasPlatformAdminGrant && !ctx.positions.includes(import_spec.BUILTIN_IDENTITY_PLATFORM_ADMIN)) {
|
|
4358
|
+
ctx.positions.unshift(import_spec.BUILTIN_IDENTITY_PLATFORM_ADMIN);
|
|
4358
4359
|
}
|
|
4359
4360
|
if (!ctx.permissions.includes("ai_seat")) {
|
|
4360
4361
|
const aiAccess = (await getUserRow())?.ai_access;
|