@brightchain/brightchain-lib 0.14.0 → 0.15.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 (571) hide show
  1. package/brightchain-lib/BROWSER_COMPAT.md +54 -0
  2. package/package.json +15 -4
  3. package/src/lib/blocks/cblBase.d.ts +16 -1
  4. package/src/lib/blocks/cblBase.d.ts.map +1 -1
  5. package/src/lib/blocks/cblBase.js +33 -4
  6. package/src/lib/blocks/cblBase.js.map +1 -1
  7. package/src/lib/blocks/extendedCbl.d.ts.map +1 -1
  8. package/src/lib/blocks/extendedCbl.js +2 -1
  9. package/src/lib/blocks/extendedCbl.js.map +1 -1
  10. package/src/lib/blocks/handle.d.ts +5 -0
  11. package/src/lib/blocks/handle.d.ts.map +1 -1
  12. package/src/lib/blocks/handle.js.map +1 -1
  13. package/src/lib/blocks/handleTuple.d.ts +9 -1
  14. package/src/lib/blocks/handleTuple.d.ts.map +1 -1
  15. package/src/lib/blocks/handleTuple.js +23 -1
  16. package/src/lib/blocks/handleTuple.js.map +1 -1
  17. package/src/lib/blocks/index.d.ts +1 -0
  18. package/src/lib/blocks/index.d.ts.map +1 -1
  19. package/src/lib/blocks/index.js +1 -0
  20. package/src/lib/blocks/index.js.map +1 -1
  21. package/src/lib/blocks/memoryTuple.d.ts +9 -2
  22. package/src/lib/blocks/memoryTuple.d.ts.map +1 -1
  23. package/src/lib/blocks/memoryTuple.js +12 -3
  24. package/src/lib/blocks/memoryTuple.js.map +1 -1
  25. package/src/lib/blocks/vcbl.d.ts +27 -0
  26. package/src/lib/blocks/vcbl.d.ts.map +1 -0
  27. package/src/lib/blocks/vcbl.js +107 -0
  28. package/src/lib/blocks/vcbl.js.map +1 -0
  29. package/src/lib/constants.d.ts +5 -1
  30. package/src/lib/constants.d.ts.map +1 -1
  31. package/src/lib/constants.js +4 -0
  32. package/src/lib/constants.js.map +1 -1
  33. package/src/lib/crypto/index.d.ts +12 -0
  34. package/src/lib/crypto/index.d.ts.map +1 -0
  35. package/src/lib/crypto/index.js +23 -0
  36. package/src/lib/crypto/index.js.map +1 -0
  37. package/src/lib/crypto/platformCrypto.d.ts +132 -0
  38. package/src/lib/crypto/platformCrypto.d.ts.map +1 -0
  39. package/src/lib/crypto/platformCrypto.js +181 -0
  40. package/src/lib/crypto/platformCrypto.js.map +1 -0
  41. package/src/lib/enumeration-translations/blockType.d.ts.map +1 -1
  42. package/src/lib/enumeration-translations/blockType.js +16 -0
  43. package/src/lib/enumeration-translations/blockType.js.map +1 -1
  44. package/src/lib/enumerations/blockType.d.ts +12 -0
  45. package/src/lib/enumerations/blockType.d.ts.map +1 -1
  46. package/src/lib/enumerations/blockType.js +14 -0
  47. package/src/lib/enumerations/blockType.js.map +1 -1
  48. package/src/lib/enumerations/brightChainStrings.d.ts +4 -0
  49. package/src/lib/enumerations/brightChainStrings.d.ts.map +1 -1
  50. package/src/lib/enumerations/brightChainStrings.js +4 -0
  51. package/src/lib/enumerations/brightChainStrings.js.map +1 -1
  52. package/src/lib/enumerations/cblErrorType.d.ts +2 -1
  53. package/src/lib/enumerations/cblErrorType.d.ts.map +1 -1
  54. package/src/lib/enumerations/cblErrorType.js +1 -0
  55. package/src/lib/enumerations/cblErrorType.js.map +1 -1
  56. package/src/lib/enumerations/communication.d.ts +57 -0
  57. package/src/lib/enumerations/communication.d.ts.map +1 -0
  58. package/src/lib/enumerations/communication.js +89 -0
  59. package/src/lib/enumerations/communication.js.map +1 -0
  60. package/src/lib/enumerations/deviceType.d.ts +15 -0
  61. package/src/lib/enumerations/deviceType.d.ts.map +1 -0
  62. package/src/lib/enumerations/deviceType.js +19 -0
  63. package/src/lib/enumerations/deviceType.js.map +1 -0
  64. package/src/lib/enumerations/handleTupleErrorType.d.ts +2 -1
  65. package/src/lib/enumerations/handleTupleErrorType.d.ts.map +1 -1
  66. package/src/lib/enumerations/handleTupleErrorType.js +1 -0
  67. package/src/lib/enumerations/handleTupleErrorType.js.map +1 -1
  68. package/src/lib/enumerations/index.d.ts +6 -0
  69. package/src/lib/enumerations/index.d.ts.map +1 -1
  70. package/src/lib/enumerations/index.js +11 -0
  71. package/src/lib/enumerations/index.js.map +1 -1
  72. package/src/lib/enumerations/paperKeyPurpose.d.ts +15 -0
  73. package/src/lib/enumerations/paperKeyPurpose.d.ts.map +1 -0
  74. package/src/lib/enumerations/paperKeyPurpose.js +19 -0
  75. package/src/lib/enumerations/paperKeyPurpose.js.map +1 -0
  76. package/src/lib/enumerations/proofPlatform.d.ts +24 -0
  77. package/src/lib/enumerations/proofPlatform.d.ts.map +1 -0
  78. package/src/lib/enumerations/proofPlatform.js +28 -0
  79. package/src/lib/enumerations/proofPlatform.js.map +1 -0
  80. package/src/lib/enumerations/readConcern.d.ts +22 -0
  81. package/src/lib/enumerations/readConcern.d.ts.map +1 -0
  82. package/src/lib/enumerations/readConcern.js +26 -0
  83. package/src/lib/enumerations/readConcern.js.map +1 -0
  84. package/src/lib/enumerations/tupleErrorType.d.ts +2 -1
  85. package/src/lib/enumerations/tupleErrorType.d.ts.map +1 -1
  86. package/src/lib/enumerations/tupleErrorType.js +1 -0
  87. package/src/lib/enumerations/tupleErrorType.js.map +1 -1
  88. package/src/lib/enumerations/verificationStatus.d.ts +17 -0
  89. package/src/lib/enumerations/verificationStatus.d.ts.map +1 -0
  90. package/src/lib/enumerations/verificationStatus.js +21 -0
  91. package/src/lib/enumerations/verificationStatus.js.map +1 -0
  92. package/src/lib/errors/blockFetchError.d.ts +51 -0
  93. package/src/lib/errors/blockFetchError.d.ts.map +1 -0
  94. package/src/lib/errors/blockFetchError.js +63 -0
  95. package/src/lib/errors/blockFetchError.js.map +1 -0
  96. package/src/lib/errors/cblError.d.ts.map +1 -1
  97. package/src/lib/errors/cblError.js +1 -0
  98. package/src/lib/errors/cblError.js.map +1 -1
  99. package/src/lib/errors/handleTupleError.d.ts +10 -1
  100. package/src/lib/errors/handleTupleError.d.ts.map +1 -1
  101. package/src/lib/errors/handleTupleError.js +10 -1
  102. package/src/lib/errors/handleTupleError.js.map +1 -1
  103. package/src/lib/errors/index.d.ts +16 -0
  104. package/src/lib/errors/index.d.ts.map +1 -1
  105. package/src/lib/errors/index.js +22 -0
  106. package/src/lib/errors/index.js.map +1 -1
  107. package/src/lib/errors/poolDeletionError.d.ts +10 -0
  108. package/src/lib/errors/poolDeletionError.d.ts.map +1 -0
  109. package/src/lib/errors/poolDeletionError.js +16 -0
  110. package/src/lib/errors/poolDeletionError.js.map +1 -0
  111. package/src/lib/errors/poolDeletionTombstoneError.d.ts +12 -0
  112. package/src/lib/errors/poolDeletionTombstoneError.d.ts.map +1 -0
  113. package/src/lib/errors/poolDeletionTombstoneError.js +18 -0
  114. package/src/lib/errors/poolDeletionTombstoneError.js.map +1 -0
  115. package/src/lib/errors/tupleError.d.ts.map +1 -1
  116. package/src/lib/errors/tupleError.js +1 -0
  117. package/src/lib/errors/tupleError.js.map +1 -1
  118. package/src/lib/i18n/i18n-setup.d.ts +1 -1
  119. package/src/lib/i18n/strings/englishUs.d.ts.map +1 -1
  120. package/src/lib/i18n/strings/englishUs.js +4 -0
  121. package/src/lib/i18n/strings/englishUs.js.map +1 -1
  122. package/src/lib/i18n/strings/french.d.ts.map +1 -1
  123. package/src/lib/i18n/strings/french.js +4 -0
  124. package/src/lib/i18n/strings/french.js.map +1 -1
  125. package/src/lib/i18n/strings/german.d.ts.map +1 -1
  126. package/src/lib/i18n/strings/german.js +4 -0
  127. package/src/lib/i18n/strings/german.js.map +1 -1
  128. package/src/lib/i18n/strings/japanese.d.ts.map +1 -1
  129. package/src/lib/i18n/strings/japanese.js +4 -0
  130. package/src/lib/i18n/strings/japanese.js.map +1 -1
  131. package/src/lib/i18n/strings/mandarin.d.ts.map +1 -1
  132. package/src/lib/i18n/strings/mandarin.js +4 -0
  133. package/src/lib/i18n/strings/mandarin.js.map +1 -1
  134. package/src/lib/i18n/strings/spanish.d.ts.map +1 -1
  135. package/src/lib/i18n/strings/spanish.js +4 -0
  136. package/src/lib/i18n/strings/spanish.js.map +1 -1
  137. package/src/lib/i18n/strings/ukrainian.d.ts.map +1 -1
  138. package/src/lib/i18n/strings/ukrainian.js +4 -0
  139. package/src/lib/i18n/strings/ukrainian.js.map +1 -1
  140. package/src/lib/index.d.ts +4 -0
  141. package/src/lib/index.d.ts.map +1 -1
  142. package/src/lib/index.js +4 -0
  143. package/src/lib/index.js.map +1 -1
  144. package/src/lib/interfaces/auth/index.d.ts +4 -0
  145. package/src/lib/interfaces/auth/index.d.ts.map +1 -0
  146. package/src/lib/interfaces/auth/index.js +8 -0
  147. package/src/lib/interfaces/auth/index.js.map +1 -0
  148. package/src/lib/interfaces/auth/nodeAuthenticator.d.ts +19 -0
  149. package/src/lib/interfaces/auth/nodeAuthenticator.d.ts.map +1 -0
  150. package/src/lib/interfaces/auth/nodeAuthenticator.js +3 -0
  151. package/src/lib/interfaces/auth/nodeAuthenticator.js.map +1 -0
  152. package/src/lib/interfaces/auth/poolAcl.d.ts +65 -0
  153. package/src/lib/interfaces/auth/poolAcl.d.ts.map +1 -0
  154. package/src/lib/interfaces/auth/poolAcl.js +52 -0
  155. package/src/lib/interfaces/auth/poolAcl.js.map +1 -0
  156. package/src/lib/interfaces/availability/availabilityService.d.ts +5 -3
  157. package/src/lib/interfaces/availability/availabilityService.d.ts.map +1 -1
  158. package/src/lib/interfaces/availability/availabilityService.js.map +1 -1
  159. package/src/lib/interfaces/availability/blockRegistry.d.ts +52 -3
  160. package/src/lib/interfaces/availability/blockRegistry.d.ts.map +1 -1
  161. package/src/lib/interfaces/availability/blockRegistry.js +1 -1
  162. package/src/lib/interfaces/availability/discoveryProtocol.d.ts +81 -3
  163. package/src/lib/interfaces/availability/discoveryProtocol.d.ts.map +1 -1
  164. package/src/lib/interfaces/availability/discoveryProtocol.js.map +1 -1
  165. package/src/lib/interfaces/availability/gossipService.d.ts +110 -6
  166. package/src/lib/interfaces/availability/gossipService.d.ts.map +1 -1
  167. package/src/lib/interfaces/availability/gossipService.js +94 -1
  168. package/src/lib/interfaces/availability/gossipService.js.map +1 -1
  169. package/src/lib/interfaces/availability/index.d.ts +1 -0
  170. package/src/lib/interfaces/availability/index.d.ts.map +1 -1
  171. package/src/lib/interfaces/availability/index.js +1 -0
  172. package/src/lib/interfaces/availability/index.js.map +1 -1
  173. package/src/lib/interfaces/availability/locationRecord.d.ts +6 -0
  174. package/src/lib/interfaces/availability/locationRecord.d.ts.map +1 -1
  175. package/src/lib/interfaces/availability/locationRecord.js +12 -0
  176. package/src/lib/interfaces/availability/locationRecord.js.map +1 -1
  177. package/src/lib/interfaces/availability/poolDeletionTombstone.d.ts +40 -0
  178. package/src/lib/interfaces/availability/poolDeletionTombstone.d.ts.map +1 -0
  179. package/src/lib/interfaces/availability/poolDeletionTombstone.js +19 -0
  180. package/src/lib/interfaces/availability/poolDeletionTombstone.js.map +1 -0
  181. package/src/lib/interfaces/availability/reconciliationService.d.ts +52 -0
  182. package/src/lib/interfaces/availability/reconciliationService.d.ts.map +1 -1
  183. package/src/lib/interfaces/availability/reconciliationService.js.map +1 -1
  184. package/src/lib/interfaces/blockCapacity.d.ts +9 -0
  185. package/src/lib/interfaces/blockCapacity.d.ts.map +1 -1
  186. package/src/lib/interfaces/blockEncryption.d.ts +4 -2
  187. package/src/lib/interfaces/blockEncryption.d.ts.map +1 -1
  188. package/src/lib/interfaces/blockFetch/blockFetchTransport.d.ts +26 -0
  189. package/src/lib/interfaces/blockFetch/blockFetchTransport.d.ts.map +1 -0
  190. package/src/lib/interfaces/blockFetch/blockFetchTransport.js +12 -0
  191. package/src/lib/interfaces/blockFetch/blockFetchTransport.js.map +1 -0
  192. package/src/lib/interfaces/blockFetch/blockFetcher.d.ts +71 -0
  193. package/src/lib/interfaces/blockFetch/blockFetcher.d.ts.map +1 -0
  194. package/src/lib/interfaces/blockFetch/blockFetcher.js +22 -0
  195. package/src/lib/interfaces/blockFetch/blockFetcher.js.map +1 -0
  196. package/src/lib/interfaces/blockFetch/enrichedQueryResult.d.ts +43 -0
  197. package/src/lib/interfaces/blockFetch/enrichedQueryResult.d.ts.map +1 -0
  198. package/src/lib/interfaces/blockFetch/enrichedQueryResult.js +13 -0
  199. package/src/lib/interfaces/blockFetch/enrichedQueryResult.js.map +1 -0
  200. package/src/lib/interfaces/blockFetch/fetchQueue.d.ts +70 -0
  201. package/src/lib/interfaces/blockFetch/fetchQueue.d.ts.map +1 -0
  202. package/src/lib/interfaces/blockFetch/fetchQueue.js +18 -0
  203. package/src/lib/interfaces/blockFetch/fetchQueue.js.map +1 -0
  204. package/src/lib/interfaces/blockFetch/index.d.ts +10 -0
  205. package/src/lib/interfaces/blockFetch/index.d.ts.map +1 -0
  206. package/src/lib/interfaces/blockFetch/index.js +13 -0
  207. package/src/lib/interfaces/blockFetch/index.js.map +1 -0
  208. package/src/lib/interfaces/blocks/index.d.ts +1 -0
  209. package/src/lib/interfaces/blocks/index.d.ts.map +1 -1
  210. package/src/lib/interfaces/blocks/vcbl.d.ts +16 -0
  211. package/src/lib/interfaces/blocks/vcbl.d.ts.map +1 -0
  212. package/src/lib/interfaces/blocks/vcbl.js +3 -0
  213. package/src/lib/interfaces/blocks/vcbl.js.map +1 -0
  214. package/src/lib/interfaces/brightpass/auditLog.d.ts +25 -0
  215. package/src/lib/interfaces/brightpass/auditLog.d.ts.map +1 -0
  216. package/src/lib/interfaces/brightpass/auditLog.js +21 -0
  217. package/src/lib/interfaces/brightpass/auditLog.js.map +1 -0
  218. package/src/lib/interfaces/brightpass/emergencyAccess.d.ts +11 -0
  219. package/src/lib/interfaces/brightpass/emergencyAccess.d.ts.map +1 -0
  220. package/src/lib/interfaces/brightpass/emergencyAccess.js +3 -0
  221. package/src/lib/interfaces/brightpass/emergencyAccess.js.map +1 -0
  222. package/src/lib/interfaces/brightpass/entryPropertyRecord.d.ts +11 -0
  223. package/src/lib/interfaces/brightpass/entryPropertyRecord.d.ts.map +1 -0
  224. package/src/lib/interfaces/brightpass/entryPropertyRecord.js +3 -0
  225. package/src/lib/interfaces/brightpass/entryPropertyRecord.js.map +1 -0
  226. package/src/lib/interfaces/brightpass/importTypes.d.ts +10 -0
  227. package/src/lib/interfaces/brightpass/importTypes.d.ts.map +1 -0
  228. package/src/lib/interfaces/brightpass/importTypes.js +3 -0
  229. package/src/lib/interfaces/brightpass/importTypes.js.map +1 -0
  230. package/src/lib/interfaces/brightpass/index.d.ts +7 -0
  231. package/src/lib/interfaces/brightpass/index.d.ts.map +1 -0
  232. package/src/lib/interfaces/brightpass/index.js +10 -0
  233. package/src/lib/interfaces/brightpass/index.js.map +1 -0
  234. package/src/lib/interfaces/brightpass/vaultEntry.d.ts +48 -0
  235. package/src/lib/interfaces/brightpass/vaultEntry.d.ts.map +1 -0
  236. package/src/lib/interfaces/brightpass/vaultEntry.js +3 -0
  237. package/src/lib/interfaces/brightpass/vaultEntry.js.map +1 -0
  238. package/src/lib/interfaces/brightpass/vaultMetadata.d.ts +34 -0
  239. package/src/lib/interfaces/brightpass/vaultMetadata.d.ts.map +1 -0
  240. package/src/lib/interfaces/brightpass/vaultMetadata.js +3 -0
  241. package/src/lib/interfaces/brightpass/vaultMetadata.js.map +1 -0
  242. package/src/lib/interfaces/clusterKeys.d.ts +4 -2
  243. package/src/lib/interfaces/clusterKeys.d.ts.map +1 -1
  244. package/src/lib/interfaces/communication.d.ts +173 -0
  245. package/src/lib/interfaces/communication.d.ts.map +1 -0
  246. package/src/lib/interfaces/communication.js +17 -0
  247. package/src/lib/interfaces/communication.js.map +1 -0
  248. package/src/lib/interfaces/communicationEvents.d.ts +168 -0
  249. package/src/lib/interfaces/communicationEvents.d.ts.map +1 -0
  250. package/src/lib/interfaces/communicationEvents.js +12 -0
  251. package/src/lib/interfaces/communicationEvents.js.map +1 -0
  252. package/src/lib/interfaces/crypto/ethereumWallet.d.ts +72 -0
  253. package/src/lib/interfaces/crypto/ethereumWallet.d.ts.map +1 -0
  254. package/src/lib/interfaces/crypto/ethereumWallet.js +12 -0
  255. package/src/lib/interfaces/crypto/ethereumWallet.js.map +1 -0
  256. package/src/lib/interfaces/crypto/gitSignature.d.ts +95 -0
  257. package/src/lib/interfaces/crypto/gitSignature.d.ts.map +1 -0
  258. package/src/lib/interfaces/crypto/gitSignature.js +12 -0
  259. package/src/lib/interfaces/crypto/gitSignature.js.map +1 -0
  260. package/src/lib/interfaces/crypto/index.d.ts +3 -0
  261. package/src/lib/interfaces/crypto/index.d.ts.map +1 -0
  262. package/src/lib/interfaces/crypto/index.js +3 -0
  263. package/src/lib/interfaces/crypto/index.js.map +1 -0
  264. package/src/lib/interfaces/dataKeyComponents.d.ts +7 -2
  265. package/src/lib/interfaces/dataKeyComponents.d.ts.map +1 -1
  266. package/src/lib/interfaces/encryptedBlockCreator.d.ts +4 -2
  267. package/src/lib/interfaces/encryptedBlockCreator.d.ts.map +1 -1
  268. package/src/lib/interfaces/events/communicationEventEmitter.d.ts +65 -0
  269. package/src/lib/interfaces/events/communicationEventEmitter.d.ts.map +1 -0
  270. package/src/lib/interfaces/events/communicationEventEmitter.js +60 -0
  271. package/src/lib/interfaces/events/communicationEventEmitter.js.map +1 -0
  272. package/src/lib/interfaces/events/index.d.ts +2 -0
  273. package/src/lib/interfaces/events/index.d.ts.map +1 -0
  274. package/src/lib/interfaces/events/index.js +5 -0
  275. package/src/lib/interfaces/events/index.js.map +1 -0
  276. package/src/lib/interfaces/failableResult.d.ts +15 -0
  277. package/src/lib/interfaces/failableResult.d.ts.map +1 -0
  278. package/src/lib/interfaces/failableResult.js +3 -0
  279. package/src/lib/interfaces/failableResult.js.map +1 -0
  280. package/src/lib/interfaces/identity/device.d.ts +59 -0
  281. package/src/lib/interfaces/identity/device.d.ts.map +1 -0
  282. package/src/lib/interfaces/identity/device.js +17 -0
  283. package/src/lib/interfaces/identity/device.js.map +1 -0
  284. package/src/lib/interfaces/identity/deviceKeyStorage.d.ts +71 -0
  285. package/src/lib/interfaces/identity/deviceKeyStorage.d.ts.map +1 -0
  286. package/src/lib/interfaces/identity/deviceKeyStorage.js +16 -0
  287. package/src/lib/interfaces/identity/deviceKeyStorage.js.map +1 -0
  288. package/src/lib/interfaces/identity/identityProof.d.ts +90 -0
  289. package/src/lib/interfaces/identity/identityProof.d.ts.map +1 -0
  290. package/src/lib/interfaces/identity/identityProof.js +18 -0
  291. package/src/lib/interfaces/identity/identityProof.js.map +1 -0
  292. package/src/lib/interfaces/identity/index.d.ts +7 -0
  293. package/src/lib/interfaces/identity/index.d.ts.map +1 -0
  294. package/src/lib/interfaces/identity/index.js +3 -0
  295. package/src/lib/interfaces/identity/index.js.map +1 -0
  296. package/src/lib/interfaces/identity/paperKey.d.ts +97 -0
  297. package/src/lib/interfaces/identity/paperKey.d.ts.map +1 -0
  298. package/src/lib/interfaces/identity/paperKey.js +17 -0
  299. package/src/lib/interfaces/identity/paperKey.js.map +1 -0
  300. package/src/lib/interfaces/identity/publicProfile.d.ts +74 -0
  301. package/src/lib/interfaces/identity/publicProfile.d.ts.map +1 -0
  302. package/src/lib/interfaces/identity/publicProfile.js +18 -0
  303. package/src/lib/interfaces/identity/publicProfile.js.map +1 -0
  304. package/src/lib/interfaces/identity/splitPaperKey.d.ts +73 -0
  305. package/src/lib/interfaces/identity/splitPaperKey.d.ts.map +1 -0
  306. package/src/lib/interfaces/identity/splitPaperKey.js +20 -0
  307. package/src/lib/interfaces/identity/splitPaperKey.js.map +1 -0
  308. package/src/lib/interfaces/index.d.ts +11 -2
  309. package/src/lib/interfaces/index.d.ts.map +1 -1
  310. package/src/lib/interfaces/index.js +12 -0
  311. package/src/lib/interfaces/index.js.map +1 -1
  312. package/src/lib/interfaces/network/node.d.ts +4 -2
  313. package/src/lib/interfaces/network/node.d.ts.map +1 -1
  314. package/src/lib/interfaces/network/nodeAdvertisement.d.ts +4 -2
  315. package/src/lib/interfaces/network/nodeAdvertisement.d.ts.map +1 -1
  316. package/src/lib/interfaces/privateVotingDerivation.d.ts +7 -2
  317. package/src/lib/interfaces/privateVotingDerivation.d.ts.map +1 -1
  318. package/src/lib/interfaces/requests/communicationRequests.d.ts +154 -0
  319. package/src/lib/interfaces/requests/communicationRequests.d.ts.map +1 -0
  320. package/src/lib/interfaces/requests/communicationRequests.js +10 -0
  321. package/src/lib/interfaces/requests/communicationRequests.js.map +1 -0
  322. package/src/lib/interfaces/requests/index.d.ts +2 -0
  323. package/src/lib/interfaces/requests/index.d.ts.map +1 -0
  324. package/src/lib/interfaces/requests/index.js +3 -0
  325. package/src/lib/interfaces/requests/index.js.map +1 -0
  326. package/src/lib/interfaces/responses/blockDataResponse.d.ts +11 -0
  327. package/src/lib/interfaces/responses/blockDataResponse.d.ts.map +1 -0
  328. package/src/lib/interfaces/responses/blockDataResponse.js +3 -0
  329. package/src/lib/interfaces/responses/blockDataResponse.js.map +1 -0
  330. package/src/lib/interfaces/responses/communicationResponses.d.ts +82 -0
  331. package/src/lib/interfaces/responses/communicationResponses.d.ts.map +1 -0
  332. package/src/lib/interfaces/responses/communicationResponses.js +17 -0
  333. package/src/lib/interfaces/responses/communicationResponses.js.map +1 -0
  334. package/src/lib/interfaces/responses/cryptoResponses.d.ts +30 -0
  335. package/src/lib/interfaces/responses/cryptoResponses.d.ts.map +1 -0
  336. package/src/lib/interfaces/responses/cryptoResponses.js +12 -0
  337. package/src/lib/interfaces/responses/cryptoResponses.js.map +1 -0
  338. package/src/lib/interfaces/responses/deviceResponses.d.ts +26 -0
  339. package/src/lib/interfaces/responses/deviceResponses.d.ts.map +1 -0
  340. package/src/lib/interfaces/responses/deviceResponses.js +15 -0
  341. package/src/lib/interfaces/responses/deviceResponses.js.map +1 -0
  342. package/src/lib/interfaces/responses/directoryResponses.d.ts +26 -0
  343. package/src/lib/interfaces/responses/directoryResponses.d.ts.map +1 -0
  344. package/src/lib/interfaces/responses/directoryResponses.js +12 -0
  345. package/src/lib/interfaces/responses/directoryResponses.js.map +1 -0
  346. package/src/lib/interfaces/responses/emailResponses.d.ts +40 -0
  347. package/src/lib/interfaces/responses/emailResponses.d.ts.map +1 -0
  348. package/src/lib/interfaces/responses/emailResponses.js +18 -0
  349. package/src/lib/interfaces/responses/emailResponses.js.map +1 -0
  350. package/src/lib/interfaces/responses/explodingMessageResponses.d.ts +42 -0
  351. package/src/lib/interfaces/responses/explodingMessageResponses.d.ts.map +1 -0
  352. package/src/lib/interfaces/responses/explodingMessageResponses.js +11 -0
  353. package/src/lib/interfaces/responses/explodingMessageResponses.js.map +1 -0
  354. package/src/lib/interfaces/responses/identityProofResponses.d.ts +33 -0
  355. package/src/lib/interfaces/responses/identityProofResponses.d.ts.map +1 -0
  356. package/src/lib/interfaces/responses/identityProofResponses.js +12 -0
  357. package/src/lib/interfaces/responses/identityProofResponses.js.map +1 -0
  358. package/src/lib/interfaces/responses/index.d.ts +3 -1
  359. package/src/lib/interfaces/responses/index.d.ts.map +1 -1
  360. package/src/lib/interfaces/sealResults.d.ts +7 -2
  361. package/src/lib/interfaces/sealResults.d.ts.map +1 -1
  362. package/src/lib/interfaces/services/fecService.d.ts +7 -5
  363. package/src/lib/interfaces/services/fecService.d.ts.map +1 -1
  364. package/src/lib/interfaces/services/fecService.js +2 -0
  365. package/src/lib/interfaces/services/fecService.js.map +1 -1
  366. package/src/lib/interfaces/singleEncryptedBlockDetails.d.ts +7 -2
  367. package/src/lib/interfaces/singleEncryptedBlockDetails.d.ts.map +1 -1
  368. package/src/lib/interfaces/storage/blockMetadata.d.ts +8 -1
  369. package/src/lib/interfaces/storage/blockMetadata.d.ts.map +1 -1
  370. package/src/lib/interfaces/storage/blockMetadata.js +3 -1
  371. package/src/lib/interfaces/storage/blockMetadata.js.map +1 -1
  372. package/src/lib/interfaces/storage/cblIndex.d.ts +141 -0
  373. package/src/lib/interfaces/storage/cblIndex.d.ts.map +1 -0
  374. package/src/lib/interfaces/storage/cblIndex.js +28 -0
  375. package/src/lib/interfaces/storage/cblIndex.js.map +1 -0
  376. package/src/lib/interfaces/storage/clientSession.d.ts +22 -0
  377. package/src/lib/interfaces/storage/clientSession.d.ts.map +1 -0
  378. package/src/lib/interfaces/storage/clientSession.js +3 -0
  379. package/src/lib/interfaces/storage/clientSession.js.map +1 -0
  380. package/src/lib/interfaces/storage/collection.d.ts +80 -0
  381. package/src/lib/interfaces/storage/collection.d.ts.map +1 -0
  382. package/src/lib/interfaces/storage/collection.js +3 -0
  383. package/src/lib/interfaces/storage/collection.js.map +1 -0
  384. package/src/lib/interfaces/storage/database.d.ts +30 -0
  385. package/src/lib/interfaces/storage/database.d.ts.map +1 -0
  386. package/src/lib/interfaces/storage/database.js +3 -0
  387. package/src/lib/interfaces/storage/database.js.map +1 -0
  388. package/src/lib/interfaces/storage/databaseLifecycleHooks.d.ts +43 -0
  389. package/src/lib/interfaces/storage/databaseLifecycleHooks.d.ts.map +1 -0
  390. package/src/lib/interfaces/storage/databaseLifecycleHooks.js +3 -0
  391. package/src/lib/interfaces/storage/databaseLifecycleHooks.js.map +1 -0
  392. package/src/lib/interfaces/storage/documentTypes.d.ts +413 -0
  393. package/src/lib/interfaces/storage/documentTypes.d.ts.map +1 -0
  394. package/src/lib/interfaces/storage/documentTypes.js +8 -0
  395. package/src/lib/interfaces/storage/documentTypes.js.map +1 -0
  396. package/src/lib/interfaces/storage/encryptedPool.d.ts +64 -0
  397. package/src/lib/interfaces/storage/encryptedPool.d.ts.map +1 -0
  398. package/src/lib/interfaces/storage/encryptedPool.js +26 -0
  399. package/src/lib/interfaces/storage/encryptedPool.js.map +1 -0
  400. package/src/lib/interfaces/storage/headRegistry.d.ts +128 -0
  401. package/src/lib/interfaces/storage/headRegistry.d.ts.map +1 -0
  402. package/src/lib/interfaces/storage/headRegistry.js +3 -0
  403. package/src/lib/interfaces/storage/headRegistry.js.map +1 -0
  404. package/src/lib/interfaces/storage/index.d.ts +14 -0
  405. package/src/lib/interfaces/storage/index.d.ts.map +1 -1
  406. package/src/lib/interfaces/storage/index.js +14 -1
  407. package/src/lib/interfaces/storage/index.js.map +1 -1
  408. package/src/lib/interfaces/storage/pooledBlockStore.d.ts +163 -0
  409. package/src/lib/interfaces/storage/pooledBlockStore.d.ts.map +1 -0
  410. package/src/lib/interfaces/storage/pooledBlockStore.js +77 -0
  411. package/src/lib/interfaces/storage/pooledBlockStore.js.map +1 -0
  412. package/src/lib/interfaces/storage/readConcernBlockStore.d.ts +47 -0
  413. package/src/lib/interfaces/storage/readConcernBlockStore.d.ts.map +1 -0
  414. package/src/lib/interfaces/storage/readConcernBlockStore.js +29 -0
  415. package/src/lib/interfaces/storage/readConcernBlockStore.js.map +1 -0
  416. package/src/lib/interfaces/symmetricEncryptionResults.d.ts +7 -5
  417. package/src/lib/interfaces/symmetricEncryptionResults.d.ts.map +1 -1
  418. package/src/lib/services/blockCapacity.service.d.ts.map +1 -1
  419. package/src/lib/services/blockCapacity.service.js +15 -0
  420. package/src/lib/services/blockCapacity.service.js.map +1 -1
  421. package/src/lib/services/brightpass/auditLogger.d.ts +41 -0
  422. package/src/lib/services/brightpass/auditLogger.d.ts.map +1 -0
  423. package/src/lib/services/brightpass/auditLogger.js +47 -0
  424. package/src/lib/services/brightpass/auditLogger.js.map +1 -0
  425. package/src/lib/services/brightpass/breachDetector.d.ts +68 -0
  426. package/src/lib/services/brightpass/breachDetector.d.ts.map +1 -0
  427. package/src/lib/services/brightpass/breachDetector.js +102 -0
  428. package/src/lib/services/brightpass/breachDetector.js.map +1 -0
  429. package/src/lib/services/brightpass/importParser.d.ts +105 -0
  430. package/src/lib/services/brightpass/importParser.d.ts.map +1 -0
  431. package/src/lib/services/brightpass/importParser.js +380 -0
  432. package/src/lib/services/brightpass/importParser.js.map +1 -0
  433. package/src/lib/services/brightpass/index.d.ts +16 -0
  434. package/src/lib/services/brightpass/index.d.ts.map +1 -0
  435. package/src/lib/services/brightpass/index.js +19 -0
  436. package/src/lib/services/brightpass/index.js.map +1 -0
  437. package/src/lib/services/brightpass/passwordGenerator.d.ts +111 -0
  438. package/src/lib/services/brightpass/passwordGenerator.d.ts.map +1 -0
  439. package/src/lib/services/brightpass/passwordGenerator.js +162 -0
  440. package/src/lib/services/brightpass/passwordGenerator.js.map +1 -0
  441. package/src/lib/services/brightpass/totpEngine.d.ts +191 -0
  442. package/src/lib/services/brightpass/totpEngine.d.ts.map +1 -0
  443. package/src/lib/services/brightpass/totpEngine.js +198 -0
  444. package/src/lib/services/brightpass/totpEngine.js.map +1 -0
  445. package/src/lib/services/brightpass/vaultKeyDerivation.d.ts +26 -0
  446. package/src/lib/services/brightpass/vaultKeyDerivation.d.ts.map +1 -0
  447. package/src/lib/services/brightpass/vaultKeyDerivation.js +42 -0
  448. package/src/lib/services/brightpass/vaultKeyDerivation.js.map +1 -0
  449. package/src/lib/services/brightpass/vaultSerializer.d.ts +14 -0
  450. package/src/lib/services/brightpass/vaultSerializer.d.ts.map +1 -0
  451. package/src/lib/services/brightpass/vaultSerializer.js +77 -0
  452. package/src/lib/services/brightpass/vaultSerializer.js.map +1 -0
  453. package/src/lib/services/cblService.d.ts +4 -2
  454. package/src/lib/services/cblService.d.ts.map +1 -1
  455. package/src/lib/services/cblService.js +8 -4
  456. package/src/lib/services/cblService.js.map +1 -1
  457. package/src/lib/services/communication/channelService.d.ts +208 -0
  458. package/src/lib/services/communication/channelService.d.ts.map +1 -0
  459. package/src/lib/services/communication/channelService.js +575 -0
  460. package/src/lib/services/communication/channelService.js.map +1 -0
  461. package/src/lib/services/communication/conversationService.d.ts +130 -0
  462. package/src/lib/services/communication/conversationService.d.ts.map +1 -0
  463. package/src/lib/services/communication/conversationService.js +279 -0
  464. package/src/lib/services/communication/conversationService.js.map +1 -0
  465. package/src/lib/services/communication/explodingMessageService.d.ts +168 -0
  466. package/src/lib/services/communication/explodingMessageService.d.ts.map +1 -0
  467. package/src/lib/services/communication/explodingMessageService.js +287 -0
  468. package/src/lib/services/communication/explodingMessageService.js.map +1 -0
  469. package/src/lib/services/communication/groupService.d.ts +165 -0
  470. package/src/lib/services/communication/groupService.d.ts.map +1 -0
  471. package/src/lib/services/communication/groupService.js +437 -0
  472. package/src/lib/services/communication/groupService.js.map +1 -0
  473. package/src/lib/services/communication/index.d.ts +16 -0
  474. package/src/lib/services/communication/index.d.ts.map +1 -0
  475. package/src/lib/services/communication/index.js +63 -0
  476. package/src/lib/services/communication/index.js.map +1 -0
  477. package/src/lib/services/communication/messageOperationsService.d.ts +81 -0
  478. package/src/lib/services/communication/messageOperationsService.d.ts.map +1 -0
  479. package/src/lib/services/communication/messageOperationsService.js +162 -0
  480. package/src/lib/services/communication/messageOperationsService.js.map +1 -0
  481. package/src/lib/services/communication/permissionService.d.ts +47 -0
  482. package/src/lib/services/communication/permissionService.d.ts.map +1 -0
  483. package/src/lib/services/communication/permissionService.js +82 -0
  484. package/src/lib/services/communication/permissionService.js.map +1 -0
  485. package/src/lib/services/communication/searchService.d.ts +30 -0
  486. package/src/lib/services/communication/searchService.d.ts.map +1 -0
  487. package/src/lib/services/communication/searchService.js +83 -0
  488. package/src/lib/services/communication/searchService.js.map +1 -0
  489. package/src/lib/services/crypto/ethereumWalletService.d.ts +159 -0
  490. package/src/lib/services/crypto/ethereumWalletService.d.ts.map +1 -0
  491. package/src/lib/services/crypto/ethereumWalletService.js +345 -0
  492. package/src/lib/services/crypto/ethereumWalletService.js.map +1 -0
  493. package/src/lib/services/crypto/gitSigningService.d.ts +145 -0
  494. package/src/lib/services/crypto/gitSigningService.d.ts.map +1 -0
  495. package/src/lib/services/crypto/gitSigningService.js +291 -0
  496. package/src/lib/services/crypto/gitSigningService.js.map +1 -0
  497. package/src/lib/services/crypto/index.d.ts +3 -0
  498. package/src/lib/services/crypto/index.d.ts.map +1 -0
  499. package/src/lib/services/crypto/index.js +6 -0
  500. package/src/lib/services/crypto/index.js.map +1 -0
  501. package/src/lib/services/identity/deviceProvisioningService.d.ts +146 -0
  502. package/src/lib/services/identity/deviceProvisioningService.d.ts.map +1 -0
  503. package/src/lib/services/identity/deviceProvisioningService.js +219 -0
  504. package/src/lib/services/identity/deviceProvisioningService.js.map +1 -0
  505. package/src/lib/services/identity/identityProofService.d.ts +139 -0
  506. package/src/lib/services/identity/identityProofService.d.ts.map +1 -0
  507. package/src/lib/services/identity/identityProofService.js +245 -0
  508. package/src/lib/services/identity/identityProofService.js.map +1 -0
  509. package/src/lib/services/identity/index.d.ts +14 -0
  510. package/src/lib/services/identity/index.d.ts.map +1 -0
  511. package/src/lib/services/identity/index.js +17 -0
  512. package/src/lib/services/identity/index.js.map +1 -0
  513. package/src/lib/services/identity/memberIdentityProofService.d.ts +179 -0
  514. package/src/lib/services/identity/memberIdentityProofService.d.ts.map +1 -0
  515. package/src/lib/services/identity/memberIdentityProofService.js +232 -0
  516. package/src/lib/services/identity/memberIdentityProofService.js.map +1 -0
  517. package/src/lib/services/identity/memberPaperKeyService.d.ts +223 -0
  518. package/src/lib/services/identity/memberPaperKeyService.d.ts.map +1 -0
  519. package/src/lib/services/identity/memberPaperKeyService.js +279 -0
  520. package/src/lib/services/identity/memberPaperKeyService.js.map +1 -0
  521. package/src/lib/services/identity/paperKeyService.d.ts +106 -0
  522. package/src/lib/services/identity/paperKeyService.d.ts.map +1 -0
  523. package/src/lib/services/identity/paperKeyService.js +161 -0
  524. package/src/lib/services/identity/paperKeyService.js.map +1 -0
  525. package/src/lib/services/identity/publicKeyDirectoryService.d.ts +210 -0
  526. package/src/lib/services/identity/publicKeyDirectoryService.d.ts.map +1 -0
  527. package/src/lib/services/identity/publicKeyDirectoryService.js +328 -0
  528. package/src/lib/services/identity/publicKeyDirectoryService.js.map +1 -0
  529. package/src/lib/services/identity/splitPaperKeyService.d.ts +92 -0
  530. package/src/lib/services/identity/splitPaperKeyService.d.ts.map +1 -0
  531. package/src/lib/services/identity/splitPaperKeyService.js +305 -0
  532. package/src/lib/services/identity/splitPaperKeyService.js.map +1 -0
  533. package/src/lib/services/index.d.ts +4 -0
  534. package/src/lib/services/index.d.ts.map +1 -1
  535. package/src/lib/services/index.js +7 -0
  536. package/src/lib/services/index.js.map +1 -1
  537. package/src/lib/services/messaging/emailMessageService.d.ts.map +1 -1
  538. package/src/lib/services/messaging/emailMessageService.js +26 -9
  539. package/src/lib/services/messaging/emailMessageService.js.map +1 -1
  540. package/src/lib/services/messaging/emailParser.d.ts +18 -0
  541. package/src/lib/services/messaging/emailParser.d.ts.map +1 -1
  542. package/src/lib/services/messaging/emailParser.js +18 -0
  543. package/src/lib/services/messaging/emailParser.js.map +1 -1
  544. package/src/lib/services/tuple.service.d.ts +27 -2
  545. package/src/lib/services/tuple.service.d.ts.map +1 -1
  546. package/src/lib/services/tuple.service.js +62 -20
  547. package/src/lib/services/tuple.service.js.map +1 -1
  548. package/src/lib/services/vcblService.d.ts +36 -0
  549. package/src/lib/services/vcblService.d.ts.map +1 -0
  550. package/src/lib/services/vcblService.js +326 -0
  551. package/src/lib/services/vcblService.js.map +1 -0
  552. package/src/lib/stores/index.d.ts +1 -0
  553. package/src/lib/stores/index.d.ts.map +1 -1
  554. package/src/lib/stores/index.js +1 -0
  555. package/src/lib/stores/index.js.map +1 -1
  556. package/src/lib/stores/pooledMemoryBlockStore.d.ts +134 -0
  557. package/src/lib/stores/pooledMemoryBlockStore.d.ts.map +1 -0
  558. package/src/lib/stores/pooledMemoryBlockStore.js +583 -0
  559. package/src/lib/stores/pooledMemoryBlockStore.js.map +1 -0
  560. package/src/lib/types/checksum.d.ts +11 -0
  561. package/src/lib/types/checksum.d.ts.map +1 -1
  562. package/src/lib/types/checksum.js +11 -0
  563. package/src/lib/types/checksum.js.map +1 -1
  564. package/src/lib/utils/index.d.ts +9 -0
  565. package/src/lib/utils/index.d.ts.map +1 -1
  566. package/src/lib/utils/index.js +12 -0
  567. package/src/lib/utils/index.js.map +1 -1
  568. package/src/lib/utils/pagination.d.ts +27 -0
  569. package/src/lib/utils/pagination.d.ts.map +1 -0
  570. package/src/lib/utils/pagination.js +38 -0
  571. package/src/lib/utils/pagination.js.map +1 -0
@@ -0,0 +1,219 @@
1
+ "use strict";
2
+ /**
3
+ * Device Provisioning Service for the BrightChain identity system.
4
+ *
5
+ * Handles the complete device provisioning workflow: validating a paper key,
6
+ * recovering the member identity, generating device-specific keys via BIP32
7
+ * hierarchical deterministic derivation, and persisting device metadata
8
+ * through a platform-independent storage interface.
9
+ *
10
+ * Device keys are derived using the BIP32 path `m/44'/60'/0'/1/<deviceIndex>`
11
+ * where `deviceIndex` is a monotonically increasing counter per member. This
12
+ * keeps device keys deterministic (reproducible from the same mnemonic) while
13
+ * ensuring each device gets a unique key pair.
14
+ *
15
+ * Requirements: 3.1, 3.2, 3.3, 3.4
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.DeviceProvisioningService = exports.DeviceKeyStorageError = exports.DeviceKeyGenerationError = exports.InvalidPaperKeyError = void 0;
19
+ const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
20
+ const bip32_1 = require("@scure/bip32");
21
+ const bip39_1 = require("@scure/bip39");
22
+ const uuid_1 = require("uuid");
23
+ const paperKeyService_1 = require("./paperKeyService");
24
+ // ─── Constants ──────────────────────────────────────────────────────────────
25
+ /**
26
+ * BIP32 derivation path prefix for device keys.
27
+ *
28
+ * Uses BIP44 structure: `m / purpose' / coin_type' / account' / change / index`
29
+ * - purpose = 44 (BIP44)
30
+ * - coin_type = 60 (Ethereum, reused for BrightChain compatibility)
31
+ * - account = 0 (default account)
32
+ * - change = 1 (internal chain — used for device keys to avoid collision
33
+ * with external wallet addresses on change=0)
34
+ *
35
+ * The final `/<index>` segment is appended per device.
36
+ */
37
+ const DEVICE_KEY_DERIVATION_PREFIX = "m/44'/60'/0'/1";
38
+ // ─── Error classes ──────────────────────────────────────────────────────────
39
+ /**
40
+ * Error thrown when a paper key fails validation during device provisioning.
41
+ */
42
+ class InvalidPaperKeyError extends Error {
43
+ constructor(message = 'Invalid paper key: not a valid 24-word BIP39 mnemonic') {
44
+ super(message);
45
+ this.name = 'InvalidPaperKeyError';
46
+ }
47
+ }
48
+ exports.InvalidPaperKeyError = InvalidPaperKeyError;
49
+ /**
50
+ * Error thrown when device key generation fails.
51
+ */
52
+ class DeviceKeyGenerationError extends Error {
53
+ constructor(message) {
54
+ super(message);
55
+ this.name = 'DeviceKeyGenerationError';
56
+ }
57
+ }
58
+ exports.DeviceKeyGenerationError = DeviceKeyGenerationError;
59
+ /**
60
+ * Error thrown when device key storage fails.
61
+ */
62
+ class DeviceKeyStorageError extends Error {
63
+ constructor(message) {
64
+ super(message);
65
+ this.name = 'DeviceKeyStorageError';
66
+ }
67
+ }
68
+ exports.DeviceKeyStorageError = DeviceKeyStorageError;
69
+ // ─── Service ────────────────────────────────────────────────────────────────
70
+ /**
71
+ * Service for provisioning new devices on a BrightChain member account.
72
+ *
73
+ * The provisioning flow:
74
+ * 1. Validate the paper key (Requirement 3.1)
75
+ * 2. Recover the member identity from the paper key (Requirement 3.2)
76
+ * 3. Generate device-specific keys via BIP32 derivation (Requirement 3.3)
77
+ * 4. Store device metadata in platform-independent storage (Requirement 3.4)
78
+ *
79
+ * All methods are static — the service is stateless and safe to call
80
+ * from any context (browser or Node.js).
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * const eciesService = ServiceProvider.getInstance().eciesService;
85
+ * const storage = new InMemoryDeviceKeyStorage();
86
+ *
87
+ * const result = await DeviceProvisioningService.provisionDevice(
88
+ * 'abandon abandon abandon ... about',
89
+ * 'Work Laptop',
90
+ * DeviceType.DESKTOP,
91
+ * eciesService,
92
+ * storage,
93
+ * 0,
94
+ * );
95
+ *
96
+ * console.log(result.deviceMetadata.publicKey); // hex-encoded public key
97
+ * console.log(result.member.name); // 'Recovered User'
98
+ * ```
99
+ */
100
+ class DeviceProvisioningService {
101
+ /**
102
+ * Provision a new device using a paper key.
103
+ *
104
+ * Performs the complete provisioning workflow: validates the paper key,
105
+ * recovers the member identity, generates device-specific keys, and
106
+ * stores the device metadata.
107
+ *
108
+ * **Validates: Requirements 3.1, 3.2, 3.3, 3.4**
109
+ *
110
+ * @param paperKey - The 24-word BIP39 mnemonic paper key
111
+ * @param deviceName - Human-readable name for the device (e.g. "Work Laptop")
112
+ * @param deviceType - Category of the device (desktop, mobile, web)
113
+ * @param eciesService - The ECIES service instance for key operations
114
+ * @param storage - Platform-independent device key storage
115
+ * @param deviceIndex - The BIP32 child index for this device (0-based)
116
+ * @returns A promise resolving to the full provisioning result
117
+ * @throws {InvalidPaperKeyError} If the paper key is invalid
118
+ * @throws {DeviceKeyGenerationError} If key derivation fails
119
+ * @throws {DeviceKeyStorageError} If storage fails
120
+ */
121
+ static async provisionDevice(paperKey, deviceName, deviceType, eciesService, storage, deviceIndex) {
122
+ // Requirement 3.1: Validate paper key before provisioning
123
+ if (!paperKeyService_1.PaperKeyService.validatePaperKey(paperKey, eciesService)) {
124
+ throw new InvalidPaperKeyError();
125
+ }
126
+ // Requirement 3.2: Recover member identity from paper key
127
+ const member = paperKeyService_1.PaperKeyService.recoverFromPaperKey(paperKey, eciesService);
128
+ // Requirement 3.3: Generate device-specific keys
129
+ const deviceKeys = DeviceProvisioningService.generateDeviceKeys(paperKey, deviceIndex);
130
+ // Build device metadata
131
+ const now = new Date();
132
+ const deviceMetadata = {
133
+ id: (0, uuid_1.v4)(),
134
+ memberId: (0, ecies_lib_1.uint8ArrayToHex)(member.idBytes),
135
+ deviceName,
136
+ deviceType,
137
+ publicKey: deviceKeys.publicKeyHex,
138
+ provisionedAt: now,
139
+ lastSeenAt: now,
140
+ };
141
+ // Requirement 3.4: Store device keys in local secure storage
142
+ await DeviceProvisioningService.storeDeviceKeys(deviceMetadata, storage);
143
+ return {
144
+ deviceMetadata,
145
+ member,
146
+ deviceKeys,
147
+ };
148
+ }
149
+ /**
150
+ * Generate device-specific keys from a paper key mnemonic using BIP32
151
+ * hierarchical deterministic derivation.
152
+ *
153
+ * The derivation path is `m/44'/60'/0'/1/<deviceIndex>` where the
154
+ * `change=1` branch is reserved for device keys (as opposed to
155
+ * `change=0` which is used for external wallet addresses).
156
+ *
157
+ * **Validates: Requirement 3.3** — Generate device-specific keys derived
158
+ * from member identity
159
+ *
160
+ * @param paperKey - The 24-word BIP39 mnemonic
161
+ * @param deviceIndex - The child index for this device (0-based, non-hardened)
162
+ * @returns The derived device key result
163
+ * @throws {DeviceKeyGenerationError} If BIP32 derivation fails
164
+ */
165
+ static generateDeviceKeys(paperKey, deviceIndex) {
166
+ if (!Number.isInteger(deviceIndex) || deviceIndex < 0) {
167
+ throw new DeviceKeyGenerationError(`Device index must be a non-negative integer, got ${deviceIndex}`);
168
+ }
169
+ const derivationPath = `${DEVICE_KEY_DERIVATION_PREFIX}/${deviceIndex}`;
170
+ try {
171
+ // Convert mnemonic → 64-byte seed
172
+ const seed = (0, bip39_1.mnemonicToSeedSync)(paperKey);
173
+ // Create HD master key from seed
174
+ const masterKey = bip32_1.HDKey.fromMasterSeed(seed);
175
+ // Derive the device-specific child key
176
+ const deviceKey = masterKey.derive(derivationPath);
177
+ const publicKey = deviceKey.publicKey;
178
+ if (!publicKey) {
179
+ throw new DeviceKeyGenerationError('BIP32 derivation produced no public key');
180
+ }
181
+ return {
182
+ publicKey: new Uint8Array(publicKey),
183
+ publicKeyHex: (0, ecies_lib_1.uint8ArrayToHex)(new Uint8Array(publicKey)),
184
+ derivationPath,
185
+ deviceIndex,
186
+ };
187
+ }
188
+ catch (error) {
189
+ if (error instanceof DeviceKeyGenerationError) {
190
+ throw error;
191
+ }
192
+ const message = error instanceof Error ? error.message : String(error);
193
+ throw new DeviceKeyGenerationError(`Failed to derive device keys at path ${derivationPath}: ${message}`);
194
+ }
195
+ }
196
+ /**
197
+ * Store device metadata in the provided platform-independent storage.
198
+ *
199
+ * This method wraps the storage call with error handling to produce
200
+ * a consistent {@link DeviceKeyStorageError} on failure.
201
+ *
202
+ * **Validates: Requirement 3.4** — Store device keys in local secure storage
203
+ *
204
+ * @param deviceMetadata - The device metadata to persist
205
+ * @param storage - The platform-independent storage implementation
206
+ * @throws {DeviceKeyStorageError} If the storage operation fails
207
+ */
208
+ static async storeDeviceKeys(deviceMetadata, storage) {
209
+ try {
210
+ await storage.store(deviceMetadata);
211
+ }
212
+ catch (error) {
213
+ const message = error instanceof Error ? error.message : String(error);
214
+ throw new DeviceKeyStorageError(`Failed to store device keys for device "${deviceMetadata.deviceName}": ${message}`);
215
+ }
216
+ }
217
+ }
218
+ exports.DeviceProvisioningService = DeviceProvisioningService;
219
+ //# sourceMappingURL=deviceProvisioningService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deviceProvisioningService.js","sourceRoot":"","sources":["../../../../../../brightchain-lib/src/lib/services/identity/deviceProvisioningService.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,0DAKoC;AACpC,wCAAqC;AACrC,wCAAkD;AAClD,+BAAoC;AAKpC,uDAAoD;AAEpD,+EAA+E;AAE/E;;;;;;;;;;;GAWG;AACH,MAAM,4BAA4B,GAAG,gBAAgB,CAAC;AAEtD,+EAA+E;AAE/E;;GAEG;AACH,MAAa,oBAAqB,SAAQ,KAAK;IAC7C,YACE,OAAO,GAAG,uDAAuD;QAEjE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAPD,oDAOC;AAED;;GAEG;AACH,MAAa,wBAAyB,SAAQ,KAAK;IACjD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AALD,4DAKC;AAED;;GAEG;AACH,MAAa,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AALD,sDAKC;AAoCD,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAa,yBAAyB;IACpC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,KAAK,CAAC,eAAe,CAC1B,QAAgB,EAChB,UAAkB,EAClB,UAAsB,EACtB,YAA+B,EAC/B,OAA0B,EAC1B,WAAmB;QA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CAAC;IACH,CAAC;CACF;AAxJD,8DAwJC"}
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Identity Proof Service for the BrightChain identity system.
3
+ *
4
+ * Creates, verifies, and manages cryptographic identity proofs that link
5
+ * a BrightChain member to external platform accounts (Twitter, GitHub,
6
+ * Reddit, personal websites, and blockchain addresses).
7
+ *
8
+ * Each proof contains a signed statement produced with the member's
9
+ * SECP256k1 private key. Anyone with the member's public key can
10
+ * independently verify the proof without contacting BrightChain.
11
+ *
12
+ * The signed statement format (Requirement 4.8):
13
+ * "I am {username} on {platform}. My BrightChain ID is {memberId}. Timestamp: {ISO8601}"
14
+ *
15
+ * Requirements: 4.1, 4.2, 4.3, 4.4, 4.6, 4.9
16
+ */
17
+ import { ECIESService, Member, PlatformID } from '@digitaldefiance/ecies-lib';
18
+ import { ProofPlatform } from '../../enumerations/proofPlatform';
19
+ import { IIdentityProof } from '../../interfaces/identity/identityProof';
20
+ /**
21
+ * Error thrown when an unsupported platform is specified.
22
+ */
23
+ export declare class UnsupportedPlatformError extends Error {
24
+ constructor(platform: string);
25
+ }
26
+ /**
27
+ * Error thrown when proof creation fails (e.g. member has no private key).
28
+ */
29
+ export declare class ProofCreationError extends Error {
30
+ constructor(message: string);
31
+ }
32
+ /**
33
+ * Error thrown when proof URL validation fails.
34
+ */
35
+ export declare class ProofUrlError extends Error {
36
+ constructor(message: string);
37
+ }
38
+ /**
39
+ * Service for creating and verifying cryptographic identity proofs.
40
+ *
41
+ * Identity proofs link a BrightChain member to an external platform
42
+ * account by signing a standardised statement with the member's
43
+ * SECP256k1 private key. The proof can be independently verified by
44
+ * anyone with the member's public key.
45
+ *
46
+ * All methods are static — the service is stateless and safe to call
47
+ * from any context (browser or Node.js).
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * const eciesService = ServiceProvider.getInstance().eciesService;
52
+ * const member = PaperKeyService.recoverFromPaperKey(paperKey, eciesService);
53
+ *
54
+ * // Create a proof
55
+ * const proof = IdentityProofService.create(member, ProofPlatform.GITHUB, 'octocat');
56
+ *
57
+ * // Verify the proof
58
+ * const isValid = IdentityProofService.verify(proof, member.publicKey, eciesService);
59
+ *
60
+ * // Get posting instructions
61
+ * const instructions = IdentityProofService.getInstructions(ProofPlatform.GITHUB);
62
+ * ```
63
+ */
64
+ export declare class IdentityProofService {
65
+ /**
66
+ * Create a new identity proof by signing a statement with the member's
67
+ * SECP256k1 private key.
68
+ *
69
+ * The signed statement follows the format defined in Requirement 4.8:
70
+ * "I am {username} on {platform}. My BrightChain ID is {memberId}. Timestamp: {ISO8601}"
71
+ *
72
+ * **Validates: Requirements 4.1, 4.2, 4.3**
73
+ *
74
+ * @param member - The member creating the proof (must have private key loaded)
75
+ * @param platform - The target platform (must be a valid {@link ProofPlatform} value)
76
+ * @param username - The member's username on the target platform
77
+ * @returns A new {@link IIdentityProof} with status {@link VerificationStatus.PENDING}
78
+ * @throws {UnsupportedPlatformError} If the platform is not a valid {@link ProofPlatform}
79
+ * @throws {ProofCreationError} If the member has no private key loaded
80
+ */
81
+ static create<TID extends PlatformID = Uint8Array>(member: Member<TID>, platform: ProofPlatform, username: string): IIdentityProof;
82
+ /**
83
+ * Verify an identity proof's signature using a public key.
84
+ *
85
+ * Reconstructs the signature from its hex encoding and verifies it
86
+ * against the signed statement using the ECIESService's ECDSA
87
+ * verification.
88
+ *
89
+ * **Validates: Requirement 4.4**
90
+ *
91
+ * @param proof - The identity proof to verify
92
+ * @param publicKey - The SECP256k1 public key to verify against (raw bytes)
93
+ * @param eciesService - The ECIES service instance for signature verification
94
+ * @returns `true` if the signature is valid for the given public key
95
+ */
96
+ static verify<TID extends PlatformID = Uint8Array>(proof: IIdentityProof, publicKey: Uint8Array, eciesService: ECIESService<TID>): boolean;
97
+ /**
98
+ * Check whether a proof URL contains the expected signed statement.
99
+ *
100
+ * Fetches the proof URL and checks that the response body includes
101
+ * the full signed statement text. This is used for initial verification
102
+ * and periodic re-verification (Requirement 4.10).
103
+ *
104
+ * **Validates: Requirement 4.6**
105
+ *
106
+ * @param proof - The identity proof whose URL to check
107
+ * @returns A promise resolving to `true` if the URL is accessible and
108
+ * contains the signed statement, `false` otherwise
109
+ */
110
+ static checkProofUrl(proof: IIdentityProof): Promise<boolean>;
111
+ /**
112
+ * Get platform-specific instructions for posting an identity proof.
113
+ *
114
+ * Returns human-readable instructions explaining how to post the
115
+ * signed statement on the specified platform and what URL to provide
116
+ * for verification.
117
+ *
118
+ * **Validates: Requirement 4.9**
119
+ *
120
+ * @param platform - The target platform
121
+ * @returns Instructions string for the specified platform, or a generic
122
+ * fallback for unrecognised platforms
123
+ */
124
+ static getInstructions(platform: ProofPlatform | string): string;
125
+ /**
126
+ * Build the signed statement string for a given set of parameters.
127
+ *
128
+ * This is a utility method that produces the statement text without
129
+ * signing it. Useful for previewing the statement before creation.
130
+ *
131
+ * @param username - The member's username on the target platform
132
+ * @param platform - The target platform
133
+ * @param memberId - The member's hex-encoded ID
134
+ * @param timestamp - ISO 8601 timestamp string
135
+ * @returns The formatted statement string per Requirement 4.8
136
+ */
137
+ static buildStatement(username: string, platform: ProofPlatform | string, memberId: string, timestamp: string): string;
138
+ }
139
+ //# sourceMappingURL=identityProofService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identityProofService.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-lib/src/lib/services/identity/identityProofService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,YAAY,EAEZ,MAAM,EACN,UAAU,EAGX,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAIzE;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,QAAQ,EAAE,MAAM;CAI7B;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAI5B;AAqCD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,oBAAoB;IAC/B;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,MAAM,CAAC,GAAG,SAAS,UAAU,GAAG,UAAU,EAC/C,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,EACnB,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,MAAM,GACf,cAAc;IA2CjB;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,MAAM,CAAC,GAAG,SAAS,UAAU,GAAG,UAAU,EAC/C,KAAK,EAAE,cAAc,EACrB,SAAS,EAAE,UAAU,EACrB,YAAY,EAAE,YAAY,CAAC,GAAG,CAAC,GAC9B,OAAO;IAiBV;;;;;;;;;;;;OAYG;WACU,aAAa,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAiBnE;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,GAAG,MAAM;IAOhE;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,cAAc,CACnB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,aAAa,GAAG,MAAM,EAChC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,MAAM;CAGV"}
@@ -0,0 +1,245 @@
1
+ "use strict";
2
+ /**
3
+ * Identity Proof Service for the BrightChain identity system.
4
+ *
5
+ * Creates, verifies, and manages cryptographic identity proofs that link
6
+ * a BrightChain member to external platform accounts (Twitter, GitHub,
7
+ * Reddit, personal websites, and blockchain addresses).
8
+ *
9
+ * Each proof contains a signed statement produced with the member's
10
+ * SECP256k1 private key. Anyone with the member's public key can
11
+ * independently verify the proof without contacting BrightChain.
12
+ *
13
+ * The signed statement format (Requirement 4.8):
14
+ * "I am {username} on {platform}. My BrightChain ID is {memberId}. Timestamp: {ISO8601}"
15
+ *
16
+ * Requirements: 4.1, 4.2, 4.3, 4.4, 4.6, 4.9
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.IdentityProofService = exports.ProofUrlError = exports.ProofCreationError = exports.UnsupportedPlatformError = void 0;
20
+ const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
21
+ const uuid_1 = require("uuid");
22
+ const bufferUtils_1 = require("../../bufferUtils");
23
+ const proofPlatform_1 = require("../../enumerations/proofPlatform");
24
+ const verificationStatus_1 = require("../../enumerations/verificationStatus");
25
+ // ─── Error classes ──────────────────────────────────────────────────────────
26
+ /**
27
+ * Error thrown when an unsupported platform is specified.
28
+ */
29
+ class UnsupportedPlatformError extends Error {
30
+ constructor(platform) {
31
+ super(`Unsupported proof platform: "${platform}"`);
32
+ this.name = 'UnsupportedPlatformError';
33
+ }
34
+ }
35
+ exports.UnsupportedPlatformError = UnsupportedPlatformError;
36
+ /**
37
+ * Error thrown when proof creation fails (e.g. member has no private key).
38
+ */
39
+ class ProofCreationError extends Error {
40
+ constructor(message) {
41
+ super(message);
42
+ this.name = 'ProofCreationError';
43
+ }
44
+ }
45
+ exports.ProofCreationError = ProofCreationError;
46
+ /**
47
+ * Error thrown when proof URL validation fails.
48
+ */
49
+ class ProofUrlError extends Error {
50
+ constructor(message) {
51
+ super(message);
52
+ this.name = 'ProofUrlError';
53
+ }
54
+ }
55
+ exports.ProofUrlError = ProofUrlError;
56
+ // ─── Constants ──────────────────────────────────────────────────────────────
57
+ /**
58
+ * Set of valid platform values derived from the ProofPlatform enum.
59
+ */
60
+ const VALID_PLATFORMS = new Set(Object.values(proofPlatform_1.ProofPlatform));
61
+ /**
62
+ * Platform-specific instructions for posting identity proofs.
63
+ *
64
+ * Requirement 4.9: Return instructions for posting the signed statement.
65
+ */
66
+ const PLATFORM_INSTRUCTIONS = {
67
+ [proofPlatform_1.ProofPlatform.TWITTER]: 'Post the signed statement as a tweet on Twitter/X and provide the tweet URL.',
68
+ [proofPlatform_1.ProofPlatform.GITHUB]: 'Create a public GitHub Gist containing the signed statement and provide the Gist URL.',
69
+ [proofPlatform_1.ProofPlatform.REDDIT]: 'Post the signed statement as a Reddit comment or text post and provide the permalink URL.',
70
+ [proofPlatform_1.ProofPlatform.WEBSITE]: 'Add the signed statement to a publicly accessible page on your website and provide the page URL.',
71
+ [proofPlatform_1.ProofPlatform.BITCOIN]: 'Sign a message with your Bitcoin address containing the signed statement and provide a verification URL.',
72
+ [proofPlatform_1.ProofPlatform.ETHEREUM]: 'Sign a message with your Ethereum address containing the signed statement and provide a verification URL.',
73
+ };
74
+ /**
75
+ * Default instruction returned for unrecognised platforms.
76
+ */
77
+ const DEFAULT_INSTRUCTION = 'Post the signed statement publicly and provide the URL where it can be verified.';
78
+ // ─── Service ────────────────────────────────────────────────────────────────
79
+ /**
80
+ * Service for creating and verifying cryptographic identity proofs.
81
+ *
82
+ * Identity proofs link a BrightChain member to an external platform
83
+ * account by signing a standardised statement with the member's
84
+ * SECP256k1 private key. The proof can be independently verified by
85
+ * anyone with the member's public key.
86
+ *
87
+ * All methods are static — the service is stateless and safe to call
88
+ * from any context (browser or Node.js).
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * const eciesService = ServiceProvider.getInstance().eciesService;
93
+ * const member = PaperKeyService.recoverFromPaperKey(paperKey, eciesService);
94
+ *
95
+ * // Create a proof
96
+ * const proof = IdentityProofService.create(member, ProofPlatform.GITHUB, 'octocat');
97
+ *
98
+ * // Verify the proof
99
+ * const isValid = IdentityProofService.verify(proof, member.publicKey, eciesService);
100
+ *
101
+ * // Get posting instructions
102
+ * const instructions = IdentityProofService.getInstructions(ProofPlatform.GITHUB);
103
+ * ```
104
+ */
105
+ class IdentityProofService {
106
+ /**
107
+ * Create a new identity proof by signing a statement with the member's
108
+ * SECP256k1 private key.
109
+ *
110
+ * The signed statement follows the format defined in Requirement 4.8:
111
+ * "I am {username} on {platform}. My BrightChain ID is {memberId}. Timestamp: {ISO8601}"
112
+ *
113
+ * **Validates: Requirements 4.1, 4.2, 4.3**
114
+ *
115
+ * @param member - The member creating the proof (must have private key loaded)
116
+ * @param platform - The target platform (must be a valid {@link ProofPlatform} value)
117
+ * @param username - The member's username on the target platform
118
+ * @returns A new {@link IIdentityProof} with status {@link VerificationStatus.PENDING}
119
+ * @throws {UnsupportedPlatformError} If the platform is not a valid {@link ProofPlatform}
120
+ * @throws {ProofCreationError} If the member has no private key loaded
121
+ */
122
+ static create(member, platform, username) {
123
+ // Validate platform
124
+ if (!VALID_PLATFORMS.has(platform)) {
125
+ throw new UnsupportedPlatformError(platform);
126
+ }
127
+ // Validate member has private key for signing
128
+ if (!member.hasPrivateKey) {
129
+ throw new ProofCreationError('Member must have a private key loaded to create identity proofs');
130
+ }
131
+ // Validate username is non-empty
132
+ if (!username || username.trim().length === 0) {
133
+ throw new ProofCreationError('Username must not be empty');
134
+ }
135
+ const trimmedUsername = username.trim();
136
+ const timestamp = new Date().toISOString();
137
+ const memberId = (0, ecies_lib_1.uint8ArrayToHex)(member.idBytes);
138
+ // Requirement 4.8: Signed statement format
139
+ const statement = `I am ${trimmedUsername} on ${platform}. My BrightChain ID is ${memberId}. Timestamp: ${timestamp}`;
140
+ // Requirement 4.3: Sign with SECP256k1 private key
141
+ const statementBytes = (0, bufferUtils_1.stringToUint8Array)(statement);
142
+ const signature = member.sign(statementBytes);
143
+ const signatureHex = (0, ecies_lib_1.uint8ArrayToHex)(signature);
144
+ return {
145
+ id: (0, uuid_1.v4)(),
146
+ memberId,
147
+ platform,
148
+ username: trimmedUsername,
149
+ proofUrl: '',
150
+ signedStatement: statement,
151
+ signature: signatureHex,
152
+ createdAt: new Date(),
153
+ verificationStatus: verificationStatus_1.VerificationStatus.PENDING,
154
+ };
155
+ }
156
+ /**
157
+ * Verify an identity proof's signature using a public key.
158
+ *
159
+ * Reconstructs the signature from its hex encoding and verifies it
160
+ * against the signed statement using the ECIESService's ECDSA
161
+ * verification.
162
+ *
163
+ * **Validates: Requirement 4.4**
164
+ *
165
+ * @param proof - The identity proof to verify
166
+ * @param publicKey - The SECP256k1 public key to verify against (raw bytes)
167
+ * @param eciesService - The ECIES service instance for signature verification
168
+ * @returns `true` if the signature is valid for the given public key
169
+ */
170
+ static verify(proof, publicKey, eciesService) {
171
+ try {
172
+ const statementBytes = (0, bufferUtils_1.stringToUint8Array)(proof.signedStatement);
173
+ const signatureBytes = (0, ecies_lib_1.hexToUint8Array)(proof.signature);
174
+ return eciesService.verifyMessage(publicKey, statementBytes, signatureBytes);
175
+ }
176
+ catch {
177
+ return false;
178
+ }
179
+ }
180
+ /**
181
+ * Check whether a proof URL contains the expected signed statement.
182
+ *
183
+ * Fetches the proof URL and checks that the response body includes
184
+ * the full signed statement text. This is used for initial verification
185
+ * and periodic re-verification (Requirement 4.10).
186
+ *
187
+ * **Validates: Requirement 4.6**
188
+ *
189
+ * @param proof - The identity proof whose URL to check
190
+ * @returns A promise resolving to `true` if the URL is accessible and
191
+ * contains the signed statement, `false` otherwise
192
+ */
193
+ static async checkProofUrl(proof) {
194
+ if (!proof.proofUrl || proof.proofUrl.trim().length === 0) {
195
+ return false;
196
+ }
197
+ try {
198
+ const response = await fetch(proof.proofUrl);
199
+ if (!response.ok) {
200
+ return false;
201
+ }
202
+ const content = await response.text();
203
+ return content.includes(proof.signedStatement);
204
+ }
205
+ catch {
206
+ return false;
207
+ }
208
+ }
209
+ /**
210
+ * Get platform-specific instructions for posting an identity proof.
211
+ *
212
+ * Returns human-readable instructions explaining how to post the
213
+ * signed statement on the specified platform and what URL to provide
214
+ * for verification.
215
+ *
216
+ * **Validates: Requirement 4.9**
217
+ *
218
+ * @param platform - The target platform
219
+ * @returns Instructions string for the specified platform, or a generic
220
+ * fallback for unrecognised platforms
221
+ */
222
+ static getInstructions(platform) {
223
+ if (VALID_PLATFORMS.has(platform)) {
224
+ return PLATFORM_INSTRUCTIONS[platform];
225
+ }
226
+ return DEFAULT_INSTRUCTION;
227
+ }
228
+ /**
229
+ * Build the signed statement string for a given set of parameters.
230
+ *
231
+ * This is a utility method that produces the statement text without
232
+ * signing it. Useful for previewing the statement before creation.
233
+ *
234
+ * @param username - The member's username on the target platform
235
+ * @param platform - The target platform
236
+ * @param memberId - The member's hex-encoded ID
237
+ * @param timestamp - ISO 8601 timestamp string
238
+ * @returns The formatted statement string per Requirement 4.8
239
+ */
240
+ static buildStatement(username, platform, memberId, timestamp) {
241
+ return `I am ${username} on ${platform}. My BrightChain ID is ${memberId}. Timestamp: ${timestamp}`;
242
+ }
243
+ }
244
+ exports.IdentityProofService = IdentityProofService;
245
+ //# sourceMappingURL=identityProofService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identityProofService.js","sourceRoot":"","sources":["../../../../../../brightchain-lib/src/lib/services/identity/identityProofService.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,0DAOoC;AACpC,+BAAoC;AAEpC,mDAAuD;AACvD,oEAAiE;AACjE,8EAA2E;AAG3E,+EAA+E;AAE/E;;GAEG;AACH,MAAa,wBAAyB,SAAQ,KAAK;IACjD,YAAY,QAAgB;QAC1B,KAAK,CAAC,gCAAgC,QAAQ,GAAG,CAAC,CAAC;QACnD,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AALD,4DAKC;AAED;;GAEG;AACH,MAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AALD,gDAKC;AAED;;GAEG;AACH,MAAa,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AALD,sCAKC;AAED,+EAA+E;AAE/E;;GAEG;AACH,MAAM,eAAe,GAAG,IAAI,GAAG,CAAS,MA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CAAC;YAC1D,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAC7C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,OAAO,KAAK,CAAC;YACf,CAAC;YACD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACtC,OAAO,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QACjD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,eAAe,CAAC,QAAgC;QACrD,IAAI,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAClC,OAAO,qBAAqB,CAAC,QAAyB,CAAC,CAAC;QAC1D,CAAC;QACD,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,cAAc,CACnB,QAAgB,EAChB,QAAgC,EAChC,QAAgB,EAChB,SAAiB;QAEjB,OAAO,QAAQ,QAAQ,OAAO,QAAQ,0BAA0B,QAAQ,gBAAgB,SAAS,EAAE,CAAC;IACtG,CAAC;CACF;AAzKD,oDAyKC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Identity services for the BrightChain identity system.
3
+ *
4
+ * Provides paper key management, split paper keys, device provisioning,
5
+ * identity proofs, and public key directory services.
6
+ */
7
+ export * from './deviceProvisioningService';
8
+ export * from './identityProofService';
9
+ export * from './memberIdentityProofService';
10
+ export * from './memberPaperKeyService';
11
+ export * from './paperKeyService';
12
+ export * from './publicKeyDirectoryService';
13
+ export * from './splitPaperKeyService';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-lib/src/lib/services/identity/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /**
3
+ * Identity services for the BrightChain identity system.
4
+ *
5
+ * Provides paper key management, split paper keys, device provisioning,
6
+ * identity proofs, and public key directory services.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const tslib_1 = require("tslib");
10
+ tslib_1.__exportStar(require("./deviceProvisioningService"), exports);
11
+ tslib_1.__exportStar(require("./identityProofService"), exports);
12
+ tslib_1.__exportStar(require("./memberIdentityProofService"), exports);
13
+ tslib_1.__exportStar(require("./memberPaperKeyService"), exports);
14
+ tslib_1.__exportStar(require("./paperKeyService"), exports);
15
+ tslib_1.__exportStar(require("./publicKeyDirectoryService"), exports);
16
+ tslib_1.__exportStar(require("./splitPaperKeyService"), exports);
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../brightchain-lib/src/lib/services/identity/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,sEAA4C;AAC5C,iEAAuC;AACvC,uEAA6C;AAC7C,kEAAwC;AACxC,4DAAkC;AAClC,sEAA4C;AAC5C,iEAAuC"}