@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.d.cts
CHANGED
|
@@ -1733,7 +1733,7 @@ interface ResolvedAuthzContext {
|
|
|
1733
1733
|
tenantId?: string;
|
|
1734
1734
|
email?: string;
|
|
1735
1735
|
accessToken?: string;
|
|
1736
|
-
|
|
1736
|
+
positions: string[];
|
|
1737
1737
|
permissions: string[];
|
|
1738
1738
|
systemPermissions: string[];
|
|
1739
1739
|
tabPermissions?: Record<string, 'visible' | 'hidden' | 'default_on' | 'default_off'>;
|
|
@@ -1756,7 +1756,7 @@ interface ResolveAuthzInput {
|
|
|
1756
1756
|
}
|
|
1757
1757
|
/**
|
|
1758
1758
|
* Resolve the authorization context for an inbound request. Always resolves —
|
|
1759
|
-
* never throws. Anonymous requests yield `{
|
|
1759
|
+
* never throws. Anonymous requests yield `{ positions: [], permissions: [], ... }`.
|
|
1760
1760
|
*/
|
|
1761
1761
|
declare function resolveAuthzContext(input: ResolveAuthzInput): Promise<ResolvedAuthzContext>;
|
|
1762
1762
|
interface ResolveLocalizationInput {
|
package/dist/index.d.ts
CHANGED
|
@@ -1733,7 +1733,7 @@ interface ResolvedAuthzContext {
|
|
|
1733
1733
|
tenantId?: string;
|
|
1734
1734
|
email?: string;
|
|
1735
1735
|
accessToken?: string;
|
|
1736
|
-
|
|
1736
|
+
positions: string[];
|
|
1737
1737
|
permissions: string[];
|
|
1738
1738
|
systemPermissions: string[];
|
|
1739
1739
|
tabPermissions?: Record<string, 'visible' | 'hidden' | 'default_on' | 'default_off'>;
|
|
@@ -1756,7 +1756,7 @@ interface ResolveAuthzInput {
|
|
|
1756
1756
|
}
|
|
1757
1757
|
/**
|
|
1758
1758
|
* Resolve the authorization context for an inbound request. Always resolves —
|
|
1759
|
-
* never throws. Anonymous requests yield `{
|
|
1759
|
+
* never throws. Anonymous requests yield `{ positions: [], permissions: [], ... }`.
|
|
1760
1760
|
*/
|
|
1761
1761
|
declare function resolveAuthzContext(input: ResolveAuthzInput): Promise<ResolvedAuthzContext>;
|
|
1762
1762
|
interface ResolveLocalizationInput {
|
package/dist/index.js
CHANGED
|
@@ -4135,7 +4135,7 @@ function safeJsonParse(s, fallback) {
|
|
|
4135
4135
|
// src/security/resolve-authz-context.ts
|
|
4136
4136
|
import {
|
|
4137
4137
|
mapMembershipRole,
|
|
4138
|
-
|
|
4138
|
+
BUILTIN_IDENTITY_PLATFORM_ADMIN,
|
|
4139
4139
|
ADMIN_FULL_ACCESS
|
|
4140
4140
|
} from "@objectstack/spec";
|
|
4141
4141
|
function safeJsonParse2(s, fallback) {
|
|
@@ -4158,7 +4158,7 @@ async function tryFind(ql, object, where, limit = 100) {
|
|
|
4158
4158
|
async function resolveAuthzContext(input) {
|
|
4159
4159
|
const { ql, headers } = input;
|
|
4160
4160
|
const ctx = {
|
|
4161
|
-
|
|
4161
|
+
positions: [],
|
|
4162
4162
|
permissions: [],
|
|
4163
4163
|
systemPermissions: [],
|
|
4164
4164
|
org_user_ids: []
|
|
@@ -4207,16 +4207,16 @@ async function resolveAuthzContext(input) {
|
|
|
4207
4207
|
if (m.role && typeof m.role === "string") {
|
|
4208
4208
|
for (const raw of m.role.split(",").map((s) => s.trim()).filter(Boolean)) {
|
|
4209
4209
|
const r = mapMembershipRole(raw);
|
|
4210
|
-
if (!ctx.
|
|
4210
|
+
if (!ctx.positions.includes(r)) ctx.positions.push(r);
|
|
4211
4211
|
}
|
|
4212
4212
|
}
|
|
4213
4213
|
}
|
|
4214
|
-
const
|
|
4215
|
-
for (const ur of
|
|
4214
|
+
const userPositionRows = await tryFind(ql, "sys_user_position", { user_id: userId }, 200);
|
|
4215
|
+
for (const ur of userPositionRows) {
|
|
4216
4216
|
const org = ur.organization_id ?? null;
|
|
4217
4217
|
if (org && tenantId && org !== tenantId) continue;
|
|
4218
|
-
const r = ur.
|
|
4219
|
-
if (typeof r === "string" && r && !ctx.
|
|
4218
|
+
const r = ur.position;
|
|
4219
|
+
if (typeof r === "string" && r && !ctx.positions.includes(r)) ctx.positions.push(r);
|
|
4220
4220
|
}
|
|
4221
4221
|
if (tenantId) {
|
|
4222
4222
|
const orgMembers = await tryFind(ql, "sys_member", { organization_id: tenantId }, 1e3);
|
|
@@ -4239,11 +4239,12 @@ async function resolveAuthzContext(input) {
|
|
|
4239
4239
|
upsRows.filter((r) => (r.organization_id ?? r.organizationId ?? null) === null).map((r) => r.permission_set_id ?? r.permissionSetId).filter(Boolean)
|
|
4240
4240
|
);
|
|
4241
4241
|
let hasPlatformAdminGrant = false;
|
|
4242
|
-
if (ctx.
|
|
4243
|
-
|
|
4244
|
-
const
|
|
4245
|
-
|
|
4246
|
-
|
|
4242
|
+
if (!ctx.positions.includes("everyone")) ctx.positions.push("everyone");
|
|
4243
|
+
if (ctx.positions.length > 0) {
|
|
4244
|
+
const positionRows = await tryFind(ql, "sys_position", { name: { $in: ctx.positions } }, 100);
|
|
4245
|
+
const positionIds = positionRows.map((r) => r.id).filter(Boolean);
|
|
4246
|
+
if (positionIds.length > 0) {
|
|
4247
|
+
const rpsRows = await tryFind(ql, "sys_position_permission_set", { position_id: { $in: positionIds } }, 500);
|
|
4247
4248
|
for (const r of rpsRows) {
|
|
4248
4249
|
const id = r.permission_set_id ?? r.permissionSetId;
|
|
4249
4250
|
if (id) psIds.add(id);
|
|
@@ -4276,8 +4277,8 @@ async function resolveAuthzContext(input) {
|
|
|
4276
4277
|
}
|
|
4277
4278
|
if (Object.keys(mergedTabs).length > 0) ctx.tabPermissions = mergedTabs;
|
|
4278
4279
|
}
|
|
4279
|
-
if (hasPlatformAdminGrant && !ctx.
|
|
4280
|
-
ctx.
|
|
4280
|
+
if (hasPlatformAdminGrant && !ctx.positions.includes(BUILTIN_IDENTITY_PLATFORM_ADMIN)) {
|
|
4281
|
+
ctx.positions.unshift(BUILTIN_IDENTITY_PLATFORM_ADMIN);
|
|
4281
4282
|
}
|
|
4282
4283
|
if (!ctx.permissions.includes("ai_seat")) {
|
|
4283
4284
|
const aiAccess = (await getUserRow())?.ai_access;
|