pigallery2-extension-kit 3.5.2 → 3.6.0-edge

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 (420) hide show
  1. package/README.md +11 -5
  2. package/index.d.ts +1 -0
  3. package/index.js +2 -3
  4. package/lib/backend/Logger.d.ts +7 -7
  5. package/lib/backend/Logger.js +104 -0
  6. package/lib/backend/ProjectPath.d.ts +12 -0
  7. package/lib/backend/ProjectPath.js +28 -2
  8. package/lib/backend/exceptions/DirectoryNotFound.d.ts +2 -0
  9. package/lib/backend/exceptions/DirectoryNotFound.js +7 -0
  10. package/lib/backend/exceptions/FileAlreadyExists.js +10 -0
  11. package/lib/backend/exceptions/FolderNotWritable.d.ts +2 -0
  12. package/lib/backend/exceptions/FolderNotWritable.js +7 -0
  13. package/lib/backend/exceptions/LocationLookupException.js +10 -0
  14. package/lib/backend/index.d.ts +1 -1
  15. package/lib/backend/middlewares/AlbumMWs.js +61 -0
  16. package/lib/backend/middlewares/GalleryMWs.d.ts +4 -0
  17. package/lib/backend/middlewares/GalleryMWs.js +380 -0
  18. package/lib/backend/middlewares/MetaFileMWs.js +41 -0
  19. package/lib/backend/middlewares/NotificationMWs.js +21 -0
  20. package/lib/backend/middlewares/PersonMWs.d.ts +1 -1
  21. package/lib/backend/middlewares/PersonMWs.js +64 -0
  22. package/lib/backend/middlewares/RenderingMWs.d.ts +24 -0
  23. package/lib/backend/middlewares/RenderingMWs.js +182 -0
  24. package/lib/backend/middlewares/RequestParams.d.ts +13 -0
  25. package/lib/backend/middlewares/RequestParams.js +25 -0
  26. package/lib/backend/middlewares/RequestSession.d.ts +9 -0
  27. package/lib/backend/middlewares/RequestSession.js +16 -0
  28. package/lib/backend/middlewares/ServerTimingMWs.d.ts +6 -6
  29. package/lib/backend/middlewares/ServerTimingMWs.js +108 -0
  30. package/lib/backend/middlewares/SharingMWs.d.ts +2 -1
  31. package/lib/backend/middlewares/SharingMWs.js +240 -0
  32. package/lib/backend/middlewares/UploadMWs.js +95 -0
  33. package/lib/backend/middlewares/VersionMWs.d.ts +1 -1
  34. package/lib/backend/middlewares/VersionMWs.js +41 -0
  35. package/lib/backend/middlewares/admin/AdminMWs.js +115 -0
  36. package/lib/backend/middlewares/admin/ExtensionMWs.js +85 -0
  37. package/lib/backend/middlewares/admin/SettingsMWs.js +54 -0
  38. package/lib/backend/middlewares/thumbnail/ThumbnailGeneratorMWs.d.ts +1 -1
  39. package/lib/backend/middlewares/thumbnail/ThumbnailGeneratorMWs.js +153 -0
  40. package/lib/backend/middlewares/user/AuthenticationMWs.d.ts +37 -0
  41. package/lib/backend/middlewares/user/AuthenticationMWs.js +346 -0
  42. package/lib/backend/middlewares/user/OIDCAuthService.d.ts +36 -5
  43. package/lib/backend/middlewares/user/OIDCAuthService.js +216 -0
  44. package/lib/backend/middlewares/user/OIDCMWs.d.ts +10 -0
  45. package/lib/backend/middlewares/user/OIDCMWs.js +30 -0
  46. package/lib/backend/middlewares/user/UserMWs.d.ts +1 -0
  47. package/lib/backend/middlewares/user/UserMWs.js +120 -0
  48. package/lib/backend/middlewares/user/UserRequestConstrainsMWs.d.ts +0 -1
  49. package/lib/backend/middlewares/user/UserRequestConstrainsMWs.js +29 -0
  50. package/lib/backend/model/DirectoryAccess.d.ts +78 -0
  51. package/lib/backend/model/DirectoryAccess.js +222 -0
  52. package/lib/backend/model/EventLoopHandler.d.ts +1 -1
  53. package/lib/backend/model/EventLoopHandler.js +24 -0
  54. package/lib/backend/model/FFmpeg.d.ts +47 -0
  55. package/lib/backend/model/FFmpeg.js +75 -0
  56. package/lib/backend/model/FFmpegFactory.d.ts +11 -2
  57. package/lib/backend/model/FFmpegFactory.js +28 -0
  58. package/lib/backend/model/Localizations.js +19 -0
  59. package/lib/backend/model/ObjectManagers.d.ts +1 -1
  60. package/lib/backend/model/ObjectManagers.js +253 -0
  61. package/lib/backend/model/PasswordHelper.d.ts +1 -1
  62. package/lib/backend/model/PasswordHelper.js +6 -2
  63. package/lib/backend/model/SessionContext.d.ts +16 -6
  64. package/lib/backend/model/SessionContext.js +11 -0
  65. package/lib/backend/model/UploadManager.d.ts +6 -3
  66. package/lib/backend/model/UploadManager.js +101 -0
  67. package/lib/backend/model/database/AlbumManager.js +122 -0
  68. package/lib/backend/model/database/CoverManager.d.ts +8 -2
  69. package/lib/backend/model/database/CoverManager.js +169 -0
  70. package/lib/backend/model/database/GalleryManager.d.ts +15 -9
  71. package/lib/backend/model/database/GalleryManager.js +363 -0
  72. package/lib/backend/model/database/IObjectManager.js +2 -0
  73. package/lib/backend/model/database/IndexingManager.d.ts +7 -7
  74. package/lib/backend/model/database/IndexingManager.js +452 -0
  75. package/lib/backend/model/database/LocationManager.d.ts +2 -3
  76. package/lib/backend/model/database/LocationManager.js +39 -0
  77. package/lib/backend/model/database/PersonManager.d.ts +5 -3
  78. package/lib/backend/model/database/PersonManager.js +248 -0
  79. package/lib/backend/model/database/ProjectedCacheManager.d.ts +9 -8
  80. package/lib/backend/model/database/ProjectedCacheManager.js +297 -0
  81. package/lib/backend/model/database/ProjectionAwareManager.d.ts +4 -4
  82. package/lib/backend/model/database/ProjectionAwareManager.js +56 -0
  83. package/lib/backend/model/database/SQLConnection.d.ts +4 -2
  84. package/lib/backend/model/database/SQLConnection.js +295 -0
  85. package/lib/backend/model/database/SearchManager.d.ts +23 -8
  86. package/lib/backend/model/database/SearchManager.js +1032 -0
  87. package/lib/backend/model/database/SessionManager.d.ts +41 -4
  88. package/lib/backend/model/database/SessionManager.js +228 -0
  89. package/lib/backend/model/database/SharingManager.d.ts +11 -6
  90. package/lib/backend/model/database/SharingManager.js +160 -0
  91. package/lib/backend/model/database/UserManager.d.ts +8 -1
  92. package/lib/backend/model/database/UserManager.js +148 -0
  93. package/lib/backend/model/database/VersionManager.js +60 -0
  94. package/lib/backend/model/database/enitites/DirectoryEntity.d.ts +1 -1
  95. package/lib/backend/model/database/enitites/DirectoryEntity.js +76 -0
  96. package/lib/backend/model/database/enitites/EntityUtils.d.ts +22 -1
  97. package/lib/backend/model/database/enitites/EntityUtils.js +66 -0
  98. package/lib/backend/model/database/enitites/FileEntity.js +31 -0
  99. package/lib/backend/model/database/enitites/MDFileEntity.js +21 -0
  100. package/lib/backend/model/database/enitites/MediaEntity.d.ts +5 -2
  101. package/lib/backend/model/database/enitites/MediaEntity.js +223 -0
  102. package/lib/backend/model/database/enitites/PhotoEntity.js +19 -0
  103. package/lib/backend/model/database/enitites/ProjectedDirectoryCacheEntity.d.ts +2 -2
  104. package/lib/backend/model/database/enitites/ProjectedDirectoryCacheEntity.js +61 -0
  105. package/lib/backend/model/database/enitites/SharingEntity.d.ts +11 -5
  106. package/lib/backend/model/database/enitites/SharingEntity.js +100 -0
  107. package/lib/backend/model/database/enitites/UserEntity.d.ts +8 -5
  108. package/lib/backend/model/database/enitites/UserEntity.js +97 -0
  109. package/lib/backend/model/database/enitites/VersionEntity.js +19 -0
  110. package/lib/backend/model/database/enitites/VideoEntity.d.ts +2 -2
  111. package/lib/backend/model/database/enitites/VideoEntity.js +38 -0
  112. package/lib/backend/model/database/enitites/album/AlbumBaseEntity.js +32 -0
  113. package/lib/backend/model/database/enitites/album/ProjectedAlbumCacheEntity.d.ts +2 -2
  114. package/lib/backend/model/database/enitites/album/ProjectedAlbumCacheEntity.js +52 -0
  115. package/lib/backend/model/database/enitites/album/SavedSearchEntity.js +29 -0
  116. package/lib/backend/model/database/enitites/person/PersonEntry.js +36 -0
  117. package/lib/backend/model/database/enitites/person/PersonJunctionTable.js +37 -0
  118. package/lib/backend/model/database/enitites/person/ProjectedPersonCacheEntity.d.ts +1 -1
  119. package/lib/backend/model/database/enitites/person/ProjectedPersonCacheEntity.js +49 -0
  120. package/lib/backend/model/diagnostics/ConfigDiagnostics.d.ts +31 -12
  121. package/lib/backend/model/diagnostics/ConfigDiagnostics.js +537 -0
  122. package/lib/backend/model/extension/ExpressRouterWrapper.d.ts +10 -4
  123. package/lib/backend/model/extension/ExpressRouterWrapper.js +113 -0
  124. package/lib/backend/model/extension/ExtensionApp.d.ts +2 -3
  125. package/lib/backend/model/extension/ExtensionApp.js +18 -0
  126. package/lib/backend/model/extension/ExtensionConfig.js +17 -0
  127. package/lib/backend/model/extension/ExtensionConfigTemplateLoader.js +4 -3
  128. package/lib/backend/model/extension/ExtensionConfigWrapper.js +6 -5
  129. package/lib/backend/model/extension/ExtensionDB.d.ts +2 -2
  130. package/lib/backend/model/extension/ExtensionDB.js +22 -0
  131. package/lib/backend/model/extension/ExtensionDecorator.js +33 -0
  132. package/lib/backend/model/extension/ExtensionEvent.d.ts +12 -1
  133. package/lib/backend/model/extension/ExtensionEvent.js +81 -0
  134. package/lib/backend/model/extension/ExtensionManager.d.ts +22 -4
  135. package/lib/backend/model/extension/ExtensionManager.js +424 -0
  136. package/lib/backend/model/extension/ExtensionMessengerHandler.js +28 -0
  137. package/lib/backend/model/extension/ExtensionObject.d.ts +6 -3
  138. package/lib/backend/model/extension/ExtensionObject.js +45 -0
  139. package/lib/backend/model/extension/ExtensionRepository.js +69 -0
  140. package/lib/backend/model/extension/IExtension.d.ts +35 -18
  141. package/lib/backend/model/extension/IExtension.js +2 -0
  142. package/lib/backend/model/extension/UIExtension.js +23 -0
  143. package/lib/backend/model/fileaccess/DiskManager.d.ts +3 -1
  144. package/lib/backend/model/fileaccess/DiskManager.js +313 -0
  145. package/lib/backend/model/fileaccess/MetadataCreationDate.js +27 -0
  146. package/lib/backend/model/fileaccess/MetadataLoader.d.ts +17 -0
  147. package/lib/backend/model/fileaccess/MetadataLoader.js +765 -0
  148. package/lib/backend/model/fileaccess/PhotoWorker.js +159 -0
  149. package/lib/backend/model/fileaccess/TaskExecuter.js +41 -0
  150. package/lib/backend/model/fileaccess/TaskQue.d.ts +4 -4
  151. package/lib/backend/model/fileaccess/TaskQue.js +50 -0
  152. package/lib/backend/model/fileaccess/VideoConverterWorker.d.ts +4 -1
  153. package/lib/backend/model/fileaccess/VideoConverterWorker.js +59 -0
  154. package/lib/backend/model/fileaccess/fileprocessing/GPXProcessing.js +136 -0
  155. package/lib/backend/model/fileaccess/fileprocessing/PhotoProcessing.d.ts +3 -2
  156. package/lib/backend/model/fileaccess/fileprocessing/PhotoProcessing.js +251 -0
  157. package/lib/backend/model/fileaccess/fileprocessing/VideoProcessing.js +97 -0
  158. package/lib/backend/model/jobs/JobManager.d.ts +2 -4
  159. package/lib/backend/model/jobs/JobManager.js +129 -0
  160. package/lib/backend/model/jobs/JobProgressManager.d.ts +5 -3
  161. package/lib/backend/model/jobs/JobProgressManager.js +94 -0
  162. package/lib/backend/model/jobs/JobRepository.d.ts +1 -3
  163. package/lib/backend/model/jobs/JobRepository.js +50 -0
  164. package/lib/backend/model/jobs/jobs/AlbumCoverFillingJob.d.ts +1 -1
  165. package/lib/backend/model/jobs/jobs/AlbumCoverFillingJob.js +91 -0
  166. package/lib/backend/model/jobs/jobs/AlbumCoverResetJob.js +32 -0
  167. package/lib/backend/model/jobs/jobs/AlbumResetJob.js +30 -0
  168. package/lib/backend/model/jobs/jobs/FileJob.js +243 -0
  169. package/lib/backend/model/jobs/jobs/GPXCompressionJob.js +35 -0
  170. package/lib/backend/model/jobs/jobs/GPXCompressionResetJob.js +23 -0
  171. package/lib/backend/model/jobs/jobs/GalleryResetJob.js +30 -0
  172. package/lib/backend/model/jobs/jobs/IJob.js +2 -0
  173. package/lib/backend/model/jobs/jobs/IJobListener.d.ts +2 -2
  174. package/lib/backend/model/jobs/jobs/IJobListener.js +2 -0
  175. package/lib/backend/model/jobs/jobs/IndexingJob.js +99 -0
  176. package/lib/backend/model/jobs/jobs/Job.d.ts +4 -1
  177. package/lib/backend/model/jobs/jobs/Job.js +135 -0
  178. package/lib/backend/model/jobs/jobs/JobProgress.js +100 -0
  179. package/lib/backend/model/jobs/jobs/PhotoConvertingJob.js +78 -0
  180. package/lib/backend/model/jobs/jobs/TempFolderCleaningJob.js +122 -0
  181. package/lib/backend/model/jobs/jobs/TopPickSendJob.js +113 -0
  182. package/lib/backend/model/jobs/jobs/VideoConvertingJob.js +31 -0
  183. package/lib/backend/model/messenger/EmailMessenger.d.ts +1 -1
  184. package/lib/backend/model/messenger/EmailMessenger.js +87 -0
  185. package/lib/backend/model/messenger/ExtensionMessenger.js +16 -0
  186. package/lib/backend/model/messenger/Messenger.d.ts +1 -2
  187. package/lib/backend/model/messenger/Messenger.js +36 -0
  188. package/lib/backend/model/messenger/MessengerRepository.d.ts +1 -3
  189. package/lib/backend/model/messenger/MessengerRepository.js +38 -0
  190. package/lib/backend/model/messenger/StdoutMessenger.js +16 -0
  191. package/lib/backend/routes/AlbumRouter.js +39 -0
  192. package/lib/backend/routes/ErrorRouter.d.ts +1 -0
  193. package/lib/backend/routes/ErrorRouter.js +39 -0
  194. package/lib/backend/routes/GalleryRouter.d.ts +8 -0
  195. package/lib/backend/routes/GalleryRouter.js +165 -0
  196. package/lib/backend/routes/LoggerRouter.js +43 -0
  197. package/lib/backend/routes/NotificationRouter.js +19 -0
  198. package/lib/backend/routes/OIDCRouter.js +20 -0
  199. package/lib/backend/routes/PersonRouter.js +41 -0
  200. package/lib/backend/routes/PublicRouter.d.ts +3 -6
  201. package/lib/backend/routes/PublicRouter.js +301 -0
  202. package/lib/backend/routes/Router.js +36 -0
  203. package/lib/backend/routes/SharingRouter.d.ts +1 -1
  204. package/lib/backend/routes/SharingRouter.js +55 -0
  205. package/lib/backend/routes/UploadRouter.js +18 -0
  206. package/lib/backend/routes/UserRouter.d.ts +1 -0
  207. package/lib/backend/routes/UserRouter.js +53 -0
  208. package/lib/backend/routes/admin/AdminRouter.js +32 -0
  209. package/lib/backend/routes/admin/ExtensionRouter.js +30 -0
  210. package/lib/backend/routes/admin/SettingsRouter.js +18 -0
  211. package/lib/backend/server.d.ts +3 -3
  212. package/lib/backend/server.js +176 -0
  213. package/lib/common/CookieNames.js +10 -0
  214. package/lib/common/CustomHeaders.js +8 -0
  215. package/lib/common/DataStructureVersion.d.ts +1 -1
  216. package/lib/common/DataStructureVersion.js +7 -0
  217. package/lib/common/PG2ConfMap.js +36 -0
  218. package/lib/common/QueryParams.js +45 -0
  219. package/lib/common/SearchQueryParser.d.ts +2 -2
  220. package/lib/common/SearchQueryParser.js +611 -0
  221. package/lib/common/SearchQueryUtils.d.ts +71 -4
  222. package/lib/common/SearchQueryUtils.js +443 -0
  223. package/lib/common/SupportedFormats.d.ts +11 -1
  224. package/lib/common/SupportedFormats.js +13 -19
  225. package/lib/common/TextFold.d.ts +6 -0
  226. package/lib/common/TextFold.js +19 -0
  227. package/lib/common/UploadUtils.d.ts +4 -0
  228. package/lib/common/UploadUtils.js +20 -0
  229. package/lib/common/Utils.d.ts +23 -24
  230. package/lib/common/Utils.js +37 -97
  231. package/lib/common/config/private/Config.d.ts +1 -1
  232. package/lib/common/config/private/Config.js +2 -0
  233. package/lib/common/config/private/PrivateConfig.d.ts +17 -4
  234. package/lib/common/config/private/PrivateConfig.js +262 -33
  235. package/lib/common/config/private/PrivateConfigClass.js +10 -13
  236. package/lib/common/config/private/WebConfig.d.ts +1 -2
  237. package/lib/common/config/private/WebConfig.js +0 -2
  238. package/lib/common/config/private/subconfigs/MessagingConfig.js +8 -0
  239. package/lib/common/config/private/subconfigs/ServerExtensionsConfig.d.ts +2 -3
  240. package/lib/common/config/private/subconfigs/ServerExtensionsConfig.js +7 -3
  241. package/lib/common/config/public/ClientConfig.d.ts +55 -17
  242. package/lib/common/config/public/ClientConfig.js +291 -20
  243. package/lib/common/config/public/Config.js +5 -4
  244. package/lib/common/entities/AutoCompleteItem.d.ts +3 -3
  245. package/lib/common/entities/ContentWrapper.d.ts +21 -8
  246. package/lib/common/entities/ContentWrapper.js +286 -318
  247. package/lib/common/entities/DirectoryDTO.d.ts +7 -6
  248. package/lib/common/entities/DirectoryDTO.js +10 -5
  249. package/lib/common/entities/Error.d.ts +12 -7
  250. package/lib/common/entities/Error.js +15 -3
  251. package/lib/common/entities/MediaDTO.d.ts +13 -0
  252. package/lib/common/entities/MediaDTO.js +10 -7
  253. package/lib/common/entities/Message.d.ts +3 -3
  254. package/lib/common/entities/NotificationDTO.d.ts +2 -2
  255. package/lib/common/entities/SearchQueryDTO.d.ts +9 -1
  256. package/lib/common/entities/SearchQueryDTO.js +1 -0
  257. package/lib/common/entities/SharingDTO.d.ts +39 -5
  258. package/lib/common/entities/SortingMethods.d.ts +26 -2
  259. package/lib/common/entities/SortingMethods.js +14 -1
  260. package/lib/common/entities/UserDTO.d.ts +5 -2
  261. package/lib/common/entities/UserSettingsDTO.d.ts +3 -1
  262. package/lib/common/entities/VideoDTO.d.ts +2 -5
  263. package/lib/common/entities/album/AlbumBaseDTO.d.ts +2 -2
  264. package/lib/common/entities/extension/ExtensionListItem.d.ts +1 -1
  265. package/lib/common/entities/extension/IClientUIConfig.d.ts +19 -12
  266. package/lib/common/entities/job/JobDTO.d.ts +1 -1
  267. package/lib/common/entities/job/JobProgressDTO.d.ts +1 -1
  268. package/lib/common/entities/job/JobScheduleDTO.d.ts +5 -5
  269. package/lib/common/entities/job/JobScheduleDTO.js +9 -5
  270. package/lib/common/event/Event.js +49 -0
  271. package/lib/common/event/EventLimit.d.ts +1 -1
  272. package/package.json +21 -8
  273. package/REPOSITORY.md +0 -13
  274. package/events.drawio +0 -1
  275. package/events.png +0 -0
  276. package/index.js.map +0 -1
  277. package/index.ts +0 -2
  278. package/lib/backend/model/database/enitites/PersonEntry.d.ts +0 -11
  279. package/lib/backend/model/database/enitites/PersonJunctionTable.d.ts +0 -10
  280. package/lib/common/entities/ConentWrapper.d.ts +0 -18
  281. package/lib/common/entities/ConentWrapper.js +0 -490
  282. package/lib/frontend/app/app.component.d.ts +0 -18
  283. package/lib/frontend/app/app.module.d.ts +0 -23
  284. package/lib/frontend/app/app.routing.d.ts +0 -4
  285. package/lib/frontend/app/icon.component.d.ts +0 -7
  286. package/lib/frontend/app/model/IRenderable.d.ts +0 -17
  287. package/lib/frontend/app/model/backendtext.service.d.ts +0 -7
  288. package/lib/frontend/app/model/backendtext.service.spec.d.ts +0 -1
  289. package/lib/frontend/app/model/extension.service.d.ts +0 -5
  290. package/lib/frontend/app/model/navigation.service.d.ts +0 -12
  291. package/lib/frontend/app/model/network/autehentication.service.spec.d.ts +0 -1
  292. package/lib/frontend/app/model/network/authentication.service.d.ts +0 -22
  293. package/lib/frontend/app/model/network/helper/auth.guard.d.ts +0 -9
  294. package/lib/frontend/app/model/network/helper/csrf.interceptor.d.ts +0 -8
  295. package/lib/frontend/app/model/network/helper/error.interceptor.d.ts +0 -8
  296. package/lib/frontend/app/model/network/network.service.d.ts +0 -29
  297. package/lib/frontend/app/model/network/network.service.spec.d.ts +0 -1
  298. package/lib/frontend/app/model/network/user.service.d.ts +0 -13
  299. package/lib/frontend/app/model/network/user.service.spec.d.ts +0 -1
  300. package/lib/frontend/app/model/notification.service.d.ts +0 -28
  301. package/lib/frontend/app/model/page.helper.d.ts +0 -15
  302. package/lib/frontend/app/model/pi-title.service.d.ts +0 -15
  303. package/lib/frontend/app/model/query.service.d.ts +0 -19
  304. package/lib/frontend/app/model/seededRandom.service.d.ts +0 -7
  305. package/lib/frontend/app/model/theme.service.d.ts +0 -16
  306. package/lib/frontend/app/model/version.service.d.ts +0 -10
  307. package/lib/frontend/app/pipes/DurationPipe.d.ts +0 -4
  308. package/lib/frontend/app/pipes/FileDTOToPathPipe.d.ts +0 -5
  309. package/lib/frontend/app/pipes/FileDTOToRelativePathPipe.d.ts +0 -5
  310. package/lib/frontend/app/pipes/FileSizePipe.d.ts +0 -4
  311. package/lib/frontend/app/pipes/GPXFilesFilterPipe.d.ts +0 -5
  312. package/lib/frontend/app/pipes/MDFilesFilterPipe.d.ts +0 -6
  313. package/lib/frontend/app/pipes/ParseIntPipe.d.ts +0 -4
  314. package/lib/frontend/app/pipes/PhotoFilterPipe.d.ts +0 -6
  315. package/lib/frontend/app/pipes/SafeHTMLPipe.d.ts +0 -7
  316. package/lib/frontend/app/pipes/StringifyEnum.d.ts +0 -4
  317. package/lib/frontend/app/pipes/StringifyGridSize.d.ts +0 -5
  318. package/lib/frontend/app/pipes/StringifyRolePipe.d.ts +0 -4
  319. package/lib/frontend/app/pipes/StringifySearchQuery.d.ts +0 -8
  320. package/lib/frontend/app/pipes/StringifySearchType.d.ts +0 -5
  321. package/lib/frontend/app/pipes/StringifySortingMethod.d.ts +0 -4
  322. package/lib/frontend/app/ui/EnumTranslations.d.ts +0 -5
  323. package/lib/frontend/app/ui/admin/admin.component.d.ts +0 -36
  324. package/lib/frontend/app/ui/albums/album/album.component.d.ts +0 -26
  325. package/lib/frontend/app/ui/albums/albums.component.d.ts +0 -31
  326. package/lib/frontend/app/ui/albums/albums.service.d.ts +0 -12
  327. package/lib/frontend/app/ui/albums/saved-search-popup/saved-search-popup.component.d.ts +0 -15
  328. package/lib/frontend/app/ui/duplicates/duplicates.component.d.ts +0 -36
  329. package/lib/frontend/app/ui/duplicates/duplicates.service.d.ts +0 -9
  330. package/lib/frontend/app/ui/duplicates/photo/photo.duplicates.component.d.ts +0 -11
  331. package/lib/frontend/app/ui/faces/Person.d.ts +0 -9
  332. package/lib/frontend/app/ui/faces/face/face.component.d.ts +0 -22
  333. package/lib/frontend/app/ui/faces/faces.component.d.ts +0 -18
  334. package/lib/frontend/app/ui/faces/faces.service.d.ts +0 -14
  335. package/lib/frontend/app/ui/faces/navigator/navigator.faces.component.d.ts +0 -15
  336. package/lib/frontend/app/ui/frame/frame.component.d.ts +0 -60
  337. package/lib/frontend/app/ui/gallery/Media.d.ts +0 -15
  338. package/lib/frontend/app/ui/gallery/MediaIcon.d.ts +0 -29
  339. package/lib/frontend/app/ui/gallery/blog/blog.gallery.component.d.ts +0 -16
  340. package/lib/frontend/app/ui/gallery/blog/blog.service.d.ts +0 -85
  341. package/lib/frontend/app/ui/gallery/blog/blog.service.spec.d.ts +0 -1
  342. package/lib/frontend/app/ui/gallery/cache.gallery.service.d.ts +0 -51
  343. package/lib/frontend/app/ui/gallery/content.service.d.ts +0 -11
  344. package/lib/frontend/app/ui/gallery/contentLoader.service.d.ts +0 -37
  345. package/lib/frontend/app/ui/gallery/directories/directories.component.d.ts +0 -14
  346. package/lib/frontend/app/ui/gallery/directories/directory/directory.gallery.component.d.ts +0 -20
  347. package/lib/frontend/app/ui/gallery/filter/filter.gallery.component.d.ts +0 -32
  348. package/lib/frontend/app/ui/gallery/filter/filter.service.d.ts +0 -51
  349. package/lib/frontend/app/ui/gallery/filter/filter.service.spec.d.ts +0 -1
  350. package/lib/frontend/app/ui/gallery/fullscreen.service.d.ts +0 -7
  351. package/lib/frontend/app/ui/gallery/gallery.component.d.ts +0 -64
  352. package/lib/frontend/app/ui/gallery/gallery.component.spec.d.ts +0 -1
  353. package/lib/frontend/app/ui/gallery/gallery.service.d.ts +0 -13
  354. package/lib/frontend/app/ui/gallery/grid/GridMedia.d.ts +0 -13
  355. package/lib/frontend/app/ui/gallery/grid/GridRowBuilder.d.ts +0 -16
  356. package/lib/frontend/app/ui/gallery/grid/grid.gallery.component.d.ts +0 -88
  357. package/lib/frontend/app/ui/gallery/grid/grid.gallery.component.spec.d.ts +0 -1
  358. package/lib/frontend/app/ui/gallery/grid/photo/loading/loading.photo.grid.gallery.component.d.ts +0 -4
  359. package/lib/frontend/app/ui/gallery/grid/photo/media-button-modal/media-button-modal.component.d.ts +0 -20
  360. package/lib/frontend/app/ui/gallery/grid/photo/media-button-modal/media-button-modal.service.d.ts +0 -27
  361. package/lib/frontend/app/ui/gallery/grid/photo/photo.grid.gallery.component.d.ts +0 -53
  362. package/lib/frontend/app/ui/gallery/lightbox/controls/controls.lightbox.gallery.component.d.ts +0 -103
  363. package/lib/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.d.ts +0 -51
  364. package/lib/frontend/app/ui/gallery/lightbox/lightbox.gallery.component.d.ts +0 -95
  365. package/lib/frontend/app/ui/gallery/lightbox/lightbox.gallery.component.spec.d.ts +0 -1
  366. package/lib/frontend/app/ui/gallery/lightbox/lightbox.service.d.ts +0 -45
  367. package/lib/frontend/app/ui/gallery/lightbox/media/media.lightbox.gallery.component.d.ts +0 -71
  368. package/lib/frontend/app/ui/gallery/map/MarkerFactory.d.ts +0 -12
  369. package/lib/frontend/app/ui/gallery/map/lightbox/lightbox.map.gallery.component.d.ts +0 -80
  370. package/lib/frontend/app/ui/gallery/map/map.gallery.component.d.ts +0 -36
  371. package/lib/frontend/app/ui/gallery/map/map.service.d.ts +0 -30
  372. package/lib/frontend/app/ui/gallery/navigator/navigator.gallery.component.d.ts +0 -81
  373. package/lib/frontend/app/ui/gallery/navigator/navigator.service.d.ts +0 -14
  374. package/lib/frontend/app/ui/gallery/navigator/sorting.service.d.ts +0 -38
  375. package/lib/frontend/app/ui/gallery/overlay.service.d.ts +0 -9
  376. package/lib/frontend/app/ui/gallery/photo-frame-builder/photo-frame-builder.gallery.component.d.ts +0 -40
  377. package/lib/frontend/app/ui/gallery/random-query-builder/random-query-builder.gallery.component.d.ts +0 -30
  378. package/lib/frontend/app/ui/gallery/search/AutoCompleteRenderItem.d.ts +0 -11
  379. package/lib/frontend/app/ui/gallery/search/autocomplete.service.d.ts +0 -33
  380. package/lib/frontend/app/ui/gallery/search/query-builder/query-bulder.gallery.component.d.ts +0 -22
  381. package/lib/frontend/app/ui/gallery/search/query-enrty/query-entry.search.gallery.component.d.ts +0 -43
  382. package/lib/frontend/app/ui/gallery/search/search-field/search-field.gallery.component.d.ts +0 -31
  383. package/lib/frontend/app/ui/gallery/search/search-field-base/search-field-base.gallery.component.d.ts +0 -57
  384. package/lib/frontend/app/ui/gallery/search/search-query-parser.service.d.ts +0 -7
  385. package/lib/frontend/app/ui/gallery/search/search.gallery.component.d.ts +0 -39
  386. package/lib/frontend/app/ui/gallery/share/share.gallery.component.d.ts +0 -67
  387. package/lib/frontend/app/ui/gallery/share.service.d.ts +0 -35
  388. package/lib/frontend/app/ui/gallery/thumbnailLoader.service.d.ts +0 -41
  389. package/lib/frontend/app/ui/gallery/thumbnailManager.service.d.ts +0 -46
  390. package/lib/frontend/app/ui/gallery/uploader/uploader.gallery.component.d.ts +0 -15
  391. package/lib/frontend/app/ui/gallery/uploader/uploader.service.d.ts +0 -36
  392. package/lib/frontend/app/ui/gallery/wakelock.service.d.ts +0 -19
  393. package/lib/frontend/app/ui/language/language.component.d.ts +0 -10
  394. package/lib/frontend/app/ui/login/login.component.d.ts +0 -18
  395. package/lib/frontend/app/ui/settings/extension-installer/extension-installer.component.d.ts +0 -18
  396. package/lib/frontend/app/ui/settings/extension-installer/extension-installer.service.d.ts +0 -10
  397. package/lib/frontend/app/ui/settings/gallery-statistic/gallery-statistic.component.d.ts +0 -5
  398. package/lib/frontend/app/ui/settings/scheduled-jobs.service.d.ts +0 -41
  399. package/lib/frontend/app/ui/settings/settings.service.d.ts +0 -27
  400. package/lib/frontend/app/ui/settings/sharings-list/sharings-list.component.d.ts +0 -14
  401. package/lib/frontend/app/ui/settings/template/CustomSettingsEntries.d.ts +0 -57
  402. package/lib/frontend/app/ui/settings/template/ISettingsComponent.d.ts +0 -13
  403. package/lib/frontend/app/ui/settings/template/settings-entry/settings-entry.component.d.ts +0 -118
  404. package/lib/frontend/app/ui/settings/template/settings-entry/sorting-method/sorting-method.settings-entry.component.d.ts +0 -28
  405. package/lib/frontend/app/ui/settings/template/template.component.d.ts +0 -97
  406. package/lib/frontend/app/ui/settings/users/users.component.d.ts +0 -47
  407. package/lib/frontend/app/ui/settings/users/users.service.d.ts +0 -12
  408. package/lib/frontend/app/ui/settings/workflow/button/job-button.settings.component.d.ts +0 -32
  409. package/lib/frontend/app/ui/settings/workflow/progress/job-progress.settings.component.d.ts +0 -25
  410. package/lib/frontend/app/ui/settings/workflow/workflow.component.d.ts +0 -68
  411. package/lib/frontend/app/ui/sharelogin/share-login.component.d.ts +0 -16
  412. package/lib/frontend/app/ui/utils/grid-size-icon/grid-size-icon.component.d.ts +0 -5
  413. package/lib/frontend/app/ui/utils/sorting-method-icon/sorting-method-icon.component.d.ts +0 -13
  414. package/lib/frontend/app/ui/utils/timestamp-datepicker/datepicker.component.d.ts +0 -10
  415. package/lib/frontend/app/ui/utils/timestamp-timepicker/timepicker.component.d.ts +0 -11
  416. package/lib/frontend/environments/environment.d.ts +0 -3
  417. package/lib/frontend/environments/environment.prod.d.ts +0 -3
  418. package/lib/frontend/main.d.ts +0 -21
  419. package/lib/frontend/polyfills.d.ts +0 -60
  420. package/lib/frontend/test.d.ts +0 -1
@@ -1,11 +1,48 @@
1
- import { ContextUser, SessionContext } from '../SessionContext';
1
+ import { SessionUser, SessionContext } from '../SessionContext';
2
2
  import { SearchQueryDTO } from '../../../common/entities/SearchQueryDTO';
3
3
  import { SharingEntity } from './enitites/SharingEntity';
4
4
  export declare class SessionManager {
5
5
  static readonly NO_PROJECTION_KEY: string;
6
- private getQueryForUser;
7
- buildAllowListForSharing(sharing: SharingEntity): SearchQueryDTO;
6
+ private stamps;
7
+ private stampGeneration;
8
+ private static andQueries;
9
+ /**
10
+ * Creates the user that is used during a sharing session.
11
+ * It inherits the restrictions of the sharing creator.
12
+ */
13
+ createSharingUser(sharing: SharingEntity): SessionUser;
14
+ /**
15
+ * Signature of the DB row a session is based on: the user, or the sharing (with its creator).
16
+ * Sessions are stored in the cookie, a session is only valid while its stamp is unchanged,
17
+ * so deleting or changing the user or sharing ends it. Null if the row does not exist or the sharing expired.
18
+ */
19
+ getSessionStamp(user: SessionUser): Promise<string | null>;
20
+ /**
21
+ * Needs to be called after every user or sharing change.
22
+ */
23
+ invalidateSessionCache(): void;
24
+ private loadSessionRow;
25
+ /**
26
+ * Returns with the final projection query (media and directory allow/block lists) of a sharing.
27
+ */
28
+ buildAllowListForSharing(sharing: SharingEntity): SearchQueryDTO | null;
8
29
  createProjectionKey(q: SearchQueryDTO): string;
9
- buildContext(user: ContextUser): Promise<SessionContext>;
30
+ buildContext(user: SessionUser): Promise<SessionContext>;
10
31
  getAvailableUserSessions(): Promise<SessionContext[]>;
32
+ private buildDirectoryFilter;
33
+ /**
34
+ * Returns the media and the directory allow/block lists combined.
35
+ * Media that is in a not available directory is also not available.
36
+ */
37
+ private getQueryForUser;
38
+ private getMediaQueryForUser;
39
+ /**
40
+ * Returns the user's own lists if they are overridden, otherwise the global ones from the config.
41
+ */
42
+ private getDirectoryListsForUser;
43
+ /**
44
+ * A directory is available if it matches every allow list and none of the block list entries.
45
+ * The directory query of a sharing works as an extra allow list (on top of the creator's lists).
46
+ */
47
+ private getDirectoryAccessForUser;
11
48
  }
@@ -0,0 +1,228 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SessionManager = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const crypto = tslib_1.__importStar(require("node:crypto"));
6
+ const SessionContext_1 = require("../SessionContext");
7
+ const DirectoryAccess_1 = require("../DirectoryAccess");
8
+ const SearchQueryUtils_1 = require("../../../common/SearchQueryUtils");
9
+ const Config_1 = require("../../../common/config/private/Config");
10
+ const SearchQueryDTO_1 = require("../../../common/entities/SearchQueryDTO");
11
+ const SharingEntity_1 = require("./enitites/SharingEntity");
12
+ const ObjectManagers_1 = require("../ObjectManagers");
13
+ const Logger_1 = require("../../Logger");
14
+ const UserDTO_1 = require("../../../common/entities/UserDTO");
15
+ const UserEntity_1 = require("./enitites/UserEntity");
16
+ const SQLConnection_1 = require("./SQLConnection");
17
+ const LOG_TAG = '[SessionManager]';
18
+ class SessionManager {
19
+ constructor() {
20
+ // Session stamps by user id or sharing key (see getSessionStamp), so they do not need a DB query per request.
21
+ this.stamps = new Map();
22
+ this.stampGeneration = 0;
23
+ }
24
+ static { this.NO_PROJECTION_KEY = crypto.createHash('sha256').update('No Key').digest('hex').slice(0, 32); }
25
+ static andQueries(...queries) {
26
+ const list = queries.filter((q) => !SearchQueryUtils_1.SearchQueryUtils.isQueryEmpty(q));
27
+ if (list.length === 0) {
28
+ return null;
29
+ }
30
+ if (list.length === 1) {
31
+ return list[0];
32
+ }
33
+ return {
34
+ type: SearchQueryDTO_1.SearchQueryTypes.AND,
35
+ list
36
+ };
37
+ }
38
+ /**
39
+ * Creates the user that is used during a sharing session.
40
+ * It inherits the restrictions of the sharing creator.
41
+ */
42
+ createSharingUser(sharing) {
43
+ // without any of these, the sharing would show everything the creator can see
44
+ if (SearchQueryUtils_1.SearchQueryUtils.isQueryEmpty(sharing.searchQuery) && !sharing.directoryQuery) {
45
+ throw new Error('Invalid sharing: either searchQuery or directoryQuery needs to be set');
46
+ }
47
+ const creatorLists = this.getDirectoryListsForUser(sharing.creator);
48
+ return {
49
+ name: 'Guest',
50
+ role: UserDTO_1.UserRoles.LimitedGuest,
51
+ usedSharingKey: sharing.sharingKey,
52
+ overrideAllowBlockList: true,
53
+ allowQuery: SessionManager.andQueries(this.getMediaQueryForUser(sharing.creator), sharing.searchQuery ?? null),
54
+ allowDirectoryList: creatorLists.allow,
55
+ blockDirectoryList: creatorLists.block,
56
+ // directories that are available through the sharing, see getDirectoryAccessForUser
57
+ sharingDirectoryQuery: sharing.directoryQuery ?? null
58
+ };
59
+ }
60
+ /**
61
+ * Signature of the DB row a session is based on: the user, or the sharing (with its creator).
62
+ * Sessions are stored in the cookie, a session is only valid while its stamp is unchanged,
63
+ * so deleting or changing the user or sharing ends it. Null if the row does not exist or the sharing expired.
64
+ */
65
+ async getSessionStamp(user) {
66
+ const key = user.usedSharingKey ? 'sharing:' + user.usedSharingKey : 'user:' + user.id;
67
+ let entry = this.stamps.get(key);
68
+ if (!entry) {
69
+ const generation = this.stampGeneration;
70
+ const row = await this.loadSessionRow(user);
71
+ entry = {
72
+ stamp: row ? crypto.createHmac('sha256', Config_1.Config.Server.sessionSecret.join(''))
73
+ .update(JSON.stringify(row)).digest('hex') : null,
74
+ expires: row?.expires
75
+ };
76
+ // do not cache it if the row changed during the query
77
+ if (generation === this.stampGeneration) {
78
+ this.stamps.set(key, entry);
79
+ }
80
+ }
81
+ return entry.expires !== undefined && entry.expires < Date.now() ? null : entry.stamp;
82
+ }
83
+ /**
84
+ * Needs to be called after every user or sharing change.
85
+ */
86
+ invalidateSessionCache() {
87
+ this.stampGeneration++;
88
+ this.stamps.clear();
89
+ }
90
+ async loadSessionRow(user) {
91
+ const connection = await SQLConnection_1.SQLConnection.getConnection();
92
+ if (user.usedSharingKey) {
93
+ // not using SharingManager.findOne, that also deletes the expired sharings
94
+ return connection.getRepository(SharingEntity_1.SharingEntity)
95
+ .createQueryBuilder('share')
96
+ .leftJoinAndSelect('share.creator', 'creator')
97
+ .where('share.sharingKey = :sharingKey', { sharingKey: user.usedSharingKey })
98
+ .getOne();
99
+ }
100
+ if (typeof user.id !== 'number') {
101
+ return null;
102
+ }
103
+ return connection.getRepository(UserEntity_1.UserEntity).findOneBy({ id: user.id });
104
+ }
105
+ /**
106
+ * Returns with the final projection query (media and directory allow/block lists) of a sharing.
107
+ */
108
+ buildAllowListForSharing(sharing) {
109
+ return this.getQueryForUser(this.createSharingUser(sharing));
110
+ }
111
+ createProjectionKey(q) {
112
+ const canonical = SearchQueryUtils_1.SearchQueryUtils.stringifyForComparison(q);
113
+ // the projectionKey columns are 32 characters long
114
+ return crypto.createHash('sha256').update(canonical).digest('hex').slice(0, 32);
115
+ }
116
+ async buildContext(user) {
117
+ const context = new SessionContext_1.SessionContext();
118
+ context.user = Object.assign(user, { projectionKey: SessionManager.NO_PROJECTION_KEY });
119
+ const finalQuery = this.getQueryForUser(user);
120
+ if (finalQuery) {
121
+ const sm = ObjectManagers_1.ObjectManagers.getInstance().SearchManager;
122
+ // Build the Brackets-based query
123
+ context.projectionQuery = await sm.prepareAndBuildWhereQuery(finalQuery);
124
+ context.hasDirectoryProjection = sm.hasDirectoryQuery(finalQuery);
125
+ context.user.projectionKey = this.createProjectionKey(finalQuery);
126
+ if (SearchQueryUtils_1.SearchQueryUtils.isQueryEmpty(finalQuery)) {
127
+ Logger_1.Logger.silly(LOG_TAG, 'Empty Projection query.');
128
+ }
129
+ else {
130
+ Logger_1.Logger.silly(LOG_TAG, 'Projection query: ' + JSON.stringify(finalQuery));
131
+ }
132
+ }
133
+ const dirAccess = this.getDirectoryAccessForUser(user);
134
+ const access = {};
135
+ if (dirAccess.allowLists.length > 0) {
136
+ access.allowLists = dirAccess.allowLists;
137
+ access.allowQuery = await this.buildDirectoryFilter(SessionManager.andQueries(...dirAccess.allowLists.map(l => SearchQueryUtils_1.SearchQueryUtils.directoryListToQuery(l))), 'directory allow list');
138
+ }
139
+ if (user.usedSharingKey && !user.sharingDirectoryQuery) {
140
+ access.byPhotos = true;
141
+ }
142
+ if (dirAccess.blockList.length > 0) {
143
+ access.blockList = dirAccess.blockList;
144
+ const blockQuery = SearchQueryUtils_1.SearchQueryUtils.directoryListToQuery(dirAccess.blockList);
145
+ access.notBlockedQuery = await this.buildDirectoryFilter(blockQuery ? SearchQueryUtils_1.SearchQueryUtils.negate(blockQuery) : null, 'directory block list');
146
+ }
147
+ context.directoryAccess = new DirectoryAccess_1.DirectoryAccess(context, access);
148
+ return context;
149
+ }
150
+ async getAvailableUserSessions() {
151
+ // If authentication is not required, expose the unauthenticated session only
152
+ if (Config_1.Config.Users.authenticationRequired === false) {
153
+ const user = ObjectManagers_1.ObjectManagers.getInstance().UserManager.getUnAuthenticatedUser();
154
+ const ctx = await this.buildContext(user);
155
+ return [ctx];
156
+ }
157
+ // List all users and build a session context for each
158
+ const users = await ObjectManagers_1.ObjectManagers.getInstance().UserManager.find({});
159
+ const sessions = [];
160
+ for (const u of users) {
161
+ try {
162
+ const ctx = await this.buildContext(u);
163
+ sessions.push(ctx);
164
+ }
165
+ catch (e) {
166
+ // Log and continue on individual user context build failure to ensure we return other sessions
167
+ Logger_1.Logger.warn(LOG_TAG, 'Failed to build session context for user id=' + u?.id + ': ' + e?.message);
168
+ }
169
+ }
170
+ return sessions;
171
+ }
172
+ async buildDirectoryFilter(query, what) {
173
+ const sm = ObjectManagers_1.ObjectManagers.getInstance().SearchManager;
174
+ const directory = query ? await sm.prepareAndBuildWhereQuery(query, true) : null;
175
+ const directories = query ? await sm.prepareAndBuildWhereQuery(query, true, { directory: 'directories' }) : null;
176
+ // fail closed: a list that does not filter directories should not silently expose everything
177
+ if (!directory || !directories) {
178
+ throw new Error('Invalid ' + what + ': ' + JSON.stringify(query));
179
+ }
180
+ return { directory, directories };
181
+ }
182
+ /**
183
+ * Returns the media and the directory allow/block lists combined.
184
+ * Media that is in a not available directory is also not available.
185
+ */
186
+ getQueryForUser(user) {
187
+ const lists = this.getDirectoryListsForUser(user);
188
+ // directoryListToQuery throws on invalid entries.
189
+ // Fail closed: a misconfigured directory list should not silently expose everything
190
+ const block = SearchQueryUtils_1.SearchQueryUtils.directoryListToQuery(lists.block);
191
+ return SessionManager.andQueries(this.getMediaQueryForUser(user), SearchQueryUtils_1.SearchQueryUtils.directoryListToQuery(lists.allow), user.usedSharingKey ? SearchQueryUtils_1.SearchQueryUtils.directoryListToQuery(user.sharingDirectoryQuery ? [user.sharingDirectoryQuery] : []) : null, block ? SearchQueryUtils_1.SearchQueryUtils.negate(block) : null);
192
+ }
193
+ getMediaQueryForUser(user) {
194
+ const blockQuery = user.overrideAllowBlockList ? user.blockQuery : Config_1.Config.Users.blockQuery;
195
+ const allowQuery = user.overrideAllowBlockList ? user.allowQuery : Config_1.Config.Users.allowQuery;
196
+ return SessionManager.andQueries(allowQuery, blockQuery && !SearchQueryUtils_1.SearchQueryUtils.isQueryEmpty(blockQuery) ? SearchQueryUtils_1.SearchQueryUtils.negate(blockQuery) : null);
197
+ }
198
+ /**
199
+ * Returns the user's own lists if they are overridden, otherwise the global ones from the config.
200
+ */
201
+ getDirectoryListsForUser(user) {
202
+ // plain copies, so config objects do not end up in the session
203
+ const copy = (list) => (list || []).map(d => ({ type: d.type, value: d.value, matchType: d.matchType, negate: d.negate }));
204
+ return {
205
+ allow: copy(user.overrideAllowBlockList ? user.allowDirectoryList : Config_1.Config.Users.allowDirectoryList),
206
+ block: copy(user.overrideAllowBlockList ? user.blockDirectoryList : Config_1.Config.Users.blockDirectoryList)
207
+ };
208
+ }
209
+ /**
210
+ * A directory is available if it matches every allow list and none of the block list entries.
211
+ * The directory query of a sharing works as an extra allow list (on top of the creator's lists).
212
+ */
213
+ getDirectoryAccessForUser(user) {
214
+ const lists = this.getDirectoryListsForUser(user);
215
+ SearchQueryUtils_1.SearchQueryUtils.validateDirectoryList(lists.allow, 'Directory allow list');
216
+ SearchQueryUtils_1.SearchQueryUtils.validateDirectoryList(lists.block, 'Directory block list');
217
+ const allowLists = [];
218
+ if (lists.allow.length > 0) {
219
+ allowLists.push(lists.allow);
220
+ }
221
+ if (user.usedSharingKey && user.sharingDirectoryQuery) {
222
+ SearchQueryUtils_1.SearchQueryUtils.validateDirectorySearch(user.sharingDirectoryQuery, 'Sharing directory query');
223
+ allowLists.push([user.sharingDirectoryQuery]);
224
+ }
225
+ return { allowLists, blockList: lists.block };
226
+ }
227
+ }
228
+ exports.SessionManager = SessionManager;
@@ -1,13 +1,18 @@
1
- import { SharingDTO } from '../../../common/entities/SharingDTO';
1
+ import { UpdateSharingDTO } from '../../../common/entities/SharingDTO';
2
2
  import { SharingEntity } from './enitites/SharingEntity';
3
3
  import { UserDTO } from '../../../common/entities/UserDTO';
4
4
  import { SearchQueryDTO } from '../../../common/entities/SearchQueryDTO';
5
5
  export declare class SharingManager {
6
+ /**
7
+ * A sharing needs at least a media (searchQuery) or a directory (directoryQuery) restriction,
8
+ * otherwise it would show everything the creator can see.
9
+ */
10
+ private static validateQueries;
6
11
  private static removeExpiredLink;
7
12
  deleteSharing(sharingKey: string): Promise<void>;
8
- listAll(): Promise<SharingDTO[]>;
9
- listAllForQuery(query: SearchQueryDTO, user?: UserDTO): Promise<SharingDTO[]>;
10
- findOne(sharingKey: string): Promise<SharingEntity>;
11
- createSharing(sharing: SharingDTO): Promise<SharingDTO>;
12
- updateSharing(inSharing: SharingDTO, forceUpdate: boolean): Promise<SharingDTO>;
13
+ listAll(): Promise<SharingEntity[]>;
14
+ listAllForQuery(query: SearchQueryDTO, user?: UserDTO): Promise<SharingEntity[]>;
15
+ findOne(sharingKey: string): Promise<SharingEntity | null>;
16
+ createSharing(sharing: Omit<UpdateSharingDTO, 'id'>): Promise<SharingEntity>;
17
+ updateSharing(inSharing: UpdateSharingDTO, forceUpdate: boolean): Promise<SharingEntity>;
13
18
  }
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SharingManager = void 0;
4
+ const SQLConnection_1 = require("./SQLConnection");
5
+ const SharingEntity_1 = require("./enitites/SharingEntity");
6
+ const Config_1 = require("../../../common/config/private/Config");
7
+ const PasswordHelper_1 = require("../PasswordHelper");
8
+ const typeorm_1 = require("typeorm");
9
+ const SearchQueryUtils_1 = require("../../../common/SearchQueryUtils");
10
+ const ObjectManagers_1 = require("../ObjectManagers");
11
+ class SharingManager {
12
+ /**
13
+ * A sharing needs at least a media (searchQuery) or a directory (directoryQuery) restriction,
14
+ * otherwise it would show everything the creator can see.
15
+ */
16
+ static validateQueries(sharing) {
17
+ if (SearchQueryUtils_1.SearchQueryUtils.isQueryEmpty(sharing.searchQuery) && !sharing.directoryQuery) {
18
+ throw new Error('Invalid sharing: either searchQuery or directoryQuery needs to be set');
19
+ }
20
+ if (sharing.searchQuery) {
21
+ SearchQueryUtils_1.SearchQueryUtils.validateSearchQuery(sharing.searchQuery);
22
+ }
23
+ if (sharing.directoryQuery) {
24
+ SearchQueryUtils_1.SearchQueryUtils.validateDirectorySearch(sharing.directoryQuery, 'Sharing directoryQuery');
25
+ }
26
+ }
27
+ static async removeExpiredLink() {
28
+ const connection = await SQLConnection_1.SQLConnection.getConnection();
29
+ return await connection
30
+ .getRepository(SharingEntity_1.SharingEntity)
31
+ .createQueryBuilder('share')
32
+ .where('expires < :now', { now: Date.now() })
33
+ .delete()
34
+ .execute();
35
+ }
36
+ async deleteSharing(sharingKey) {
37
+ if (typeof sharingKey !== 'string' || sharingKey.length === 0) {
38
+ throw new Error('Invalid sharing key');
39
+ }
40
+ const connection = await SQLConnection_1.SQLConnection.getConnection();
41
+ const sharing = await connection
42
+ .getRepository(SharingEntity_1.SharingEntity)
43
+ .findOneBy({ sharingKey });
44
+ if (!sharing) {
45
+ throw new Error('Sharing not found');
46
+ }
47
+ await connection.getRepository(SharingEntity_1.SharingEntity).remove(sharing);
48
+ ObjectManagers_1.ObjectManagers.getInstance().SessionManager.invalidateSessionCache();
49
+ }
50
+ async listAll() {
51
+ await SharingManager.removeExpiredLink();
52
+ const connection = await SQLConnection_1.SQLConnection.getConnection();
53
+ return await connection
54
+ .getRepository(SharingEntity_1.SharingEntity)
55
+ .createQueryBuilder('share')
56
+ .leftJoinAndSelect('share.creator', 'creator')
57
+ .getMany();
58
+ }
59
+ async listAllForQuery(query, user) {
60
+ await SharingManager.removeExpiredLink();
61
+ const connection = await SQLConnection_1.SQLConnection.getConnection();
62
+ const q = connection
63
+ .getRepository(SharingEntity_1.SharingEntity)
64
+ .createQueryBuilder('share')
65
+ .leftJoinAndSelect('share.creator', 'creator')
66
+ // a sharing matches if either its media or its directory query is the given query
67
+ .where(new typeorm_1.Brackets(b => {
68
+ b.where('share.searchQuery = :query', { query: SearchQueryUtils_1.SearchQueryUtils.stringifyForComparison(query) })
69
+ .orWhere('share.directoryQuery = :query');
70
+ }));
71
+ if (user) {
72
+ q.andWhere('share.creator = :user', { user: user.id });
73
+ }
74
+ return await q.getMany();
75
+ }
76
+ async findOne(sharingKey) {
77
+ await SharingManager.removeExpiredLink();
78
+ const connection = await SQLConnection_1.SQLConnection.getConnection();
79
+ return await connection.getRepository(SharingEntity_1.SharingEntity)
80
+ .createQueryBuilder('share')
81
+ .leftJoinAndSelect('share.creator', 'creator')
82
+ .where('share.sharingKey = :sharingKey', { sharingKey })
83
+ .getOne();
84
+ }
85
+ async createSharing(sharing) {
86
+ await SharingManager.removeExpiredLink();
87
+ const connection = await SQLConnection_1.SQLConnection.getConnection();
88
+ if (sharing.password) {
89
+ sharing.password = PasswordHelper_1.PasswordHelper.cryptPassword(sharing.password);
90
+ }
91
+ if (sharing.searchQuery) {
92
+ sharing.searchQuery = SearchQueryUtils_1.SearchQueryUtils.sortQuery(sharing.searchQuery);
93
+ }
94
+ if (sharing.defaultDirectoryView && sharing.defaultSearchView) {
95
+ throw new Error('defaultDirectoryView and defaultSearchView cannot be set at the same time');
96
+ }
97
+ SharingManager.validateQueries(sharing);
98
+ if (sharing.directoryQuery) {
99
+ sharing.directoryQuery = SearchQueryUtils_1.SearchQueryUtils.sortQuery(sharing.directoryQuery);
100
+ }
101
+ if (sharing.defaultSearchView) {
102
+ SearchQueryUtils_1.SearchQueryUtils.validateSearchQuery(sharing.defaultSearchView);
103
+ sharing.defaultSearchView = SearchQueryUtils_1.SearchQueryUtils.sortQuery(sharing.defaultSearchView);
104
+ }
105
+ const ret = await connection.getRepository(SharingEntity_1.SharingEntity).save(sharing);
106
+ ObjectManagers_1.ObjectManagers.getInstance().SessionManager.invalidateSessionCache();
107
+ return ret;
108
+ }
109
+ async updateSharing(inSharing, forceUpdate) {
110
+ const creatorId = inSharing.creator?.id;
111
+ if (!Number.isInteger(inSharing.id) || creatorId === undefined || !Number.isInteger(creatorId)) {
112
+ throw new Error('Invalid sharing, id or creator is missing');
113
+ }
114
+ const connection = await SQLConnection_1.SQLConnection.getConnection();
115
+ // an Admin (forceUpdate) may update the sharing of anybody; it stays the sharing of its creator
116
+ const sharing = await connection.getRepository(SharingEntity_1.SharingEntity).findOneBy(forceUpdate === true
117
+ ? { id: inSharing.id }
118
+ : { id: inSharing.id, creator: { id: creatorId } });
119
+ if (!sharing) {
120
+ throw new Error('Sharing not found');
121
+ }
122
+ if (sharing.timeStamp < Date.now() - Config_1.Config.Sharing.updateTimeout &&
123
+ forceUpdate !== true) {
124
+ throw new Error('Sharing is locked, can\'t update anymore');
125
+ }
126
+ if (inSharing.defaultDirectoryView && inSharing.defaultSearchView) {
127
+ throw new Error('defaultDirectoryView and defaultSearchView cannot be set at the same time');
128
+ }
129
+ if (inSharing.password == null) {
130
+ sharing.password = null;
131
+ }
132
+ else {
133
+ sharing.password = PasswordHelper_1.PasswordHelper.cryptPassword(inSharing.password);
134
+ }
135
+ // allow updating searchQuery and directoryQuery and canonicalize them
136
+ SharingManager.validateQueries(inSharing);
137
+ sharing.searchQuery = inSharing.searchQuery ? SearchQueryUtils_1.SearchQueryUtils.sortQuery(inSharing.searchQuery) : null;
138
+ sharing.directoryQuery = inSharing.directoryQuery ? SearchQueryUtils_1.SearchQueryUtils.sortQuery(inSharing.directoryQuery) : null;
139
+ if (inSharing.defaultSearchView) {
140
+ SearchQueryUtils_1.SearchQueryUtils.validateSearchQuery(inSharing.defaultSearchView);
141
+ sharing.defaultSearchView = SearchQueryUtils_1.SearchQueryUtils.sortQuery(inSharing.defaultSearchView);
142
+ sharing.defaultDirectoryView = null;
143
+ }
144
+ else if (inSharing.defaultSearchView === null) {
145
+ sharing.defaultSearchView = null;
146
+ }
147
+ if (inSharing.defaultDirectoryView) {
148
+ sharing.defaultDirectoryView = inSharing.defaultDirectoryView;
149
+ sharing.defaultSearchView = null;
150
+ }
151
+ else if (inSharing.defaultDirectoryView === null) {
152
+ sharing.defaultDirectoryView = null;
153
+ }
154
+ sharing.expires = inSharing.expires;
155
+ const ret = await connection.getRepository(SharingEntity_1.SharingEntity).save(sharing);
156
+ ObjectManagers_1.ObjectManagers.getInstance().SessionManager.invalidateSessionCache();
157
+ return ret;
158
+ }
159
+ }
160
+ exports.SharingManager = SharingManager;
@@ -3,11 +3,18 @@ import { UserEntity } from './enitites/UserEntity';
3
3
  import { FindOptionsWhere } from 'typeorm';
4
4
  import { UserSettingsDTO } from '../../../common/entities/UserSettingsDTO';
5
5
  export declare class UserManager {
6
- findOne(filter: FindOptionsWhere<UserEntity>): Promise<UserEntity>;
6
+ /**
7
+ * A missing value would otherwise match any user (e.g.: the admin).
8
+ * Use IsNull() if NULL is really meant.
9
+ */
10
+ private static validateFilter;
11
+ private static validateId;
12
+ findOne(filter: FindOptionsWhere<UserEntity>): Promise<UserEntity | null>;
7
13
  find(filter: FindOptionsWhere<UserDTO>): Promise<UserEntity[]>;
8
14
  createUser(user: UserDTO): Promise<UserEntity>;
9
15
  deleteUser(id: number): Promise<UserEntity>;
10
16
  changeRole(id: number, newRole: UserRoles): Promise<UserEntity>;
17
+ setOidcSubject(id: number, oidcSubject: string | null): Promise<UserEntity>;
11
18
  updateSettings(id: number, settings: UserSettingsDTO): Promise<UserEntity>;
12
19
  getUnAuthenticatedUser(): UserDTO;
13
20
  }
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserManager = void 0;
4
+ const UserDTO_1 = require("../../../common/entities/UserDTO");
5
+ const UserEntity_1 = require("./enitites/UserEntity");
6
+ const SQLConnection_1 = require("./SQLConnection");
7
+ const PasswordHelper_1 = require("../PasswordHelper");
8
+ const SearchQueryUtils_1 = require("../../../common/SearchQueryUtils");
9
+ const Config_1 = require("../../../common/config/private/Config");
10
+ const ObjectManagers_1 = require("../ObjectManagers");
11
+ class UserManager {
12
+ /**
13
+ * A missing value would otherwise match any user (e.g.: the admin).
14
+ * Use IsNull() if NULL is really meant.
15
+ */
16
+ static validateFilter(filter) {
17
+ const missing = Object.keys(filter).filter(k => filter[k] === undefined ||
18
+ filter[k] === null);
19
+ if (missing.length > 0) {
20
+ throw new Error('Invalid user filter, missing value for: ' + missing.join(', '));
21
+ }
22
+ }
23
+ static validateId(id) {
24
+ if (!Number.isInteger(id)) {
25
+ throw new Error('Invalid user id: ' + id);
26
+ }
27
+ }
28
+ async findOne(filter) {
29
+ const connection = await SQLConnection_1.SQLConnection.getConnection();
30
+ const verifyPassword = typeof filter.password == 'string';
31
+ const pass = filter.password;
32
+ delete filter.password;
33
+ UserManager.validateFilter(filter);
34
+ if (Object.keys(filter).length === 0) {
35
+ throw new Error('Invalid user filter, it is empty');
36
+ }
37
+ const user = await connection.getRepository(UserEntity_1.UserEntity).findOneBy(filter);
38
+ if (verifyPassword && (!user || !PasswordHelper_1.PasswordHelper.comparePassword(pass, user.password))) {
39
+ throw new Error('No entry found');
40
+ }
41
+ return user;
42
+ }
43
+ async find(filter) {
44
+ UserManager.validateFilter(filter);
45
+ const connection = await SQLConnection_1.SQLConnection.getConnection();
46
+ return await connection.getRepository(UserEntity_1.UserEntity).findBy(filter);
47
+ }
48
+ async createUser(user) {
49
+ const connection = await SQLConnection_1.SQLConnection.getConnection();
50
+ // Validate search queries if provided
51
+ if (user.allowQuery) {
52
+ SearchQueryUtils_1.SearchQueryUtils.validateSearchQuery(user.allowQuery, 'User allowQuery');
53
+ }
54
+ if (user.blockQuery) {
55
+ SearchQueryUtils_1.SearchQueryUtils.validateSearchQuery(user.blockQuery, 'User blockQuery');
56
+ }
57
+ SearchQueryUtils_1.SearchQueryUtils.validateDirectoryList(user.allowDirectoryList, 'User allowDirectoryList');
58
+ SearchQueryUtils_1.SearchQueryUtils.validateDirectoryList(user.blockDirectoryList, 'User blockDirectoryList');
59
+ if (!user.password) {
60
+ throw new Error('Password is required');
61
+ }
62
+ user.password = PasswordHelper_1.PasswordHelper.cryptPassword(user.password);
63
+ const ret = await connection.getRepository(UserEntity_1.UserEntity).save(user);
64
+ ObjectManagers_1.ObjectManagers.getInstance().SessionManager.invalidateSessionCache();
65
+ return ret;
66
+ }
67
+ async deleteUser(id) {
68
+ UserManager.validateId(id);
69
+ const connection = await SQLConnection_1.SQLConnection.getConnection();
70
+ const user = await connection.getRepository(UserEntity_1.UserEntity).findOneBy({ id });
71
+ if (!user) {
72
+ throw new Error('User not found');
73
+ }
74
+ const ret = await connection.getRepository(UserEntity_1.UserEntity).remove(user);
75
+ // ends the sessions of the user and of its sharings
76
+ ObjectManagers_1.ObjectManagers.getInstance().SessionManager.invalidateSessionCache();
77
+ return ret;
78
+ }
79
+ async changeRole(id, newRole) {
80
+ UserManager.validateId(id);
81
+ const connection = await SQLConnection_1.SQLConnection.getConnection();
82
+ const userRepository = connection.getRepository(UserEntity_1.UserEntity);
83
+ const user = await userRepository.findOneBy({ id });
84
+ if (!user) {
85
+ throw new Error('User not found');
86
+ }
87
+ user.role = newRole;
88
+ const ret = await userRepository.save(user);
89
+ ObjectManagers_1.ObjectManagers.getInstance().SessionManager.invalidateSessionCache();
90
+ return ret;
91
+ }
92
+ async setOidcSubject(id, oidcSubject) {
93
+ UserManager.validateId(id);
94
+ const connection = await SQLConnection_1.SQLConnection.getConnection();
95
+ const userRepository = connection.getRepository(UserEntity_1.UserEntity);
96
+ const user = await userRepository.findOneBy({ id });
97
+ if (!user) {
98
+ throw new Error('User not found');
99
+ }
100
+ user.oidcSubject = oidcSubject;
101
+ return userRepository.save(user);
102
+ }
103
+ async updateSettings(id, settings) {
104
+ UserManager.validateId(id);
105
+ const connection = await SQLConnection_1.SQLConnection.getConnection();
106
+ const userRepository = connection.getRepository(UserEntity_1.UserEntity);
107
+ const user = await userRepository.findOneBy({ id });
108
+ if (!user) {
109
+ throw new Error('User not found');
110
+ }
111
+ if (typeof settings.overrideAllowBlockList !== 'undefined') {
112
+ user.overrideAllowBlockList = settings.overrideAllowBlockList;
113
+ }
114
+ if (typeof settings.allowQuery !== 'undefined') {
115
+ if (settings.allowQuery) {
116
+ SearchQueryUtils_1.SearchQueryUtils.validateSearchQuery(settings.allowQuery, 'User allowQuery');
117
+ }
118
+ user.allowQuery = settings.allowQuery ?? null;
119
+ }
120
+ if (typeof settings.blockQuery !== 'undefined') {
121
+ if (settings.blockQuery) {
122
+ SearchQueryUtils_1.SearchQueryUtils.validateSearchQuery(settings.blockQuery, 'User blockQuery');
123
+ }
124
+ user.blockQuery = settings.blockQuery ?? null;
125
+ }
126
+ if (typeof settings.allowDirectoryList !== 'undefined') {
127
+ SearchQueryUtils_1.SearchQueryUtils.validateDirectoryList(settings.allowDirectoryList, 'User allowDirectoryList');
128
+ user.allowDirectoryList = settings.allowDirectoryList ?? null;
129
+ }
130
+ if (typeof settings.blockDirectoryList !== 'undefined') {
131
+ SearchQueryUtils_1.SearchQueryUtils.validateDirectoryList(settings.blockDirectoryList, 'User blockDirectoryList');
132
+ user.blockDirectoryList = settings.blockDirectoryList ?? null;
133
+ }
134
+ if (settings.newPassword && settings.newPassword.length > 0) {
135
+ user.password = PasswordHelper_1.PasswordHelper.cryptPassword(settings.newPassword);
136
+ }
137
+ const ret = await userRepository.save(user);
138
+ ObjectManagers_1.ObjectManagers.getInstance().SessionManager.invalidateSessionCache();
139
+ return ret;
140
+ }
141
+ getUnAuthenticatedUser() {
142
+ return {
143
+ name: UserDTO_1.UserRoles[Config_1.Config.Users.unAuthenticatedUserRole],
144
+ role: Config_1.Config.Users.unAuthenticatedUserRole,
145
+ };
146
+ }
147
+ }
148
+ exports.UserManager = UserManager;