@nwire/rbac 0.7.1 → 0.8.17

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.
@@ -6,7 +6,7 @@
6
6
  * - conditionsFor (CASL rulesToQuery surface)
7
7
  */
8
8
  import { describe, it, expect } from "vitest";
9
- import { permission, parsePermission, resolver, ownedBy, sameTenant, authorize, conditionsFor, defineAbility, ActionDeniedError, OwnershipMismatchError, RoleMissingError, isOwnershipMismatchError, } from "../rbac";
9
+ import { permission, parsePermission, resolver, ownedBy, sameTenant, authorize, conditionsFor, defineAbility, ActionDeniedError, OwnershipMismatchError, RoleMissingError, isOwnershipMismatchError, } from "../rbac.js";
10
10
  describe("permission() — typed strings", () => {
11
11
  it("produces resource:action format", () => {
12
12
  expect(permission("update", "Post")).toBe("update:Post");
@@ -15,7 +15,7 @@ import { describe, it, expect } from "vitest";
15
15
  import { z } from "zod";
16
16
  import { createApp, defineAction, defineHandler, defineModule, seedEnvelope } from "@nwire/forge";
17
17
  import { ForbiddenError } from "@nwire/auth";
18
- import { defineAbility, rbacPlugin, abilityFor, abilityFromCtx, subject } from "../rbac";
18
+ import { defineAbility, rbacPlugin, abilityFor, abilityFromCtx, subject } from "../rbac.js";
19
19
  // ─── Shared fixtures ─────────────────────────────────────────────
20
20
  const buildAbility = defineAbility((user, { allow }) => {
21
21
  if (!user)
package/dist/filters.d.ts CHANGED
@@ -20,7 +20,7 @@
20
20
  * bridges (`@casl/mongoose`, `@casl/prisma`, `@casl/drizzle`) drop right
21
21
  * in. We expose it; users pick their bridge.
22
22
  */
23
- import type { Ability } from "./rbac";
23
+ import type { Ability } from "./rbac.js";
24
24
  /**
25
25
  * The MongoDB-style disjunctive query the ability allows for the given
26
26
  * (action, subjectType). Three return shapes:
package/dist/rbac.d.ts CHANGED
@@ -109,8 +109,8 @@ export declare function abilityFor(buildAbility: (user: User | null) => Ability,
109
109
  */
110
110
  export declare function canKoa(verb: string, subj: string): import("koa").Middleware;
111
111
  export declare function abilityFromCtx(ctx: HandlerContext): Ability | null;
112
- export { permission, parsePermission, type Permission } from "./typed";
113
- export { resolver, ownedBy, sameTenant, authorize, type Resolver, type ResolverFn, } from "./resolvers";
114
- export { conditionsFor, type DrizzleFilterBuilder } from "./filters";
115
- export { ActionDeniedError, OwnershipMismatchError, ScopeMissingError, RoleMissingError, isOwnershipMismatchError, isScopeMissingError, isRoleMissingError, } from "./errors";
112
+ export { permission, parsePermission, type Permission } from "./typed.js";
113
+ export { resolver, ownedBy, sameTenant, authorize, type Resolver, type ResolverFn, } from "./resolvers.js";
114
+ export { conditionsFor, type DrizzleFilterBuilder } from "./filters.js";
115
+ export { ActionDeniedError, OwnershipMismatchError, ScopeMissingError, RoleMissingError, isOwnershipMismatchError, isScopeMissingError, isRoleMissingError, } from "./errors.js";
116
116
  //# sourceMappingURL=rbac.d.ts.map
package/dist/rbac.js CHANGED
@@ -170,8 +170,8 @@ export function abilityFromCtx(ctx) {
170
170
  // - conditionsFor → CASL accessibleBy for query-time filtering (no N+1)
171
171
  // - structured error subclasses (OwnershipMismatchError, ScopeMissing,
172
172
  // RoleMissing) so the API can tell the UI *why* a denial happened
173
- export { permission, parsePermission } from "./typed";
174
- export { resolver, ownedBy, sameTenant, authorize, } from "./resolvers";
175
- export { conditionsFor } from "./filters";
176
- export { ActionDeniedError, OwnershipMismatchError, ScopeMissingError, RoleMissingError, isOwnershipMismatchError, isScopeMissingError, isRoleMissingError, } from "./errors";
173
+ export { permission, parsePermission } from "./typed.js";
174
+ export { resolver, ownedBy, sameTenant, authorize, } from "./resolvers.js";
175
+ export { conditionsFor } from "./filters.js";
176
+ export { ActionDeniedError, OwnershipMismatchError, ScopeMissingError, RoleMissingError, isOwnershipMismatchError, isScopeMissingError, isRoleMissingError, } from "./errors.js";
177
177
  //# sourceMappingURL=rbac.js.map
package/dist/resolvers.js CHANGED
@@ -78,7 +78,7 @@ export function sameTenant() {
78
78
  * import { authorize, ownedBy } from "@nwire/rbac";
79
79
  * await authorize(user, "update", post, ownedBy());
80
80
  */
81
- import { OwnershipMismatchError } from "./errors";
81
+ import { OwnershipMismatchError } from "./errors.js";
82
82
  export async function authorize(user, action, subject, rule, opts = {}) {
83
83
  if (!user) {
84
84
  throw new OwnershipMismatchError({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nwire/rbac",
3
- "version": "0.7.1",
3
+ "version": "0.8.17",
4
4
  "description": "Nwire — RBAC + permissions wrapped around CASL. defineAbility(user => ...) declares what each user can do; rbacPlugin enforces it on every dispatch.",
5
5
  "keywords": [
6
6
  "authorization",
@@ -30,9 +30,9 @@
30
30
  "dependencies": {
31
31
  "@casl/ability": "^6.8.1",
32
32
  "koa": "^2.16.4",
33
- "@nwire/auth": "0.7.1",
34
- "@nwire/forge": "0.7.1",
35
- "@nwire/http": "0.7.1"
33
+ "@nwire/forge": "0.8.17",
34
+ "@nwire/http": "0.8.17",
35
+ "@nwire/auth": "0.8.17"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/node": "^22.19.9",
@@ -40,7 +40,7 @@
40
40
  "vitest": "^4.1.6"
41
41
  },
42
42
  "scripts": {
43
- "build": "tsc",
43
+ "build": "tsc && node ../../scripts/fix-dist-extensions.mjs dist",
44
44
  "dev": "tsc --watch",
45
45
  "typecheck": "tsc --noEmit"
46
46
  }