@brightchain/brightchain-api-lib 0.23.25 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (438) hide show
  1. package/package.json +5 -5
  2. package/src/lib/__tests__/fixtures/mock-backend-brightchain-member.d.ts.map +1 -1
  3. package/src/lib/__tests__/fixtures/mock-backend-brightchain-member.js +11 -0
  4. package/src/lib/__tests__/fixtures/mock-backend-brightchain-member.js.map +1 -1
  5. package/src/lib/__tests__/fixtures/mocked-model.js +63 -60
  6. package/src/lib/__tests__/fixtures/mocked-model.js.map +1 -1
  7. package/src/lib/application.d.ts +1 -1
  8. package/src/lib/application.d.ts.map +1 -1
  9. package/src/lib/application.js +103 -34
  10. package/src/lib/application.js.map +1 -1
  11. package/src/lib/auth/aclEnforcedAvailability.js +4 -0
  12. package/src/lib/auth/aclEnforcedAvailability.js.map +1 -1
  13. package/src/lib/auth/aclEnforcedBlockStore.js +7 -0
  14. package/src/lib/auth/aclEnforcedBlockStore.js.map +1 -1
  15. package/src/lib/auth/ecdsaNodeAuthenticator.js +1 -0
  16. package/src/lib/auth/ecdsaNodeAuthenticator.js.map +1 -1
  17. package/src/lib/auth/poolAclBootstrap.js +2 -0
  18. package/src/lib/auth/poolAclBootstrap.js.map +1 -1
  19. package/src/lib/auth/poolAclStore.js +2 -1
  20. package/src/lib/auth/poolAclStore.js.map +1 -1
  21. package/src/lib/auth/poolAclUpdater.js +4 -0
  22. package/src/lib/auth/poolAclUpdater.js.map +1 -1
  23. package/src/lib/availability/availabilityMetrics.js +43 -45
  24. package/src/lib/availability/availabilityMetrics.js.map +1 -1
  25. package/src/lib/availability/availabilityService.js +26 -20
  26. package/src/lib/availability/availabilityService.js.map +1 -1
  27. package/src/lib/availability/blockRegistry.js +46 -25
  28. package/src/lib/availability/blockRegistry.js.map +1 -1
  29. package/src/lib/availability/discoveryProtocol.js +10 -8
  30. package/src/lib/availability/discoveryProtocol.js.map +1 -1
  31. package/src/lib/availability/gossipService.js +56 -45
  32. package/src/lib/availability/gossipService.js.map +1 -1
  33. package/src/lib/availability/heartbeatMonitor.js +22 -20
  34. package/src/lib/availability/heartbeatMonitor.js.map +1 -1
  35. package/src/lib/availability/poolDiscoveryService.js +7 -1
  36. package/src/lib/availability/poolDiscoveryService.js.map +1 -1
  37. package/src/lib/availability/quorumGossipHandler.js +13 -6
  38. package/src/lib/availability/quorumGossipHandler.js.map +1 -1
  39. package/src/lib/availability/reconciliationService.js +18 -12
  40. package/src/lib/availability/reconciliationService.js.map +1 -1
  41. package/src/lib/blockFetch/blockFetcher.js +14 -8
  42. package/src/lib/blockFetch/blockFetcher.js.map +1 -1
  43. package/src/lib/blockFetch/fetchQueue.js +9 -7
  44. package/src/lib/blockFetch/fetchQueue.js.map +1 -1
  45. package/src/lib/blockFetch/httpBlockFetchTransport.js +2 -0
  46. package/src/lib/blockFetch/httpBlockFetchTransport.js.map +1 -1
  47. package/src/lib/browserKeyring.js +5 -2
  48. package/src/lib/browserKeyring.js.map +1 -1
  49. package/src/lib/controllers/api/blocks.d.ts.map +1 -1
  50. package/src/lib/controllers/api/blocks.js +9 -3
  51. package/src/lib/controllers/api/blocks.js.map +1 -1
  52. package/src/lib/controllers/api/brighthub/connectionController.d.ts +80 -0
  53. package/src/lib/controllers/api/brighthub/connectionController.d.ts.map +1 -0
  54. package/src/lib/controllers/api/brighthub/connectionController.js +890 -0
  55. package/src/lib/controllers/api/brighthub/connectionController.js.map +1 -0
  56. package/src/lib/controllers/api/brighthub/index.d.ts +9 -0
  57. package/src/lib/controllers/api/brighthub/index.d.ts.map +1 -0
  58. package/src/lib/controllers/api/brighthub/index.js +12 -0
  59. package/src/lib/controllers/api/brighthub/index.js.map +1 -0
  60. package/src/lib/controllers/api/brighthub/messagingController.d.ts +84 -0
  61. package/src/lib/controllers/api/brighthub/messagingController.d.ts.map +1 -0
  62. package/src/lib/controllers/api/brighthub/messagingController.js +1077 -0
  63. package/src/lib/controllers/api/brighthub/messagingController.js.map +1 -0
  64. package/src/lib/controllers/api/brighthub/notificationController.d.ts +89 -0
  65. package/src/lib/controllers/api/brighthub/notificationController.d.ts.map +1 -0
  66. package/src/lib/controllers/api/brighthub/notificationController.js +444 -0
  67. package/src/lib/controllers/api/brighthub/notificationController.js.map +1 -0
  68. package/src/lib/controllers/api/brighthub/postController.d.ts +75 -0
  69. package/src/lib/controllers/api/brighthub/postController.d.ts.map +1 -0
  70. package/src/lib/controllers/api/brighthub/postController.js +388 -0
  71. package/src/lib/controllers/api/brighthub/postController.js.map +1 -0
  72. package/src/lib/controllers/api/brighthub/timelineController.d.ts +74 -0
  73. package/src/lib/controllers/api/brighthub/timelineController.d.ts.map +1 -0
  74. package/src/lib/controllers/api/brighthub/timelineController.js +418 -0
  75. package/src/lib/controllers/api/brighthub/timelineController.js.map +1 -0
  76. package/src/lib/controllers/api/brightpass.d.ts.map +1 -1
  77. package/src/lib/controllers/api/brightpass.js +46 -4
  78. package/src/lib/controllers/api/brightpass.js.map +1 -1
  79. package/src/lib/controllers/api/cbl.js +1 -0
  80. package/src/lib/controllers/api/cbl.js.map +1 -1
  81. package/src/lib/controllers/api/channels.js +2 -2
  82. package/src/lib/controllers/api/channels.js.map +1 -1
  83. package/src/lib/controllers/api/conversations.js +1 -1
  84. package/src/lib/controllers/api/conversations.js.map +1 -1
  85. package/src/lib/controllers/api/docs.js +2 -1
  86. package/src/lib/controllers/api/docs.js.map +1 -1
  87. package/src/lib/controllers/api/emails.d.ts.map +1 -1
  88. package/src/lib/controllers/api/emails.js +16 -2
  89. package/src/lib/controllers/api/emails.js.map +1 -1
  90. package/src/lib/controllers/api/explodingMessages.js +2 -4
  91. package/src/lib/controllers/api/explodingMessages.js.map +1 -1
  92. package/src/lib/controllers/api/groups.js +2 -2
  93. package/src/lib/controllers/api/groups.js.map +1 -1
  94. package/src/lib/controllers/api/health.d.ts +9 -2
  95. package/src/lib/controllers/api/health.d.ts.map +1 -1
  96. package/src/lib/controllers/api/health.js +48 -6
  97. package/src/lib/controllers/api/health.js.map +1 -1
  98. package/src/lib/controllers/api/index.d.ts +1 -0
  99. package/src/lib/controllers/api/index.d.ts.map +1 -1
  100. package/src/lib/controllers/api/index.js +1 -0
  101. package/src/lib/controllers/api/index.js.map +1 -1
  102. package/src/lib/controllers/api/introspection.js +2 -0
  103. package/src/lib/controllers/api/introspection.js.map +1 -1
  104. package/src/lib/controllers/api/messages.js +1 -1
  105. package/src/lib/controllers/api/messages.js.map +1 -1
  106. package/src/lib/controllers/api/nodes.js +6 -6
  107. package/src/lib/controllers/api/nodes.js.map +1 -1
  108. package/src/lib/controllers/api/quorum.d.ts +1 -1
  109. package/src/lib/controllers/api/quorum.d.ts.map +1 -1
  110. package/src/lib/controllers/api/quorum.js +3 -2
  111. package/src/lib/controllers/api/quorum.js.map +1 -1
  112. package/src/lib/controllers/api/scbl.js +3 -0
  113. package/src/lib/controllers/api/scbl.js.map +1 -1
  114. package/src/lib/controllers/api/sessions.d.ts +18 -2
  115. package/src/lib/controllers/api/sessions.d.ts.map +1 -1
  116. package/src/lib/controllers/api/sessions.js +60 -3
  117. package/src/lib/controllers/api/sessions.js.map +1 -1
  118. package/src/lib/controllers/api/sync.js +4 -4
  119. package/src/lib/controllers/api/sync.js.map +1 -1
  120. package/src/lib/controllers/api/user.d.ts +2 -0
  121. package/src/lib/controllers/api/user.d.ts.map +1 -1
  122. package/src/lib/controllers/api/user.js +95 -3
  123. package/src/lib/controllers/api/user.js.map +1 -1
  124. package/src/lib/controllers/identity/deviceController.js +2 -2
  125. package/src/lib/controllers/identity/deviceController.js.map +1 -1
  126. package/src/lib/controllers/identity/directoryController.js +1 -1
  127. package/src/lib/controllers/identity/directoryController.js.map +1 -1
  128. package/src/lib/controllers/identity/identityProofController.js +4 -6
  129. package/src/lib/controllers/identity/identityProofController.js.map +1 -1
  130. package/src/lib/databaseInit.d.ts +3 -3
  131. package/src/lib/databaseInit.js +5 -5
  132. package/src/lib/databaseInit.js.map +1 -1
  133. package/src/lib/datastore/block-document-store.d.ts.map +1 -1
  134. package/src/lib/datastore/block-document-store.js +18 -6
  135. package/src/lib/datastore/block-document-store.js.map +1 -1
  136. package/src/lib/datastore/document-store.d.ts.map +1 -1
  137. package/src/lib/datastore/memory-document-store.js +5 -2
  138. package/src/lib/datastore/memory-document-store.js.map +1 -1
  139. package/src/lib/encryption/encryptedMetadataService.js +2 -0
  140. package/src/lib/encryption/encryptedMetadataService.js.map +1 -1
  141. package/src/lib/encryption/encryptionAwareReplication.js +3 -0
  142. package/src/lib/encryption/encryptionAwareReplication.js.map +1 -1
  143. package/src/lib/encryption/errors.d.ts.map +1 -1
  144. package/src/lib/encryption/errors.js +8 -0
  145. package/src/lib/encryption/errors.js.map +1 -1
  146. package/src/lib/encryption/poolKeyManager.js +2 -0
  147. package/src/lib/encryption/poolKeyManager.js.map +1 -1
  148. package/src/lib/environment.js +10 -0
  149. package/src/lib/environment.js.map +1 -1
  150. package/src/lib/errors/express-validation.js +1 -0
  151. package/src/lib/errors/express-validation.js.map +1 -1
  152. package/src/lib/errors/invalid-backup-code-version.js +1 -0
  153. package/src/lib/errors/invalid-backup-code-version.js.map +1 -1
  154. package/src/lib/errors/memberIndexSchemaValidationError.js +1 -0
  155. package/src/lib/errors/memberIndexSchemaValidationError.js.map +1 -1
  156. package/src/lib/errors/missing-validated-data.js +2 -0
  157. package/src/lib/errors/missing-validated-data.js.map +1 -1
  158. package/src/lib/errors/token-not-found.js +1 -0
  159. package/src/lib/errors/token-not-found.js.map +1 -1
  160. package/src/lib/errors/typed-error-local.js +3 -0
  161. package/src/lib/errors/typed-error-local.js.map +1 -1
  162. package/src/lib/interfaces/brightpass/index.d.ts +1 -1
  163. package/src/lib/interfaces/brightpass/index.d.ts.map +1 -1
  164. package/src/lib/interfaces/environment.d.ts +1 -1
  165. package/src/lib/interfaces/environment.d.ts.map +1 -1
  166. package/src/lib/interfaces/member/memberProfileResponse.d.ts.map +1 -1
  167. package/src/lib/interfaces/member/operational.d.ts.map +1 -1
  168. package/src/lib/interfaces/member-init-config.d.ts +1 -1
  169. package/src/lib/interfaces/member-init-config.d.ts.map +1 -1
  170. package/src/lib/interfaces/responses/api-backup-codes-response.d.ts.map +1 -1
  171. package/src/lib/interfaces/responses/api-challenge-response.d.ts.map +1 -1
  172. package/src/lib/interfaces/responses/api-code-count-response.d.ts.map +1 -1
  173. package/src/lib/interfaces/responses/api-detailed-health-response.d.ts.map +1 -1
  174. package/src/lib/interfaces/responses/api-discover-block-response.d.ts.map +1 -1
  175. package/src/lib/interfaces/responses/api-express-validation-error.d.ts.map +1 -1
  176. package/src/lib/interfaces/responses/api-get-block-response.d.ts.map +1 -1
  177. package/src/lib/interfaces/responses/api-get-node-response.d.ts.map +1 -1
  178. package/src/lib/interfaces/responses/api-health-response.d.ts.map +1 -1
  179. package/src/lib/interfaces/responses/api-list-nodes-response.d.ts.map +1 -1
  180. package/src/lib/interfaces/responses/api-login-response.d.ts.map +1 -1
  181. package/src/lib/interfaces/responses/api-members-response.d.ts.map +1 -1
  182. package/src/lib/interfaces/responses/api-mnemonic-response.d.ts.map +1 -1
  183. package/src/lib/interfaces/responses/api-reconcile-response.d.ts.map +1 -1
  184. package/src/lib/interfaces/responses/api-register-node-response.d.ts.map +1 -1
  185. package/src/lib/interfaces/responses/api-registration-response.d.ts.map +1 -1
  186. package/src/lib/interfaces/responses/api-replicate-block-response.d.ts.map +1 -1
  187. package/src/lib/interfaces/responses/api-request-user-response.d.ts.map +1 -1
  188. package/src/lib/interfaces/responses/api-store-block-response.d.ts.map +1 -1
  189. package/src/lib/interfaces/responses/api-store-cbl-response.d.ts.map +1 -1
  190. package/src/lib/interfaces/responses/api-sync-request-response.d.ts.map +1 -1
  191. package/src/lib/interfaces/responses/brighthub/api-connection-response.d.ts +21 -0
  192. package/src/lib/interfaces/responses/brighthub/api-connection-response.d.ts.map +1 -0
  193. package/src/lib/interfaces/responses/brighthub/api-connection-response.js +3 -0
  194. package/src/lib/interfaces/responses/brighthub/api-connection-response.js.map +1 -0
  195. package/src/lib/interfaces/responses/brighthub/api-messaging-response.d.ts +39 -0
  196. package/src/lib/interfaces/responses/brighthub/api-messaging-response.d.ts.map +1 -0
  197. package/src/lib/interfaces/responses/brighthub/api-messaging-response.js +3 -0
  198. package/src/lib/interfaces/responses/brighthub/api-messaging-response.js.map +1 -0
  199. package/src/lib/interfaces/responses/brighthub/api-notification-response.d.ts +30 -0
  200. package/src/lib/interfaces/responses/brighthub/api-notification-response.d.ts.map +1 -0
  201. package/src/lib/interfaces/responses/brighthub/api-notification-response.js +3 -0
  202. package/src/lib/interfaces/responses/brighthub/api-notification-response.js.map +1 -0
  203. package/src/lib/interfaces/responses/brighthub/api-post-response.d.ts +21 -0
  204. package/src/lib/interfaces/responses/brighthub/api-post-response.d.ts.map +1 -0
  205. package/src/lib/interfaces/responses/brighthub/api-post-response.js +3 -0
  206. package/src/lib/interfaces/responses/brighthub/api-post-response.js.map +1 -0
  207. package/src/lib/interfaces/responses/brighthub/api-timeline-response.d.ts +14 -0
  208. package/src/lib/interfaces/responses/brighthub/api-timeline-response.d.ts.map +1 -0
  209. package/src/lib/interfaces/responses/brighthub/api-timeline-response.js +3 -0
  210. package/src/lib/interfaces/responses/brighthub/api-timeline-response.js.map +1 -0
  211. package/src/lib/interfaces/responses/brighthub/api-user-profile-response.d.ts +10 -0
  212. package/src/lib/interfaces/responses/brighthub/api-user-profile-response.d.ts.map +1 -0
  213. package/src/lib/interfaces/responses/brighthub/api-user-profile-response.js +3 -0
  214. package/src/lib/interfaces/responses/brighthub/api-user-profile-response.js.map +1 -0
  215. package/src/lib/interfaces/responses/brighthub/index.d.ts +13 -0
  216. package/src/lib/interfaces/responses/brighthub/index.d.ts.map +1 -0
  217. package/src/lib/interfaces/responses/brighthub/index.js +9 -0
  218. package/src/lib/interfaces/responses/brighthub/index.js.map +1 -0
  219. package/src/lib/interfaces/responses/index.d.ts +1 -0
  220. package/src/lib/interfaces/responses/index.d.ts.map +1 -1
  221. package/src/lib/interfaces/storage/storedDocumentTypes.d.ts +1 -1
  222. package/src/lib/interfaces/storage/storedDocumentTypes.js +1 -1
  223. package/src/lib/interfaces/storage/userRoleSchema.d.ts.map +1 -1
  224. package/src/lib/interfaces/storage/userRoleSchema.js +1 -3
  225. package/src/lib/interfaces/storage/userRoleSchema.js.map +1 -1
  226. package/src/lib/middlewares.js +31 -31
  227. package/src/lib/middlewares.js.map +1 -1
  228. package/src/lib/nodeKeyring.js +2 -0
  229. package/src/lib/nodeKeyring.js.map +1 -1
  230. package/src/lib/plugins/brightchain-database-plugin.d.ts +14 -14
  231. package/src/lib/plugins/brightchain-database-plugin.d.ts.map +1 -1
  232. package/src/lib/plugins/brightchain-database-plugin.js +36 -34
  233. package/src/lib/plugins/brightchain-database-plugin.js.map +1 -1
  234. package/src/lib/routers/api.d.ts +62 -1
  235. package/src/lib/routers/api.d.ts.map +1 -1
  236. package/src/lib/routers/api.js +123 -2
  237. package/src/lib/routers/api.js.map +1 -1
  238. package/src/lib/routers/app.d.ts.map +1 -1
  239. package/src/lib/routers/app.js +10 -1
  240. package/src/lib/routers/app.js.map +1 -1
  241. package/src/lib/routers/base.js +2 -0
  242. package/src/lib/routers/base.js.map +1 -1
  243. package/src/lib/secureEnclaveKeyring.js +4 -2
  244. package/src/lib/secureEnclaveKeyring.js.map +1 -1
  245. package/src/lib/services/auth.d.ts.map +1 -1
  246. package/src/lib/services/auth.js +11 -2
  247. package/src/lib/services/auth.js.map +1 -1
  248. package/src/lib/services/base.js +1 -0
  249. package/src/lib/services/base.js.map +1 -1
  250. package/src/lib/services/blockServiceFactory.js +2 -0
  251. package/src/lib/services/blockServiceFactory.js.map +1 -1
  252. package/src/lib/services/blockStore.js +3 -2
  253. package/src/lib/services/blockStore.js.map +1 -1
  254. package/src/lib/services/blocks.js +1 -0
  255. package/src/lib/services/blocks.js.map +1 -1
  256. package/src/lib/services/brightChainBackupCodeService.d.ts +114 -0
  257. package/src/lib/services/brightChainBackupCodeService.d.ts.map +1 -0
  258. package/src/lib/services/brightChainBackupCodeService.js +303 -0
  259. package/src/lib/services/brightChainBackupCodeService.js.map +1 -0
  260. package/src/lib/services/brightchain-authentication-provider.d.ts.map +1 -1
  261. package/src/lib/services/brightchain-authentication-provider.js +40 -9
  262. package/src/lib/services/brightchain-authentication-provider.js.map +1 -1
  263. package/src/lib/services/brightchain-member-init.service.d.ts +17 -17
  264. package/src/lib/services/brightchain-member-init.service.d.ts.map +1 -1
  265. package/src/lib/services/brightchain-member-init.service.js +12 -9
  266. package/src/lib/services/brightchain-member-init.service.js.map +1 -1
  267. package/src/lib/services/brighthub/connectionService.d.ts +286 -0
  268. package/src/lib/services/brighthub/connectionService.d.ts.map +1 -0
  269. package/src/lib/services/brighthub/connectionService.js +1887 -0
  270. package/src/lib/services/brighthub/connectionService.js.map +1 -0
  271. package/src/lib/services/brighthub/discoveryService.d.ts +110 -0
  272. package/src/lib/services/brighthub/discoveryService.d.ts.map +1 -0
  273. package/src/lib/services/brighthub/discoveryService.js +528 -0
  274. package/src/lib/services/brighthub/discoveryService.js.map +1 -0
  275. package/src/lib/services/brighthub/feedService.d.ts +141 -0
  276. package/src/lib/services/brighthub/feedService.d.ts.map +1 -0
  277. package/src/lib/services/brighthub/feedService.js +418 -0
  278. package/src/lib/services/brighthub/feedService.js.map +1 -0
  279. package/src/lib/services/brighthub/index.d.ts +11 -0
  280. package/src/lib/services/brighthub/index.d.ts.map +1 -0
  281. package/src/lib/services/brighthub/index.js +14 -0
  282. package/src/lib/services/brighthub/index.js.map +1 -0
  283. package/src/lib/services/brighthub/messagingService.d.ts +109 -0
  284. package/src/lib/services/brighthub/messagingService.d.ts.map +1 -0
  285. package/src/lib/services/brighthub/messagingService.js +947 -0
  286. package/src/lib/services/brighthub/messagingService.js.map +1 -0
  287. package/src/lib/services/brighthub/messagingService.test-helpers.d.ts +75 -0
  288. package/src/lib/services/brighthub/messagingService.test-helpers.d.ts.map +1 -0
  289. package/src/lib/services/brighthub/messagingService.test-helpers.js +237 -0
  290. package/src/lib/services/brighthub/messagingService.test-helpers.js.map +1 -0
  291. package/src/lib/services/brighthub/notificationService.d.ts +172 -0
  292. package/src/lib/services/brighthub/notificationService.d.ts.map +1 -0
  293. package/src/lib/services/brighthub/notificationService.js +768 -0
  294. package/src/lib/services/brighthub/notificationService.js.map +1 -0
  295. package/src/lib/services/brighthub/notificationService.test-helpers.d.ts +75 -0
  296. package/src/lib/services/brighthub/notificationService.test-helpers.d.ts.map +1 -0
  297. package/src/lib/services/brighthub/notificationService.test-helpers.js +230 -0
  298. package/src/lib/services/brighthub/notificationService.test-helpers.js.map +1 -0
  299. package/src/lib/services/brighthub/postService.d.ts +129 -0
  300. package/src/lib/services/brighthub/postService.d.ts.map +1 -0
  301. package/src/lib/services/brighthub/postService.js +470 -0
  302. package/src/lib/services/brighthub/postService.js.map +1 -0
  303. package/src/lib/services/brighthub/postService.test-helpers.d.ts +40 -0
  304. package/src/lib/services/brighthub/postService.test-helpers.d.ts.map +1 -0
  305. package/src/lib/services/brighthub/postService.test-helpers.js +84 -0
  306. package/src/lib/services/brighthub/postService.test-helpers.js.map +1 -0
  307. package/src/lib/services/brighthub/textFormatter.d.ts +64 -0
  308. package/src/lib/services/brighthub/textFormatter.d.ts.map +1 -0
  309. package/src/lib/services/brighthub/textFormatter.js +256 -0
  310. package/src/lib/services/brighthub/textFormatter.js.map +1 -0
  311. package/src/lib/services/brighthub/threadService.d.ts +79 -0
  312. package/src/lib/services/brighthub/threadService.d.ts.map +1 -0
  313. package/src/lib/services/brighthub/threadService.js +246 -0
  314. package/src/lib/services/brighthub/threadService.js.map +1 -0
  315. package/src/lib/services/brighthub/userProfileService.d.ts +203 -0
  316. package/src/lib/services/brighthub/userProfileService.d.ts.map +1 -0
  317. package/src/lib/services/brighthub/userProfileService.js +868 -0
  318. package/src/lib/services/brighthub/userProfileService.js.map +1 -0
  319. package/src/lib/services/brighthub/userProfileService.test-helpers.d.ts +86 -0
  320. package/src/lib/services/brighthub/userProfileService.test-helpers.d.ts.map +1 -0
  321. package/src/lib/services/brighthub/userProfileService.test-helpers.js +169 -0
  322. package/src/lib/services/brighthub/userProfileService.test-helpers.js.map +1 -0
  323. package/src/lib/services/brighthub/webSocketServer.d.ts +68 -0
  324. package/src/lib/services/brighthub/webSocketServer.d.ts.map +1 -0
  325. package/src/lib/services/brighthub/webSocketServer.js +194 -0
  326. package/src/lib/services/brighthub/webSocketServer.js.map +1 -0
  327. package/src/lib/services/brightpass/auditLogger.js +10 -5
  328. package/src/lib/services/brightpass/auditLogger.js.map +1 -1
  329. package/src/lib/services/brightpass/vaultEncryption.js +8 -8
  330. package/src/lib/services/brightpass/vaultEncryption.js.map +1 -1
  331. package/src/lib/services/brightpass.js +16 -8
  332. package/src/lib/services/brightpass.js.map +1 -1
  333. package/src/lib/services/cliOperatorPrompt.js +5 -2
  334. package/src/lib/services/cliOperatorPrompt.js.map +1 -1
  335. package/src/lib/services/clientWebSocketServer.d.ts +69 -4
  336. package/src/lib/services/clientWebSocketServer.d.ts.map +1 -1
  337. package/src/lib/services/clientWebSocketServer.js +188 -10
  338. package/src/lib/services/clientWebSocketServer.js.map +1 -1
  339. package/src/lib/services/contentAwareBlocksService.js +2 -0
  340. package/src/lib/services/contentAwareBlocksService.js.map +1 -1
  341. package/src/lib/services/contentIngestionService.d.ts.map +1 -1
  342. package/src/lib/services/contentIngestionService.js +2 -0
  343. package/src/lib/services/contentIngestionService.js.map +1 -1
  344. package/src/lib/services/diskQuorumService.js +3 -0
  345. package/src/lib/services/diskQuorumService.js.map +1 -1
  346. package/src/lib/services/email.js +5 -0
  347. package/src/lib/services/email.js.map +1 -1
  348. package/src/lib/services/eventNotificationSystem.d.ts +51 -10
  349. package/src/lib/services/eventNotificationSystem.d.ts.map +1 -1
  350. package/src/lib/services/eventNotificationSystem.js +76 -23
  351. package/src/lib/services/eventNotificationSystem.js.map +1 -1
  352. package/src/lib/services/expirationScheduler.js +6 -3
  353. package/src/lib/services/expirationScheduler.js.map +1 -1
  354. package/src/lib/services/fakeEmailService.js +3 -4
  355. package/src/lib/services/fakeEmailService.js.map +1 -1
  356. package/src/lib/services/fec.js +1 -3
  357. package/src/lib/services/fec.js.map +1 -1
  358. package/src/lib/services/fecServiceFactory.js +2 -2
  359. package/src/lib/services/fecServiceFactory.js.map +1 -1
  360. package/src/lib/services/fecUsageExample.js +1 -3
  361. package/src/lib/services/fecUsageExample.js.map +1 -1
  362. package/src/lib/services/identityExpirationScheduler.d.ts.map +1 -1
  363. package/src/lib/services/identityExpirationScheduler.js +7 -2
  364. package/src/lib/services/identityExpirationScheduler.js.map +1 -1
  365. package/src/lib/services/index.d.ts +3 -2
  366. package/src/lib/services/index.d.ts.map +1 -1
  367. package/src/lib/services/index.js +3 -2
  368. package/src/lib/services/index.js.map +1 -1
  369. package/src/lib/services/messageEventsWebSocketHandler.js +1 -0
  370. package/src/lib/services/messageEventsWebSocketHandler.js.map +1 -1
  371. package/src/lib/services/messagePassingService.js +5 -0
  372. package/src/lib/services/messagePassingService.js.map +1 -1
  373. package/src/lib/services/nativeRsFecService.js +3 -5
  374. package/src/lib/services/nativeRsFecService.js.map +1 -1
  375. package/src/lib/services/presenceService.js +5 -4
  376. package/src/lib/services/presenceService.js.map +1 -1
  377. package/src/lib/services/quorum.js +3 -2
  378. package/src/lib/services/quorum.js.map +1 -1
  379. package/src/lib/services/quorumDatabaseAdapter.d.ts +5 -5
  380. package/src/lib/services/quorumDatabaseAdapter.d.ts.map +1 -1
  381. package/src/lib/services/quorumDatabaseAdapter.js +5 -3
  382. package/src/lib/services/quorumDatabaseAdapter.js.map +1 -1
  383. package/src/lib/services/rbac-input-builder.js +5 -0
  384. package/src/lib/services/rbac-input-builder.js.map +1 -1
  385. package/src/lib/services/secureKeyStorage.js +3 -0
  386. package/src/lib/services/secureKeyStorage.js.map +1 -1
  387. package/src/lib/services/sessionAdapter.d.ts +4 -4
  388. package/src/lib/services/sessionAdapter.d.ts.map +1 -1
  389. package/src/lib/services/sessionAdapter.js +3 -2
  390. package/src/lib/services/sessionAdapter.js.map +1 -1
  391. package/src/lib/services/webSocketMessageServer.js +7 -4
  392. package/src/lib/services/webSocketMessageServer.js.map +1 -1
  393. package/src/lib/services/webSocketPeerProvider.js +2 -1
  394. package/src/lib/services/webSocketPeerProvider.js.map +1 -1
  395. package/src/lib/services/websocketHandler.js +9 -1
  396. package/src/lib/services/websocketHandler.js.map +1 -1
  397. package/src/lib/shared-types.d.ts +1 -2
  398. package/src/lib/shared-types.d.ts.map +1 -1
  399. package/src/lib/stores/__tests__/helpers/mockCloudBlockStore.d.ts +63 -0
  400. package/src/lib/stores/__tests__/helpers/mockCloudBlockStore.d.ts.map +1 -0
  401. package/src/lib/stores/__tests__/helpers/mockCloudBlockStore.js +160 -0
  402. package/src/lib/stores/__tests__/helpers/mockCloudBlockStore.js.map +1 -0
  403. package/src/lib/stores/availabilityAwareBlockStore.js +34 -5
  404. package/src/lib/stores/availabilityAwareBlockStore.js.map +1 -1
  405. package/src/lib/stores/cloudBlockStoreBase.d.ts +121 -0
  406. package/src/lib/stores/cloudBlockStoreBase.d.ts.map +1 -0
  407. package/src/lib/stores/cloudBlockStoreBase.js +1165 -0
  408. package/src/lib/stores/cloudBlockStoreBase.js.map +1 -0
  409. package/src/lib/stores/diskBlockAsyncStore.js +9 -5
  410. package/src/lib/stores/diskBlockAsyncStore.js.map +1 -1
  411. package/src/lib/stores/diskBlockMetadataStore.js +2 -0
  412. package/src/lib/stores/diskBlockMetadataStore.js.map +1 -1
  413. package/src/lib/stores/diskBlockStore.js +10 -8
  414. package/src/lib/stores/diskBlockStore.js.map +1 -1
  415. package/src/lib/stores/diskCBLStore.d.ts.map +1 -1
  416. package/src/lib/stores/diskCBLStore.js +8 -0
  417. package/src/lib/stores/diskCBLStore.js.map +1 -1
  418. package/src/lib/stores/index.d.ts +1 -0
  419. package/src/lib/stores/index.d.ts.map +1 -1
  420. package/src/lib/stores/index.js +1 -0
  421. package/src/lib/stores/index.js.map +1 -1
  422. package/src/lib/systemKeyring.d.ts.map +1 -1
  423. package/src/lib/systemKeyring.js +5 -4
  424. package/src/lib/systemKeyring.js.map +1 -1
  425. package/src/lib/transforms/checksumTransform.js +1 -0
  426. package/src/lib/transforms/checksumTransform.js.map +1 -1
  427. package/src/lib/transforms/memoryWritableStream.js +1 -0
  428. package/src/lib/transforms/memoryWritableStream.js.map +1 -1
  429. package/src/lib/transforms/xorMultipleTransform.js +3 -0
  430. package/src/lib/transforms/xorMultipleTransform.js.map +1 -1
  431. package/src/lib/utils/rehydration.d.ts +1 -1
  432. package/src/lib/utils/rehydration.js +1 -1
  433. package/src/lib/utils/serialization.d.ts +1 -1
  434. package/src/lib/utils/serialization.js +1 -1
  435. package/src/lib/services/backupCodeService.d.ts +0 -35
  436. package/src/lib/services/backupCodeService.d.ts.map +0 -1
  437. package/src/lib/services/backupCodeService.js +0 -109
  438. package/src/lib/services/backupCodeService.js.map +0 -1
@@ -0,0 +1,1077 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BrightHubMessagingController = void 0;
4
+ const brighthub_lib_1 = require("@brightchain/brighthub-lib");
5
+ const node_express_suite_1 = require("@digitaldefiance/node-express-suite");
6
+ const errorResponse_1 = require("../../../utils/errorResponse");
7
+ const base_1 = require("../../base");
8
+ /**
9
+ * Controller for BrightHub messaging operations.
10
+ *
11
+ * Provides REST API endpoints for conversations, messages, reactions,
12
+ * read receipts, message requests, and group management.
13
+ *
14
+ * @requirements 45.1-45.28
15
+ */
16
+ class BrightHubMessagingController extends base_1.BaseController {
17
+ messagingService = null;
18
+ constructor(application) {
19
+ super(application);
20
+ }
21
+ setMessagingService(service) {
22
+ this.messagingService = service;
23
+ }
24
+ getMessagingService() {
25
+ if (!this.messagingService)
26
+ throw new Error('MessagingService not initialized');
27
+ return this.messagingService;
28
+ }
29
+ mapMessagingError(error) {
30
+ switch (error.code) {
31
+ case brighthub_lib_1.MessagingErrorCode.ConversationNotFound:
32
+ case brighthub_lib_1.MessagingErrorCode.MessageNotFound:
33
+ case brighthub_lib_1.MessagingErrorCode.MessageRequestNotFound:
34
+ case brighthub_lib_1.MessagingErrorCode.ReactionNotFound:
35
+ return (0, errorResponse_1.notFoundError)('Resource', 'unknown');
36
+ case brighthub_lib_1.MessagingErrorCode.NotParticipant:
37
+ case brighthub_lib_1.MessagingErrorCode.Unauthorized:
38
+ case brighthub_lib_1.MessagingErrorCode.NotAdmin:
39
+ case brighthub_lib_1.MessagingErrorCode.UserBlocked:
40
+ return (0, errorResponse_1.forbiddenError)(error.message);
41
+ case brighthub_lib_1.MessagingErrorCode.EmptyContent:
42
+ case brighthub_lib_1.MessagingErrorCode.ContentTooLong:
43
+ case brighthub_lib_1.MessagingErrorCode.TooManyAttachments:
44
+ case brighthub_lib_1.MessagingErrorCode.AttachmentSizeTooLarge:
45
+ case brighthub_lib_1.MessagingErrorCode.InvalidMediaFormat:
46
+ case brighthub_lib_1.MessagingErrorCode.ReactionLimitExceeded:
47
+ case brighthub_lib_1.MessagingErrorCode.ReactionAlreadyExists:
48
+ case brighthub_lib_1.MessagingErrorCode.PinLimitExceeded:
49
+ case brighthub_lib_1.MessagingErrorCode.AlreadyPinned:
50
+ case brighthub_lib_1.MessagingErrorCode.NotPinned:
51
+ case brighthub_lib_1.MessagingErrorCode.AlreadyArchived:
52
+ case brighthub_lib_1.MessagingErrorCode.NotArchived:
53
+ case brighthub_lib_1.MessagingErrorCode.AlreadyMuted:
54
+ case brighthub_lib_1.MessagingErrorCode.NotMuted:
55
+ case brighthub_lib_1.MessagingErrorCode.GroupParticipantLimitExceeded:
56
+ case brighthub_lib_1.MessagingErrorCode.AlreadyParticipant:
57
+ case brighthub_lib_1.MessagingErrorCode.InvalidGroupName:
58
+ case brighthub_lib_1.MessagingErrorCode.ConversationAlreadyExists:
59
+ case brighthub_lib_1.MessagingErrorCode.MessageRequestAlreadyExists:
60
+ case brighthub_lib_1.MessagingErrorCode.MessageAlreadyDeleted:
61
+ case brighthub_lib_1.MessagingErrorCode.EditWindowExpired:
62
+ case brighthub_lib_1.MessagingErrorCode.LastAdminCannotLeave:
63
+ return (0, errorResponse_1.validationError)(error.message);
64
+ default:
65
+ return (0, errorResponse_1.handleError)(error);
66
+ }
67
+ }
68
+ parsePaginationOptions(query) {
69
+ const options = {};
70
+ if (query['cursor'])
71
+ options.cursor = query['cursor'];
72
+ if (query['limit'])
73
+ options.limit = parseInt(query['limit'], 10);
74
+ return options;
75
+ }
76
+ initRouteDefinitions() {
77
+ this.routeDefinitions = [
78
+ // ── Core Messaging (21.5) ──
79
+ (0, node_express_suite_1.routeConfig)('get', '/conversations', {
80
+ handlerKey: 'getConversations',
81
+ useAuthentication: false,
82
+ useCryptoAuthentication: false,
83
+ openapi: {
84
+ summary: 'Get conversations',
85
+ tags: ['BrightHub Messaging'],
86
+ responses: {
87
+ 200: {
88
+ schema: 'ConversationsResponse',
89
+ description: 'Conversations retrieved',
90
+ },
91
+ },
92
+ },
93
+ }),
94
+ (0, node_express_suite_1.routeConfig)('post', '/conversations', {
95
+ handlerKey: 'createConversation',
96
+ useAuthentication: false,
97
+ useCryptoAuthentication: false,
98
+ openapi: {
99
+ summary: 'Create a conversation',
100
+ tags: ['BrightHub Messaging'],
101
+ responses: {
102
+ 201: {
103
+ schema: 'ConversationResponse',
104
+ description: 'Conversation created',
105
+ },
106
+ },
107
+ },
108
+ }),
109
+ (0, node_express_suite_1.routeConfig)('get', '/conversations/:id', {
110
+ handlerKey: 'getConversation',
111
+ useAuthentication: false,
112
+ useCryptoAuthentication: false,
113
+ openapi: {
114
+ summary: 'Get a conversation with messages',
115
+ tags: ['BrightHub Messaging'],
116
+ responses: {
117
+ 200: {
118
+ schema: 'ConversationResponse',
119
+ description: 'Conversation retrieved',
120
+ },
121
+ },
122
+ },
123
+ }),
124
+ (0, node_express_suite_1.routeConfig)('delete', '/conversations/:id', {
125
+ handlerKey: 'deleteConversation',
126
+ useAuthentication: false,
127
+ useCryptoAuthentication: false,
128
+ openapi: {
129
+ summary: 'Delete a conversation',
130
+ tags: ['BrightHub Messaging'],
131
+ responses: {
132
+ 204: {
133
+ schema: 'EmptyResponse',
134
+ description: 'Conversation deleted',
135
+ },
136
+ },
137
+ },
138
+ }),
139
+ (0, node_express_suite_1.routeConfig)('post', '/conversations/:id/messages', {
140
+ handlerKey: 'sendMessage',
141
+ useAuthentication: false,
142
+ useCryptoAuthentication: false,
143
+ openapi: {
144
+ summary: 'Send a message',
145
+ tags: ['BrightHub Messaging'],
146
+ responses: {
147
+ 201: { schema: 'MessageResponse', description: 'Message sent' },
148
+ },
149
+ },
150
+ }),
151
+ (0, node_express_suite_1.routeConfig)('put', '/:messageId', {
152
+ handlerKey: 'editMessage',
153
+ useAuthentication: false,
154
+ useCryptoAuthentication: false,
155
+ openapi: {
156
+ summary: 'Edit a message',
157
+ tags: ['BrightHub Messaging'],
158
+ responses: {
159
+ 200: { schema: 'MessageResponse', description: 'Message edited' },
160
+ },
161
+ },
162
+ }),
163
+ (0, node_express_suite_1.routeConfig)('delete', '/:messageId', {
164
+ handlerKey: 'deleteMessage',
165
+ useAuthentication: false,
166
+ useCryptoAuthentication: false,
167
+ openapi: {
168
+ summary: 'Delete a message',
169
+ tags: ['BrightHub Messaging'],
170
+ responses: {
171
+ 204: { schema: 'EmptyResponse', description: 'Message deleted' },
172
+ },
173
+ },
174
+ }),
175
+ (0, node_express_suite_1.routeConfig)('post', '/:messageId/reactions', {
176
+ handlerKey: 'addReaction',
177
+ useAuthentication: false,
178
+ useCryptoAuthentication: false,
179
+ openapi: {
180
+ summary: 'Add a reaction to a message',
181
+ tags: ['BrightHub Messaging'],
182
+ responses: {
183
+ 201: { schema: 'ReactionResponse', description: 'Reaction added' },
184
+ },
185
+ },
186
+ }),
187
+ (0, node_express_suite_1.routeConfig)('delete', '/:messageId/reactions/:emoji', {
188
+ handlerKey: 'removeReaction',
189
+ useAuthentication: false,
190
+ useCryptoAuthentication: false,
191
+ openapi: {
192
+ summary: 'Remove a reaction from a message',
193
+ tags: ['BrightHub Messaging'],
194
+ responses: {
195
+ 200: { schema: 'MessageResponse', description: 'Reaction removed' },
196
+ },
197
+ },
198
+ }),
199
+ (0, node_express_suite_1.routeConfig)('post', '/conversations/:id/read', {
200
+ handlerKey: 'markAsRead',
201
+ useAuthentication: false,
202
+ useCryptoAuthentication: false,
203
+ openapi: {
204
+ summary: 'Mark messages as read',
205
+ tags: ['BrightHub Messaging'],
206
+ responses: {
207
+ 200: {
208
+ schema: 'ReadReceiptResponse',
209
+ description: 'Marked as read',
210
+ },
211
+ },
212
+ },
213
+ }),
214
+ (0, node_express_suite_1.routeConfig)('post', '/conversations/:id/typing', {
215
+ handlerKey: 'sendTypingIndicator',
216
+ useAuthentication: false,
217
+ useCryptoAuthentication: false,
218
+ openapi: {
219
+ summary: 'Send typing indicator',
220
+ tags: ['BrightHub Messaging'],
221
+ responses: {
222
+ 200: {
223
+ schema: 'TypingResponse',
224
+ description: 'Typing indicator sent',
225
+ },
226
+ },
227
+ },
228
+ }),
229
+ // ── Additional Messaging (21.6) ──
230
+ (0, node_express_suite_1.routeConfig)('get', '/requests', {
231
+ handlerKey: 'getMessageRequests',
232
+ useAuthentication: false,
233
+ useCryptoAuthentication: false,
234
+ openapi: {
235
+ summary: 'Get message requests',
236
+ tags: ['BrightHub Messaging'],
237
+ responses: {
238
+ 200: {
239
+ schema: 'MessageRequestsResponse',
240
+ description: 'Requests retrieved',
241
+ },
242
+ },
243
+ },
244
+ }),
245
+ (0, node_express_suite_1.routeConfig)('post', '/requests/:id/accept', {
246
+ handlerKey: 'acceptMessageRequest',
247
+ useAuthentication: false,
248
+ useCryptoAuthentication: false,
249
+ openapi: {
250
+ summary: 'Accept a message request',
251
+ tags: ['BrightHub Messaging'],
252
+ responses: {
253
+ 200: {
254
+ schema: 'ConversationResponse',
255
+ description: 'Request accepted',
256
+ },
257
+ },
258
+ },
259
+ }),
260
+ (0, node_express_suite_1.routeConfig)('post', '/requests/:id/decline', {
261
+ handlerKey: 'declineMessageRequest',
262
+ useAuthentication: false,
263
+ useCryptoAuthentication: false,
264
+ openapi: {
265
+ summary: 'Decline a message request',
266
+ tags: ['BrightHub Messaging'],
267
+ responses: {
268
+ 200: { schema: 'MessageResponse', description: 'Request declined' },
269
+ },
270
+ },
271
+ }),
272
+ (0, node_express_suite_1.routeConfig)('post', '/conversations/:id/pin', {
273
+ handlerKey: 'pinConversation',
274
+ useAuthentication: false,
275
+ useCryptoAuthentication: false,
276
+ openapi: {
277
+ summary: 'Pin a conversation',
278
+ tags: ['BrightHub Messaging'],
279
+ responses: {
280
+ 200: {
281
+ schema: 'MessageResponse',
282
+ description: 'Conversation pinned',
283
+ },
284
+ },
285
+ },
286
+ }),
287
+ (0, node_express_suite_1.routeConfig)('delete', '/conversations/:id/pin', {
288
+ handlerKey: 'unpinConversation',
289
+ useAuthentication: false,
290
+ useCryptoAuthentication: false,
291
+ openapi: {
292
+ summary: 'Unpin a conversation',
293
+ tags: ['BrightHub Messaging'],
294
+ responses: {
295
+ 200: {
296
+ schema: 'MessageResponse',
297
+ description: 'Conversation unpinned',
298
+ },
299
+ },
300
+ },
301
+ }),
302
+ (0, node_express_suite_1.routeConfig)('post', '/conversations/:id/archive', {
303
+ handlerKey: 'archiveConversation',
304
+ useAuthentication: false,
305
+ useCryptoAuthentication: false,
306
+ openapi: {
307
+ summary: 'Archive a conversation',
308
+ tags: ['BrightHub Messaging'],
309
+ responses: {
310
+ 200: {
311
+ schema: 'MessageResponse',
312
+ description: 'Conversation archived',
313
+ },
314
+ },
315
+ },
316
+ }),
317
+ (0, node_express_suite_1.routeConfig)('post', '/conversations/:id/unarchive', {
318
+ handlerKey: 'unarchiveConversation',
319
+ useAuthentication: false,
320
+ useCryptoAuthentication: false,
321
+ openapi: {
322
+ summary: 'Unarchive a conversation',
323
+ tags: ['BrightHub Messaging'],
324
+ responses: {
325
+ 200: {
326
+ schema: 'MessageResponse',
327
+ description: 'Conversation unarchived',
328
+ },
329
+ },
330
+ },
331
+ }),
332
+ (0, node_express_suite_1.routeConfig)('post', '/conversations/:id/mute', {
333
+ handlerKey: 'muteConversation',
334
+ useAuthentication: false,
335
+ useCryptoAuthentication: false,
336
+ openapi: {
337
+ summary: 'Mute a conversation',
338
+ tags: ['BrightHub Messaging'],
339
+ responses: {
340
+ 200: {
341
+ schema: 'MessageResponse',
342
+ description: 'Conversation muted',
343
+ },
344
+ },
345
+ },
346
+ }),
347
+ (0, node_express_suite_1.routeConfig)('delete', '/conversations/:id/mute', {
348
+ handlerKey: 'unmuteConversation',
349
+ useAuthentication: false,
350
+ useCryptoAuthentication: false,
351
+ openapi: {
352
+ summary: 'Unmute a conversation',
353
+ tags: ['BrightHub Messaging'],
354
+ responses: {
355
+ 200: {
356
+ schema: 'MessageResponse',
357
+ description: 'Conversation unmuted',
358
+ },
359
+ },
360
+ },
361
+ }),
362
+ (0, node_express_suite_1.routeConfig)('post', '/:messageId/report', {
363
+ handlerKey: 'reportMessage',
364
+ useAuthentication: false,
365
+ useCryptoAuthentication: false,
366
+ openapi: {
367
+ summary: 'Report a message',
368
+ tags: ['BrightHub Messaging'],
369
+ responses: {
370
+ 200: { schema: 'MessageResponse', description: 'Message reported' },
371
+ },
372
+ },
373
+ }),
374
+ (0, node_express_suite_1.routeConfig)('get', '/conversations/:id/search', {
375
+ handlerKey: 'searchInConversation',
376
+ useAuthentication: false,
377
+ useCryptoAuthentication: false,
378
+ openapi: {
379
+ summary: 'Search within a conversation',
380
+ tags: ['BrightHub Messaging'],
381
+ responses: {
382
+ 200: { schema: 'MessagesResponse', description: 'Search results' },
383
+ },
384
+ },
385
+ }),
386
+ (0, node_express_suite_1.routeConfig)('get', '/search', {
387
+ handlerKey: 'searchAllMessages',
388
+ useAuthentication: false,
389
+ useCryptoAuthentication: false,
390
+ openapi: {
391
+ summary: 'Search all conversations',
392
+ tags: ['BrightHub Messaging'],
393
+ responses: {
394
+ 200: { schema: 'MessagesResponse', description: 'Search results' },
395
+ },
396
+ },
397
+ }),
398
+ (0, node_express_suite_1.routeConfig)('post', '/conversations/:id/participants', {
399
+ handlerKey: 'addParticipants',
400
+ useAuthentication: false,
401
+ useCryptoAuthentication: false,
402
+ openapi: {
403
+ summary: 'Add participants to group',
404
+ tags: ['BrightHub Messaging'],
405
+ responses: {
406
+ 200: {
407
+ schema: 'MessageResponse',
408
+ description: 'Participants added',
409
+ },
410
+ },
411
+ },
412
+ }),
413
+ (0, node_express_suite_1.routeConfig)('delete', '/conversations/:id/participants/:userId', {
414
+ handlerKey: 'removeParticipant',
415
+ useAuthentication: false,
416
+ useCryptoAuthentication: false,
417
+ openapi: {
418
+ summary: 'Remove a participant from group',
419
+ tags: ['BrightHub Messaging'],
420
+ responses: {
421
+ 200: {
422
+ schema: 'MessageResponse',
423
+ description: 'Participant removed',
424
+ },
425
+ },
426
+ },
427
+ }),
428
+ (0, node_express_suite_1.routeConfig)('put', '/conversations/:id/settings', {
429
+ handlerKey: 'updateGroupSettings',
430
+ useAuthentication: false,
431
+ useCryptoAuthentication: false,
432
+ openapi: {
433
+ summary: 'Update group settings',
434
+ tags: ['BrightHub Messaging'],
435
+ responses: {
436
+ 200: {
437
+ schema: 'ConversationResponse',
438
+ description: 'Settings updated',
439
+ },
440
+ },
441
+ },
442
+ }),
443
+ (0, node_express_suite_1.routeConfig)('post', '/:messageId/forward', {
444
+ handlerKey: 'forwardMessage',
445
+ useAuthentication: false,
446
+ useCryptoAuthentication: false,
447
+ openapi: {
448
+ summary: 'Forward a message',
449
+ tags: ['BrightHub Messaging'],
450
+ responses: {
451
+ 201: {
452
+ schema: 'MessageResponse',
453
+ description: 'Message forwarded',
454
+ },
455
+ },
456
+ },
457
+ }),
458
+ ];
459
+ node_express_suite_1.ControllerRegistry.register('/brighthub/messages', 'BrightHubMessagingController', this.routeDefinitions);
460
+ this.handlers = {
461
+ getConversations: this.handleGetConversations.bind(this),
462
+ createConversation: this.handleCreateConversation.bind(this),
463
+ getConversation: this.handleGetConversation.bind(this),
464
+ deleteConversation: this.handleDeleteConversation.bind(this),
465
+ sendMessage: this.handleSendMessage.bind(this),
466
+ editMessage: this.handleEditMessage.bind(this),
467
+ deleteMessage: this.handleDeleteMessage.bind(this),
468
+ addReaction: this.handleAddReaction.bind(this),
469
+ removeReaction: this.handleRemoveReaction.bind(this),
470
+ markAsRead: this.handleMarkAsRead.bind(this),
471
+ sendTypingIndicator: this.handleSendTypingIndicator.bind(this),
472
+ getMessageRequests: this.handleGetMessageRequests.bind(this),
473
+ acceptMessageRequest: this.handleAcceptMessageRequest.bind(this),
474
+ declineMessageRequest: this.handleDeclineMessageRequest.bind(this),
475
+ pinConversation: this.handlePinConversation.bind(this),
476
+ unpinConversation: this.handleUnpinConversation.bind(this),
477
+ archiveConversation: this.handleArchiveConversation.bind(this),
478
+ unarchiveConversation: this.handleUnarchiveConversation.bind(this),
479
+ muteConversation: this.handleMuteConversation.bind(this),
480
+ unmuteConversation: this.handleUnmuteConversation.bind(this),
481
+ reportMessage: this.handleReportMessage.bind(this),
482
+ searchInConversation: this.handleSearchInConversation.bind(this),
483
+ searchAllMessages: this.handleSearchAllMessages.bind(this),
484
+ addParticipants: this.handleAddParticipants.bind(this),
485
+ removeParticipant: this.handleRemoveParticipant.bind(this),
486
+ updateGroupSettings: this.handleUpdateGroupSettings.bind(this),
487
+ forwardMessage: this.handleForwardMessage.bind(this),
488
+ };
489
+ }
490
+ // ═══════════════════════════════════════════════════════
491
+ // Core Messaging Handlers (21.5)
492
+ // ═══════════════════════════════════════════════════════
493
+ async handleGetConversations(req) {
494
+ try {
495
+ const typedReq = req;
496
+ const userId = typedReq.query['userId'];
497
+ if (!userId)
498
+ return (0, errorResponse_1.validationError)('Missing required query parameter: userId');
499
+ const options = this.parsePaginationOptions(typedReq.query);
500
+ const result = await this.getMessagingService().getConversations(userId, options);
501
+ return {
502
+ statusCode: 200,
503
+ response: {
504
+ message: 'OK',
505
+ data: {
506
+ conversations: result.items,
507
+ cursor: result.cursor,
508
+ hasMore: result.hasMore,
509
+ },
510
+ },
511
+ };
512
+ }
513
+ catch (error) {
514
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
515
+ return this.mapMessagingError(error);
516
+ return (0, errorResponse_1.handleError)(error);
517
+ }
518
+ }
519
+ async handleCreateConversation(req) {
520
+ try {
521
+ const { userId, otherUserId, participantIds, type, name, avatarUrl } = req.body;
522
+ if (!userId)
523
+ return (0, errorResponse_1.validationError)('Missing required field: userId');
524
+ const service = this.getMessagingService();
525
+ if (type === 'group') {
526
+ if (!participantIds || !Array.isArray(participantIds))
527
+ return (0, errorResponse_1.validationError)('Missing required field: participantIds');
528
+ if (!name)
529
+ return (0, errorResponse_1.validationError)('Missing required field: name for group conversation');
530
+ const conversation = await service.createGroupConversation(userId, participantIds, { name, avatarUrl });
531
+ return {
532
+ statusCode: 201,
533
+ response: {
534
+ message: 'Group conversation created',
535
+ data: conversation,
536
+ },
537
+ };
538
+ }
539
+ else {
540
+ if (!otherUserId)
541
+ return (0, errorResponse_1.validationError)('Missing required field: otherUserId');
542
+ const conversation = await service.createDirectConversation(userId, otherUserId);
543
+ return {
544
+ statusCode: 201,
545
+ response: { message: 'Conversation created', data: conversation },
546
+ };
547
+ }
548
+ }
549
+ catch (error) {
550
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
551
+ return this.mapMessagingError(error);
552
+ return (0, errorResponse_1.handleError)(error);
553
+ }
554
+ }
555
+ async handleGetConversation(req) {
556
+ try {
557
+ const { id } = req.params;
558
+ const typedReq = req;
559
+ const userId = typedReq.query['userId'];
560
+ if (!id)
561
+ return (0, errorResponse_1.validationError)('Missing required parameter: id');
562
+ if (!userId)
563
+ return (0, errorResponse_1.validationError)('Missing required query parameter: userId');
564
+ const conversation = await this.getMessagingService().getConversation(id, userId);
565
+ return {
566
+ statusCode: 200,
567
+ response: { message: 'OK', data: conversation },
568
+ };
569
+ }
570
+ catch (error) {
571
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
572
+ return this.mapMessagingError(error);
573
+ return (0, errorResponse_1.handleError)(error);
574
+ }
575
+ }
576
+ async handleDeleteConversation(req) {
577
+ try {
578
+ const { id } = req.params;
579
+ const { userId } = req.body;
580
+ if (!id)
581
+ return (0, errorResponse_1.validationError)('Missing required parameter: id');
582
+ if (!userId)
583
+ return (0, errorResponse_1.validationError)('Missing required field: userId');
584
+ await this.getMessagingService().deleteConversation(id, userId);
585
+ return { statusCode: 204, response: { message: 'Conversation deleted' } };
586
+ }
587
+ catch (error) {
588
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
589
+ return this.mapMessagingError(error);
590
+ return (0, errorResponse_1.handleError)(error);
591
+ }
592
+ }
593
+ async handleSendMessage(req) {
594
+ try {
595
+ const { id } = req.params;
596
+ const { senderId, content, attachments, replyToMessageId, forwardedFromId, } = req.body;
597
+ if (!id)
598
+ return (0, errorResponse_1.validationError)('Missing required parameter: id');
599
+ if (!senderId)
600
+ return (0, errorResponse_1.validationError)('Missing required field: senderId');
601
+ if (content === undefined || content === null)
602
+ return (0, errorResponse_1.validationError)('Missing required field: content');
603
+ const options = {};
604
+ if (attachments)
605
+ options.attachments = attachments;
606
+ if (replyToMessageId)
607
+ options.replyToMessageId = replyToMessageId;
608
+ if (forwardedFromId)
609
+ options.forwardedFromId = forwardedFromId;
610
+ const message = await this.getMessagingService().sendMessage(id, senderId, content, options);
611
+ return {
612
+ statusCode: 201,
613
+ response: { message: 'Message sent', data: message },
614
+ };
615
+ }
616
+ catch (error) {
617
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
618
+ return this.mapMessagingError(error);
619
+ return (0, errorResponse_1.handleError)(error);
620
+ }
621
+ }
622
+ async handleEditMessage(req) {
623
+ try {
624
+ const { messageId } = req.params;
625
+ const { userId, content } = req.body;
626
+ if (!messageId)
627
+ return (0, errorResponse_1.validationError)('Missing required parameter: messageId');
628
+ if (!userId)
629
+ return (0, errorResponse_1.validationError)('Missing required field: userId');
630
+ if (content === undefined || content === null)
631
+ return (0, errorResponse_1.validationError)('Missing required field: content');
632
+ const message = await this.getMessagingService().editMessage(messageId, userId, content);
633
+ return {
634
+ statusCode: 200,
635
+ response: { message: 'Message edited', data: message },
636
+ };
637
+ }
638
+ catch (error) {
639
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
640
+ return this.mapMessagingError(error);
641
+ return (0, errorResponse_1.handleError)(error);
642
+ }
643
+ }
644
+ async handleDeleteMessage(req) {
645
+ try {
646
+ const { messageId } = req.params;
647
+ const { userId } = req.body;
648
+ if (!messageId)
649
+ return (0, errorResponse_1.validationError)('Missing required parameter: messageId');
650
+ if (!userId)
651
+ return (0, errorResponse_1.validationError)('Missing required field: userId');
652
+ await this.getMessagingService().deleteMessage(messageId, userId);
653
+ return { statusCode: 204, response: { message: 'Message deleted' } };
654
+ }
655
+ catch (error) {
656
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
657
+ return this.mapMessagingError(error);
658
+ return (0, errorResponse_1.handleError)(error);
659
+ }
660
+ }
661
+ async handleAddReaction(req) {
662
+ try {
663
+ const { messageId } = req.params;
664
+ const { userId, emoji } = req.body;
665
+ if (!messageId)
666
+ return (0, errorResponse_1.validationError)('Missing required parameter: messageId');
667
+ if (!userId)
668
+ return (0, errorResponse_1.validationError)('Missing required field: userId');
669
+ if (!emoji)
670
+ return (0, errorResponse_1.validationError)('Missing required field: emoji');
671
+ const reaction = await this.getMessagingService().addReaction(messageId, userId, emoji);
672
+ return {
673
+ statusCode: 201,
674
+ response: {
675
+ message: 'Reaction added',
676
+ data: reaction,
677
+ },
678
+ };
679
+ }
680
+ catch (error) {
681
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
682
+ return this.mapMessagingError(error);
683
+ return (0, errorResponse_1.handleError)(error);
684
+ }
685
+ }
686
+ async handleRemoveReaction(req) {
687
+ try {
688
+ const { messageId, emoji } = req.params;
689
+ const typedReq = req;
690
+ const userId = typedReq.query['userId'];
691
+ if (!messageId)
692
+ return (0, errorResponse_1.validationError)('Missing required parameter: messageId');
693
+ if (!emoji)
694
+ return (0, errorResponse_1.validationError)('Missing required parameter: emoji');
695
+ if (!userId)
696
+ return (0, errorResponse_1.validationError)('Missing required query parameter: userId');
697
+ await this.getMessagingService().removeReaction(messageId, userId, decodeURIComponent(emoji));
698
+ return { statusCode: 200, response: { message: 'Reaction removed' } };
699
+ }
700
+ catch (error) {
701
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
702
+ return this.mapMessagingError(error);
703
+ return (0, errorResponse_1.handleError)(error);
704
+ }
705
+ }
706
+ async handleMarkAsRead(req) {
707
+ try {
708
+ const { id } = req.params;
709
+ const { userId, messageId } = req.body;
710
+ if (!id)
711
+ return (0, errorResponse_1.validationError)('Missing required parameter: id');
712
+ if (!userId)
713
+ return (0, errorResponse_1.validationError)('Missing required field: userId');
714
+ if (!messageId)
715
+ return (0, errorResponse_1.validationError)('Missing required field: messageId');
716
+ const receipt = await this.getMessagingService().markAsRead(id, userId, messageId);
717
+ return {
718
+ statusCode: 200,
719
+ response: {
720
+ message: 'Marked as read',
721
+ data: receipt,
722
+ },
723
+ };
724
+ }
725
+ catch (error) {
726
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
727
+ return this.mapMessagingError(error);
728
+ return (0, errorResponse_1.handleError)(error);
729
+ }
730
+ }
731
+ async handleSendTypingIndicator(req) {
732
+ try {
733
+ const { id } = req.params;
734
+ const { userId } = req.body;
735
+ if (!id)
736
+ return (0, errorResponse_1.validationError)('Missing required parameter: id');
737
+ if (!userId)
738
+ return (0, errorResponse_1.validationError)('Missing required field: userId');
739
+ const result = await this.getMessagingService().sendTypingIndicator(id, userId);
740
+ return {
741
+ statusCode: 200,
742
+ response: {
743
+ message: 'Typing indicator sent',
744
+ data: result,
745
+ },
746
+ };
747
+ }
748
+ catch (error) {
749
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
750
+ return this.mapMessagingError(error);
751
+ return (0, errorResponse_1.handleError)(error);
752
+ }
753
+ }
754
+ // ═══════════════════════════════════════════════════════
755
+ // Additional Messaging Handlers (21.6)
756
+ // ═══════════════════════════════════════════════════════
757
+ async handleGetMessageRequests(_req) {
758
+ // Message requests are created via createMessageRequest on the service.
759
+ // Listing them requires a dedicated query method not yet on the interface.
760
+ // Return a placeholder until the service method is available.
761
+ return {
762
+ statusCode: 200,
763
+ response: {
764
+ message: 'OK',
765
+ data: { items: [], hasMore: false },
766
+ },
767
+ };
768
+ }
769
+ async handleAcceptMessageRequest(req) {
770
+ try {
771
+ const { id } = req.params;
772
+ const { userId } = req.body;
773
+ if (!id)
774
+ return (0, errorResponse_1.validationError)('Missing required parameter: id');
775
+ if (!userId)
776
+ return (0, errorResponse_1.validationError)('Missing required field: userId');
777
+ const conversation = await this.getMessagingService().acceptMessageRequest(id, userId);
778
+ return {
779
+ statusCode: 200,
780
+ response: { message: 'Message request accepted', data: conversation },
781
+ };
782
+ }
783
+ catch (error) {
784
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
785
+ return this.mapMessagingError(error);
786
+ return (0, errorResponse_1.handleError)(error);
787
+ }
788
+ }
789
+ async handleDeclineMessageRequest(req) {
790
+ try {
791
+ const { id } = req.params;
792
+ const { userId } = req.body;
793
+ if (!id)
794
+ return (0, errorResponse_1.validationError)('Missing required parameter: id');
795
+ if (!userId)
796
+ return (0, errorResponse_1.validationError)('Missing required field: userId');
797
+ await this.getMessagingService().declineMessageRequest(id, userId);
798
+ return {
799
+ statusCode: 200,
800
+ response: { message: 'Message request declined' },
801
+ };
802
+ }
803
+ catch (error) {
804
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
805
+ return this.mapMessagingError(error);
806
+ return (0, errorResponse_1.handleError)(error);
807
+ }
808
+ }
809
+ async handlePinConversation(req) {
810
+ try {
811
+ const { id } = req.params;
812
+ const { userId } = req.body;
813
+ if (!id)
814
+ return (0, errorResponse_1.validationError)('Missing required parameter: id');
815
+ if (!userId)
816
+ return (0, errorResponse_1.validationError)('Missing required field: userId');
817
+ await this.getMessagingService().pinConversation(id, userId);
818
+ return { statusCode: 200, response: { message: 'Conversation pinned' } };
819
+ }
820
+ catch (error) {
821
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
822
+ return this.mapMessagingError(error);
823
+ return (0, errorResponse_1.handleError)(error);
824
+ }
825
+ }
826
+ async handleUnpinConversation(req) {
827
+ try {
828
+ const { id } = req.params;
829
+ const typedReq = req;
830
+ const userId = typedReq.query['userId'];
831
+ if (!id)
832
+ return (0, errorResponse_1.validationError)('Missing required parameter: id');
833
+ if (!userId)
834
+ return (0, errorResponse_1.validationError)('Missing required query parameter: userId');
835
+ await this.getMessagingService().unpinConversation(id, userId);
836
+ return {
837
+ statusCode: 200,
838
+ response: { message: 'Conversation unpinned' },
839
+ };
840
+ }
841
+ catch (error) {
842
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
843
+ return this.mapMessagingError(error);
844
+ return (0, errorResponse_1.handleError)(error);
845
+ }
846
+ }
847
+ async handleArchiveConversation(req) {
848
+ try {
849
+ const { id } = req.params;
850
+ const { userId } = req.body;
851
+ if (!id)
852
+ return (0, errorResponse_1.validationError)('Missing required parameter: id');
853
+ if (!userId)
854
+ return (0, errorResponse_1.validationError)('Missing required field: userId');
855
+ await this.getMessagingService().archiveConversation(id, userId);
856
+ return {
857
+ statusCode: 200,
858
+ response: { message: 'Conversation archived' },
859
+ };
860
+ }
861
+ catch (error) {
862
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
863
+ return this.mapMessagingError(error);
864
+ return (0, errorResponse_1.handleError)(error);
865
+ }
866
+ }
867
+ async handleUnarchiveConversation(req) {
868
+ try {
869
+ const { id } = req.params;
870
+ const { userId } = req.body;
871
+ if (!id)
872
+ return (0, errorResponse_1.validationError)('Missing required parameter: id');
873
+ if (!userId)
874
+ return (0, errorResponse_1.validationError)('Missing required field: userId');
875
+ await this.getMessagingService().unarchiveConversation(id, userId);
876
+ return {
877
+ statusCode: 200,
878
+ response: { message: 'Conversation unarchived' },
879
+ };
880
+ }
881
+ catch (error) {
882
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
883
+ return this.mapMessagingError(error);
884
+ return (0, errorResponse_1.handleError)(error);
885
+ }
886
+ }
887
+ async handleMuteConversation(req) {
888
+ try {
889
+ const { id } = req.params;
890
+ const { userId, expiresAt } = req.body;
891
+ if (!id)
892
+ return (0, errorResponse_1.validationError)('Missing required parameter: id');
893
+ if (!userId)
894
+ return (0, errorResponse_1.validationError)('Missing required field: userId');
895
+ await this.getMessagingService().muteConversation(id, userId, expiresAt);
896
+ return { statusCode: 200, response: { message: 'Conversation muted' } };
897
+ }
898
+ catch (error) {
899
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
900
+ return this.mapMessagingError(error);
901
+ return (0, errorResponse_1.handleError)(error);
902
+ }
903
+ }
904
+ async handleUnmuteConversation(req) {
905
+ try {
906
+ const { id } = req.params;
907
+ const typedReq = req;
908
+ const userId = typedReq.query['userId'];
909
+ if (!id)
910
+ return (0, errorResponse_1.validationError)('Missing required parameter: id');
911
+ if (!userId)
912
+ return (0, errorResponse_1.validationError)('Missing required query parameter: userId');
913
+ await this.getMessagingService().unmuteConversation(id, userId);
914
+ return { statusCode: 200, response: { message: 'Conversation unmuted' } };
915
+ }
916
+ catch (error) {
917
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
918
+ return this.mapMessagingError(error);
919
+ return (0, errorResponse_1.handleError)(error);
920
+ }
921
+ }
922
+ async handleReportMessage(_req) {
923
+ // Message reporting requires a dedicated service method not yet on the interface.
924
+ // Return acknowledgment for now.
925
+ return { statusCode: 200, response: { message: 'Message reported' } };
926
+ }
927
+ async handleSearchInConversation(req) {
928
+ try {
929
+ const { id } = req.params;
930
+ const typedReq = req;
931
+ const userId = typedReq.query['userId'];
932
+ const query = typedReq.query['q'];
933
+ if (!id)
934
+ return (0, errorResponse_1.validationError)('Missing required parameter: id');
935
+ if (!userId)
936
+ return (0, errorResponse_1.validationError)('Missing required query parameter: userId');
937
+ if (!query)
938
+ return (0, errorResponse_1.validationError)('Missing required query parameter: q');
939
+ const options = this.parsePaginationOptions(typedReq.query);
940
+ const result = await this.getMessagingService().searchInConversation(id, userId, query, options);
941
+ return {
942
+ statusCode: 200,
943
+ response: {
944
+ message: 'OK',
945
+ data: {
946
+ messages: result.items,
947
+ cursor: result.cursor,
948
+ hasMore: result.hasMore,
949
+ },
950
+ },
951
+ };
952
+ }
953
+ catch (error) {
954
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
955
+ return this.mapMessagingError(error);
956
+ return (0, errorResponse_1.handleError)(error);
957
+ }
958
+ }
959
+ async handleSearchAllMessages(req) {
960
+ try {
961
+ const typedReq = req;
962
+ const userId = typedReq.query['userId'];
963
+ const query = typedReq.query['q'];
964
+ if (!userId)
965
+ return (0, errorResponse_1.validationError)('Missing required query parameter: userId');
966
+ if (!query)
967
+ return (0, errorResponse_1.validationError)('Missing required query parameter: q');
968
+ const options = this.parsePaginationOptions(typedReq.query);
969
+ const result = await this.getMessagingService().searchMessages(userId, query, options);
970
+ return {
971
+ statusCode: 200,
972
+ response: {
973
+ message: 'OK',
974
+ data: {
975
+ messages: result.items,
976
+ cursor: result.cursor,
977
+ hasMore: result.hasMore,
978
+ },
979
+ },
980
+ };
981
+ }
982
+ catch (error) {
983
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
984
+ return this.mapMessagingError(error);
985
+ return (0, errorResponse_1.handleError)(error);
986
+ }
987
+ }
988
+ async handleAddParticipants(req) {
989
+ try {
990
+ const { id } = req.params;
991
+ const { adminId, userIds } = req.body;
992
+ if (!id)
993
+ return (0, errorResponse_1.validationError)('Missing required parameter: id');
994
+ if (!adminId)
995
+ return (0, errorResponse_1.validationError)('Missing required field: adminId');
996
+ if (!userIds || !Array.isArray(userIds))
997
+ return (0, errorResponse_1.validationError)('Missing required field: userIds (array)');
998
+ await this.getMessagingService().addParticipants(id, adminId, userIds);
999
+ return { statusCode: 200, response: { message: 'Participants added' } };
1000
+ }
1001
+ catch (error) {
1002
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
1003
+ return this.mapMessagingError(error);
1004
+ return (0, errorResponse_1.handleError)(error);
1005
+ }
1006
+ }
1007
+ async handleRemoveParticipant(req) {
1008
+ try {
1009
+ const { id, userId: targetUserId } = req.params;
1010
+ const typedReq = req;
1011
+ const adminId = typedReq.query['adminId'];
1012
+ if (!id)
1013
+ return (0, errorResponse_1.validationError)('Missing required parameter: id');
1014
+ if (!targetUserId)
1015
+ return (0, errorResponse_1.validationError)('Missing required parameter: userId');
1016
+ if (!adminId)
1017
+ return (0, errorResponse_1.validationError)('Missing required query parameter: adminId');
1018
+ await this.getMessagingService().removeParticipant(id, adminId, targetUserId);
1019
+ return { statusCode: 200, response: { message: 'Participant removed' } };
1020
+ }
1021
+ catch (error) {
1022
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
1023
+ return this.mapMessagingError(error);
1024
+ return (0, errorResponse_1.handleError)(error);
1025
+ }
1026
+ }
1027
+ async handleUpdateGroupSettings(req) {
1028
+ try {
1029
+ const { id } = req.params;
1030
+ const { adminId, name, avatarUrl } = req.body;
1031
+ if (!id)
1032
+ return (0, errorResponse_1.validationError)('Missing required parameter: id');
1033
+ if (!adminId)
1034
+ return (0, errorResponse_1.validationError)('Missing required field: adminId');
1035
+ const updates = {};
1036
+ if (name !== undefined)
1037
+ updates.name = name;
1038
+ if (avatarUrl !== undefined)
1039
+ updates.avatarUrl = avatarUrl;
1040
+ const conversation = await this.getMessagingService().updateGroupSettings(id, adminId, updates);
1041
+ return {
1042
+ statusCode: 200,
1043
+ response: { message: 'Group settings updated', data: conversation },
1044
+ };
1045
+ }
1046
+ catch (error) {
1047
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
1048
+ return this.mapMessagingError(error);
1049
+ return (0, errorResponse_1.handleError)(error);
1050
+ }
1051
+ }
1052
+ async handleForwardMessage(req) {
1053
+ try {
1054
+ const { messageId } = req.params;
1055
+ const { userId, targetConversationId } = req.body;
1056
+ if (!messageId)
1057
+ return (0, errorResponse_1.validationError)('Missing required parameter: messageId');
1058
+ if (!userId)
1059
+ return (0, errorResponse_1.validationError)('Missing required field: userId');
1060
+ if (!targetConversationId)
1061
+ return (0, errorResponse_1.validationError)('Missing required field: targetConversationId');
1062
+ // Forward by sending a new message with forwardedFromId
1063
+ const message = await this.getMessagingService().sendMessage(targetConversationId, userId, '', { forwardedFromId: messageId });
1064
+ return {
1065
+ statusCode: 201,
1066
+ response: { message: 'Message forwarded', data: message },
1067
+ };
1068
+ }
1069
+ catch (error) {
1070
+ if (error instanceof brighthub_lib_1.MessagingServiceError)
1071
+ return this.mapMessagingError(error);
1072
+ return (0, errorResponse_1.handleError)(error);
1073
+ }
1074
+ }
1075
+ }
1076
+ exports.BrightHubMessagingController = BrightHubMessagingController;
1077
+ //# sourceMappingURL=messagingController.js.map