@bsv/wallet-toolbox-client 2.1.24 → 3.0.0-alpha.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 (588) hide show
  1. package/out/src/CWIStyleWalletManager.d.ts +33 -7
  2. package/out/src/CWIStyleWalletManager.d.ts.map +1 -1
  3. package/out/src/CWIStyleWalletManager.js +281 -313
  4. package/out/src/CWIStyleWalletManager.js.map +1 -1
  5. package/out/src/SetupClient.d.ts +6 -6
  6. package/out/src/SetupClient.d.ts.map +1 -1
  7. package/out/src/SetupClient.js +5 -5
  8. package/out/src/SetupClient.js.map +1 -1
  9. package/out/src/SetupWallet.d.ts.map +1 -1
  10. package/out/src/SimpleWalletManager.d.ts +12 -2
  11. package/out/src/SimpleWalletManager.d.ts.map +1 -1
  12. package/out/src/SimpleWalletManager.js +46 -30
  13. package/out/src/SimpleWalletManager.js.map +1 -1
  14. package/out/src/Wallet.d.ts +1 -1
  15. package/out/src/Wallet.d.ts.map +1 -1
  16. package/out/src/Wallet.js +102 -100
  17. package/out/src/Wallet.js.map +1 -1
  18. package/out/src/WalletAuthenticationManager.d.ts +1 -1
  19. package/out/src/WalletAuthenticationManager.d.ts.map +1 -1
  20. package/out/src/WalletAuthenticationManager.js +3 -3
  21. package/out/src/WalletAuthenticationManager.js.map +1 -1
  22. package/out/src/WalletLogger.d.ts.map +1 -1
  23. package/out/src/WalletLogger.js +16 -8
  24. package/out/src/WalletLogger.js.map +1 -1
  25. package/out/src/WalletPermissionsManager.d.ts +89 -18
  26. package/out/src/WalletPermissionsManager.d.ts.map +1 -1
  27. package/out/src/WalletPermissionsManager.js +656 -870
  28. package/out/src/WalletPermissionsManager.js.map +1 -1
  29. package/out/src/WalletSettingsManager.d.ts +2 -2
  30. package/out/src/WalletSettingsManager.d.ts.map +1 -1
  31. package/out/src/WalletSettingsManager.js.map +1 -1
  32. package/out/src/fundWalletP2PKH.d.ts +2 -2
  33. package/out/src/fundWalletP2PKH.d.ts.map +1 -1
  34. package/out/src/fundWalletP2PKH.js +11 -10
  35. package/out/src/fundWalletP2PKH.js.map +1 -1
  36. package/out/src/mockchain/MockChainMigrations.d.ts +3 -3
  37. package/out/src/mockchain/MockChainMigrations.d.ts.map +1 -1
  38. package/out/src/mockchain/MockChainMigrations.js.map +1 -1
  39. package/out/src/mockchain/MockChainStorage.d.ts.map +1 -1
  40. package/out/src/mockchain/MockChainStorage.js +5 -5
  41. package/out/src/mockchain/MockChainStorage.js.map +1 -1
  42. package/out/src/mockchain/MockChainTracker.d.ts.map +1 -1
  43. package/out/src/mockchain/MockChainTracker.js +10 -10
  44. package/out/src/mockchain/MockChainTracker.js.map +1 -1
  45. package/out/src/mockchain/MockMiner.d.ts.map +1 -1
  46. package/out/src/mockchain/MockMiner.js +3 -3
  47. package/out/src/mockchain/MockMiner.js.map +1 -1
  48. package/out/src/mockchain/MockServices.d.ts +9 -0
  49. package/out/src/mockchain/MockServices.d.ts.map +1 -1
  50. package/out/src/mockchain/MockServices.js +195 -238
  51. package/out/src/mockchain/MockServices.js.map +1 -1
  52. package/out/src/mockchain/merkleTree.d.ts.map +1 -1
  53. package/out/src/mockchain/merkleTree.js +21 -12
  54. package/out/src/mockchain/merkleTree.js.map +1 -1
  55. package/out/src/monitor/LeasedMonitorTask.d.ts +43 -0
  56. package/out/src/monitor/LeasedMonitorTask.d.ts.map +1 -0
  57. package/out/src/monitor/LeasedMonitorTask.js +89 -0
  58. package/out/src/monitor/LeasedMonitorTask.js.map +1 -0
  59. package/out/src/monitor/Monitor.d.ts +24 -0
  60. package/out/src/monitor/Monitor.d.ts.map +1 -1
  61. package/out/src/monitor/Monitor.js +63 -75
  62. package/out/src/monitor/Monitor.js.map +1 -1
  63. package/out/src/monitor/V7LeasedTask.d.ts +43 -0
  64. package/out/src/monitor/V7LeasedTask.d.ts.map +1 -0
  65. package/out/src/monitor/V7LeasedTask.js +89 -0
  66. package/out/src/monitor/V7LeasedTask.js.map +1 -0
  67. package/out/src/monitor/tasks/TaskArcSSE.d.ts +2 -2
  68. package/out/src/monitor/tasks/TaskArcSSE.d.ts.map +1 -1
  69. package/out/src/monitor/tasks/TaskArcSSE.js +10 -23
  70. package/out/src/monitor/tasks/TaskArcSSE.js.map +1 -1
  71. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts +4 -2
  72. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -1
  73. package/out/src/monitor/tasks/TaskCheckForProofs.js +83 -16
  74. package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -1
  75. package/out/src/monitor/tasks/TaskCheckNoSends.d.ts +1 -1
  76. package/out/src/monitor/tasks/TaskCheckNoSends.d.ts.map +1 -1
  77. package/out/src/monitor/tasks/TaskCheckNoSends.js +1 -2
  78. package/out/src/monitor/tasks/TaskCheckNoSends.js.map +1 -1
  79. package/out/src/monitor/tasks/TaskClock.d.ts +1 -1
  80. package/out/src/monitor/tasks/TaskClock.d.ts.map +1 -1
  81. package/out/src/monitor/tasks/TaskClock.js +0 -1
  82. package/out/src/monitor/tasks/TaskClock.js.map +1 -1
  83. package/out/src/monitor/tasks/TaskFailAbandoned.d.ts +1 -1
  84. package/out/src/monitor/tasks/TaskFailAbandoned.d.ts.map +1 -1
  85. package/out/src/monitor/tasks/TaskFailAbandoned.js.map +1 -1
  86. package/out/src/monitor/tasks/TaskMineBlock.d.ts +1 -1
  87. package/out/src/monitor/tasks/TaskMineBlock.d.ts.map +1 -1
  88. package/out/src/monitor/tasks/TaskMineBlock.js.map +1 -1
  89. package/out/src/monitor/tasks/TaskMonitorCallHistory.d.ts +1 -1
  90. package/out/src/monitor/tasks/TaskMonitorCallHistory.d.ts.map +1 -1
  91. package/out/src/monitor/tasks/TaskMonitorCallHistory.js +1 -1
  92. package/out/src/monitor/tasks/TaskMonitorCallHistory.js.map +1 -1
  93. package/out/src/monitor/tasks/TaskNewHeader.d.ts +2 -2
  94. package/out/src/monitor/tasks/TaskNewHeader.d.ts.map +1 -1
  95. package/out/src/monitor/tasks/TaskNewHeader.js +7 -5
  96. package/out/src/monitor/tasks/TaskNewHeader.js.map +1 -1
  97. package/out/src/monitor/tasks/TaskPurge.d.ts +1 -1
  98. package/out/src/monitor/tasks/TaskPurge.d.ts.map +1 -1
  99. package/out/src/monitor/tasks/TaskPurge.js.map +1 -1
  100. package/out/src/monitor/tasks/TaskReorg.d.ts +1 -1
  101. package/out/src/monitor/tasks/TaskReorg.d.ts.map +1 -1
  102. package/out/src/monitor/tasks/TaskReorg.js +2 -2
  103. package/out/src/monitor/tasks/TaskReorg.js.map +1 -1
  104. package/out/src/monitor/tasks/TaskReviewDoubleSpends.d.ts +1 -1
  105. package/out/src/monitor/tasks/TaskReviewDoubleSpends.d.ts.map +1 -1
  106. package/out/src/monitor/tasks/TaskReviewDoubleSpends.js +10 -10
  107. package/out/src/monitor/tasks/TaskReviewDoubleSpends.js.map +1 -1
  108. package/out/src/monitor/tasks/TaskReviewProvenTxs.d.ts +1 -1
  109. package/out/src/monitor/tasks/TaskReviewProvenTxs.d.ts.map +1 -1
  110. package/out/src/monitor/tasks/TaskReviewProvenTxs.js +2 -2
  111. package/out/src/monitor/tasks/TaskReviewProvenTxs.js.map +1 -1
  112. package/out/src/monitor/tasks/TaskReviewStatus.d.ts +1 -1
  113. package/out/src/monitor/tasks/TaskReviewStatus.d.ts.map +1 -1
  114. package/out/src/monitor/tasks/TaskReviewStatus.js.map +1 -1
  115. package/out/src/monitor/tasks/TaskReviewUtxos.d.ts +1 -1
  116. package/out/src/monitor/tasks/TaskReviewUtxos.d.ts.map +1 -1
  117. package/out/src/monitor/tasks/TaskReviewUtxos.js.map +1 -1
  118. package/out/src/monitor/tasks/TaskSendWaiting.d.ts +1 -1
  119. package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -1
  120. package/out/src/monitor/tasks/TaskSendWaiting.js +4 -5
  121. package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -1
  122. package/out/src/monitor/tasks/TaskUnFail.d.ts +1 -1
  123. package/out/src/monitor/tasks/TaskUnFail.d.ts.map +1 -1
  124. package/out/src/monitor/tasks/TaskUnFail.js +13 -15
  125. package/out/src/monitor/tasks/TaskUnFail.js.map +1 -1
  126. package/out/src/monitor/tasks/WalletMonitorTask.d.ts.map +1 -1
  127. package/out/src/monitor/tasks/WalletMonitorTask.js +3 -1
  128. package/out/src/monitor/tasks/WalletMonitorTask.js.map +1 -1
  129. package/out/src/sdk/CertOpsWallet.d.ts +3 -3
  130. package/out/src/sdk/CertOpsWallet.d.ts.map +1 -1
  131. package/out/src/sdk/PrivilegedKeyManager.d.ts +3 -3
  132. package/out/src/sdk/PrivilegedKeyManager.d.ts.map +1 -1
  133. package/out/src/sdk/PrivilegedKeyManager.js +26 -21
  134. package/out/src/sdk/PrivilegedKeyManager.js.map +1 -1
  135. package/out/src/sdk/WERR_errors.d.ts.map +1 -1
  136. package/out/src/sdk/WERR_errors.js +5 -5
  137. package/out/src/sdk/WERR_errors.js.map +1 -1
  138. package/out/src/sdk/WalletError.d.ts +1 -1
  139. package/out/src/sdk/WalletError.d.ts.map +1 -1
  140. package/out/src/sdk/WalletError.js +10 -3
  141. package/out/src/sdk/WalletError.js.map +1 -1
  142. package/out/src/sdk/WalletErrorFromJson.d.ts.map +1 -1
  143. package/out/src/sdk/WalletErrorFromJson.js +1 -3
  144. package/out/src/sdk/WalletErrorFromJson.js.map +1 -1
  145. package/out/src/sdk/WalletServices.interfaces.d.ts +19 -19
  146. package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -1
  147. package/out/src/sdk/WalletStorage.interfaces.d.ts +59 -59
  148. package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
  149. package/out/src/sdk/types.d.ts +36 -4
  150. package/out/src/sdk/types.d.ts.map +1 -1
  151. package/out/src/sdk/types.js +53 -4
  152. package/out/src/sdk/types.js.map +1 -1
  153. package/out/src/services/ServiceCollection.d.ts +6 -6
  154. package/out/src/services/ServiceCollection.d.ts.map +1 -1
  155. package/out/src/services/ServiceCollection.js +3 -4
  156. package/out/src/services/ServiceCollection.js.map +1 -1
  157. package/out/src/services/Services.d.ts +5 -0
  158. package/out/src/services/Services.d.ts.map +1 -1
  159. package/out/src/services/Services.js +174 -182
  160. package/out/src/services/Services.js.map +1 -1
  161. package/out/src/services/chaintracker/BHServiceClient.d.ts.map +1 -1
  162. package/out/src/services/chaintracker/BHServiceClient.js +7 -7
  163. package/out/src/services/chaintracker/BHServiceClient.js.map +1 -1
  164. package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts.map +1 -1
  165. package/out/src/services/chaintracker/ChaintracksChainTracker.js +5 -5
  166. package/out/src/services/chaintracker/ChaintracksChainTracker.js.map +1 -1
  167. package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.d.ts +5 -3
  168. package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.d.ts.map +1 -1
  169. package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.js.map +1 -1
  170. package/out/src/services/chaintracker/chaintracks/Api/BulkStorageApi.d.ts.map +1 -1
  171. package/out/src/services/chaintracker/chaintracks/Chaintracks.d.ts +20 -10
  172. package/out/src/services/chaintracker/chaintracks/Chaintracks.d.ts.map +1 -1
  173. package/out/src/services/chaintracker/chaintracks/Chaintracks.js +228 -221
  174. package/out/src/services/chaintracker/chaintracks/Chaintracks.js.map +1 -1
  175. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts.map +1 -1
  176. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js +9 -10
  177. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js.map +1 -1
  178. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.d.ts.map +1 -1
  179. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.js +1 -1
  180. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.js.map +1 -1
  181. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.d.ts +1 -2
  182. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.d.ts.map +1 -1
  183. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.js +3 -3
  184. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.js.map +1 -1
  185. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.d.ts.map +1 -1
  186. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.js.map +1 -1
  187. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.d.ts.map +1 -1
  188. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.js +3 -3
  189. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.js.map +1 -1
  190. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.d.ts.map +1 -1
  191. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.js +1 -1
  192. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.js.map +1 -1
  193. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.d.ts.map +1 -1
  194. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js +2 -2
  195. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js.map +1 -1
  196. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.d.ts +2 -2
  197. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.d.ts.map +1 -1
  198. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.js +6 -39
  199. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.js.map +1 -1
  200. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.d.ts +3 -3
  201. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.d.ts.map +1 -1
  202. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.js +8 -6
  203. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.js.map +1 -1
  204. package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.d.ts.map +1 -1
  205. package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.js +9 -16
  206. package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.js.map +1 -1
  207. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.d.ts.map +1 -1
  208. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js +34 -22
  209. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js.map +1 -1
  210. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.d.ts.map +1 -1
  211. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.js +31 -30
  212. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.js.map +1 -1
  213. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.d.ts +2 -2
  214. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.d.ts.map +1 -1
  215. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.js +11 -10
  216. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.js.map +1 -1
  217. package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.d.ts.map +1 -1
  218. package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.js.map +1 -1
  219. package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.d.ts.map +1 -1
  220. package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.js.map +1 -1
  221. package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.d.ts.map +1 -1
  222. package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.js.map +1 -1
  223. package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.d.ts.map +1 -1
  224. package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.js.map +1 -1
  225. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.d.ts +6 -1
  226. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.d.ts.map +1 -1
  227. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js +247 -227
  228. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js.map +1 -1
  229. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataReader.d.ts.map +1 -1
  230. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataReader.js +8 -7
  231. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataReader.js.map +1 -1
  232. package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.d.ts.map +1 -1
  233. package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js +35 -25
  234. package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js.map +1 -1
  235. package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.d.ts +5 -5
  236. package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.d.ts.map +1 -1
  237. package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.js +13 -11
  238. package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.js.map +1 -1
  239. package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.d.ts +0 -1
  240. package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.d.ts.map +1 -1
  241. package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.js.map +1 -1
  242. package/out/src/services/chaintracker/chaintracks/util/HeightRange.d.ts.map +1 -1
  243. package/out/src/services/chaintracker/chaintracks/util/HeightRange.js +21 -13
  244. package/out/src/services/chaintracker/chaintracks/util/HeightRange.js.map +1 -1
  245. package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts +2 -2
  246. package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts.map +1 -1
  247. package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.js.map +1 -1
  248. package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts +1 -1
  249. package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts.map +1 -1
  250. package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js +28 -24
  251. package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js.map +1 -1
  252. package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.d.ts.map +1 -1
  253. package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.js.map +1 -1
  254. package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.d.ts.map +1 -1
  255. package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.js +9 -10
  256. package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.js.map +1 -1
  257. package/out/src/services/createDefaultWalletServicesOptions.d.ts.map +1 -1
  258. package/out/src/services/createDefaultWalletServicesOptions.js +3 -3
  259. package/out/src/services/createDefaultWalletServicesOptions.js.map +1 -1
  260. package/out/src/services/providers/ARC.d.ts.map +1 -1
  261. package/out/src/services/providers/ARC.js +7 -14
  262. package/out/src/services/providers/ARC.js.map +1 -1
  263. package/out/src/services/providers/ArcSSEClient.d.ts.map +1 -1
  264. package/out/src/services/providers/ArcSSEClient.js +1 -1
  265. package/out/src/services/providers/ArcSSEClient.js.map +1 -1
  266. package/out/src/services/providers/Bitails.d.ts.map +1 -1
  267. package/out/src/services/providers/Bitails.js +17 -17
  268. package/out/src/services/providers/Bitails.js.map +1 -1
  269. package/out/src/services/providers/SdkWhatsOnChain.d.ts.map +1 -1
  270. package/out/src/services/providers/SdkWhatsOnChain.js.map +1 -1
  271. package/out/src/services/providers/WhatsOnChain.d.ts +2 -0
  272. package/out/src/services/providers/WhatsOnChain.d.ts.map +1 -1
  273. package/out/src/services/providers/WhatsOnChain.js +109 -233
  274. package/out/src/services/providers/WhatsOnChain.js.map +1 -1
  275. package/out/src/services/providers/exchangeRates.d.ts.map +1 -1
  276. package/out/src/services/providers/exchangeRates.js +3 -3
  277. package/out/src/services/providers/exchangeRates.js.map +1 -1
  278. package/out/src/services/providers/getBeefForTxid.d.ts +1 -1
  279. package/out/src/services/providers/getBeefForTxid.d.ts.map +1 -1
  280. package/out/src/services/providers/getBeefForTxid.js.map +1 -1
  281. package/out/src/services/providers/whatsOnChainHelpers.d.ts +68 -0
  282. package/out/src/services/providers/whatsOnChainHelpers.d.ts.map +1 -0
  283. package/out/src/services/providers/whatsOnChainHelpers.js +147 -0
  284. package/out/src/services/providers/whatsOnChainHelpers.js.map +1 -0
  285. package/out/src/signer/WalletSigner.d.ts.map +1 -1
  286. package/out/src/signer/WalletSigner.js.map +1 -1
  287. package/out/src/signer/methods/acquireDirectCertificate.js +1 -1
  288. package/out/src/signer/methods/acquireDirectCertificate.js.map +1 -1
  289. package/out/src/signer/methods/buildSignableTransaction.d.ts.map +1 -1
  290. package/out/src/signer/methods/buildSignableTransaction.js +21 -13
  291. package/out/src/signer/methods/buildSignableTransaction.js.map +1 -1
  292. package/out/src/signer/methods/completeSignedTransaction.d.ts.map +1 -1
  293. package/out/src/signer/methods/completeSignedTransaction.js +20 -21
  294. package/out/src/signer/methods/completeSignedTransaction.js.map +1 -1
  295. package/out/src/signer/methods/createAction.d.ts.map +1 -1
  296. package/out/src/signer/methods/createAction.js +8 -7
  297. package/out/src/signer/methods/createAction.js.map +1 -1
  298. package/out/src/signer/methods/internalizeAction.d.ts.map +1 -1
  299. package/out/src/signer/methods/internalizeAction.js +8 -6
  300. package/out/src/signer/methods/internalizeAction.js.map +1 -1
  301. package/out/src/signer/methods/proveCertificate.js +1 -1
  302. package/out/src/signer/methods/signAction.d.ts.map +1 -1
  303. package/out/src/signer/methods/signAction.js +8 -10
  304. package/out/src/signer/methods/signAction.js.map +1 -1
  305. package/out/src/storage/StorageIdb.d.ts +16 -1
  306. package/out/src/storage/StorageIdb.d.ts.map +1 -1
  307. package/out/src/storage/StorageIdb.js +544 -1224
  308. package/out/src/storage/StorageIdb.js.map +1 -1
  309. package/out/src/storage/StorageProvider.d.ts +124 -1
  310. package/out/src/storage/StorageProvider.d.ts.map +1 -1
  311. package/out/src/storage/StorageProvider.js +316 -186
  312. package/out/src/storage/StorageProvider.js.map +1 -1
  313. package/out/src/storage/StorageReader.d.ts.map +1 -1
  314. package/out/src/storage/StorageReader.js +8 -7
  315. package/out/src/storage/StorageReader.js.map +1 -1
  316. package/out/src/storage/StorageReaderWriter.d.ts.map +1 -1
  317. package/out/src/storage/StorageReaderWriter.js +32 -32
  318. package/out/src/storage/StorageReaderWriter.js.map +1 -1
  319. package/out/src/storage/StorageSyncReader.d.ts.map +1 -1
  320. package/out/src/storage/StorageSyncReader.js +3 -3
  321. package/out/src/storage/StorageSyncReader.js.map +1 -1
  322. package/out/src/storage/WalletStorageManager.d.ts +3 -0
  323. package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
  324. package/out/src/storage/WalletStorageManager.js +83 -73
  325. package/out/src/storage/WalletStorageManager.js.map +1 -1
  326. package/out/src/storage/idbHelpers.d.ts +47 -0
  327. package/out/src/storage/idbHelpers.d.ts.map +1 -0
  328. package/out/src/storage/idbHelpers.js +417 -0
  329. package/out/src/storage/idbHelpers.js.map +1 -0
  330. package/out/src/storage/methods/ListActionsSpecOp.d.ts +6 -1
  331. package/out/src/storage/methods/ListActionsSpecOp.d.ts.map +1 -1
  332. package/out/src/storage/methods/ListActionsSpecOp.js +28 -2
  333. package/out/src/storage/methods/ListActionsSpecOp.js.map +1 -1
  334. package/out/src/storage/methods/ListOutputsSpecOp.d.ts.map +1 -1
  335. package/out/src/storage/methods/ListOutputsSpecOp.js +8 -11
  336. package/out/src/storage/methods/ListOutputsSpecOp.js.map +1 -1
  337. package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts +83 -0
  338. package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
  339. package/out/src/storage/methods/attemptToPostReqsToNetwork.js +338 -63
  340. package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -1
  341. package/out/src/storage/methods/createAction.d.ts.map +1 -1
  342. package/out/src/storage/methods/createAction.js +251 -274
  343. package/out/src/storage/methods/createAction.js.map +1 -1
  344. package/out/src/storage/methods/generateChange.d.ts.map +1 -1
  345. package/out/src/storage/methods/generateChange.js +99 -80
  346. package/out/src/storage/methods/generateChange.js.map +1 -1
  347. package/out/src/storage/methods/getBeefForTransaction.js +15 -13
  348. package/out/src/storage/methods/getBeefForTransaction.js.map +1 -1
  349. package/out/src/storage/methods/getSyncChunk.d.ts.map +1 -1
  350. package/out/src/storage/methods/getSyncChunk.js +4 -3
  351. package/out/src/storage/methods/getSyncChunk.js.map +1 -1
  352. package/out/src/storage/methods/internalizeAction.d.ts.map +1 -1
  353. package/out/src/storage/methods/internalizeAction.js +213 -56
  354. package/out/src/storage/methods/internalizeAction.js.map +1 -1
  355. package/out/src/storage/methods/listActionsIdb.d.ts.map +1 -1
  356. package/out/src/storage/methods/listActionsIdb.js +85 -110
  357. package/out/src/storage/methods/listActionsIdb.js.map +1 -1
  358. package/out/src/storage/methods/listCertificates.d.ts +1 -1
  359. package/out/src/storage/methods/listCertificates.d.ts.map +1 -1
  360. package/out/src/storage/methods/listCertificates.js +7 -7
  361. package/out/src/storage/methods/listCertificates.js.map +1 -1
  362. package/out/src/storage/methods/listOutputsIdb.d.ts.map +1 -1
  363. package/out/src/storage/methods/listOutputsIdb.js +24 -27
  364. package/out/src/storage/methods/listOutputsIdb.js.map +1 -1
  365. package/out/src/storage/methods/offsetKey.d.ts +1 -1
  366. package/out/src/storage/methods/offsetKey.d.ts.map +1 -1
  367. package/out/src/storage/methods/offsetKey.js +3 -5
  368. package/out/src/storage/methods/offsetKey.js.map +1 -1
  369. package/out/src/storage/methods/processAction.d.ts +0 -11
  370. package/out/src/storage/methods/processAction.d.ts.map +1 -1
  371. package/out/src/storage/methods/processAction.js +168 -93
  372. package/out/src/storage/methods/processAction.js.map +1 -1
  373. package/out/src/storage/methods/purgeDataIdb.d.ts.map +1 -1
  374. package/out/src/storage/methods/purgeDataIdb.js +1 -1
  375. package/out/src/storage/methods/purgeDataIdb.js.map +1 -1
  376. package/out/src/storage/methods/reviewStatusIdb.d.ts +1 -1
  377. package/out/src/storage/methods/reviewStatusIdb.d.ts.map +1 -1
  378. package/out/src/storage/methods/reviewStatusIdb.js.map +1 -1
  379. package/out/src/storage/methods/utils.d.ts.map +1 -1
  380. package/out/src/storage/methods/utils.js +7 -1
  381. package/out/src/storage/methods/utils.js.map +1 -1
  382. package/out/src/storage/remoting/StorageClient.d.ts +4 -270
  383. package/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
  384. package/out/src/storage/remoting/StorageClient.js +16 -423
  385. package/out/src/storage/remoting/StorageClient.js.map +1 -1
  386. package/out/src/storage/remoting/StorageClientBase.d.ts +289 -0
  387. package/out/src/storage/remoting/StorageClientBase.d.ts.map +1 -0
  388. package/out/src/storage/remoting/StorageClientBase.js +375 -0
  389. package/out/src/storage/remoting/StorageClientBase.js.map +1 -0
  390. package/out/src/storage/remoting/entityValidationHelpers.d.ts +29 -0
  391. package/out/src/storage/remoting/entityValidationHelpers.d.ts.map +1 -0
  392. package/out/src/storage/remoting/entityValidationHelpers.js +91 -0
  393. package/out/src/storage/remoting/entityValidationHelpers.js.map +1 -0
  394. package/out/src/storage/schema/StorageIdbSchema.d.ts +43 -2
  395. package/out/src/storage/schema/StorageIdbSchema.d.ts.map +1 -1
  396. package/out/src/storage/schema/entities/EntityBase.d.ts.map +1 -1
  397. package/out/src/storage/schema/entities/EntityBase.js.map +1 -1
  398. package/out/src/storage/schema/entities/EntityCertificate.d.ts.map +1 -1
  399. package/out/src/storage/schema/entities/EntityCertificate.js +5 -4
  400. package/out/src/storage/schema/entities/EntityCertificate.js.map +1 -1
  401. package/out/src/storage/schema/entities/EntityCertificateField.d.ts.map +1 -1
  402. package/out/src/storage/schema/entities/EntityCertificateField.js +5 -7
  403. package/out/src/storage/schema/entities/EntityCertificateField.js.map +1 -1
  404. package/out/src/storage/schema/entities/EntityCommission.d.ts.map +1 -1
  405. package/out/src/storage/schema/entities/EntityCommission.js +6 -8
  406. package/out/src/storage/schema/entities/EntityCommission.js.map +1 -1
  407. package/out/src/storage/schema/entities/EntityOutput.d.ts.map +1 -1
  408. package/out/src/storage/schema/entities/EntityOutput.js +21 -24
  409. package/out/src/storage/schema/entities/EntityOutput.js.map +1 -1
  410. package/out/src/storage/schema/entities/EntityOutputBasket.d.ts.map +1 -1
  411. package/out/src/storage/schema/entities/EntityOutputBasket.js +6 -6
  412. package/out/src/storage/schema/entities/EntityOutputBasket.js.map +1 -1
  413. package/out/src/storage/schema/entities/EntityOutputTag.d.ts.map +1 -1
  414. package/out/src/storage/schema/entities/EntityOutputTag.js +2 -2
  415. package/out/src/storage/schema/entities/EntityOutputTag.js.map +1 -1
  416. package/out/src/storage/schema/entities/EntityOutputTagMap.d.ts.map +1 -1
  417. package/out/src/storage/schema/entities/EntityOutputTagMap.js +4 -6
  418. package/out/src/storage/schema/entities/EntityOutputTagMap.js.map +1 -1
  419. package/out/src/storage/schema/entities/EntityProvenTx.d.ts +3 -3
  420. package/out/src/storage/schema/entities/EntityProvenTx.d.ts.map +1 -1
  421. package/out/src/storage/schema/entities/EntityProvenTx.js +22 -23
  422. package/out/src/storage/schema/entities/EntityProvenTx.js.map +1 -1
  423. package/out/src/storage/schema/entities/EntityProvenTxReq.d.ts +9 -0
  424. package/out/src/storage/schema/entities/EntityProvenTxReq.d.ts.map +1 -1
  425. package/out/src/storage/schema/entities/EntityProvenTxReq.js +116 -68
  426. package/out/src/storage/schema/entities/EntityProvenTxReq.js.map +1 -1
  427. package/out/src/storage/schema/entities/EntitySyncState.d.ts.map +1 -1
  428. package/out/src/storage/schema/entities/EntitySyncState.js +19 -18
  429. package/out/src/storage/schema/entities/EntitySyncState.js.map +1 -1
  430. package/out/src/storage/schema/entities/EntityTransaction.d.ts.map +1 -1
  431. package/out/src/storage/schema/entities/EntityTransaction.js +25 -26
  432. package/out/src/storage/schema/entities/EntityTransaction.js.map +1 -1
  433. package/out/src/storage/schema/entities/EntityTxLabel.d.ts.map +1 -1
  434. package/out/src/storage/schema/entities/EntityTxLabel.js +2 -2
  435. package/out/src/storage/schema/entities/EntityTxLabel.js.map +1 -1
  436. package/out/src/storage/schema/entities/EntityTxLabelMap.d.ts.map +1 -1
  437. package/out/src/storage/schema/entities/EntityTxLabelMap.js +4 -6
  438. package/out/src/storage/schema/entities/EntityTxLabelMap.js.map +1 -1
  439. package/out/src/storage/schema/entities/EntityUser.d.ts.map +1 -1
  440. package/out/src/storage/schema/entities/EntityUser.js +3 -3
  441. package/out/src/storage/schema/entities/EntityUser.js.map +1 -1
  442. package/out/src/storage/schema/entities/MergeEntity.d.ts.map +1 -1
  443. package/out/src/storage/schema/entities/MergeEntity.js +6 -6
  444. package/out/src/storage/schema/entities/MergeEntity.js.map +1 -1
  445. package/out/src/storage/schema/monitorLease.d.ts +57 -0
  446. package/out/src/storage/schema/monitorLease.d.ts.map +1 -0
  447. package/out/src/storage/schema/monitorLease.js +101 -0
  448. package/out/src/storage/schema/monitorLease.js.map +1 -0
  449. package/out/src/storage/schema/processingFsm.d.ts +27 -0
  450. package/out/src/storage/schema/processingFsm.d.ts.map +1 -0
  451. package/out/src/storage/schema/processingFsm.js +132 -0
  452. package/out/src/storage/schema/processingFsm.js.map +1 -0
  453. package/out/src/storage/schema/tables/TableAction.d.ts +38 -0
  454. package/out/src/storage/schema/tables/TableAction.d.ts.map +1 -0
  455. package/out/src/storage/schema/tables/TableAction.js +3 -0
  456. package/out/src/storage/schema/tables/TableAction.js.map +1 -0
  457. package/out/src/storage/schema/tables/TableCertificate.d.ts +2 -1
  458. package/out/src/storage/schema/tables/TableCertificate.d.ts.map +1 -1
  459. package/out/src/storage/schema/tables/TableCertificateField.d.ts +1 -1
  460. package/out/src/storage/schema/tables/TableCertificateField.d.ts.map +1 -1
  461. package/out/src/storage/schema/tables/TableChainTip.d.ts +17 -0
  462. package/out/src/storage/schema/tables/TableChainTip.d.ts.map +1 -0
  463. package/out/src/storage/schema/tables/TableChainTip.js +3 -0
  464. package/out/src/storage/schema/tables/TableChainTip.js.map +1 -0
  465. package/out/src/storage/schema/tables/TableCommission.d.ts +1 -1
  466. package/out/src/storage/schema/tables/TableCommission.d.ts.map +1 -1
  467. package/out/src/storage/schema/tables/TableMonitorEvent.d.ts +1 -1
  468. package/out/src/storage/schema/tables/TableMonitorEvent.d.ts.map +1 -1
  469. package/out/src/storage/schema/tables/TableMonitorLease.d.ts +23 -0
  470. package/out/src/storage/schema/tables/TableMonitorLease.d.ts.map +1 -0
  471. package/out/src/storage/schema/tables/TableMonitorLease.js +3 -0
  472. package/out/src/storage/schema/tables/TableMonitorLease.js.map +1 -0
  473. package/out/src/storage/schema/tables/TableOutput.d.ts +10 -2
  474. package/out/src/storage/schema/tables/TableOutput.d.ts.map +1 -1
  475. package/out/src/storage/schema/tables/TableOutput.js +1 -1
  476. package/out/src/storage/schema/tables/TableOutput.js.map +1 -1
  477. package/out/src/storage/schema/tables/TableOutputBasket.d.ts +1 -1
  478. package/out/src/storage/schema/tables/TableOutputBasket.d.ts.map +1 -1
  479. package/out/src/storage/schema/tables/TableOutputTag.d.ts +1 -1
  480. package/out/src/storage/schema/tables/TableOutputTag.d.ts.map +1 -1
  481. package/out/src/storage/schema/tables/TableOutputTagMap.d.ts +1 -1
  482. package/out/src/storage/schema/tables/TableOutputTagMap.d.ts.map +1 -1
  483. package/out/src/storage/schema/tables/TableProvenTx.d.ts +1 -1
  484. package/out/src/storage/schema/tables/TableProvenTx.d.ts.map +1 -1
  485. package/out/src/storage/schema/tables/TableProvenTxReq.d.ts +24 -1
  486. package/out/src/storage/schema/tables/TableProvenTxReq.d.ts.map +1 -1
  487. package/out/src/storage/schema/tables/TableSettings.d.ts +1 -1
  488. package/out/src/storage/schema/tables/TableSettings.d.ts.map +1 -1
  489. package/out/src/storage/schema/tables/TableSyncState.d.ts +1 -1
  490. package/out/src/storage/schema/tables/TableSyncState.d.ts.map +1 -1
  491. package/out/src/storage/schema/tables/TableTransaction.d.ts +1 -1
  492. package/out/src/storage/schema/tables/TableTransaction.d.ts.map +1 -1
  493. package/out/src/storage/schema/tables/TableTransactionNew.d.ts +50 -0
  494. package/out/src/storage/schema/tables/TableTransactionNew.d.ts.map +1 -0
  495. package/out/src/storage/schema/tables/TableTransactionNew.js +3 -0
  496. package/out/src/storage/schema/tables/TableTransactionNew.js.map +1 -0
  497. package/out/src/storage/schema/tables/TableTransactionV7.d.ts +50 -0
  498. package/out/src/storage/schema/tables/TableTransactionV7.d.ts.map +1 -0
  499. package/out/src/storage/schema/tables/TableTransactionV7.js +3 -0
  500. package/out/src/storage/schema/tables/TableTransactionV7.js.map +1 -0
  501. package/out/src/storage/schema/tables/TableTxAudit.d.ts +26 -0
  502. package/out/src/storage/schema/tables/TableTxAudit.d.ts.map +1 -0
  503. package/out/src/storage/schema/tables/TableTxAudit.js +3 -0
  504. package/out/src/storage/schema/tables/TableTxAudit.js.map +1 -0
  505. package/out/src/storage/schema/tables/TableTxLabel.d.ts +1 -1
  506. package/out/src/storage/schema/tables/TableTxLabel.d.ts.map +1 -1
  507. package/out/src/storage/schema/tables/TableTxLabelMap.d.ts +1 -1
  508. package/out/src/storage/schema/tables/TableTxLabelMap.d.ts.map +1 -1
  509. package/out/src/storage/schema/tables/TableUser.d.ts +1 -1
  510. package/out/src/storage/schema/tables/TableUser.d.ts.map +1 -1
  511. package/out/src/storage/schema/tables/index.d.ts +5 -0
  512. package/out/src/storage/schema/tables/index.d.ts.map +1 -1
  513. package/out/src/storage/schema/tables/index.js +5 -0
  514. package/out/src/storage/schema/tables/index.js.map +1 -1
  515. package/out/src/storage/schema/transactionCrud.d.ts +41 -0
  516. package/out/src/storage/schema/transactionCrud.d.ts.map +1 -0
  517. package/out/src/storage/schema/transactionCrud.js +205 -0
  518. package/out/src/storage/schema/transactionCrud.js.map +1 -0
  519. package/out/src/storage/schema/transactionService.d.ts +315 -0
  520. package/out/src/storage/schema/transactionService.d.ts.map +1 -0
  521. package/out/src/storage/schema/transactionService.js +783 -0
  522. package/out/src/storage/schema/transactionService.js.map +1 -0
  523. package/out/src/storage/schema/txAudit.d.ts +33 -0
  524. package/out/src/storage/schema/txAudit.d.ts.map +1 -0
  525. package/out/src/storage/schema/txAudit.js +64 -0
  526. package/out/src/storage/schema/txAudit.js.map +1 -0
  527. package/out/src/storage/schema/v7Crud.d.ts +41 -0
  528. package/out/src/storage/schema/v7Crud.d.ts.map +1 -0
  529. package/out/src/storage/schema/v7Crud.js +205 -0
  530. package/out/src/storage/schema/v7Crud.js.map +1 -0
  531. package/out/src/storage/schema/v7Fsm.d.ts +27 -0
  532. package/out/src/storage/schema/v7Fsm.d.ts.map +1 -0
  533. package/out/src/storage/schema/v7Fsm.js +124 -0
  534. package/out/src/storage/schema/v7Fsm.js.map +1 -0
  535. package/out/src/storage/schema/v7MonitorLease.d.ts +57 -0
  536. package/out/src/storage/schema/v7MonitorLease.d.ts.map +1 -0
  537. package/out/src/storage/schema/v7MonitorLease.js +101 -0
  538. package/out/src/storage/schema/v7MonitorLease.js.map +1 -0
  539. package/out/src/storage/schema/v7Service.d.ts +305 -0
  540. package/out/src/storage/schema/v7Service.d.ts.map +1 -0
  541. package/out/src/storage/schema/v7Service.js +757 -0
  542. package/out/src/storage/schema/v7Service.js.map +1 -0
  543. package/out/src/storage/schema/v7TxAudit.d.ts +33 -0
  544. package/out/src/storage/schema/v7TxAudit.d.ts.map +1 -0
  545. package/out/src/storage/schema/v7TxAudit.js +64 -0
  546. package/out/src/storage/schema/v7TxAudit.js.map +1 -0
  547. package/out/src/storage/storageProviderHelpers.d.ts +34 -0
  548. package/out/src/storage/storageProviderHelpers.d.ts.map +1 -0
  549. package/out/src/storage/storageProviderHelpers.js +100 -0
  550. package/out/src/storage/storageProviderHelpers.js.map +1 -0
  551. package/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -1
  552. package/out/src/utility/ScriptTemplateBRC29.js +2 -1
  553. package/out/src/utility/ScriptTemplateBRC29.js.map +1 -1
  554. package/out/src/utility/aggregateResults.d.ts +1 -1
  555. package/out/src/utility/aggregateResults.d.ts.map +1 -1
  556. package/out/src/utility/aggregateResults.js +2 -2
  557. package/out/src/utility/aggregateResults.js.map +1 -1
  558. package/out/src/utility/brc114ActionTimeLabels.d.ts +2 -2
  559. package/out/src/utility/brc114ActionTimeLabels.d.ts.map +1 -1
  560. package/out/src/utility/brc114ActionTimeLabels.js +16 -9
  561. package/out/src/utility/brc114ActionTimeLabels.js.map +1 -1
  562. package/out/src/utility/identityUtils.js +1 -1
  563. package/out/src/utility/identityUtils.js.map +1 -1
  564. package/out/src/utility/parseTxScriptOffsets.d.ts +4 -4
  565. package/out/src/utility/parseTxScriptOffsets.d.ts.map +1 -1
  566. package/out/src/utility/parseTxScriptOffsets.js.map +1 -1
  567. package/out/src/utility/stampLog.d.ts.map +1 -1
  568. package/out/src/utility/stampLog.js +7 -5
  569. package/out/src/utility/stampLog.js.map +1 -1
  570. package/out/src/utility/tscProofToMerklePath.d.ts.map +1 -1
  571. package/out/src/utility/tscProofToMerklePath.js +1 -1
  572. package/out/src/utility/tscProofToMerklePath.js.map +1 -1
  573. package/out/src/utility/utilityHelpers.d.ts +1 -2
  574. package/out/src/utility/utilityHelpers.d.ts.map +1 -1
  575. package/out/src/utility/utilityHelpers.js +10 -10
  576. package/out/src/utility/utilityHelpers.js.map +1 -1
  577. package/out/src/utility/utilityHelpers.noBuffer.d.ts +7 -3
  578. package/out/src/utility/utilityHelpers.noBuffer.d.ts.map +1 -1
  579. package/out/src/utility/utilityHelpers.noBuffer.js +3 -3
  580. package/out/src/utility/utilityHelpers.noBuffer.js.map +1 -1
  581. package/out/src/wab-client/WABClient.d.ts +1 -1
  582. package/out/src/wab-client/WABClient.d.ts.map +1 -1
  583. package/out/src/wab-client/WABClient.js +12 -12
  584. package/out/src/wab-client/WABClient.js.map +1 -1
  585. package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts.map +1 -1
  586. package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js +3 -3
  587. package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js.map +1 -1
  588. package/package.json +7 -6
@@ -43,8 +43,8 @@ function stripVerifiedPushDropSignature(fields, lockingPublicKey) {
43
43
  let writeOffset = 0;
44
44
  for (let i = 0; i < protocolFieldCount; i++) {
45
45
  const field = fields[i];
46
- for (let j = 0; j < field.length; j++) {
47
- dataToVerify[writeOffset++] = field[j];
46
+ for (const byte of field) {
47
+ dataToVerify[writeOffset++] = byte;
48
48
  }
49
49
  }
50
50
  const signature = sdk_1.Signature.fromDER(trailingField);
@@ -71,10 +71,10 @@ async function pbkdf2NativeOrWasm(passwordBytes, salt, iterations, keyLen, hash
71
71
  var _a;
72
72
  // ----- fast-path: WebCrypto (both browser & recent Node expose globalThis.crypto.subtle)
73
73
  const subtle = (_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.crypto) === null || _a === void 0 ? void 0 : _a.subtle;
74
- if (subtle) {
74
+ if (subtle != null) {
75
75
  try {
76
76
  const baseKey = await subtle.importKey('raw', new Uint8Array(passwordBytes), { name: 'PBKDF2' },
77
- /*extractable*/ false, ['deriveBits']);
77
+ /* extractable */ false, ['deriveBits']);
78
78
  const bits = await subtle.deriveBits({
79
79
  name: 'PBKDF2',
80
80
  salt: new Uint8Array(salt),
@@ -83,9 +83,10 @@ async function pbkdf2NativeOrWasm(passwordBytes, salt, iterations, keyLen, hash
83
83
  }, baseKey, keyLen * 8);
84
84
  return Array.from(new Uint8Array(bits));
85
85
  }
86
- catch (err) {
87
- //console.warn('[pbkdf2] WebCrypto path failed falling back to JS implementation', err)
88
- /* fall through */
86
+ catch (webCryptoErr) {
87
+ // WebCrypto is unavailable or refused the algorithm (e.g. non-secure context, old
88
+ // Safari). Fall through to the pure-JS hash-wasm implementation below.
89
+ console.debug('[pbkdf2] WebCrypto path failed, falling back to JS implementation', webCryptoErr);
89
90
  }
90
91
  }
91
92
  const hashFunction = hash === 'sha256' ? (0, hash_wasm_1.createSHA256)() : (0, hash_wasm_1.createSHA512)();
@@ -113,8 +114,8 @@ async function derivePasswordKey(token, passwordBytes, overrideKdf) {
113
114
  var _a, _b, _c, _d, _e;
114
115
  const kdf = overrideKdf || token.passwordKdf;
115
116
  // Legacy token or explicit PBKDF2 request
116
- if (!kdf || kdf.algorithm === 'pbkdf2-sha512') {
117
- return pbkdf2NativeOrWasm(passwordBytes, token.passwordSalt, (_a = kdf === null || kdf === void 0 ? void 0 : kdf.iterations) !== null && _a !== void 0 ? _a : exports.PBKDF2_NUM_ROUNDS, 32, 'sha512');
117
+ if ((kdf == null) || kdf.algorithm === 'pbkdf2-sha512') {
118
+ return await pbkdf2NativeOrWasm(passwordBytes, token.passwordSalt, (_a = kdf === null || kdf === void 0 ? void 0 : kdf.iterations) !== null && _a !== void 0 ? _a : exports.PBKDF2_NUM_ROUNDS, 32, 'sha512');
118
119
  }
119
120
  // Argon2id path (UMP v3)
120
121
  if (kdf.algorithm === 'argon2id') {
@@ -207,7 +208,32 @@ class OverlayUMPTokenInteractor {
207
208
  */
208
209
  async buildAndSend(wallet, // This wallet MUST be the one built for the default profile
209
210
  adminOriginator, token, oldTokenToConsume) {
210
- // 1) Construct the data fields for the new UMP token.
211
+ // 1) Construct the data fields and PushDrop locking script for the new UMP token.
212
+ const fields = this.buildUMPTokenFields(token);
213
+ const script = await new sdk_1.PushDrop(wallet, adminOriginator).lock(fields, [2, 'admin user management token'], '1', 'self',
214
+ /* forSelf= */ true,
215
+ /* includeSignature= */ true);
216
+ const tokenOutput = [{ lockingScript: script.toHex(), satoshis: 1, outputDescription: 'New UMP token output' }];
217
+ // 2) Resolve the old-token input (if provided) and create the action.
218
+ const { resolvedOldToken, inputToken } = await this.resolveOldTokenInput(oldTokenToConsume);
219
+ const inputs = (resolvedOldToken === null || resolvedOldToken === void 0 ? void 0 : resolvedOldToken.currentOutpoint)
220
+ ? [{ outpoint: resolvedOldToken.currentOutpoint, unlockingScriptLength: 73, inputDescription: 'Consume old UMP token' }]
221
+ : [];
222
+ const createResult = await this.createUMPAction(wallet, adminOriginator, inputs, tokenOutput, inputToken, resolvedOldToken);
223
+ // 3) If the wallet fully processed it (no signable tx), broadcast and return.
224
+ if (!createResult.signableTransaction) {
225
+ return await this.broadcastFinishedUMPAction(createResult);
226
+ }
227
+ // 4) Sign and broadcast: with old token input or without.
228
+ const reference = createResult.signableTransaction.reference;
229
+ const partialTx = sdk_1.Transaction.fromBEEF(createResult.signableTransaction.tx);
230
+ if (resolvedOldToken === null || resolvedOldToken === void 0 ? void 0 : resolvedOldToken.currentOutpoint) {
231
+ return await this.signAndBroadcastWithOldToken(wallet, adminOriginator, reference, partialTx);
232
+ }
233
+ return await this.signAndBroadcastNewToken(wallet, adminOriginator, reference);
234
+ }
235
+ /** Assembles the ordered number[][] fields array from a UMPToken. */
236
+ buildUMPTokenFields(token) {
211
237
  const fields = [];
212
238
  fields[0] = token.passwordSalt;
213
239
  fields[1] = token.passwordPresentationPrimary;
@@ -220,148 +246,90 @@ class OverlayUMPTokenInteractor {
220
246
  fields[8] = token.presentationKeyEncrypted;
221
247
  fields[9] = token.passwordKeyEncrypted;
222
248
  fields[10] = token.recoveryKeyEncrypted;
223
- // Optional field for encrypted profiles
224
- if (token.profilesEncrypted) {
249
+ if (token.profilesEncrypted != null)
225
250
  fields[11] = token.profilesEncrypted;
226
- }
227
- // V3 fields: umpVersion, kdfAlgorithm, kdfParams
228
- if (token.umpVersion === 3 && token.passwordKdf) {
229
- const versionFieldIndex = token.profilesEncrypted ? 12 : 11;
230
- fields[versionFieldIndex] = [token.umpVersion]; // Single byte
231
- fields[versionFieldIndex + 1] = sdk_1.Utils.toArray(token.passwordKdf.algorithm, 'utf8');
232
- // Construct kdfParams JSON
233
- const kdfParams = {
234
- iterations: token.passwordKdf.iterations
235
- };
236
- if (token.passwordKdf.memoryKiB !== undefined) {
251
+ if (token.umpVersion === 3 && token.passwordKdf != null) {
252
+ const vi = (token.profilesEncrypted == null) ? 11 : 12;
253
+ fields[vi] = [token.umpVersion];
254
+ fields[vi + 1] = sdk_1.Utils.toArray(token.passwordKdf.algorithm, 'utf8');
255
+ const kdfParams = { iterations: token.passwordKdf.iterations };
256
+ if (token.passwordKdf.memoryKiB !== undefined)
237
257
  kdfParams.memoryKiB = token.passwordKdf.memoryKiB;
238
- }
239
- if (token.passwordKdf.parallelism !== undefined) {
258
+ if (token.passwordKdf.parallelism !== undefined)
240
259
  kdfParams.parallelism = token.passwordKdf.parallelism;
241
- }
242
- if (token.passwordKdf.hashLength !== undefined) {
260
+ if (token.passwordKdf.hashLength !== undefined)
243
261
  kdfParams.hashLength = token.passwordKdf.hashLength;
244
- }
245
- fields[versionFieldIndex + 2] = sdk_1.Utils.toArray(JSON.stringify(kdfParams), 'utf8');
246
- }
247
- // 2) Create a PushDrop script referencing these fields, locked with the admin key.
248
- // The signature will be added as trailing metadata by PushDrop (not part of protocol fields).
249
- const script = await new sdk_1.PushDrop(wallet, adminOriginator).lock(fields, [2, 'admin user management token'], // protocolID
250
- '1', // keyID
251
- 'self', // counterparty
252
- /*forSelf=*/ true,
253
- /*includeSignature=*/ true);
254
- // 3) Prepare the createAction call. If oldTokenToConsume is provided, gather the outpoint.
255
- const inputs = [];
256
- let inputToken;
257
- if (oldTokenToConsume === null || oldTokenToConsume === void 0 ? void 0 : oldTokenToConsume.currentOutpoint) {
258
- inputToken = await this.findByOutpoint(oldTokenToConsume.currentOutpoint);
259
- // If there is no token on the overlay, we can't consume it. Just start over with a new token.
260
- if (!inputToken) {
261
- oldTokenToConsume = undefined;
262
- // Otherwise, add the input
263
- }
264
- else {
265
- inputs.push({
266
- outpoint: oldTokenToConsume.currentOutpoint,
267
- unlockingScriptLength: 73, // typical signature length
268
- inputDescription: 'Consume old UMP token'
269
- });
270
- }
262
+ fields[vi + 2] = sdk_1.Utils.toArray(JSON.stringify(kdfParams), 'utf8');
271
263
  }
272
- const outputs = [
273
- {
274
- lockingScript: script.toHex(),
275
- satoshis: 1,
276
- outputDescription: 'New UMP token output'
277
- }
278
- ];
279
- // 4) Build the partial transaction via createAction.
280
- let createResult;
264
+ return fields;
265
+ }
266
+ /** Looks up the old token on the overlay; returns undefined resolved token if not found. */
267
+ async resolveOldTokenInput(oldTokenToConsume) {
268
+ if (!(oldTokenToConsume === null || oldTokenToConsume === void 0 ? void 0 : oldTokenToConsume.currentOutpoint))
269
+ return { resolvedOldToken: undefined, inputToken: undefined };
270
+ const inputToken = await this.findByOutpoint(oldTokenToConsume.currentOutpoint);
271
+ if (inputToken == null)
272
+ return { resolvedOldToken: undefined, inputToken: undefined };
273
+ return { resolvedOldToken: oldTokenToConsume, inputToken };
274
+ }
275
+ /** Creates the UMP action; falls back to a bare recovery action on failure. */
276
+ async createUMPAction(wallet, adminOriginator, inputs, outputs, inputToken, resolvedOldToken) {
281
277
  try {
282
- createResult = await wallet.createAction({
283
- description: oldTokenToConsume ? 'Renew UMP token (consume old, create new)' : 'Create new UMP token',
278
+ return await wallet.createAction({
279
+ description: (resolvedOldToken == null) ? 'Create new UMP token' : 'Renew UMP token (consume old, create new)',
284
280
  inputs,
285
281
  outputs,
286
282
  inputBEEF: inputToken === null || inputToken === void 0 ? void 0 : inputToken.beef,
287
- options: {
288
- randomizeOutputs: false,
289
- acceptDelayedBroadcast: false
290
- }
283
+ options: { randomizeOutputs: false, acceptDelayedBroadcast: false }
291
284
  }, adminOriginator);
292
285
  }
293
286
  catch (e) {
294
287
  console.error('Error with UMP token update. Attempting a last-ditch effort to get a new one', e);
295
- createResult = await wallet.createAction({
288
+ return await wallet.createAction({
296
289
  description: 'Recover UMP token',
297
290
  outputs,
298
- options: {
299
- randomizeOutputs: false,
300
- acceptDelayedBroadcast: false
301
- }
302
- }, adminOriginator);
303
- }
304
- // If the transaction is fully processed by the wallet
305
- if (!createResult.signableTransaction) {
306
- const finalTxid = createResult.txid || (createResult.tx ? sdk_1.Transaction.fromAtomicBEEF(createResult.tx).id('hex') : undefined);
307
- if (!finalTxid) {
308
- throw new Error('No signableTransaction and no final TX found.');
309
- }
310
- // Now broadcast to `tm_users` using SHIP
311
- const broadcastTx = sdk_1.Transaction.fromAtomicBEEF(createResult.tx);
312
- const result = await this.broadcaster.broadcast(broadcastTx);
313
- console.log('BROADCAST RESULT', result);
314
- return `${finalTxid}.0`;
315
- }
316
- // 5) If oldTokenToConsume is present, we must sign the input referencing it.
317
- // (If there's no old token, there's nothing to sign for the input.)
318
- let finalTxid = '';
319
- const reference = createResult.signableTransaction.reference;
320
- const partialTx = sdk_1.Transaction.fromBEEF(createResult.signableTransaction.tx);
321
- if (oldTokenToConsume === null || oldTokenToConsume === void 0 ? void 0 : oldTokenToConsume.currentOutpoint) {
322
- // Unlock the old token with a matching PushDrop unlocker
323
- const unlocker = new sdk_1.PushDrop(wallet, adminOriginator).unlock([2, 'admin user management token'], '1', 'self');
324
- const unlockingScript = await unlocker.sign(partialTx, 0);
325
- // Provide it to the wallet
326
- const signResult = await wallet.signAction({
327
- reference,
328
- spends: {
329
- 0: {
330
- unlockingScript: unlockingScript.toHex()
331
- }
332
- }
291
+ options: { randomizeOutputs: false, acceptDelayedBroadcast: false }
333
292
  }, adminOriginator);
334
- finalTxid = signResult.txid || (signResult.tx ? sdk_1.Transaction.fromAtomicBEEF(signResult.tx).id('hex') : '');
335
- if (!finalTxid) {
336
- throw new Error('Could not finalize transaction for renewed UMP token.');
337
- }
338
- // 6) Broadcast to `tm_users`
339
- const finalAtomicTx = signResult.tx;
340
- if (!finalAtomicTx) {
341
- throw new Error('Final transaction data missing after signing renewed UMP token.');
342
- }
343
- const broadcastTx = sdk_1.Transaction.fromAtomicBEEF(finalAtomicTx);
344
- const result = await this.broadcaster.broadcast(broadcastTx);
345
- console.log('BROADCAST RESULT', result);
346
- return `${finalTxid}.0`;
347
- }
348
- else {
349
- // Fallback for creating a new token (no input spending)
350
- const signResult = await wallet.signAction({ reference, spends: {} }, adminOriginator);
351
- finalTxid = signResult.txid || (signResult.tx ? sdk_1.Transaction.fromAtomicBEEF(signResult.tx).id('hex') : '');
352
- if (!finalTxid) {
353
- throw new Error('Failed to finalize new UMP token transaction.');
354
- }
355
- const finalAtomicTx = signResult.tx;
356
- if (!finalAtomicTx) {
357
- throw new Error('Final transaction data missing after signing new UMP token.');
358
- }
359
- const broadcastTx = sdk_1.Transaction.fromAtomicBEEF(finalAtomicTx);
360
- const result = await this.broadcaster.broadcast(broadcastTx);
361
- console.log('BROADCAST RESULT', result);
362
- return `${finalTxid}.0`;
363
293
  }
364
294
  }
295
+ /** Handles a fully-finalized (no signable tx) createAction result — broadcasts and returns outpoint. */
296
+ async broadcastFinishedUMPAction(createResult) {
297
+ const finalTxid = createResult.txid || (createResult.tx != null ? sdk_1.Transaction.fromAtomicBEEF(createResult.tx).id('hex') : undefined);
298
+ if (!finalTxid)
299
+ throw new Error('No signableTransaction and no final TX found.');
300
+ if (createResult.tx == null)
301
+ throw new Error('No final TX data to broadcast.');
302
+ const broadcastTx = sdk_1.Transaction.fromAtomicBEEF(createResult.tx);
303
+ const result = await this.broadcaster.broadcast(broadcastTx);
304
+ console.log('BROADCAST RESULT', result);
305
+ return `${finalTxid}.0`;
306
+ }
307
+ /** Signs the old-token input and broadcasts — used during UMP token renewal. */
308
+ async signAndBroadcastWithOldToken(wallet, adminOriginator, reference, partialTx) {
309
+ const unlocker = new sdk_1.PushDrop(wallet, adminOriginator).unlock([2, 'admin user management token'], '1', 'self');
310
+ const unlockingScript = await unlocker.sign(partialTx, 0);
311
+ const signResult = await wallet.signAction({ reference, spends: { 0: { unlockingScript: unlockingScript.toHex() } } }, adminOriginator);
312
+ const finalTxid = signResult.txid || ((signResult.tx == null) ? '' : sdk_1.Transaction.fromAtomicBEEF(signResult.tx).id('hex'));
313
+ if (!finalTxid)
314
+ throw new Error('Could not finalize transaction for renewed UMP token.');
315
+ if (signResult.tx == null)
316
+ throw new Error('Final transaction data missing after signing renewed UMP token.');
317
+ const result = await this.broadcaster.broadcast(sdk_1.Transaction.fromAtomicBEEF(signResult.tx));
318
+ console.log('BROADCAST RESULT', result);
319
+ return `${finalTxid}.0`;
320
+ }
321
+ /** Signs without input spending and broadcasts — used when creating a brand-new UMP token. */
322
+ async signAndBroadcastNewToken(wallet, adminOriginator, reference) {
323
+ const signResult = await wallet.signAction({ reference, spends: {} }, adminOriginator);
324
+ const finalTxid = signResult.txid || ((signResult.tx == null) ? '' : sdk_1.Transaction.fromAtomicBEEF(signResult.tx).id('hex'));
325
+ if (!finalTxid)
326
+ throw new Error('Failed to finalize new UMP token transaction.');
327
+ if (signResult.tx == null)
328
+ throw new Error('Final transaction data missing after signing new UMP token.');
329
+ const result = await this.broadcaster.broadcast(sdk_1.Transaction.fromAtomicBEEF(signResult.tx));
330
+ console.log('BROADCAST RESULT', result);
331
+ return `${finalTxid}.0`;
332
+ }
365
333
  /**
366
334
  * Attempts to parse a LookupAnswer from the UMP lookup service. If successful,
367
335
  * extracts the token fields from the resulting transaction and constructs
@@ -390,13 +358,19 @@ class OverlayUMPTokenInteractor {
390
358
  }
391
359
  // Parse protocol fields, excluding the trailing PushDrop signature only when
392
360
  // it is cryptographically valid for the preceding field payload.
393
- let protocolFields = stripVerifiedPushDropSignature(decoded.fields, decoded.lockingPublicKey);
361
+ const protocolFields = stripVerifiedPushDropSignature(decoded.fields, decoded.lockingPublicKey);
394
362
  // Detect v3 token metadata in either layout:
395
363
  // - with profilesEncrypted present: [0..10]=core, [11]=profiles, [12]=version, [13]=algorithm, [14]=params
396
364
  // - without profilesEncrypted: [0..10]=core, [11]=version, [12]=algorithm, [13]=params
397
365
  const hasV3MetadataWithProfiles = protocolFields.length >= 15 && ((_b = protocolFields[12]) === null || _b === void 0 ? void 0 : _b.length) === 1 && protocolFields[12][0] === 3;
398
366
  const hasV3MetadataWithoutProfiles = protocolFields.length >= 14 && ((_c = protocolFields[11]) === null || _c === void 0 ? void 0 : _c.length) === 1 && protocolFields[11][0] === 3;
399
- const kdfVersionFieldIndex = hasV3MetadataWithProfiles ? 12 : hasV3MetadataWithoutProfiles ? 11 : -1;
367
+ let kdfVersionFieldIndex;
368
+ if (hasV3MetadataWithProfiles)
369
+ kdfVersionFieldIndex = 12;
370
+ else if (hasV3MetadataWithoutProfiles)
371
+ kdfVersionFieldIndex = 11;
372
+ else
373
+ kdfVersionFieldIndex = -1;
400
374
  // Build the UMP token from these fields, preserving outpoint
401
375
  const t = {
402
376
  // Core fields (unchanged for all versions)
@@ -464,7 +438,7 @@ class OverlayUMPTokenInteractor {
464
438
  if (results.type !== 'output-list') {
465
439
  return undefined;
466
440
  }
467
- if (!results.outputs || !results.outputs.length) {
441
+ if (!results.outputs || (results.outputs.length === 0)) {
468
442
  return undefined;
469
443
  }
470
444
  return results.outputs[0];
@@ -477,6 +451,18 @@ exports.OverlayUMPTokenInteractor = OverlayUMPTokenInteractor;
477
451
  * supporting multiple user profiles under a single account.
478
452
  */
479
453
  class CWIStyleWalletManager {
454
+ /**
455
+ * Resolves once the optional snapshot (if provided to the constructor) has been
456
+ * fully loaded and the wallet is ready to accept calls.
457
+ * When no snapshot is provided this resolves immediately.
458
+ * Await `ready` before calling wallet methods after constructing with a snapshot.
459
+ */
460
+ get ready() {
461
+ if (this._readyInit === undefined) {
462
+ this._readyInit = this._init();
463
+ }
464
+ return this._readyInit;
465
+ }
480
466
  /**
481
467
  * Constructs a new CWIStyleWalletManager.
482
468
  *
@@ -522,14 +508,14 @@ class CWIStyleWalletManager {
522
508
  parallelism: (_d = kdfConfig === null || kdfConfig === void 0 ? void 0 : kdfConfig.parallelism) !== null && _d !== void 0 ? _d : exports.ARGON2ID_DEFAULT_PARALLELISM,
523
509
  hashLength: (_e = kdfConfig === null || kdfConfig === void 0 ? void 0 : kdfConfig.hashLength) !== null && _e !== void 0 ? _e : exports.ARGON2ID_DEFAULT_HASH_LENGTH
524
510
  };
525
- // If a saved snapshot is provided, attempt to load it.
526
- // Note: loadSnapshot now returns a promise. We don't await it here,
527
- // as the constructor must be synchronous. The caller should check
528
- // `this.authenticated` after construction if a snapshot was provided.
529
- if (stateSnapshot) {
530
- this.loadSnapshot(stateSnapshot).catch(err => {
511
+ // Store snapshot for lazy init; callers await ready before calling wallet methods.
512
+ this._initSnapshot = stateSnapshot;
513
+ }
514
+ async _init() {
515
+ if (this._initSnapshot !== undefined) {
516
+ await this.loadSnapshot(this._initSnapshot).catch((err) => {
531
517
  console.error('Failed to load snapshot during construction:', err);
532
- // Clear potentially partially loaded state
518
+ // Clear potentially partially loaded state. destroy() is synchronous.
533
519
  this.destroy();
534
520
  });
535
521
  }
@@ -547,7 +533,7 @@ class CWIStyleWalletManager {
547
533
  }
548
534
  const hash = sdk_1.Hash.sha256(key);
549
535
  const token = await this.UMPTokenInteractor.findByPresentationKeyHash(hash);
550
- if (!token) {
536
+ if (token == null) {
551
537
  // No token found -> New user
552
538
  this.authenticationFlow = 'new-user';
553
539
  this.presentationKey = key;
@@ -563,119 +549,98 @@ class CWIStyleWalletManager {
563
549
  * Provides the password.
564
550
  */
565
551
  async providePassword(password) {
566
- if (this.authenticated) {
552
+ if (this.authenticated)
567
553
  throw new Error('User is already authenticated');
568
- }
569
554
  if (this.authenticationMode === 'presentation-key-and-recovery-key') {
570
555
  throw new Error('Password is not needed in this mode');
571
556
  }
572
557
  if (this.authenticationFlow === 'existing-user') {
573
- // Existing user flow
574
- if (!this.currentUMPToken) {
575
- throw new Error('Provide presentation or recovery key first.');
576
- }
577
- // Use token-driven KDF (legacy PBKDF2 or v3 Argon2id)
578
- const derivedPasswordKey = await derivePasswordKey(this.currentUMPToken, sdk_1.Utils.toArray(password, 'utf8'));
579
- let rootPrimaryKey;
580
- let rootPrivilegedKey; // Only needed for recovery mode
581
- if (this.authenticationMode === 'presentation-key-and-password') {
582
- if (!this.presentationKey)
583
- throw new Error('No presentation key found!');
584
- const xorKey = this.XOR(this.presentationKey, derivedPasswordKey);
585
- rootPrimaryKey = new sdk_1.SymmetricKey(xorKey).decrypt(this.currentUMPToken.passwordPresentationPrimary);
586
- }
587
- else {
588
- // 'recovery-key-and-password'
589
- if (!this.recoveryKey)
590
- throw new Error('No recovery key found!');
591
- const primaryDecryptionKey = this.XOR(this.recoveryKey, derivedPasswordKey);
592
- rootPrimaryKey = new sdk_1.SymmetricKey(primaryDecryptionKey).decrypt(this.currentUMPToken.passwordRecoveryPrimary);
593
- const privilegedDecryptionKey = this.XOR(rootPrimaryKey, derivedPasswordKey);
594
- rootPrivilegedKey = new sdk_1.SymmetricKey(privilegedDecryptionKey).decrypt(this.currentUMPToken.passwordPrimaryPrivileged);
595
- }
596
- // Build root infrastructure, load profiles, and switch to default profile initially
597
- await this.setupRootInfrastructure(rootPrimaryKey, rootPrivilegedKey);
598
- await this.switchProfile(this.activeProfileId);
558
+ await this.handleExistingUserPassword(password);
599
559
  }
600
560
  else {
601
- // New user flow (only 'presentation-key-and-password')
602
- if (this.authenticationMode !== 'presentation-key-and-password') {
603
- throw new Error('New-user flow requires presentation key and password mode.');
604
- }
605
- if (!this.presentationKey) {
606
- throw new Error('No presentation key provided for new-user flow.');
607
- }
608
- // Generate new keys/salt
609
- const recoveryKey = (0, sdk_1.Random)(32);
610
- await this.recoveryKeySaver(recoveryKey);
611
- const passwordSalt = (0, sdk_1.Random)(32);
612
- // Build temporary token with KDF config for password derivation
613
- const tempTokenForKdf = {
614
- passwordSalt,
615
- passwordKdf: this.kdfConfig
616
- };
617
- const passwordKey = await derivePasswordKey(tempTokenForKdf, sdk_1.Utils.toArray(password, 'utf8'));
618
- const rootPrimaryKey = (0, sdk_1.Random)(32);
619
- const rootPrivilegedKey = (0, sdk_1.Random)(32);
620
- // Build XOR keys
621
- const presentationPassword = new sdk_1.SymmetricKey(this.XOR(this.presentationKey, passwordKey));
622
- const presentationRecovery = new sdk_1.SymmetricKey(this.XOR(this.presentationKey, recoveryKey));
623
- const recoveryPassword = new sdk_1.SymmetricKey(this.XOR(recoveryKey, passwordKey));
624
- const primaryPassword = new sdk_1.SymmetricKey(this.XOR(rootPrimaryKey, passwordKey));
625
- // Temp manager for encryption
626
- const tempPrivilegedKeyManager = new PrivilegedKeyManager_1.PrivilegedKeyManager(async () => new sdk_1.PrivateKey(rootPrivilegedKey));
627
- // Build new UMP token (v3 with KDF metadata, no profiles initially)
628
- const newToken = {
629
- passwordSalt,
630
- passwordPresentationPrimary: presentationPassword.encrypt(rootPrimaryKey),
631
- passwordRecoveryPrimary: recoveryPassword.encrypt(rootPrimaryKey),
632
- presentationRecoveryPrimary: presentationRecovery.encrypt(rootPrimaryKey),
633
- passwordPrimaryPrivileged: primaryPassword.encrypt(rootPrivilegedKey),
634
- presentationRecoveryPrivileged: presentationRecovery.encrypt(rootPrivilegedKey),
635
- presentationHash: sdk_1.Hash.sha256(this.presentationKey),
636
- recoveryHash: sdk_1.Hash.sha256(recoveryKey),
637
- presentationKeyEncrypted: (await tempPrivilegedKeyManager.encrypt({
638
- plaintext: this.presentationKey,
639
- protocolID: [2, 'admin key wrapping'],
640
- keyID: '1'
641
- })).ciphertext,
642
- passwordKeyEncrypted: (await tempPrivilegedKeyManager.encrypt({
643
- plaintext: passwordKey,
644
- protocolID: [2, 'admin key wrapping'],
645
- keyID: '1'
646
- })).ciphertext,
647
- recoveryKeyEncrypted: (await tempPrivilegedKeyManager.encrypt({
648
- plaintext: recoveryKey,
649
- protocolID: [2, 'admin key wrapping'],
650
- keyID: '1'
651
- })).ciphertext,
652
- profilesEncrypted: undefined, // No profiles yet
653
- umpVersion: 3, // UMP protocol version 3
654
- passwordKdf: this.kdfConfig // KDF metadata for v3
655
- };
656
- this.currentUMPToken = newToken;
657
- // Setup root infrastructure and switch to default profile
658
- await this.setupRootInfrastructure(rootPrimaryKey);
659
- await this.switchProfile(exports.DEFAULT_PROFILE_ID);
660
- // Fund the *default* wallet if funder provided
661
- if (this.newWalletFunder && this.underlying) {
662
- try {
663
- await this.newWalletFunder(this.presentationKey, this.underlying, this.adminOriginator);
664
- }
665
- catch (e) {
666
- console.error('Error funding new wallet:', e);
667
- const message = e instanceof Error ? e.message : String(e);
668
- throw new Error(`Failed to fund new wallet before publishing UMP token: ${message}`);
669
- }
561
+ await this.handleNewUserPassword(password);
562
+ }
563
+ }
564
+ /** Handles the password step for an existing user — derives keys, sets up infrastructure. */
565
+ async handleExistingUserPassword(password) {
566
+ if (this.currentUMPToken == null)
567
+ throw new Error('Provide presentation or recovery key first.');
568
+ const derivedPasswordKey = await derivePasswordKey(this.currentUMPToken, sdk_1.Utils.toArray(password, 'utf8'));
569
+ let rootPrimaryKey;
570
+ let rootPrivilegedKey;
571
+ if (this.authenticationMode === 'presentation-key-and-password') {
572
+ if (this.presentationKey == null)
573
+ throw new Error('No presentation key found!');
574
+ rootPrimaryKey = new sdk_1.SymmetricKey(this.XOR(this.presentationKey, derivedPasswordKey))
575
+ .decrypt(this.currentUMPToken.passwordPresentationPrimary);
576
+ }
577
+ else {
578
+ // 'recovery-key-and-password'
579
+ if (this.recoveryKey == null)
580
+ throw new Error('No recovery key found!');
581
+ const primaryDecryptionKey = this.XOR(this.recoveryKey, derivedPasswordKey);
582
+ rootPrimaryKey = new sdk_1.SymmetricKey(primaryDecryptionKey).decrypt(this.currentUMPToken.passwordRecoveryPrimary);
583
+ rootPrivilegedKey = new sdk_1.SymmetricKey(this.XOR(rootPrimaryKey, derivedPasswordKey))
584
+ .decrypt(this.currentUMPToken.passwordPrimaryPrivileged);
585
+ }
586
+ await this.setupRootInfrastructure(rootPrimaryKey, rootPrivilegedKey);
587
+ await this.switchProfile(this.activeProfileId);
588
+ }
589
+ /** Handles the password step for a new user — generates keys, builds UMP token, publishes on-chain. */
590
+ async handleNewUserPassword(password) {
591
+ if (this.authenticationMode !== 'presentation-key-and-password') {
592
+ throw new Error('New-user flow requires presentation key and password mode.');
593
+ }
594
+ if (this.presentationKey == null)
595
+ throw new Error('No presentation key provided for new-user flow.');
596
+ // Generate new keys/salt
597
+ const recoveryKey = (0, sdk_1.Random)(32);
598
+ await this.recoveryKeySaver(recoveryKey);
599
+ const passwordSalt = (0, sdk_1.Random)(32);
600
+ const passwordKey = await derivePasswordKey({ passwordSalt, passwordKdf: this.kdfConfig }, sdk_1.Utils.toArray(password, 'utf8'));
601
+ const rootPrimaryKey = (0, sdk_1.Random)(32);
602
+ const rootPrivilegedKey = (0, sdk_1.Random)(32);
603
+ // Build XOR-combined symmetric keys
604
+ const presentationPassword = new sdk_1.SymmetricKey(this.XOR(this.presentationKey, passwordKey));
605
+ const presentationRecovery = new sdk_1.SymmetricKey(this.XOR(this.presentationKey, recoveryKey));
606
+ const recoveryPassword = new sdk_1.SymmetricKey(this.XOR(recoveryKey, passwordKey));
607
+ const primaryPassword = new sdk_1.SymmetricKey(this.XOR(rootPrimaryKey, passwordKey));
608
+ const tempPrivilegedKeyManager = new PrivilegedKeyManager_1.PrivilegedKeyManager(async () => new sdk_1.PrivateKey(rootPrivilegedKey));
609
+ const wrapKey = async (plaintext) => (await tempPrivilegedKeyManager.encrypt({ plaintext, protocolID: [2, 'admin key wrapping'], keyID: '1' })).ciphertext;
610
+ // Build new UMP token (v3 with KDF metadata, no profiles initially)
611
+ const newToken = {
612
+ passwordSalt,
613
+ passwordPresentationPrimary: presentationPassword.encrypt(rootPrimaryKey),
614
+ passwordRecoveryPrimary: recoveryPassword.encrypt(rootPrimaryKey),
615
+ presentationRecoveryPrimary: presentationRecovery.encrypt(rootPrimaryKey),
616
+ passwordPrimaryPrivileged: primaryPassword.encrypt(rootPrivilegedKey),
617
+ presentationRecoveryPrivileged: presentationRecovery.encrypt(rootPrivilegedKey),
618
+ presentationHash: sdk_1.Hash.sha256(this.presentationKey),
619
+ recoveryHash: sdk_1.Hash.sha256(recoveryKey),
620
+ presentationKeyEncrypted: await wrapKey(this.presentationKey),
621
+ passwordKeyEncrypted: await wrapKey(passwordKey),
622
+ recoveryKeyEncrypted: await wrapKey(recoveryKey),
623
+ profilesEncrypted: undefined,
624
+ umpVersion: 3,
625
+ passwordKdf: this.kdfConfig
626
+ };
627
+ this.currentUMPToken = newToken;
628
+ await this.setupRootInfrastructure(rootPrimaryKey);
629
+ await this.switchProfile(exports.DEFAULT_PROFILE_ID);
630
+ // Fund the *default* wallet if funder provided
631
+ if ((this.newWalletFunder != null) && (this.underlying != null)) {
632
+ try {
633
+ await this.newWalletFunder(this.presentationKey, this.underlying, this.adminOriginator);
670
634
  }
671
- // Publish the new UMP token *after* potentially funding
672
- // We need the default profile wallet to sign the UMP creation TX
673
- if (!this.underlying) {
674
- throw new Error('Default profile wallet not built before attempting to publish UMP token.');
635
+ catch (e) {
636
+ console.error('Error funding new wallet:', e);
637
+ const message = e instanceof Error ? e.message : String(e);
638
+ throw new Error(`Failed to fund new wallet before publishing UMP token: ${message}`);
675
639
  }
676
- this.currentUMPToken.currentOutpoint = await this.UMPTokenInteractor.buildAndSend(this.underlying, // Use the default profile wallet
677
- this.adminOriginator, newToken);
678
640
  }
641
+ if (this.underlying == null)
642
+ throw new Error('Default profile wallet not built before attempting to publish UMP token.');
643
+ this.currentUMPToken.currentOutpoint = await this.UMPTokenInteractor.buildAndSend(this.underlying, this.adminOriginator, newToken);
679
644
  }
680
645
  /**
681
646
  * Provides the recovery key.
@@ -694,7 +659,7 @@ class CWIStyleWalletManager {
694
659
  // Wait for password
695
660
  const hash = sdk_1.Hash.sha256(recoveryKey);
696
661
  const token = await this.UMPTokenInteractor.findByRecoveryKeyHash(hash);
697
- if (!token)
662
+ if (token == null)
698
663
  throw new Error('No user found with this recovery key');
699
664
  this.authenticationFlow = 'existing-user';
700
665
  this.recoveryKey = recoveryKey;
@@ -702,9 +667,9 @@ class CWIStyleWalletManager {
702
667
  }
703
668
  else {
704
669
  // 'presentation-key-and-recovery-key'
705
- if (!this.presentationKey)
670
+ if (this.presentationKey == null)
706
671
  throw new Error('Provide the presentation key first');
707
- if (!this.currentUMPToken)
672
+ if (this.currentUMPToken == null)
708
673
  throw new Error('Current UMP token not found');
709
674
  const xorKey = this.XOR(this.presentationKey, recoveryKey);
710
675
  const rootPrimaryKey = new sdk_1.SymmetricKey(xorKey).decrypt(this.currentUMPToken.presentationRecoveryPrimary);
@@ -723,7 +688,7 @@ class CWIStyleWalletManager {
723
688
  * @returns Encrypted snapshot bytes.
724
689
  */
725
690
  saveSnapshot() {
726
- if (!this.rootPrimaryKey || !this.currentUMPToken) {
691
+ if ((this.rootPrimaryKey == null) || (this.currentUMPToken == null)) {
727
692
  throw new Error('No root primary key or current UMP token set');
728
693
  }
729
694
  const snapshotKey = (0, sdk_1.Random)(32);
@@ -795,18 +760,18 @@ class CWIStyleWalletManager {
795
760
  }
796
761
  }
797
762
  async syncUMPToken() {
798
- if (!this.authenticated || !this.currentUMPToken || !this.rootPrimaryKey) {
763
+ if (!this.authenticated || (this.currentUMPToken == null) || (this.rootPrimaryKey == null)) {
799
764
  throw new Error('Wallet not authenticated or missing UMP token.');
800
765
  }
801
766
  const currentToken = this.currentUMPToken;
802
767
  let refreshed;
803
- if (currentToken.presentationHash && currentToken.presentationHash.length) {
768
+ if (currentToken.presentationHash && (currentToken.presentationHash.length > 0)) {
804
769
  refreshed = await this.UMPTokenInteractor.findByPresentationKeyHash(currentToken.presentationHash);
805
770
  }
806
- if (!refreshed && currentToken.recoveryHash && currentToken.recoveryHash.length) {
771
+ if ((refreshed == null) && currentToken.recoveryHash && (currentToken.recoveryHash.length > 0)) {
807
772
  refreshed = await this.UMPTokenInteractor.findByRecoveryKeyHash(currentToken.recoveryHash);
808
773
  }
809
- if (!refreshed) {
774
+ if (refreshed == null) {
810
775
  return false;
811
776
  }
812
777
  if (refreshed.currentOutpoint &&
@@ -873,7 +838,7 @@ class CWIStyleWalletManager {
873
838
  * @returns The ID of the newly created profile.
874
839
  */
875
840
  async addProfile(name) {
876
- if (!this.authenticated || !this.rootPrimaryKey || !this.currentUMPToken || !this.rootPrivilegedKeyManager) {
841
+ if (!this.authenticated || (this.rootPrimaryKey == null) || (this.currentUMPToken == null) || (this.rootPrivilegedKeyManager == null)) {
877
842
  throw new Error('Wallet not fully initialized or authenticated.');
878
843
  }
879
844
  // Ensure name is unique (including 'default')
@@ -904,7 +869,7 @@ class CWIStyleWalletManager {
904
869
  * @param profileId The 16-byte ID of the profile to delete.
905
870
  */
906
871
  async deleteProfile(profileId) {
907
- if (!this.authenticated || !this.rootPrimaryKey || !this.currentUMPToken || !this.rootPrivilegedKeyManager) {
872
+ if (!this.authenticated || (this.rootPrimaryKey == null) || (this.currentUMPToken == null) || (this.rootPrivilegedKeyManager == null)) {
908
873
  throw new Error('Wallet not fully initialized or authenticated.');
909
874
  }
910
875
  if (profileId.every(x => x === 0)) {
@@ -931,7 +896,7 @@ class CWIStyleWalletManager {
931
896
  * @param profileId The 16-byte ID of the profile to switch to (use DEFAULT_PROFILE_ID for default).
932
897
  */
933
898
  async switchProfile(profileId) {
934
- if (!this.authenticated || !this.rootPrimaryKey || !this.rootPrivilegedKeyManager) {
899
+ if (!this.authenticated || (this.rootPrimaryKey == null) || (this.rootPrivilegedKeyManager == null)) {
935
900
  throw new Error('Cannot switch profile: Wallet not authenticated or root keys missing.');
936
901
  }
937
902
  let profilePrimaryKey;
@@ -945,7 +910,7 @@ class CWIStyleWalletManager {
945
910
  else {
946
911
  // Switching to a non-default profile
947
912
  const profile = this.profiles.find(p => p.id.every((x, i) => x === profileId[i]));
948
- if (!profile) {
913
+ if (profile == null) {
949
914
  throw new Error('Profile not found.');
950
915
  }
951
916
  profilePrimaryKey = this.XOR(this.rootPrimaryKey, profile.primaryPad);
@@ -959,9 +924,9 @@ class CWIStyleWalletManager {
959
924
  const rootPrivileged = await this.rootPrivilegedKeyManager.getPrivilegedKey(reason);
960
925
  const rootPrivilegedBytes = rootPrivileged.toArray();
961
926
  // Apply the profile's pad if applicable
962
- const profilePrivilegedBytes = profilePrivilegedPad
963
- ? this.XOR(rootPrivilegedBytes, profilePrivilegedPad)
964
- : rootPrivilegedBytes;
927
+ const profilePrivilegedBytes = (profilePrivilegedPad == null)
928
+ ? rootPrivilegedBytes
929
+ : this.XOR(rootPrivilegedBytes, profilePrivilegedPad);
965
930
  return new sdk_1.PrivateKey(profilePrivilegedBytes);
966
931
  });
967
932
  // Build the underlying wallet for the specific profile
@@ -975,7 +940,7 @@ class CWIStyleWalletManager {
975
940
  */
976
941
  async changePassword(newPassword) {
977
942
  var _a;
978
- if (!this.authenticated || !this.currentUMPToken || !this.rootPrimaryKey || !this.rootPrivilegedKeyManager) {
943
+ if (!this.authenticated || (this.currentUMPToken == null) || (this.rootPrimaryKey == null) || (this.rootPrivilegedKeyManager == null)) {
979
944
  throw new Error('Not authenticated or missing required data.');
980
945
  }
981
946
  const passwordSalt = (0, sdk_1.Random)(32);
@@ -998,16 +963,16 @@ class CWIStyleWalletManager {
998
963
  * Retrieves the current recovery key. Requires privileged access.
999
964
  */
1000
965
  async getRecoveryKey() {
1001
- if (!this.authenticated || !this.currentUMPToken || !this.rootPrivilegedKeyManager) {
966
+ if (!this.authenticated || (this.currentUMPToken == null) || (this.rootPrivilegedKeyManager == null)) {
1002
967
  throw new Error('Not authenticated or missing required data.');
1003
968
  }
1004
- return this.getFactor('recoveryKey');
969
+ return await this.getFactor('recoveryKey');
1005
970
  }
1006
971
  /**
1007
972
  * Changes the user's recovery key. Prompts user to save the new key.
1008
973
  */
1009
974
  async changeRecoveryKey() {
1010
- if (!this.authenticated || !this.currentUMPToken || !this.rootPrimaryKey || !this.rootPrivilegedKeyManager) {
975
+ if (!this.authenticated || (this.currentUMPToken == null) || (this.rootPrimaryKey == null) || (this.rootPrivilegedKeyManager == null)) {
1011
976
  throw new Error('Not authenticated or missing required data.');
1012
977
  }
1013
978
  // Decrypt existing factors needed
@@ -1025,7 +990,7 @@ class CWIStyleWalletManager {
1025
990
  * Changes the user's presentation key.
1026
991
  */
1027
992
  async changePresentationKey(newPresentationKey) {
1028
- if (!this.authenticated || !this.currentUMPToken || !this.rootPrimaryKey || !this.rootPrivilegedKeyManager) {
993
+ if (!this.authenticated || (this.currentUMPToken == null) || (this.rootPrimaryKey == null) || (this.rootPrivilegedKeyManager == null)) {
1029
994
  throw new Error('Not authenticated or missing required data.');
1030
995
  }
1031
996
  if (newPresentationKey.length !== 32) {
@@ -1039,7 +1004,7 @@ class CWIStyleWalletManager {
1039
1004
  recoveryKey, this.rootPrimaryKey, rootPrivilegedKey, this.profiles // Preserve profiles
1040
1005
  );
1041
1006
  // Update the temporarily stored key if it was set
1042
- if (this.presentationKey) {
1007
+ if (this.presentationKey != null) {
1043
1008
  this.presentationKey = newPresentationKey;
1044
1009
  }
1045
1010
  }
@@ -1066,7 +1031,7 @@ class CWIStyleWalletManager {
1066
1031
  * @returns The decrypted key bytes.
1067
1032
  */
1068
1033
  async getFactor(factorName) {
1069
- if (!this.authenticated || !this.currentUMPToken || !this.rootPrivilegedKeyManager) {
1034
+ if (!this.authenticated || (this.currentUMPToken == null) || (this.rootPrivilegedKeyManager == null)) {
1070
1035
  throw new Error(`Cannot get factor "${factorName}": Wallet not ready.`);
1071
1036
  }
1072
1037
  const protocolID = [2, 'admin key wrapping']; // Protocol used for encrypting factors
@@ -1114,7 +1079,7 @@ class CWIStyleWalletManager {
1114
1079
  async updateAuthFactors(passwordSalt, passwordKey, presentationKey, recoveryKey, rootPrimaryKey, rootPrivilegedKey, // Explicitly pass the root key bytes
1115
1080
  profiles // Pass current/new profiles list
1116
1081
  ) {
1117
- if (!this.authenticated || !this.rootPrimaryKey || !this.currentUMPToken) {
1082
+ if (!this.authenticated || (this.rootPrimaryKey == null) || (this.currentUMPToken == null)) {
1118
1083
  throw new Error('Wallet is not properly authenticated or missing data for update.');
1119
1084
  }
1120
1085
  // Ensure we have the OLD token to consume
@@ -1131,7 +1096,7 @@ class CWIStyleWalletManager {
1131
1096
  const tempRootPrivilegedKeyManager = new PrivilegedKeyManager_1.PrivilegedKeyManager(async () => new sdk_1.PrivateKey(rootPrivilegedKey));
1132
1097
  // Encrypt profiles if provided
1133
1098
  let profilesEncrypted;
1134
- if (profiles && profiles.length > 0) {
1099
+ if ((profiles != null) && profiles.length > 0) {
1135
1100
  const profilesJson = JSON.stringify(profiles);
1136
1101
  const profilesBytes = sdk_1.Utils.toArray(profilesJson, 'utf8');
1137
1102
  profilesEncrypted = new sdk_1.SymmetricKey(rootPrimaryKey).encrypt(profilesBytes);
@@ -1166,12 +1131,12 @@ class CWIStyleWalletManager {
1166
1131
  keyID: '1'
1167
1132
  })).ciphertext,
1168
1133
  profilesEncrypted, // Add encrypted profiles
1169
- ...(kdfMetadata
1170
- ? {
1134
+ ...(kdfMetadata == null
1135
+ ? {}
1136
+ : {
1171
1137
  umpVersion: 3,
1172
1138
  passwordKdf: kdfMetadata
1173
- }
1174
- : {})
1139
+ })
1175
1140
  // currentOutpoint will be set after publishing
1176
1141
  };
1177
1142
  // We need the wallet built for the DEFAULT profile to publish the UMP token.
@@ -1183,7 +1148,7 @@ class CWIStyleWalletManager {
1183
1148
  await this.switchProfile(exports.DEFAULT_PROFILE_ID); // This rebuilds this.underlying
1184
1149
  walletToUse = this.underlying;
1185
1150
  }
1186
- if (!walletToUse) {
1151
+ if (walletToUse == null) {
1187
1152
  throw new Error('Default profile wallet could not be activated for UMP token update.');
1188
1153
  }
1189
1154
  // Publish the new token on-chain, consuming the old one
@@ -1230,7 +1195,7 @@ class CWIStyleWalletManager {
1230
1195
  writeArray(token.passwordKeyEncrypted); // 9
1231
1196
  writeArray(token.recoveryKeyEncrypted); // 10
1232
1197
  // Write optional profiles field
1233
- if (token.profilesEncrypted && token.profilesEncrypted.length > 0) {
1198
+ if ((token.profilesEncrypted != null) && token.profilesEncrypted.length > 0) {
1234
1199
  writer.writeUInt8(1); // Flag indicating profiles present
1235
1200
  writeArray(token.profilesEncrypted);
1236
1201
  }
@@ -1360,18 +1325,18 @@ class CWIStyleWalletManager {
1360
1325
  * @param ephemeralRootPrivilegedKey Optional root privileged key (e.g., during recovery flows).
1361
1326
  */
1362
1327
  async setupRootInfrastructure(rootPrimaryKey, ephemeralRootPrivilegedKey) {
1363
- if (!this.currentUMPToken) {
1328
+ if (this.currentUMPToken == null) {
1364
1329
  throw new Error('A UMP token must exist before setting up root infrastructure!');
1365
1330
  }
1366
1331
  this.rootPrimaryKey = rootPrimaryKey;
1367
1332
  // Store ephemeral key if provided, for one-time use by the manager
1368
- let oneTimePrivilegedKey = ephemeralRootPrivilegedKey
1369
- ? new sdk_1.PrivateKey(ephemeralRootPrivilegedKey)
1370
- : undefined;
1333
+ let oneTimePrivilegedKey = (ephemeralRootPrivilegedKey == null)
1334
+ ? undefined
1335
+ : new sdk_1.PrivateKey(ephemeralRootPrivilegedKey);
1371
1336
  // Create the ROOT PrivilegedKeyManager
1372
1337
  this.rootPrivilegedKeyManager = new PrivilegedKeyManager_1.PrivilegedKeyManager(async (reason) => {
1373
1338
  // 1. Use one-time key if available (for recovery)
1374
- if (oneTimePrivilegedKey) {
1339
+ if (oneTimePrivilegedKey != null) {
1375
1340
  const tempKey = oneTimePrivilegedKey;
1376
1341
  oneTimePrivilegedKey = undefined; // Consume it
1377
1342
  return tempKey;
@@ -1384,7 +1349,10 @@ class CWIStyleWalletManager {
1384
1349
  const decryptedPrivileged = new sdk_1.SymmetricKey(privilegedDecryptor).decrypt(this.currentUMPToken.passwordPrimaryPrivileged);
1385
1350
  return !!decryptedPrivileged; // Test passes if decryption works
1386
1351
  }
1387
- catch (e) {
1352
+ catch (_intentionallyIgnored) {
1353
+ // Decryption failure means the password candidate is wrong — this is the
1354
+ // expected rejection path for an incorrect password. Returning false causes
1355
+ // the password-retriever loop to prompt the user again rather than crashing.
1388
1356
  return false;
1389
1357
  }
1390
1358
  });
@@ -1396,7 +1364,7 @@ class CWIStyleWalletManager {
1396
1364
  });
1397
1365
  // Decrypt and load profiles if present in the token
1398
1366
  this.profiles = []; // Clear existing profiles before loading
1399
- if (this.currentUMPToken.profilesEncrypted && this.currentUMPToken.profilesEncrypted.length > 0) {
1367
+ if ((this.currentUMPToken.profilesEncrypted != null) && this.currentUMPToken.profilesEncrypted.length > 0) {
1400
1368
  try {
1401
1369
  const decryptedProfileBytes = new sdk_1.SymmetricKey(rootPrimaryKey).decrypt(this.currentUMPToken.profilesEncrypted);
1402
1370
  const profilesJson = sdk_1.Utils.toUTF8(decryptedProfileBytes);
@@ -1424,7 +1392,7 @@ class CWIStyleWalletManager {
1424
1392
  if (!this.authenticated) {
1425
1393
  throw new Error('User is not authenticated.');
1426
1394
  }
1427
- if (!this.underlying) {
1395
+ if (this.underlying == null) {
1428
1396
  // This might happen if authentication succeeded but profile switching failed
1429
1397
  throw new Error('Underlying wallet for the active profile is not initialized.');
1430
1398
  }
@@ -1435,91 +1403,91 @@ class CWIStyleWalletManager {
1435
1403
  // Example proxy method (repeat pattern for all others)
1436
1404
  async getPublicKey(args, originator) {
1437
1405
  this.checkAuthAndUnderlying(originator);
1438
- return this.underlying.getPublicKey(args, originator);
1406
+ return await this.underlying.getPublicKey(args, originator);
1439
1407
  }
1440
1408
  async revealCounterpartyKeyLinkage(args, originator) {
1441
1409
  this.checkAuthAndUnderlying(originator);
1442
- return this.underlying.revealCounterpartyKeyLinkage(args, originator);
1410
+ return await this.underlying.revealCounterpartyKeyLinkage(args, originator);
1443
1411
  }
1444
1412
  async revealSpecificKeyLinkage(args, originator) {
1445
1413
  this.checkAuthAndUnderlying(originator);
1446
- return this.underlying.revealSpecificKeyLinkage(args, originator);
1414
+ return await this.underlying.revealSpecificKeyLinkage(args, originator);
1447
1415
  }
1448
1416
  async encrypt(args, originator) {
1449
1417
  this.checkAuthAndUnderlying(originator);
1450
- return this.underlying.encrypt(args, originator);
1418
+ return await this.underlying.encrypt(args, originator);
1451
1419
  }
1452
1420
  async decrypt(args, originator) {
1453
1421
  this.checkAuthAndUnderlying(originator);
1454
- return this.underlying.decrypt(args, originator);
1422
+ return await this.underlying.decrypt(args, originator);
1455
1423
  }
1456
1424
  async createHmac(args, originator) {
1457
1425
  this.checkAuthAndUnderlying(originator);
1458
- return this.underlying.createHmac(args, originator);
1426
+ return await this.underlying.createHmac(args, originator);
1459
1427
  }
1460
1428
  async verifyHmac(args, originator) {
1461
1429
  this.checkAuthAndUnderlying(originator);
1462
- return this.underlying.verifyHmac(args, originator);
1430
+ return await this.underlying.verifyHmac(args, originator);
1463
1431
  }
1464
1432
  async createSignature(args, originator) {
1465
1433
  this.checkAuthAndUnderlying(originator);
1466
- return this.underlying.createSignature(args, originator);
1434
+ return await this.underlying.createSignature(args, originator);
1467
1435
  }
1468
1436
  async verifySignature(args, originator) {
1469
1437
  this.checkAuthAndUnderlying(originator);
1470
- return this.underlying.verifySignature(args, originator);
1438
+ return await this.underlying.verifySignature(args, originator);
1471
1439
  }
1472
1440
  async createAction(args, originator) {
1473
1441
  this.checkAuthAndUnderlying(originator);
1474
- return this.underlying.createAction(args, originator);
1442
+ return await this.underlying.createAction(args, originator);
1475
1443
  }
1476
1444
  async signAction(args, originator) {
1477
1445
  this.checkAuthAndUnderlying(originator);
1478
- return this.underlying.signAction(args, originator);
1446
+ return await this.underlying.signAction(args, originator);
1479
1447
  }
1480
1448
  async abortAction(args, originator) {
1481
1449
  this.checkAuthAndUnderlying(originator);
1482
- return this.underlying.abortAction(args, originator);
1450
+ return await this.underlying.abortAction(args, originator);
1483
1451
  }
1484
1452
  async listActions(args, originator) {
1485
1453
  this.checkAuthAndUnderlying(originator);
1486
- return this.underlying.listActions(args, originator);
1454
+ return await this.underlying.listActions(args, originator);
1487
1455
  }
1488
1456
  async internalizeAction(args, originator) {
1489
1457
  this.checkAuthAndUnderlying(originator);
1490
- return this.underlying.internalizeAction(args, originator);
1458
+ return await this.underlying.internalizeAction(args, originator);
1491
1459
  }
1492
1460
  async listOutputs(args, originator) {
1493
1461
  this.checkAuthAndUnderlying(originator);
1494
- return this.underlying.listOutputs(args, originator);
1462
+ return await this.underlying.listOutputs(args, originator);
1495
1463
  }
1496
1464
  async relinquishOutput(args, originator) {
1497
1465
  this.checkAuthAndUnderlying(originator);
1498
- return this.underlying.relinquishOutput(args, originator);
1466
+ return await this.underlying.relinquishOutput(args, originator);
1499
1467
  }
1500
1468
  async acquireCertificate(args, originator) {
1501
1469
  this.checkAuthAndUnderlying(originator);
1502
- return this.underlying.acquireCertificate(args, originator);
1470
+ return await this.underlying.acquireCertificate(args, originator);
1503
1471
  }
1504
1472
  async listCertificates(args, originator) {
1505
1473
  this.checkAuthAndUnderlying(originator);
1506
- return this.underlying.listCertificates(args, originator);
1474
+ return await this.underlying.listCertificates(args, originator);
1507
1475
  }
1508
1476
  async proveCertificate(args, originator) {
1509
1477
  this.checkAuthAndUnderlying(originator);
1510
- return this.underlying.proveCertificate(args, originator);
1478
+ return await this.underlying.proveCertificate(args, originator);
1511
1479
  }
1512
1480
  async relinquishCertificate(args, originator) {
1513
1481
  this.checkAuthAndUnderlying(originator);
1514
- return this.underlying.relinquishCertificate(args, originator);
1482
+ return await this.underlying.relinquishCertificate(args, originator);
1515
1483
  }
1516
1484
  async discoverByIdentityKey(args, originator) {
1517
1485
  this.checkAuthAndUnderlying(originator);
1518
- return this.underlying.discoverByIdentityKey(args, originator);
1486
+ return await this.underlying.discoverByIdentityKey(args, originator);
1519
1487
  }
1520
1488
  async discoverByAttributes(args, originator) {
1521
1489
  this.checkAuthAndUnderlying(originator);
1522
- return this.underlying.discoverByAttributes(args, originator);
1490
+ return await this.underlying.discoverByAttributes(args, originator);
1523
1491
  }
1524
1492
  async isAuthenticated(_, originator) {
1525
1493
  if (!this.authenticated) {
@@ -1534,26 +1502,26 @@ class CWIStyleWalletManager {
1534
1502
  if (originator === this.adminOriginator) {
1535
1503
  throw new Error('External applications are not allowed to use the admin originator.');
1536
1504
  }
1537
- while (!this.authenticated || !this.underlying) {
1505
+ while (!this.authenticated || (this.underlying == null)) {
1538
1506
  await new Promise(resolve => setTimeout(resolve, 100));
1539
1507
  }
1540
1508
  return await this.underlying.waitForAuthentication({}, originator);
1541
1509
  }
1542
1510
  async getHeight(_, originator) {
1543
1511
  this.checkAuthAndUnderlying(originator);
1544
- return this.underlying.getHeight({}, originator);
1512
+ return await this.underlying.getHeight({}, originator);
1545
1513
  }
1546
1514
  async getHeaderForHeight(args, originator) {
1547
1515
  this.checkAuthAndUnderlying(originator);
1548
- return this.underlying.getHeaderForHeight(args, originator);
1516
+ return await this.underlying.getHeaderForHeight(args, originator);
1549
1517
  }
1550
1518
  async getNetwork(_, originator) {
1551
1519
  this.checkAuthAndUnderlying(originator);
1552
- return this.underlying.getNetwork({}, originator);
1520
+ return await this.underlying.getNetwork({}, originator);
1553
1521
  }
1554
1522
  async getVersion(_, originator) {
1555
1523
  this.checkAuthAndUnderlying(originator);
1556
- return this.underlying.getVersion({}, originator);
1524
+ return await this.underlying.getVersion({}, originator);
1557
1525
  }
1558
1526
  }
1559
1527
  exports.CWIStyleWalletManager = CWIStyleWalletManager;