@psavelis/enterprise-blockchain 0.1.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) hide show
  1. package/dist/aid-settlement/application/reconciler.d.ts +13 -0
  2. package/dist/aid-settlement/application/reconciler.d.ts.map +1 -0
  3. package/dist/aid-settlement/application/reconciler.js +77 -0
  4. package/dist/aid-settlement/domain/entities.d.ts +24 -0
  5. package/dist/aid-settlement/domain/entities.d.ts.map +1 -0
  6. package/dist/aid-settlement/domain/entities.js +1 -0
  7. package/dist/aid-settlement/domain/ports.d.ts +10 -0
  8. package/dist/aid-settlement/domain/ports.d.ts.map +1 -0
  9. package/dist/aid-settlement/domain/ports.js +1 -0
  10. package/dist/aid-settlement/index.d.ts +19 -0
  11. package/dist/aid-settlement/index.d.ts.map +1 -0
  12. package/dist/aid-settlement/index.js +23 -0
  13. package/dist/aid-settlement/infrastructure/in-memory-store.d.ts +12 -0
  14. package/dist/aid-settlement/infrastructure/in-memory-store.d.ts.map +1 -0
  15. package/dist/aid-settlement/infrastructure/in-memory-store.js +17 -0
  16. package/dist/credentialing/application/clearance-evaluator.d.ts +10 -0
  17. package/dist/credentialing/application/clearance-evaluator.d.ts.map +1 -0
  18. package/dist/credentialing/application/clearance-evaluator.js +63 -0
  19. package/dist/credentialing/domain/entities.d.ts +28 -0
  20. package/dist/credentialing/domain/entities.d.ts.map +1 -0
  21. package/dist/credentialing/domain/entities.js +1 -0
  22. package/dist/credentialing/domain/ports.d.ts +9 -0
  23. package/dist/credentialing/domain/ports.d.ts.map +1 -0
  24. package/dist/credentialing/domain/ports.js +1 -0
  25. package/dist/credentialing/index.d.ts +19 -0
  26. package/dist/credentialing/index.d.ts.map +1 -0
  27. package/dist/credentialing/index.js +23 -0
  28. package/dist/credentialing/infrastructure/in-memory-store.d.ts +11 -0
  29. package/dist/credentialing/infrastructure/in-memory-store.d.ts.map +1 -0
  30. package/dist/credentialing/infrastructure/in-memory-store.js +14 -0
  31. package/dist/hsm/application/asymmetric-key-service.d.ts +23 -0
  32. package/dist/hsm/application/asymmetric-key-service.d.ts.map +1 -0
  33. package/dist/hsm/application/asymmetric-key-service.js +109 -0
  34. package/dist/hsm/application/envelope-encryption-service.d.ts +18 -0
  35. package/dist/hsm/application/envelope-encryption-service.d.ts.map +1 -0
  36. package/dist/hsm/application/envelope-encryption-service.js +59 -0
  37. package/dist/hsm/application/symmetric-key-service.d.ts +34 -0
  38. package/dist/hsm/application/symmetric-key-service.d.ts.map +1 -0
  39. package/dist/hsm/application/symmetric-key-service.js +107 -0
  40. package/dist/hsm/domain/entities.d.ts +104 -0
  41. package/dist/hsm/domain/entities.d.ts.map +1 -0
  42. package/dist/hsm/domain/entities.js +10 -0
  43. package/dist/hsm/domain/ports.d.ts +20 -0
  44. package/dist/hsm/domain/ports.d.ts.map +1 -0
  45. package/dist/hsm/domain/ports.js +1 -0
  46. package/dist/hsm/index.d.ts +48 -0
  47. package/dist/hsm/index.d.ts.map +1 -0
  48. package/dist/hsm/index.js +97 -0
  49. package/dist/hsm/infrastructure/audit-log-factory.d.ts +59 -0
  50. package/dist/hsm/infrastructure/audit-log-factory.d.ts.map +1 -0
  51. package/dist/hsm/infrastructure/audit-log-factory.js +95 -0
  52. package/dist/hsm/infrastructure/audit-log.d.ts +8 -0
  53. package/dist/hsm/infrastructure/audit-log.d.ts.map +1 -0
  54. package/dist/hsm/infrastructure/audit-log.js +18 -0
  55. package/dist/hsm/infrastructure/file-audit-log.d.ts +55 -0
  56. package/dist/hsm/infrastructure/file-audit-log.d.ts.map +1 -0
  57. package/dist/hsm/infrastructure/file-audit-log.js +128 -0
  58. package/dist/hsm/infrastructure/key-store.d.ts +9 -0
  59. package/dist/hsm/infrastructure/key-store.d.ts.map +1 -0
  60. package/dist/hsm/infrastructure/key-store.js +12 -0
  61. package/dist/hsm/infrastructure/syslog-audit-log.d.ts +64 -0
  62. package/dist/hsm/infrastructure/syslog-audit-log.d.ts.map +1 -0
  63. package/dist/hsm/infrastructure/syslog-audit-log.js +167 -0
  64. package/dist/index.d.ts +22 -0
  65. package/dist/index.d.ts.map +1 -0
  66. package/dist/index.js +37 -0
  67. package/dist/integrations/besu-client/error-mapper.d.ts +9 -0
  68. package/dist/integrations/besu-client/error-mapper.d.ts.map +1 -0
  69. package/dist/integrations/besu-client/error-mapper.js +22 -0
  70. package/dist/integrations/besu-client/index.d.ts +65 -0
  71. package/dist/integrations/besu-client/index.d.ts.map +1 -0
  72. package/dist/integrations/besu-client/index.js +276 -0
  73. package/dist/integrations/besu-client/ports.d.ts +44 -0
  74. package/dist/integrations/besu-client/ports.d.ts.map +1 -0
  75. package/dist/integrations/besu-client/ports.js +1 -0
  76. package/dist/integrations/corda-gateway/index.d.ts +37 -0
  77. package/dist/integrations/corda-gateway/index.d.ts.map +1 -0
  78. package/dist/integrations/corda-gateway/index.js +234 -0
  79. package/dist/integrations/corda-gateway/ports.d.ts +33 -0
  80. package/dist/integrations/corda-gateway/ports.d.ts.map +1 -0
  81. package/dist/integrations/corda-gateway/ports.js +1 -0
  82. package/dist/integrations/fabric-gateway/index.d.ts +78 -0
  83. package/dist/integrations/fabric-gateway/index.d.ts.map +1 -0
  84. package/dist/integrations/fabric-gateway/index.js +214 -0
  85. package/dist/integrations/fabric-gateway/ports.d.ts +50 -0
  86. package/dist/integrations/fabric-gateway/ports.d.ts.map +1 -0
  87. package/dist/integrations/fabric-gateway/ports.js +1 -0
  88. package/dist/integrations/index.d.ts +19 -0
  89. package/dist/integrations/index.d.ts.map +1 -0
  90. package/dist/integrations/index.js +19 -0
  91. package/dist/integrations/shared/env.d.ts +4 -0
  92. package/dist/integrations/shared/env.d.ts.map +1 -0
  93. package/dist/integrations/shared/env.js +24 -0
  94. package/dist/integrations/shared/retry.d.ts +79 -0
  95. package/dist/integrations/shared/retry.d.ts.map +1 -0
  96. package/dist/integrations/shared/retry.js +315 -0
  97. package/dist/mpc/adapters.d.ts +36 -0
  98. package/dist/mpc/adapters.d.ts.map +1 -0
  99. package/dist/mpc/adapters.js +46 -0
  100. package/dist/mpc/crypto.d.ts +2 -0
  101. package/dist/mpc/crypto.d.ts.map +1 -0
  102. package/dist/mpc/crypto.js +2 -0
  103. package/dist/mpc/dsa.d.ts +134 -0
  104. package/dist/mpc/dsa.d.ts.map +1 -0
  105. package/dist/mpc/dsa.js +127 -0
  106. package/dist/mpc/field.d.ts +127 -0
  107. package/dist/mpc/field.d.ts.map +1 -0
  108. package/dist/mpc/field.js +209 -0
  109. package/dist/mpc/hybrid-kem.d.ts +96 -0
  110. package/dist/mpc/hybrid-kem.d.ts.map +1 -0
  111. package/dist/mpc/hybrid-kem.js +136 -0
  112. package/dist/mpc/index.d.ts +135 -0
  113. package/dist/mpc/index.d.ts.map +1 -0
  114. package/dist/mpc/index.js +348 -0
  115. package/dist/mpc/kyber.d.ts +134 -0
  116. package/dist/mpc/kyber.d.ts.map +1 -0
  117. package/dist/mpc/kyber.js +143 -0
  118. package/dist/mpc/ports.d.ts +67 -0
  119. package/dist/mpc/ports.d.ts.map +1 -0
  120. package/dist/mpc/ports.js +9 -0
  121. package/dist/mpc/quantum.d.ts +80 -0
  122. package/dist/mpc/quantum.d.ts.map +1 -0
  123. package/dist/mpc/quantum.js +180 -0
  124. package/dist/p2mr/adapters.d.ts +31 -0
  125. package/dist/p2mr/adapters.d.ts.map +1 -0
  126. package/dist/p2mr/adapters.js +35 -0
  127. package/dist/p2mr/index.d.ts +63 -0
  128. package/dist/p2mr/index.d.ts.map +1 -0
  129. package/dist/p2mr/index.js +59 -0
  130. package/dist/p2mr/merkle-tree.d.ts +109 -0
  131. package/dist/p2mr/merkle-tree.d.ts.map +1 -0
  132. package/dist/p2mr/merkle-tree.js +239 -0
  133. package/dist/p2mr/p2mr-output.d.ts +142 -0
  134. package/dist/p2mr/p2mr-output.d.ts.map +1 -0
  135. package/dist/p2mr/p2mr-output.js +150 -0
  136. package/dist/p2mr/ports.d.ts +52 -0
  137. package/dist/p2mr/ports.d.ts.map +1 -0
  138. package/dist/p2mr/ports.js +9 -0
  139. package/dist/p2mr/script-interpreter.d.ts +92 -0
  140. package/dist/p2mr/script-interpreter.d.ts.map +1 -0
  141. package/dist/p2mr/script-interpreter.js +535 -0
  142. package/dist/p2mr/script-leaf.d.ts +70 -0
  143. package/dist/p2mr/script-leaf.d.ts.map +1 -0
  144. package/dist/p2mr/script-leaf.js +203 -0
  145. package/dist/p2mr/spend-proof.d.ts +95 -0
  146. package/dist/p2mr/spend-proof.d.ts.map +1 -0
  147. package/dist/p2mr/spend-proof.js +358 -0
  148. package/dist/p2mr/types.d.ts +209 -0
  149. package/dist/p2mr/types.d.ts.map +1 -0
  150. package/dist/p2mr/types.js +9 -0
  151. package/dist/privacy/application/view-projector.d.ts +13 -0
  152. package/dist/privacy/application/view-projector.d.ts.map +1 -0
  153. package/dist/privacy/application/view-projector.js +85 -0
  154. package/dist/privacy/domain/entities.d.ts +26 -0
  155. package/dist/privacy/domain/entities.d.ts.map +1 -0
  156. package/dist/privacy/domain/entities.js +1 -0
  157. package/dist/privacy/domain/ports.d.ts +7 -0
  158. package/dist/privacy/domain/ports.d.ts.map +1 -0
  159. package/dist/privacy/domain/ports.js +1 -0
  160. package/dist/privacy/index.d.ts +21 -0
  161. package/dist/privacy/index.d.ts.map +1 -0
  162. package/dist/privacy/index.js +25 -0
  163. package/dist/privacy/infrastructure/in-memory-store.d.ts +8 -0
  164. package/dist/privacy/infrastructure/in-memory-store.d.ts.map +1 -0
  165. package/dist/privacy/infrastructure/in-memory-store.js +7 -0
  166. package/dist/protocols/besu-port.d.ts +80 -0
  167. package/dist/protocols/besu-port.d.ts.map +1 -0
  168. package/dist/protocols/besu-port.js +1 -0
  169. package/dist/protocols/corda-port.d.ts +103 -0
  170. package/dist/protocols/corda-port.d.ts.map +1 -0
  171. package/dist/protocols/corda-port.js +9 -0
  172. package/dist/protocols/credentialing-port.d.ts +11 -0
  173. package/dist/protocols/credentialing-port.d.ts.map +1 -0
  174. package/dist/protocols/credentialing-port.js +1 -0
  175. package/dist/protocols/fabric-port.d.ts +89 -0
  176. package/dist/protocols/fabric-port.d.ts.map +1 -0
  177. package/dist/protocols/fabric-port.js +9 -0
  178. package/dist/protocols/index.d.ts +14 -0
  179. package/dist/protocols/index.d.ts.map +1 -0
  180. package/dist/protocols/index.js +7 -0
  181. package/dist/protocols/p2mr-port.d.ts +159 -0
  182. package/dist/protocols/p2mr-port.d.ts.map +1 -0
  183. package/dist/protocols/p2mr-port.js +12 -0
  184. package/dist/protocols/privacy-port.d.ts +9 -0
  185. package/dist/protocols/privacy-port.d.ts.map +1 -0
  186. package/dist/protocols/privacy-port.js +1 -0
  187. package/dist/protocols/traceability-port.d.ts +12 -0
  188. package/dist/protocols/traceability-port.d.ts.map +1 -0
  189. package/dist/protocols/traceability-port.js +1 -0
  190. package/dist/shared/collection-store.d.ts +12 -0
  191. package/dist/shared/collection-store.d.ts.map +1 -0
  192. package/dist/shared/collection-store.js +26 -0
  193. package/dist/shared/commit.d.ts +24 -0
  194. package/dist/shared/commit.d.ts.map +1 -0
  195. package/dist/shared/commit.js +50 -0
  196. package/dist/shared/crypto.d.ts +2 -0
  197. package/dist/shared/crypto.d.ts.map +1 -0
  198. package/dist/shared/crypto.js +4 -0
  199. package/dist/shared/date.d.ts +2 -0
  200. package/dist/shared/date.d.ts.map +1 -0
  201. package/dist/shared/date.js +3 -0
  202. package/dist/shared/index.d.ts +9 -0
  203. package/dist/shared/index.d.ts.map +1 -0
  204. package/dist/shared/index.js +11 -0
  205. package/dist/shared/logger.d.ts +37 -0
  206. package/dist/shared/logger.d.ts.map +1 -0
  207. package/dist/shared/logger.js +45 -0
  208. package/dist/shared/store.d.ts +25 -0
  209. package/dist/shared/store.d.ts.map +1 -0
  210. package/dist/shared/store.js +18 -0
  211. package/dist/shared/telemetry-sdk.d.ts +26 -0
  212. package/dist/shared/telemetry-sdk.d.ts.map +1 -0
  213. package/dist/shared/telemetry-sdk.js +97 -0
  214. package/dist/shared/telemetry.d.ts +86 -0
  215. package/dist/shared/telemetry.d.ts.map +1 -0
  216. package/dist/shared/telemetry.js +137 -0
  217. package/dist/stark-settlement/application/aggregator-service.d.ts +112 -0
  218. package/dist/stark-settlement/application/aggregator-service.d.ts.map +1 -0
  219. package/dist/stark-settlement/application/aggregator-service.js +256 -0
  220. package/dist/stark-settlement/application/ledger-service.d.ts +114 -0
  221. package/dist/stark-settlement/application/ledger-service.d.ts.map +1 -0
  222. package/dist/stark-settlement/application/ledger-service.js +318 -0
  223. package/dist/stark-settlement/application/settlement-service.d.ts +104 -0
  224. package/dist/stark-settlement/application/settlement-service.d.ts.map +1 -0
  225. package/dist/stark-settlement/application/settlement-service.js +251 -0
  226. package/dist/stark-settlement/domain/entities.d.ts +365 -0
  227. package/dist/stark-settlement/domain/entities.d.ts.map +1 -0
  228. package/dist/stark-settlement/domain/entities.js +29 -0
  229. package/dist/stark-settlement/domain/ports.d.ts +485 -0
  230. package/dist/stark-settlement/domain/ports.d.ts.map +1 -0
  231. package/dist/stark-settlement/domain/ports.js +14 -0
  232. package/dist/stark-settlement/domain/value-objects.d.ts +268 -0
  233. package/dist/stark-settlement/domain/value-objects.d.ts.map +1 -0
  234. package/dist/stark-settlement/domain/value-objects.js +500 -0
  235. package/dist/stark-settlement/index.d.ts +172 -0
  236. package/dist/stark-settlement/index.d.ts.map +1 -0
  237. package/dist/stark-settlement/index.js +193 -0
  238. package/dist/stark-settlement/infrastructure/adapters/audit-adapter.d.ts +52 -0
  239. package/dist/stark-settlement/infrastructure/adapters/audit-adapter.d.ts.map +1 -0
  240. package/dist/stark-settlement/infrastructure/adapters/audit-adapter.js +154 -0
  241. package/dist/stark-settlement/infrastructure/adapters/bitcoin-adapter.d.ts +88 -0
  242. package/dist/stark-settlement/infrastructure/adapters/bitcoin-adapter.d.ts.map +1 -0
  243. package/dist/stark-settlement/infrastructure/adapters/bitcoin-adapter.js +187 -0
  244. package/dist/stark-settlement/infrastructure/adapters/clock-adapter.d.ts +59 -0
  245. package/dist/stark-settlement/infrastructure/adapters/clock-adapter.d.ts.map +1 -0
  246. package/dist/stark-settlement/infrastructure/adapters/clock-adapter.js +85 -0
  247. package/dist/stark-settlement/infrastructure/adapters/dilithium-adapter.d.ts +60 -0
  248. package/dist/stark-settlement/infrastructure/adapters/dilithium-adapter.d.ts.map +1 -0
  249. package/dist/stark-settlement/infrastructure/adapters/dilithium-adapter.js +104 -0
  250. package/dist/stark-settlement/infrastructure/adapters/event-emitter-adapter.d.ts +115 -0
  251. package/dist/stark-settlement/infrastructure/adapters/event-emitter-adapter.d.ts.map +1 -0
  252. package/dist/stark-settlement/infrastructure/adapters/event-emitter-adapter.js +191 -0
  253. package/dist/stark-settlement/infrastructure/adapters/fiat-adapter.d.ts +65 -0
  254. package/dist/stark-settlement/infrastructure/adapters/fiat-adapter.d.ts.map +1 -0
  255. package/dist/stark-settlement/infrastructure/adapters/fiat-adapter.js +207 -0
  256. package/dist/stark-settlement/infrastructure/adapters/mock-stark-adapter.d.ts +73 -0
  257. package/dist/stark-settlement/infrastructure/adapters/mock-stark-adapter.d.ts.map +1 -0
  258. package/dist/stark-settlement/infrastructure/adapters/mock-stark-adapter.js +287 -0
  259. package/dist/stark-settlement/infrastructure/adapters/solana-adapter.d.ts +78 -0
  260. package/dist/stark-settlement/infrastructure/adapters/solana-adapter.d.ts.map +1 -0
  261. package/dist/stark-settlement/infrastructure/adapters/solana-adapter.js +172 -0
  262. package/dist/stark-settlement/infrastructure/adapters/starknet-proof-adapter.d.ts +56 -0
  263. package/dist/stark-settlement/infrastructure/adapters/starknet-proof-adapter.d.ts.map +1 -0
  264. package/dist/stark-settlement/infrastructure/adapters/starknet-proof-adapter.js +261 -0
  265. package/dist/stark-settlement/infrastructure/adapters/stone-proof-adapter.d.ts +125 -0
  266. package/dist/stark-settlement/infrastructure/adapters/stone-proof-adapter.d.ts.map +1 -0
  267. package/dist/stark-settlement/infrastructure/adapters/stone-proof-adapter.js +416 -0
  268. package/dist/stark-settlement/infrastructure/persistence/ledger-store.d.ts +68 -0
  269. package/dist/stark-settlement/infrastructure/persistence/ledger-store.d.ts.map +1 -0
  270. package/dist/stark-settlement/infrastructure/persistence/ledger-store.js +238 -0
  271. package/dist/stark-settlement/infrastructure/persistence/offset-store.d.ts +30 -0
  272. package/dist/stark-settlement/infrastructure/persistence/offset-store.d.ts.map +1 -0
  273. package/dist/stark-settlement/infrastructure/persistence/offset-store.js +57 -0
  274. package/dist/stark-settlement/infrastructure/persistence/outbox-store.d.ts +45 -0
  275. package/dist/stark-settlement/infrastructure/persistence/outbox-store.d.ts.map +1 -0
  276. package/dist/stark-settlement/infrastructure/persistence/outbox-store.js +171 -0
  277. package/dist/traceability/application/recall-assessor.d.ts +13 -0
  278. package/dist/traceability/application/recall-assessor.d.ts.map +1 -0
  279. package/dist/traceability/application/recall-assessor.js +74 -0
  280. package/dist/traceability/domain/entities.d.ts +23 -0
  281. package/dist/traceability/domain/entities.d.ts.map +1 -0
  282. package/dist/traceability/domain/entities.js +1 -0
  283. package/dist/traceability/domain/ports.d.ts +23 -0
  284. package/dist/traceability/domain/ports.d.ts.map +1 -0
  285. package/dist/traceability/domain/ports.js +1 -0
  286. package/dist/traceability/domain/recall.d.ts +12 -0
  287. package/dist/traceability/domain/recall.d.ts.map +1 -0
  288. package/dist/traceability/domain/recall.js +1 -0
  289. package/dist/traceability/index.d.ts +22 -0
  290. package/dist/traceability/index.d.ts.map +1 -0
  291. package/dist/traceability/index.js +26 -0
  292. package/dist/traceability/infrastructure/in-memory-store.d.ts +13 -0
  293. package/dist/traceability/infrastructure/in-memory-store.d.ts.map +1 -0
  294. package/dist/traceability/infrastructure/in-memory-store.js +24 -0
  295. package/package.json +4 -3
@@ -0,0 +1,11 @@
1
+ import type { StaffingAssignment } from "../credentialing/domain/entities.js";
2
+ /**
3
+ * Port for projecting credentialing decisions onto a distributed ledger.
4
+ */
5
+ export interface CredentialingProtocolAdapter<TInvocation> {
6
+ buildAssignmentClearanceFlow(assignment: StaffingAssignment, decision: {
7
+ approved: boolean;
8
+ reasons: string[];
9
+ }): TInvocation;
10
+ }
11
+ //# sourceMappingURL=credentialing-port.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentialing-port.d.ts","sourceRoot":"","sources":["../../src/protocols/credentialing-port.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,4BAA4B,CAAC,WAAW;IACvD,4BAA4B,CAC1B,UAAU,EAAE,kBAAkB,EAC9B,QAAQ,EAAE;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,GACjD,WAAW,CAAC;CAChB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Protocol-level port for Hyperledger Fabric capabilities.
3
+ *
4
+ * This defines what operations are available at the protocol level,
5
+ * independent of specific domain use cases (traceability, privacy, etc.).
6
+ *
7
+ * @see skills/platform-selection.md for protocol selection criteria
8
+ */
9
+ export interface FabricInvocationResult {
10
+ transactionId: string;
11
+ payload: Uint8Array;
12
+ validationCode: number;
13
+ }
14
+ export interface FabricEndorsementPolicy {
15
+ identities: Array<{
16
+ role: string;
17
+ mspId: string;
18
+ }>;
19
+ policy: string;
20
+ }
21
+ /**
22
+ * Port for Fabric chaincode invocation (submit transactions).
23
+ *
24
+ * Implementations handle endorsement collection and commit.
25
+ */
26
+ export interface IFabricSubmitPort {
27
+ /**
28
+ * Submit a transaction to the ledger.
29
+ * @param chaincodeId Chaincode name
30
+ * @param functionName Function to invoke
31
+ * @param args Function arguments
32
+ * @param transientData Private data (not committed to ledger)
33
+ * @returns Transaction result with validation code
34
+ */
35
+ submitTransaction(chaincodeId: string, functionName: string, args: string[], transientData?: Record<string, Uint8Array>): Promise<FabricInvocationResult>;
36
+ }
37
+ /**
38
+ * Port for Fabric chaincode queries (read-only operations).
39
+ */
40
+ export interface IFabricQueryPort {
41
+ /**
42
+ * Evaluate a chaincode function without committing.
43
+ * @param chaincodeId Chaincode name
44
+ * @param functionName Function to evaluate
45
+ * @param args Function arguments
46
+ * @returns Query result payload
47
+ */
48
+ evaluateTransaction(chaincodeId: string, functionName: string, args: string[]): Promise<Uint8Array>;
49
+ }
50
+ /**
51
+ * Port for Fabric private data collection operations.
52
+ */
53
+ export interface IFabricPrivateDataPort {
54
+ /**
55
+ * Store data in a private data collection.
56
+ * @param collectionName Name of the collection
57
+ * @param key Document key
58
+ * @param value Document value
59
+ */
60
+ putPrivateData(collectionName: string, key: string, value: Uint8Array): Promise<void>;
61
+ /**
62
+ * Retrieve data from a private data collection.
63
+ * @param collectionName Name of the collection
64
+ * @param key Document key
65
+ * @returns Document value or undefined if not found
66
+ */
67
+ getPrivateData(collectionName: string, key: string): Promise<Uint8Array | undefined>;
68
+ }
69
+ /**
70
+ * Port for Fabric event subscription.
71
+ */
72
+ export interface IFabricEventPort {
73
+ /**
74
+ * Subscribe to chaincode events.
75
+ * @param chaincodeId Chaincode name
76
+ * @param eventName Event name filter
77
+ * @param callback Event handler
78
+ * @returns Unsubscribe function
79
+ */
80
+ subscribeToEvents(chaincodeId: string, eventName: string, callback: (event: FabricChaincodeEvent) => void): () => void;
81
+ }
82
+ export interface FabricChaincodeEvent {
83
+ chaincodeId: string;
84
+ eventName: string;
85
+ payload: Uint8Array;
86
+ transactionId: string;
87
+ blockNumber: bigint;
88
+ }
89
+ //# sourceMappingURL=fabric-port.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fabric-port.d.ts","sourceRoot":"","sources":["../../src/protocols/fabric-port.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,UAAU,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,KAAK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,MAAM,CAAC;CACrB"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Protocol-level port for Hyperledger Fabric capabilities.
3
+ *
4
+ * This defines what operations are available at the protocol level,
5
+ * independent of specific domain use cases (traceability, privacy, etc.).
6
+ *
7
+ * @see skills/platform-selection.md for protocol selection criteria
8
+ */
9
+ export {};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Protocol adapter interfaces for enterprise blockchain platforms.
3
+ *
4
+ * These ports define the contract between domain logic and
5
+ * platform-specific implementations (Fabric, Besu, Corda).
6
+ */
7
+ export type { TraceabilityProtocolAdapter } from "./traceability-port.js";
8
+ export type { PrivacyProtocolAdapter } from "./privacy-port.js";
9
+ export type { CredentialingProtocolAdapter } from "./credentialing-port.js";
10
+ export type { FabricInvocationResult, FabricEndorsementPolicy, IFabricSubmitPort, IFabricQueryPort, IFabricPrivateDataPort, IFabricEventPort, FabricChaincodeEvent, } from "./fabric-port.js";
11
+ export type { BesuTransactionResult, BesuGasEstimate, IBesuTransactionPort, IBesuQueryPort, IBesuPrivacyPort, } from "./besu-port.js";
12
+ export type { CordaFlowResult, CordaTransactionInfo, ICordaFlowPort, ICordaVaultPort, CordaQueryCriteria, CordaVaultState, ICordaIdentityPort, CordaPartyInfo, } from "./corda-port.js";
13
+ export type { P2MRCreateResult, P2MRSpendResult, P2MROutputStatus, IP2MRCreatePort, IP2MRSpendPort, IP2MRQueryPort, IP2MRProtocolAdapter, P2MRProtocolConfig, } from "./p2mr-port.js";
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/protocols/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAG1E,YAAY,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAGhE,YAAY,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAG5E,YAAY,EACV,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EACV,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,cAAc,EACd,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACV,eAAe,EACf,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,cAAc,GACf,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Protocol adapter interfaces for enterprise blockchain platforms.
3
+ *
4
+ * These ports define the contract between domain logic and
5
+ * platform-specific implementations (Fabric, Besu, Corda).
6
+ */
7
+ export {};
@@ -0,0 +1,159 @@
1
+ /**
2
+ * P2MR (Pay-to-Merkle-Root) Protocol Port
3
+ *
4
+ * Defines the interface for P2MR operations across different blockchain protocols.
5
+ * Implementations provide protocol-specific handling while the domain layer
6
+ * remains protocol-agnostic.
7
+ *
8
+ * P2MR is BIP-360-inspired: outputs store only a Merkle root of spending conditions,
9
+ * keeping public keys private until spend time. This eliminates the quantum
10
+ * "harvest now, decrypt later" threat.
11
+ */
12
+ import type { P2MROutput, SpendProof } from "../p2mr/types.js";
13
+ /**
14
+ * Result of creating a P2MR output on-chain.
15
+ */
16
+ export interface P2MRCreateResult {
17
+ /** Output ID assigned by the protocol. */
18
+ outputId: string;
19
+ /** Transaction/block identifier. */
20
+ txRef: string;
21
+ /** Block number or ledger height. */
22
+ blockHeight: number;
23
+ /** Protocol-specific metadata. */
24
+ metadata?: Record<string, unknown>;
25
+ }
26
+ /**
27
+ * Result of spending a P2MR output.
28
+ */
29
+ export interface P2MRSpendResult {
30
+ /** Output ID that was spent. */
31
+ outputId: string;
32
+ /** Transaction/block identifier. */
33
+ txRef: string;
34
+ /** Block number or ledger height. */
35
+ blockHeight: number;
36
+ /** Recipient address/identity. */
37
+ recipient: string;
38
+ /** Value transferred. */
39
+ value: bigint;
40
+ }
41
+ /**
42
+ * Query result for an output.
43
+ */
44
+ export interface P2MROutputStatus {
45
+ /** Whether the output exists. */
46
+ exists: boolean;
47
+ /** Whether the output is unspent. */
48
+ unspent: boolean;
49
+ /** The output data (if exists). */
50
+ output?: P2MROutput;
51
+ /** Block height when created. */
52
+ createdAtBlock?: number;
53
+ /** Block height when spent (if spent). */
54
+ spentAtBlock?: number;
55
+ }
56
+ /**
57
+ * Port for creating P2MR outputs.
58
+ *
59
+ * Implementations handle protocol-specific transaction submission and
60
+ * output registration.
61
+ */
62
+ export interface IP2MRCreatePort {
63
+ /**
64
+ * Create a new P2MR output by committing to a Merkle root.
65
+ *
66
+ * @param merkleRoot - SHA-256 Merkle root of the script tree.
67
+ * @param value - Value to lock in the output.
68
+ * @param metadataHash - Optional hash of off-chain metadata.
69
+ * @returns Creation result with output ID and transaction reference.
70
+ */
71
+ createOutput(merkleRoot: string, value: bigint, metadataHash?: string): Promise<P2MRCreateResult>;
72
+ /**
73
+ * Create an output with a specific ID (for deterministic outputs).
74
+ *
75
+ * @param outputId - Desired output ID.
76
+ * @param merkleRoot - SHA-256 Merkle root of the script tree.
77
+ * @param value - Value to lock in the output.
78
+ * @param metadataHash - Optional hash of off-chain metadata.
79
+ */
80
+ createOutputWithId(outputId: string, merkleRoot: string, value: bigint, metadataHash?: string): Promise<P2MRCreateResult>;
81
+ }
82
+ /**
83
+ * Port for spending P2MR outputs.
84
+ *
85
+ * Implementations handle spend proof validation and value transfer.
86
+ */
87
+ export interface IP2MRSpendPort {
88
+ /**
89
+ * Spend a P2MR output using a spend proof.
90
+ *
91
+ * The proof includes:
92
+ * - The revealed script leaf (spending condition)
93
+ * - Merkle proof from leaf to root
94
+ * - Witness data (public keys, signatures)
95
+ *
96
+ * Off-chain: ML-DSA-65 signature verification
97
+ * On-chain: Merkle proof verification, value transfer
98
+ *
99
+ * @param proof - Complete spend proof.
100
+ * @param recipient - Recipient address/identity.
101
+ * @returns Spend result with transaction reference.
102
+ */
103
+ spend(proof: SpendProof, recipient: string): Promise<P2MRSpendResult>;
104
+ }
105
+ /**
106
+ * Port for querying P2MR outputs.
107
+ */
108
+ export interface IP2MRQueryPort {
109
+ /**
110
+ * Get the status of an output.
111
+ *
112
+ * @param outputId - Output ID to query.
113
+ * @returns Output status including spent/unspent.
114
+ */
115
+ getOutputStatus(outputId: string): Promise<P2MROutputStatus>;
116
+ /**
117
+ * Verify a Merkle proof off-chain (without submitting transaction).
118
+ *
119
+ * @param leafHash - SHA-256 hash of the script leaf.
120
+ * @param merkleRoot - Expected Merkle root.
121
+ * @param proof - Array of sibling hashes with positions.
122
+ * @returns True if the proof is valid.
123
+ */
124
+ verifyMerkleProof(leafHash: string, merkleRoot: string, proof: Array<{
125
+ hash: string;
126
+ position: "left" | "right";
127
+ }>): Promise<boolean>;
128
+ }
129
+ /**
130
+ * Combined port for full P2MR operations.
131
+ */
132
+ export interface IP2MRProtocolAdapter extends IP2MRCreatePort, IP2MRSpendPort, IP2MRQueryPort {
133
+ /**
134
+ * Protocol identifier.
135
+ */
136
+ readonly protocol: "besu" | "fabric" | "corda";
137
+ /**
138
+ * Protocol-specific configuration.
139
+ */
140
+ readonly config: P2MRProtocolConfig;
141
+ }
142
+ /**
143
+ * Configuration for P2MR protocol adapter.
144
+ */
145
+ export interface P2MRProtocolConfig {
146
+ /** Contract address (Besu) or chaincode name (Fabric). */
147
+ contractAddress?: string;
148
+ chaincodeName?: string;
149
+ /** Channel name (Fabric). */
150
+ channelName?: string;
151
+ /** Network/chain ID (Besu). */
152
+ chainId?: number;
153
+ /** Relayer configuration (for ML-DSA verification). */
154
+ relayer?: {
155
+ endpoint: string;
156
+ publicKey?: string;
157
+ };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E,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * P2MR (Pay-to-Merkle-Root) Protocol Port
3
+ *
4
+ * Defines the interface for P2MR operations across different blockchain protocols.
5
+ * Implementations provide protocol-specific handling while the domain layer
6
+ * remains protocol-agnostic.
7
+ *
8
+ * P2MR is BIP-360-inspired: outputs store only a Merkle root of spending conditions,
9
+ * keeping public keys private until spend time. This eliminates the quantum
10
+ * "harvest now, decrypt later" threat.
11
+ */
12
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { PurchaseOrder, SharedOrderView } from "../privacy/domain/entities.js";
2
+ /**
3
+ * Port for anchoring privacy-preserving order views on a distributed ledger.
4
+ */
5
+ export interface PrivacyProtocolAdapter<TInvocation> {
6
+ anchorOrder(order: PurchaseOrder, auditProof: string): TInvocation;
7
+ publishAudienceView(view: SharedOrderView): TInvocation;
8
+ }
9
+ //# sourceMappingURL=privacy-port.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privacy-port.d.ts","sourceRoot":"","sources":["../../src/protocols/privacy-port.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EAChB,MAAM,+BAA+B,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,WAAW;IACjD,WAAW,CAAC,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,GAAG,WAAW,CAAC;IACnE,mBAAmB,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW,CAAC;CACzD"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { ProductLot, Shipment, TelemetryReading } from "../traceability/domain/entities.js";
2
+ /**
3
+ * Port for projecting traceability commands onto a distributed ledger.
4
+ *
5
+ * Implementations translate domain operations into platform-specific
6
+ * invocations (Fabric chaincode, Besu contract calls, etc.).
7
+ */
8
+ export interface TraceabilityProtocolAdapter<TInvocation> {
9
+ createLotCommand(lot: ProductLot): TInvocation;
10
+ recordShipmentCommand(shipment: Shipment, reading?: TelemetryReading): TInvocation;
11
+ }
12
+ //# sourceMappingURL=traceability-port.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traceability-port.d.ts","sourceRoot":"","sources":["../../src/protocols/traceability-port.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,QAAQ,EACR,gBAAgB,EACjB,MAAM,oCAAoC,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,WAAW,2BAA2B,CAAC,WAAW;IACtD,gBAAgB,CAAC,GAAG,EAAE,UAAU,GAAG,WAAW,CAAC;IAC/C,qBAAqB,CACnB,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,gBAAgB,GACzB,WAAW,CAAC;CAChB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Append-only collection store for grouping items by key.
3
+ * Provides immutable read access via defensive copies.
4
+ */
5
+ export declare class CollectionStore<K, V> {
6
+ private readonly store;
7
+ append(key: K, item: V): void;
8
+ getAll(key: K): readonly V[];
9
+ keys(): IterableIterator<K>;
10
+ private keySet;
11
+ }
12
+ //# sourceMappingURL=collection-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection-store.d.ts","sourceRoot":"","sources":["../../src/shared/collection-store.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,qBAAa,eAAe,CAAC,CAAC,EAAE,CAAC;IAC/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA+B;IAErD,MAAM,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI;IAM7B,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,SAAS,CAAC,EAAE;IAI5B,IAAI,IAAI,gBAAgB,CAAC,CAAC,CAAC;IAI3B,OAAO,CAAC,MAAM;CAOf"}
@@ -0,0 +1,26 @@
1
+ import { InMemoryStore } from "./store.js";
2
+ /**
3
+ * Append-only collection store for grouping items by key.
4
+ * Provides immutable read access via defensive copies.
5
+ */
6
+ export class CollectionStore {
7
+ store = new InMemoryStore();
8
+ append(key, item) {
9
+ const existing = this.store.get(key) ?? [];
10
+ existing.push(item);
11
+ this.store.set(key, existing);
12
+ }
13
+ getAll(key) {
14
+ return [...(this.store.get(key) ?? [])];
15
+ }
16
+ keys() {
17
+ return this.keySet().values();
18
+ }
19
+ keySet() {
20
+ const result = new Set();
21
+ for (const [key] of this.store.entries()) {
22
+ result.add(key);
23
+ }
24
+ return result;
25
+ }
26
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Create a cryptographic commitment for a secret share.
3
+ * The commitment binds the share value to a specific party and index,
4
+ * preventing substitution attacks.
5
+ *
6
+ * @param partyId - Identifier of the share holder
7
+ * @param index - Share index in the polynomial evaluation
8
+ * @param value - Share value (number for demo mode, bigint for production)
9
+ * @param nonce - Random nonce for hiding the value
10
+ */
11
+ export declare function commitShare(partyId: string, index: number, value: number | bigint, nonce: string): string;
12
+ /**
13
+ * Timing-safe comparison of two hex strings.
14
+ * Prevents timing attacks by ensuring constant-time comparison
15
+ * regardless of where the first difference occurs.
16
+ *
17
+ * The comparison decodes hex to bytes before comparing, ensuring
18
+ * the function behavior matches its documented contract.
19
+ *
20
+ * IMPORTANT: Both strings must be the same length (e.g., SHA-256 hashes).
21
+ * Malformed hex inputs (odd length, non-hex characters) return false.
22
+ */
23
+ export declare function timingSafeCompare(a: string, b: string): boolean;
24
+ //# sourceMappingURL=commit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commit.d.ts","sourceRoot":"","sources":["../../src/shared/commit.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,KAAK,EAAE,MAAM,GACZ,MAAM,CAIR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CA0B/D"}
@@ -0,0 +1,50 @@
1
+ import { timingSafeEqual } from "node:crypto";
2
+ import { sha256hex } from "./crypto.js";
3
+ /**
4
+ * Create a cryptographic commitment for a secret share.
5
+ * The commitment binds the share value to a specific party and index,
6
+ * preventing substitution attacks.
7
+ *
8
+ * @param partyId - Identifier of the share holder
9
+ * @param index - Share index in the polynomial evaluation
10
+ * @param value - Share value (number for demo mode, bigint for production)
11
+ * @param nonce - Random nonce for hiding the value
12
+ */
13
+ export function commitShare(partyId, index, value, nonce) {
14
+ // Convert bigint to string for consistent hashing
15
+ const valueStr = typeof value === "bigint" ? value.toString() : String(value);
16
+ return sha256hex(`${nonce}:${partyId}:${index}:${valueStr}`);
17
+ }
18
+ /**
19
+ * Timing-safe comparison of two hex strings.
20
+ * Prevents timing attacks by ensuring constant-time comparison
21
+ * regardless of where the first difference occurs.
22
+ *
23
+ * The comparison decodes hex to bytes before comparing, ensuring
24
+ * the function behavior matches its documented contract.
25
+ *
26
+ * IMPORTANT: Both strings must be the same length (e.g., SHA-256 hashes).
27
+ * Malformed hex inputs (odd length, non-hex characters) return false.
28
+ */
29
+ export function timingSafeCompare(a, b) {
30
+ // Length check is not constant-time but reveals no secret data
31
+ if (a.length !== b.length) {
32
+ return false;
33
+ }
34
+ // Hex strings must have even length
35
+ if (a.length % 2 !== 0) {
36
+ return false;
37
+ }
38
+ // Validate hex format before decoding
39
+ const hexRegex = /^[0-9a-fA-F]*$/;
40
+ if (!hexRegex.test(a) || !hexRegex.test(b)) {
41
+ return false;
42
+ }
43
+ const bufA = Buffer.from(a, "hex");
44
+ const bufB = Buffer.from(b, "hex");
45
+ // Defensive check (should always be true given the above validation)
46
+ if (bufA.length !== bufB.length) {
47
+ return false;
48
+ }
49
+ return timingSafeEqual(bufA, bufB);
50
+ }
@@ -0,0 +1,2 @@
1
+ export declare function sha256hex(value: string): string;
2
+ //# sourceMappingURL=crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/shared/crypto.ts"],"names":[],"mappings":"AAEA,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C"}
@@ -0,0 +1,4 @@
1
+ import { createHash } from "node:crypto";
2
+ export function sha256hex(value) {
3
+ return createHash("sha256").update(value).digest("hex");
4
+ }
@@ -0,0 +1,2 @@
1
+ export declare function daysUntil(from: Date, to: Date): number;
2
+ //# sourceMappingURL=date.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/shared/date.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,GAAG,MAAM,CAEtD"}
@@ -0,0 +1,3 @@
1
+ export function daysUntil(from, to) {
2
+ return Math.ceil((to.getTime() - from.getTime()) / (1000 * 60 * 60 * 24));
3
+ }
@@ -0,0 +1,9 @@
1
+ export { sha256hex } from "./crypto.js";
2
+ export { commitShare, timingSafeCompare } from "./commit.js";
3
+ export { daysUntil } from "./date.js";
4
+ export type { ReadonlyStore, Store } from "./store.js";
5
+ export { InMemoryStore } from "./store.js";
6
+ export { CollectionStore } from "./collection-store.js";
7
+ export type { Logger, LogFields } from "./logger.js";
8
+ export { ConsoleLogger, noopLogger } from "./logger.js";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,11 @@
1
+ export { sha256hex } from "./crypto.js";
2
+ export { commitShare, timingSafeCompare } from "./commit.js";
3
+ export { daysUntil } from "./date.js";
4
+ export { InMemoryStore } from "./store.js";
5
+ export { CollectionStore } from "./collection-store.js";
6
+ export { ConsoleLogger, noopLogger } from "./logger.js";
7
+ // NOTE: Telemetry is NOT re-exported here to preserve optional peer dependency.
8
+ // @opentelemetry/api is an optional peer dep and importing telemetry.ts at the
9
+ // top level would fail when OTEL is not installed. Import telemetry directly:
10
+ // import "@psavelis/enterprise-blockchain/shared/telemetry-sdk"; // SDK init (side-effect)
11
+ // import { createTracer, ... } from "@psavelis/enterprise-blockchain/shared/telemetry";
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Minimal structured logging port.
3
+ *
4
+ * Domain modules accept an optional Logger instance via constructor injection.
5
+ * When no logger is provided, operations run silently (zero behavior change).
6
+ * Teams can swap in Pino, Winston, or OpenTelemetry at integration time.
7
+ */
8
+ export interface LogFields {
9
+ operation?: string;
10
+ entityId?: string;
11
+ result?: string;
12
+ durationMs?: number;
13
+ [key: string]: string | number | boolean | undefined;
14
+ }
15
+ export interface Logger {
16
+ info(msg: string, fields?: LogFields): void;
17
+ warn(msg: string, fields?: LogFields): void;
18
+ error(msg: string, fields?: LogFields): void;
19
+ }
20
+ /**
21
+ * No-op logger that silently discards all messages.
22
+ * Used as the default when no logger is provided.
23
+ */
24
+ export declare const noopLogger: Logger;
25
+ /**
26
+ * Simple console-based structured logger.
27
+ * Outputs JSON lines for machine consumption.
28
+ */
29
+ export declare class ConsoleLogger implements Logger {
30
+ private readonly prefix;
31
+ constructor(prefix?: string);
32
+ info(msg: string, fields?: LogFields): void;
33
+ warn(msg: string, fields?: LogFields): void;
34
+ error(msg: string, fields?: LogFields): void;
35
+ private log;
36
+ }
37
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/shared/logger.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CACtD;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5C,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5C,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;CAC9C;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,MAIxB,CAAC;AAEF;;;GAGG;AACH,qBAAa,aAAc,YAAW,MAAM;IAC1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEpB,MAAM,SAAK;IAIvB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,IAAI;IAI3C,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,IAAI;IAI3C,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,IAAI;IAI5C,OAAO,CAAC,GAAG;CAkBZ"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * No-op logger that silently discards all messages.
3
+ * Used as the default when no logger is provided.
4
+ */
5
+ export const noopLogger = {
6
+ info() { },
7
+ warn() { },
8
+ error() { },
9
+ };
10
+ /**
11
+ * Simple console-based structured logger.
12
+ * Outputs JSON lines for machine consumption.
13
+ */
14
+ export class ConsoleLogger {
15
+ prefix;
16
+ constructor(prefix = "") {
17
+ this.prefix = prefix;
18
+ }
19
+ info(msg, fields) {
20
+ this.log("info", msg, fields);
21
+ }
22
+ warn(msg, fields) {
23
+ this.log("warn", msg, fields);
24
+ }
25
+ error(msg, fields) {
26
+ this.log("error", msg, fields);
27
+ }
28
+ log(level, msg, fields) {
29
+ // Spread caller fields first, then apply reserved keys so they cannot
30
+ // be accidentally overridden by user-supplied LogFields.
31
+ const entry = {
32
+ ...fields,
33
+ level,
34
+ ts: new Date().toISOString(),
35
+ ...(this.prefix ? { module: this.prefix } : {}),
36
+ msg,
37
+ };
38
+ const writer = level === "error"
39
+ ? console.error
40
+ : level === "warn"
41
+ ? console.warn
42
+ : console.log;
43
+ writer(JSON.stringify(entry));
44
+ }
45
+ }