@ereactthohir/core 1.1.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.
Files changed (247) hide show
  1. package/README.md +39 -0
  2. package/dist/database/MigrationRunner.d.ts +21 -0
  3. package/dist/database/MigrationRunner.d.ts.map +1 -0
  4. package/dist/database/MigrationRunner.js +60 -0
  5. package/dist/database/MigrationRunner.js.map +1 -0
  6. package/dist/database/Model.d.ts +81 -0
  7. package/dist/database/Model.d.ts.map +1 -0
  8. package/dist/database/Model.js +186 -0
  9. package/dist/database/Model.js.map +1 -0
  10. package/dist/database/QueryBuilder.d.ts +132 -0
  11. package/dist/database/QueryBuilder.d.ts.map +1 -0
  12. package/dist/database/QueryBuilder.js +267 -0
  13. package/dist/database/QueryBuilder.js.map +1 -0
  14. package/dist/database/drivers/SawitDriver.d.ts +7 -0
  15. package/dist/database/drivers/SawitDriver.d.ts.map +1 -0
  16. package/dist/database/drivers/SawitDriver.js +28 -0
  17. package/dist/database/drivers/SawitDriver.js.map +1 -0
  18. package/dist/foundation/Application.d.ts +23 -0
  19. package/dist/foundation/Application.d.ts.map +1 -0
  20. package/dist/foundation/Application.js +71 -0
  21. package/dist/foundation/Application.js.map +1 -0
  22. package/dist/foundation/Cache.d.ts +35 -0
  23. package/dist/foundation/Cache.d.ts.map +1 -0
  24. package/dist/foundation/Cache.js +92 -0
  25. package/dist/foundation/Cache.js.map +1 -0
  26. package/dist/foundation/Config.d.ts +9 -0
  27. package/dist/foundation/Config.d.ts.map +1 -0
  28. package/dist/foundation/Config.js +31 -0
  29. package/dist/foundation/Config.js.map +1 -0
  30. package/dist/foundation/Container.d.ts +24 -0
  31. package/dist/foundation/Container.d.ts.map +1 -0
  32. package/dist/foundation/Container.js +94 -0
  33. package/dist/foundation/Container.js.map +1 -0
  34. package/dist/foundation/Env.d.ts +17 -0
  35. package/dist/foundation/Env.d.ts.map +1 -0
  36. package/dist/foundation/Env.js +57 -0
  37. package/dist/foundation/Env.js.map +1 -0
  38. package/dist/foundation/Events.d.ts +9 -0
  39. package/dist/foundation/Events.d.ts.map +1 -0
  40. package/dist/foundation/Events.js +23 -0
  41. package/dist/foundation/Events.js.map +1 -0
  42. package/dist/foundation/Hooks.d.ts +9 -0
  43. package/dist/foundation/Hooks.d.ts.map +1 -0
  44. package/dist/foundation/Hooks.js +28 -0
  45. package/dist/foundation/Hooks.js.map +1 -0
  46. package/dist/foundation/Logger.d.ts +6 -0
  47. package/dist/foundation/Logger.d.ts.map +1 -0
  48. package/dist/foundation/Logger.js +16 -0
  49. package/dist/foundation/Logger.js.map +1 -0
  50. package/dist/foundation/Middleware.d.ts +7 -0
  51. package/dist/foundation/Middleware.d.ts.map +1 -0
  52. package/dist/foundation/Middleware.js +7 -0
  53. package/dist/foundation/Middleware.js.map +1 -0
  54. package/dist/foundation/Pipeline.d.ts +14 -0
  55. package/dist/foundation/Pipeline.d.ts.map +1 -0
  56. package/dist/foundation/Pipeline.js +63 -0
  57. package/dist/foundation/Pipeline.js.map +1 -0
  58. package/dist/foundation/Queue.d.ts +11 -0
  59. package/dist/foundation/Queue.d.ts.map +1 -0
  60. package/dist/foundation/Queue.js +38 -0
  61. package/dist/foundation/Queue.js.map +1 -0
  62. package/dist/foundation/RateLimiter.d.ts +16 -0
  63. package/dist/foundation/RateLimiter.d.ts.map +1 -0
  64. package/dist/foundation/RateLimiter.js +51 -0
  65. package/dist/foundation/RateLimiter.js.map +1 -0
  66. package/dist/foundation/Scheduler.d.ts +10 -0
  67. package/dist/foundation/Scheduler.d.ts.map +1 -0
  68. package/dist/foundation/Scheduler.js +48 -0
  69. package/dist/foundation/Scheduler.js.map +1 -0
  70. package/dist/foundation/ServiceProvider.d.ts +23 -0
  71. package/dist/foundation/ServiceProvider.d.ts.map +1 -0
  72. package/dist/foundation/ServiceProvider.js +28 -0
  73. package/dist/foundation/ServiceProvider.js.map +1 -0
  74. package/dist/foundation/Session.d.ts +26 -0
  75. package/dist/foundation/Session.d.ts.map +1 -0
  76. package/dist/foundation/Session.js +59 -0
  77. package/dist/foundation/Session.js.map +1 -0
  78. package/dist/foundation/View.d.ts +6 -0
  79. package/dist/foundation/View.d.ts.map +1 -0
  80. package/dist/foundation/View.js +207 -0
  81. package/dist/foundation/View.js.map +1 -0
  82. package/dist/http/ApiResponse.d.ts +38 -0
  83. package/dist/http/ApiResponse.d.ts.map +1 -0
  84. package/dist/http/ApiResponse.js +152 -0
  85. package/dist/http/ApiResponse.js.map +1 -0
  86. package/dist/http/Controller.d.ts +3 -0
  87. package/dist/http/Controller.d.ts.map +1 -0
  88. package/dist/http/Controller.js +7 -0
  89. package/dist/http/Controller.js.map +1 -0
  90. package/dist/http/ExceptionHandler.d.ts +6 -0
  91. package/dist/http/ExceptionHandler.d.ts.map +1 -0
  92. package/dist/http/ExceptionHandler.js +32 -0
  93. package/dist/http/ExceptionHandler.js.map +1 -0
  94. package/dist/http/Kernel.d.ts +8 -0
  95. package/dist/http/Kernel.d.ts.map +1 -0
  96. package/dist/http/Kernel.js +59 -0
  97. package/dist/http/Kernel.js.map +1 -0
  98. package/dist/http/Middleware/AuthMiddleware.d.ts +8 -0
  99. package/dist/http/Middleware/AuthMiddleware.d.ts.map +1 -0
  100. package/dist/http/Middleware/AuthMiddleware.js +17 -0
  101. package/dist/http/Middleware/AuthMiddleware.js.map +1 -0
  102. package/dist/http/Request.d.ts +35 -0
  103. package/dist/http/Request.d.ts.map +1 -0
  104. package/dist/http/Request.js +106 -0
  105. package/dist/http/Request.js.map +1 -0
  106. package/dist/http/Response.d.ts +26 -0
  107. package/dist/http/Response.d.ts.map +1 -0
  108. package/dist/http/Response.js +90 -0
  109. package/dist/http/Response.js.map +1 -0
  110. package/dist/http/Router.d.ts +46 -0
  111. package/dist/http/Router.d.ts.map +1 -0
  112. package/dist/http/Router.js +150 -0
  113. package/dist/http/Router.js.map +1 -0
  114. package/dist/index.d.ts +38 -0
  115. package/dist/index.d.ts.map +1 -0
  116. package/dist/index.js +55 -0
  117. package/dist/index.js.map +1 -0
  118. package/dist/security/CSRF.d.ts +18 -0
  119. package/dist/security/CSRF.d.ts.map +1 -0
  120. package/dist/security/CSRF.js +79 -0
  121. package/dist/security/CSRF.js.map +1 -0
  122. package/dist/security/Encrypter.d.ts +18 -0
  123. package/dist/security/Encrypter.d.ts.map +1 -0
  124. package/dist/security/Encrypter.js +75 -0
  125. package/dist/security/Encrypter.js.map +1 -0
  126. package/dist/security/InputSanitizer.d.ts +23 -0
  127. package/dist/security/InputSanitizer.d.ts.map +1 -0
  128. package/dist/security/InputSanitizer.js +65 -0
  129. package/dist/security/InputSanitizer.js.map +1 -0
  130. package/dist/security/PasswordHasher.d.ts +22 -0
  131. package/dist/security/PasswordHasher.d.ts.map +1 -0
  132. package/dist/security/PasswordHasher.js +68 -0
  133. package/dist/security/PasswordHasher.js.map +1 -0
  134. package/dist/services/Auth.d.ts +20 -0
  135. package/dist/services/Auth.d.ts.map +1 -0
  136. package/dist/services/Auth.js +28 -0
  137. package/dist/services/Auth.js.map +1 -0
  138. package/dist/services/Gate.d.ts +10 -0
  139. package/dist/services/Gate.d.ts.map +1 -0
  140. package/dist/services/Gate.js +36 -0
  141. package/dist/services/Gate.js.map +1 -0
  142. package/dist/services/Service.d.ts +4 -0
  143. package/dist/services/Service.d.ts.map +1 -0
  144. package/dist/services/Service.js +7 -0
  145. package/dist/services/Service.js.map +1 -0
  146. package/dist/services/Validator.d.ts +8 -0
  147. package/dist/services/Validator.d.ts.map +1 -0
  148. package/dist/services/Validator.js +39 -0
  149. package/dist/services/Validator.js.map +1 -0
  150. package/dist/src/database/Model.d.ts +13 -0
  151. package/dist/src/database/Model.d.ts.map +1 -0
  152. package/dist/src/database/Model.js +37 -0
  153. package/dist/src/database/Model.js.map +1 -0
  154. package/dist/src/database/QueryBuilder.d.ts +15 -0
  155. package/dist/src/database/QueryBuilder.d.ts.map +1 -0
  156. package/dist/src/database/QueryBuilder.js +43 -0
  157. package/dist/src/database/QueryBuilder.js.map +1 -0
  158. package/dist/src/database/drivers/SawitDriver.d.ts +7 -0
  159. package/dist/src/database/drivers/SawitDriver.d.ts.map +1 -0
  160. package/dist/src/database/drivers/SawitDriver.js +28 -0
  161. package/dist/src/database/drivers/SawitDriver.js.map +1 -0
  162. package/dist/src/foundation/Application.d.ts +13 -0
  163. package/dist/src/foundation/Application.d.ts.map +1 -0
  164. package/dist/src/foundation/Application.js +41 -0
  165. package/dist/src/foundation/Application.js.map +1 -0
  166. package/dist/src/foundation/Container.d.ts +11 -0
  167. package/dist/src/foundation/Container.d.ts.map +1 -0
  168. package/dist/src/foundation/Container.js +43 -0
  169. package/dist/src/foundation/Container.js.map +1 -0
  170. package/dist/src/foundation/Events.d.ts +9 -0
  171. package/dist/src/foundation/Events.d.ts.map +1 -0
  172. package/dist/src/foundation/Events.js +23 -0
  173. package/dist/src/foundation/Events.js.map +1 -0
  174. package/dist/src/foundation/Logger.d.ts +6 -0
  175. package/dist/src/foundation/Logger.d.ts.map +1 -0
  176. package/dist/src/foundation/Logger.js +16 -0
  177. package/dist/src/foundation/Logger.js.map +1 -0
  178. package/dist/src/foundation/Queue.d.ts +11 -0
  179. package/dist/src/foundation/Queue.d.ts.map +1 -0
  180. package/dist/src/foundation/Queue.js +38 -0
  181. package/dist/src/foundation/Queue.js.map +1 -0
  182. package/dist/src/foundation/Scheduler.d.ts +10 -0
  183. package/dist/src/foundation/Scheduler.d.ts.map +1 -0
  184. package/dist/src/foundation/Scheduler.js +48 -0
  185. package/dist/src/foundation/Scheduler.js.map +1 -0
  186. package/dist/src/foundation/ServiceProvider.d.ts +13 -0
  187. package/dist/src/foundation/ServiceProvider.d.ts.map +1 -0
  188. package/dist/src/foundation/ServiceProvider.js +14 -0
  189. package/dist/src/foundation/ServiceProvider.js.map +1 -0
  190. package/dist/src/foundation/View.d.ts +6 -0
  191. package/dist/src/foundation/View.d.ts.map +1 -0
  192. package/dist/src/foundation/View.js +37 -0
  193. package/dist/src/foundation/View.js.map +1 -0
  194. package/dist/src/http/Controller.d.ts +3 -0
  195. package/dist/src/http/Controller.d.ts.map +1 -0
  196. package/dist/src/http/Controller.js +7 -0
  197. package/dist/src/http/Controller.js.map +1 -0
  198. package/dist/src/http/ExceptionHandler.d.ts +6 -0
  199. package/dist/src/http/ExceptionHandler.d.ts.map +1 -0
  200. package/dist/src/http/ExceptionHandler.js +32 -0
  201. package/dist/src/http/ExceptionHandler.js.map +1 -0
  202. package/dist/src/http/Kernel.d.ts +8 -0
  203. package/dist/src/http/Kernel.d.ts.map +1 -0
  204. package/dist/src/http/Kernel.js +58 -0
  205. package/dist/src/http/Kernel.js.map +1 -0
  206. package/dist/src/http/Middleware/AuthMiddleware.d.ts +8 -0
  207. package/dist/src/http/Middleware/AuthMiddleware.d.ts.map +1 -0
  208. package/dist/src/http/Middleware/AuthMiddleware.js +17 -0
  209. package/dist/src/http/Middleware/AuthMiddleware.js.map +1 -0
  210. package/dist/src/http/Router.d.ts +27 -0
  211. package/dist/src/http/Router.d.ts.map +1 -0
  212. package/dist/src/http/Router.js +74 -0
  213. package/dist/src/http/Router.js.map +1 -0
  214. package/dist/src/index.d.ts +20 -0
  215. package/dist/src/index.d.ts.map +1 -0
  216. package/dist/src/index.js +37 -0
  217. package/dist/src/index.js.map +1 -0
  218. package/dist/src/services/Auth.d.ts +20 -0
  219. package/dist/src/services/Auth.d.ts.map +1 -0
  220. package/dist/src/services/Auth.js +28 -0
  221. package/dist/src/services/Auth.js.map +1 -0
  222. package/dist/src/services/Gate.d.ts +10 -0
  223. package/dist/src/services/Gate.d.ts.map +1 -0
  224. package/dist/src/services/Gate.js +36 -0
  225. package/dist/src/services/Gate.js.map +1 -0
  226. package/dist/src/services/Service.d.ts +4 -0
  227. package/dist/src/services/Service.d.ts.map +1 -0
  228. package/dist/src/services/Service.js +7 -0
  229. package/dist/src/services/Service.js.map +1 -0
  230. package/dist/src/services/Validator.d.ts +8 -0
  231. package/dist/src/services/Validator.d.ts.map +1 -0
  232. package/dist/src/services/Validator.js +39 -0
  233. package/dist/src/services/Validator.js.map +1 -0
  234. package/dist/testing/Factory.d.ts +31 -0
  235. package/dist/testing/Factory.d.ts.map +1 -0
  236. package/dist/testing/Factory.js +68 -0
  237. package/dist/testing/Factory.js.map +1 -0
  238. package/dist/testing/TestHelpers.d.ts +65 -0
  239. package/dist/testing/TestHelpers.d.ts.map +1 -0
  240. package/dist/testing/TestHelpers.js +141 -0
  241. package/dist/testing/TestHelpers.js.map +1 -0
  242. package/dist/tests/Application.test.d.ts +2 -0
  243. package/dist/tests/Application.test.d.ts.map +1 -0
  244. package/dist/tests/Application.test.js +22 -0
  245. package/dist/tests/Application.test.js.map +1 -0
  246. package/dist/tsconfig.tsbuildinfo +1 -0
  247. package/package.json +39 -0
package/dist/index.js ADDED
@@ -0,0 +1,55 @@
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
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.VERSION = void 0;
18
+ __exportStar(require("./foundation/Application"), exports);
19
+ __exportStar(require("./foundation/Container"), exports);
20
+ __exportStar(require("./foundation/ServiceProvider"), exports);
21
+ __exportStar(require("./foundation/Logger"), exports);
22
+ __exportStar(require("./foundation/Events"), exports);
23
+ __exportStar(require("./foundation/Queue"), exports);
24
+ __exportStar(require("./foundation/Scheduler"), exports);
25
+ __exportStar(require("./foundation/Config"), exports);
26
+ __exportStar(require("./foundation/Hooks"), exports);
27
+ __exportStar(require("./foundation/Middleware"), exports);
28
+ __exportStar(require("./foundation/Cache"), exports);
29
+ __exportStar(require("./foundation/Session"), exports);
30
+ __exportStar(require("./foundation/RateLimiter"), exports);
31
+ __exportStar(require("./foundation/Env"), exports);
32
+ __exportStar(require("./foundation/Pipeline"), exports);
33
+ __exportStar(require("./http/Controller"), exports);
34
+ __exportStar(require("./http/Router"), exports);
35
+ __exportStar(require("./http/Kernel"), exports);
36
+ __exportStar(require("./http/Request"), exports);
37
+ __exportStar(require("./http/Response"), exports);
38
+ __exportStar(require("./http/ApiResponse"), exports);
39
+ __exportStar(require("./database/Model"), exports);
40
+ __exportStar(require("./database/QueryBuilder"), exports);
41
+ __exportStar(require("./database/MigrationRunner"), exports);
42
+ __exportStar(require("./database/drivers/SawitDriver"), exports);
43
+ __exportStar(require("./services/Service"), exports);
44
+ __exportStar(require("./services/Auth"), exports);
45
+ __exportStar(require("./services/Gate"), exports);
46
+ __exportStar(require("./services/Validator"), exports);
47
+ __exportStar(require("./foundation/View"), exports);
48
+ __exportStar(require("./security/CSRF"), exports);
49
+ __exportStar(require("./security/Encrypter"), exports);
50
+ __exportStar(require("./security/InputSanitizer"), exports);
51
+ __exportStar(require("./security/PasswordHasher"), exports);
52
+ __exportStar(require("./testing/Factory"), exports);
53
+ __exportStar(require("./testing/TestHelpers"), exports);
54
+ exports.VERSION = '1.1.0';
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,yDAAuC;AACvC,+DAA6C;AAC7C,sDAAoC;AACpC,sDAAoC;AACpC,qDAAmC;AACnC,yDAAuC;AACvC,sDAAoC;AACpC,qDAAmC;AACnC,0DAAwC;AACxC,qDAAmC;AACnC,uDAAqC;AACrC,2DAAyC;AACzC,mDAAiC;AACjC,wDAAsC;AACtC,oDAAkC;AAClC,gDAA8B;AAC9B,gDAA8B;AAC9B,iDAA+B;AAC/B,kDAAgC;AAChC,qDAAmC;AACnC,mDAAiC;AACjC,0DAAwC;AACxC,6DAA2C;AAC3C,iEAA+C;AAC/C,qDAAmC;AACnC,kDAAgC;AAChC,kDAAgC;AAChC,uDAAqC;AACrC,oDAAkC;AAClC,kDAAgC;AAChC,uDAAqC;AACrC,4DAA0C;AAC1C,4DAA0C;AAC1C,oDAAkC;AAClC,wDAAsC;AAEzB,QAAA,OAAO,GAAG,OAAO,CAAC"}
@@ -0,0 +1,18 @@
1
+ export declare class CSRF {
2
+ private tokens;
3
+ private secret;
4
+ constructor(secret?: string);
5
+ /**
6
+ * Generate a CSRF token
7
+ */
8
+ generate(sessionId: string): string;
9
+ /**
10
+ * Verify a CSRF token
11
+ */
12
+ verify(sessionId: string, token: string): boolean;
13
+ /**
14
+ * Clean expired tokens
15
+ */
16
+ cleanup(): void;
17
+ }
18
+ //# sourceMappingURL=CSRF.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CSRF.d.ts","sourceRoot":"","sources":["../../src/security/CSRF.ts"],"names":[],"mappings":"AAEA,qBAAa,IAAI;IACb,OAAO,CAAC,MAAM,CAA8D;IAC5E,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,CAAC,EAAE,MAAM;IAI3B;;OAEG;IACI,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAQ1C;;OAEG;IACI,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAexD;;OAEG;IACI,OAAO,IAAI,IAAI;CAQzB"}
@@ -0,0 +1,79 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.CSRF = void 0;
37
+ const crypto = __importStar(require("crypto"));
38
+ class CSRF {
39
+ constructor(secret) {
40
+ this.tokens = new Map();
41
+ this.secret = secret || crypto.randomBytes(32).toString('hex');
42
+ }
43
+ /**
44
+ * Generate a CSRF token
45
+ */
46
+ generate(sessionId) {
47
+ const token = crypto.randomBytes(32).toString('hex');
48
+ const expires = Date.now() + 3600000; // 1 hour
49
+ this.tokens.set(sessionId, { token, expires });
50
+ return token;
51
+ }
52
+ /**
53
+ * Verify a CSRF token
54
+ */
55
+ verify(sessionId, token) {
56
+ const stored = this.tokens.get(sessionId);
57
+ if (!stored) {
58
+ return false;
59
+ }
60
+ if (stored.expires < Date.now()) {
61
+ this.tokens.delete(sessionId);
62
+ return false;
63
+ }
64
+ return crypto.timingSafeEqual(Buffer.from(stored.token), Buffer.from(token));
65
+ }
66
+ /**
67
+ * Clean expired tokens
68
+ */
69
+ cleanup() {
70
+ const now = Date.now();
71
+ for (const [key, value] of this.tokens.entries()) {
72
+ if (value.expires < now) {
73
+ this.tokens.delete(key);
74
+ }
75
+ }
76
+ }
77
+ }
78
+ exports.CSRF = CSRF;
79
+ //# sourceMappingURL=CSRF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CSRF.js","sourceRoot":"","sources":["../../src/security/CSRF.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AAEjC,MAAa,IAAI;IAIb,YAAY,MAAe;QAHnB,WAAM,GAAoD,IAAI,GAAG,EAAE,CAAC;QAIxE,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACnE,CAAC;IAED;;OAEG;IACI,QAAQ,CAAC,SAAiB;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC,SAAS;QAE/C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QAC/C,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,SAAiB,EAAE,KAAa;QAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAE1C,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,IAAI,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;YAC9B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAC9B,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,OAAO,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACjF,CAAC;IAED;;OAEG;IACI,OAAO;QACV,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;YAC/C,IAAI,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC;gBACtB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC5B,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AAhDD,oBAgDC"}
@@ -0,0 +1,18 @@
1
+ export declare class Encrypter {
2
+ private key;
3
+ private algorithm;
4
+ constructor(key: string);
5
+ /**
6
+ * Encrypt data
7
+ */
8
+ encrypt(data: string): string;
9
+ /**
10
+ * Decrypt data
11
+ */
12
+ decrypt(encrypted: string): string;
13
+ /**
14
+ * Hash data
15
+ */
16
+ static hash(data: string, algorithm?: string): string;
17
+ }
18
+ //# sourceMappingURL=Encrypter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Encrypter.d.ts","sourceRoot":"","sources":["../../src/security/Encrypter.ts"],"names":[],"mappings":"AAEA,qBAAa,SAAS;IAClB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,SAAS,CAAyB;gBAE9B,GAAG,EAAE,MAAM;IAOvB;;OAEG;IACI,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAUpC;;OAEG;IACI,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAWzC;;OAEG;WACW,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,MAAiB,GAAG,MAAM;CAGzE"}
@@ -0,0 +1,75 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Encrypter = void 0;
37
+ const crypto = __importStar(require("crypto"));
38
+ class Encrypter {
39
+ constructor(key) {
40
+ this.algorithm = 'aes-256-cbc';
41
+ if (key.length !== 32) {
42
+ throw new Error('Encryption key must be 32 bytes');
43
+ }
44
+ this.key = key;
45
+ }
46
+ /**
47
+ * Encrypt data
48
+ */
49
+ encrypt(data) {
50
+ const iv = crypto.randomBytes(16);
51
+ const cipher = crypto.createCipheriv(this.algorithm, Buffer.from(this.key), iv);
52
+ let encrypted = cipher.update(data, 'utf8', 'hex');
53
+ encrypted += cipher.final('hex');
54
+ return iv.toString('hex') + ':' + encrypted;
55
+ }
56
+ /**
57
+ * Decrypt data
58
+ */
59
+ decrypt(encrypted) {
60
+ const parts = encrypted.split(':');
61
+ const iv = Buffer.from(parts[0], 'hex');
62
+ const decipher = crypto.createDecipheriv(this.algorithm, Buffer.from(this.key), iv);
63
+ let decrypted = decipher.update(parts[1], 'hex', 'utf8');
64
+ decrypted += decipher.final('utf8');
65
+ return decrypted;
66
+ }
67
+ /**
68
+ * Hash data
69
+ */
70
+ static hash(data, algorithm = 'sha256') {
71
+ return crypto.createHash(algorithm).update(data).digest('hex');
72
+ }
73
+ }
74
+ exports.Encrypter = Encrypter;
75
+ //# sourceMappingURL=Encrypter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Encrypter.js","sourceRoot":"","sources":["../../src/security/Encrypter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AAEjC,MAAa,SAAS;IAIlB,YAAY,GAAW;QAFf,cAAS,GAAW,aAAa,CAAC;QAGtC,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACvD,CAAC;QACD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;IAED;;OAEG;IACI,OAAO,CAAC,IAAY;QACvB,MAAM,EAAE,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAClC,MAAM,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;QAEhF,IAAI,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QACnD,SAAS,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAEjC,OAAO,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,SAAS,CAAC;IAChD,CAAC;IAED;;OAEG;IACI,OAAO,CAAC,SAAiB;QAC5B,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QACxC,MAAM,QAAQ,GAAG,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;QAEpF,IAAI,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QACzD,SAAS,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAEpC,OAAO,SAAS,CAAC;IACrB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,IAAI,CAAC,IAAY,EAAE,YAAoB,QAAQ;QACzD,OAAO,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACnE,CAAC;CACJ;AA5CD,8BA4CC"}
@@ -0,0 +1,23 @@
1
+ export declare class InputSanitizer {
2
+ /**
3
+ * Sanitize string input
4
+ */
5
+ static sanitize(input: string): string;
6
+ /**
7
+ * Sanitize object
8
+ */
9
+ static sanitizeObject(obj: Record<string, any>): Record<string, any>;
10
+ /**
11
+ * Remove dangerous characters
12
+ */
13
+ static removeDangerousChars(input: string): string;
14
+ /**
15
+ * Validate email
16
+ */
17
+ static isValidEmail(email: string): boolean;
18
+ /**
19
+ * Validate URL
20
+ */
21
+ static isValidUrl(url: string): boolean;
22
+ }
23
+ //# sourceMappingURL=InputSanitizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InputSanitizer.d.ts","sourceRoot":"","sources":["../../src/security/InputSanitizer.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAc;IACvB;;OAEG;WACW,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAU7C;;OAEG;WACW,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAoB3E;;OAEG;WACW,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAIzD;;OAEG;WACW,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAKlD;;OAEG;WACW,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;CAQjD"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InputSanitizer = void 0;
4
+ class InputSanitizer {
5
+ /**
6
+ * Sanitize string input
7
+ */
8
+ static sanitize(input) {
9
+ return input
10
+ .replace(/&/g, '&amp;')
11
+ .replace(/</g, '&lt;')
12
+ .replace(/>/g, '&gt;')
13
+ .replace(/"/g, '&quot;')
14
+ .replace(/'/g, '&#x27;')
15
+ .replace(/\//g, '&#x2F;');
16
+ }
17
+ /**
18
+ * Sanitize object
19
+ */
20
+ static sanitizeObject(obj) {
21
+ const result = {};
22
+ for (const [key, value] of Object.entries(obj)) {
23
+ if (typeof value === 'string') {
24
+ result[key] = this.sanitize(value);
25
+ }
26
+ else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
27
+ result[key] = this.sanitizeObject(value);
28
+ }
29
+ else if (Array.isArray(value)) {
30
+ result[key] = value.map(v => typeof v === 'string' ? this.sanitize(v) : v);
31
+ }
32
+ else {
33
+ result[key] = value;
34
+ }
35
+ }
36
+ return result;
37
+ }
38
+ /**
39
+ * Remove dangerous characters
40
+ */
41
+ static removeDangerousChars(input) {
42
+ return input.replace(/[<>\"'%()&+]/g, '');
43
+ }
44
+ /**
45
+ * Validate email
46
+ */
47
+ static isValidEmail(email) {
48
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
49
+ return emailRegex.test(email);
50
+ }
51
+ /**
52
+ * Validate URL
53
+ */
54
+ static isValidUrl(url) {
55
+ try {
56
+ new URL(url);
57
+ return true;
58
+ }
59
+ catch {
60
+ return false;
61
+ }
62
+ }
63
+ }
64
+ exports.InputSanitizer = InputSanitizer;
65
+ //# sourceMappingURL=InputSanitizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InputSanitizer.js","sourceRoot":"","sources":["../../src/security/InputSanitizer.ts"],"names":[],"mappings":";;;AAAA,MAAa,cAAc;IACvB;;OAEG;IACI,MAAM,CAAC,QAAQ,CAAC,KAAa;QAChC,OAAO,KAAK;aACP,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;aACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;aACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;aACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;aACvB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;aACvB,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,cAAc,CAAC,GAAwB;QACjD,MAAM,MAAM,GAAwB,EAAE,CAAC;QAEvC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC5B,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YACvC,CAAC;iBAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9E,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC7C,CAAC;iBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9B,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CACxB,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC/C,CAAC;YACN,CAAC;iBAAM,CAAC;gBACJ,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACxB,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,oBAAoB,CAAC,KAAa;QAC5C,OAAO,KAAK,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,YAAY,CAAC,KAAa;QACpC,MAAM,UAAU,GAAG,4BAA4B,CAAC;QAChD,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,UAAU,CAAC,GAAW;QAChC,IAAI,CAAC;YACD,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;YACb,OAAO,IAAI,CAAC;QAChB,CAAC;QAAC,MAAM,CAAC;YACL,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;CACJ;AA/DD,wCA+DC"}
@@ -0,0 +1,22 @@
1
+ export interface PasswordHashOptions {
2
+ rounds?: number;
3
+ saltLength?: number;
4
+ }
5
+ export declare class PasswordHasher {
6
+ private rounds;
7
+ private saltLength;
8
+ constructor(options?: PasswordHashOptions);
9
+ /**
10
+ * Hash a password
11
+ */
12
+ hash(password: string): string;
13
+ /**
14
+ * Verify a password
15
+ */
16
+ verify(password: string, hashed: string): boolean;
17
+ /**
18
+ * Check if password needs rehashing
19
+ */
20
+ needsRehash(hashed: string): boolean;
21
+ }
22
+ //# sourceMappingURL=PasswordHasher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PasswordHasher.d.ts","sourceRoot":"","sources":["../../src/security/PasswordHasher.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,cAAc;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAS;gBAEf,OAAO,GAAE,mBAAwB;IAK7C;;OAEG;IACI,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAMrC;;OAEG;IACI,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAMxD;;OAEG;IACI,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;CAI9C"}
@@ -0,0 +1,68 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.PasswordHasher = void 0;
37
+ const crypto = __importStar(require("crypto"));
38
+ class PasswordHasher {
39
+ constructor(options = {}) {
40
+ this.rounds = options.rounds || 10;
41
+ this.saltLength = options.saltLength || 16;
42
+ }
43
+ /**
44
+ * Hash a password
45
+ */
46
+ hash(password) {
47
+ const salt = crypto.randomBytes(this.saltLength).toString('hex');
48
+ const hash = crypto.pbkdf2Sync(password, salt, this.rounds, 64, 'sha512').toString('hex');
49
+ return `${salt}$${hash}`;
50
+ }
51
+ /**
52
+ * Verify a password
53
+ */
54
+ verify(password, hashed) {
55
+ const [salt, hash] = hashed.split('$');
56
+ const hashVerify = crypto.pbkdf2Sync(password, salt, this.rounds, 64, 'sha512').toString('hex');
57
+ return crypto.timingSafeEqual(Buffer.from(hash), Buffer.from(hashVerify));
58
+ }
59
+ /**
60
+ * Check if password needs rehashing
61
+ */
62
+ needsRehash(hashed) {
63
+ const [, hash] = hashed.split('$');
64
+ return hash.length !== 128; // sha512 produces 128 hex characters
65
+ }
66
+ }
67
+ exports.PasswordHasher = PasswordHasher;
68
+ //# sourceMappingURL=PasswordHasher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PasswordHasher.js","sourceRoot":"","sources":["../../src/security/PasswordHasher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AAOjC,MAAa,cAAc;IAIvB,YAAY,UAA+B,EAAE;QACzC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC;QACnC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC;IAC/C,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,QAAgB;QACxB,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACjE,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC1F,OAAO,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAAgB,EAAE,MAAc;QAC1C,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACvC,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAChG,OAAO,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9E,CAAC;IAED;;OAEG;IACI,WAAW,CAAC,MAAc;QAC7B,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,qCAAqC;IACrE,CAAC;CACJ;AAlCD,wCAkCC"}
@@ -0,0 +1,20 @@
1
+ import { Application } from '../foundation/Application';
2
+ export interface User {
3
+ id: number;
4
+ email: string;
5
+ [key: string]: any;
6
+ }
7
+ export declare class Auth {
8
+ protected app: Application;
9
+ protected user: User | null;
10
+ constructor(app: Application);
11
+ attempt(credentials: {
12
+ email: string;
13
+ password?: string;
14
+ }): Promise<boolean>;
15
+ login(user: User): void;
16
+ logout(): void;
17
+ check(): boolean;
18
+ getUser(): User | null;
19
+ }
20
+ //# sourceMappingURL=Auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Auth.d.ts","sourceRoot":"","sources":["../../src/services/Auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,WAAW,IAAI;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED,qBAAa,IAAI;IACb,SAAS,CAAC,GAAG,EAAE,WAAW,CAAC;IAC3B,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ;gBAEvB,GAAG,EAAE,WAAW;IAIf,OAAO,CAAC,WAAW,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAMlF,KAAK,CAAC,IAAI,EAAE,IAAI;IAIhB,MAAM;IAIN,KAAK,IAAI,OAAO;IAIhB,OAAO,IAAI,IAAI,GAAG,IAAI;CAGhC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Auth = void 0;
4
+ class Auth {
5
+ constructor(app) {
6
+ this.user = null;
7
+ this.app = app;
8
+ }
9
+ async attempt(credentials) {
10
+ // Logic for authentication
11
+ console.log(`Attempting login for: ${credentials.email}`);
12
+ return true;
13
+ }
14
+ login(user) {
15
+ this.user = user;
16
+ }
17
+ logout() {
18
+ this.user = null;
19
+ }
20
+ check() {
21
+ return this.user !== null;
22
+ }
23
+ getUser() {
24
+ return this.user;
25
+ }
26
+ }
27
+ exports.Auth = Auth;
28
+ //# sourceMappingURL=Auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Auth.js","sourceRoot":"","sources":["../../src/services/Auth.ts"],"names":[],"mappings":";;;AAQA,MAAa,IAAI;IAIb,YAAY,GAAgB;QAFlB,SAAI,GAAgB,IAAI,CAAC;QAG/B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,WAAiD;QAClE,2BAA2B;QAC3B,OAAO,CAAC,GAAG,CAAC,yBAAyB,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,IAAU;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAEM,MAAM;QACT,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAEM,KAAK;QACR,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC;IAC9B,CAAC;IAEM,OAAO;QACV,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;CACJ;AA7BD,oBA6BC"}
@@ -0,0 +1,10 @@
1
+ export declare class Gate {
2
+ private abilities;
3
+ private policies;
4
+ define(ability: string, callback: (user: any, ...args: any[]) => boolean): void;
5
+ policy(modelClass: any, policyClass: any): void;
6
+ allows(user: any, ability: string, ...args: any[]): boolean;
7
+ denies(user: any, ability: string, ...args: any[]): boolean;
8
+ }
9
+ export declare const GateManager: Gate;
10
+ //# sourceMappingURL=Gate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Gate.d.ts","sourceRoot":"","sources":["../../src/services/Gate.ts"],"names":[],"mappings":"AAAA,qBAAa,IAAI;IACb,OAAO,CAAC,SAAS,CAAoC;IACrD,OAAO,CAAC,QAAQ,CAA+B;IAExC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO;IAIxE,MAAM,CAAC,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG;IAIxC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO;IAkB3D,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO;CAGrE;AAED,eAAO,MAAM,WAAW,MAAa,CAAC"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GateManager = exports.Gate = void 0;
4
+ class Gate {
5
+ constructor() {
6
+ this.abilities = new Map();
7
+ this.policies = new Map();
8
+ }
9
+ define(ability, callback) {
10
+ this.abilities.set(ability, callback);
11
+ }
12
+ policy(modelClass, policyClass) {
13
+ this.policies.set(modelClass.name, new policyClass());
14
+ }
15
+ allows(user, ability, ...args) {
16
+ const abilityCallback = this.abilities.get(ability);
17
+ if (abilityCallback) {
18
+ return abilityCallback(user, ...args);
19
+ }
20
+ // Check policies
21
+ if (args.length > 0 && args[0] && args[0].constructor) {
22
+ const modelName = args[0].constructor.name;
23
+ const policy = this.policies.get(modelName);
24
+ if (policy && typeof policy[ability] === 'function') {
25
+ return policy[ability](user, ...args);
26
+ }
27
+ }
28
+ return false;
29
+ }
30
+ denies(user, ability, ...args) {
31
+ return !this.allows(user, ability, ...args);
32
+ }
33
+ }
34
+ exports.Gate = Gate;
35
+ exports.GateManager = new Gate();
36
+ //# sourceMappingURL=Gate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Gate.js","sourceRoot":"","sources":["../../src/services/Gate.ts"],"names":[],"mappings":";;;AAAA,MAAa,IAAI;IAAjB;QACY,cAAS,GAA0B,IAAI,GAAG,EAAE,CAAC;QAC7C,aAAQ,GAAqB,IAAI,GAAG,EAAE,CAAC;IA+BnD,CAAC;IA7BU,MAAM,CAAC,OAAe,EAAE,QAAgD;QAC3E,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAEM,MAAM,CAAC,UAAe,EAAE,WAAgB;QAC3C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,WAAW,EAAE,CAAC,CAAC;IAC1D,CAAC;IAEM,MAAM,CAAC,IAAS,EAAE,OAAe,EAAE,GAAG,IAAW;QACpD,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACpD,IAAI,eAAe,EAAE,CAAC;YAClB,OAAO,eAAe,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;QAC1C,CAAC;QAED,iBAAiB;QACjB,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;YACpD,MAAM,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC;YAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC5C,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,EAAE,CAAC;gBAClD,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;YAC1C,CAAC;QACL,CAAC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;IAEM,MAAM,CAAC,IAAS,EAAE,OAAe,EAAE,GAAG,IAAW;QACpD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAChD,CAAC;CACJ;AAjCD,oBAiCC;AAEY,QAAA,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare abstract class Service {
2
+ abstract execute(...args: any[]): Promise<any> | any;
3
+ }
4
+ //# sourceMappingURL=Service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Service.d.ts","sourceRoot":"","sources":["../../src/services/Service.ts"],"names":[],"mappings":"AAAA,8BAAsB,OAAO;IACzB,QAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;CACvD"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Service = void 0;
4
+ class Service {
5
+ }
6
+ exports.Service = Service;
7
+ //# sourceMappingURL=Service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Service.js","sourceRoot":"","sources":["../../src/services/Service.ts"],"names":[],"mappings":";;;AAAA,MAAsB,OAAO;CAE5B;AAFD,0BAEC"}
@@ -0,0 +1,8 @@
1
+ export declare class Validator {
2
+ static validate(data: any, rules: Record<string, string>): {
3
+ isValid: boolean;
4
+ errors: Record<string, string[]>;
5
+ };
6
+ private static addError;
7
+ }
8
+ //# sourceMappingURL=Validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Validator.d.ts","sourceRoot":"","sources":["../../src/services/Validator.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAS;WACJ,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;KAAE;IAgCxH,OAAO,CAAC,MAAM,CAAC,QAAQ;CAM1B"}