@dudousxd/nestjs-authz-prisma 0.2.0 → 0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,63 @@
1
1
  # @dudousxd/nestjs-authz-prisma
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#9](https://github.com/DavideCarvalho/nestjs-authz/pull/9) [`07d01de`](https://github.com/DavideCarvalho/nestjs-authz/commit/07d01de286e7dfcae5fbeb10b7e8d48533214087) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Ecosystem improvements across the authz packages.
8
+
9
+ ### Permissions
10
+
11
+ - **Wildcard / hierarchical permissions.** Permission strings now support wildcard
12
+ and hierarchical matching (e.g. `posts:*` or `posts:read:*`), so a single granted
13
+ permission can authorize a family of related actions instead of enumerating each one.
14
+
15
+ ### Authorization decisions
16
+
17
+ - **Deny reason / message surfaced on `ForbiddenException`.** When a check fails, the
18
+ reason for the denial is propagated onto the thrown `ForbiddenException`, making it
19
+ possible to return a meaningful message to the caller and to debug authorization
20
+ failures.
21
+ - **Gate `after` hook.** The Gate now exposes an `after` hook that runs once a decision
22
+ has been made, enabling cross-cutting concerns such as auditing, logging, and metrics.
23
+
24
+ ### Batch authorization
25
+
26
+ - **`allowsMany`** for evaluating multiple permission checks in a single call.
27
+ - **Batch `/authz/can` endpoint** so clients can resolve many checks in one round trip.
28
+ - **`createCanBatch`** client helper that batches `can` calls transparently.
29
+
30
+ ### Performance
31
+
32
+ - **Request-scoped permission cache.** Permissions resolved during a request are cached
33
+ for the lifetime of that request, avoiding repeated lookups on the hot path.
34
+
35
+ ### RBAC adapters (TypeORM)
36
+
37
+ - **Direct user permissions** granted to a user independent of their roles.
38
+ - **Tenant-scoped roles** so the same role can be assigned per tenant in multi-tenant
39
+ deployments.
40
+
41
+ ### Query scoping / policy filter (ABAC)
42
+
43
+ - **ORM-neutral constraint AST.** Policies can produce a portable constraint
44
+ representation describing which rows a subject may access.
45
+ - **Per-ORM application.** The constraint AST is translated and applied for
46
+ **TypeORM**, **MikroORM**, and **Prisma**, giving ABAC-style query scoping that
47
+ filters data at the database layer regardless of the ORM in use.
48
+
49
+ ### Testing
50
+
51
+ - **New `@dudousxd/nestjs-authz-testing` package** with fakes and helpers for testing
52
+ authorization in consumer applications.
53
+ - **Postgres / MySQL testcontainers + contract tests** so the ORM stores are verified
54
+ against real database engines, and a shared contract suite keeps the adapters
55
+ behaviorally consistent.
56
+
57
+ ### Housekeeping
58
+
59
+ - **Packaging hygiene** across the published packages.
60
+
3
61
  ## 0.2.0
4
62
 
5
63
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -4,4 +4,6 @@ export type { UserAuthz } from './prisma-authz.store.js';
4
4
  export { AUTHZ_RBAC_OPTIONS, AUTHZ_RBAC_STORE, AuthzRbacModule, defaultUserRefMapper, } from './authz-rbac.module.js';
5
5
  export type { AuthzRbacModuleAsyncOptions, AuthzRbacModuleOptions, UserRefMapper, } from './authz-rbac.module.js';
6
6
  export type { UserRef, UserRefInput } from './types.js';
7
+ export { applyScope, compileScope } from './scope.js';
8
+ export type { PrismaWhere, ScopeResolver } from './scope.js';
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,YAAY,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,2BAA2B,EAC3B,sBAAsB,EACtB,aAAa,GACd,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,YAAY,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,2BAA2B,EAC3B,sBAAsB,EACtB,aAAa,GACd,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACtD,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { PRISMA_CLIENT, } from './prisma-client.js';
2
2
  export { PrismaAuthzStore } from './prisma-authz.store.js';
3
3
  export { AUTHZ_RBAC_OPTIONS, AUTHZ_RBAC_STORE, AuthzRbacModule, defaultUserRefMapper, } from './authz-rbac.module.js';
4
+ export { applyScope, compileScope } from './scope.js';
4
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,GAGd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,GACrB,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,GAGd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAOhC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
@@ -42,8 +42,28 @@ export declare class PrismaAuthzStore {
42
42
  removeRole(user: UserRef, roleName: string): Promise<void>;
43
43
  /** The role names a user holds. */
44
44
  getRolesForUser(user: UserRef): Promise<string[]>;
45
- /** The flattened, distinct permission names a user has via their roles. */
45
+ /**
46
+ * The flattened, distinct permission names a user has via their roles.
47
+ *
48
+ * Contract: returns the FULL deduped set of granted permission NAMES — including
49
+ * wildcard grants such as `posts.*`. This is NOT an existence check; callers
50
+ * ({@link userHasPermission}, {@link getUserAuthz}) depend on the complete set.
51
+ *
52
+ * Fast path: when the injected client exposes `$queryRaw`, assemble the set in a
53
+ * SINGLE database round-trip via one JOIN (3 round-trips → 1). On ANY failure
54
+ * (missing `$queryRaw`, custom `@@map` table names, non-Postgres identifier
55
+ * quoting, etc.) it degrades to {@link getPermissionsViaDelegates}, so correctness
56
+ * is preserved everywhere and only the common (Postgres + documented schema) case
57
+ * gets the speedup.
58
+ */
46
59
  getPermissionsForUser(user: UserRef): Promise<string[]>;
60
+ /**
61
+ * The original three-query implementation (userRole → rolePermission → permission),
62
+ * returning the same deduped permission-name set as {@link getPermissionsForUser}.
63
+ * Used directly when `$queryRaw` is unavailable, and as the fallback when the raw
64
+ * fast path throws.
65
+ */
66
+ private getPermissionsViaDelegates;
47
67
  /** A user's roles + effective permissions in one shot. */
48
68
  getUserAuthz(user: UserRef): Promise<UserAuthz>;
49
69
  /** True when the user holds `permission` through any of their roles. */
@@ -1 +1 @@
1
- {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,IAAI,CAAC;IAUhE,4EAA4E;IACtE,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAShE,mCAAmC;IAC7B,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAWvD;;;;;;;;;;;;;OAaG;IACG,qBAAqB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IA0B7D;;;;;OAKG;YACW,0BAA0B;IAiBxC,0DAA0D;IACpD,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;IAQrD,wEAAwE;IAClE,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAI7E"}
@@ -144,9 +144,51 @@ let PrismaAuthzStore = class PrismaAuthzStore {
144
144
  const roles = await this.client.role.findMany({ where: { id: { in: roleIds } } });
145
145
  return roles.map((r) => r.name);
146
146
  }
147
- /** The flattened, distinct permission names a user has via their roles. */
147
+ /**
148
+ * The flattened, distinct permission names a user has via their roles.
149
+ *
150
+ * Contract: returns the FULL deduped set of granted permission NAMES — including
151
+ * wildcard grants such as `posts.*`. This is NOT an existence check; callers
152
+ * ({@link userHasPermission}, {@link getUserAuthz}) depend on the complete set.
153
+ *
154
+ * Fast path: when the injected client exposes `$queryRaw`, assemble the set in a
155
+ * SINGLE database round-trip via one JOIN (3 round-trips → 1). On ANY failure
156
+ * (missing `$queryRaw`, custom `@@map` table names, non-Postgres identifier
157
+ * quoting, etc.) it degrades to {@link getPermissionsViaDelegates}, so correctness
158
+ * is preserved everywhere and only the common (Postgres + documented schema) case
159
+ * gets the speedup.
160
+ */
148
161
  async getPermissionsForUser(user) {
149
162
  const { type, id } = normalizeUserRef(user);
163
+ const queryRaw = this.client.$queryRaw;
164
+ if (typeof queryRaw === 'function') {
165
+ try {
166
+ // Single JOIN across the three documented `@@map` tables. Identifiers are
167
+ // literal + double-quoted (Postgres); the user `${type}`/`${id}` VALUES go
168
+ // through the tagged template as BOUND params — never string-concatenated.
169
+ const rows = await queryRaw `
170
+ SELECT DISTINCT p."name" AS name
171
+ FROM "authz_permissions" p
172
+ JOIN "authz_role_permission" rp ON rp."permissionId" = p."id"
173
+ JOIN "authz_user_role" ur ON ur."roleId" = rp."roleId"
174
+ WHERE ur."userType" = ${type} AND ur."userId" = ${id}
175
+ `;
176
+ return [...new Set(rows.map((r) => r.name))];
177
+ }
178
+ catch {
179
+ // Raw path unsupported for this client/schema/dialect — fall back below.
180
+ return this.getPermissionsViaDelegates(type, id);
181
+ }
182
+ }
183
+ return this.getPermissionsViaDelegates(type, id);
184
+ }
185
+ /**
186
+ * The original three-query implementation (userRole → rolePermission → permission),
187
+ * returning the same deduped permission-name set as {@link getPermissionsForUser}.
188
+ * Used directly when `$queryRaw` is unavailable, and as the fallback when the raw
189
+ * fast path throws.
190
+ */
191
+ async getPermissionsViaDelegates(type, id) {
150
192
  const assignments = await this.client.userRole.findMany({
151
193
  where: { userType: type, userId: id },
152
194
  });
@@ -1 +1 @@
1
- {"version":3,"file":"prisma-authz.store.js","sourceRoot":"","sources":["../src/prisma-authz.store.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAA8B,MAAM,oBAAoB,CAAC;AAG/E,sFAAsF;AACtF,wFAAwF;AACxF,2FAA2F;AAC3F,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEpD,2EAA2E;AAC3E,SAAS,gBAAgB,CAAC,GAAY;IACpC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACvD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC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AAC,aAAa,CAAC,CAAA;;GAFb,gBAAgB,CAkM5B"}
@@ -54,6 +54,30 @@
54
54
  *
55
55
  * Apply it with `prisma migrate` / `prisma db push` — this adapter is
56
56
  * consumer-managed and never runs DDL.
57
+ *
58
+ * ## Optional single-round-trip fast path (`$queryRaw`)
59
+ *
60
+ * `getPermissionsForUser` can assemble a user's granted-permission set in ONE
61
+ * database round-trip via a raw JOIN instead of the default three sequential
62
+ * delegate queries. To allow that, the interface exposes an OPTIONAL `$queryRaw`
63
+ * tagged-template method (see {@link PrismaAuthzClientLike.$queryRaw}).
64
+ *
65
+ * Why raw SQL and not a Prisma relation filter?
66
+ * - A relation filter (`permission.findMany({ where: { rolePermissions: { some } } })`)
67
+ * would force every consumer to declare a full back-relation graph across all four
68
+ * models in THEIR `schema.prisma`. That couples this adapter to the consumer's
69
+ * schema shape and breaks the package's "minimal structural client, no relations
70
+ * required" philosophy. REJECTED.
71
+ * - A `$queryRaw` JOIN needs NO relation fields in the consumer's schema — it works
72
+ * off the existing tables/columns documented above. This preserves the decoupled,
73
+ * relation-free design. CHOSEN.
74
+ *
75
+ * The trade-off: the raw SQL hard-codes the documented `@@map` table names plus the
76
+ * (camelCase, unquoted-in-schema → must be double-quoted) column names, so it is NOT
77
+ * portable to every SQL dialect or custom `@@map`. The store therefore treats the raw
78
+ * path as an OPTIONAL optimization and gracefully FALLS BACK to the three-query path
79
+ * on any failure — correctness is preserved everywhere; speed is gained on the common
80
+ * (Postgres + documented schema) case.
57
81
  */
58
82
  /**
59
83
  * Minimal structural view of a Prisma model delegate (the methods the store calls).
@@ -86,6 +110,20 @@ export interface PrismaAuthzClientLike {
86
110
  permission: PrismaModelDelegate;
87
111
  rolePermission: PrismaModelDelegate;
88
112
  userRole: PrismaModelDelegate;
113
+ /**
114
+ * OPTIONAL tagged-template raw query, matching the real `PrismaClient.$queryRaw`
115
+ * signature. A real `PrismaClient` always provides it (so there is NO extra burden
116
+ * on consumers injecting one). It is declared OPTIONAL so that purely structural
117
+ * clients / in-memory fakes that omit it — or setups where the raw path is unsafe
118
+ * (non-Postgres quoting, custom `@@map` table names) — remain assignable and simply
119
+ * fall back to the three-query delegate path. See the file-level doc for the full
120
+ * raw-vs-relation rationale.
121
+ *
122
+ * The `any` value type mirrors `PrismaModelDelegate` above: a narrower
123
+ * `unknown`/`Record` would make a real `PrismaClient` not structurally assignable
124
+ * (arg/return-position variance), which is exactly what this package avoids.
125
+ */
126
+ $queryRaw?<T = unknown>(query: TemplateStringsArray, ...values: any[]): Promise<T>;
89
127
  }
90
128
  /**
91
129
  * DI token for the app-provided Prisma client ({@link PrismaAuthzClientLike})
@@ -1 +1 @@
1
- {"version":3,"file":"prisma-client.d.ts","sourceRoot":"","sources":["../src/prisma-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAmB;IAElC,MAAM,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,GAAG,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAE1C,SAAS,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,GAAG,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAE9C,QAAQ,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,GAAG,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAE/C,UAAU,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,GAAG,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC9D;AAED,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,UAAU,EAAE,mBAAmB,CAAC;IAChC,cAAc,EAAE,mBAAmB,CAAC;IACpC,QAAQ,EAAE,mBAAmB,CAAC;CAC/B;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,eAAqD,CAAC"}
1
+ {"version":3,"file":"prisma-client.d.ts","sourceRoot":"","sources":["../src/prisma-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgFG;AAEH;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAmB;IAElC,MAAM,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,GAAG,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAE1C,SAAS,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,GAAG,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAE9C,QAAQ,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,GAAG,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAE/C,UAAU,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,GAAG,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC9D;AAED,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,UAAU,EAAE,mBAAmB,CAAC;IAChC,cAAc,EAAE,mBAAmB,CAAC;IACpC,QAAQ,EAAE,mBAAmB,CAAC;IAE9B;;;;;;;;;;;;OAYG;IAEH,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACpF;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,eAAqD,CAAC"}
@@ -54,6 +54,30 @@
54
54
  *
55
55
  * Apply it with `prisma migrate` / `prisma db push` — this adapter is
56
56
  * consumer-managed and never runs DDL.
57
+ *
58
+ * ## Optional single-round-trip fast path (`$queryRaw`)
59
+ *
60
+ * `getPermissionsForUser` can assemble a user's granted-permission set in ONE
61
+ * database round-trip via a raw JOIN instead of the default three sequential
62
+ * delegate queries. To allow that, the interface exposes an OPTIONAL `$queryRaw`
63
+ * tagged-template method (see {@link PrismaAuthzClientLike.$queryRaw}).
64
+ *
65
+ * Why raw SQL and not a Prisma relation filter?
66
+ * - A relation filter (`permission.findMany({ where: { rolePermissions: { some } } })`)
67
+ * would force every consumer to declare a full back-relation graph across all four
68
+ * models in THEIR `schema.prisma`. That couples this adapter to the consumer's
69
+ * schema shape and breaks the package's "minimal structural client, no relations
70
+ * required" philosophy. REJECTED.
71
+ * - A `$queryRaw` JOIN needs NO relation fields in the consumer's schema — it works
72
+ * off the existing tables/columns documented above. This preserves the decoupled,
73
+ * relation-free design. CHOSEN.
74
+ *
75
+ * The trade-off: the raw SQL hard-codes the documented `@@map` table names plus the
76
+ * (camelCase, unquoted-in-schema → must be double-quoted) column names, so it is NOT
77
+ * portable to every SQL dialect or custom `@@map`. The store therefore treats the raw
78
+ * path as an OPTIONAL optimization and gracefully FALLS BACK to the three-query path
79
+ * on any failure — correctness is preserved everywhere; speed is gained on the common
80
+ * (Postgres + documented schema) case.
57
81
  */
58
82
  /**
59
83
  * DI token for the app-provided Prisma client ({@link PrismaAuthzClientLike})
@@ -1 +1 @@
1
- {"version":3,"file":"prisma-client.js","sourceRoot":"","sources":["../src/prisma-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AA8BH;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC"}
1
+ {"version":3,"file":"prisma-client.js","sourceRoot":"","sources":["../src/prisma-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgFG;AA8CH;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC"}
@@ -0,0 +1,54 @@
1
+ import type { ScopeConstraint } from '@dudousxd/nestjs-authz';
2
+ import type { Type } from '@nestjs/common';
3
+ /**
4
+ * The minimal scope-resolving surface shared by `Gate` and `BoundGate`. Accepting
5
+ * this (rather than `Gate`) lets the scope helpers take either a Gate (current/context
6
+ * user) or a `gate.forUser(...)` BoundGate without a cast. Mirrors the TypeORM and
7
+ * MikroORM adapters' `ScopeResolver` so all ORMs feel identical.
8
+ */
9
+ export interface ScopeResolver {
10
+ scope(entity: Type<unknown>, ability?: string): Promise<ScopeConstraint>;
11
+ }
12
+ /** A Prisma `where` object (structurally typed; the consumer's generated input is narrower). */
13
+ export type PrismaWhere = Record<string, unknown>;
14
+ /**
15
+ * Compile an ORM-neutral {@link ScopeConstraint} into a Prisma `where` object.
16
+ *
17
+ * Terminal/empty semantics (matching the core AST and the TypeORM/MikroORM adapters):
18
+ * - `allow-all` → `{}` (an empty where matches EVERY row);
19
+ * - `deny-all` → `{ OR: [] }` (an empty OR matches NO row);
20
+ * - empty `in` → no rows (`{ OR: [] }`); empty `nin` → all rows (`{}`);
21
+ * - empty `and` group → all rows; empty `or` group → no rows.
22
+ *
23
+ * Operator mapping:
24
+ * - `eq` → `{ field: { equals } }`; `ne` → `{ field: { not } }`;
25
+ * - `gt/gte/lt/lte` → `{ field: { gt/gte/lt/lte } }`;
26
+ * - `in/nin` → `{ field: { in/notIn: [...] } }` (a scalar value is wrapped to a single
27
+ * element);
28
+ * - `isNull` → `{ field: { equals: null } }`; `isNotNull` → `{ field: { not: null } }`;
29
+ * - `and`/`or` → `{ AND: [...] }` / `{ OR: [...] }`.
30
+ *
31
+ * SAFE: only VALUES come from the (untrusted) policy result and Prisma binds them as
32
+ * parameters. Field names become object keys (a column/relation path), so each is
33
+ * validated against {@link assertSafeIdentifier} — a hostile field throws.
34
+ */
35
+ export declare function compileScope(constraint: ScopeConstraint): PrismaWhere;
36
+ /**
37
+ * Ergonomic entry point: resolve the query scope for the current (context) user via
38
+ * the {@link Gate} and return the Prisma `where` to pass to `model.findMany`.
39
+ * Equivalent to `compileScope(await gate.scope(entity, ability))`.
40
+ *
41
+ * Mirrors the TypeORM/MikroORM adapters' `applyScope` shape (gate + entity), but returns
42
+ * the `where` instead of mutating a query builder, because Prisma's idiomatic collection
43
+ * fetch is `prisma.post.findMany({ where })`:
44
+ *
45
+ * ```ts
46
+ * const where = await applyScope(gate, Post); // current user's accessible posts
47
+ * const posts = await prisma.post.findMany({ where });
48
+ * ```
49
+ *
50
+ * Combine with extra criteria via Prisma's own `AND`:
51
+ * `prisma.post.findMany({ where: { AND: [where, { published: true }] } })`.
52
+ */
53
+ export declare function applyScope(gate: ScopeResolver, entity: Type<unknown>, ability?: string): Promise<PrismaWhere>;
54
+ //# sourceMappingURL=scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EAGhB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC1E;AAED,gGAAgG;AAChG,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAmClD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,eAAe,GAAG,WAAW,CA+BrE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,EACrB,OAAO,SAAY,GAClB,OAAO,CAAC,WAAW,CAAC,CAEtB"}
package/dist/scope.js ADDED
@@ -0,0 +1,108 @@
1
+ /**
2
+ * SQL identifiers (column names) become object KEYS in the emitted `where`. Prisma binds
3
+ * VALUES as parameters, but a field name is interpreted as a column/relation path on the
4
+ * model, so a hostile name must never reach the query engine. We restrict field names to
5
+ * the same conservative allowlist the TypeORM adapter uses (letters/digits/underscore,
6
+ * not leading-digit) and reject anything else loudly.
7
+ */
8
+ const SAFE_IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
9
+ function assertSafeIdentifier(value, what) {
10
+ if (!SAFE_IDENTIFIER.test(value)) {
11
+ throw new Error(`Unsafe ${what}: ${JSON.stringify(value)}. Identifiers must match /^[A-Za-z_][A-Za-z0-9_]*$/ (letters, digits, underscore; not starting with a digit). This blocks injection via configured names.`);
12
+ }
13
+ }
14
+ /**
15
+ * An always-false predicate as a Prisma `where`. Prisma treats an EMPTY `OR` array as
16
+ * "match nothing" (an OR over zero alternatives can never be satisfied), which is the
17
+ * documented, portable way to express a deny-all filter — parallel to the core AST's
18
+ * "empty OR is the zero" rule and the TypeORM adapter's `1 = 0`.
19
+ */
20
+ const ALWAYS_FALSE = { OR: [] };
21
+ /** Prisma filter-condition keys for the binary comparison operators. */
22
+ const BINARY_OPS = {
23
+ gt: 'gt',
24
+ gte: 'gte',
25
+ lt: 'lt',
26
+ lte: 'lte',
27
+ };
28
+ /**
29
+ * Compile an ORM-neutral {@link ScopeConstraint} into a Prisma `where` object.
30
+ *
31
+ * Terminal/empty semantics (matching the core AST and the TypeORM/MikroORM adapters):
32
+ * - `allow-all` → `{}` (an empty where matches EVERY row);
33
+ * - `deny-all` → `{ OR: [] }` (an empty OR matches NO row);
34
+ * - empty `in` → no rows (`{ OR: [] }`); empty `nin` → all rows (`{}`);
35
+ * - empty `and` group → all rows; empty `or` group → no rows.
36
+ *
37
+ * Operator mapping:
38
+ * - `eq` → `{ field: { equals } }`; `ne` → `{ field: { not } }`;
39
+ * - `gt/gte/lt/lte` → `{ field: { gt/gte/lt/lte } }`;
40
+ * - `in/nin` → `{ field: { in/notIn: [...] } }` (a scalar value is wrapped to a single
41
+ * element);
42
+ * - `isNull` → `{ field: { equals: null } }`; `isNotNull` → `{ field: { not: null } }`;
43
+ * - `and`/`or` → `{ AND: [...] }` / `{ OR: [...] }`.
44
+ *
45
+ * SAFE: only VALUES come from the (untrusted) policy result and Prisma binds them as
46
+ * parameters. Field names become object keys (a column/relation path), so each is
47
+ * validated against {@link assertSafeIdentifier} — a hostile field throws.
48
+ */
49
+ export function compileScope(constraint) {
50
+ if (constraint.kind === 'all')
51
+ return {};
52
+ if (constraint.kind === 'none')
53
+ return { ...ALWAYS_FALSE };
54
+ const compileCondition = (c) => {
55
+ assertSafeIdentifier(c.field, `scope field "${c.field}"`);
56
+ if (c.op === 'eq')
57
+ return { [c.field]: { equals: c.value } };
58
+ if (c.op === 'ne')
59
+ return { [c.field]: { not: c.value } };
60
+ if (c.op === 'isNull')
61
+ return { [c.field]: { equals: null } };
62
+ if (c.op === 'isNotNull')
63
+ return { [c.field]: { not: null } };
64
+ if (c.op === 'in' || c.op === 'nin') {
65
+ const values = Array.isArray(c.value) ? c.value : [c.value];
66
+ // An empty `in` matches nothing; an empty `nin` matches everything.
67
+ if (values.length === 0)
68
+ return c.op === 'in' ? { ...ALWAYS_FALSE } : {};
69
+ const key = c.op === 'in' ? 'in' : 'notIn';
70
+ return { [c.field]: { [key]: values } };
71
+ }
72
+ const token = BINARY_OPS[c.op];
73
+ if (!token)
74
+ throw new Error(`Unsupported scope operator: ${c.op}`);
75
+ return { [c.field]: { [token]: c.value } };
76
+ };
77
+ const compileNode = (node) => {
78
+ if (node.kind === 'condition')
79
+ return compileCondition(node);
80
+ // An empty `and` is the identity (all rows); an empty `or` is the zero (no rows).
81
+ if (node.nodes.length === 0)
82
+ return node.kind === 'and' ? {} : { ...ALWAYS_FALSE };
83
+ const children = node.nodes.map(compileNode);
84
+ return node.kind === 'and' ? { AND: children } : { OR: children };
85
+ };
86
+ return compileNode(constraint);
87
+ }
88
+ /**
89
+ * Ergonomic entry point: resolve the query scope for the current (context) user via
90
+ * the {@link Gate} and return the Prisma `where` to pass to `model.findMany`.
91
+ * Equivalent to `compileScope(await gate.scope(entity, ability))`.
92
+ *
93
+ * Mirrors the TypeORM/MikroORM adapters' `applyScope` shape (gate + entity), but returns
94
+ * the `where` instead of mutating a query builder, because Prisma's idiomatic collection
95
+ * fetch is `prisma.post.findMany({ where })`:
96
+ *
97
+ * ```ts
98
+ * const where = await applyScope(gate, Post); // current user's accessible posts
99
+ * const posts = await prisma.post.findMany({ where });
100
+ * ```
101
+ *
102
+ * Combine with extra criteria via Prisma's own `AND`:
103
+ * `prisma.post.findMany({ where: { AND: [where, { published: true }] } })`.
104
+ */
105
+ export async function applyScope(gate, entity, ability = 'viewAny') {
106
+ return compileScope(await gate.scope(entity, ability));
107
+ }
108
+ //# sourceMappingURL=scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.js","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAqBA;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,0BAA0B,CAAC;AAEnD,SAAS,oBAAoB,CAAC,KAAa,EAAE,IAAY;IACvD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CACb,UAAU,IAAI,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,2JAA2J,CACpM,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,YAAY,GAAgB,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;AAE7C,wEAAwE;AACxE,MAAM,UAAU,GAAgE;IAC9E,EAAE,EAAE,IAAI;IACR,GAAG,EAAE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E,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;IACpE,CAAC,CAAC;IAEF,OAAO,WAAW,CAAC,UAAU,CAAC,CAAC;AACjC,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,IAAmB,EACnB,MAAqB,EACrB,OAAO,GAAG,SAAS;IAEnB,OAAO,YAAY,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AACzD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudousxd/nestjs-authz-prisma",
3
- "version": "0.2.0",
3
+ "version": "0.3.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": {
@@ -34,12 +34,15 @@
34
34
  "@nestjs/common": "^11.0.0",
35
35
  "@nestjs/core": "^11.0.0",
36
36
  "@nestjs/testing": "^11.0.0",
37
+ "@testcontainers/postgresql": "^12.0.3",
37
38
  "@types/node": "^20.0.0",
39
+ "@types/pg": "^8.11.0",
40
+ "pg": "^8.21.0",
38
41
  "reflect-metadata": "^0.2.2",
39
42
  "rxjs": "^7.8.1",
40
43
  "typescript": "^5.4.0",
41
44
  "vitest": "^3.0.0",
42
- "@dudousxd/nestjs-authz": "^0.4.0"
45
+ "@dudousxd/nestjs-authz": "^0.6.0"
43
46
  },
44
47
  "engines": {
45
48
  "node": ">=20"
@@ -56,6 +59,7 @@
56
59
  "scripts": {
57
60
  "build": "tsc -p tsconfig.json",
58
61
  "test": "vitest run --passWithNoTests",
62
+ "test:db:pg": "AUTHZ_TEST_DIALECT=postgres vitest run --config vitest.db.config.ts",
59
63
  "test:watch": "vitest",
60
64
  "typecheck": "tsc -p tsconfig.json --noEmit"
61
65
  }