@brightchain/brightchain-api-lib 0.25.0 → 0.27.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 (130) hide show
  1. package/package.json +4 -3
  2. package/src/lib/appConstants.d.ts +1 -1
  3. package/src/lib/appConstants.js +1 -1
  4. package/src/lib/application.d.ts +3 -14
  5. package/src/lib/application.d.ts.map +1 -1
  6. package/src/lib/application.js +91 -34
  7. package/src/lib/application.js.map +1 -1
  8. package/src/lib/constants.d.ts.map +1 -1
  9. package/src/lib/constants.js +1 -1
  10. package/src/lib/constants.js.map +1 -1
  11. package/src/lib/databaseInit.d.ts +7 -11
  12. package/src/lib/databaseInit.d.ts.map +1 -1
  13. package/src/lib/databaseInit.js +41 -107
  14. package/src/lib/databaseInit.js.map +1 -1
  15. package/src/lib/datastore/block-document-store-factory.d.ts +3 -0
  16. package/src/lib/datastore/block-document-store-factory.d.ts.map +1 -1
  17. package/src/lib/datastore/block-document-store-factory.js +15 -18
  18. package/src/lib/datastore/block-document-store-factory.js.map +1 -1
  19. package/src/lib/datastore/block-document-store.d.ts +2 -191
  20. package/src/lib/datastore/block-document-store.d.ts.map +1 -1
  21. package/src/lib/datastore/block-document-store.js +4 -628
  22. package/src/lib/datastore/block-document-store.js.map +1 -1
  23. package/src/lib/datastore/document-store.d.ts +1 -62
  24. package/src/lib/datastore/document-store.d.ts.map +1 -1
  25. package/src/lib/datastore/memory-document-store.d.ts +1 -8
  26. package/src/lib/datastore/memory-document-store.d.ts.map +1 -1
  27. package/src/lib/datastore/memory-document-store.js +3 -214
  28. package/src/lib/datastore/memory-document-store.js.map +1 -1
  29. package/src/lib/environment.d.ts +4 -47
  30. package/src/lib/environment.d.ts.map +1 -1
  31. package/src/lib/environment.js +2 -136
  32. package/src/lib/environment.js.map +1 -1
  33. package/src/lib/interfaces/environment.d.ts +3 -25
  34. package/src/lib/interfaces/environment.d.ts.map +1 -1
  35. package/src/lib/interfaces/responses/emailGatewayResponses.d.ts +30 -0
  36. package/src/lib/interfaces/responses/emailGatewayResponses.d.ts.map +1 -0
  37. package/src/lib/interfaces/responses/emailGatewayResponses.js +3 -0
  38. package/src/lib/interfaces/responses/emailGatewayResponses.js.map +1 -0
  39. package/src/lib/interfaces/responses/index.d.ts +1 -0
  40. package/src/lib/interfaces/responses/index.d.ts.map +1 -1
  41. package/src/lib/middleware/index.d.ts +1 -1
  42. package/src/lib/middleware/index.d.ts.map +1 -1
  43. package/src/lib/middleware/index.js +3 -2
  44. package/src/lib/middleware/index.js.map +1 -1
  45. package/src/lib/middleware/validateBody.d.ts +1 -12
  46. package/src/lib/middleware/validateBody.d.ts.map +1 -1
  47. package/src/lib/middleware/validateBody.js +4 -32
  48. package/src/lib/middleware/validateBody.js.map +1 -1
  49. package/src/lib/middlewares.d.ts.map +1 -1
  50. package/src/lib/middlewares.js +7 -1
  51. package/src/lib/middlewares.js.map +1 -1
  52. package/src/lib/plugins/brightchain-database-plugin.d.ts +27 -79
  53. package/src/lib/plugins/brightchain-database-plugin.d.ts.map +1 -1
  54. package/src/lib/plugins/brightchain-database-plugin.js +32 -103
  55. package/src/lib/plugins/brightchain-database-plugin.js.map +1 -1
  56. package/src/lib/routers/app.d.ts.map +1 -1
  57. package/src/lib/routers/app.js +1 -0
  58. package/src/lib/routers/app.js.map +1 -1
  59. package/src/lib/services/emailGateway/antiSpamFilter.d.ts +229 -0
  60. package/src/lib/services/emailGateway/antiSpamFilter.d.ts.map +1 -0
  61. package/src/lib/services/emailGateway/antiSpamFilter.js +325 -0
  62. package/src/lib/services/emailGateway/antiSpamFilter.js.map +1 -0
  63. package/src/lib/services/emailGateway/bounceProcessor.d.ts +182 -0
  64. package/src/lib/services/emailGateway/bounceProcessor.d.ts.map +1 -0
  65. package/src/lib/services/emailGateway/bounceProcessor.js +391 -0
  66. package/src/lib/services/emailGateway/bounceProcessor.js.map +1 -0
  67. package/src/lib/services/emailGateway/emailAuthVerifier.d.ts +99 -0
  68. package/src/lib/services/emailGateway/emailAuthVerifier.d.ts.map +1 -0
  69. package/src/lib/services/emailGateway/emailAuthVerifier.js +202 -0
  70. package/src/lib/services/emailGateway/emailAuthVerifier.js.map +1 -0
  71. package/src/lib/services/emailGateway/emailGatewayConfig.d.ts +74 -0
  72. package/src/lib/services/emailGateway/emailGatewayConfig.d.ts.map +1 -0
  73. package/src/lib/services/emailGateway/emailGatewayConfig.js +107 -0
  74. package/src/lib/services/emailGateway/emailGatewayConfig.js.map +1 -0
  75. package/src/lib/services/emailGateway/emailGatewayService.d.ts +209 -0
  76. package/src/lib/services/emailGateway/emailGatewayService.d.ts.map +1 -0
  77. package/src/lib/services/emailGateway/emailGatewayService.js +254 -0
  78. package/src/lib/services/emailGateway/emailGatewayService.js.map +1 -0
  79. package/src/lib/services/emailGateway/gatewayObservability.d.ts +123 -0
  80. package/src/lib/services/emailGateway/gatewayObservability.d.ts.map +1 -0
  81. package/src/lib/services/emailGateway/gatewayObservability.js +186 -0
  82. package/src/lib/services/emailGateway/gatewayObservability.js.map +1 -0
  83. package/src/lib/services/emailGateway/inboundProcessor.d.ts +113 -0
  84. package/src/lib/services/emailGateway/inboundProcessor.d.ts.map +1 -0
  85. package/src/lib/services/emailGateway/inboundProcessor.js +298 -0
  86. package/src/lib/services/emailGateway/inboundProcessor.js.map +1 -0
  87. package/src/lib/services/emailGateway/index.d.ts +23 -0
  88. package/src/lib/services/emailGateway/index.d.ts.map +1 -0
  89. package/src/lib/services/emailGateway/index.js +26 -0
  90. package/src/lib/services/emailGateway/index.js.map +1 -0
  91. package/src/lib/services/emailGateway/outboundDeliveryWorker.d.ts +122 -0
  92. package/src/lib/services/emailGateway/outboundDeliveryWorker.d.ts.map +1 -0
  93. package/src/lib/services/emailGateway/outboundDeliveryWorker.js +110 -0
  94. package/src/lib/services/emailGateway/outboundDeliveryWorker.js.map +1 -0
  95. package/src/lib/services/emailGateway/outboundQueue.d.ts +135 -0
  96. package/src/lib/services/emailGateway/outboundQueue.d.ts.map +1 -0
  97. package/src/lib/services/emailGateway/outboundQueue.js +227 -0
  98. package/src/lib/services/emailGateway/outboundQueue.js.map +1 -0
  99. package/src/lib/services/emailGateway/outboundQueueStore.d.ts +110 -0
  100. package/src/lib/services/emailGateway/outboundQueueStore.d.ts.map +1 -0
  101. package/src/lib/services/emailGateway/outboundQueueStore.js +131 -0
  102. package/src/lib/services/emailGateway/outboundQueueStore.js.map +1 -0
  103. package/src/lib/services/emailGateway/recipientLookupService.d.ts +146 -0
  104. package/src/lib/services/emailGateway/recipientLookupService.d.ts.map +1 -0
  105. package/src/lib/services/emailGateway/recipientLookupService.js +307 -0
  106. package/src/lib/services/emailGateway/recipientLookupService.js.map +1 -0
  107. package/src/lib/services/emailGateway/retryBackoff.d.ts +79 -0
  108. package/src/lib/services/emailGateway/retryBackoff.d.ts.map +1 -0
  109. package/src/lib/services/emailGateway/retryBackoff.js +77 -0
  110. package/src/lib/services/emailGateway/retryBackoff.js.map +1 -0
  111. package/src/lib/services/index.d.ts +1 -0
  112. package/src/lib/services/index.d.ts.map +1 -1
  113. package/src/lib/services/index.js +1 -0
  114. package/src/lib/services/index.js.map +1 -1
  115. package/src/lib/services/quorumDatabaseAdapter.d.ts +7 -1
  116. package/src/lib/services/quorumDatabaseAdapter.d.ts.map +1 -1
  117. package/src/lib/services/quorumDatabaseAdapter.js +83 -0
  118. package/src/lib/services/quorumDatabaseAdapter.js.map +1 -1
  119. package/src/lib/services/sessionAdapter.d.ts +2 -61
  120. package/src/lib/services/sessionAdapter.d.ts.map +1 -1
  121. package/src/lib/services/sessionAdapter.js +2 -102
  122. package/src/lib/services/sessionAdapter.js.map +1 -1
  123. package/src/lib/shared-types.d.ts +7 -15
  124. package/src/lib/shared-types.d.ts.map +1 -1
  125. package/src/lib/types/backend-id.d.ts +1 -2
  126. package/src/lib/types/backend-id.d.ts.map +1 -1
  127. package/src/lib/validation/userValidation.d.ts +2 -43
  128. package/src/lib/validation/userValidation.d.ts.map +1 -1
  129. package/src/lib/validation/userValidation.js +6 -144
  130. package/src/lib/validation/userValidation.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/interfaces/environment.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,cAAc,EACd,sBAAsB,EACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EACL,YAAY,IAAI,gBAAgB,EAChC,WAAW,EACZ,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,WAAW,uBAAwB,SAAQ,sBAAsB;IACrE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAqB,SAAQ,sBAAsB;IAClE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY,CAAC,GAAG,SAAS,UAAU,CAClD,SAAQ,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAC5D,OAAO,EAAE,GAAG,CAAC;IACb,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC;IAExC;;;;OAIG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,GAAG,EAAE,eAAe,CAAC;IAErB;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,oBAAoB,EAAE,SAAS,SAAS,EAAE,CAAC;IAE3C;;OAEG;IACH,mBAAmB,EAAE,SAAS,CAAC;IAE/B;;;OAGG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAEhC;;;OAGG;IACH,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;IAExC;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAC;IAE/B;;;OAGG;IACH,WAAW,CAAC,EAAE,uBAAuB,CAAC;IAEtC;;;OAGG;IACH,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CACjC"}
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/interfaces/environment.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,cAAc,EACf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EACL,YAAY,IAAI,gBAAgB,EAChC,WAAW,EACZ,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,iCAAiC,CAAC;AACzC,YAAY,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,CAAC;AAE9D,MAAM,WAAW,YAAY,CAAC,GAAG,SAAS,UAAU,CAClD,SAAQ,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAC5D,OAAO,EAAE,GAAG,CAAC;IACb,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC;IAExC;;;;OAIG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,GAAG,EAAE,eAAe,CAAC;IAErB;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,oBAAoB,EAAE,SAAS,SAAS,EAAE,CAAC;IAE3C;;OAEG;IACH,mBAAmB,EAAE,SAAS,CAAC;IAE/B;;;OAGG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAEhC;;;OAGG;IACH,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;IAExC;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAC;IAE/B;;;OAGG;IACH,WAAW,CAAC,EAAE,uBAAuB,CAAC;IAEtC;;;OAGG;IACH,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CACjC"}
@@ -0,0 +1,30 @@
1
+ import type { IBounceNotification, IInboundEmailResult, IOutboundEmailStatus } from '@brightchain/brightchain-lib';
2
+ import type { IApiMessageResponse } from '@digitaldefiance/node-express-suite';
3
+ /**
4
+ * API response for outbound email delivery status queries.
5
+ * Wraps the shared IOutboundEmailStatus DTO with the standard API message envelope.
6
+ *
7
+ * @see Requirements 11.2
8
+ */
9
+ export interface IOutboundEmailStatusApiResponse extends IApiMessageResponse {
10
+ data: IOutboundEmailStatus<string>;
11
+ }
12
+ /**
13
+ * API response for bounce notification retrieval.
14
+ * Wraps the shared IBounceNotification DTO with the standard API message envelope.
15
+ *
16
+ * @see Requirements 11.2
17
+ */
18
+ export interface IBounceNotificationApiResponse extends IApiMessageResponse {
19
+ data: IBounceNotification<string>;
20
+ }
21
+ /**
22
+ * API response for inbound email processing results.
23
+ * Wraps the shared IInboundEmailResult DTO with the standard API message envelope.
24
+ *
25
+ * @see Requirements 11.2
26
+ */
27
+ export interface IInboundEmailResultApiResponse extends IApiMessageResponse {
28
+ data: IInboundEmailResult<string>;
29
+ }
30
+ //# sourceMappingURL=emailGatewayResponses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emailGatewayResponses.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/interfaces/responses/emailGatewayResponses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAE/E;;;;;GAKG;AACH,MAAM,WAAW,+BAAgC,SAAQ,mBAAmB;IAC1E,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAC;CACpC;AAED;;;;;GAKG;AACH,MAAM,WAAW,8BAA+B,SAAQ,mBAAmB;IACzE,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC;CACnC;AAED;;;;;GAKG;AACH,MAAM,WAAW,8BAA+B,SAAQ,mBAAmB;IACzE,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC;CACnC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=emailGatewayResponses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emailGatewayResponses.js","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/interfaces/responses/emailGatewayResponses.ts"],"names":[],"mappings":""}
@@ -25,5 +25,6 @@ export type * from './api-store-cbl-response';
25
25
  export type * from './api-sync-request-response';
26
26
  export type * from './block-data-response';
27
27
  export type * from './block-location-response';
28
+ export type * from './emailGatewayResponses';
28
29
  export type * from './brighthub';
29
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/interfaces/responses/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,6BAA6B,CAAC;AACjD,mBAAmB,0BAA0B,CAAC;AAC9C,mBAAmB,2BAA2B,CAAC;AAC/C,mBAAmB,gCAAgC,CAAC;AACpD,mBAAmB,+BAA+B,CAAC;AACnD,mBAAmB,aAAa,CAAC;AACjC,mBAAmB,gCAAgC,CAAC;AACpD,mBAAmB,0BAA0B,CAAC;AAC9C,mBAAmB,yBAAyB,CAAC;AAC7C,mBAAmB,uBAAuB,CAAC;AAC3C,mBAAmB,2BAA2B,CAAC;AAC/C,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,wBAAwB,CAAC;AAC5C,mBAAmB,yBAAyB,CAAC;AAC7C,mBAAmB,gCAAgC,CAAC;AACpD,mBAAmB,0BAA0B,CAAC;AAC9C,mBAAmB,yBAAyB,CAAC;AAC7C,mBAAmB,8BAA8B,CAAC;AAClD,mBAAmB,6BAA6B,CAAC;AACjD,mBAAmB,gCAAgC,CAAC;AACpD,mBAAmB,6BAA6B,CAAC;AACjD,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,0BAA0B,CAAC;AAC9C,mBAAmB,6BAA6B,CAAC;AACjD,mBAAmB,uBAAuB,CAAC;AAC3C,mBAAmB,2BAA2B,CAAC;AAG/C,mBAAmB,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/interfaces/responses/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,6BAA6B,CAAC;AACjD,mBAAmB,0BAA0B,CAAC;AAC9C,mBAAmB,2BAA2B,CAAC;AAC/C,mBAAmB,gCAAgC,CAAC;AACpD,mBAAmB,+BAA+B,CAAC;AACnD,mBAAmB,aAAa,CAAC;AACjC,mBAAmB,gCAAgC,CAAC;AACpD,mBAAmB,0BAA0B,CAAC;AAC9C,mBAAmB,yBAAyB,CAAC;AAC7C,mBAAmB,uBAAuB,CAAC;AAC3C,mBAAmB,2BAA2B,CAAC;AAC/C,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,wBAAwB,CAAC;AAC5C,mBAAmB,yBAAyB,CAAC;AAC7C,mBAAmB,gCAAgC,CAAC;AACpD,mBAAmB,0BAA0B,CAAC;AAC9C,mBAAmB,yBAAyB,CAAC;AAC7C,mBAAmB,8BAA8B,CAAC;AAClD,mBAAmB,6BAA6B,CAAC;AACjD,mBAAmB,gCAAgC,CAAC;AACpD,mBAAmB,6BAA6B,CAAC;AACjD,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,0BAA0B,CAAC;AAC9C,mBAAmB,6BAA6B,CAAC;AACjD,mBAAmB,uBAAuB,CAAC;AAC3C,mBAAmB,2BAA2B,CAAC;AAG/C,mBAAmB,yBAAyB,CAAC;AAG7C,mBAAmB,aAAa,CAAC"}
@@ -1,2 +1,2 @@
1
- export { validateBody } from './validateBody';
1
+ export { validateBody } from '@brightchain/node-express-suite';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/middleware/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateBody = void 0;
4
- var validateBody_1 = require("./validateBody");
5
- Object.defineProperty(exports, "validateBody", { enumerable: true, get: function () { return validateBody_1.validateBody; } });
4
+ // Re-export middleware from @brightchain/node-express-suite
5
+ var node_express_suite_1 = require("@brightchain/node-express-suite");
6
+ Object.defineProperty(exports, "validateBody", { enumerable: true, get: function () { return node_express_suite_1.validateBody; } });
6
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/middleware/index.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAArC,4GAAA,YAAY,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/middleware/index.ts"],"names":[],"mappings":";;;AAAA,4DAA4D;AAC5D,sEAA+D;AAAtD,kHAAA,YAAY,OAAA"}
@@ -1,13 +1,2 @@
1
- import { BrandedInterfaceDefinition } from '@digitaldefiance/branded-interface';
2
- import type { NextFunction, Request, Response } from 'express';
3
- /**
4
- * Express middleware factory that validates the request body against a
5
- * BrandedInterfaceDefinition using safeParseInterface().
6
- *
7
- * On success: attaches the branded instance to `req.brandedBody` and calls `next()`.
8
- * On failure: responds with HTTP 400 and a JSON error body.
9
- *
10
- * Requirements: 6.1, 6.2, 6.3, 6.4, 6.5
11
- */
12
- export declare function validateBody<T extends Record<string, unknown>>(definition: BrandedInterfaceDefinition<T>): (req: Request, res: Response, next: NextFunction) => void;
1
+ export { validateBody } from '@brightchain/node-express-suite';
13
2
  //# sourceMappingURL=validateBody.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validateBody.d.ts","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/middleware/validateBody.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAE3B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE/D;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5D,UAAU,EAAE,0BAA0B,CAAC,CAAC,CAAC,IAEjC,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,KAAG,IAAI,CAmB/D"}
1
+ {"version":3,"file":"validateBody.d.ts","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/middleware/validateBody.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC"}
@@ -1,35 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateBody = validateBody;
4
- const branded_interface_1 = require("@digitaldefiance/branded-interface");
5
- /**
6
- * Express middleware factory that validates the request body against a
7
- * BrandedInterfaceDefinition using safeParseInterface().
8
- *
9
- * On success: attaches the branded instance to `req.brandedBody` and calls `next()`.
10
- * On failure: responds with HTTP 400 and a JSON error body.
11
- *
12
- * Requirements: 6.1, 6.2, 6.3, 6.4, 6.5
13
- */
14
- function validateBody(definition) {
15
- return (req, res, next) => {
16
- if (!req.body || typeof req.body !== 'object' || Array.isArray(req.body)) {
17
- res
18
- .status(400)
19
- .json({ error: 'Request body is missing or not an object' });
20
- return;
21
- }
22
- const result = (0, branded_interface_1.safeParseInterface)(req.body, definition);
23
- if (!result.success) {
24
- res.status(400).json({
25
- error: result.error.message,
26
- code: result.error.code,
27
- fieldErrors: result.error.fieldErrors ?? [],
28
- });
29
- return;
30
- }
31
- req.brandedBody = result.value;
32
- next();
33
- };
34
- }
3
+ exports.validateBody = void 0;
4
+ // Re-export validateBody middleware from @brightchain/node-express-suite
5
+ var node_express_suite_1 = require("@brightchain/node-express-suite");
6
+ Object.defineProperty(exports, "validateBody", { enumerable: true, get: function () { return node_express_suite_1.validateBody; } });
35
7
  //# sourceMappingURL=validateBody.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validateBody.js","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/middleware/validateBody.ts"],"names":[],"mappings":";;AAeA,oCAsBC;AArCD,0EAG4C;AAG5C;;;;;;;;GAQG;AACH,SAAgB,YAAY,CAC1B,UAAyC;IAEzC,OAAO,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAQ,EAAE;QAC/D,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACzE,GAAG;iBACA,MAAM,CAAC,GAAG,CAAC;iBACX,IAAI,CAAC,EAAE,KAAK,EAAE,0CAA0C,EAAE,CAAC,CAAC;YAC/D,OAAO;QACT,CAAC;QACD,MAAM,MAAM,GAAG,IAAA,sCAAkB,EAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACxD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACnB,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO;gBAC3B,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI;gBACvB,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC,WAAW,IAAI,EAAE;aAC5C,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QACA,GAA0C,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC;QACvE,IAAI,EAAE,CAAC;IACT,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"validateBody.js","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/middleware/validateBody.ts"],"names":[],"mappings":";;;AAAA,yEAAyE;AACzE,sEAA+D;AAAtD,kHAAA,YAAY,OAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"middlewares.d.ts","sourceRoot":"","sources":["../../../../brightchain-api-lib/src/lib/middlewares.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,WAAW,EAMZ,MAAM,SAAS,CAAC;AAIjB,qBAAa,WAAW;IACtB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAGnC;IAEF;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAwBzC;IAEF;;;OAGG;WACW,IAAI,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI;CAmD3C"}
1
+ {"version":3,"file":"middlewares.d.ts","sourceRoot":"","sources":["../../../../brightchain-api-lib/src/lib/middlewares.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,WAAW,EAMZ,MAAM,SAAS,CAAC;AAIjB,qBAAa,WAAW;IACtB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAGnC;IAEF;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAwBzC;IAEF;;;OAGG;WACW,IAAI,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI;CAyD3C"}
@@ -53,7 +53,13 @@ class Middlewares {
53
53
  contentSecurityPolicy: {
54
54
  directives: {
55
55
  defaultSrc: ["'self'"],
56
- imgSrc: ["'self'", 'https://flagcdn.com', 'data:', 'blob:'],
56
+ imgSrc: [
57
+ "'self'",
58
+ 'https://flagcdn.com',
59
+ 'data:',
60
+ 'blob:',
61
+ 'https://raw.githubusercontent.com',
62
+ ],
57
63
  connectSrc: [
58
64
  "'self'",
59
65
  'http://localhost:3000',
@@ -1 +1 @@
1
- {"version":3,"file":"middlewares.js","sourceRoot":"","sources":["../../../../brightchain-api-lib/src/lib/middlewares.ts"],"names":[],"mappings":";;;;AAAA,wDAAwB;AACxB,mCAAqC;AACrC,qCAOiB;AACjB,4DAA4B;AAG5B,MAAa,WAAW;IACtB;;OAEG;IACK,MAAM,CAAU,aAAa,GAAwB;QAC3D,uBAAuB;QACvB,wBAAwB;KACzB,CAAC;IAEF;;;;OAIG;IACK,MAAM,CAAU,mBAAmB,GAAG,CAC5C,GAAqB,EACrB,QAGS,EACT,EAAE;QACF,IAAI,WAA6B,CAAC;QAClC,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC;QAClC,IACE,MAAM;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C,UAAW,GAAgB,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG;wBACnD,uDAAuD,EAAE,cAAc;qBACxE;oBACD,QAAQ,EAAE;wBACR,QAAQ;wBACR,iBAAiB;wBACjB,8BAA8B;qBAC/B;oBACD,OAAO,EAAE;wBACP,QAAQ;wBACR,2BAA2B;wBAC3B,8BAA8B;qBAC/B;oBACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;iBACrB;aACF;SACF,CAAC,CACH,CAAC;QACF,cAAc;QACd,GAAG,CAAC,GAAG,CAAC,IAAA,cAAI,EAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAC;QAC/C,6CAA6C;QAC7C,GAAG,CAAC,GAAG,CAAC,IAAA,cAAI,GAAE,CAAC,CAAC;QAChB,mDAAmD;QACnD,GAAG,CAAC,GAAG,CAAC,IAAA,oBAAU,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1C,CAAC;;AA9FH,kCA+FC"}
1
+ {"version":3,"file":"middlewares.js","sourceRoot":"","sources":["../../../../brightchain-api-lib/src/lib/middlewares.ts"],"names":[],"mappings":";;;;AAAA,wDAAwB;AACxB,mCAAqC;AACrC,qCAOiB;AACjB,4DAA4B;AAG5B,MAAa,WAAW;IACtB;;OAEG;IACK,MAAM,CAAU,aAAa,GAAwB;QAC3D,uBAAuB;QACvB,wBAAwB;KACzB,CAAC;IAEF;;;;OAIG;IACK,MAAM,CAAU,mBAAmB,GAAG,CAC5C,GAAqB,EACrB,QAGS,EACT,EAAE;QACF,IAAI,WAA6B,CAAC;QAClC,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC;QAClC,IACE,MAAM;YACN,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;gBACnC,IAAI,CAAC,YAAY,MAAM,EAAE,CAAC;oBACxB,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACxB,CA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BACD,OAAO,EAAE;wBACP,QAAQ;wBACR,2BAA2B;wBAC3B,8BAA8B;qBAC/B;oBACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;iBACrB;aACF;SACF,CAAC,CACH,CAAC;QACF,cAAc;QACd,GAAG,CAAC,GAAG,CAAC,IAAA,cAAI,EAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAC;QAC/C,6CAA6C;QAC7C,GAAG,CAAC,GAAG,CAAC,IAAA,cAAI,GAAE,CAAC,CAAC;QAChB,mDAAmD;QACnD,GAAG,CAAC,GAAG,CAAC,IAAA,oBAAU,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1C,CAAC;;AApGH,kCAqGC"}
@@ -1,38 +1,26 @@
1
1
  /**
2
2
  * @fileoverview BrightChain database plugin for the express-suite plugin architecture.
3
3
  *
4
- * Implements IDatabasePlugin<TID> to encapsulate the BrightChain database stack
5
- * lifecycle: block stores, BrightDb, member/energy stores, and the
6
- * authentication provider. The plugin is registered via Application.useDatabasePlugin()
7
- * and participates in the standard plugin lifecycle (connect → init → stop).
8
- *
9
- * BrightDb already implements IDatabase from express-suite, so the plugin's
10
- * `database` property returns the BrightDb instance directly — no adapter needed.
4
+ * Extends BrightDbDatabasePlugin from @brightchain/node-express-suite with
5
+ * domain-specific store initialization (MemberStore, EnergyAccountStore),
6
+ * RBAC seeding, and the BrightChain authentication provider.
11
7
  *
12
8
  * @module plugins/brightchain-database-plugin
13
9
  */
14
- import type { IBlockStore, IBrightChainInitResult, IBrightChainMemberInitInput } from '@brightchain/brightchain-lib';
10
+ import type { IBrightChainInitResult, IBrightChainMemberInitInput } from '@brightchain/brightchain-lib';
15
11
  import { EnergyAccountStore, MemberStore } from '@brightchain/brightchain-lib';
16
12
  import type { BrightDb } from '@brightchain/db';
13
+ import { BrightDbDatabasePlugin, type IBrightDbDatabasePluginOptions } from '@brightchain/node-express-suite';
17
14
  import type { PlatformID } from '@digitaldefiance/node-ecies-lib';
18
- import type { IApplication, IAuthenticationProvider, IDatabasePlugin } from '@digitaldefiance/node-express-suite';
19
- import type { IDatabase } from '@digitaldefiance/suite-core-lib';
15
+ import type { IApplication } from '@digitaldefiance/node-express-suite';
20
16
  import type { Environment } from '../environment';
21
17
  import type { IBrightChainMemberInitConfig } from '../interfaces/member-init-config';
22
18
  import { type IRbacUserInput } from '../services/rbac-input-builder';
23
19
  /**
24
- * BrightChain database plugin implementing IDatabasePlugin<TID>.
25
- *
26
- * Owns the full database lifecycle:
27
- * - connect() → calls brightchainDatabaseInit() and stores backend references
28
- * - init(app) → creates BrightChainAuthenticationProvider
29
- * - stop() → delegates to disconnect()
30
- * - disconnect() → releases all references (idempotent)
31
- *
32
- * Typed accessors (blockStore, memberStore, energyStore, brightDb)
33
- * throw descriptive errors when the plugin is not connected.
20
+ * BrightChain-specific database plugin options.
21
+ * Extends the generic BrightDB plugin options.
34
22
  */
35
- export interface IBrightChainDatabasePluginOptions {
23
+ export interface IBrightChainDatabasePluginOptions extends IBrightDbDatabasePluginOptions {
36
24
  /**
37
25
  * When true, skip the automatic production seed in connect().
38
26
  * Use this when the caller (e.g. brightchain-inituserdb) will perform
@@ -40,31 +28,22 @@ export interface IBrightChainDatabasePluginOptions {
40
28
  */
41
29
  skipAutoSeed?: boolean;
42
30
  }
43
- export declare class BrightChainDatabasePlugin<TID extends PlatformID> implements IDatabasePlugin<TID> {
31
+ /**
32
+ * BrightChain database plugin extending BrightDbDatabasePlugin.
33
+ *
34
+ * Adds domain-specific functionality on top of the generic BrightDB lifecycle:
35
+ * - MemberStore and EnergyAccountStore initialization
36
+ * - RBAC seeding (seedWithRbac, seedProductionIfEmpty)
37
+ * - BrightChainAuthenticationProvider creation
38
+ * - Domain-specific dev store initialization
39
+ */
40
+ export declare class BrightChainDatabasePlugin<TID extends PlatformID> extends BrightDbDatabasePlugin<TID> {
44
41
  readonly name = "brightchain-database";
45
- readonly version = "1.0.0";
46
- private readonly _environment;
47
- private readonly _skipAutoSeed;
48
- private _connected;
49
- private _blockStore;
50
- private _brightDb;
51
42
  private _memberStore;
52
43
  private _energyStore;
53
- private _authProvider;
54
44
  /** Stored result from the most recent seedWithRbac() / initializeDevStore() call. */
55
45
  private _lastInitResult;
56
46
  constructor(environment: Environment<TID>, options?: IBrightChainDatabasePluginOptions);
57
- /**
58
- * The IDatabase instance this plugin manages.
59
- * BrightDb implements IDatabase directly, so no adapter is needed.
60
- * @throws Error if the plugin is not connected.
61
- */
62
- get database(): IDatabase;
63
- /**
64
- * Authentication provider created during init().
65
- * Returns undefined before init() is called.
66
- */
67
- get authenticationProvider(): IAuthenticationProvider<TID> | undefined;
68
47
  /**
69
48
  * The result from the most recent seedWithRbac() / initializeDevStore() call.
70
49
  * Useful in tests to retrieve credentials (e.g. memberMnemonic) without
@@ -74,22 +53,21 @@ export declare class BrightChainDatabasePlugin<TID extends PlatformID> implement
74
53
  /**
75
54
  * Connect the BrightChain database stack.
76
55
  *
77
- * Calls brightchainDatabaseInit(environment) and stores the resulting
78
- * backend references (blockStore, BrightDb, memberStore, energyStore).
56
+ * Uses the domain-specific brightchainDatabaseInit (from api-lib) which
57
+ * wraps the generic init and adds MemberStore + EnergyAccountStore via
58
+ * the modelRegistrations callback.
59
+ *
60
+ * Does NOT call super.connect() because the domain init handles everything.
79
61
  *
80
62
  * @param _uri - Ignored; BrightChain uses environment-based configuration.
81
63
  * @throws Error if brightchainDatabaseInit() returns a failure result.
82
64
  */
83
65
  connect(_uri?: string): Promise<void>;
84
66
  /**
85
- * Disconnect and release all backend references.
67
+ * Disconnect and release all backend references (including domain stores).
86
68
  * Idempotent — calling when already disconnected completes without error.
87
69
  */
88
70
  disconnect(): Promise<void>;
89
- /**
90
- * Whether the database is currently connected.
91
- */
92
- isConnected(): boolean;
93
71
  /**
94
72
  * Initialize the plugin after connection.
95
73
  * Creates the BrightChainAuthenticationProvider and stores it
@@ -98,47 +76,17 @@ export declare class BrightChainDatabasePlugin<TID extends PlatformID> implement
98
76
  * @param app - The application instance (must implement IBrightChainApplication).
99
77
  */
100
78
  init(app: IApplication<TID>): Promise<void>;
101
- /**
102
- * Stop the plugin. Delegates to disconnect() for cleanup.
103
- */
104
- stop(): Promise<void>;
105
79
  /**
106
80
  * Provision an ephemeral dev/test block store.
107
- *
108
- * Called by Application.start() before connect() when
109
- * environment.devDatabase is truthy. BrightChain doesn't use
110
- * connection URIs — the memory vs disk decision is driven by
111
- * environment.blockStorePath (absent → memory). This hook
112
- * signals that we're in dev mode and returns an empty string
113
- * (no URI concept for block stores).
114
81
  */
115
82
  setupDevStore(): Promise<string>;
116
- /**
117
- * Tear down the ephemeral dev/test block store.
118
- *
119
- * Called during stop() flow. Our disconnect() already releases
120
- * all in-memory references, so this is a no-op beyond logging.
121
- */
122
- teardownDevStore(): Promise<void>;
123
83
  /**
124
84
  * Seed the dev database after connection.
125
85
  *
126
- * Called by Application.start() after connect() and init() when
127
- * environment.devDatabase is truthy. Uses RbacInputBuilder to generate
128
- * ephemeral credentials and calls initializeWithRbac() for a fully
129
- * functional dev database. Prints credentials so dev users can log in.
86
+ * Uses RbacInputBuilder to generate ephemeral credentials and calls
87
+ * initializeWithRbac() for a fully functional dev database.
130
88
  */
131
89
  initializeDevStore(): Promise<IBrightChainInitResult<TID, BrightDb>>;
132
- /**
133
- * The block store backing the BrightChain database.
134
- * @throws Error if the plugin is not connected.
135
- */
136
- get blockStore(): IBlockStore;
137
- /**
138
- * The BrightDb instance (implements IDatabase).
139
- * @throws Error if the plugin is not connected.
140
- */
141
- get brightDb(): BrightDb;
142
90
  /**
143
91
  * The member store for user/member operations.
144
92
  * @throws Error if the plugin is not connected.
@@ -1 +1 @@
1
- {"version":3,"file":"brightchain-database-plugin.d.ts","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/plugins/brightchain-database-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,sBAAsB,EACtB,2BAA2B,EAE5B,MA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C,CAAC;KAC7B;IAqED;;;;OAIG;IACG,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAOzC;;;;;;;;;;;;OAYG;IACG,YAAY,CAChB,gBAAgB,EAAE,OAAO,GACxB,OAAO,CAAC,sBAAsB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAuFjD;;;;;;OAMG;IACG,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;CAc7C"}
1
+ {"version":3,"file":"brightchain-database-plugin.d.ts","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/plugins/brightchain-database-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAEV,sBAAsB,EACtB,2BAA2B,EAE5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEL,kBAAkB,EAElB,WAAW,EACZ,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,sBAAsB,EACtB,KAAK,8BAA8B,EACpC,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAGxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAGrF,OAAO,EACL,KAAK,cAAc,EAEpB,MAAM,gCAAgC,CAAC;AAExC;;;GAGG;AACH,MAAM,WAAW,iCACf,SAAQ,8BAA8B;IACtC;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,qBAAa,yBAAyB,CAAC,GAAG,SAAS,UAAU,CAC3D,SAAQ,sBAAsB,CAAC,GAAG,CAAC;IAEnC,SAAyB,IAAI,0BAA0B;IAEvD,OAAO,CAAC,YAAY,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AAsB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAuFjD;;;;;;OAMG;IACG,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;CAc7C"}
@@ -2,19 +2,16 @@
2
2
  /**
3
3
  * @fileoverview BrightChain database plugin for the express-suite plugin architecture.
4
4
  *
5
- * Implements IDatabasePlugin<TID> to encapsulate the BrightChain database stack
6
- * lifecycle: block stores, BrightDb, member/energy stores, and the
7
- * authentication provider. The plugin is registered via Application.useDatabasePlugin()
8
- * and participates in the standard plugin lifecycle (connect → init → stop).
9
- *
10
- * BrightDb already implements IDatabase from express-suite, so the plugin's
11
- * `database` property returns the BrightDb instance directly — no adapter needed.
5
+ * Extends BrightDbDatabasePlugin from @brightchain/node-express-suite with
6
+ * domain-specific store initialization (MemberStore, EnergyAccountStore),
7
+ * RBAC seeding, and the BrightChain authentication provider.
12
8
  *
13
9
  * @module plugins/brightchain-database-plugin
14
10
  */
15
11
  Object.defineProperty(exports, "__esModule", { value: true });
16
12
  exports.BrightChainDatabasePlugin = void 0;
17
13
  const brightchain_lib_1 = require("@brightchain/brightchain-lib");
14
+ const node_express_suite_1 = require("@brightchain/node-express-suite");
18
15
  const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
19
16
  const node_ecies_lib_1 = require("@digitaldefiance/node-ecies-lib");
20
17
  const crypto_1 = require("crypto");
@@ -22,42 +19,25 @@ const databaseInit_1 = require("../databaseInit");
22
19
  const services_1 = require("../services");
23
20
  const brightchain_authentication_provider_1 = require("../services/brightchain-authentication-provider");
24
21
  const rbac_input_builder_1 = require("../services/rbac-input-builder");
25
- class BrightChainDatabasePlugin {
22
+ /**
23
+ * BrightChain database plugin extending BrightDbDatabasePlugin.
24
+ *
25
+ * Adds domain-specific functionality on top of the generic BrightDB lifecycle:
26
+ * - MemberStore and EnergyAccountStore initialization
27
+ * - RBAC seeding (seedWithRbac, seedProductionIfEmpty)
28
+ * - BrightChainAuthenticationProvider creation
29
+ * - Domain-specific dev store initialization
30
+ */
31
+ class BrightChainDatabasePlugin extends node_express_suite_1.BrightDbDatabasePlugin {
26
32
  name = 'brightchain-database';
27
- version = '1.0.0';
28
- _environment;
29
- _skipAutoSeed;
30
- _connected = false;
31
- _blockStore = null;
32
- _brightDb = null;
33
33
  _memberStore = null;
34
34
  _energyStore = null;
35
- _authProvider = null;
36
35
  /** Stored result from the most recent seedWithRbac() / initializeDevStore() call. */
37
36
  _lastInitResult = null;
38
37
  constructor(environment, options = {}) {
39
- this._environment = environment;
40
- this._skipAutoSeed = options.skipAutoSeed ?? false;
41
- }
42
- // ── IDatabasePlugin contract ──────────────────────────────────────
43
- /**
44
- * The IDatabase instance this plugin manages.
45
- * BrightDb implements IDatabase directly, so no adapter is needed.
46
- * @throws Error if the plugin is not connected.
47
- */
48
- get database() {
49
- if (!this._brightDb) {
50
- throw new Error('BrightChainDatabasePlugin: cannot access "database" — plugin is not connected. Call connect() first.');
51
- }
52
- return this._brightDb;
53
- }
54
- /**
55
- * Authentication provider created during init().
56
- * Returns undefined before init() is called.
57
- */
58
- get authenticationProvider() {
59
- return this._authProvider ?? undefined;
38
+ super(environment, options);
60
39
  }
40
+ // ── Overrides ─────────────────────────────────────────────────────
61
41
  /**
62
42
  * The result from the most recent seedWithRbac() / initializeDevStore() call.
63
43
  * Useful in tests to retrieve credentials (e.g. memberMnemonic) without
@@ -69,8 +49,11 @@ class BrightChainDatabasePlugin {
69
49
  /**
70
50
  * Connect the BrightChain database stack.
71
51
  *
72
- * Calls brightchainDatabaseInit(environment) and stores the resulting
73
- * backend references (blockStore, BrightDb, memberStore, energyStore).
52
+ * Uses the domain-specific brightchainDatabaseInit (from api-lib) which
53
+ * wraps the generic init and adds MemberStore + EnergyAccountStore via
54
+ * the modelRegistrations callback.
55
+ *
56
+ * Does NOT call super.connect() because the domain init handles everything.
74
57
  *
75
58
  * @param _uri - Ignored; BrightChain uses environment-based configuration.
76
59
  * @throws Error if brightchainDatabaseInit() returns a failure result.
@@ -97,25 +80,16 @@ class BrightChainDatabasePlugin {
97
80
  }
98
81
  }
99
82
  /**
100
- * Disconnect and release all backend references.
83
+ * Disconnect and release all backend references (including domain stores).
101
84
  * Idempotent — calling when already disconnected completes without error.
102
85
  */
103
86
  async disconnect() {
104
87
  if (!this._connected) {
105
88
  return;
106
89
  }
107
- this._blockStore = null;
108
- this._brightDb = null;
109
90
  this._memberStore = null;
110
91
  this._energyStore = null;
111
- this._authProvider = null;
112
- this._connected = false;
113
- }
114
- /**
115
- * Whether the database is currently connected.
116
- */
117
- isConnected() {
118
- return this._connected;
92
+ await super.disconnect();
119
93
  }
120
94
  /**
121
95
  * Initialize the plugin after connection.
@@ -126,44 +100,22 @@ class BrightChainDatabasePlugin {
126
100
  */
127
101
  async init(app) {
128
102
  this._authProvider = new brightchain_authentication_provider_1.BrightChainAuthenticationProvider(app);
129
- }
130
- /**
131
- * Stop the plugin. Delegates to disconnect() for cleanup.
132
- */
133
- async stop() {
134
- await this.disconnect();
103
+ // Delegate to base class — triggers initializeDevStore() in dev mode
104
+ await super.init(app);
135
105
  }
136
106
  // ── Dev store lifecycle hooks ─────────────────────────────────────
137
107
  /**
138
108
  * Provision an ephemeral dev/test block store.
139
- *
140
- * Called by Application.start() before connect() when
141
- * environment.devDatabase is truthy. BrightChain doesn't use
142
- * connection URIs — the memory vs disk decision is driven by
143
- * environment.blockStorePath (absent → memory). This hook
144
- * signals that we're in dev mode and returns an empty string
145
- * (no URI concept for block stores).
146
109
  */
147
110
  async setupDevStore() {
148
111
  console.log('[BrightChain] Dev database mode — using ephemeral MemoryBlockStore + InMemoryHeadRegistry.');
149
112
  return '';
150
113
  }
151
- /**
152
- * Tear down the ephemeral dev/test block store.
153
- *
154
- * Called during stop() flow. Our disconnect() already releases
155
- * all in-memory references, so this is a no-op beyond logging.
156
- */
157
- async teardownDevStore() {
158
- // disconnect() handles all cleanup — nothing extra needed
159
- }
160
114
  /**
161
115
  * Seed the dev database after connection.
162
116
  *
163
- * Called by Application.start() after connect() and init() when
164
- * environment.devDatabase is truthy. Uses RbacInputBuilder to generate
165
- * ephemeral credentials and calls initializeWithRbac() for a fully
166
- * functional dev database. Prints credentials so dev users can log in.
117
+ * Uses RbacInputBuilder to generate ephemeral credentials and calls
118
+ * initializeWithRbac() for a fully functional dev database.
167
119
  */
168
120
  async initializeDevStore() {
169
121
  const result = await this.seedWithRbac(true);
@@ -174,27 +126,7 @@ class BrightChainDatabasePlugin {
174
126
  }
175
127
  return result;
176
128
  }
177
- // ── Typed accessors ───────────────────────────────────────────────
178
- /**
179
- * The block store backing the BrightChain database.
180
- * @throws Error if the plugin is not connected.
181
- */
182
- get blockStore() {
183
- if (!this._blockStore) {
184
- throw new Error('BrightChainDatabasePlugin: cannot access "blockStore" — plugin is not connected. Call connect() first.');
185
- }
186
- return this._blockStore;
187
- }
188
- /**
189
- * The BrightDb instance (implements IDatabase).
190
- * @throws Error if the plugin is not connected.
191
- */
192
- get brightDb() {
193
- if (!this._brightDb) {
194
- throw new Error('BrightChainDatabasePlugin: cannot access "brightDb" — plugin is not connected. Call connect() first.');
195
- }
196
- return this._brightDb;
197
- }
129
+ // ── Domain-specific typed accessors ───────────────────────────────
198
130
  /**
199
131
  * The member store for user/member operations.
200
132
  * @throws Error if the plugin is not connected.
@@ -215,7 +147,7 @@ class BrightChainDatabasePlugin {
215
147
  }
216
148
  return this._energyStore;
217
149
  }
218
- // ── Private helpers ───────────────────────────────────────────────
150
+ // ── Domain-specific helpers ───────────────────────────────────────
219
151
  /**
220
152
  * Build an IBrightChainMemberInitConfig from the environment.
221
153
  *
@@ -275,8 +207,7 @@ class BrightChainDatabasePlugin {
275
207
  fullId: env.systemId,
276
208
  type: ecies_lib_1.MemberType.System,
277
209
  username: env.get('SYSTEM_USERNAME') ?? 'system',
278
- email: env.get('SYSTEM_EMAIL') ??
279
- `system@${env.emailSender.split('@')[1] ?? 'brightchain.org'}`,
210
+ email: env.systemEmail.email,
280
211
  roleId: env.systemRoleId ?? generateId(),
281
212
  userRoleId: env.systemUserRoleId ?? generateId(),
282
213
  roleName: 'System',
@@ -291,8 +222,7 @@ class BrightChainDatabasePlugin {
291
222
  fullId: env.adminId,
292
223
  type: ecies_lib_1.MemberType.User,
293
224
  username: env.get('ADMIN_USERNAME') ?? 'admin',
294
- email: env.get('ADMIN_EMAIL') ??
295
- `admin@${env.emailSender.split('@')[1] ?? 'brightchain.org'}`,
225
+ email: env.adminEmail.email,
296
226
  roleId: env.adminRoleId ?? generateId(),
297
227
  userRoleId: env.adminUserRoleId ?? generateId(),
298
228
  roleName: 'Admin',
@@ -307,8 +237,7 @@ class BrightChainDatabasePlugin {
307
237
  fullId: env.memberId,
308
238
  type: ecies_lib_1.MemberType.User,
309
239
  username: env.get('MEMBER_USERNAME') ?? 'member',
310
- email: env.get('MEMBER_EMAIL') ??
311
- `member@${env.emailSender.split('@')[1] ?? 'brightchain.org'}`,
240
+ email: env.memberEmail.email,
312
241
  roleId: env.memberRoleId ?? generateId(),
313
242
  userRoleId: env.memberUserRoleId ?? generateId(),
314
243
  roleName: 'Member',