@dudousxd/nestjs-authz-prisma 0.6.0 → 0.8.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.
@@ -0,0 +1,227 @@
1
+ // Tenancy for the RBAC module: which tenant scope a permission/role check runs in, and which
2
+ // roles the caller's role inside the context tenant maps to. The same file ships in every
3
+ // store adapter. It reads the @dudousxd/nestjs-context tenancy contract STRUCTURALLY (no import),
4
+ // so it works with any context version, and with none: a missing or older context reads as
5
+ // tenancy off.
6
+ import { CONTEXT_ACCESSOR } from '@dudousxd/nestjs-authz';
7
+ import { normalizeUserRef } from '@dudousxd/nestjs-authz/store-kit';
8
+ import { ForbiddenException } from '@nestjs/common';
9
+ const SLOT = Symbol.for('@dudousxd/nestjs-diagnostics:accessor');
10
+ /** The core's `runInTenantScope` storage, read structurally (any core version, or none). */
11
+ const TENANT_SCOPE_SLOT = Symbol.for('@dudousxd/nestjs-authz:tenant-scope');
12
+ /** What the core's `runInTenantScope` / `runWithoutRequiredTenant` force here, if anything. */
13
+ function forced() {
14
+ const slot = globalThis[TENANT_SCOPE_SLOT];
15
+ const store = slot?.storage?.getStore?.();
16
+ if (!store)
17
+ return { relaxed: false };
18
+ const relaxed = store.required === false;
19
+ const id = store.tenantId;
20
+ return id === null || typeof id === 'string' ? { scope: { tenantId: id }, relaxed } : { relaxed };
21
+ }
22
+ /** The error `required` raises, shaped like nestjs-context's `TenantRequiredError`. */
23
+ export class TenantRequiredError extends ForbiddenException {
24
+ code = 'E_TENANT_REQUIRED';
25
+ constructor() {
26
+ super({
27
+ statusCode: 403,
28
+ error: 'Forbidden',
29
+ code: 'E_TENANT_REQUIRED',
30
+ message: 'This action needs an active tenant (organization). Select one and retry.',
31
+ });
32
+ this.name = 'TenantRequiredError';
33
+ }
34
+ }
35
+ /** Is tenancy on for this module? Call per check: the context can change between requests. */
36
+ function readTenancy(option, a, relaxed) {
37
+ if (option === false)
38
+ return { enabled: false };
39
+ if (typeof a?.tenancy !== 'function' || typeof a.tenantFilter !== 'function') {
40
+ return { enabled: false };
41
+ }
42
+ const own = typeof option === 'object' ? option : {};
43
+ const inherit = own.enabled === undefined || own.enabled === 'inherit';
44
+ const context = a.tenancy();
45
+ if (!(inherit ? context.enabled : own.enabled))
46
+ return { enabled: false };
47
+ const options = {};
48
+ if (own.kinds)
49
+ options.kinds = own.kinds;
50
+ if (own.family !== undefined)
51
+ options.family = own.family;
52
+ const required = relaxed ? false : (own.required ?? context.required === true);
53
+ if (relaxed)
54
+ options.required = false;
55
+ else if (own.required !== undefined)
56
+ options.required = own.required;
57
+ const tenantFilter = a.tenantFilter.bind(a);
58
+ return {
59
+ enabled: true,
60
+ kinds: own.kinds ?? context.kinds,
61
+ filter: () => {
62
+ // A context that knows `required` throws its own TenantRequiredError here.
63
+ const filter = tenantFilter(Object.keys(options).length > 0 ? options : undefined);
64
+ // An older one answers `tenantless`: raise the same error.
65
+ if (required && filter.mode === 'tenantless')
66
+ throw new TenantRequiredError();
67
+ return filter;
68
+ },
69
+ };
70
+ }
71
+ /** The levels of a `tenant` filter that scope this module, root first, the matched level last. */
72
+ function scopeLevels(filter, kinds) {
73
+ const path = filter.chain && filter.chain.length > 0
74
+ ? filter.chain
75
+ : filter.tenant.chain && filter.tenant.chain.length > 0
76
+ ? cutAt(filter.tenant.chain, filter.tenant)
77
+ : [filter.tenant];
78
+ const last = path[path.length - 1];
79
+ return path.filter((level) => level === last || !kinds || kinds.includes(level.kind));
80
+ }
81
+ /** `chain` up to and including `tenant` (the whole chain when it is not in it). */
82
+ function cutAt(chain, tenant) {
83
+ const at = chain.findIndex((level) => level.id === tenant.id && level.kind === tenant.kind);
84
+ return at === -1 ? [...chain, tenant] : chain.slice(0, at + 1);
85
+ }
86
+ /** The accessor found through DI, else the global slot `ContextModule` publishes. */
87
+ function effectiveAccessor(injected) {
88
+ if (injected)
89
+ return injected;
90
+ const slot = globalThis[SLOT];
91
+ const current = slot?.current;
92
+ return current && typeof current === 'object' ? current : undefined;
93
+ }
94
+ /** Today's behaviour without tenancy: the context's plain `tenantId()`, read defensively. */
95
+ function legacyTenantId(accessor) {
96
+ if (!accessor || typeof accessor.tenantId !== 'function')
97
+ return undefined;
98
+ try {
99
+ return accessor.tenantId() ?? undefined;
100
+ }
101
+ catch {
102
+ return undefined;
103
+ }
104
+ }
105
+ /** Is `ref` the context's current user? Tenant roles belong to the caller, nobody else. */
106
+ function isContextUser(ref, accessor) {
107
+ let current;
108
+ try {
109
+ current = accessor?.userRef?.();
110
+ }
111
+ catch {
112
+ current = undefined;
113
+ }
114
+ if (!current || current.id === undefined || current.id === null)
115
+ return false;
116
+ const a = normalizeUserRef(ref);
117
+ const b = normalizeUserRef(current);
118
+ return a.type === b.type && a.id === b.id;
119
+ }
120
+ /**
121
+ * Precedence: a scope forced by the core's `runInTenantScope` (the dev tools), then the
122
+ * explicit `tenant` resolver, then (tenancy on) the context tenant filter, then (tenancy off)
123
+ * the adapter's behaviour without tenancy. `tenant` mode scopes to that tenant and, for a nested
124
+ * tenant, to each level above it the module honours; `tenantless`, `all` and `system` use the
125
+ * global scope. With `required`, `tenantless` throws {@link TenantRequiredError}.
126
+ */
127
+ export function resolveRbacTenant(input) {
128
+ const force = forced();
129
+ const explicit = force.scope
130
+ ? force.scope.tenantId
131
+ : input.resolver
132
+ ? input.resolver(input.user)
133
+ : undefined;
134
+ const accessor = effectiveAccessor(input.accessor);
135
+ // An explicit scope never needs a tenant from the context.
136
+ const tenancy = readTenancy(input.tenancy, accessor, force.relaxed || explicit !== undefined);
137
+ const filter = tenancy.enabled ? tenancy.filter() : undefined;
138
+ const own = typeof input.tenancy === 'object' ? input.tenancy : {};
139
+ const levels = tenancy.enabled && filter?.mode === 'tenant' ? scopeLevels(filter, tenancy.kinds) : [];
140
+ let scopes;
141
+ if (explicit !== undefined) {
142
+ scopes = [explicit === null ? {} : { tenantId: explicit }];
143
+ }
144
+ else if (filter) {
145
+ scopes = levels.length > 0 ? levels.map((level) => ({ tenantId: level.id })) : [{}];
146
+ }
147
+ else if (input.legacyContextTenant) {
148
+ const id = legacyTenantId(input.accessor);
149
+ scopes = [id === undefined ? {} : { tenantId: id }];
150
+ }
151
+ else {
152
+ scopes = [{}];
153
+ }
154
+ const scope = scopes[scopes.length - 1] ?? {};
155
+ // The caller's role at each level in scope, mapped by `tenancy.roles`.
156
+ const map = own.roles;
157
+ const roles = new Set();
158
+ if (map && levels.length > 0 && isContextUser(input.ref, accessor)) {
159
+ const inScope = new Set(scopes.map((s) => s.tenantId));
160
+ const matched = filter?.mode === 'tenant' ? filter.tenant : undefined;
161
+ for (const level of levels) {
162
+ // The matched level's role may live only on the tenant itself, not on its chain entry.
163
+ const role = level.role ??
164
+ (matched && level.id === matched.id && level.kind === matched.kind
165
+ ? matched.role
166
+ : undefined);
167
+ if (role === undefined || !inScope.has(level.id))
168
+ continue;
169
+ if (!Object.prototype.hasOwnProperty.call(map, role))
170
+ continue;
171
+ const mapped = map[role];
172
+ for (const role of typeof mapped === 'string' ? [mapped] : (mapped ?? []))
173
+ roles.add(role);
174
+ }
175
+ }
176
+ return { scope, scopes, roles: [...roles] };
177
+ }
178
+ /**
179
+ * Run `read` once per scope of `tenant` and merge the results (one call for a flat tenant).
180
+ */
181
+ export async function acrossScopes(tenant, read) {
182
+ if (tenant.scopes.length <= 1)
183
+ return [...(await read(tenant.scope))];
184
+ const all = await Promise.all(tenant.scopes.map(read));
185
+ return [...new Set(all.flat())];
186
+ }
187
+ /** True when `test` holds in any scope of `tenant`. */
188
+ export async function inAnyScope(tenant, test) {
189
+ for (const scope of tenant.scopes)
190
+ if (await test(scope))
191
+ return true;
192
+ return false;
193
+ }
194
+ /**
195
+ * Locate the context accessor. Prefers a value injected into the module; falls back to a
196
+ * non-strict {@link ModuleRef} lookup so an accessor provided by ANY module (the app root, a
197
+ * global ContextModule) is still found: the RBAC module is global and its providers don't import
198
+ * the app's modules, so a plain `@Inject` would miss a root-provided accessor.
199
+ */
200
+ function resolveTenantContext(injected, moduleRef, cache) {
201
+ if (injected)
202
+ return injected;
203
+ if (cache.resolved)
204
+ return cache.value;
205
+ cache.resolved = true;
206
+ if (moduleRef) {
207
+ try {
208
+ cache.value = moduleRef.get(CONTEXT_ACCESSOR, { strict: false });
209
+ }
210
+ catch {
211
+ cache.value = undefined;
212
+ }
213
+ }
214
+ return cache.value;
215
+ }
216
+ /** The tenant scope (and `tenancy.roles` roles) of one check for `user`. */
217
+ export function rbacTenant(options, user, ref, injected, moduleRef, cache, legacyContextTenant) {
218
+ return resolveRbacTenant({
219
+ user,
220
+ ref,
221
+ resolver: options.tenant,
222
+ tenancy: options.tenancy,
223
+ accessor: resolveTenantContext(injected, moduleRef, cache),
224
+ legacyContextTenant,
225
+ });
226
+ }
227
+ //# sourceMappingURL=tenancy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tenancy.js","sourceRoot":"","sources":["../src/tenancy.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,0FAA0F;AAC1F,kGAAkG;AAClG,2FAA2F;AAC3F,eAAe;AACf,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAgB,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AA+EpD,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;AAEjE,4FAA4F;AAC5F,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;AAE5E,+FAA+F;AAC/F,SAAS,MAAM;IACb,MAAM,IAAI,GAAI,UAAiD,CAAC,iBAAiB,CAEpE,CAAC;IACd,MAAM,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,EAE1B,CAAC;IACd,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACtC,MAAM,OAAO,GAAG,KAA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,KAAsE;IAEtE,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,IAAI,KAAK,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC,KAAK,CAAC;IACvC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;IACtB,IAAI,SAAS,EAAE,CAAC;QACd,IAAI,CAAC;YACH,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,CAAwB,gBAAgB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1F,CAAC;QAAC,MAAM,CAAC;YACP,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC;QAC1B,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,KAAK,CAAC;AACrB,CAAC;AAQD,4EAA4E;AAC5E,MAAM,UAAU,UAAU,CACxB,OAA0F,EAC1F,IAAa,EACb,GAAY,EACZ,QAA2C,EAC3C,SAAgC,EAChC,KAAyB,EACzB,mBAA4B;IAE5B,OAAO,iBAAiB,CAAC;QACvB,IAAI;QACJ,GAAG;QACH,QAAQ,EAAE,OAAO,CAAC,MAAM;QACxB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,QAAQ,EAAE,oBAAoB,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC;QAC1D,mBAAmB;KACpB,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudousxd/nestjs-authz-prisma",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "Prisma RBAC persistence for @dudousxd/nestjs-authz — roles, permissions, and a Gate seam (zero connection ownership, structural client).",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,29 +38,30 @@
38
38
  "CHANGELOG.md"
39
39
  ],
40
40
  "peerDependencies": {
41
- "@dudousxd/nestjs-authz": ">=0.9.0 <0.10.0",
41
+ "@dudousxd/nestjs-authz": ">=0.10.0",
42
42
  "@nestjs/authorization": "^0.1.3",
43
43
  "@nestjs/common": "^12.0.0",
44
44
  "@nestjs/core": "^12.0.0",
45
45
  "reflect-metadata": ">=0.1.13"
46
46
  },
47
47
  "devDependencies": {
48
+ "@electric-sql/pglite": "0.4.6",
48
49
  "@nestjs/authorization": "0.1.3",
49
50
  "@nestjs/common": "12.0.1",
50
51
  "@nestjs/core": "12.0.1",
51
52
  "@nestjs/testing": "12.0.1",
52
53
  "@testcontainers/postgresql": "12.1.0",
53
- "@types/node": "22.20.5",
54
+ "@types/node": "24.19.2",
54
55
  "@types/pg": "8.23.1",
55
56
  "pg": "8.23.0",
56
57
  "reflect-metadata": "0.2.2",
57
58
  "rxjs": "7.8.2",
58
59
  "typescript": "5.9.3",
59
60
  "vitest": "3.2.7",
60
- "@dudousxd/nestjs-authz": "^0.9.0"
61
+ "@dudousxd/nestjs-authz": "^0.12.0"
61
62
  },
62
63
  "engines": {
63
- "node": ">=22"
64
+ "node": ">=24"
64
65
  },
65
66
  "scripts": {
66
67
  "build": "tsc -p tsconfig.json --incremental false",