@aooth/arbac-moost 0.1.60 → 0.1.62

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.
Files changed (2) hide show
  1. package/dist/index.mjs +7 -15
  2. package/package.json +20 -20
package/dist/index.mjs CHANGED
@@ -579,10 +579,10 @@ function readCachedScopes() {
579
579
  * (`transformProjection`, `validateControls`), and merge the user filter
580
580
  * with the union of scope filters.
581
581
  *
582
- * Wraps the merge with `$and` (not object spread) so a top-level
583
- * `$or`/`$and`/`$not` in `filter` cannot drop the scope's sibling field
584
- * keys when @uniqu/core's `walkFilter` short-circuits on logical
585
- * operators (see BUG-2). Returns a match-nothing filter on denial so the
582
+ * Combining is delegated to `conjoinScopeFilters`, which owns the
583
+ * `$and`-never-spread invariant (a user filter constraining the same field as
584
+ * the scope would otherwise replace it and widen access) and treats an empty
585
+ * side as the identity. Returns a match-nothing filter on denial so the
586
586
  * downstream pipeline returns an empty result set without leaking rows.
587
587
  */
588
588
  async function transformArbacFilter(filter) {
@@ -590,12 +590,7 @@ async function transformArbacFilter(filter) {
590
590
  const { allowed, scopes } = await arbac.evaluate();
591
591
  if (!allowed) return DENY_FILTER;
592
592
  arbac.setScopes(scopes);
593
- const scopeList = scopes ?? [];
594
- const merged = scopeList.length > 0 ? mergeScopeFilters(scopeList.map((s) => s.filter ?? {})) : void 0;
595
- const userFilter = filter && Object.keys(filter).length > 0 ? filter : void 0;
596
- if (!merged) return userFilter ?? {};
597
- if (!userFilter) return merged;
598
- return { $and: [merged, userFilter] };
593
+ return conjoinScopeFilters(mergeScopeFilters((scopes ?? []).map((s) => s.filter ?? {})), filter) ?? {};
599
594
  }
600
595
  /**
601
596
  * Union the per-scope `projection` whitelists and restrict the user-supplied
@@ -640,11 +635,8 @@ function applyArbacRelationScopes(controls, scopes) {
640
635
  if (typeof entry.name !== "string") continue;
641
636
  const subScopes = collectSubScopes(scopes, entry.name);
642
637
  if (subScopes.length === 0) continue;
643
- const subFilter = mergeScopeFilters(subScopes.map((s) => s.filter ?? {}));
644
- if (subFilter) {
645
- const userFilter = entry.filter && Object.keys(entry.filter).length > 0 ? entry.filter : void 0;
646
- entry.filter = userFilter ? { $and: [subFilter, userFilter] } : subFilter;
647
- }
638
+ const conjoined = conjoinScopeFilters(mergeScopeFilters(subScopes.map((s) => s.filter ?? {})), entry.filter);
639
+ if (conjoined) entry.filter = conjoined;
648
640
  const entryControls = entry.controls ?? {};
649
641
  const restricted = applyArbacProjection(normalizeSelect(entryControls.$select), subScopes);
650
642
  if (restricted !== void 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aooth/arbac-moost",
3
- "version": "0.1.60",
3
+ "version": "0.1.62",
4
4
  "description": "Moost RBAC integration for aoothjs (migrated from @moostjs/arbac)",
5
5
  "keywords": [
6
6
  "abac",
@@ -60,31 +60,31 @@
60
60
  "access": "public"
61
61
  },
62
62
  "dependencies": {
63
- "@aooth/arbac": "0.1.60",
64
- "@aooth/user": "0.1.60",
65
- "@aooth/arbac-core": "0.1.60"
63
+ "@aooth/arbac": "0.1.62",
64
+ "@aooth/user": "0.1.62",
65
+ "@aooth/arbac-core": "0.1.62"
66
66
  },
67
67
  "devDependencies": {
68
- "@atscript/core": "^0.1.88",
69
- "@atscript/db": "^0.1.126",
70
- "@atscript/db-sql-tools": "^0.1.126",
71
- "@atscript/db-sqlite": "^0.1.126",
72
- "@atscript/moost-db": "^0.1.126",
73
- "@atscript/typescript": "^0.1.88",
74
- "@moostjs/event-http": "^0.6.35",
68
+ "@atscript/core": "^0.1.93",
69
+ "@atscript/db": "^0.1.129",
70
+ "@atscript/db-sql-tools": "^0.1.129",
71
+ "@atscript/db-sqlite": "^0.1.129",
72
+ "@atscript/moost-db": "^0.1.129",
73
+ "@atscript/typescript": "^0.1.93",
74
+ "@moostjs/event-http": "^0.6.37",
75
75
  "@types/better-sqlite3": "^7.6.13",
76
- "@uniqu/core": "^0.1.7",
76
+ "@uniqu/core": "^0.1.8",
77
77
  "better-sqlite3": "^12.6.2",
78
- "unplugin-atscript": "^0.1.88"
78
+ "unplugin-atscript": "^0.1.93"
79
79
  },
80
80
  "peerDependencies": {
81
- "@atscript/db": "^0.1.126",
82
- "@atscript/moost-db": "^0.1.126",
83
- "@atscript/typescript": "^0.1.88",
84
- "@moostjs/event-http": "^0.6.35",
85
- "@wooksjs/event-core": "^0.7.22",
86
- "@wooksjs/event-http": "^0.7.22",
87
- "moost": "^0.6.35"
81
+ "@atscript/db": "^0.1.129",
82
+ "@atscript/moost-db": "^0.1.129",
83
+ "@atscript/typescript": "^0.1.93",
84
+ "@moostjs/event-http": "^0.6.37",
85
+ "@wooksjs/event-core": "^0.7.23",
86
+ "@wooksjs/event-http": "^0.7.23",
87
+ "moost": "^0.6.37"
88
88
  },
89
89
  "peerDependenciesMeta": {
90
90
  "@atscript/db": {