@brightchain/brightchain-lib 0.19.0 โ†’ 0.21.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 (281) hide show
  1. package/package.json +6 -2
  2. package/src/lib/documents/member/memberProfileHydration.d.ts.map +1 -1
  3. package/src/lib/documents/member/memberProfileHydration.js +6 -0
  4. package/src/lib/documents/member/memberProfileHydration.js.map +1 -1
  5. package/src/lib/enumerations/brightChainStrings.d.ts +39 -0
  6. package/src/lib/enumerations/brightChainStrings.d.ts.map +1 -1
  7. package/src/lib/enumerations/brightChainStrings.js +47 -0
  8. package/src/lib/enumerations/brightChainStrings.js.map +1 -1
  9. package/src/lib/enumerations/identityValidationErrorType.d.ts +11 -0
  10. package/src/lib/enumerations/identityValidationErrorType.d.ts.map +1 -0
  11. package/src/lib/enumerations/identityValidationErrorType.js +15 -0
  12. package/src/lib/enumerations/identityValidationErrorType.js.map +1 -0
  13. package/src/lib/enumerations/index.d.ts +4 -0
  14. package/src/lib/enumerations/index.d.ts.map +1 -1
  15. package/src/lib/enumerations/index.js +5 -0
  16. package/src/lib/enumerations/index.js.map +1 -1
  17. package/src/lib/enumerations/memberStatusType.d.ts +2 -1
  18. package/src/lib/enumerations/memberStatusType.d.ts.map +1 -1
  19. package/src/lib/enumerations/memberStatusType.js +1 -0
  20. package/src/lib/enumerations/memberStatusType.js.map +1 -1
  21. package/src/lib/enumerations/proposalActionType.d.ts +22 -0
  22. package/src/lib/enumerations/proposalActionType.d.ts.map +1 -0
  23. package/src/lib/enumerations/proposalActionType.js +26 -0
  24. package/src/lib/enumerations/proposalActionType.js.map +1 -0
  25. package/src/lib/enumerations/proposalStatus.d.ts +14 -0
  26. package/src/lib/enumerations/proposalStatus.d.ts.map +1 -0
  27. package/src/lib/enumerations/proposalStatus.js +18 -0
  28. package/src/lib/enumerations/proposalStatus.js.map +1 -0
  29. package/src/lib/enumerations/quorumErrorType.d.ts +30 -1
  30. package/src/lib/enumerations/quorumErrorType.d.ts.map +1 -1
  31. package/src/lib/enumerations/quorumErrorType.js +37 -0
  32. package/src/lib/enumerations/quorumErrorType.js.map +1 -1
  33. package/src/lib/enumerations/quorumOperationalMode.d.ts +16 -0
  34. package/src/lib/enumerations/quorumOperationalMode.d.ts.map +1 -0
  35. package/src/lib/enumerations/quorumOperationalMode.js +20 -0
  36. package/src/lib/enumerations/quorumOperationalMode.js.map +1 -0
  37. package/src/lib/enumerations/sealingErrorType.d.ts +3 -1
  38. package/src/lib/enumerations/sealingErrorType.d.ts.map +1 -1
  39. package/src/lib/enumerations/sealingErrorType.js +2 -0
  40. package/src/lib/enumerations/sealingErrorType.js.map +1 -1
  41. package/src/lib/errors/identityValidationError.d.ts +8 -0
  42. package/src/lib/errors/identityValidationError.d.ts.map +1 -0
  43. package/src/lib/errors/identityValidationError.js +26 -0
  44. package/src/lib/errors/identityValidationError.js.map +1 -0
  45. package/src/lib/errors/index.d.ts +4 -0
  46. package/src/lib/errors/index.d.ts.map +1 -1
  47. package/src/lib/errors/index.js +7 -0
  48. package/src/lib/errors/index.js.map +1 -1
  49. package/src/lib/errors/quorumError.d.ts.map +1 -1
  50. package/src/lib/errors/quorumError.js +37 -0
  51. package/src/lib/errors/quorumError.js.map +1 -1
  52. package/src/lib/errors/sealingError.d.ts.map +1 -1
  53. package/src/lib/errors/sealingError.js +2 -0
  54. package/src/lib/errors/sealingError.js.map +1 -1
  55. package/src/lib/i18n/strings/englishUs.d.ts.map +1 -1
  56. package/src/lib/i18n/strings/englishUs.js +45 -0
  57. package/src/lib/i18n/strings/englishUs.js.map +1 -1
  58. package/src/lib/i18n/strings/french.d.ts.map +1 -1
  59. package/src/lib/i18n/strings/french.js +37 -0
  60. package/src/lib/i18n/strings/french.js.map +1 -1
  61. package/src/lib/i18n/strings/german.d.ts.map +1 -1
  62. package/src/lib/i18n/strings/german.js +37 -0
  63. package/src/lib/i18n/strings/german.js.map +1 -1
  64. package/src/lib/i18n/strings/japanese.d.ts.map +1 -1
  65. package/src/lib/i18n/strings/japanese.js +37 -0
  66. package/src/lib/i18n/strings/japanese.js.map +1 -1
  67. package/src/lib/i18n/strings/mandarin.d.ts.map +1 -1
  68. package/src/lib/i18n/strings/mandarin.js +37 -0
  69. package/src/lib/i18n/strings/mandarin.js.map +1 -1
  70. package/src/lib/i18n/strings/spanish.d.ts.map +1 -1
  71. package/src/lib/i18n/strings/spanish.js +37 -0
  72. package/src/lib/i18n/strings/spanish.js.map +1 -1
  73. package/src/lib/i18n/strings/ukrainian.d.ts.map +1 -1
  74. package/src/lib/i18n/strings/ukrainian.js +37 -0
  75. package/src/lib/i18n/strings/ukrainian.js.map +1 -1
  76. package/src/lib/interfaces/aliasRecord.d.ts +34 -0
  77. package/src/lib/interfaces/aliasRecord.d.ts.map +1 -0
  78. package/src/lib/interfaces/aliasRecord.js +11 -0
  79. package/src/lib/interfaces/aliasRecord.js.map +1 -0
  80. package/src/lib/interfaces/api/index.d.ts +2 -0
  81. package/src/lib/interfaces/api/index.d.ts.map +1 -0
  82. package/src/lib/interfaces/api/index.js +5 -0
  83. package/src/lib/interfaces/api/index.js.map +1 -0
  84. package/src/lib/interfaces/api/quorumApi.d.ts +97 -0
  85. package/src/lib/interfaces/api/quorumApi.d.ts.map +1 -0
  86. package/src/lib/interfaces/api/quorumApi.js +12 -0
  87. package/src/lib/interfaces/api/quorumApi.js.map +1 -0
  88. package/src/lib/interfaces/auditLogEntry.d.ts +34 -0
  89. package/src/lib/interfaces/auditLogEntry.d.ts.map +1 -0
  90. package/src/lib/interfaces/auditLogEntry.js +10 -0
  91. package/src/lib/interfaces/auditLogEntry.js.map +1 -0
  92. package/src/lib/interfaces/availability/gossipService.d.ts +116 -2
  93. package/src/lib/interfaces/availability/gossipService.d.ts.map +1 -1
  94. package/src/lib/interfaces/availability/gossipService.js +62 -0
  95. package/src/lib/interfaces/availability/gossipService.js.map +1 -1
  96. package/src/lib/interfaces/chainedAuditLogEntry.d.ts +27 -0
  97. package/src/lib/interfaces/chainedAuditLogEntry.d.ts.map +1 -0
  98. package/src/lib/interfaces/chainedAuditLogEntry.js +12 -0
  99. package/src/lib/interfaces/chainedAuditLogEntry.js.map +1 -0
  100. package/src/lib/interfaces/contentWithIdentity.d.ts +39 -0
  101. package/src/lib/interfaces/contentWithIdentity.d.ts.map +1 -0
  102. package/src/lib/interfaces/contentWithIdentity.js +24 -0
  103. package/src/lib/interfaces/contentWithIdentity.js.map +1 -0
  104. package/src/lib/interfaces/energyAccount.d.ts +3 -1
  105. package/src/lib/interfaces/energyAccount.d.ts.map +1 -1
  106. package/src/lib/interfaces/identityRecoveryRecord.d.ts +41 -0
  107. package/src/lib/interfaces/identityRecoveryRecord.d.ts.map +1 -0
  108. package/src/lib/interfaces/identityRecoveryRecord.js +11 -0
  109. package/src/lib/interfaces/identityRecoveryRecord.js.map +1 -0
  110. package/src/lib/interfaces/index.d.ts +16 -0
  111. package/src/lib/interfaces/index.d.ts.map +1 -1
  112. package/src/lib/interfaces/index.js +4 -0
  113. package/src/lib/interfaces/index.js.map +1 -1
  114. package/src/lib/interfaces/initResult.d.ts +6 -6
  115. package/src/lib/interfaces/initResult.d.ts.map +1 -1
  116. package/src/lib/interfaces/member/brightChainBaseInitResult.d.ts +4 -1
  117. package/src/lib/interfaces/member/brightChainBaseInitResult.d.ts.map +1 -1
  118. package/src/lib/interfaces/member/brightChainInitResult.d.ts +1 -1
  119. package/src/lib/interfaces/member/brightChainInitResult.d.ts.map +1 -1
  120. package/src/lib/interfaces/member/memberData.d.ts +3 -0
  121. package/src/lib/interfaces/member/memberData.d.ts.map +1 -1
  122. package/src/lib/interfaces/member/profileStorage.d.ts +5 -0
  123. package/src/lib/interfaces/member/profileStorage.d.ts.map +1 -1
  124. package/src/lib/interfaces/operationalState.d.ts +20 -0
  125. package/src/lib/interfaces/operationalState.d.ts.map +1 -0
  126. package/src/lib/interfaces/operationalState.js +10 -0
  127. package/src/lib/interfaces/operationalState.js.map +1 -0
  128. package/src/lib/interfaces/proposal.d.ts +59 -0
  129. package/src/lib/interfaces/proposal.d.ts.map +1 -0
  130. package/src/lib/interfaces/proposal.js +10 -0
  131. package/src/lib/interfaces/proposal.js.map +1 -0
  132. package/src/lib/interfaces/quorumDocumentMetadata.d.ts +20 -0
  133. package/src/lib/interfaces/quorumDocumentMetadata.d.ts.map +1 -0
  134. package/src/lib/interfaces/quorumDocumentMetadata.js +10 -0
  135. package/src/lib/interfaces/quorumDocumentMetadata.js.map +1 -0
  136. package/src/lib/interfaces/quorumEpoch.d.ts +33 -0
  137. package/src/lib/interfaces/quorumEpoch.d.ts.map +1 -0
  138. package/src/lib/interfaces/quorumEpoch.js +11 -0
  139. package/src/lib/interfaces/quorumEpoch.js.map +1 -0
  140. package/src/lib/interfaces/quorumMetrics.d.ts +49 -0
  141. package/src/lib/interfaces/quorumMetrics.d.ts.map +1 -0
  142. package/src/lib/interfaces/quorumMetrics.js +10 -0
  143. package/src/lib/interfaces/quorumMetrics.js.map +1 -0
  144. package/src/lib/interfaces/redistributionJournalEntry.d.ts +25 -0
  145. package/src/lib/interfaces/redistributionJournalEntry.d.ts.map +1 -0
  146. package/src/lib/interfaces/redistributionJournalEntry.js +11 -0
  147. package/src/lib/interfaces/redistributionJournalEntry.js.map +1 -0
  148. package/src/lib/interfaces/responses/backupCodesResponseData.d.ts +3 -5
  149. package/src/lib/interfaces/responses/backupCodesResponseData.d.ts.map +1 -1
  150. package/src/lib/interfaces/responses/challengeResponseData.d.ts +5 -0
  151. package/src/lib/interfaces/responses/challengeResponseData.d.ts.map +1 -1
  152. package/src/lib/interfaces/responses/codeCountResponseData.d.ts +3 -5
  153. package/src/lib/interfaces/responses/codeCountResponseData.d.ts.map +1 -1
  154. package/src/lib/interfaces/responses/index.d.ts +4 -2
  155. package/src/lib/interfaces/responses/index.d.ts.map +1 -1
  156. package/src/lib/interfaces/responses/passwordChangeResponse.d.ts +2 -0
  157. package/src/lib/interfaces/responses/passwordChangeResponse.d.ts.map +1 -0
  158. package/src/lib/interfaces/responses/passwordChangeResponse.js +3 -0
  159. package/src/lib/interfaces/responses/passwordChangeResponse.js.map +1 -0
  160. package/src/lib/interfaces/responses/recoveryResponse.d.ts +2 -0
  161. package/src/lib/interfaces/responses/recoveryResponse.d.ts.map +1 -0
  162. package/src/lib/interfaces/responses/recoveryResponse.js +3 -0
  163. package/src/lib/interfaces/responses/recoveryResponse.js.map +1 -0
  164. package/src/lib/interfaces/responses/registrationResponseData.d.ts +2 -2
  165. package/src/lib/interfaces/responses/registrationResponseData.d.ts.map +1 -1
  166. package/src/lib/interfaces/services/contentIngestion.d.ts +61 -0
  167. package/src/lib/interfaces/services/contentIngestion.d.ts.map +1 -0
  168. package/src/lib/interfaces/services/contentIngestion.js +12 -0
  169. package/src/lib/interfaces/services/contentIngestion.js.map +1 -0
  170. package/src/lib/interfaces/services/expirationScheduler.d.ts +55 -0
  171. package/src/lib/interfaces/services/expirationScheduler.d.ts.map +1 -0
  172. package/src/lib/interfaces/services/expirationScheduler.js +11 -0
  173. package/src/lib/interfaces/services/expirationScheduler.js.map +1 -0
  174. package/src/lib/interfaces/services/identitySealingPipeline.d.ts +56 -0
  175. package/src/lib/interfaces/services/identitySealingPipeline.d.ts.map +1 -0
  176. package/src/lib/interfaces/services/identitySealingPipeline.js +12 -0
  177. package/src/lib/interfaces/services/identitySealingPipeline.js.map +1 -0
  178. package/src/lib/interfaces/services/identityValidator.d.ts +44 -0
  179. package/src/lib/interfaces/services/identityValidator.d.ts.map +1 -0
  180. package/src/lib/interfaces/services/identityValidator.js +11 -0
  181. package/src/lib/interfaces/services/identityValidator.js.map +1 -0
  182. package/src/lib/interfaces/services/index.d.ts +9 -0
  183. package/src/lib/interfaces/services/index.d.ts.map +1 -1
  184. package/src/lib/interfaces/services/membershipProof.d.ts +40 -0
  185. package/src/lib/interfaces/services/membershipProof.d.ts.map +1 -0
  186. package/src/lib/interfaces/services/membershipProof.js +11 -0
  187. package/src/lib/interfaces/services/membershipProof.js.map +1 -0
  188. package/src/lib/interfaces/services/operatorPrompt.d.ts +68 -0
  189. package/src/lib/interfaces/services/operatorPrompt.d.ts.map +1 -0
  190. package/src/lib/interfaces/services/operatorPrompt.js +11 -0
  191. package/src/lib/interfaces/services/operatorPrompt.js.map +1 -0
  192. package/src/lib/interfaces/services/quorumDatabase.d.ts +207 -0
  193. package/src/lib/interfaces/services/quorumDatabase.d.ts.map +1 -0
  194. package/src/lib/interfaces/services/quorumDatabase.js +13 -0
  195. package/src/lib/interfaces/services/quorumDatabase.js.map +1 -0
  196. package/src/lib/interfaces/services/quorumService.d.ts +3 -0
  197. package/src/lib/interfaces/services/quorumService.d.ts.map +1 -1
  198. package/src/lib/interfaces/services/quorumStateMachine.d.ts +128 -0
  199. package/src/lib/interfaces/services/quorumStateMachine.d.ts.map +1 -0
  200. package/src/lib/interfaces/services/quorumStateMachine.js +12 -0
  201. package/src/lib/interfaces/services/quorumStateMachine.js.map +1 -0
  202. package/src/lib/interfaces/services/redistributionConfig.d.ts +20 -0
  203. package/src/lib/interfaces/services/redistributionConfig.d.ts.map +1 -0
  204. package/src/lib/interfaces/services/redistributionConfig.js +10 -0
  205. package/src/lib/interfaces/services/redistributionConfig.js.map +1 -0
  206. package/src/lib/interfaces/statuteConfig.d.ts +22 -0
  207. package/src/lib/interfaces/statuteConfig.d.ts.map +1 -0
  208. package/src/lib/interfaces/statuteConfig.js +18 -0
  209. package/src/lib/interfaces/statuteConfig.js.map +1 -0
  210. package/src/lib/interfaces/storage/documentStore.d.ts +46 -24
  211. package/src/lib/interfaces/storage/documentStore.d.ts.map +1 -1
  212. package/src/lib/interfaces/storage/documentStore.js +6 -2
  213. package/src/lib/interfaces/storage/documentStore.js.map +1 -1
  214. package/src/lib/interfaces/userManagement.d.ts +49 -0
  215. package/src/lib/interfaces/userManagement.d.ts.map +1 -0
  216. package/src/lib/interfaces/userManagement.js +9 -0
  217. package/src/lib/interfaces/userManagement.js.map +1 -0
  218. package/src/lib/interfaces/vote.d.ts +45 -0
  219. package/src/lib/interfaces/vote.d.ts.map +1 -0
  220. package/src/lib/interfaces/vote.js +10 -0
  221. package/src/lib/interfaces/vote.js.map +1 -0
  222. package/src/lib/quorumDataRecord.d.ts +7 -1
  223. package/src/lib/quorumDataRecord.d.ts.map +1 -1
  224. package/src/lib/quorumDataRecord.js +12 -4
  225. package/src/lib/quorumDataRecord.js.map +1 -1
  226. package/src/lib/quorumDataRecordDto.d.ts +6 -0
  227. package/src/lib/quorumDataRecordDto.d.ts.map +1 -1
  228. package/src/lib/services/aliasRegistry.d.ts +77 -0
  229. package/src/lib/services/aliasRegistry.d.ts.map +1 -0
  230. package/src/lib/services/aliasRegistry.js +138 -0
  231. package/src/lib/services/aliasRegistry.js.map +1 -0
  232. package/src/lib/services/auditLogService.d.ts +100 -0
  233. package/src/lib/services/auditLogService.d.ts.map +1 -0
  234. package/src/lib/services/auditLogService.js +223 -0
  235. package/src/lib/services/auditLogService.js.map +1 -0
  236. package/src/lib/services/blockService.d.ts +2 -1
  237. package/src/lib/services/blockService.d.ts.map +1 -1
  238. package/src/lib/services/blockService.js +7 -2
  239. package/src/lib/services/blockService.js.map +1 -1
  240. package/src/lib/services/identitySealingPipeline.d.ts +120 -0
  241. package/src/lib/services/identitySealingPipeline.d.ts.map +1 -0
  242. package/src/lib/services/identitySealingPipeline.js +288 -0
  243. package/src/lib/services/identitySealingPipeline.js.map +1 -0
  244. package/src/lib/services/identityValidator.d.ts +75 -0
  245. package/src/lib/services/identityValidator.d.ts.map +1 -0
  246. package/src/lib/services/identityValidator.js +202 -0
  247. package/src/lib/services/identityValidator.js.map +1 -0
  248. package/src/lib/services/index.d.ts +6 -0
  249. package/src/lib/services/index.d.ts.map +1 -1
  250. package/src/lib/services/index.js +6 -0
  251. package/src/lib/services/index.js.map +1 -1
  252. package/src/lib/services/member/memberCblService.d.ts.map +1 -1
  253. package/src/lib/services/member/memberCblService.js +12 -1
  254. package/src/lib/services/member/memberCblService.js.map +1 -1
  255. package/src/lib/services/memberStore.d.ts.map +1 -1
  256. package/src/lib/services/memberStore.js +2 -0
  257. package/src/lib/services/memberStore.js.map +1 -1
  258. package/src/lib/services/membershipProofService.d.ts +90 -0
  259. package/src/lib/services/membershipProofService.d.ts.map +1 -0
  260. package/src/lib/services/membershipProofService.js +361 -0
  261. package/src/lib/services/membershipProofService.js.map +1 -0
  262. package/src/lib/services/quorumStateMachine.d.ts +336 -0
  263. package/src/lib/services/quorumStateMachine.d.ts.map +1 -0
  264. package/src/lib/services/quorumStateMachine.js +1396 -0
  265. package/src/lib/services/quorumStateMachine.js.map +1 -0
  266. package/src/lib/services/sealing.service.d.ts +80 -0
  267. package/src/lib/services/sealing.service.d.ts.map +1 -1
  268. package/src/lib/services/sealing.service.js +192 -0
  269. package/src/lib/services/sealing.service.js.map +1 -1
  270. package/src/lib/stores/energyAccountStore.d.ts +13 -11
  271. package/src/lib/stores/energyAccountStore.d.ts.map +1 -1
  272. package/src/lib/stores/energyAccountStore.js +18 -20
  273. package/src/lib/stores/energyAccountStore.js.map +1 -1
  274. package/brightchain-lib/BLOCK_COVERAGE_AUDIT.md +0 -169
  275. package/brightchain-lib/BROWSER_COMPAT.md +0 -54
  276. package/brightchain-lib/DEPRECATIONS.md +0 -454
  277. package/brightchain-lib/DEPRECATIONS_REMOVED.md +0 -160
  278. package/brightchain-lib/MIGRATION.md +0 -801
  279. package/brightchain-lib/NAMING_AUDIT.md +0 -233
  280. package/brightchain-lib/NAMING_CONVENTIONS.md +0 -346
  281. package/brightchain-lib/README.md +0 -611
@@ -1,611 +0,0 @@
1
- # BrightChain Library
2
-
3
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
- [![npm version](https://badge.fury.io/js/%40brightchain%2Fbrightchain-lib.svg)](https://badge.fury.io/js/%40brightchain%2Fbrightchain-lib)
5
-
6
- **BrightChain** is a revolutionary cryptographic ecosystem that reimagines digital governance, storage, and communication. At its core, it implements the Owner-Free File System (OFFS) with advanced cryptographic features including ECIES encryption, homomorphic voting capabilities, and brokered anonymity.
7
-
8
- ## ๐ŸŒŸ Key Features
9
-
10
- ### ๐Ÿ” Unified Cryptographic Architecture
11
- - **ECIES Integration**: Elliptic Curve Integrated Encryption Scheme for secure messaging and file storage
12
- - **Homomorphic Encryption**: Paillier keys derived from ECDH keypairs for secure voting and computation
13
- - **Brokered Anonymity**: Forward Error Correction with quorum-based identity recovery
14
-
15
- ### ๐Ÿ“ฆ Owner-Free File System (OFFS)
16
- - **TUPLE Storage**: All data stored as 3-block TUPLEs (data + 2 randomizers) for complete plausible deniability
17
- - **Block-based Storage**: Files broken into encrypted blocks with XOR randomization
18
- - **Deduplication**: SHA-512 based block identification prevents duplicate storage
19
- - **Distributed Architecture**: Decentralized storage with no single point of failure
20
- - **Legal Protection**: True owner-free storage ensures no single party can be compelled to produce meaningful data
21
-
22
- ### โšก Energy-Efficient Design
23
- - **Joule Currency**: All operations measured in actual energy consumption
24
- - **Proof of Work Throttling**: Bad actors face increased computational requirements
25
- - **Sustainable Operations**: Optimized for minimal energy consumption
26
-
27
- ## ๐Ÿš€ Quick Start
28
-
29
- ### Installation
30
-
31
- ```bash
32
- npm install @brightchain/brightchain-lib
33
- ```
34
-
35
- ### Basic Usage
36
-
37
- ```typescript
38
- import { BrightChain, BlockSize } from '@brightchain/brightchain-lib';
39
-
40
- // Initialize BrightChain
41
- const brightChain = new BrightChain(BlockSize.Small);
42
-
43
- // Store a file
44
- const fileData = new TextEncoder().encode("Hello, BrightChain!");
45
- const receipt = await brightChain.storeFile(fileData, "greeting.txt");
46
-
47
- console.log(`File stored with ID: ${receipt.id}`);
48
- console.log(`Magnet URL: ${receipt.magnetUrl}`);
49
-
50
- // Retrieve the file
51
- const retrievedData = await brightChain.retrieveFile(receipt);
52
- const retrievedText = new TextDecoder().decode(retrievedData);
53
- console.log(`Retrieved: ${retrievedText}`);
54
- ```
55
-
56
- ## ๐Ÿ“š Core Concepts
57
-
58
- ### Block Types
59
-
60
- BrightChain supports several block types for different use cases:
61
-
62
- - **RawDataBlock**: Unencrypted data blocks
63
- - **EncryptedBlock**: ECIES-encrypted blocks with single or multiple recipients
64
- - **ConstituentBlockList (CBL)**: Metadata blocks that reference other blocks
65
- - **EphemeralBlock**: Temporary blocks for processing
66
- - **WhitenedBlock**: XOR-randomized blocks for anonymization
67
-
68
- ### Block Sizes
69
-
70
- ```typescript
71
- import { BlockSize } from '@brightchain/brightchain-lib';
72
-
73
- // Available block sizes
74
- BlockSize.Tiny // 1024 bytes
75
- BlockSize.Small // 8192 bytes
76
- BlockSize.Medium // 32768 bytes
77
- BlockSize.Large // 131072 bytes
78
- BlockSize.Huge // 524288 bytes
79
- BlockSize.Message // 1024 bytes (alias for Tiny)
80
- ```
81
-
82
- ### Encryption Types
83
-
84
- ```typescript
85
- import { BlockEncryptionType } from '@brightchain/brightchain-lib';
86
-
87
- BlockEncryptionType.None // No encryption
88
- BlockEncryptionType.SingleRecipient // Single recipient ECIES
89
- BlockEncryptionType.MultiRecipient // Multiple recipient ECIES
90
- ```
91
-
92
- ## ๐Ÿ”ง Advanced Usage
93
-
94
- ### Error Handling
95
-
96
- BrightChain v2.0 introduces a unified error handling system with rich context and type safety:
97
-
98
- ```typescript
99
- import {
100
- BrightChainError,
101
- ValidationError,
102
- ChecksumError,
103
- FactoryPatternViolationError,
104
- isValidationError,
105
- isChecksumError,
106
- isBrightChainError
107
- } from '@brightchain/brightchain-lib';
108
-
109
- try {
110
- // Perform operations
111
- const block = await blockService.createBlock(params);
112
- } catch (error) {
113
- // Type-safe error handling with type guards
114
- if (isValidationError(error)) {
115
- console.error(`Validation failed for field: ${error.field}`);
116
- console.error(`Message: ${error.message}`);
117
- console.error(`Context:`, error.context);
118
- } else if (isChecksumError(error)) {
119
- console.error(`Checksum error type: ${error.checksumErrorType}`);
120
- console.error(`Message: ${error.message}`);
121
- } else if (isBrightChainError(error)) {
122
- // Generic BrightChain error
123
- console.error(`Error type: ${error.type}`);
124
- console.error(`Message: ${error.message}`);
125
- console.error(`Context:`, error.context);
126
-
127
- // Check for underlying cause
128
- if (error.cause) {
129
- console.error(`Caused by:`, error.cause);
130
- }
131
- } else {
132
- // Non-BrightChain error
133
- console.error('Unexpected error:', error);
134
- }
135
- }
136
- ```
137
-
138
- **Error Types:**
139
- - `BrightChainError`: Base class for all BrightChain errors
140
- - `ValidationError`: Input validation failures
141
- - `ChecksumError`: Checksum calculation or validation errors
142
- - `FactoryPatternViolationError`: Attempted direct instantiation of factory-only classes
143
- - `BlockCapacityError`: Block capacity calculation errors
144
- - `ExtendedCblError`: Extended CBL validation errors
145
-
146
- **Error Context:**
147
- All BrightChain errors include:
148
- - `type`: Error type identifier
149
- - `message`: Human-readable error message
150
- - `context`: Additional context (parameters, state, etc.)
151
- - `cause`: Original error if this error wraps another
152
-
153
- ### Type System
154
-
155
- BrightChain v2.0 introduces improved type safety with the `Checksum` class and typed `BlockHandle`:
156
-
157
- #### Checksum Class
158
-
159
- The unified `Checksum` class replaces separate `ChecksumBuffer` and `ChecksumUint8Array` types:
160
-
161
- ```typescript
162
- import { Checksum } from '@brightchain/brightchain-lib';
163
-
164
- // Create from different sources
165
- const checksumFromBuffer = Checksum.fromBuffer(buffer);
166
- const checksumFromArray = Checksum.fromUint8Array(uint8Array);
167
- const checksumFromHex = Checksum.fromHex('abc123...');
168
-
169
- // Compare checksums
170
- if (checksum1.equals(checksum2)) {
171
- console.log('Checksums match!');
172
- }
173
-
174
- // Convert to different formats
175
- const buffer = checksum.toBuffer();
176
- const array = checksum.toUint8Array();
177
- const hex = checksum.toHex();
178
- const str = checksum.toString(); // Same as toHex()
179
-
180
- // Use with services
181
- const checksumService = ServiceProvider.getInstance().checksumService;
182
- const checksum = checksumService.calculateChecksumAsClass(data);
183
- console.log(`Checksum: ${checksum.toHex()}`);
184
- ```
185
-
186
- #### Typed BlockHandle
187
-
188
- `BlockHandle<T>` now requires a type parameter for full type safety:
189
-
190
- ```typescript
191
- import { BlockHandle, BaseBlock, RawDataBlock } from '@brightchain/brightchain-lib';
192
-
193
- // Type-safe block handles
194
- const baseHandle: BlockHandle<BaseBlock> = ...;
195
- const rawDataHandle: BlockHandle<RawDataBlock> = ...;
196
-
197
- // TypeScript enforces type safety
198
- function processBlock(handle: BlockHandle<RawDataBlock>) {
199
- // TypeScript knows this is a RawDataBlock handle
200
- }
201
-
202
- // Compile-time error if type parameter is missing
203
- // const handle: BlockHandle = ...; // โŒ Error: Type parameter required
204
- ```
205
-
206
- ### Factory Patterns
207
-
208
- BrightChain enforces factory patterns at runtime to ensure proper object initialization:
209
-
210
- ```typescript
211
- import { MemberDocument, FactoryPatternViolationError } from '@brightchain/brightchain-lib';
212
-
213
- // โœ… Correct: Use factory method
214
- const member = MemberDocument.create(
215
- publicMember,
216
- privateMember,
217
- data
218
- );
219
-
220
- // โŒ Incorrect: Direct instantiation throws error
221
- try {
222
- const member = new MemberDocument(...); // Throws FactoryPatternViolationError
223
- } catch (error) {
224
- if (error instanceof FactoryPatternViolationError) {
225
- console.error('Use factory method instead:', error.message);
226
- }
227
- }
228
- ```
229
-
230
- **Classes with Factory Patterns:**
231
- - `MemberDocument`: Use `MemberDocument.create()`
232
- - `BaseBlock` subclasses: Use `BlockType.from()` or specific factory methods
233
- - `Checksum`: Use `Checksum.fromBuffer()`, `Checksum.fromUint8Array()`, or `Checksum.fromHex()`
234
-
235
- **Why Factory Patterns?**
236
- - Ensures proper validation during object creation
237
- - Prevents invalid object states
238
- - Provides clear, documented creation APIs
239
- - Enables future enhancements without breaking changes
240
-
241
- ### Migration from v1.x to v2.0
242
-
243
- If you're upgrading from BrightChain v1.x, see our comprehensive [Migration Guide](./MIGRATION.md) for:
244
-
245
- - Step-by-step migration instructions
246
- - Before/after code examples
247
- - Automated migration scripts
248
- - Deprecation timeline
249
- - Breaking changes documentation
250
-
251
- **Quick Migration Checklist:**
252
- - [ ] Replace `ChecksumBuffer`/`ChecksumUint8Array` with `Checksum` class
253
- - [ ] Update direct constructor calls to use factory methods
254
- - [ ] Add type parameters to `BlockHandle` declarations
255
- - [ ] Update property names (`typeSpecificHeader` โ†’ `typeSpecificOverhead`, `payload` โ†’ `data`)
256
- - [ ] Update error handling to use new error types and type guards
257
-
258
- See [MIGRATION.md](./MIGRATION.md) for complete details.
259
-
260
- ### TUPLE Storage
261
-
262
- BrightChain v2.1+ implements complete Owner-Free Filesystem compliance through TUPLE storage:
263
-
264
- ```typescript
265
- import { TupleStorageService, BlockSize } from '@brightchain/brightchain-lib';
266
-
267
- // Initialize TUPLE storage service
268
- const blockStore = ...; // Your block store instance
269
- const tupleService = new TupleStorageService(blockStore);
270
-
271
- // Store data as a TUPLE (3 blocks: data โŠ• R1 โŠ• R2, R1, R2)
272
- const data = new TextEncoder().encode("Sensitive information");
273
- const result = await tupleService.storeTuple(data, {
274
- durabilityLevel: DurabilityLevel.High,
275
- expiresAt: new Date(Date.now() + 86400000), // 24 hours
276
- });
277
-
278
- console.log('TUPLE Magnet URL:', result.magnetUrl);
279
- // magnet:?xt=urn:brightchain:tuple&bs=1024&d=abc...&r1=def...&r2=ghi...
280
-
281
- // Retrieve original data from TUPLE
282
- const components = tupleService.parseTupleMagnetUrl(result.magnetUrl);
283
- const originalData = await tupleService.retrieveTuple(
284
- components.dataBlockId,
285
- components.randomizerBlockIds,
286
- components.parityBlockIds,
287
- );
288
- ```
289
-
290
- **Why TUPLEs?**
291
- - **Plausible Deniability**: No single block contains identifiable data
292
- - **Legal Protection**: Node operators cannot be compelled to produce meaningful data
293
- - **Complete OFF Compliance**: All data stored as 3 blocks (not just 2)
294
- - **Brokered Anonymity**: Supports quorum-based identity recovery
295
-
296
- See [TUPLE Storage Architecture](../../docs/TUPLE_Storage_Architecture.md) for complete details.
297
-
298
- ```typescript
299
- import {
300
- EncryptedBlock,
301
- BlockType,
302
- BlockDataType,
303
- BlockSize,
304
- Member,
305
- MemberType
306
- } from '@brightchain/brightchain-lib';
307
-
308
- // Create a member (user) with cryptographic keys
309
- const eciesService = ServiceProvider.getInstance().eciesService;
310
- const member = Member.newMember(
311
- eciesService,
312
- MemberType.User,
313
- 'Alice',
314
- new EmailString('alice@example.com')
315
- ).member;
316
-
317
- // Create encrypted data
318
- const plaintext = new TextEncoder().encode("Secret message");
319
- const encryptedData = await eciesService.encryptSimpleOrSingle(
320
- true,
321
- member.publicKey,
322
- plaintext
323
- );
324
-
325
- // Create encrypted block
326
- const block = await EncryptedBlock.from(
327
- BlockType.EncryptedOwnedDataBlock,
328
- BlockDataType.EncryptedData,
329
- BlockSize.Small,
330
- encryptedData,
331
- checksumService.calculateChecksum(encryptedData),
332
- member
333
- );
334
-
335
- // Decrypt the block
336
- const decryptedBlock = await block.decrypt(BlockType.RawDataBlock);
337
- ```
338
-
339
- ### Constituent Block Lists (CBL)
340
-
341
- CBLs are metadata blocks that reference other blocks, enabling complex file structures:
342
-
343
- ```typescript
344
- import { ConstituentBlockListBlock, CBLService } from '@brightchain/brightchain-lib';
345
-
346
- const cblService = ServiceProvider.getInstance().cblService;
347
-
348
- // Calculate capacity for CBL blocks
349
- const capacity = cblService.calculateCBLAddressCapacity(
350
- BlockSize.Medium,
351
- BlockEncryptionType.SingleRecipient
352
- );
353
-
354
- console.log(`CBL can hold ${capacity} block references`);
355
- ```
356
-
357
- ### Service Provider Pattern
358
-
359
- BrightChain uses a service provider pattern for dependency injection:
360
-
361
- ```typescript
362
- import { ServiceProvider } from '@brightchain/brightchain-lib';
363
-
364
- // Get service instances
365
- const provider = ServiceProvider.getInstance();
366
- const checksumService = provider.checksumService;
367
- const eciesService = provider.eciesService;
368
- const blockService = provider.blockService;
369
-
370
- // Calculate checksums
371
- const data = new Uint8Array([1, 2, 3, 4]);
372
- const checksum = checksumService.calculateChecksum(data);
373
- ```
374
-
375
- ## ๐Ÿ—๏ธ Architecture
376
-
377
- ### Block Structure
378
-
379
- All blocks follow a layered structure:
380
-
381
- ```
382
- [Base Header][Layer Headers][Layer Data][Padding]
383
- ```
384
-
385
- **Base Header includes:**
386
- - Block Type
387
- - Block Size
388
- - Data Type
389
- - Checksum
390
- - Date Created
391
-
392
- **Encrypted Block Header adds:**
393
- - Encryption Type (1 byte)
394
- - Recipient GUID (16 bytes)
395
- - Ephemeral Public Key (65 bytes)
396
- - IV (16 bytes)
397
- - Auth Tag (16 bytes)
398
-
399
- ### Storage Architecture
400
-
401
- ```mermaid
402
- graph TD
403
- A[File Input] --> B[Block Splitter]
404
- B --> C[XOR with Random Blocks]
405
- C --> D[Encrypted Blocks]
406
- D --> E[Block Store]
407
- E --> F[CBL Creation]
408
- F --> G[Magnet URL]
409
- ```
410
-
411
- ## ๐Ÿ”’ Security Features
412
-
413
- ### Brokered Anonymity
414
-
415
- BrightChain provides privacy through Forward Error Correction:
416
-
417
- 1. **Identity Replacement**: Real identities replaced with FEC datasets
418
- 2. **Quorum Distribution**: Identity shards distributed among trusted agents
419
- 3. **Majority Recovery**: Requires quorum majority to recover identity
420
- 4. **Digital Statute of Limitations**: FEC data expires after predetermined time
421
-
422
- ### Cryptographic Guarantees
423
-
424
- - **ECIES Security**: Elliptic curve cryptography with AES-256-GCM
425
- - **Homomorphic Voting**: Paillier encryption for private voting
426
- - **Block Integrity**: SHA-512 checksums for all blocks
427
- - **Forward Secrecy**: Temporal key rotation support
428
-
429
- ## ๐Ÿ“Š Constants and Configuration
430
-
431
- ### Core Constants
432
-
433
- ```typescript
434
- import CONSTANTS from '@brightchain/brightchain-lib';
435
-
436
- // ECIES Configuration
437
- CONSTANTS.ECIES.CURVE_NAME // 'secp256k1'
438
- CONSTANTS.ECIES.PUBLIC_KEY_LENGTH // 65 bytes
439
- CONSTANTS.ECIES.PRIVATE_KEY_LENGTH // 32 bytes
440
-
441
- // Block Configuration
442
- CONSTANTS.CBL.MAX_FILE_NAME_LENGTH // 255 characters
443
- CONSTANTS.TUPLE.SIZE // 3 blocks per tuple
444
- CONSTANTS.FEC.MAX_SHARD_SIZE // 1MB
445
-
446
- // Encryption Settings
447
- CONSTANTS.ENCRYPTION.RECIPIENT_ID_SIZE // 16 bytes
448
- CONSTANTS.ENCRYPTION.ENCRYPTION_TYPE_SIZE // 1 byte
449
- ```
450
-
451
- ### ECIES Configuration
452
-
453
- ```typescript
454
- import { EciesConfig } from '@brightchain/brightchain-lib';
455
-
456
- const config = EciesConfig;
457
- console.log(config.curveName); // 'secp256k1'
458
- console.log(config.symmetricAlgorithm); // 'aes-256-gcm'
459
- ```
460
-
461
- ## ๐Ÿงช Testing
462
-
463
- ### Running Tests
464
-
465
- ```bash
466
- # Run all tests
467
- npm test
468
-
469
- # Run with specific configuration
470
- npm run test:dev:16
471
-
472
- # Run with logging
473
- npm run test:dev:16:logged
474
- ```
475
-
476
- ### Test Structure
477
-
478
- The library includes comprehensive tests:
479
-
480
- - **Unit Tests**: Individual component testing
481
- - **Integration Tests**: Service interaction testing
482
- - **Property Tests**: Cryptographic property verification
483
- - **System Tests**: End-to-end functionality testing
484
-
485
- ## ๐Ÿ”ง Development
486
-
487
- ### Building
488
-
489
- ```bash
490
- # Development build
491
- npm run build:dev
492
-
493
- # Production build (via Nx)
494
- npx nx build brightchain-lib
495
- ```
496
-
497
- ### Linting
498
-
499
- ```bash
500
- # Check code style
501
- npm run lint
502
-
503
- # Fix code style issues
504
- npm run lint:fix
505
- ```
506
-
507
- ## ๐ŸŒ Browser Compatibility
508
-
509
- BrightChain is designed to work in both Node.js and browser environments:
510
-
511
- ```typescript
512
- // Browser-specific entry point
513
- import { BrightChain } from '@brightchain/brightchain-lib/browser';
514
-
515
- // Node.js entry point
516
- import { BrightChain } from '@brightchain/brightchain-lib';
517
- ```
518
-
519
- ## ๐Ÿ“– API Reference
520
-
521
- For detailed naming conventions and terminology, see [NAMING_CONVENTIONS.md](./NAMING_CONVENTIONS.md).
522
-
523
- ### Core Classes
524
-
525
- #### BrightChain
526
- Main interface for file storage and retrieval.
527
-
528
- **Methods:**
529
- - `storeFile(data: Uint8Array, fileName?: string): Promise<FileReceipt>`
530
- - `retrieveFile(receipt: FileReceipt): Promise<Uint8Array>`
531
-
532
- #### BaseBlock
533
- Abstract base class for all block types.
534
-
535
- **Properties:**
536
- - `blockSize: BlockSize` - Size category of the block
537
- - `blockType: BlockType` - Type of block (raw, encrypted, CBL, etc)
538
- - `idChecksum: ChecksumUint8Array` - Unique identifier
539
- - `dateCreated: Date` - Creation timestamp
540
-
541
- **Methods:**
542
- - `validateAsync(): Promise<void>` - Async validation
543
- - `validateSync(): void` - Sync validation
544
-
545
- #### EncryptedBlock
546
- Encrypted block implementation with ECIES.
547
-
548
- **Properties:**
549
- - `encryptionType: BlockEncryptionType` - Single or multi-recipient
550
- - `recipients: Array<TID>` - List of recipient IDs
551
- - `recipientWithKey: Member<TID>` - Member with decryption key
552
-
553
- **Methods:**
554
- - `decrypt<D>(newBlockType: BlockType): Promise<D>` - Decrypt block
555
-
556
- ### Services
557
-
558
- #### ChecksumService
559
- Handles SHA-512 checksum operations.
560
-
561
- **Methods:**
562
- - `calculateChecksum(data: Uint8Array): ChecksumUint8Array`
563
- - `checksumToHexString(checksum: ChecksumUint8Array): ChecksumString`
564
-
565
- #### ECIESService
566
- Provides ECIES encryption/decryption.
567
-
568
- **Methods:**
569
- - `encryptSimpleOrSingle(simple: boolean, publicKey: Uint8Array, data: Uint8Array): Promise<Uint8Array>`
570
- - `decryptSimpleOrSingle(simple: boolean, privateKey: Uint8Array, data: Uint8Array): Promise<Uint8Array>`
571
-
572
- ## ๐Ÿค Contributing
573
-
574
- We welcome contributions! Please see our [Contributing Guide](../CONTRIBUTING.md) for details.
575
-
576
- ### Development Setup
577
-
578
- 1. Clone the repository
579
- 2. Install dependencies: `yarn install`
580
- 3. Run tests: `npm test`
581
- 4. Build: `npm run build:dev`
582
-
583
- ## ๐Ÿ“„ License
584
-
585
- This project is licensed under the MIT License - see the [LICENSE](../LICENSE) file for details.
586
-
587
- ## ๐Ÿ”— Related Projects
588
-
589
- - **@digitaldefiance/ecies-lib**: Core cryptographic primitives
590
- - **@digitaldefiance/i18n-lib**: Internationalization support
591
- - **brightchain-api**: REST API server
592
- - **brightchain-react**: React frontend components
593
-
594
- ## ๐Ÿ“ž Support
595
-
596
- - **GitHub Issues**: [Report bugs or request features](https://github.com/Digital-Defiance/BrightChain/issues)
597
- - **Documentation**: [Full documentation](https://github.com/Digital-Defiance/BrightChain#readme)
598
- - **Community**: [Join our discussions](https://github.com/Digital-Defiance/BrightChain/discussions)
599
-
600
- ## ๐ŸŽฏ Roadmap
601
-
602
- BrightChain is actively developed with ambitious goals:
603
-
604
- - **Phase 1**: Complete Owner-Free File System โœ…
605
- - **Phase 2**: Identity and reputation systems (In Progress)
606
- - **Phase 3**: Digital contracts and governance
607
- - **Phase 4**: Global adoption and interplanetary standards
608
-
609
- ---
610
-
611
- **BrightChain** - *Illuminating the future of decentralized digital governance*