@rapidrest/service-core 1.0.0-beta.1

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 (332) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +16 -0
  3. package/dist/lib/ApiErrors.js +41 -0
  4. package/dist/lib/ApiErrors.js.map +1 -0
  5. package/dist/lib/BackgroundService.js +16 -0
  6. package/dist/lib/BackgroundService.js.map +1 -0
  7. package/dist/lib/BackgroundServiceManager.js +135 -0
  8. package/dist/lib/BackgroundServiceManager.js.map +1 -0
  9. package/dist/lib/BulkError.js +24 -0
  10. package/dist/lib/BulkError.js.map +1 -0
  11. package/dist/lib/EventListenerManager.js +161 -0
  12. package/dist/lib/EventListenerManager.js.map +1 -0
  13. package/dist/lib/NetUtils.js +103 -0
  14. package/dist/lib/NetUtils.js.map +1 -0
  15. package/dist/lib/NotificationUtils.js +34 -0
  16. package/dist/lib/NotificationUtils.js.map +1 -0
  17. package/dist/lib/ObjectFactory.js +90 -0
  18. package/dist/lib/ObjectFactory.js.map +1 -0
  19. package/dist/lib/OpenApiSpec.js +748 -0
  20. package/dist/lib/OpenApiSpec.js.map +1 -0
  21. package/dist/lib/Server.js +549 -0
  22. package/dist/lib/Server.js.map +1 -0
  23. package/dist/lib/Types.js +2 -0
  24. package/dist/lib/Types.js.map +1 -0
  25. package/dist/lib/auth/AuthMiddleware.js +229 -0
  26. package/dist/lib/auth/AuthMiddleware.js.map +1 -0
  27. package/dist/lib/auth/AuthStrategy.js +2 -0
  28. package/dist/lib/auth/AuthStrategy.js.map +1 -0
  29. package/dist/lib/auth/BasicStrategy.js +106 -0
  30. package/dist/lib/auth/BasicStrategy.js.map +1 -0
  31. package/dist/lib/auth/JWTStrategy.js +161 -0
  32. package/dist/lib/auth/JWTStrategy.js.map +1 -0
  33. package/dist/lib/auth/index.js +5 -0
  34. package/dist/lib/auth/index.js.map +1 -0
  35. package/dist/lib/database/ConnectionKinds.js +14 -0
  36. package/dist/lib/database/ConnectionKinds.js.map +1 -0
  37. package/dist/lib/database/ConnectionManager.js +161 -0
  38. package/dist/lib/database/ConnectionManager.js.map +1 -0
  39. package/dist/lib/database/MongoConnection.js +86 -0
  40. package/dist/lib/database/MongoConnection.js.map +1 -0
  41. package/dist/lib/database/MongoRepository.js +136 -0
  42. package/dist/lib/database/MongoRepository.js.map +1 -0
  43. package/dist/lib/database/MongoSchemaSync.js +136 -0
  44. package/dist/lib/database/MongoSchemaSync.js.map +1 -0
  45. package/dist/lib/database/NamingUtils.js +52 -0
  46. package/dist/lib/database/NamingUtils.js.map +1 -0
  47. package/dist/lib/database/TypeOrmSupport.js +146 -0
  48. package/dist/lib/database/TypeOrmSupport.js.map +1 -0
  49. package/dist/lib/database/index.js +7 -0
  50. package/dist/lib/database/index.js.map +1 -0
  51. package/dist/lib/decorators/DatabaseDecorators.js +52 -0
  52. package/dist/lib/decorators/DatabaseDecorators.js.map +1 -0
  53. package/dist/lib/decorators/DocDecorators.js +120 -0
  54. package/dist/lib/decorators/DocDecorators.js.map +1 -0
  55. package/dist/lib/decorators/EventDecorators.js +24 -0
  56. package/dist/lib/decorators/EventDecorators.js.map +1 -0
  57. package/dist/lib/decorators/ModelDecorators.js +173 -0
  58. package/dist/lib/decorators/ModelDecorators.js.map +1 -0
  59. package/dist/lib/decorators/PersistenceDecorators.js +177 -0
  60. package/dist/lib/decorators/PersistenceDecorators.js.map +1 -0
  61. package/dist/lib/decorators/RouteDecorators.js +324 -0
  62. package/dist/lib/decorators/RouteDecorators.js.map +1 -0
  63. package/dist/lib/decorators/index.js +7 -0
  64. package/dist/lib/decorators/index.js.map +1 -0
  65. package/dist/lib/http/Adapters.js +230 -0
  66. package/dist/lib/http/Adapters.js.map +1 -0
  67. package/dist/lib/http/Router.js +403 -0
  68. package/dist/lib/http/Router.js.map +1 -0
  69. package/dist/lib/http/WebSocket.js +82 -0
  70. package/dist/lib/http/WebSocket.js.map +1 -0
  71. package/dist/lib/http/index.js +4 -0
  72. package/dist/lib/http/index.js.map +1 -0
  73. package/dist/lib/http/types.js +5 -0
  74. package/dist/lib/http/types.js.map +1 -0
  75. package/dist/lib/index.js +18 -0
  76. package/dist/lib/index.js.map +1 -0
  77. package/dist/lib/models/BaseEntity.js +83 -0
  78. package/dist/lib/models/BaseEntity.js.map +1 -0
  79. package/dist/lib/models/BaseMongoEntity.js +40 -0
  80. package/dist/lib/models/BaseMongoEntity.js.map +1 -0
  81. package/dist/lib/models/ModelUtils.js +645 -0
  82. package/dist/lib/models/ModelUtils.js.map +1 -0
  83. package/dist/lib/models/RecoverableBaseEntity.js +39 -0
  84. package/dist/lib/models/RecoverableBaseEntity.js.map +1 -0
  85. package/dist/lib/models/RecoverableBaseMongoEntity.js +40 -0
  86. package/dist/lib/models/RecoverableBaseMongoEntity.js.map +1 -0
  87. package/dist/lib/models/RepoUtils.js +717 -0
  88. package/dist/lib/models/RepoUtils.js.map +1 -0
  89. package/dist/lib/models/SimpleEntity.js +42 -0
  90. package/dist/lib/models/SimpleEntity.js.map +1 -0
  91. package/dist/lib/models/SimpleMongoEntity.js +38 -0
  92. package/dist/lib/models/SimpleMongoEntity.js.map +1 -0
  93. package/dist/lib/models/StatusExtraData.js +15 -0
  94. package/dist/lib/models/StatusExtraData.js.map +1 -0
  95. package/dist/lib/models/index.js +10 -0
  96. package/dist/lib/models/index.js.map +1 -0
  97. package/dist/lib/routes/AdminRoute.js +268 -0
  98. package/dist/lib/routes/AdminRoute.js.map +1 -0
  99. package/dist/lib/routes/MetricsRoute.js +86 -0
  100. package/dist/lib/routes/MetricsRoute.js.map +1 -0
  101. package/dist/lib/routes/ModelRoute.js +481 -0
  102. package/dist/lib/routes/ModelRoute.js.map +1 -0
  103. package/dist/lib/routes/OpenAPIRoute.js +115 -0
  104. package/dist/lib/routes/OpenAPIRoute.js.map +1 -0
  105. package/dist/lib/routes/RouteUtils.js +445 -0
  106. package/dist/lib/routes/RouteUtils.js.map +1 -0
  107. package/dist/lib/routes/StatusRoute.js +55 -0
  108. package/dist/lib/routes/StatusRoute.js.map +1 -0
  109. package/dist/lib/routes/index.js +7 -0
  110. package/dist/lib/routes/index.js.map +1 -0
  111. package/dist/lib/security/ACLRouteMongo.js +194 -0
  112. package/dist/lib/security/ACLRouteMongo.js.map +1 -0
  113. package/dist/lib/security/ACLRouteSQL.js +193 -0
  114. package/dist/lib/security/ACLRouteSQL.js.map +1 -0
  115. package/dist/lib/security/ACLUtils.js +457 -0
  116. package/dist/lib/security/ACLUtils.js.map +1 -0
  117. package/dist/lib/security/AccessControlList.js +18 -0
  118. package/dist/lib/security/AccessControlList.js.map +1 -0
  119. package/dist/lib/security/AccessControlListMongo.js +155 -0
  120. package/dist/lib/security/AccessControlListMongo.js.map +1 -0
  121. package/dist/lib/security/AccessControlListSQL.js +149 -0
  122. package/dist/lib/security/AccessControlListSQL.js.map +1 -0
  123. package/dist/lib/security/index.js +3 -0
  124. package/dist/lib/security/index.js.map +1 -0
  125. package/dist/lib/test/index.js +3 -0
  126. package/dist/lib/test/index.js.map +1 -0
  127. package/dist/lib/test/request.js +99 -0
  128. package/dist/lib/test/request.js.map +1 -0
  129. package/dist/lib/test/requestws.js +173 -0
  130. package/dist/lib/test/requestws.js.map +1 -0
  131. package/dist/types/ApiErrors.d.ts +38 -0
  132. package/dist/types/BackgroundService.d.ts +30 -0
  133. package/dist/types/BackgroundServiceManager.d.ts +66 -0
  134. package/dist/types/BulkError.d.ts +11 -0
  135. package/dist/types/EventListenerManager.d.ts +36 -0
  136. package/dist/types/NetUtils.d.ts +29 -0
  137. package/dist/types/NotificationUtils.d.ts +25 -0
  138. package/dist/types/ObjectFactory.d.ts +17 -0
  139. package/dist/types/OpenApiSpec.d.ts +114 -0
  140. package/dist/types/Server.d.ts +180 -0
  141. package/dist/types/Types.d.ts +8 -0
  142. package/dist/types/auth/AuthMiddleware.d.ts +42 -0
  143. package/dist/types/auth/AuthStrategy.d.ts +32 -0
  144. package/dist/types/auth/BasicStrategy.d.ts +33 -0
  145. package/dist/types/auth/JWTStrategy.d.ts +61 -0
  146. package/dist/types/auth/index.d.ts +4 -0
  147. package/dist/types/database/ConnectionKinds.d.ts +7 -0
  148. package/dist/types/database/ConnectionManager.d.ts +35 -0
  149. package/dist/types/database/MongoConnection.d.ts +54 -0
  150. package/dist/types/database/MongoRepository.d.ts +92 -0
  151. package/dist/types/database/MongoSchemaSync.d.ts +41 -0
  152. package/dist/types/database/NamingUtils.d.ts +24 -0
  153. package/dist/types/database/TypeOrmSupport.d.ts +20 -0
  154. package/dist/types/database/index.d.ts +6 -0
  155. package/dist/types/decorators/DatabaseDecorators.d.ts +18 -0
  156. package/dist/types/decorators/DocDecorators.d.ts +69 -0
  157. package/dist/types/decorators/EventDecorators.d.ts +12 -0
  158. package/dist/types/decorators/ModelDecorators.d.ts +80 -0
  159. package/dist/types/decorators/PersistenceDecorators.d.ts +117 -0
  160. package/dist/types/decorators/RouteDecorators.d.ts +172 -0
  161. package/dist/types/decorators/index.d.ts +6 -0
  162. package/dist/types/http/Adapters.d.ts +68 -0
  163. package/dist/types/http/Router.d.ts +99 -0
  164. package/dist/types/http/WebSocket.d.ts +56 -0
  165. package/dist/types/http/index.d.ts +6 -0
  166. package/dist/types/http/types.d.ts +54 -0
  167. package/dist/types/index.d.ts +17 -0
  168. package/dist/types/models/BaseEntity.d.ts +29 -0
  169. package/dist/types/models/BaseMongoEntity.d.ts +13 -0
  170. package/dist/types/models/ModelUtils.d.ts +166 -0
  171. package/dist/types/models/RecoverableBaseEntity.d.ts +16 -0
  172. package/dist/types/models/RecoverableBaseMongoEntity.d.ts +16 -0
  173. package/dist/types/models/RepoUtils.d.ts +154 -0
  174. package/dist/types/models/SimpleEntity.d.ts +14 -0
  175. package/dist/types/models/SimpleMongoEntity.d.ts +15 -0
  176. package/dist/types/models/StatusExtraData.d.ts +6 -0
  177. package/dist/types/models/index.d.ts +9 -0
  178. package/dist/types/routes/AdminRoute.d.ts +47 -0
  179. package/dist/types/routes/MetricsRoute.d.ts +15 -0
  180. package/dist/types/routes/ModelRoute.d.ts +226 -0
  181. package/dist/types/routes/OpenAPIRoute.d.ts +17 -0
  182. package/dist/types/routes/RouteUtils.d.ts +55 -0
  183. package/dist/types/routes/StatusRoute.d.ts +11 -0
  184. package/dist/types/routes/index.d.ts +6 -0
  185. package/dist/types/security/ACLRouteMongo.d.ts +19 -0
  186. package/dist/types/security/ACLRouteSQL.d.ts +19 -0
  187. package/dist/types/security/ACLUtils.d.ts +94 -0
  188. package/dist/types/security/AccessControlList.d.ts +103 -0
  189. package/dist/types/security/AccessControlListMongo.d.ts +24 -0
  190. package/dist/types/security/AccessControlListSQL.d.ts +24 -0
  191. package/dist/types/security/index.d.ts +2 -0
  192. package/dist/types/test/index.d.ts +2 -0
  193. package/dist/types/test/request.d.ts +24 -0
  194. package/dist/types/test/requestws.d.ts +21 -0
  195. package/docs/Makefile +20 -0
  196. package/docs/conf.py +58 -0
  197. package/docs/index.rst +17 -0
  198. package/docs/make.bat +35 -0
  199. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/README.md +13 -0
  200. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/MongoRepository.md +25 -0
  201. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/RedisConnection.md +25 -0
  202. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/Repository.md +25 -0
  203. package/docs/reference/@rapidrest/namespaces/DocDecorators/README.md +23 -0
  204. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Default.md +25 -0
  205. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Description.md +25 -0
  206. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Document.md +25 -0
  207. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Example.md +25 -0
  208. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Format.md +25 -0
  209. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Returns.md +28 -0
  210. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Summary.md +25 -0
  211. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Tags.md +25 -0
  212. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/TypeInfo.md +28 -0
  213. package/docs/reference/@rapidrest/namespaces/DocDecorators/interfaces/DocumentsData.md +57 -0
  214. package/docs/reference/@rapidrest/namespaces/EventDecorators/README.md +12 -0
  215. package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/EventListener.md +17 -0
  216. package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/OnEvent.md +26 -0
  217. package/docs/reference/@rapidrest/namespaces/ModelDecorators/README.md +26 -0
  218. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Cache.md +25 -0
  219. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/ChildEntity.md +18 -0
  220. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/DataStore.md +25 -0
  221. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Identifier.md +27 -0
  222. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Protect.md +35 -0
  223. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Reference.md +25 -0
  224. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Shard.md +27 -0
  225. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/TrackChanges.md +26 -0
  226. package/docs/reference/@rapidrest/namespaces/ModelDecorators/interfaces/PendingTypeOrmColumn.md +45 -0
  227. package/docs/reference/@rapidrest/namespaces/ModelDecorators/variables/pendingTypeOrmColumns.md +14 -0
  228. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/README.md +25 -0
  229. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Column.md +25 -0
  230. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Entity.md +26 -0
  231. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Index.md +119 -0
  232. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/PrimaryColumn.md +25 -0
  233. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Unique.md +68 -0
  234. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getColumnMetadata.md +26 -0
  235. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getEntityName.md +26 -0
  236. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getIndexMetadata.md +27 -0
  237. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnInfo.md +41 -0
  238. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnOptions.md +51 -0
  239. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexInfo.md +41 -0
  240. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexOptions.md +51 -0
  241. package/docs/reference/@rapidrest/namespaces/RouteDecorators/README.md +36 -0
  242. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/After.md +26 -0
  243. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Auth.md +33 -0
  244. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/AuthResult.md +31 -0
  245. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Before.md +25 -0
  246. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/ContentType.md +25 -0
  247. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Delete.md +25 -0
  248. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Get.md +25 -0
  249. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Head.md +25 -0
  250. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Header.md +25 -0
  251. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Method.md +31 -0
  252. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Model.md +25 -0
  253. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Options.md +25 -0
  254. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Param.md +26 -0
  255. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Patch.md +25 -0
  256. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Post.md +25 -0
  257. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Protect.md +31 -0
  258. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Put.md +25 -0
  259. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Query.md +26 -0
  260. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Request.md +31 -0
  261. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/RequiresRole.md +26 -0
  262. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Response.md +31 -0
  263. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Route.md +25 -0
  264. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Socket.md +33 -0
  265. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/User.md +31 -0
  266. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Validate.md +25 -0
  267. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/WebSocket.md +25 -0
  268. package/docs/reference/README.md +20 -0
  269. package/docs/reference/classes/ACLUtils.md +251 -0
  270. package/docs/reference/classes/AdminRoute.md +51 -0
  271. package/docs/reference/classes/AuthMiddleware.md +131 -0
  272. package/docs/reference/classes/BackgroundService.md +117 -0
  273. package/docs/reference/classes/BackgroundServiceManager.md +172 -0
  274. package/docs/reference/classes/BaseEntity.md +82 -0
  275. package/docs/reference/classes/BaseMongoEntity.md +107 -0
  276. package/docs/reference/classes/BasicStrategy.md +89 -0
  277. package/docs/reference/classes/BasicStrategyOptions.md +91 -0
  278. package/docs/reference/classes/BulkError.md +271 -0
  279. package/docs/reference/classes/ConnectionManager.md +75 -0
  280. package/docs/reference/classes/EventListenerManager.md +88 -0
  281. package/docs/reference/classes/JWTStrategy.md +77 -0
  282. package/docs/reference/classes/JWTStrategyOptions.md +97 -0
  283. package/docs/reference/classes/MetricsRoute.md +27 -0
  284. package/docs/reference/classes/ModelRoute.md +527 -0
  285. package/docs/reference/classes/ModelUtils.md +448 -0
  286. package/docs/reference/classes/MongoConnection.md +218 -0
  287. package/docs/reference/classes/MongoRepository.md +354 -0
  288. package/docs/reference/classes/MongoSchemaSync.md +67 -0
  289. package/docs/reference/classes/NetUtils.md +90 -0
  290. package/docs/reference/classes/NotificationUtils.md +77 -0
  291. package/docs/reference/classes/ObjectFactory.md +336 -0
  292. package/docs/reference/classes/OpenAPIRoute.md +77 -0
  293. package/docs/reference/classes/OpenApiSpec.md +892 -0
  294. package/docs/reference/classes/RecoverableBaseEntity.md +114 -0
  295. package/docs/reference/classes/RecoverableBaseMongoEntity.md +124 -0
  296. package/docs/reference/classes/RedisTransport.md +2202 -0
  297. package/docs/reference/classes/RepoUtils.md +486 -0
  298. package/docs/reference/classes/RouteUtils.md +191 -0
  299. package/docs/reference/classes/Server.md +408 -0
  300. package/docs/reference/classes/SimpleEntity.md +48 -0
  301. package/docs/reference/classes/SimpleMongoEntity.md +66 -0
  302. package/docs/reference/classes/StatusExtraData.md +57 -0
  303. package/docs/reference/classes/StatusRoute.md +26 -0
  304. package/docs/reference/enumerations/ACLAction.md +63 -0
  305. package/docs/reference/enumerations/ApiErrorMessages.md +123 -0
  306. package/docs/reference/enumerations/ApiErrors.md +123 -0
  307. package/docs/reference/functions/isSqlDataSource.md +26 -0
  308. package/docs/reference/functions/resolveCollectionName.md +33 -0
  309. package/docs/reference/functions/snakeCase.md +28 -0
  310. package/docs/reference/globals.md +91 -0
  311. package/docs/reference/interfaces/ACLRecord.md +96 -0
  312. package/docs/reference/interfaces/AccessControlList.md +76 -0
  313. package/docs/reference/interfaces/AuthResult.md +55 -0
  314. package/docs/reference/interfaces/AuthStrategy.md +57 -0
  315. package/docs/reference/interfaces/CreateRequestOptions.md +121 -0
  316. package/docs/reference/interfaces/DeleteRequestOptions.md +147 -0
  317. package/docs/reference/interfaces/FindRequestOptions.md +133 -0
  318. package/docs/reference/interfaces/JWTAuthResult.md +84 -0
  319. package/docs/reference/interfaces/RepoCreateOptions.md +95 -0
  320. package/docs/reference/interfaces/RepoDeleteOptions.md +115 -0
  321. package/docs/reference/interfaces/RepoFindOptions.md +135 -0
  322. package/docs/reference/interfaces/RepoOperationOptions.md +69 -0
  323. package/docs/reference/interfaces/RepoUpdateOptions.md +111 -0
  324. package/docs/reference/interfaces/RequestOptions.md +112 -0
  325. package/docs/reference/interfaces/TruncateRequestOptions.md +175 -0
  326. package/docs/reference/interfaces/UpdateRequestOptions.md +149 -0
  327. package/docs/reference/type-aliases/OneOrMany.md +19 -0
  328. package/docs/reference/type-aliases/OneOrNull.md +19 -0
  329. package/docs/reference/type-aliases/PartialBaseEntity.md +17 -0
  330. package/docs/reference/type-aliases/PartialSimpleEntity.md +17 -0
  331. package/docs/reference/type-aliases/UpdateObject.md +19 -0
  332. package/package.json +125 -0
@@ -0,0 +1,229 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ ////////////////////////////////////////////////////////////////////////////////
11
+ // Copyright (C) 2020-2026 Jean-Philippe Steinmetz
12
+ ///////////////////////////////////////////////////////////////////////////////
13
+ import { ApiError, JWTUtils, ObjectDecorators } from "@rapidrest/core";
14
+ import { ApiErrors, ApiErrorMessages } from "../ApiErrors.js";
15
+ import { ObjectFactory } from "../ObjectFactory.js";
16
+ import { JWTStrategy } from "./JWTStrategy.js";
17
+ import { BasicStrategy } from "./BasicStrategy.js";
18
+ const { Config, Init, Inject } = ObjectDecorators;
19
+ /**
20
+ * A set of common utilities for performing authentication using one or more strategies.
21
+ *
22
+ * @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
23
+ */
24
+ export class AuthMiddleware {
25
+ constructor() {
26
+ this.authSocketTimeout = 2000;
27
+ /** The authentication strategies that have been registered. */
28
+ this.strategies = new Map();
29
+ }
30
+ async init() {
31
+ if (this.objectFactory) {
32
+ // Register built-in strategy classes with ObjectFactory
33
+ this.objectFactory.register(BasicStrategy, "auth.BasicStrategy");
34
+ this.objectFactory.register(JWTStrategy, "auth.JWTStrategy");
35
+ if (this.authConfig.strategy) {
36
+ const strategy = await this.objectFactory.newInstance(this.authConfig.strategy);
37
+ this.strategies.set(strategy.name, strategy);
38
+ }
39
+ }
40
+ }
41
+ /**
42
+ * Performs authentication of the given request using one of the provided strategies.
43
+ *
44
+ * @param strategies The list of strategy names to attempt authentication with.
45
+ * @param req The request containing data to perform authenticate with.
46
+ * @param res The response to use when writing back directly to the client.
47
+ * @param required Set to `true` to if authentication is required to pass, otherwise set to `false`.
48
+ */
49
+ authenticate(strategies, req, res, required) {
50
+ let authResult = undefined;
51
+ for (const name of strategies) {
52
+ // Attempt authentication with the strategy
53
+ const strategy = this.strategies.get(name);
54
+ if (strategy) {
55
+ authResult = strategy.authenticate(req, res, required);
56
+ }
57
+ else {
58
+ throw new Error("No authentication strategy has been registered with name: " + name);
59
+ }
60
+ // Was it successful?
61
+ if (authResult) {
62
+ break;
63
+ }
64
+ }
65
+ if (!authResult && required) {
66
+ throw new Error("Authentication failed but is required to proceed.");
67
+ }
68
+ return authResult;
69
+ }
70
+ /**
71
+ * Returns a request handler function that will perform authentication of a websocket connection. Authentication
72
+ * can be handled in two ways:
73
+ *
74
+ * 1. Authorization header
75
+ * 2. Negotiation via handshake
76
+ *
77
+ * This middleware function primarily provides the implementation for item 2 above.
78
+ *
79
+ * @param required Set to `true` to indicate that auth is required, otherwise `false`.
80
+ */
81
+ authWebSocket(required) {
82
+ return (req, _res, next) => {
83
+ const sock = req.websocket || req.socket;
84
+ const user = req.user;
85
+ // Pre-upgrade auth already set req.user — no LOGIN handshake needed
86
+ if (user && user.uid) {
87
+ next();
88
+ return;
89
+ }
90
+ // Ensures timer, message listener, and close listener each fire at most once.
91
+ // Prevents the timer from firing after the socket closes (which would try to call
92
+ // sock.close() on an already-closed handle and throw an unhandled rejection).
93
+ let settled = false;
94
+ const settle = (fn) => {
95
+ if (settled)
96
+ return;
97
+ settled = true;
98
+ clearTimeout(timer);
99
+ sock.removeListener("message", onMessage);
100
+ sock.removeListener("close", onClose);
101
+ fn();
102
+ };
103
+ const onClose = () => {
104
+ // Socket closed before auth completed — unblock runChain so the open handler can
105
+ // finish. The readyState === 3 guard in Router.ts will skip the final ws.close().
106
+ settle(() => next());
107
+ };
108
+ const onMessage = (data, isBinary) => {
109
+ if (isBinary) {
110
+ settle(() => {
111
+ if (required) {
112
+ const error = new ApiError(ApiErrors.INVALID_REQUEST, 400, ApiErrorMessages.INVALID_REQUEST);
113
+ sock.close(1002, error.code);
114
+ next(error);
115
+ }
116
+ else {
117
+ next();
118
+ }
119
+ });
120
+ return;
121
+ }
122
+ try {
123
+ const message = JSON.parse(data);
124
+ if (message.type === "LOGIN") {
125
+ const payload = JWTUtils.decodeToken(this.authConfig, message.data);
126
+ const loginUser = payload && payload.profile ? payload.profile : null;
127
+ if (loginUser && loginUser.uid) {
128
+ settle(() => {
129
+ sock.send(JSON.stringify({ id: message.id, type: "LOGIN_RESPONSE", success: true }));
130
+ req.user = loginUser;
131
+ // Set req.auth so @User decorator in wrapMiddleware resolves correctly
132
+ req.auth = { user: loginUser, method: "jwt", data: message.data, payload };
133
+ next();
134
+ });
135
+ }
136
+ else if (required) {
137
+ settle(() => {
138
+ const error = new ApiError(ApiErrors.AUTH_FAILED, 401, ApiErrorMessages.AUTH_FAILED);
139
+ sock.send(JSON.stringify({
140
+ id: message.id,
141
+ type: "LOGIN_RESPONSE",
142
+ success: false,
143
+ data: error.message,
144
+ }));
145
+ sock.close(1002, error.message);
146
+ next(error);
147
+ });
148
+ }
149
+ else {
150
+ settle(() => {
151
+ sock.send(JSON.stringify({
152
+ id: message.id,
153
+ type: "LOGIN_RESPONSE",
154
+ success: false,
155
+ data: "Invalid authentication token.",
156
+ }));
157
+ next();
158
+ });
159
+ }
160
+ }
161
+ else if (required) {
162
+ settle(() => {
163
+ const error = new ApiError(ApiErrors.INVALID_REQUEST, 400, ApiErrorMessages.INVALID_REQUEST);
164
+ sock.close(1002, error.code);
165
+ next(error);
166
+ });
167
+ }
168
+ else {
169
+ settle(() => next());
170
+ }
171
+ }
172
+ catch {
173
+ settle(() => {
174
+ if (required) {
175
+ const error = new ApiError(ApiErrors.INVALID_REQUEST, 400, ApiErrorMessages.INVALID_REQUEST);
176
+ sock.close(1002, error.code);
177
+ next(error);
178
+ }
179
+ else {
180
+ next();
181
+ }
182
+ });
183
+ }
184
+ };
185
+ sock.once("message", onMessage);
186
+ sock.once("close", onClose);
187
+ const timer = setTimeout(() => {
188
+ settle(() => {
189
+ if (required) {
190
+ const error = new ApiError(ApiErrors.AUTH_FAILED, 401, ApiErrorMessages.AUTH_FAILED);
191
+ error.status = 401;
192
+ sock.close(1002, error.message);
193
+ next(error);
194
+ }
195
+ else {
196
+ next();
197
+ }
198
+ });
199
+ }, this.authSocketTimeout);
200
+ };
201
+ }
202
+ /**
203
+ * Registers the provided authentication strategy to be used
204
+ * @param name The name of the authentication type to associate the given strategy with
205
+ * @param strategy The strategy to register
206
+ */
207
+ register(name, strategy) {
208
+ this.strategies.set(name, strategy);
209
+ }
210
+ }
211
+ __decorate([
212
+ Config("auth"),
213
+ __metadata("design:type", Object)
214
+ ], AuthMiddleware.prototype, "authConfig", void 0);
215
+ __decorate([
216
+ Config("auth:socketTimeout", 2000),
217
+ __metadata("design:type", Number)
218
+ ], AuthMiddleware.prototype, "authSocketTimeout", void 0);
219
+ __decorate([
220
+ Inject(ObjectFactory),
221
+ __metadata("design:type", ObjectFactory)
222
+ ], AuthMiddleware.prototype, "objectFactory", void 0);
223
+ __decorate([
224
+ Init,
225
+ __metadata("design:type", Function),
226
+ __metadata("design:paramtypes", []),
227
+ __metadata("design:returntype", Promise)
228
+ ], AuthMiddleware.prototype, "init", null);
229
+ //# sourceMappingURL=AuthMiddleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthMiddleware.js","sourceRoot":"","sources":["../../../src/auth/AuthMiddleware.ts"],"names":[],"mappings":";;;;;;;;;AAAA,gFAAgF;AAChF,kDAAkD;AAClD,+EAA+E;AAC/E,OAAO,EAAW,QAAQ,EAAc,QAAQ,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAE5F,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAG9D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC;AAElD;;;;GAIG;AACH,MAAM,OAAO,cAAc;IAA3B;QAKY,sBAAiB,GAAW,IAAI,CAAC;QAKzC,+DAA+D;QAC/C,eAAU,GAA8B,IAAI,GAAG,EAAE,CAAC;IAoNtE,CAAC;IAjNiB,AAAN,KAAK,CAAC,IAAI;QACd,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,wDAAwD;YACxD,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC;YACjE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;YAE7D,IAAI,I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AEF,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YAChC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAE5B,MAAM,KAAK,GAAmB,UAAU,CAAC,GAAG,EAAE;gBAC1C,MAAM,CAAC,GAAG,EAAE;oBACR,IAAI,QAAQ,EAAE,CAAC;wBACX,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,SAAS,CAAC,WAAW,EAAE,GAAG,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAC;wBACrF,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC;wBACnB,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;wBAChC,IAAI,CAAC,KAAK,CAAC,CAAC;oBAChB,CAAC;yBAAM,CAAC;wBACJ,IAAI,EAAE,CAAC;oBACX,CAAC;gBACL,CAAC,CAAC,CAAC;YACP,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC/B,CAAC,CAAC;IACN,CAAC;IAED;;;;OAIG;IACI,QAAQ,CAAC,IAAY,EAAE,QAAsB;QAChD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC;CACJ;AA7NW;IADP,MAAM,CAAC,MAAM,CAAC;;kDACS;AAGhB;IADP,MAAM,CAAC,oBAAoB,EAAE,IAAI,CAAC;;yDACM;AAGjC;IADP,MAAM,CAAC,aAAa,CAAC;8BACE,aAAa;qDAAC;AAMxB;IADb,IAAI;;;;0CAYJ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=AuthStrategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthStrategy.js","sourceRoot":"","sources":["../../../src/auth/AuthStrategy.ts"],"names":[],"mappings":""}
@@ -0,0 +1,106 @@
1
+ import { ApiErrorMessages } from "../ApiErrors.js";
2
+ /**
3
+ * Describes the configuration options that can be used to initialize BasicStrategy.
4
+ *
5
+ * @author Jean-Philippe Steinmetz
6
+ */
7
+ export class BasicStrategyOptions {
8
+ constructor() {
9
+ /** The name of the header to look for when performing header based authentication. Default value is `Authorization`. */
10
+ this.headerKey = "authorization";
11
+ /** The authorization scheme type when using header based authentication. Default value is `jwt`. */
12
+ this.headerScheme = "basic";
13
+ /** The name of the request query parameter to retrieve the token from when using query based authentication. Default value is `auth_basic`. */
14
+ this.queryKey = "auth_basic";
15
+ /**
16
+ * Set to `true` to allow credentials to be supplied via the `queryKey` URL parameter.
17
+ * Disabled by default — query parameters appear in server logs, browser history, and
18
+ * Referer headers, which permanently exposes credentials outside the application.
19
+ */
20
+ this.allowQueryParam = false;
21
+ }
22
+ /** You must override this function to perform verification of the login information. */
23
+ verify(uid, secret) {
24
+ return undefined;
25
+ }
26
+ }
27
+ /**
28
+ * @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
29
+ */
30
+ export class BasicStrategy {
31
+ constructor(options = new BasicStrategyOptions()) {
32
+ this.name = "basic";
33
+ this.options = options;
34
+ }
35
+ authenticate(req, res, required) {
36
+ let error = "";
37
+ let loginFound = false;
38
+ let loginInfo = "";
39
+ // Login info should be found in this order: Query Parameter => Authorization
40
+ // Check the query parameter (only when explicitly opted in — tokens in URLs appear in logs)
41
+ if (this.options.allowQueryParam && this.options.queryKey && req.query && this.options.queryKey in req.query) {
42
+ loginInfo = req.query[this.options.queryKey];
43
+ loginFound = true;
44
+ }
45
+ // Next check the headers. It's possible there is more than one header value defined. Loop through each of
46
+ // them until we have a verified login info.
47
+ if (!loginFound && this.options.headerKey && this.options.headerKey in req.headers) {
48
+ loginFound = true;
49
+ const value = req.headers[this.options.headerKey];
50
+ const headers = Array.isArray(value) ? value : typeof value === "string" ? [value] : [];
51
+ // Loop throught th
52
+ for (const header in headers) {
53
+ const parts = headers[header].split(" ");
54
+ if (parts.length !== 2) {
55
+ error = ApiErrorMessages.AUTH_FAILED;
56
+ continue;
57
+ }
58
+ if (!parts[0].match(new RegExp("^" + this.options.headerScheme + "$", "i"))) {
59
+ error = ApiErrorMessages.AUTH_FAILED;
60
+ continue;
61
+ }
62
+ loginInfo = parts[1];
63
+ }
64
+ }
65
+ // If the login info has been found, verify it.
66
+ if (loginInfo && loginInfo.length > 0) {
67
+ const info = Buffer.from(loginInfo, "base64").toString("utf-8");
68
+ const parts = info.split(":");
69
+ if (parts.length !== 2) {
70
+ throw new Error("Invalid or missing username of password.");
71
+ }
72
+ const result = this.options.verify(parts[0], parts[1]);
73
+ if (result) {
74
+ if (result instanceof Promise) {
75
+ return new Promise(async (resolve, reject) => {
76
+ try {
77
+ const user = await result;
78
+ resolve({
79
+ data: loginInfo,
80
+ method: this.name,
81
+ payload: info,
82
+ user,
83
+ });
84
+ }
85
+ catch (err) {
86
+ reject(err);
87
+ }
88
+ });
89
+ }
90
+ else {
91
+ return {
92
+ data: loginInfo,
93
+ method: this.name,
94
+ payload: info,
95
+ user: result,
96
+ };
97
+ }
98
+ }
99
+ }
100
+ if (required) {
101
+ throw new Error("Invalid or missing username of password.");
102
+ }
103
+ return undefined;
104
+ }
105
+ }
106
+ //# sourceMappingURL=BasicStrategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BasicStrategy.js","sourceRoot":"","sources":["../../../src/auth/BasicStrategy.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IAAjC;QACI,wHAAwH;QACjH,cAAS,GAAW,eAAe,CAAC;QAC3C,oGAAoG;QAC7F,iBAAY,GAAW,OAAO,CAAC;QACtC,+IAA+I;QACxI,aAAQ,GAAW,YAAY,CAAC;QACvC;;;;WAIG;QACI,oBAAe,GAAY,KAAK,CAAC;IAK5C,CAAC;IAJG,wFAAwF;IACjF,MAAM,CAAC,GAAW,EAAE,MAAc;QACrC,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AA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AAE,SAAS;gCACf,MAAM,EAAE,IAAI,CAAC,IAAI;gCACjB,OAAO,EAAE,IAAI;gCACb,IAAI;6BACP,CAAC,CAAC;wBACP,CAAC;wBAAC,OAAO,GAAG,EAAE,CAAC;4BACX,MAAM,CAAC,GAAG,CAAC,CAAC;wBAChB,CAAC;oBACL,CAAC,CAAC,CAAC;gBACP,CAAC;qBAAM,CAAC;oBACJ,OAAO;wBACH,IAAI,EAAE,SAAS;wBACf,MAAM,EAAE,IAAI,CAAC,IAAI;wBACjB,OAAO,EAAE,IAAI;wBACb,IAAI,EAAE,MAAM;qBACf,CAAC;gBACN,CAAC;YACL,CAAC;QACL,CAAC;QAED,IAAI,QAAQ,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAChE,CAAC;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ"}
@@ -0,0 +1,161 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ ////////////////////////////////////////////////////////////////////////////////
11
+ // Copyright (C) 2020-2026 Jean-Philippe Steinmetz
12
+ ///////////////////////////////////////////////////////////////////////////////
13
+ import { JWTUtils, ObjectDecorators } from "@rapidrest/core";
14
+ import { ApiErrorMessages } from "../ApiErrors.js";
15
+ import dayjs from "dayjs";
16
+ import { createRequire } from "module";
17
+ const { Config } = ObjectDecorators;
18
+ const _require = createRequire(process.cwd() + "/package.json");
19
+ const duration = _require("dayjs/plugin/duration");
20
+ dayjs.extend(duration);
21
+ /**
22
+ * Describes the configuration options that can be used to initialize JWTStrategy.
23
+ *
24
+ * @author Jean-Philippe Steinmetz
25
+ */
26
+ export class JWTStrategyOptions {
27
+ constructor() {
28
+ /** The name of the header to look for when performing header based authentication. Default value is `Authorization`. */
29
+ this.headerKey = "authorization";
30
+ /** The authorization scheme type when using header based authentication. Default value is `jwt`. */
31
+ this.headerScheme = "(jwt|bearer)";
32
+ /** The name of the cookie to retrieve the token from when using cookie based authentication. Default value is `jwt`. */
33
+ this.cookieName = "jwt";
34
+ /** The name of the secured cookie to retreive the token from when using cookie based authentication. */
35
+ this.cookieSecure = false;
36
+ /** The name of the request query parameter to retrieve the token from when using query based authentication. Default value is `auth_token`. */
37
+ this.queryKey = "auth_token";
38
+ /**
39
+ * Set to `true` to allow tokens to be supplied via the `queryKey` URL parameter.
40
+ * Disabled by default — query parameters appear in server logs, browser history, and
41
+ * Referer headers, which permanently exposes tokens outside the application.
42
+ */
43
+ this.allowQueryParam = false;
44
+ }
45
+ }
46
+ /**
47
+ * JWT authentication strategy. Performs JWT verification and searches for a token by one of the
48
+ * following methods (in order of precedence):
49
+ * * Query Parameter
50
+ * * Authorization Header
51
+ * * Cookie
52
+ *
53
+ * This class no longer extends `passport-strategy`; it is used directly by route middleware
54
+ * and returns a plain result object instead of calling Passport callbacks.
55
+ *
56
+ * @author Jean-Philippe Steinmetz
57
+ */
58
+ export class JWTStrategy {
59
+ constructor(options = new JWTStrategyOptions()) {
60
+ this.name = "jwt";
61
+ this.options = options;
62
+ this.options.headerKey = options.headerKey.toLowerCase();
63
+ }
64
+ /**
65
+ * Attempts to authenticate the incoming request by extracting and verifying a JWT token.
66
+ * Returns a `JWTAuthResult` describing the outcome.
67
+ */
68
+ authenticate(req, res, required) {
69
+ let error = "";
70
+ let user = undefined;
71
+ let authPayload = undefined;
72
+ let authToken = undefined;
73
+ let tokenFound = false;
74
+ // Tokens should be found in this order: Query Parameter => Authorization => Cookie
75
+ // Check the query parameter (only when explicitly opted in — tokens in URLs appear in logs)
76
+ if ((this.options.allowQueryParam || this.config?.allowQueryParam) && this.options.queryKey && req.query && this.options.queryKey in req.query) {
77
+ let token = req.query[this.options.queryKey];
78
+ tokenFound = true;
79
+ const payload = JWTUtils.decodeToken(this.config, token);
80
+ // If the verification succeeded clear out any existing error, we have success
81
+ if (payload && payload.profile) {
82
+ error = "";
83
+ user = payload.profile;
84
+ }
85
+ // Store the payload in the request in case someone needs it
86
+ authPayload = payload;
87
+ // Store the full token in the request in case someone needs it
88
+ authToken = token;
89
+ }
90
+ // Next check the headers. It's possible there is more than one header value defined. Loop through each of
91
+ // them until we have a verified token.
92
+ if (!user && this.options.headerKey && this.options.headerKey in req.headers) {
93
+ tokenFound = true;
94
+ const value = req.headers[this.options.headerKey];
95
+ const headers = Array.isArray(value) ? value : typeof value === "string" ? [value] : [];
96
+ // Loop throught th
97
+ for (const header in headers) {
98
+ const parts = headers[header].split(" ");
99
+ if (parts.length !== 2) {
100
+ error = ApiErrorMessages.AUTH_FAILED;
101
+ continue;
102
+ }
103
+ if (!parts[0].match(new RegExp("^" + this.options.headerScheme + "$", "i"))) {
104
+ error = ApiErrorMessages.AUTH_FAILED;
105
+ continue;
106
+ }
107
+ let token = parts[1];
108
+ const payload = JWTUtils.decodeToken(this.config, token);
109
+ // If the verification succeeded clear out any existing error, we have success
110
+ if (payload && payload.profile) {
111
+ error = "";
112
+ user = payload.profile;
113
+ authPayload = payload;
114
+ authToken = token;
115
+ // No need to continue checking remaining headers. We have our success.
116
+ break;
117
+ }
118
+ authPayload = payload;
119
+ authToken = token;
120
+ }
121
+ }
122
+ // Check the cookie header
123
+ let token = "";
124
+ if (!user && this.options.cookieSecure && this.options.cookieName && req.signedCookies) {
125
+ // TODO Decrypt the signed cookie
126
+ token = req.signedCookies[this.options.cookieName];
127
+ }
128
+ if (!user && !this.options.cookieSecure && this.options.cookieName && req.cookies) {
129
+ token = req.cookies[this.options.cookieName];
130
+ }
131
+ // If the token has been found, verify it.
132
+ if (!user && token && token.length > 0) {
133
+ tokenFound = true;
134
+ try {
135
+ const payload = JWTUtils.decodeToken(this.config, token);
136
+ // If the verification succeeded clear out any existing error, we have success
137
+ if (payload && payload.profile) {
138
+ error = "";
139
+ user = payload.profile;
140
+ }
141
+ authPayload = payload;
142
+ authToken = token;
143
+ }
144
+ catch (err) {
145
+ error = err;
146
+ }
147
+ }
148
+ if (user) {
149
+ return { data: authToken, method: this.name, payload: authPayload, tokenFound, user };
150
+ }
151
+ if (required) {
152
+ throw new Error("Invalid or missing auth token.");
153
+ }
154
+ return undefined;
155
+ }
156
+ }
157
+ __decorate([
158
+ Config("auth"),
159
+ __metadata("design:type", Object)
160
+ ], JWTStrategy.prototype, "config", void 0);
161
+ //# sourceMappingURL=JWTStrategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JWTStrategy.js","sourceRoot":"","sources":["../../../src/auth/JWTStrategy.ts"],"names":[],"mappings":";;;;;;;;;AAAA,gFAAgF;AAChF,kDAAkD;AAClD,+EAA+E;AAC/E,OAAO,EAAE,QAAQ,EAAuC,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAClG,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC;AACpC,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,eAAe,CAAC,CAAC;AAChE,MAAM,QAAQ,GAAG,QAAQ,CAAC,uBAAuB,CAAC,CAAC;AACnD,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAEvB;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IAA/B;QAGI,wHAAwH;Q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QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;gBACrE,8EAA8E;gBAC9E,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;oBAC7B,KAAK,GAAG,EAAE,CAAC;oBACX,IAAI,GAAG,OAAO,CAAC,OAAkB,CAAC;gBACtC,CAAC;gBACD,WAAW,GAAG,OAAO,CAAC;gBACtB,SAAS,GAAG,KAAK,CAAC;YACtB,CAAC;YAAC,OAAO,GAAQ,EAAE,CAAC;gBAChB,KAAK,GAAG,GAAG,CAAC;YAChB,CAAC;QACL,CAAC;QAED,IAAI,IAAI,EAAE,CAAC;YACP,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QAC1F,CAAC;QAED,IAAI,QAAQ,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACtD,CAAC;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AAjHW;IADP,MAAM,CAAC,MAAM,CAAC;;2CACK"}
@@ -0,0 +1,5 @@
1
+ export * from "./AuthMiddleware.js";
2
+ export * from "./AuthStrategy.js";
3
+ export * from "./BasicStrategy.js";
4
+ export * from "./JWTStrategy.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,14 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2020-2026 Jean-Philippe Steinmetz. All rights reserved.
3
+ ///////////////////////////////////////////////////////////////////////////////
4
+ import { MongoConnection } from "./MongoConnection.js";
5
+ /**
6
+ * Determines whether the given connection object is a TypeORM `DataSource` for a SQL database. This check is
7
+ * performed without importing the optional `typeorm` package by duck-typing the connection object.
8
+ *
9
+ * @param conn The connection object to inspect.
10
+ */
11
+ export function isSqlDataSource(conn) {
12
+ return !!conn && typeof conn.getRepository === "function" && !(conn instanceof MongoConnection);
13
+ }
14
+ //# sourceMappingURL=ConnectionKinds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectionKinds.js","sourceRoot":"","sources":["../../../src/database/ConnectionKinds.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,wEAAwE;AACxE,+EAA+E;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,IAAS;IACrC,OAAO,CAAC,CAAC,IAAI,IAAI,OAAO,IAAI,CAAC,aAAa,KAAK,UAAU,IAAI,CAAC,CAAC,IAAI,YAAY,eAAe,CAAC,CAAC;AACpG,CAAC"}