@schorts/shared-kernel 2.3.0 → 2.3.2

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 CHANGED
@@ -5,7 +5,19 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [2.3.0] - 2025-10-11
8
+ ## [2.3.2] - 2025-10-11
9
+
10
+ ### Added
11
+
12
+ - Added `NotAuthorized` exception.
13
+
14
+ ## [2.3.1] - 2025-10-11
15
+
16
+ ### Changed
17
+
18
+ - `userID` now is protected in the `RBACPolicy`.
19
+
20
+ ## [2.3.0] - 2025-10-10
9
21
 
10
22
  ### Added
11
23
 
package/README.md CHANGED
@@ -15,6 +15,10 @@ npm install @schorts/shared-kernel --save
15
15
  - **AuthProvider:** Abstract interface for authentication strategies.
16
16
  - **RequireAuthDecorator:** Method-level decorator for enforcing authentication.
17
17
 
18
+ ### 🛡️ RBAC (Role-Based Access Control)
19
+ - **RBACPolicy:** Abstract base class for defining role-based permission logic. Supports wildcard actions (manage) and resources (*), ownership checks, and composable access control strategies.
20
+ - **Permission:** Lightweight value object representing an action-resource pair (e.g., read:orders, manage:*).
21
+
18
22
  ### 📊 Criteria
19
23
 
20
24
  - **Criteria:** Fluent query builder for filtering, sorting, and pagination.
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotAuthorized = void 0;
4
+ var not_authorized_1 = require("./not-authorized");
5
+ Object.defineProperty(exports, "NotAuthorized", { enumerable: true, get: function () { return not_authorized_1.NotAuthorized; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/rbac/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAAxC,+GAAA,aAAa,OAAA"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotAuthorized = void 0;
4
+ class NotAuthorized extends Error {
5
+ }
6
+ exports.NotAuthorized = NotAuthorized;
7
+ //# sourceMappingURL=not-authorized.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"not-authorized.js","sourceRoot":"","sources":["../../../../src/rbac/exceptions/not-authorized.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAc,SAAQ,KAAK;CAAG;AAA3C,sCAA2C"}
@@ -1,6 +1,21 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.RBACPolicy = void 0;
4
18
  var rbac_policy_1 = require("./rbac-policy");
5
19
  Object.defineProperty(exports, "RBACPolicy", { enumerable: true, get: function () { return rbac_policy_1.RBACPolicy; } });
20
+ __exportStar(require("./exceptions"), exports);
6
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rbac/index.ts"],"names":[],"mappings":";;;AAGA,6CAA2C;AAAlC,yGAAA,UAAU,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rbac/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAGA,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,+CAA6B"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotAuthorized = void 0;
4
+ var not_authorized_1 = require("./not-authorized");
5
+ Object.defineProperty(exports, "NotAuthorized", { enumerable: true, get: function () { return not_authorized_1.NotAuthorized; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/rbac/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAAxC,+GAAA,aAAa,OAAA"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotAuthorized = void 0;
4
+ class NotAuthorized extends Error {
5
+ }
6
+ exports.NotAuthorized = NotAuthorized;
7
+ //# sourceMappingURL=not-authorized.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"not-authorized.js","sourceRoot":"","sources":["../../../../src/rbac/exceptions/not-authorized.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAc,SAAQ,KAAK;CAAG;AAA3C,sCAA2C"}
@@ -1,6 +1,21 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.RBACPolicy = void 0;
4
18
  var rbac_policy_1 = require("./rbac-policy");
5
19
  Object.defineProperty(exports, "RBACPolicy", { enumerable: true, get: function () { return rbac_policy_1.RBACPolicy; } });
20
+ __exportStar(require("./exceptions"), exports);
6
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rbac/index.ts"],"names":[],"mappings":";;;AAGA,6CAA2C;AAAlC,yGAAA,UAAU,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rbac/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAGA,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,+CAA6B"}
@@ -0,0 +1,2 @@
1
+ export { NotAuthorized } from "./not-authorized";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/rbac/exceptions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare class NotAuthorized extends Error {
2
+ }
3
+ //# sourceMappingURL=not-authorized.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"not-authorized.d.ts","sourceRoot":"","sources":["../../../../src/rbac/exceptions/not-authorized.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAc,SAAQ,KAAK;CAAG"}
@@ -1,4 +1,5 @@
1
1
  export type { Permission } from "./permission";
2
2
  export type { Resource } from "./resource";
3
3
  export { RBACPolicy } from "./rbac-policy";
4
+ export * from "./exceptions";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rbac/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rbac/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,cAAc,cAAc,CAAC"}
@@ -2,7 +2,7 @@ import { Permission } from './permission';
2
2
  import { Resource } from './resource';
3
3
  import { ValueObject } from '../value-objects';
4
4
  export declare abstract class RBACPolicy<Role extends string, UserID extends ValueObject> {
5
- abstract userID: UserID;
5
+ protected abstract userID: UserID;
6
6
  abstract getPermissions(role: Role): Permission[];
7
7
  can(role: Role, action: Permission['action'], resource: Resource): boolean;
8
8
  canAccessOwnedResource(resource: Resource): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"rbac-policy.d.ts","sourceRoot":"","sources":["../../../src/rbac/rbac-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,8BAAsB,UAAU,CAAC,IAAI,SAAS,MAAM,EAAE,MAAM,SAAS,WAAW;IAC9E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,UAAU,EAAE;IAEjD,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO;IAU1E,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO;IAInD,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO;CAGxF"}
1
+ {"version":3,"file":"rbac-policy.d.ts","sourceRoot":"","sources":["../../../src/rbac/rbac-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,8BAAsB,UAAU,CAAC,IAAI,SAAS,MAAM,EAAE,MAAM,SAAS,WAAW;IAC9E,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,UAAU,EAAE;IAEjD,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO;IAU1E,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO;IAInD,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO;CAGxF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schorts/shared-kernel",
3
- "version": "2.3.0",
3
+ "version": "2.3.2",
4
4
  "description": "A modular, type-safe foundation for building expressive, maintainable applications. This package provides core abstractions for domain modeling, HTTP integration, authentication, state management, and more — designed to be framework-agnostic and highly extensible.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -0,0 +1 @@
1
+ export { NotAuthorized } from "./not-authorized";
@@ -0,0 +1 @@
1
+ export class NotAuthorized extends Error {}
package/src/rbac/index.ts CHANGED
@@ -2,3 +2,4 @@ export type { Permission } from "./permission";
2
2
  export type { Resource } from "./resource";
3
3
 
4
4
  export { RBACPolicy } from "./rbac-policy";
5
+ export * from "./exceptions";
@@ -3,7 +3,7 @@ import { Resource } from './resource';
3
3
  import { ValueObject } from '../value-objects';
4
4
 
5
5
  export abstract class RBACPolicy<Role extends string, UserID extends ValueObject> {
6
- abstract userID: UserID;
6
+ protected abstract userID: UserID;
7
7
  abstract getPermissions(role: Role): Permission[];
8
8
 
9
9
  can(role: Role, action: Permission['action'], resource: Resource): boolean {