@bsv/wallet-toolbox-client 2.4.4 → 2.4.20

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 (837) hide show
  1. package/LICENSE.txt +58 -0
  2. package/README.md +43 -22
  3. package/out/index.client.cjs +33583 -0
  4. package/out/index.client.cjs.map +1 -0
  5. package/out/index.client.d.cts +10768 -0
  6. package/out/index.client.d.cts.map +1 -0
  7. package/out/index.client.d.mts +10767 -0
  8. package/out/index.client.d.mts.map +1 -0
  9. package/out/index.client.mjs +33377 -0
  10. package/out/index.client.mjs.map +1 -0
  11. package/out/rolldown-runtime-D7D4PA-g.mjs +13 -0
  12. package/package.json +56 -9
  13. package/out/src/CWIStyleWalletManager.d.ts +0 -564
  14. package/out/src/CWIStyleWalletManager.d.ts.map +0 -1
  15. package/out/src/CWIStyleWalletManager.js +0 -1966
  16. package/out/src/CWIStyleWalletManager.js.map +0 -1
  17. package/out/src/SetupClient.d.ts +0 -135
  18. package/out/src/SetupClient.d.ts.map +0 -1
  19. package/out/src/SetupClient.js +0 -226
  20. package/out/src/SetupClient.js.map +0 -1
  21. package/out/src/SetupWallet.d.ts +0 -103
  22. package/out/src/SetupWallet.d.ts.map +0 -1
  23. package/out/src/SetupWallet.js +0 -3
  24. package/out/src/SetupWallet.js.map +0 -1
  25. package/out/src/SimpleWalletManager.d.ts +0 -179
  26. package/out/src/SimpleWalletManager.d.ts.map +0 -1
  27. package/out/src/SimpleWalletManager.js +0 -360
  28. package/out/src/SimpleWalletManager.js.map +0 -1
  29. package/out/src/Wallet.d.ts +0 -262
  30. package/out/src/Wallet.d.ts.map +0 -1
  31. package/out/src/Wallet.js +0 -923
  32. package/out/src/Wallet.js.map +0 -1
  33. package/out/src/WalletAuthenticationManager.d.ts +0 -47
  34. package/out/src/WalletAuthenticationManager.d.ts.map +0 -1
  35. package/out/src/WalletAuthenticationManager.js +0 -306
  36. package/out/src/WalletAuthenticationManager.js.map +0 -1
  37. package/out/src/WalletLogger.d.ts +0 -65
  38. package/out/src/WalletLogger.d.ts.map +0 -1
  39. package/out/src/WalletLogger.js +0 -177
  40. package/out/src/WalletLogger.js.map +0 -1
  41. package/out/src/WalletPermissionsManager.d.ts +0 -981
  42. package/out/src/WalletPermissionsManager.d.ts.map +0 -1
  43. package/out/src/WalletPermissionsManager.js +0 -3744
  44. package/out/src/WalletPermissionsManager.js.map +0 -1
  45. package/out/src/WalletSettingsManager.d.ts +0 -53
  46. package/out/src/WalletSettingsManager.d.ts.map +0 -1
  47. package/out/src/WalletSettingsManager.js +0 -86
  48. package/out/src/WalletSettingsManager.js.map +0 -1
  49. package/out/src/fundWalletP2PKH.d.ts +0 -48
  50. package/out/src/fundWalletP2PKH.d.ts.map +0 -1
  51. package/out/src/fundWalletP2PKH.js +0 -239
  52. package/out/src/fundWalletP2PKH.js.map +0 -1
  53. package/out/src/index.client.d.ts +0 -25
  54. package/out/src/index.client.d.ts.map +0 -1
  55. package/out/src/index.client.js +0 -64
  56. package/out/src/index.client.js.map +0 -1
  57. package/out/src/mockchain/MockChainMigrations.d.ts +0 -20
  58. package/out/src/mockchain/MockChainMigrations.d.ts.map +0 -1
  59. package/out/src/mockchain/MockChainMigrations.js +0 -67
  60. package/out/src/mockchain/MockChainMigrations.js.map +0 -1
  61. package/out/src/mockchain/MockChainStorage.d.ts +0 -58
  62. package/out/src/mockchain/MockChainStorage.d.ts.map +0 -1
  63. package/out/src/mockchain/MockChainStorage.js +0 -102
  64. package/out/src/mockchain/MockChainStorage.js.map +0 -1
  65. package/out/src/mockchain/MockChainTracker.d.ts +0 -28
  66. package/out/src/mockchain/MockChainTracker.d.ts.map +0 -1
  67. package/out/src/mockchain/MockChainTracker.js +0 -97
  68. package/out/src/mockchain/MockChainTracker.js.map +0 -1
  69. package/out/src/mockchain/MockMiner.d.ts +0 -16
  70. package/out/src/mockchain/MockMiner.d.ts.map +0 -1
  71. package/out/src/mockchain/MockMiner.js +0 -137
  72. package/out/src/mockchain/MockMiner.js.map +0 -1
  73. package/out/src/mockchain/MockServices.d.ts +0 -53
  74. package/out/src/mockchain/MockServices.d.ts.map +0 -1
  75. package/out/src/mockchain/MockServices.js +0 -459
  76. package/out/src/mockchain/MockServices.js.map +0 -1
  77. package/out/src/mockchain/merkleTree.d.ts +0 -13
  78. package/out/src/mockchain/merkleTree.d.ts.map +0 -1
  79. package/out/src/mockchain/merkleTree.js +0 -122
  80. package/out/src/mockchain/merkleTree.js.map +0 -1
  81. package/out/src/monitor/Monitor.d.ts +0 -189
  82. package/out/src/monitor/Monitor.d.ts.map +0 -1
  83. package/out/src/monitor/Monitor.js +0 -387
  84. package/out/src/monitor/Monitor.js.map +0 -1
  85. package/out/src/monitor/tasks/TaskArcSSE.d.ts +0 -29
  86. package/out/src/monitor/tasks/TaskArcSSE.d.ts.map +0 -1
  87. package/out/src/monitor/tasks/TaskArcSSE.js +0 -259
  88. package/out/src/monitor/tasks/TaskArcSSE.js.map +0 -1
  89. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts +0 -53
  90. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +0 -1
  91. package/out/src/monitor/tasks/TaskCheckForProofs.js +0 -224
  92. package/out/src/monitor/tasks/TaskCheckForProofs.js.map +0 -1
  93. package/out/src/monitor/tasks/TaskCheckNoSends.d.ts +0 -91
  94. package/out/src/monitor/tasks/TaskCheckNoSends.d.ts.map +0 -1
  95. package/out/src/monitor/tasks/TaskCheckNoSends.js +0 -159
  96. package/out/src/monitor/tasks/TaskCheckNoSends.js.map +0 -1
  97. package/out/src/monitor/tasks/TaskCleanupActionBatches.d.ts +0 -13
  98. package/out/src/monitor/tasks/TaskCleanupActionBatches.d.ts.map +0 -1
  99. package/out/src/monitor/tasks/TaskCleanupActionBatches.js +0 -24
  100. package/out/src/monitor/tasks/TaskCleanupActionBatches.js.map +0 -1
  101. package/out/src/monitor/tasks/TaskClock.d.ts +0 -14
  102. package/out/src/monitor/tasks/TaskClock.d.ts.map +0 -1
  103. package/out/src/monitor/tasks/TaskClock.js +0 -29
  104. package/out/src/monitor/tasks/TaskClock.js.map +0 -1
  105. package/out/src/monitor/tasks/TaskFailAbandoned.d.ts +0 -20
  106. package/out/src/monitor/tasks/TaskFailAbandoned.d.ts.map +0 -1
  107. package/out/src/monitor/tasks/TaskFailAbandoned.js +0 -53
  108. package/out/src/monitor/tasks/TaskFailAbandoned.js.map +0 -1
  109. package/out/src/monitor/tasks/TaskMineBlock.d.ts +0 -13
  110. package/out/src/monitor/tasks/TaskMineBlock.d.ts.map +0 -1
  111. package/out/src/monitor/tasks/TaskMineBlock.js +0 -30
  112. package/out/src/monitor/tasks/TaskMineBlock.js.map +0 -1
  113. package/out/src/monitor/tasks/TaskMonitorCallHistory.d.ts +0 -12
  114. package/out/src/monitor/tasks/TaskMonitorCallHistory.d.ts.map +0 -1
  115. package/out/src/monitor/tasks/TaskMonitorCallHistory.js +0 -25
  116. package/out/src/monitor/tasks/TaskMonitorCallHistory.js.map +0 -1
  117. package/out/src/monitor/tasks/TaskNewHeader.d.ts +0 -50
  118. package/out/src/monitor/tasks/TaskNewHeader.d.ts.map +0 -1
  119. package/out/src/monitor/tasks/TaskNewHeader.js +0 -97
  120. package/out/src/monitor/tasks/TaskNewHeader.js.map +0 -1
  121. package/out/src/monitor/tasks/TaskPurge.d.ts +0 -45
  122. package/out/src/monitor/tasks/TaskPurge.d.ts.map +0 -1
  123. package/out/src/monitor/tasks/TaskPurge.js +0 -36
  124. package/out/src/monitor/tasks/TaskPurge.js.map +0 -1
  125. package/out/src/monitor/tasks/TaskReorg.d.ts +0 -43
  126. package/out/src/monitor/tasks/TaskReorg.d.ts.map +0 -1
  127. package/out/src/monitor/tasks/TaskReorg.js +0 -84
  128. package/out/src/monitor/tasks/TaskReorg.js.map +0 -1
  129. package/out/src/monitor/tasks/TaskReviewDoubleSpends.d.ts +0 -26
  130. package/out/src/monitor/tasks/TaskReviewDoubleSpends.d.ts.map +0 -1
  131. package/out/src/monitor/tasks/TaskReviewDoubleSpends.js +0 -127
  132. package/out/src/monitor/tasks/TaskReviewDoubleSpends.js.map +0 -1
  133. package/out/src/monitor/tasks/TaskReviewProvenTxs.d.ts +0 -34
  134. package/out/src/monitor/tasks/TaskReviewProvenTxs.d.ts.map +0 -1
  135. package/out/src/monitor/tasks/TaskReviewProvenTxs.js +0 -136
  136. package/out/src/monitor/tasks/TaskReviewProvenTxs.js.map +0 -1
  137. package/out/src/monitor/tasks/TaskReviewStatus.d.ts +0 -26
  138. package/out/src/monitor/tasks/TaskReviewStatus.d.ts.map +0 -1
  139. package/out/src/monitor/tasks/TaskReviewStatus.js +0 -50
  140. package/out/src/monitor/tasks/TaskReviewStatus.js.map +0 -1
  141. package/out/src/monitor/tasks/TaskReviewUtxos.d.ts +0 -23
  142. package/out/src/monitor/tasks/TaskReviewUtxos.d.ts.map +0 -1
  143. package/out/src/monitor/tasks/TaskReviewUtxos.js +0 -75
  144. package/out/src/monitor/tasks/TaskReviewUtxos.js.map +0 -1
  145. package/out/src/monitor/tasks/TaskSendWaiting.d.ts +0 -48
  146. package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +0 -1
  147. package/out/src/monitor/tasks/TaskSendWaiting.js +0 -202
  148. package/out/src/monitor/tasks/TaskSendWaiting.js.map +0 -1
  149. package/out/src/monitor/tasks/TaskUnFail.d.ts +0 -41
  150. package/out/src/monitor/tasks/TaskUnFail.d.ts.map +0 -1
  151. package/out/src/monitor/tasks/TaskUnFail.js +0 -89
  152. package/out/src/monitor/tasks/TaskUnFail.js.map +0 -1
  153. package/out/src/monitor/tasks/WalletMonitorTask.d.ts +0 -40
  154. package/out/src/monitor/tasks/WalletMonitorTask.d.ts.map +0 -1
  155. package/out/src/monitor/tasks/WalletMonitorTask.js +0 -42
  156. package/out/src/monitor/tasks/WalletMonitorTask.js.map +0 -1
  157. package/out/src/sdk/ActionBatch.interfaces.d.ts +0 -105
  158. package/out/src/sdk/ActionBatch.interfaces.d.ts.map +0 -1
  159. package/out/src/sdk/ActionBatch.interfaces.js +0 -3
  160. package/out/src/sdk/ActionBatch.interfaces.js.map +0 -1
  161. package/out/src/sdk/CertOpsWallet.d.ts +0 -7
  162. package/out/src/sdk/CertOpsWallet.d.ts.map +0 -1
  163. package/out/src/sdk/CertOpsWallet.js +0 -3
  164. package/out/src/sdk/CertOpsWallet.js.map +0 -1
  165. package/out/src/sdk/PrivilegedKeyManager.d.ts +0 -125
  166. package/out/src/sdk/PrivilegedKeyManager.d.ts.map +0 -1
  167. package/out/src/sdk/PrivilegedKeyManager.js +0 -320
  168. package/out/src/sdk/PrivilegedKeyManager.js.map +0 -1
  169. package/out/src/sdk/WERR_errors.d.ts +0 -136
  170. package/out/src/sdk/WERR_errors.d.ts.map +0 -1
  171. package/out/src/sdk/WERR_errors.js +0 -233
  172. package/out/src/sdk/WERR_errors.js.map +0 -1
  173. package/out/src/sdk/WalletError.d.ts +0 -63
  174. package/out/src/sdk/WalletError.d.ts.map +0 -1
  175. package/out/src/sdk/WalletError.js +0 -177
  176. package/out/src/sdk/WalletError.js.map +0 -1
  177. package/out/src/sdk/WalletErrorFromJson.d.ts +0 -12
  178. package/out/src/sdk/WalletErrorFromJson.d.ts.map +0 -1
  179. package/out/src/sdk/WalletErrorFromJson.js +0 -67
  180. package/out/src/sdk/WalletErrorFromJson.js.map +0 -1
  181. package/out/src/sdk/WalletServices.interfaces.d.ts +0 -643
  182. package/out/src/sdk/WalletServices.interfaces.d.ts.map +0 -1
  183. package/out/src/sdk/WalletServices.interfaces.js +0 -3
  184. package/out/src/sdk/WalletServices.interfaces.js.map +0 -1
  185. package/out/src/sdk/WalletSigner.interfaces.d.ts +0 -10
  186. package/out/src/sdk/WalletSigner.interfaces.d.ts.map +0 -1
  187. package/out/src/sdk/WalletSigner.interfaces.js +0 -3
  188. package/out/src/sdk/WalletSigner.interfaces.js.map +0 -1
  189. package/out/src/sdk/WalletStorage.interfaces.d.ts +0 -556
  190. package/out/src/sdk/WalletStorage.interfaces.d.ts.map +0 -1
  191. package/out/src/sdk/WalletStorage.interfaces.js +0 -3
  192. package/out/src/sdk/WalletStorage.interfaces.js.map +0 -1
  193. package/out/src/sdk/index.d.ts +0 -12
  194. package/out/src/sdk/index.d.ts.map +0 -1
  195. package/out/src/sdk/index.js +0 -30
  196. package/out/src/sdk/index.js.map +0 -1
  197. package/out/src/sdk/types.d.ts +0 -178
  198. package/out/src/sdk/types.d.ts.map +0 -1
  199. package/out/src/sdk/types.js +0 -104
  200. package/out/src/sdk/types.js.map +0 -1
  201. package/out/src/services/ServiceCollection.d.ts +0 -79
  202. package/out/src/services/ServiceCollection.d.ts.map +0 -1
  203. package/out/src/services/ServiceCollection.js +0 -197
  204. package/out/src/services/ServiceCollection.js.map +0 -1
  205. package/out/src/services/Services.d.ts +0 -97
  206. package/out/src/services/Services.d.ts.map +0 -1
  207. package/out/src/services/Services.js +0 -729
  208. package/out/src/services/Services.js.map +0 -1
  209. package/out/src/services/chaintracker/BHServiceClient.d.ts +0 -39
  210. package/out/src/services/chaintracker/BHServiceClient.d.ts.map +0 -1
  211. package/out/src/services/chaintracker/BHServiceClient.js +0 -180
  212. package/out/src/services/chaintracker/BHServiceClient.js.map +0 -1
  213. package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts +0 -16
  214. package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts.map +0 -1
  215. package/out/src/services/chaintracker/ChaintracksChainTracker.js +0 -59
  216. package/out/src/services/chaintracker/ChaintracksChainTracker.js.map +0 -1
  217. package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.d.ts +0 -57
  218. package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.d.ts.map +0 -1
  219. package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.js +0 -38
  220. package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.js.map +0 -1
  221. package/out/src/services/chaintracker/chaintracks/Api/BulkIngestorApi.d.ts +0 -70
  222. package/out/src/services/chaintracker/chaintracks/Api/BulkIngestorApi.d.ts.map +0 -1
  223. package/out/src/services/chaintracker/chaintracks/Api/BulkIngestorApi.js +0 -3
  224. package/out/src/services/chaintracker/chaintracks/Api/BulkIngestorApi.js.map +0 -1
  225. package/out/src/services/chaintracker/chaintracks/Api/BulkStorageApi.d.ts +0 -81
  226. package/out/src/services/chaintracker/chaintracks/Api/BulkStorageApi.d.ts.map +0 -1
  227. package/out/src/services/chaintracker/chaintracks/Api/BulkStorageApi.js +0 -3
  228. package/out/src/services/chaintracker/chaintracks/Api/BulkStorageApi.js.map +0 -1
  229. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksApi.d.ts +0 -54
  230. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksApi.d.ts.map +0 -1
  231. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksApi.js +0 -3
  232. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksApi.js.map +0 -1
  233. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksClientApi.d.ts +0 -163
  234. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksClientApi.d.ts.map +0 -1
  235. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksClientApi.js +0 -3
  236. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksClientApi.js.map +0 -1
  237. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFetchApi.d.ts +0 -18
  238. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFetchApi.d.ts.map +0 -1
  239. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFetchApi.js +0 -3
  240. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFetchApi.js.map +0 -1
  241. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFsApi.d.ts +0 -55
  242. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFsApi.d.ts.map +0 -1
  243. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFsApi.js +0 -3
  244. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFsApi.js.map +0 -1
  245. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksStorageApi.d.ts +0 -338
  246. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksStorageApi.d.ts.map +0 -1
  247. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksStorageApi.js +0 -3
  248. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksStorageApi.js.map +0 -1
  249. package/out/src/services/chaintracker/chaintracks/Api/LiveIngestorApi.d.ts +0 -19
  250. package/out/src/services/chaintracker/chaintracks/Api/LiveIngestorApi.d.ts.map +0 -1
  251. package/out/src/services/chaintracker/chaintracks/Api/LiveIngestorApi.js +0 -3
  252. package/out/src/services/chaintracker/chaintracks/Api/LiveIngestorApi.js.map +0 -1
  253. package/out/src/services/chaintracker/chaintracks/Chaintracks.d.ts +0 -113
  254. package/out/src/services/chaintracker/chaintracks/Chaintracks.d.ts.map +0 -1
  255. package/out/src/services/chaintracker/chaintracks/Chaintracks.js +0 -607
  256. package/out/src/services/chaintracker/chaintracks/Chaintracks.js.map +0 -1
  257. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts +0 -38
  258. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts.map +0 -1
  259. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js +0 -149
  260. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js.map +0 -1
  261. package/out/src/services/chaintracker/chaintracks/GoChaintracksServiceClient.d.ts +0 -52
  262. package/out/src/services/chaintracker/chaintracks/GoChaintracksServiceClient.d.ts.map +0 -1
  263. package/out/src/services/chaintracker/chaintracks/GoChaintracksServiceClient.js +0 -232
  264. package/out/src/services/chaintracker/chaintracks/GoChaintracksServiceClient.js.map +0 -1
  265. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.d.ts +0 -60
  266. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.d.ts.map +0 -1
  267. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.js +0 -126
  268. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.js.map +0 -1
  269. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.d.ts +0 -75
  270. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.d.ts.map +0 -1
  271. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.js +0 -121
  272. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.js.map +0 -1
  273. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.d.ts +0 -13
  274. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.d.ts.map +0 -1
  275. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.js +0 -20
  276. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.js.map +0 -1
  277. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.d.ts +0 -62
  278. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.d.ts.map +0 -1
  279. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.js +0 -61
  280. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.js.map +0 -1
  281. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.d.ts +0 -62
  282. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.d.ts.map +0 -1
  283. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.js +0 -44
  284. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.js.map +0 -1
  285. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorChaintracksSSE.d.ts +0 -24
  286. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorChaintracksSSE.d.ts.map +0 -1
  287. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorChaintracksSSE.js +0 -55
  288. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorChaintracksSSE.js.map +0 -1
  289. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.d.ts +0 -64
  290. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.d.ts.map +0 -1
  291. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js +0 -95
  292. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js.map +0 -1
  293. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.d.ts +0 -171
  294. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.d.ts.map +0 -1
  295. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.js +0 -487
  296. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.js.map +0 -1
  297. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.d.ts +0 -89
  298. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.d.ts.map +0 -1
  299. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.js +0 -142
  300. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.js.map +0 -1
  301. package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.d.ts +0 -23
  302. package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.d.ts.map +0 -1
  303. package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.js +0 -63
  304. package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.js.map +0 -1
  305. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.d.ts +0 -68
  306. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.d.ts.map +0 -1
  307. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js +0 -311
  308. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js.map +0 -1
  309. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.d.ts +0 -92
  310. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.d.ts.map +0 -1
  311. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.js +0 -467
  312. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.js.map +0 -1
  313. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.d.ts +0 -37
  314. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.d.ts.map +0 -1
  315. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.js +0 -261
  316. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.js.map +0 -1
  317. package/out/src/services/chaintracker/chaintracks/configureChaintracksIngestors.d.ts +0 -22
  318. package/out/src/services/chaintracker/chaintracks/configureChaintracksIngestors.d.ts.map +0 -1
  319. package/out/src/services/chaintracker/chaintracks/configureChaintracksIngestors.js +0 -54
  320. package/out/src/services/chaintracker/chaintracks/configureChaintracksIngestors.js.map +0 -1
  321. package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.d.ts +0 -5
  322. package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.d.ts.map +0 -1
  323. package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.js +0 -29
  324. package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.js.map +0 -1
  325. package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.d.ts +0 -5
  326. package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.d.ts.map +0 -1
  327. package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.js +0 -29
  328. package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.js.map +0 -1
  329. package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.d.ts +0 -13
  330. package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.d.ts.map +0 -1
  331. package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.js +0 -27
  332. package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.js.map +0 -1
  333. package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.d.ts +0 -13
  334. package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.d.ts.map +0 -1
  335. package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.js +0 -27
  336. package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.js.map +0 -1
  337. package/out/src/services/chaintracker/chaintracks/index.client.d.ts +0 -4
  338. package/out/src/services/chaintracker/chaintracks/index.client.d.ts.map +0 -1
  339. package/out/src/services/chaintracker/chaintracks/index.client.js +0 -20
  340. package/out/src/services/chaintracker/chaintracks/index.client.js.map +0 -1
  341. package/out/src/services/chaintracker/chaintracks/index.mobile.d.ts +0 -32
  342. package/out/src/services/chaintracker/chaintracks/index.mobile.d.ts.map +0 -1
  343. package/out/src/services/chaintracker/chaintracks/index.mobile.js +0 -70
  344. package/out/src/services/chaintracker/chaintracks/index.mobile.js.map +0 -1
  345. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.d.ts +0 -142
  346. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.d.ts.map +0 -1
  347. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js +0 -821
  348. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js.map +0 -1
  349. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataReader.d.ts +0 -22
  350. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataReader.d.ts.map +0 -1
  351. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataReader.js +0 -65
  352. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataReader.js.map +0 -1
  353. package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.d.ts +0 -78
  354. package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.d.ts.map +0 -1
  355. package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js +0 -284
  356. package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js.map +0 -1
  357. package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.d.ts +0 -129
  358. package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.d.ts.map +0 -1
  359. package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.js +0 -168
  360. package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.js.map +0 -1
  361. package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.d.ts +0 -21
  362. package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.d.ts.map +0 -1
  363. package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.js +0 -108
  364. package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.js.map +0 -1
  365. package/out/src/services/chaintracker/chaintracks/util/HeightRange.d.ts +0 -90
  366. package/out/src/services/chaintracker/chaintracks/util/HeightRange.d.ts.map +0 -1
  367. package/out/src/services/chaintracker/chaintracks/util/HeightRange.js +0 -150
  368. package/out/src/services/chaintracker/chaintracks/util/HeightRange.js.map +0 -1
  369. package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts +0 -14
  370. package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts.map +0 -1
  371. package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.js +0 -86
  372. package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.js.map +0 -1
  373. package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts +0 -159
  374. package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts.map +0 -1
  375. package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js +0 -530
  376. package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js.map +0 -1
  377. package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.d.ts +0 -20
  378. package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.d.ts.map +0 -1
  379. package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.js +0 -31
  380. package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.js.map +0 -1
  381. package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.d.ts +0 -37
  382. package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.d.ts.map +0 -1
  383. package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.js +0 -429
  384. package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.js.map +0 -1
  385. package/out/src/services/chaintracker/index.client.d.ts +0 -4
  386. package/out/src/services/chaintracker/index.client.d.ts.map +0 -1
  387. package/out/src/services/chaintracker/index.client.js +0 -20
  388. package/out/src/services/chaintracker/index.client.js.map +0 -1
  389. package/out/src/services/createDefaultWalletServicesOptions.d.ts +0 -25
  390. package/out/src/services/createDefaultWalletServicesOptions.d.ts.map +0 -1
  391. package/out/src/services/createDefaultWalletServicesOptions.js +0 -143
  392. package/out/src/services/createDefaultWalletServicesOptions.js.map +0 -1
  393. package/out/src/services/networkConfig.d.ts +0 -29
  394. package/out/src/services/networkConfig.d.ts.map +0 -1
  395. package/out/src/services/networkConfig.js +0 -54
  396. package/out/src/services/networkConfig.js.map +0 -1
  397. package/out/src/services/providers/ARC.d.ts +0 -96
  398. package/out/src/services/providers/ARC.d.ts.map +0 -1
  399. package/out/src/services/providers/ARC.js +0 -332
  400. package/out/src/services/providers/ARC.js.map +0 -1
  401. package/out/src/services/providers/ArcSSEClient.d.ts +0 -58
  402. package/out/src/services/providers/ArcSSEClient.d.ts.map +0 -1
  403. package/out/src/services/providers/ArcSSEClient.js +0 -115
  404. package/out/src/services/providers/ArcSSEClient.js.map +0 -1
  405. package/out/src/services/providers/Arcade.d.ts +0 -73
  406. package/out/src/services/providers/Arcade.d.ts.map +0 -1
  407. package/out/src/services/providers/Arcade.js +0 -330
  408. package/out/src/services/providers/Arcade.js.map +0 -1
  409. package/out/src/services/providers/Bitails.d.ts +0 -50
  410. package/out/src/services/providers/Bitails.d.ts.map +0 -1
  411. package/out/src/services/providers/Bitails.js +0 -237
  412. package/out/src/services/providers/Bitails.js.map +0 -1
  413. package/out/src/services/providers/SdkWhatsOnChain.d.ts +0 -21
  414. package/out/src/services/providers/SdkWhatsOnChain.d.ts.map +0 -1
  415. package/out/src/services/providers/SdkWhatsOnChain.js +0 -82
  416. package/out/src/services/providers/SdkWhatsOnChain.js.map +0 -1
  417. package/out/src/services/providers/WhatsOnChain.d.ts +0 -132
  418. package/out/src/services/providers/WhatsOnChain.d.ts.map +0 -1
  419. package/out/src/services/providers/WhatsOnChain.js +0 -558
  420. package/out/src/services/providers/WhatsOnChain.js.map +0 -1
  421. package/out/src/services/providers/exchangeRates.d.ts +0 -12
  422. package/out/src/services/providers/exchangeRates.d.ts.map +0 -1
  423. package/out/src/services/providers/exchangeRates.js +0 -244
  424. package/out/src/services/providers/exchangeRates.js.map +0 -1
  425. package/out/src/services/providers/getBeefForTxid.d.ts +0 -4
  426. package/out/src/services/providers/getBeefForTxid.d.ts.map +0 -1
  427. package/out/src/services/providers/getBeefForTxid.js +0 -287
  428. package/out/src/services/providers/getBeefForTxid.js.map +0 -1
  429. package/out/src/services/providers/whatsOnChainHelpers.d.ts +0 -68
  430. package/out/src/services/providers/whatsOnChainHelpers.d.ts.map +0 -1
  431. package/out/src/services/providers/whatsOnChainHelpers.js +0 -147
  432. package/out/src/services/providers/whatsOnChainHelpers.js.map +0 -1
  433. package/out/src/signer/WalletSigner.d.ts +0 -11
  434. package/out/src/signer/WalletSigner.d.ts.map +0 -1
  435. package/out/src/signer/WalletSigner.js +0 -16
  436. package/out/src/signer/WalletSigner.js.map +0 -1
  437. package/out/src/signer/actionBatch/ActionBatchPlanner.d.ts +0 -28
  438. package/out/src/signer/actionBatch/ActionBatchPlanner.d.ts.map +0 -1
  439. package/out/src/signer/actionBatch/ActionBatchPlanner.js +0 -313
  440. package/out/src/signer/actionBatch/ActionBatchPlanner.js.map +0 -1
  441. package/out/src/signer/actionBatch/ActionBatchWorkspace.d.ts +0 -33
  442. package/out/src/signer/actionBatch/ActionBatchWorkspace.d.ts.map +0 -1
  443. package/out/src/signer/actionBatch/ActionBatchWorkspace.js +0 -693
  444. package/out/src/signer/actionBatch/ActionBatchWorkspace.js.map +0 -1
  445. package/out/src/signer/methods/acquireDirectCertificate.d.ts +0 -5
  446. package/out/src/signer/methods/acquireDirectCertificate.d.ts.map +0 -1
  447. package/out/src/signer/methods/acquireDirectCertificate.js +0 -44
  448. package/out/src/signer/methods/acquireDirectCertificate.js.map +0 -1
  449. package/out/src/signer/methods/buildSignableTransaction.d.ts +0 -69
  450. package/out/src/signer/methods/buildSignableTransaction.d.ts.map +0 -1
  451. package/out/src/signer/methods/buildSignableTransaction.js +0 -268
  452. package/out/src/signer/methods/buildSignableTransaction.js.map +0 -1
  453. package/out/src/signer/methods/completeSignedTransaction.d.ts +0 -10
  454. package/out/src/signer/methods/completeSignedTransaction.d.ts.map +0 -1
  455. package/out/src/signer/methods/completeSignedTransaction.js +0 -106
  456. package/out/src/signer/methods/completeSignedTransaction.js.map +0 -1
  457. package/out/src/signer/methods/createAction.d.ts +0 -14
  458. package/out/src/signer/methods/createAction.d.ts.map +0 -1
  459. package/out/src/signer/methods/createAction.js +0 -126
  460. package/out/src/signer/methods/createAction.js.map +0 -1
  461. package/out/src/signer/methods/internalizeAction.d.ts +0 -43
  462. package/out/src/signer/methods/internalizeAction.d.ts.map +0 -1
  463. package/out/src/signer/methods/internalizeAction.js +0 -109
  464. package/out/src/signer/methods/internalizeAction.js.map +0 -1
  465. package/out/src/signer/methods/proveCertificate.d.ts +0 -5
  466. package/out/src/signer/methods/proveCertificate.d.ts.map +0 -1
  467. package/out/src/signer/methods/proveCertificate.js +0 -29
  468. package/out/src/signer/methods/proveCertificate.js.map +0 -1
  469. package/out/src/signer/methods/resultBeef.d.ts +0 -4
  470. package/out/src/signer/methods/resultBeef.d.ts.map +0 -1
  471. package/out/src/signer/methods/resultBeef.js +0 -12
  472. package/out/src/signer/methods/resultBeef.js.map +0 -1
  473. package/out/src/signer/methods/signAction.d.ts +0 -11
  474. package/out/src/signer/methods/signAction.d.ts.map +0 -1
  475. package/out/src/signer/methods/signAction.js +0 -43
  476. package/out/src/signer/methods/signAction.js.map +0 -1
  477. package/out/src/storage/StorageIdb.d.ts +0 -248
  478. package/out/src/storage/StorageIdb.d.ts.map +0 -1
  479. package/out/src/storage/StorageIdb.js +0 -1827
  480. package/out/src/storage/StorageIdb.js.map +0 -1
  481. package/out/src/storage/StorageProvider.d.ts +0 -309
  482. package/out/src/storage/StorageProvider.d.ts.map +0 -1
  483. package/out/src/storage/StorageProvider.js +0 -973
  484. package/out/src/storage/StorageProvider.js.map +0 -1
  485. package/out/src/storage/StorageReader.d.ts +0 -77
  486. package/out/src/storage/StorageReader.d.ts.map +0 -1
  487. package/out/src/storage/StorageReader.js +0 -166
  488. package/out/src/storage/StorageReader.js.map +0 -1
  489. package/out/src/storage/StorageReaderWriter.d.ts +0 -102
  490. package/out/src/storage/StorageReaderWriter.d.ts.map +0 -1
  491. package/out/src/storage/StorageReaderWriter.js +0 -335
  492. package/out/src/storage/StorageReaderWriter.js.map +0 -1
  493. package/out/src/storage/StorageSyncReader.d.ts +0 -18
  494. package/out/src/storage/StorageSyncReader.d.ts.map +0 -1
  495. package/out/src/storage/StorageSyncReader.js +0 -73
  496. package/out/src/storage/StorageSyncReader.js.map +0 -1
  497. package/out/src/storage/WalletStorageManager.d.ts +0 -225
  498. package/out/src/storage/WalletStorageManager.d.ts.map +0 -1
  499. package/out/src/storage/WalletStorageManager.js +0 -854
  500. package/out/src/storage/WalletStorageManager.js.map +0 -1
  501. package/out/src/storage/idbHelpers.d.ts +0 -44
  502. package/out/src/storage/idbHelpers.d.ts.map +0 -1
  503. package/out/src/storage/idbHelpers.js +0 -393
  504. package/out/src/storage/idbHelpers.js.map +0 -1
  505. package/out/src/storage/index.client.d.ts +0 -12
  506. package/out/src/storage/index.client.d.ts.map +0 -1
  507. package/out/src/storage/index.client.js +0 -28
  508. package/out/src/storage/index.client.js.map +0 -1
  509. package/out/src/storage/methods/ListActionsSpecOp.d.ts +0 -23
  510. package/out/src/storage/methods/ListActionsSpecOp.d.ts.map +0 -1
  511. package/out/src/storage/methods/ListActionsSpecOp.js +0 -129
  512. package/out/src/storage/methods/ListActionsSpecOp.js.map +0 -1
  513. package/out/src/storage/methods/ListOutputsSpecOp.d.ts +0 -42
  514. package/out/src/storage/methods/ListOutputsSpecOp.d.ts.map +0 -1
  515. package/out/src/storage/methods/ListOutputsSpecOp.js +0 -154
  516. package/out/src/storage/methods/ListOutputsSpecOp.js.map +0 -1
  517. package/out/src/storage/methods/actionBatch.d.ts +0 -14
  518. package/out/src/storage/methods/actionBatch.d.ts.map +0 -1
  519. package/out/src/storage/methods/actionBatch.js +0 -644
  520. package/out/src/storage/methods/actionBatch.js.map +0 -1
  521. package/out/src/storage/methods/actionBatchBlobs.d.ts +0 -12
  522. package/out/src/storage/methods/actionBatchBlobs.d.ts.map +0 -1
  523. package/out/src/storage/methods/actionBatchBlobs.js +0 -121
  524. package/out/src/storage/methods/actionBatchBlobs.js.map +0 -1
  525. package/out/src/storage/methods/actionBatchValidation.d.ts +0 -15
  526. package/out/src/storage/methods/actionBatchValidation.d.ts.map +0 -1
  527. package/out/src/storage/methods/actionBatchValidation.js +0 -310
  528. package/out/src/storage/methods/actionBatchValidation.js.map +0 -1
  529. package/out/src/storage/methods/actionPlanning.d.ts +0 -12
  530. package/out/src/storage/methods/actionPlanning.d.ts.map +0 -1
  531. package/out/src/storage/methods/actionPlanning.js +0 -48
  532. package/out/src/storage/methods/actionPlanning.js.map +0 -1
  533. package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts +0 -124
  534. package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +0 -1
  535. package/out/src/storage/methods/attemptToPostReqsToNetwork.js +0 -490
  536. package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +0 -1
  537. package/out/src/storage/methods/createAction.d.ts +0 -13
  538. package/out/src/storage/methods/createAction.d.ts.map +0 -1
  539. package/out/src/storage/methods/createAction.js +0 -777
  540. package/out/src/storage/methods/createAction.js.map +0 -1
  541. package/out/src/storage/methods/generateChange.d.ts +0 -121
  542. package/out/src/storage/methods/generateChange.d.ts.map +0 -1
  543. package/out/src/storage/methods/generateChange.js +0 -496
  544. package/out/src/storage/methods/generateChange.js.map +0 -1
  545. package/out/src/storage/methods/getBeefForTransaction.d.ts +0 -23
  546. package/out/src/storage/methods/getBeefForTransaction.d.ts.map +0 -1
  547. package/out/src/storage/methods/getBeefForTransaction.js +0 -132
  548. package/out/src/storage/methods/getBeefForTransaction.js.map +0 -1
  549. package/out/src/storage/methods/getSyncChunk.d.ts +0 -10
  550. package/out/src/storage/methods/getSyncChunk.d.ts.map +0 -1
  551. package/out/src/storage/methods/getSyncChunk.js +0 -273
  552. package/out/src/storage/methods/getSyncChunk.js.map +0 -1
  553. package/out/src/storage/methods/internalizeAction.d.ts +0 -102
  554. package/out/src/storage/methods/internalizeAction.d.ts.map +0 -1
  555. package/out/src/storage/methods/internalizeAction.js +0 -670
  556. package/out/src/storage/methods/internalizeAction.js.map +0 -1
  557. package/out/src/storage/methods/listActionsIdb.d.ts +0 -5
  558. package/out/src/storage/methods/listActionsIdb.d.ts.map +0 -1
  559. package/out/src/storage/methods/listActionsIdb.js +0 -142
  560. package/out/src/storage/methods/listActionsIdb.js.map +0 -1
  561. package/out/src/storage/methods/listCertificates.d.ts +0 -5
  562. package/out/src/storage/methods/listCertificates.d.ts.map +0 -1
  563. package/out/src/storage/methods/listCertificates.js +0 -68
  564. package/out/src/storage/methods/listCertificates.js.map +0 -1
  565. package/out/src/storage/methods/listOutputsIdb.d.ts +0 -5
  566. package/out/src/storage/methods/listOutputsIdb.d.ts.map +0 -1
  567. package/out/src/storage/methods/listOutputsIdb.js +0 -195
  568. package/out/src/storage/methods/listOutputsIdb.js.map +0 -1
  569. package/out/src/storage/methods/managedChange.d.ts +0 -26
  570. package/out/src/storage/methods/managedChange.d.ts.map +0 -1
  571. package/out/src/storage/methods/managedChange.js +0 -43
  572. package/out/src/storage/methods/managedChange.js.map +0 -1
  573. package/out/src/storage/methods/offsetKey.d.ts +0 -24
  574. package/out/src/storage/methods/offsetKey.d.ts.map +0 -1
  575. package/out/src/storage/methods/offsetKey.js +0 -65
  576. package/out/src/storage/methods/offsetKey.js.map +0 -1
  577. package/out/src/storage/methods/processAction.d.ts +0 -43
  578. package/out/src/storage/methods/processAction.d.ts.map +0 -1
  579. package/out/src/storage/methods/processAction.js +0 -313
  580. package/out/src/storage/methods/processAction.js.map +0 -1
  581. package/out/src/storage/methods/purgeDataIdb.d.ts +0 -4
  582. package/out/src/storage/methods/purgeDataIdb.d.ts.map +0 -1
  583. package/out/src/storage/methods/purgeDataIdb.js +0 -9
  584. package/out/src/storage/methods/purgeDataIdb.js.map +0 -1
  585. package/out/src/storage/methods/reviewStatusIdb.d.ts +0 -20
  586. package/out/src/storage/methods/reviewStatusIdb.d.ts.map +0 -1
  587. package/out/src/storage/methods/reviewStatusIdb.js +0 -76
  588. package/out/src/storage/methods/reviewStatusIdb.js.map +0 -1
  589. package/out/src/storage/methods/utils.d.ts +0 -25
  590. package/out/src/storage/methods/utils.d.ts.map +0 -1
  591. package/out/src/storage/methods/utils.js +0 -59
  592. package/out/src/storage/methods/utils.js.map +0 -1
  593. package/out/src/storage/portable/index.d.ts +0 -55
  594. package/out/src/storage/portable/index.d.ts.map +0 -1
  595. package/out/src/storage/portable/index.js +0 -872
  596. package/out/src/storage/portable/index.js.map +0 -1
  597. package/out/src/storage/remoting/BinaryJson.d.ts +0 -10
  598. package/out/src/storage/remoting/BinaryJson.d.ts.map +0 -1
  599. package/out/src/storage/remoting/BinaryJson.js +0 -172
  600. package/out/src/storage/remoting/BinaryJson.js.map +0 -1
  601. package/out/src/storage/remoting/StorageClient.d.ts +0 -26
  602. package/out/src/storage/remoting/StorageClient.d.ts.map +0 -1
  603. package/out/src/storage/remoting/StorageClient.js +0 -98
  604. package/out/src/storage/remoting/StorageClient.js.map +0 -1
  605. package/out/src/storage/remoting/StorageClientBase.d.ts +0 -308
  606. package/out/src/storage/remoting/StorageClientBase.d.ts.map +0 -1
  607. package/out/src/storage/remoting/StorageClientBase.js +0 -416
  608. package/out/src/storage/remoting/StorageClientBase.js.map +0 -1
  609. package/out/src/storage/remoting/entityValidationHelpers.d.ts +0 -29
  610. package/out/src/storage/remoting/entityValidationHelpers.d.ts.map +0 -1
  611. package/out/src/storage/remoting/entityValidationHelpers.js +0 -91
  612. package/out/src/storage/remoting/entityValidationHelpers.js.map +0 -1
  613. package/out/src/storage/schema/StorageIdbSchema.d.ts +0 -157
  614. package/out/src/storage/schema/StorageIdbSchema.d.ts.map +0 -1
  615. package/out/src/storage/schema/StorageIdbSchema.js +0 -3
  616. package/out/src/storage/schema/StorageIdbSchema.js.map +0 -1
  617. package/out/src/storage/schema/entities/EntityBase.d.ts +0 -106
  618. package/out/src/storage/schema/entities/EntityBase.d.ts.map +0 -1
  619. package/out/src/storage/schema/entities/EntityBase.js +0 -101
  620. package/out/src/storage/schema/entities/EntityBase.js.map +0 -1
  621. package/out/src/storage/schema/entities/EntityCertificate.d.ts +0 -44
  622. package/out/src/storage/schema/entities/EntityCertificate.d.ts.map +0 -1
  623. package/out/src/storage/schema/entities/EntityCertificate.js +0 -163
  624. package/out/src/storage/schema/entities/EntityCertificate.js.map +0 -1
  625. package/out/src/storage/schema/entities/EntityCertificateField.d.ts +0 -33
  626. package/out/src/storage/schema/entities/EntityCertificateField.d.ts.map +0 -1
  627. package/out/src/storage/schema/entities/EntityCertificateField.js +0 -110
  628. package/out/src/storage/schema/entities/EntityCertificateField.js.map +0 -1
  629. package/out/src/storage/schema/entities/EntityCommission.d.ts +0 -38
  630. package/out/src/storage/schema/entities/EntityCommission.d.ts.map +0 -1
  631. package/out/src/storage/schema/entities/EntityCommission.js +0 -125
  632. package/out/src/storage/schema/entities/EntityCommission.js.map +0 -1
  633. package/out/src/storage/schema/entities/EntityOutput.d.ts +0 -68
  634. package/out/src/storage/schema/entities/EntityOutput.d.ts.map +0 -1
  635. package/out/src/storage/schema/entities/EntityOutput.js +0 -261
  636. package/out/src/storage/schema/entities/EntityOutput.js.map +0 -1
  637. package/out/src/storage/schema/entities/EntityOutputBasket.d.ts +0 -36
  638. package/out/src/storage/schema/entities/EntityOutputBasket.d.ts.map +0 -1
  639. package/out/src/storage/schema/entities/EntityOutputBasket.js +0 -133
  640. package/out/src/storage/schema/entities/EntityOutputBasket.js.map +0 -1
  641. package/out/src/storage/schema/entities/EntityOutputTag.d.ts +0 -32
  642. package/out/src/storage/schema/entities/EntityOutputTag.d.ts.map +0 -1
  643. package/out/src/storage/schema/entities/EntityOutputTag.js +0 -104
  644. package/out/src/storage/schema/entities/EntityOutputTag.js.map +0 -1
  645. package/out/src/storage/schema/entities/EntityOutputTagMap.d.ts +0 -29
  646. package/out/src/storage/schema/entities/EntityOutputTagMap.d.ts.map +0 -1
  647. package/out/src/storage/schema/entities/EntityOutputTagMap.js +0 -96
  648. package/out/src/storage/schema/entities/EntityOutputTagMap.js.map +0 -1
  649. package/out/src/storage/schema/entities/EntityProvenTx.d.ts +0 -87
  650. package/out/src/storage/schema/entities/EntityProvenTx.d.ts.map +0 -1
  651. package/out/src/storage/schema/entities/EntityProvenTx.js +0 -276
  652. package/out/src/storage/schema/entities/EntityProvenTx.js.map +0 -1
  653. package/out/src/storage/schema/entities/EntityProvenTxReq.d.ts +0 -148
  654. package/out/src/storage/schema/entities/EntityProvenTxReq.d.ts.map +0 -1
  655. package/out/src/storage/schema/entities/EntityProvenTxReq.js +0 -570
  656. package/out/src/storage/schema/entities/EntityProvenTxReq.js.map +0 -1
  657. package/out/src/storage/schema/entities/EntitySyncState.d.ts +0 -69
  658. package/out/src/storage/schema/entities/EntitySyncState.d.ts.map +0 -1
  659. package/out/src/storage/schema/entities/EntitySyncState.js +0 -338
  660. package/out/src/storage/schema/entities/EntitySyncState.js.map +0 -1
  661. package/out/src/storage/schema/entities/EntityTransaction.d.ts +0 -71
  662. package/out/src/storage/schema/entities/EntityTransaction.d.ts.map +0 -1
  663. package/out/src/storage/schema/entities/EntityTransaction.js +0 -265
  664. package/out/src/storage/schema/entities/EntityTransaction.js.map +0 -1
  665. package/out/src/storage/schema/entities/EntityTxLabel.d.ts +0 -32
  666. package/out/src/storage/schema/entities/EntityTxLabel.d.ts.map +0 -1
  667. package/out/src/storage/schema/entities/EntityTxLabel.js +0 -104
  668. package/out/src/storage/schema/entities/EntityTxLabel.js.map +0 -1
  669. package/out/src/storage/schema/entities/EntityTxLabelMap.d.ts +0 -29
  670. package/out/src/storage/schema/entities/EntityTxLabelMap.d.ts.map +0 -1
  671. package/out/src/storage/schema/entities/EntityTxLabelMap.js +0 -96
  672. package/out/src/storage/schema/entities/EntityTxLabelMap.js.map +0 -1
  673. package/out/src/storage/schema/entities/EntityUser.d.ts +0 -30
  674. package/out/src/storage/schema/entities/EntityUser.d.ts.map +0 -1
  675. package/out/src/storage/schema/entities/EntityUser.js +0 -99
  676. package/out/src/storage/schema/entities/EntityUser.js.map +0 -1
  677. package/out/src/storage/schema/entities/MergeEntity.d.ts +0 -34
  678. package/out/src/storage/schema/entities/MergeEntity.d.ts.map +0 -1
  679. package/out/src/storage/schema/entities/MergeEntity.js +0 -67
  680. package/out/src/storage/schema/entities/MergeEntity.js.map +0 -1
  681. package/out/src/storage/schema/entities/index.d.ts +0 -17
  682. package/out/src/storage/schema/entities/index.d.ts.map +0 -1
  683. package/out/src/storage/schema/entities/index.js +0 -33
  684. package/out/src/storage/schema/entities/index.js.map +0 -1
  685. package/out/src/storage/schema/tables/TableActionBatch.d.ts +0 -24
  686. package/out/src/storage/schema/tables/TableActionBatch.d.ts.map +0 -1
  687. package/out/src/storage/schema/tables/TableActionBatch.js +0 -3
  688. package/out/src/storage/schema/tables/TableActionBatch.js.map +0 -1
  689. package/out/src/storage/schema/tables/TableAuthSession.d.ts +0 -20
  690. package/out/src/storage/schema/tables/TableAuthSession.d.ts.map +0 -1
  691. package/out/src/storage/schema/tables/TableAuthSession.js +0 -15
  692. package/out/src/storage/schema/tables/TableAuthSession.js.map +0 -1
  693. package/out/src/storage/schema/tables/TableCertificate.d.ts +0 -21
  694. package/out/src/storage/schema/tables/TableCertificate.d.ts.map +0 -1
  695. package/out/src/storage/schema/tables/TableCertificate.js +0 -3
  696. package/out/src/storage/schema/tables/TableCertificate.js.map +0 -1
  697. package/out/src/storage/schema/tables/TableCertificateField.d.ts +0 -12
  698. package/out/src/storage/schema/tables/TableCertificateField.d.ts.map +0 -1
  699. package/out/src/storage/schema/tables/TableCertificateField.js +0 -3
  700. package/out/src/storage/schema/tables/TableCertificateField.js.map +0 -1
  701. package/out/src/storage/schema/tables/TableCommission.d.ts +0 -13
  702. package/out/src/storage/schema/tables/TableCommission.d.ts.map +0 -1
  703. package/out/src/storage/schema/tables/TableCommission.js +0 -3
  704. package/out/src/storage/schema/tables/TableCommission.js.map +0 -1
  705. package/out/src/storage/schema/tables/TableMonitorEvent.d.ts +0 -9
  706. package/out/src/storage/schema/tables/TableMonitorEvent.d.ts.map +0 -1
  707. package/out/src/storage/schema/tables/TableMonitorEvent.js +0 -3
  708. package/out/src/storage/schema/tables/TableMonitorEvent.js.map +0 -1
  709. package/out/src/storage/schema/tables/TableOutput.d.ts +0 -37
  710. package/out/src/storage/schema/tables/TableOutput.d.ts.map +0 -1
  711. package/out/src/storage/schema/tables/TableOutput.js +0 -31
  712. package/out/src/storage/schema/tables/TableOutput.js.map +0 -1
  713. package/out/src/storage/schema/tables/TableOutputBasket.d.ts +0 -12
  714. package/out/src/storage/schema/tables/TableOutputBasket.d.ts.map +0 -1
  715. package/out/src/storage/schema/tables/TableOutputBasket.js +0 -3
  716. package/out/src/storage/schema/tables/TableOutputBasket.js.map +0 -1
  717. package/out/src/storage/schema/tables/TableOutputTag.d.ts +0 -10
  718. package/out/src/storage/schema/tables/TableOutputTag.d.ts.map +0 -1
  719. package/out/src/storage/schema/tables/TableOutputTag.js +0 -3
  720. package/out/src/storage/schema/tables/TableOutputTag.js.map +0 -1
  721. package/out/src/storage/schema/tables/TableOutputTagMap.d.ts +0 -9
  722. package/out/src/storage/schema/tables/TableOutputTagMap.d.ts.map +0 -1
  723. package/out/src/storage/schema/tables/TableOutputTagMap.js +0 -3
  724. package/out/src/storage/schema/tables/TableOutputTagMap.js.map +0 -1
  725. package/out/src/storage/schema/tables/TableProvenTx.d.ts +0 -14
  726. package/out/src/storage/schema/tables/TableProvenTx.d.ts.map +0 -1
  727. package/out/src/storage/schema/tables/TableProvenTx.js +0 -3
  728. package/out/src/storage/schema/tables/TableProvenTx.js.map +0 -1
  729. package/out/src/storage/schema/tables/TableProvenTxReq.d.ts +0 -87
  730. package/out/src/storage/schema/tables/TableProvenTxReq.d.ts.map +0 -1
  731. package/out/src/storage/schema/tables/TableProvenTxReq.js +0 -3
  732. package/out/src/storage/schema/tables/TableProvenTxReq.js.map +0 -1
  733. package/out/src/storage/schema/tables/TableSettings.d.ts +0 -17
  734. package/out/src/storage/schema/tables/TableSettings.d.ts.map +0 -1
  735. package/out/src/storage/schema/tables/TableSettings.js +0 -3
  736. package/out/src/storage/schema/tables/TableSettings.js.map +0 -1
  737. package/out/src/storage/schema/tables/TableSyncState.d.ts +0 -18
  738. package/out/src/storage/schema/tables/TableSyncState.d.ts.map +0 -1
  739. package/out/src/storage/schema/tables/TableSyncState.js +0 -3
  740. package/out/src/storage/schema/tables/TableSyncState.js.map +0 -1
  741. package/out/src/storage/schema/tables/TableTransaction.d.ts +0 -37
  742. package/out/src/storage/schema/tables/TableTransaction.d.ts.map +0 -1
  743. package/out/src/storage/schema/tables/TableTransaction.js +0 -21
  744. package/out/src/storage/schema/tables/TableTransaction.js.map +0 -1
  745. package/out/src/storage/schema/tables/TableTxLabel.d.ts +0 -10
  746. package/out/src/storage/schema/tables/TableTxLabel.d.ts.map +0 -1
  747. package/out/src/storage/schema/tables/TableTxLabel.js +0 -3
  748. package/out/src/storage/schema/tables/TableTxLabel.js.map +0 -1
  749. package/out/src/storage/schema/tables/TableTxLabelMap.d.ts +0 -9
  750. package/out/src/storage/schema/tables/TableTxLabelMap.d.ts.map +0 -1
  751. package/out/src/storage/schema/tables/TableTxLabelMap.js +0 -3
  752. package/out/src/storage/schema/tables/TableTxLabelMap.js.map +0 -1
  753. package/out/src/storage/schema/tables/TableUser.d.ts +0 -16
  754. package/out/src/storage/schema/tables/TableUser.d.ts.map +0 -1
  755. package/out/src/storage/schema/tables/TableUser.js +0 -3
  756. package/out/src/storage/schema/tables/TableUser.js.map +0 -1
  757. package/out/src/storage/schema/tables/index.d.ts +0 -19
  758. package/out/src/storage/schema/tables/index.d.ts.map +0 -1
  759. package/out/src/storage/schema/tables/index.js +0 -35
  760. package/out/src/storage/schema/tables/index.js.map +0 -1
  761. package/out/src/storage/storageProviderHelpers.d.ts +0 -35
  762. package/out/src/storage/storageProviderHelpers.d.ts.map +0 -1
  763. package/out/src/storage/storageProviderHelpers.js +0 -100
  764. package/out/src/storage/storageProviderHelpers.js.map +0 -1
  765. package/out/src/utility/ScriptTemplateBRC29.d.ts +0 -25
  766. package/out/src/utility/ScriptTemplateBRC29.d.ts.map +0 -1
  767. package/out/src/utility/ScriptTemplateBRC29.js +0 -51
  768. package/out/src/utility/ScriptTemplateBRC29.js.map +0 -1
  769. package/out/src/utility/actionBatchDigest.d.ts +0 -9
  770. package/out/src/utility/actionBatchDigest.d.ts.map +0 -1
  771. package/out/src/utility/actionBatchDigest.js +0 -48
  772. package/out/src/utility/actionBatchDigest.js.map +0 -1
  773. package/out/src/utility/aggregateResults.d.ts +0 -8
  774. package/out/src/utility/aggregateResults.d.ts.map +0 -1
  775. package/out/src/utility/aggregateResults.js +0 -59
  776. package/out/src/utility/aggregateResults.js.map +0 -1
  777. package/out/src/utility/beefForTxids.d.ts +0 -9
  778. package/out/src/utility/beefForTxids.d.ts.map +0 -1
  779. package/out/src/utility/beefForTxids.js +0 -35
  780. package/out/src/utility/beefForTxids.js.map +0 -1
  781. package/out/src/utility/brc114ActionTimeLabels.d.ts +0 -9
  782. package/out/src/utility/brc114ActionTimeLabels.d.ts.map +0 -1
  783. package/out/src/utility/brc114ActionTimeLabels.js +0 -58
  784. package/out/src/utility/brc114ActionTimeLabels.js.map +0 -1
  785. package/out/src/utility/identityUtils.d.ts +0 -37
  786. package/out/src/utility/identityUtils.d.ts.map +0 -1
  787. package/out/src/utility/identityUtils.js +0 -162
  788. package/out/src/utility/identityUtils.js.map +0 -1
  789. package/out/src/utility/index.client.d.ts +0 -8
  790. package/out/src/utility/index.client.d.ts.map +0 -1
  791. package/out/src/utility/index.client.js +0 -24
  792. package/out/src/utility/index.client.js.map +0 -1
  793. package/out/src/utility/parseTxScriptOffsets.d.ts +0 -14
  794. package/out/src/utility/parseTxScriptOffsets.d.ts.map +0 -1
  795. package/out/src/utility/parseTxScriptOffsets.js +0 -26
  796. package/out/src/utility/parseTxScriptOffsets.js.map +0 -1
  797. package/out/src/utility/stampLog.d.ts +0 -18
  798. package/out/src/utility/stampLog.d.ts.map +0 -1
  799. package/out/src/utility/stampLog.js +0 -74
  800. package/out/src/utility/stampLog.js.map +0 -1
  801. package/out/src/utility/tscProofToMerklePath.d.ts +0 -8
  802. package/out/src/utility/tscProofToMerklePath.d.ts.map +0 -1
  803. package/out/src/utility/tscProofToMerklePath.js +0 -41
  804. package/out/src/utility/tscProofToMerklePath.js.map +0 -1
  805. package/out/src/utility/utilityHelpers.d.ts +0 -142
  806. package/out/src/utility/utilityHelpers.d.ts.map +0 -1
  807. package/out/src/utility/utilityHelpers.js +0 -319
  808. package/out/src/utility/utilityHelpers.js.map +0 -1
  809. package/out/src/utility/utilityHelpers.noBuffer.d.ts +0 -30
  810. package/out/src/utility/utilityHelpers.noBuffer.d.ts.map +0 -1
  811. package/out/src/utility/utilityHelpers.noBuffer.js +0 -64
  812. package/out/src/utility/utilityHelpers.noBuffer.js.map +0 -1
  813. package/out/src/wab-client/WABClient.d.ts +0 -60
  814. package/out/src/wab-client/WABClient.d.ts.map +0 -1
  815. package/out/src/wab-client/WABClient.js +0 -140
  816. package/out/src/wab-client/WABClient.js.map +0 -1
  817. package/out/src/wab-client/WABTransport.d.ts +0 -53
  818. package/out/src/wab-client/WABTransport.d.ts.map +0 -1
  819. package/out/src/wab-client/WABTransport.js +0 -300
  820. package/out/src/wab-client/WABTransport.js.map +0 -1
  821. package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts +0 -41
  822. package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts.map +0 -1
  823. package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js +0 -44
  824. package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js.map +0 -1
  825. package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.d.ts +0 -11
  826. package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.d.ts.map +0 -1
  827. package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.js +0 -15
  828. package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.js.map +0 -1
  829. package/out/src/wab-client/auth-method-interactors/PersonaIDInteractor.d.ts +0 -5
  830. package/out/src/wab-client/auth-method-interactors/PersonaIDInteractor.d.ts.map +0 -1
  831. package/out/src/wab-client/auth-method-interactors/PersonaIDInteractor.js +0 -9
  832. package/out/src/wab-client/auth-method-interactors/PersonaIDInteractor.js.map +0 -1
  833. package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.d.ts +0 -11
  834. package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.d.ts.map +0 -1
  835. package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.js +0 -28
  836. package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.js.map +0 -1
  837. package/out/tsconfig.client.tsbuildinfo +0 -1
@@ -1,1966 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CWIStyleWalletManager = exports.OverlayUMPTokenInteractor = exports.UMPTokenLookupError = exports.DEFAULT_PROFILE_ID = exports.MAX_STATE_SNAPSHOT_BYTES = exports.PBKDF2_MAX_ITERATIONS = exports.KDF_MAX_HASH_LENGTH = exports.ARGON2ID_MAX_PARALLELISM = exports.ARGON2ID_MAX_MEMORY_KIB = exports.ARGON2ID_MAX_ITERATIONS = exports.ARGON2ID_DEFAULT_HASH_LENGTH = exports.ARGON2ID_DEFAULT_PARALLELISM = exports.ARGON2ID_DEFAULT_MEMORY_KIB = exports.ARGON2ID_DEFAULT_ITERATIONS = exports.PBKDF2_NUM_ROUNDS = void 0;
4
- const sdk_1 = require("@bsv/sdk");
5
- const hash_wasm_1 = require("hash-wasm");
6
- const PrivilegedKeyManager_1 = require("./sdk/PrivilegedKeyManager");
7
- /**
8
- * Number of rounds used in PBKDF2 for deriving password keys.
9
- */
10
- exports.PBKDF2_NUM_ROUNDS = 7777;
11
- /**
12
- * Default Argon2id parameters for password-key derivation (UMP v3).
13
- */
14
- exports.ARGON2ID_DEFAULT_ITERATIONS = 7;
15
- exports.ARGON2ID_DEFAULT_MEMORY_KIB = 131072;
16
- exports.ARGON2ID_DEFAULT_PARALLELISM = 1;
17
- exports.ARGON2ID_DEFAULT_HASH_LENGTH = 32;
18
- exports.ARGON2ID_MAX_ITERATIONS = 20;
19
- exports.ARGON2ID_MAX_MEMORY_KIB = 262144;
20
- exports.ARGON2ID_MAX_PARALLELISM = 16;
21
- exports.KDF_MAX_HASH_LENGTH = 64;
22
- exports.PBKDF2_MAX_ITERATIONS = 10_000_000;
23
- exports.MAX_STATE_SNAPSHOT_BYTES = 16 * 1024 * 1024;
24
- function isPositiveIntegerInRange(value, maximum) {
25
- return typeof value === 'number' && Number.isInteger(value) && value > 0 && value <= maximum;
26
- }
27
- function isValidKdfConfig(kdf) {
28
- if (kdf == null)
29
- return false;
30
- if (!isPositiveIntegerInRange(kdf.iterations, kdf.algorithm === 'argon2id' ? exports.ARGON2ID_MAX_ITERATIONS : exports.PBKDF2_MAX_ITERATIONS)) {
31
- return false;
32
- }
33
- if (kdf.algorithm === 'pbkdf2-sha512') {
34
- return kdf.hashLength === undefined || isPositiveIntegerInRange(kdf.hashLength, exports.KDF_MAX_HASH_LENGTH);
35
- }
36
- if (kdf.algorithm !== 'argon2id')
37
- return false;
38
- return isPositiveIntegerInRange(kdf.memoryKiB, exports.ARGON2ID_MAX_MEMORY_KIB) &&
39
- isPositiveIntegerInRange(kdf.parallelism, exports.ARGON2ID_MAX_PARALLELISM) &&
40
- isPositiveIntegerInRange(kdf.hashLength, exports.KDF_MAX_HASH_LENGTH);
41
- }
42
- function isLikelyDerSignatureField(field) {
43
- if (!field || field.length < 8 || field.length > 80) {
44
- return false;
45
- }
46
- if (field[0] !== 0x30) {
47
- return false;
48
- }
49
- const declaredLen = field[1];
50
- return declaredLen === field.length - 2;
51
- }
52
- function stripVerifiedPushDropSignature(fields, lockingPublicKey) {
53
- if (fields.length <= 11) {
54
- return fields;
55
- }
56
- const protocolFieldCount = fields.length - 1;
57
- const trailingField = fields[protocolFieldCount];
58
- if (!trailingField || !isLikelyDerSignatureField(trailingField)) {
59
- return fields;
60
- }
61
- try {
62
- let dataLength = 0;
63
- for (let i = 0; i < protocolFieldCount; i++) {
64
- dataLength += fields[i].length;
65
- }
66
- const dataToVerify = new Array(dataLength);
67
- let writeOffset = 0;
68
- for (let i = 0; i < protocolFieldCount; i++) {
69
- const field = fields[i];
70
- for (const byte of field) {
71
- dataToVerify[writeOffset++] = byte;
72
- }
73
- }
74
- const signature = sdk_1.Signature.fromDER(trailingField);
75
- if (signature.verify(dataToVerify, lockingPublicKey)) {
76
- return fields.slice(0, protocolFieldCount);
77
- }
78
- }
79
- catch {
80
- return fields;
81
- }
82
- return fields;
83
- }
84
- /**
85
- * PBKDF-2 that prefers WebCrypto and falls back to hash-wasm.
86
- *
87
- * @param passwordBytes Raw password bytes.
88
- * @param salt Salt bytes.
89
- * @param iterations Number of rounds.
90
- * @param keyLen Desired key length in bytes.
91
- * @param hash Digest algorithm (default "sha512").
92
- * @returns Derived key bytes.
93
- */
94
- async function pbkdf2NativeOrWasm(passwordBytes, salt, iterations, keyLen, hash = 'sha512') {
95
- // ----- fast-path: WebCrypto (both browser & recent Node expose globalThis.crypto.subtle)
96
- const subtle = globalThis?.crypto?.subtle;
97
- if (subtle != null) {
98
- try {
99
- const baseKey = await subtle.importKey('raw', new Uint8Array(passwordBytes), { name: 'PBKDF2' },
100
- /* extractable */ false, ['deriveBits']);
101
- const bits = await subtle.deriveBits({
102
- name: 'PBKDF2',
103
- salt: new Uint8Array(salt),
104
- iterations,
105
- hash: hash.toUpperCase()
106
- }, baseKey, keyLen * 8);
107
- return Array.from(new Uint8Array(bits));
108
- }
109
- catch {
110
- // WebCrypto is unavailable or refused the algorithm (e.g. non-secure context, old
111
- // Safari). Fall through to the pure-JS hash-wasm implementation below.
112
- }
113
- }
114
- const hashFunction = hash === 'sha256' ? (0, hash_wasm_1.createSHA256)() : (0, hash_wasm_1.createSHA512)();
115
- const derived = await (0, hash_wasm_1.pbkdf2)({
116
- password: new Uint8Array(passwordBytes),
117
- salt: new Uint8Array(salt),
118
- iterations,
119
- hashLength: keyLen,
120
- hashFunction,
121
- outputType: 'binary'
122
- });
123
- return Array.from(derived);
124
- }
125
- /**
126
- * Derives the password key from a password using the KDF specified in the UMP token.
127
- * For legacy tokens (no KDF metadata), uses PBKDF2 with fixed rounds (7777).
128
- * For v3 tokens, uses the algorithm specified in passwordKdf metadata.
129
- *
130
- * @param token The UMP token containing KDF metadata and salt.
131
- * @param passwordBytes Raw password bytes.
132
- * @param overrideKdf Optional KDF config to override token/default settings.
133
- * @returns Derived password key bytes.
134
- */
135
- async function derivePasswordKey(token, passwordBytes, overrideKdf) {
136
- const kdf = overrideKdf || token.passwordKdf;
137
- if (kdf != null && !isValidKdfConfig(kdf)) {
138
- throw new Error('UMP token contains unsupported or unsafe KDF parameters.');
139
- }
140
- // Legacy token or explicit PBKDF2 request
141
- if ((kdf == null) || kdf.algorithm === 'pbkdf2-sha512') {
142
- return await pbkdf2NativeOrWasm(passwordBytes, token.passwordSalt, kdf?.iterations ?? exports.PBKDF2_NUM_ROUNDS, 32, 'sha512');
143
- }
144
- // Argon2id path (UMP v3)
145
- if (kdf.algorithm === 'argon2id') {
146
- const iterations = kdf.iterations ?? exports.ARGON2ID_DEFAULT_ITERATIONS;
147
- const memorySize = kdf.memoryKiB ?? exports.ARGON2ID_DEFAULT_MEMORY_KIB;
148
- const parallelism = kdf.parallelism ?? exports.ARGON2ID_DEFAULT_PARALLELISM;
149
- const hashLength = kdf.hashLength ?? exports.ARGON2ID_DEFAULT_HASH_LENGTH;
150
- const hash = await (0, hash_wasm_1.argon2id)({
151
- password: new Uint8Array(passwordBytes),
152
- salt: new Uint8Array(token.passwordSalt),
153
- iterations,
154
- memorySize,
155
- parallelism,
156
- hashLength,
157
- outputType: 'binary'
158
- });
159
- return Array.from(hash);
160
- }
161
- throw new Error(`Unsupported KDF algorithm: ${kdf.algorithm}`);
162
- }
163
- /**
164
- * Unique Identifier for the default profile (16 zero bytes).
165
- */
166
- exports.DEFAULT_PROFILE_ID = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
167
- function isByteArrayOfLength(value, length) {
168
- return Array.isArray(value) &&
169
- value.length === length &&
170
- value.every(byte => Number.isInteger(byte) && byte >= 0 && byte <= 255);
171
- }
172
- function isValidProfile(value) {
173
- if (value == null || typeof value !== 'object')
174
- return false;
175
- const profile = value;
176
- return typeof profile.name === 'string' &&
177
- profile.name.length > 0 &&
178
- profile.name.length <= 250 &&
179
- isByteArrayOfLength(profile.id, 16) &&
180
- isByteArrayOfLength(profile.primaryPad, 32) &&
181
- isByteArrayOfLength(profile.privilegedPad, 32) &&
182
- typeof profile.createdAt === 'number' &&
183
- Number.isFinite(profile.createdAt) &&
184
- profile.createdAt >= 0;
185
- }
186
- /**
187
- * Raised when UMP absence cannot be established authoritatively.
188
- *
189
- * Callers must offer retry/recovery rather than treating this error as a new
190
- * account. Diagnostics contain counts only and never hashes, keys, or tokens.
191
- */
192
- class UMPTokenLookupError extends Error {
193
- reason;
194
- diagnostics;
195
- code = 'WERR_UMP_LOOKUP_INDETERMINATE';
196
- constructor(reason, diagnostics, options) {
197
- super('Unable to determine whether the wallet account already exists. Retry or use account recovery.', options);
198
- this.reason = reason;
199
- this.diagnostics = diagnostics;
200
- this.name = 'UMPTokenLookupError';
201
- }
202
- }
203
- exports.UMPTokenLookupError = UMPTokenLookupError;
204
- /**
205
- * @class OverlayUMPTokenInteractor
206
- *
207
- * A concrete implementation of the UMPTokenInteractor interface that interacts
208
- * with Overlay Services and the UMP (User Management Protocol) topic. This class
209
- * is responsible for:
210
- *
211
- * 1) Locating UMP tokens via overlay lookups (ls_users).
212
- * 2) Creating and publishing new or updated UMP token outputs on-chain under
213
- * the "tm_users" topic.
214
- * 3) Consuming (spending) an old token if provided.
215
- */
216
- class OverlayUMPTokenInteractor {
217
- /**
218
- * A `LookupResolver` instance used to query overlay networks.
219
- */
220
- resolver;
221
- /**
222
- * A SHIP broadcaster that can be used to publish updated UMP tokens
223
- * under the `tm_users` topic to overlay service peers.
224
- */
225
- broadcaster;
226
- telemetry;
227
- /**
228
- * Construct a new OverlayUMPTokenInteractor.
229
- *
230
- * @param resolver A LookupResolver instance for performing overlay queries (ls_users).
231
- * @param broadcaster A SHIPBroadcaster instance for sharing new or updated tokens across the `tm_users` overlay.
232
- */
233
- constructor(resolver = new sdk_1.LookupResolver(), broadcaster = new sdk_1.SHIPBroadcaster(['tm_users']), telemetry) {
234
- this.resolver = resolver;
235
- this.broadcaster = broadcaster;
236
- this.telemetry = new sdk_1.Telemetry(telemetry);
237
- }
238
- /**
239
- * Finds a UMP token on-chain by the given presentation key hash, if it exists.
240
- * Uses the ls_users overlay service to perform the lookup.
241
- *
242
- * @param hash The 32-byte SHA-256 hash of the presentation key.
243
- * @returns A UMPToken object (including currentOutpoint) if found, otherwise undefined.
244
- */
245
- async findByPresentationKeyHash(hash) {
246
- return await this.findToken({
247
- service: 'ls_users',
248
- query: { presentationHash: sdk_1.Utils.toHex(hash) }
249
- }, 'presentation');
250
- }
251
- /**
252
- * Finds a UMP token on-chain by the given recovery key hash, if it exists.
253
- * Uses the ls_users overlay service to perform the lookup.
254
- *
255
- * @param hash The 32-byte SHA-256 hash of the recovery key.
256
- * @returns A UMPToken object (including currentOutpoint) if found, otherwise undefined.
257
- */
258
- async findByRecoveryKeyHash(hash) {
259
- return await this.findToken({
260
- service: 'ls_users',
261
- query: { recoveryHash: sdk_1.Utils.toHex(hash) }
262
- }, 'recovery');
263
- }
264
- async findToken(question, lookupKind) {
265
- const correlationId = this.telemetry.enabled === true ? this.telemetry.createCorrelationId() : undefined;
266
- const startedAt = Date.now();
267
- this.telemetry.capture({
268
- name: 'wallet-toolbox.ump.lookup.started',
269
- component: 'wallet-toolbox.ump',
270
- severity: 'debug',
271
- correlationId,
272
- attributes: { lookupKind }
273
- });
274
- let resolution;
275
- try {
276
- resolution = await this.resolver.queryDetailed(question, undefined, {
277
- waitForAllHosts: true,
278
- correlationId
279
- });
280
- }
281
- catch (error) {
282
- const diagnostics = this.emptyLookupDiagnostics(correlationId);
283
- this.captureLookupFailure(lookupKind, 'lookup-unavailable', diagnostics, startedAt, error);
284
- throw new UMPTokenLookupError('lookup-unavailable', diagnostics, { cause: error });
285
- }
286
- const diagnostics = this.toLookupDiagnostics(resolution);
287
- if (resolution.answer.outputs.length === 0) {
288
- const authoritative = resolution.progress.isFinal &&
289
- resolution.progress.hostCount > 0 &&
290
- resolution.progress.completedHosts === resolution.progress.hostCount &&
291
- resolution.progress.successfulHosts === resolution.progress.hostCount &&
292
- resolution.progress.emptyHosts === resolution.progress.hostCount &&
293
- resolution.progress.failedHosts === 0 &&
294
- resolution.progress.rejectedHosts === 0 &&
295
- resolution.progress.freeformHosts === 0;
296
- if (!authoritative) {
297
- this.captureLookupFailure(lookupKind, 'lookup-incomplete', diagnostics, startedAt);
298
- throw new UMPTokenLookupError('lookup-incomplete', diagnostics);
299
- }
300
- this.telemetry.capture({
301
- name: 'wallet-toolbox.ump.lookup.completed',
302
- component: 'wallet-toolbox.ump',
303
- severity: 'info',
304
- correlationId: diagnostics.correlationId,
305
- attributes: {
306
- lookupKind,
307
- result: 'not-found',
308
- durationMs: Date.now() - startedAt,
309
- ...this.lookupDiagnosticAttributes(diagnostics)
310
- }
311
- });
312
- return undefined;
313
- }
314
- const tokens = this.parseLookupAnswers(resolution.answer);
315
- const expectedHash = question.query[lookupKind === 'presentation' ? 'presentationHash' : 'recoveryHash'].toLowerCase();
316
- const everyOutputValidAndMatching = tokens.length === resolution.answer.outputs.length &&
317
- tokens.every(token => sdk_1.Utils.toHex(lookupKind === 'presentation' ? token.presentationHash : token.recoveryHash).toLowerCase() === expectedHash);
318
- if (!everyOutputValidAndMatching || tokens.length === 0) {
319
- this.captureLookupFailure(lookupKind, 'token-malformed', diagnostics, startedAt);
320
- throw new UMPTokenLookupError('token-malformed', diagnostics);
321
- }
322
- if (tokens.length !== 1) {
323
- const reason = 'token-ambiguous';
324
- this.captureLookupFailure(lookupKind, reason, diagnostics, startedAt);
325
- throw new UMPTokenLookupError(reason, diagnostics);
326
- }
327
- this.telemetry.capture({
328
- name: 'wallet-toolbox.ump.lookup.completed',
329
- component: 'wallet-toolbox.ump',
330
- severity: 'info',
331
- correlationId: diagnostics.correlationId,
332
- attributes: {
333
- lookupKind,
334
- result: 'found',
335
- durationMs: Date.now() - startedAt,
336
- ...this.lookupDiagnosticAttributes(diagnostics)
337
- }
338
- });
339
- return tokens[0];
340
- }
341
- emptyLookupDiagnostics(correlationId) {
342
- return {
343
- hostCount: 0,
344
- completedHosts: 0,
345
- successfulHosts: 0,
346
- emptyHosts: 0,
347
- failedHosts: 0,
348
- rejectedHosts: 0,
349
- freeformHosts: 0,
350
- outputCount: 0,
351
- ...(correlationId !== undefined ? { correlationId } : {})
352
- };
353
- }
354
- toLookupDiagnostics(resolution) {
355
- const progress = resolution.progress;
356
- return {
357
- hostCount: progress.hostCount,
358
- completedHosts: progress.completedHosts,
359
- successfulHosts: progress.successfulHosts,
360
- emptyHosts: progress.emptyHosts,
361
- failedHosts: progress.failedHosts,
362
- rejectedHosts: progress.rejectedHosts,
363
- freeformHosts: progress.freeformHosts,
364
- outputCount: resolution.answer.outputs.length,
365
- ...(progress.correlationId !== undefined ? { correlationId: progress.correlationId } : {})
366
- };
367
- }
368
- lookupDiagnosticAttributes(diagnostics) {
369
- return {
370
- hostCount: diagnostics.hostCount,
371
- completedHosts: diagnostics.completedHosts,
372
- successfulHosts: diagnostics.successfulHosts,
373
- emptyHosts: diagnostics.emptyHosts,
374
- failedHosts: diagnostics.failedHosts,
375
- rejectedHosts: diagnostics.rejectedHosts,
376
- freeformHosts: diagnostics.freeformHosts,
377
- outputCount: diagnostics.outputCount
378
- };
379
- }
380
- captureLookupFailure(lookupKind, reason, diagnostics, startedAt, error) {
381
- this.telemetry.capture({
382
- name: 'wallet-toolbox.ump.lookup.indeterminate',
383
- component: 'wallet-toolbox.ump',
384
- severity: 'warn',
385
- correlationId: diagnostics.correlationId,
386
- attributes: {
387
- lookupKind,
388
- reason,
389
- durationMs: Date.now() - startedAt,
390
- ...this.lookupDiagnosticAttributes(diagnostics)
391
- },
392
- error
393
- });
394
- }
395
- /**
396
- * Creates or updates (replaces) a UMP token on-chain. If `oldTokenToConsume` is provided,
397
- * it is spent in the same transaction that creates the new token output. The new token is
398
- * then broadcast and published under the `tm_users` topic using a SHIP broadcast, ensuring
399
- * overlay participants see the updated token.
400
- *
401
- * @param wallet The wallet used to build and sign the transaction (MUST be operating under the DEFAULT profile).
402
- * @param adminOriginator The domain/FQDN of the administrative originator (wallet operator).
403
- * @param token The new UMPToken to create on-chain.
404
- * @param oldTokenToConsume Optionally, an existing token to consume/spend in the same transaction.
405
- * @returns The outpoint of the newly created UMP token (e.g. "abcd1234...ef.0").
406
- */
407
- async buildAndSend(wallet, // This wallet MUST be the one built for the default profile
408
- adminOriginator, token, oldTokenToConsume) {
409
- // 1) Construct the data fields and PushDrop locking script for the new UMP token.
410
- const fields = this.buildUMPTokenFields(token);
411
- const script = await new sdk_1.PushDrop(wallet, adminOriginator).lock(fields, [2, 'admin user management token'], '1', 'self',
412
- /* forSelf= */ true,
413
- /* includeSignature= */ true);
414
- const tokenOutput = [{ lockingScript: script.toHex(), satoshis: 1, outputDescription: 'New UMP token output' }];
415
- // 2) Resolve the old-token input (if provided) and create the action.
416
- const { resolvedOldToken, inputToken } = await this.resolveOldTokenInput(oldTokenToConsume);
417
- const inputs = resolvedOldToken?.currentOutpoint
418
- ? [{ outpoint: resolvedOldToken.currentOutpoint, unlockingScriptLength: 73, inputDescription: 'Consume old UMP token' }]
419
- : [];
420
- const createResult = await this.createUMPAction(wallet, adminOriginator, inputs, tokenOutput, inputToken, resolvedOldToken);
421
- // 3) If the wallet fully processed it (no signable tx), broadcast and return.
422
- if (!createResult.signableTransaction) {
423
- return await this.broadcastFinishedUMPAction(createResult);
424
- }
425
- // 4) Sign and broadcast: with old token input or without.
426
- const reference = createResult.signableTransaction.reference;
427
- const partialTx = sdk_1.Transaction.fromBEEF(createResult.signableTransaction.tx);
428
- if (resolvedOldToken?.currentOutpoint) {
429
- return await this.signAndBroadcastWithOldToken(wallet, adminOriginator, reference, partialTx);
430
- }
431
- return await this.signAndBroadcastNewToken(wallet, adminOriginator, reference);
432
- }
433
- /** Assembles the ordered number[][] fields array from a UMPToken. */
434
- buildUMPTokenFields(token) {
435
- const fields = [];
436
- fields[0] = token.passwordSalt;
437
- fields[1] = token.passwordPresentationPrimary;
438
- fields[2] = token.passwordRecoveryPrimary;
439
- fields[3] = token.presentationRecoveryPrimary;
440
- fields[4] = token.passwordPrimaryPrivileged;
441
- fields[5] = token.presentationRecoveryPrivileged;
442
- fields[6] = token.presentationHash;
443
- fields[7] = token.recoveryHash;
444
- fields[8] = token.presentationKeyEncrypted;
445
- fields[9] = token.passwordKeyEncrypted;
446
- fields[10] = token.recoveryKeyEncrypted;
447
- if (token.profilesEncrypted != null)
448
- fields[11] = token.profilesEncrypted;
449
- if (token.umpVersion === 3 && token.passwordKdf != null) {
450
- const vi = (token.profilesEncrypted == null) ? 11 : 12;
451
- fields[vi] = [token.umpVersion];
452
- fields[vi + 1] = sdk_1.Utils.toArray(token.passwordKdf.algorithm, 'utf8');
453
- const kdfParams = { iterations: token.passwordKdf.iterations };
454
- if (token.passwordKdf.memoryKiB !== undefined)
455
- kdfParams.memoryKiB = token.passwordKdf.memoryKiB;
456
- if (token.passwordKdf.parallelism !== undefined)
457
- kdfParams.parallelism = token.passwordKdf.parallelism;
458
- if (token.passwordKdf.hashLength !== undefined)
459
- kdfParams.hashLength = token.passwordKdf.hashLength;
460
- fields[vi + 2] = sdk_1.Utils.toArray(JSON.stringify(kdfParams), 'utf8');
461
- }
462
- return fields;
463
- }
464
- /** Looks up the old token on the overlay; returns undefined resolved token if not found. */
465
- async resolveOldTokenInput(oldTokenToConsume) {
466
- if (!oldTokenToConsume?.currentOutpoint)
467
- return { resolvedOldToken: undefined, inputToken: undefined };
468
- const inputToken = await this.findByOutpoint(oldTokenToConsume.currentOutpoint);
469
- if (inputToken == null) {
470
- throw new Error('The previous UMP token could not be resolved; refusing to publish a duplicate token.');
471
- }
472
- return { resolvedOldToken: oldTokenToConsume, inputToken };
473
- }
474
- /** Creates the UMP action without dropping a required old-token input on failure. */
475
- async createUMPAction(wallet, adminOriginator, inputs, outputs, inputToken, resolvedOldToken) {
476
- try {
477
- return await wallet.createAction({
478
- description: (resolvedOldToken == null) ? 'Create new UMP token' : 'Renew UMP token (consume old, create new)',
479
- inputs,
480
- outputs,
481
- inputBEEF: inputToken?.beef,
482
- options: { randomizeOutputs: false, acceptDelayedBroadcast: false }
483
- }, adminOriginator);
484
- }
485
- catch (error) {
486
- this.telemetry.capture({
487
- name: 'wallet-toolbox.ump.action.failed',
488
- component: 'wallet-toolbox.ump',
489
- severity: 'error',
490
- attributes: {
491
- operation: resolvedOldToken == null ? 'create' : 'renew',
492
- oldTokenInputRequired: resolvedOldToken != null
493
- },
494
- error
495
- });
496
- throw error;
497
- }
498
- }
499
- /** Handles a fully-finalized (no signable tx) createAction result — broadcasts and returns outpoint. */
500
- async broadcastFinishedUMPAction(createResult) {
501
- const finalTxid = createResult.txid || (createResult.tx != null ? sdk_1.Transaction.fromAtomicBEEF(createResult.tx).id('hex') : undefined);
502
- if (!finalTxid)
503
- throw new Error('No signableTransaction and no final TX found.');
504
- if (createResult.tx == null)
505
- throw new Error('No final TX data to broadcast.');
506
- const broadcastTx = sdk_1.Transaction.fromAtomicBEEF(createResult.tx);
507
- const result = await this.broadcaster.broadcast(broadcastTx);
508
- this.assertSuccessfulBroadcast(result, 'create-finalized');
509
- return `${finalTxid}.0`;
510
- }
511
- /** Signs the old-token input and broadcasts — used during UMP token renewal. */
512
- async signAndBroadcastWithOldToken(wallet, adminOriginator, reference, partialTx) {
513
- const unlocker = new sdk_1.PushDrop(wallet, adminOriginator).unlock([2, 'admin user management token'], '1', 'self');
514
- const unlockingScript = await unlocker.sign(partialTx, 0);
515
- const signResult = await wallet.signAction({ reference, spends: { 0: { unlockingScript: unlockingScript.toHex() } } }, adminOriginator);
516
- const finalTxid = signResult.txid || ((signResult.tx == null) ? '' : sdk_1.Transaction.fromAtomicBEEF(signResult.tx).id('hex'));
517
- if (!finalTxid)
518
- throw new Error('Could not finalize transaction for renewed UMP token.');
519
- if (signResult.tx == null)
520
- throw new Error('Final transaction data missing after signing renewed UMP token.');
521
- const result = await this.broadcaster.broadcast(sdk_1.Transaction.fromAtomicBEEF(signResult.tx));
522
- this.assertSuccessfulBroadcast(result, 'renew');
523
- return `${finalTxid}.0`;
524
- }
525
- /** Signs without input spending and broadcasts — used when creating a brand-new UMP token. */
526
- async signAndBroadcastNewToken(wallet, adminOriginator, reference) {
527
- const signResult = await wallet.signAction({ reference, spends: {} }, adminOriginator);
528
- const finalTxid = signResult.txid || ((signResult.tx == null) ? '' : sdk_1.Transaction.fromAtomicBEEF(signResult.tx).id('hex'));
529
- if (!finalTxid)
530
- throw new Error('Failed to finalize new UMP token transaction.');
531
- if (signResult.tx == null)
532
- throw new Error('Final transaction data missing after signing new UMP token.');
533
- const result = await this.broadcaster.broadcast(sdk_1.Transaction.fromAtomicBEEF(signResult.tx));
534
- this.assertSuccessfulBroadcast(result, 'create');
535
- return `${finalTxid}.0`;
536
- }
537
- assertSuccessfulBroadcast(result, operation) {
538
- const succeeded = result.status === 'success';
539
- this.telemetry.capture({
540
- name: succeeded
541
- ? 'wallet-toolbox.ump.broadcast.completed'
542
- : 'wallet-toolbox.ump.broadcast.failed',
543
- component: 'wallet-toolbox.ump',
544
- severity: succeeded ? 'info' : 'error',
545
- attributes: {
546
- operation,
547
- outcome: result.status,
548
- ...(result.status === 'error' ? { code: result.code } : {})
549
- }
550
- });
551
- if (!succeeded) {
552
- throw new Error(`UMP token broadcast failed (${result.code}).`);
553
- }
554
- }
555
- /**
556
- * Attempts to parse a LookupAnswer from the UMP lookup service. If successful,
557
- * extracts the token fields from the resulting transaction and constructs
558
- * a UMPToken object.
559
- *
560
- * @param answer The LookupAnswer returned by a query to ls_users.
561
- * @returns The parsed UMPToken or `undefined` if none found/decodable.
562
- */
563
- parseLookupAnswer(answer) {
564
- return this.parseLookupAnswers(answer)[0];
565
- }
566
- parseLookupAnswers(answer) {
567
- if (answer.type !== 'output-list' || answer.outputs.length === 0)
568
- return [];
569
- const tokens = [];
570
- for (const output of answer.outputs) {
571
- const token = this.parseLookupOutput(output);
572
- if (token != null)
573
- tokens.push(token);
574
- }
575
- return tokens;
576
- }
577
- parseLookupOutput(output) {
578
- try {
579
- const tx = sdk_1.Transaction.fromBEEF(output.beef);
580
- const txOutput = tx.outputs[output.outputIndex];
581
- if (txOutput == null)
582
- return undefined;
583
- const decoded = sdk_1.PushDrop.decode(txOutput.lockingScript);
584
- if (decoded.fields == null || decoded.fields.length < 11 || decoded.fields.length > 16) {
585
- return undefined;
586
- }
587
- const protocolFields = stripVerifiedPushDropSignature(decoded.fields, decoded.lockingPublicKey);
588
- if (protocolFields.length < 11 ||
589
- protocolFields.slice(0, 11).some(field => field.length === 0 || field.length > exports.MAX_STATE_SNAPSHOT_BYTES)) {
590
- return undefined;
591
- }
592
- const hasV3MetadataWithProfiles = protocolFields.length >= 15 && protocolFields[12]?.length === 1 && protocolFields[12][0] === 3;
593
- const hasV3MetadataWithoutProfiles = protocolFields.length >= 14 && protocolFields[11]?.length === 1 && protocolFields[11][0] === 3;
594
- const kdfVersionFieldIndex = hasV3MetadataWithProfiles ? 12 : (hasV3MetadataWithoutProfiles ? 11 : -1);
595
- const token = {
596
- passwordSalt: protocolFields[0],
597
- passwordPresentationPrimary: protocolFields[1],
598
- passwordRecoveryPrimary: protocolFields[2],
599
- presentationRecoveryPrimary: protocolFields[3],
600
- passwordPrimaryPrivileged: protocolFields[4],
601
- presentationRecoveryPrivileged: protocolFields[5],
602
- presentationHash: protocolFields[6],
603
- recoveryHash: protocolFields[7],
604
- presentationKeyEncrypted: protocolFields[8],
605
- passwordKeyEncrypted: protocolFields[9],
606
- recoveryKeyEncrypted: protocolFields[10],
607
- currentOutpoint: `${tx.id('hex')}.${output.outputIndex}`
608
- };
609
- if (token.presentationHash.length !== 32 || token.recoveryHash.length !== 32)
610
- return undefined;
611
- const hasProfilesField = hasV3MetadataWithProfiles || (!hasV3MetadataWithoutProfiles && protocolFields[11] != null);
612
- if (hasProfilesField && protocolFields[11].length > 0) {
613
- if (protocolFields[11].length > exports.MAX_STATE_SNAPSHOT_BYTES)
614
- return undefined;
615
- token.profilesEncrypted = protocolFields[11];
616
- }
617
- if (kdfVersionFieldIndex !== -1) {
618
- const kdfAlgorithmField = protocolFields[kdfVersionFieldIndex + 1];
619
- const kdfParamsField = protocolFields[kdfVersionFieldIndex + 2];
620
- if (kdfAlgorithmField == null || kdfParamsField == null || kdfParamsField.length > 1024) {
621
- return undefined;
622
- }
623
- const kdfParams = JSON.parse(sdk_1.Utils.toUTF8(kdfParamsField));
624
- const passwordKdf = {
625
- algorithm: sdk_1.Utils.toUTF8(kdfAlgorithmField),
626
- iterations: kdfParams.iterations,
627
- memoryKiB: kdfParams.memoryKiB,
628
- parallelism: kdfParams.parallelism,
629
- hashLength: kdfParams.hashLength
630
- };
631
- if (!isValidKdfConfig(passwordKdf))
632
- return undefined;
633
- token.umpVersion = 3;
634
- token.passwordKdf = passwordKdf;
635
- }
636
- return token;
637
- }
638
- catch {
639
- return undefined;
640
- }
641
- }
642
- /**
643
- * Finds by outpoint for unlocking / spending previous tokens.
644
- * @param outpoint The outpoint we are searching by
645
- * @returns The result so that we can use it to unlock the transaction
646
- */
647
- async findByOutpoint(outpoint) {
648
- const correlationId = this.telemetry.enabled === true ? this.telemetry.createCorrelationId() : undefined;
649
- const startedAt = Date.now();
650
- let resolution;
651
- try {
652
- resolution = await this.resolver.queryDetailed({
653
- service: 'ls_users',
654
- query: {
655
- outpoint
656
- }
657
- }, undefined, {
658
- waitForAllHosts: true,
659
- correlationId
660
- });
661
- }
662
- catch (error) {
663
- const diagnostics = this.emptyLookupDiagnostics(correlationId);
664
- this.captureLookupFailure('outpoint', 'lookup-unavailable', diagnostics, startedAt, error);
665
- throw new UMPTokenLookupError('lookup-unavailable', diagnostics, { cause: error });
666
- }
667
- if (resolution.answer.outputs.length === 0) {
668
- const p = resolution.progress;
669
- const authoritative = p.isFinal &&
670
- p.hostCount > 0 &&
671
- p.completedHosts === p.hostCount &&
672
- p.successfulHosts === p.hostCount &&
673
- p.emptyHosts === p.hostCount &&
674
- p.failedHosts === 0 &&
675
- p.rejectedHosts === 0 &&
676
- p.freeformHosts === 0;
677
- if (!authoritative) {
678
- const diagnostics = this.toLookupDiagnostics(resolution);
679
- this.captureLookupFailure('outpoint', 'lookup-incomplete', diagnostics, startedAt);
680
- throw new UMPTokenLookupError('lookup-incomplete', diagnostics);
681
- }
682
- return undefined;
683
- }
684
- return resolution.answer.outputs[0];
685
- }
686
- }
687
- exports.OverlayUMPTokenInteractor = OverlayUMPTokenInteractor;
688
- /**
689
- * Manages a "CWI-style" wallet that uses a UMP token and a
690
- * multi-key authentication scheme (password, presentation key, and recovery key),
691
- * supporting multiple user profiles under a single account.
692
- */
693
- class CWIStyleWalletManager {
694
- /**
695
- * Whether the user is currently authenticated (i.e., root keys are available).
696
- */
697
- authenticated;
698
- /**
699
- * Resolves once the optional snapshot (if provided to the constructor) has been
700
- * fully loaded and the wallet is ready to accept calls.
701
- * When no snapshot is provided this resolves immediately.
702
- * Await `ready` before calling wallet methods after constructing with a snapshot.
703
- */
704
- get ready() {
705
- if (this._readyInit === undefined) {
706
- this._readyInit = this._init();
707
- }
708
- return this._readyInit;
709
- }
710
- _readyInit;
711
- _initSnapshot;
712
- /**
713
- * The domain name of the administrative originator (wallet operator / vendor, or your own).
714
- */
715
- adminOriginator;
716
- /**
717
- * The system that locates and publishes UMP tokens on-chain.
718
- */
719
- UMPTokenInteractor;
720
- /**
721
- * Privacy-bounded diagnostic channel for wallet state transitions.
722
- */
723
- telemetry;
724
- /**
725
- * A function called to persist the newly generated recovery key.
726
- * It should generally trigger a UI prompt where the user is asked to write it down.
727
- */
728
- recoveryKeySaver;
729
- /**
730
- * Asks the user to enter their password, for a given reason.
731
- * The test function can be used to see if the password is correct before resolving.
732
- * Only resolve with the correct password or reject with an error.
733
- * Resolving with an incorrect password will throw an error.
734
- */
735
- passwordRetriever;
736
- /**
737
- * Optional function to fund a new Wallet after the new-user flow.
738
- */
739
- newWalletFunder;
740
- /**
741
- * Builds the underlying wallet for a specific profile.
742
- */
743
- walletBuilder;
744
- /**
745
- * Current mode of authentication.
746
- */
747
- authenticationMode = 'presentation-key-and-password';
748
- /**
749
- * Indicates new user or existing user flow.
750
- */
751
- authenticationFlow = 'unknown';
752
- /**
753
- * The current UMP token in use.
754
- */
755
- currentUMPToken;
756
- /**
757
- * Temporarily retained presentation key.
758
- */
759
- presentationKey;
760
- /**
761
- * Temporarily retained recovery key.
762
- */
763
- recoveryKey;
764
- /**
765
- * The user's *root* primary key, derived from authentication factors.
766
- */
767
- rootPrimaryKey;
768
- /**
769
- * The currently active profile ID (null or DEFAULT_PROFILE_ID means default profile).
770
- */
771
- activeProfileId = exports.DEFAULT_PROFILE_ID;
772
- /**
773
- * List of loaded non-default profiles.
774
- */
775
- profiles = [];
776
- /**
777
- * The underlying wallet instance for the *active* profile.
778
- */
779
- underlying;
780
- /**
781
- * Privileged key manager associated with the *root* keys, aware of the active profile.
782
- */
783
- rootPrivilegedKeyManager;
784
- /**
785
- * KDF configuration for new UMP tokens. Defaults to Argon2id for v3 tokens.
786
- */
787
- kdfConfig;
788
- /**
789
- * Constructs a new CWIStyleWalletManager.
790
- *
791
- * @param adminOriginator The domain name of the administrative originator.
792
- * @param walletBuilder A function that can build an underlying wallet instance for a profile.
793
- * @param interactor An instance of UMPTokenInteractor.
794
- * @param recoveryKeySaver A function to persist a new recovery key.
795
- * @param passwordRetriever A function to request the user's password.
796
- * @param newWalletFunder Optional function to fund a new wallet.
797
- * @param stateSnapshot Optional previously saved state snapshot.
798
- * @param kdfConfig Optional KDF configuration for new UMP tokens.
799
- */
800
- constructor(adminOriginator, walletBuilder, interactor, recoveryKeySaver, passwordRetriever, newWalletFunder, stateSnapshot, kdfConfig, telemetry) {
801
- this.adminOriginator = adminOriginator;
802
- this.walletBuilder = walletBuilder;
803
- this.telemetry = new sdk_1.Telemetry(telemetry);
804
- this.UMPTokenInteractor = interactor ?? new OverlayUMPTokenInteractor(undefined, undefined, telemetry);
805
- this.recoveryKeySaver = recoveryKeySaver;
806
- this.passwordRetriever = passwordRetriever;
807
- this.authenticated = false;
808
- this.newWalletFunder = newWalletFunder;
809
- // Initialize KDF config with Argon2id defaults for v3 tokens
810
- const kdfAlgorithm = kdfConfig?.algorithm ?? 'argon2id';
811
- this.kdfConfig = {
812
- algorithm: kdfAlgorithm,
813
- iterations: kdfConfig?.iterations ??
814
- (kdfAlgorithm === 'argon2id' ? exports.ARGON2ID_DEFAULT_ITERATIONS : exports.PBKDF2_NUM_ROUNDS),
815
- memoryKiB: kdfConfig?.memoryKiB ?? exports.ARGON2ID_DEFAULT_MEMORY_KIB,
816
- parallelism: kdfConfig?.parallelism ?? exports.ARGON2ID_DEFAULT_PARALLELISM,
817
- hashLength: kdfConfig?.hashLength ?? exports.ARGON2ID_DEFAULT_HASH_LENGTH
818
- };
819
- if (!isValidKdfConfig(this.kdfConfig)) {
820
- throw new Error('Unsupported or unsafe KDF configuration.');
821
- }
822
- // Store snapshot for lazy init; callers await ready before calling wallet methods.
823
- this._initSnapshot = stateSnapshot;
824
- }
825
- async _init() {
826
- if (this._initSnapshot !== undefined) {
827
- this.telemetry.capture({
828
- name: 'wallet-toolbox.snapshot.initialization.started',
829
- component: 'wallet-toolbox.cwi-manager',
830
- severity: 'debug'
831
- });
832
- try {
833
- await this.loadSnapshot(this._initSnapshot);
834
- this.telemetry.capture({
835
- name: 'wallet-toolbox.snapshot.initialization.completed',
836
- component: 'wallet-toolbox.cwi-manager',
837
- severity: 'info'
838
- });
839
- }
840
- catch (error) {
841
- this.telemetry.capture({
842
- name: 'wallet-toolbox.snapshot.initialization.failed',
843
- component: 'wallet-toolbox.cwi-manager',
844
- severity: 'error',
845
- error
846
- });
847
- throw error;
848
- }
849
- }
850
- }
851
- // --- Authentication Methods ---
852
- /**
853
- * Provides the presentation key.
854
- */
855
- async providePresentationKey(key) {
856
- if (this.authenticated) {
857
- throw new Error('User is already authenticated');
858
- }
859
- if (this.authenticationMode === 'recovery-key-and-password') {
860
- throw new Error('Presentation key is not needed in this mode');
861
- }
862
- if (key.length !== 32 || key.some(byte => !Number.isInteger(byte) || byte < 0 || byte > 255)) {
863
- throw new TypeError('Presentation key must contain exactly 32 bytes.');
864
- }
865
- this.authenticationFlow = 'unknown';
866
- const hash = sdk_1.Hash.sha256(key);
867
- const startedAt = Date.now();
868
- this.telemetry.capture({
869
- name: 'wallet-toolbox.authentication.account-lookup.started',
870
- component: 'wallet-toolbox.cwi-manager',
871
- severity: 'debug',
872
- attributes: { lookupKind: 'presentation' }
873
- });
874
- let token;
875
- try {
876
- token = await this.UMPTokenInteractor.findByPresentationKeyHash(hash);
877
- }
878
- catch (error) {
879
- this.telemetry.capture({
880
- name: 'wallet-toolbox.authentication.account-lookup.failed',
881
- component: 'wallet-toolbox.cwi-manager',
882
- severity: 'warn',
883
- attributes: {
884
- lookupKind: 'presentation',
885
- durationMs: Date.now() - startedAt
886
- },
887
- error
888
- });
889
- throw error;
890
- }
891
- if (token == null) {
892
- // No token found -> New user
893
- this.authenticationFlow = 'new-user';
894
- this.presentationKey = key;
895
- }
896
- else {
897
- // Found token -> existing user
898
- this.authenticationFlow = 'existing-user';
899
- this.presentationKey = key;
900
- this.currentUMPToken = token;
901
- }
902
- this.telemetry.capture({
903
- name: 'wallet-toolbox.authentication.account-lookup.completed',
904
- component: 'wallet-toolbox.cwi-manager',
905
- severity: 'info',
906
- attributes: {
907
- lookupKind: 'presentation',
908
- accountStatus: this.authenticationFlow,
909
- durationMs: Date.now() - startedAt
910
- }
911
- });
912
- }
913
- /**
914
- * Provides the password.
915
- */
916
- async providePassword(password) {
917
- if (this.authenticated)
918
- throw new Error('User is already authenticated');
919
- if (this.authenticationMode === 'presentation-key-and-recovery-key') {
920
- throw new Error('Password is not needed in this mode');
921
- }
922
- if (this.authenticationFlow === 'unknown') {
923
- throw new Error('Determine account status with a presentation or recovery key before providing a password.');
924
- }
925
- if (this.authenticationFlow === 'existing-user') {
926
- await this.handleExistingUserPassword(password);
927
- }
928
- else {
929
- await this.handleNewUserPassword(password);
930
- }
931
- }
932
- /** Handles the password step for an existing user — derives keys, sets up infrastructure. */
933
- async handleExistingUserPassword(password) {
934
- if (this.currentUMPToken == null)
935
- throw new Error('Provide presentation or recovery key first.');
936
- const derivedPasswordKey = await derivePasswordKey(this.currentUMPToken, sdk_1.Utils.toArray(password, 'utf8'));
937
- let rootPrimaryKey;
938
- let rootPrivilegedKey;
939
- if (this.authenticationMode === 'presentation-key-and-password') {
940
- if (this.presentationKey == null)
941
- throw new Error('No presentation key found!');
942
- rootPrimaryKey = new sdk_1.SymmetricKey(this.XOR(this.presentationKey, derivedPasswordKey))
943
- .decrypt(this.currentUMPToken.passwordPresentationPrimary);
944
- }
945
- else {
946
- // 'recovery-key-and-password'
947
- if (this.recoveryKey == null)
948
- throw new Error('No recovery key found!');
949
- const primaryDecryptionKey = this.XOR(this.recoveryKey, derivedPasswordKey);
950
- rootPrimaryKey = new sdk_1.SymmetricKey(primaryDecryptionKey).decrypt(this.currentUMPToken.passwordRecoveryPrimary);
951
- rootPrivilegedKey = new sdk_1.SymmetricKey(this.XOR(rootPrimaryKey, derivedPasswordKey))
952
- .decrypt(this.currentUMPToken.passwordPrimaryPrivileged);
953
- }
954
- await this.setupRootInfrastructure(rootPrimaryKey, rootPrivilegedKey);
955
- await this.switchProfile(this.activeProfileId);
956
- }
957
- /** Handles the password step for a new user — generates keys, builds UMP token, publishes on-chain. */
958
- async handleNewUserPassword(password) {
959
- if (this.authenticationMode !== 'presentation-key-and-password') {
960
- throw new Error('New-user flow requires presentation key and password mode.');
961
- }
962
- if (this.presentationKey == null)
963
- throw new Error('No presentation key provided for new-user flow.');
964
- // Generate new keys/salt
965
- const recoveryKey = (0, sdk_1.Random)(32);
966
- await this.recoveryKeySaver(recoveryKey);
967
- const passwordSalt = (0, sdk_1.Random)(32);
968
- const passwordKey = await derivePasswordKey({ passwordSalt, passwordKdf: this.kdfConfig }, sdk_1.Utils.toArray(password, 'utf8'));
969
- const rootPrimaryKey = (0, sdk_1.Random)(32);
970
- const rootPrivilegedKey = (0, sdk_1.Random)(32);
971
- // Build XOR-combined symmetric keys
972
- const presentationPassword = new sdk_1.SymmetricKey(this.XOR(this.presentationKey, passwordKey));
973
- const presentationRecovery = new sdk_1.SymmetricKey(this.XOR(this.presentationKey, recoveryKey));
974
- const recoveryPassword = new sdk_1.SymmetricKey(this.XOR(recoveryKey, passwordKey));
975
- const primaryPassword = new sdk_1.SymmetricKey(this.XOR(rootPrimaryKey, passwordKey));
976
- const tempPrivilegedKeyManager = new PrivilegedKeyManager_1.PrivilegedKeyManager(async () => new sdk_1.PrivateKey(rootPrivilegedKey));
977
- const wrapKey = async (plaintext) => (await tempPrivilegedKeyManager.encrypt({ plaintext, protocolID: [2, 'admin key wrapping'], keyID: '1' })).ciphertext;
978
- // Build new UMP token (v3 with KDF metadata, no profiles initially)
979
- const newToken = {
980
- passwordSalt,
981
- passwordPresentationPrimary: presentationPassword.encrypt(rootPrimaryKey),
982
- passwordRecoveryPrimary: recoveryPassword.encrypt(rootPrimaryKey),
983
- presentationRecoveryPrimary: presentationRecovery.encrypt(rootPrimaryKey),
984
- passwordPrimaryPrivileged: primaryPassword.encrypt(rootPrivilegedKey),
985
- presentationRecoveryPrivileged: presentationRecovery.encrypt(rootPrivilegedKey),
986
- presentationHash: sdk_1.Hash.sha256(this.presentationKey),
987
- recoveryHash: sdk_1.Hash.sha256(recoveryKey),
988
- presentationKeyEncrypted: await wrapKey(this.presentationKey),
989
- passwordKeyEncrypted: await wrapKey(passwordKey),
990
- recoveryKeyEncrypted: await wrapKey(recoveryKey),
991
- profilesEncrypted: undefined,
992
- umpVersion: 3,
993
- passwordKdf: this.kdfConfig
994
- };
995
- this.currentUMPToken = newToken;
996
- await this.setupRootInfrastructure(rootPrimaryKey);
997
- await this.switchProfile(exports.DEFAULT_PROFILE_ID);
998
- // Fund the *default* wallet if funder provided
999
- if ((this.newWalletFunder != null) && (this.underlying != null)) {
1000
- try {
1001
- await this.newWalletFunder(this.presentationKey, this.underlying, this.adminOriginator);
1002
- }
1003
- catch (error) {
1004
- this.telemetry.capture({
1005
- name: 'wallet-toolbox.authentication.new-wallet-funding.failed',
1006
- component: 'wallet-toolbox.cwi-manager',
1007
- severity: 'error',
1008
- error: new Error('New wallet funding failed.')
1009
- });
1010
- const message = error instanceof Error ? error.message : String(error);
1011
- throw new Error(`Failed to fund new wallet before publishing UMP token: ${message}`, { cause: error });
1012
- }
1013
- }
1014
- if (this.underlying == null)
1015
- throw new Error('Default profile wallet not built before attempting to publish UMP token.');
1016
- this.currentUMPToken.currentOutpoint = await this.UMPTokenInteractor.buildAndSend(this.underlying, this.adminOriginator, newToken);
1017
- }
1018
- /**
1019
- * Provides the recovery key.
1020
- */
1021
- async provideRecoveryKey(recoveryKey) {
1022
- if (this.authenticated) {
1023
- throw new Error('Already authenticated');
1024
- }
1025
- if (this.authenticationFlow === 'new-user' && this.authenticationMode !== 'recovery-key-and-password') {
1026
- throw new Error('Do not submit recovery key in new-user flow');
1027
- }
1028
- if (this.authenticationMode === 'presentation-key-and-password') {
1029
- throw new Error('No recovery key required in this mode');
1030
- }
1031
- if (recoveryKey.length !== 32 || recoveryKey.some(byte => !Number.isInteger(byte) || byte < 0 || byte > 255)) {
1032
- throw new TypeError('Recovery key must contain exactly 32 bytes.');
1033
- }
1034
- if (this.authenticationMode === 'recovery-key-and-password') {
1035
- // Wait for password
1036
- const hash = sdk_1.Hash.sha256(recoveryKey);
1037
- const token = await this.UMPTokenInteractor.findByRecoveryKeyHash(hash);
1038
- if (token == null)
1039
- throw new Error('No user found with this recovery key');
1040
- this.authenticationFlow = 'existing-user';
1041
- this.recoveryKey = recoveryKey;
1042
- this.currentUMPToken = token;
1043
- }
1044
- else {
1045
- // 'presentation-key-and-recovery-key'
1046
- if (this.presentationKey == null)
1047
- throw new Error('Provide the presentation key first');
1048
- if (this.currentUMPToken == null)
1049
- throw new Error('Current UMP token not found');
1050
- const xorKey = this.XOR(this.presentationKey, recoveryKey);
1051
- const rootPrimaryKey = new sdk_1.SymmetricKey(xorKey).decrypt(this.currentUMPToken.presentationRecoveryPrimary);
1052
- const rootPrivilegedKey = new sdk_1.SymmetricKey(xorKey).decrypt(this.currentUMPToken.presentationRecoveryPrivileged);
1053
- // Build root infrastructure, load profiles, switch to default
1054
- await this.setupRootInfrastructure(rootPrimaryKey, rootPrivilegedKey);
1055
- await this.switchProfile(this.activeProfileId);
1056
- }
1057
- }
1058
- // --- State Management Methods ---
1059
- /**
1060
- * Saves the current wallet state (root key, UMP token, active profile) into an encrypted snapshot.
1061
- * Version 2 format: [1 byte version=2] + [32 byte snapshot key] + [16 byte activeProfileId] + [encrypted payload]
1062
- * Encrypted Payload: [32 byte rootPrimaryKey] + [varint token length + serialized UMP token]
1063
- *
1064
- * @returns Encrypted snapshot bytes.
1065
- */
1066
- saveSnapshot() {
1067
- if ((this.rootPrimaryKey == null) || (this.currentUMPToken == null)) {
1068
- throw new Error('No root primary key or current UMP token set');
1069
- }
1070
- const snapshotKey = (0, sdk_1.Random)(32);
1071
- const snapshotPreimageWriter = new sdk_1.Utils.Writer();
1072
- // Write root primary key
1073
- snapshotPreimageWriter.write(this.rootPrimaryKey);
1074
- // Write serialized UMP token (must have outpoint)
1075
- if (!this.currentUMPToken.currentOutpoint) {
1076
- throw new Error('UMP token cannot be saved without a current outpoint.');
1077
- }
1078
- const serializedToken = this.serializeUMPToken(this.currentUMPToken);
1079
- snapshotPreimageWriter.writeVarIntNum(serializedToken.length);
1080
- snapshotPreimageWriter.write(serializedToken);
1081
- // Encrypt the payload
1082
- const snapshotPreimage = snapshotPreimageWriter.toArray();
1083
- const snapshotPayload = new sdk_1.SymmetricKey(snapshotKey).encrypt(snapshotPreimage);
1084
- // Build final snapshot (Version 2)
1085
- const snapshotWriter = new sdk_1.Utils.Writer();
1086
- snapshotWriter.writeUInt8(2); // Version
1087
- snapshotWriter.write(snapshotKey);
1088
- snapshotWriter.write(this.activeProfileId); // Active profile ID
1089
- snapshotWriter.write(snapshotPayload); // Encrypted data
1090
- const snapshot = snapshotWriter.toArray();
1091
- if (snapshot.length > exports.MAX_STATE_SNAPSHOT_BYTES) {
1092
- throw new Error('Snapshot exceeds the maximum supported size.');
1093
- }
1094
- this.telemetry.capture({
1095
- name: 'wallet-toolbox.snapshot.saved',
1096
- component: 'wallet-toolbox.cwi-manager',
1097
- severity: 'info',
1098
- attributes: {
1099
- formatVersion: 2,
1100
- profileCount: this.profiles.length
1101
- }
1102
- });
1103
- return snapshot;
1104
- }
1105
- /**
1106
- * Loads a previously saved state snapshot. Restores root key, UMP token, profiles, and active profile.
1107
- * Handles Version 1 (legacy) and Version 2 formats.
1108
- *
1109
- * @param snapshot Encrypted snapshot bytes.
1110
- */
1111
- async loadSnapshot(snapshot) {
1112
- try {
1113
- if (snapshot.length === 0 ||
1114
- snapshot.length > exports.MAX_STATE_SNAPSHOT_BYTES ||
1115
- snapshot.some(byte => !Number.isInteger(byte) || byte < 0 || byte > 255)) {
1116
- throw new Error('Snapshot is empty, oversized, or contains invalid bytes.');
1117
- }
1118
- const reader = new sdk_1.Utils.Reader(snapshot);
1119
- const version = reader.readUInt8();
1120
- let snapshotKey;
1121
- let encryptedPayload;
1122
- let activeProfileId = exports.DEFAULT_PROFILE_ID; // Default for V1
1123
- if (version === 1) {
1124
- snapshotKey = reader.read(32);
1125
- encryptedPayload = reader.read();
1126
- }
1127
- else if (version === 2) {
1128
- snapshotKey = reader.read(32);
1129
- activeProfileId = reader.read(16); // Read active profile ID
1130
- encryptedPayload = reader.read();
1131
- }
1132
- else {
1133
- throw new Error(`Unsupported snapshot version: ${version}`);
1134
- }
1135
- // Decrypt payload
1136
- const decryptedPayload = new sdk_1.SymmetricKey(snapshotKey).decrypt(encryptedPayload);
1137
- const payloadReader = new sdk_1.Utils.Reader(decryptedPayload);
1138
- // Read root primary key
1139
- const rootPrimaryKey = payloadReader.read(32);
1140
- // Read serialized UMP token
1141
- const tokenLen = payloadReader.readVarIntNum();
1142
- const tokenBytes = payloadReader.read(tokenLen);
1143
- const token = this.deserializeUMPToken(tokenBytes);
1144
- // Assign loaded data
1145
- this.currentUMPToken = token;
1146
- // Setup root infrastructure, load profiles, and switch to the loaded active profile
1147
- await this.setupRootInfrastructure(rootPrimaryKey); // Will automatically load profiles
1148
- await this.switchProfile(activeProfileId); // Switch to the profile saved in the snapshot
1149
- this.authenticationFlow = 'existing-user'; // Loading implies existing user
1150
- this.telemetry.capture({
1151
- name: 'wallet-toolbox.snapshot.loaded',
1152
- component: 'wallet-toolbox.cwi-manager',
1153
- severity: 'info',
1154
- attributes: {
1155
- formatVersion: version,
1156
- profileCount: this.profiles.length
1157
- }
1158
- });
1159
- }
1160
- catch (error) {
1161
- this.destroy(); // Clear state on error
1162
- this.telemetry.capture({
1163
- name: 'wallet-toolbox.snapshot.load-failed',
1164
- component: 'wallet-toolbox.cwi-manager',
1165
- severity: 'error',
1166
- error
1167
- });
1168
- const message = error instanceof Error ? error.message : 'Unknown error';
1169
- throw new Error(`Failed to load snapshot: ${message}`, { cause: error });
1170
- }
1171
- }
1172
- async syncUMPToken() {
1173
- if (!this.authenticated || (this.currentUMPToken == null) || (this.rootPrimaryKey == null)) {
1174
- throw new Error('Wallet not authenticated or missing UMP token.');
1175
- }
1176
- const currentToken = this.currentUMPToken;
1177
- let refreshed;
1178
- if (currentToken.presentationHash && (currentToken.presentationHash.length > 0)) {
1179
- refreshed = await this.UMPTokenInteractor.findByPresentationKeyHash(currentToken.presentationHash);
1180
- }
1181
- if ((refreshed == null) && currentToken.recoveryHash && (currentToken.recoveryHash.length > 0)) {
1182
- refreshed = await this.UMPTokenInteractor.findByRecoveryKeyHash(currentToken.recoveryHash);
1183
- }
1184
- if (refreshed == null) {
1185
- return false;
1186
- }
1187
- if (refreshed.currentOutpoint &&
1188
- currentToken.currentOutpoint &&
1189
- refreshed.currentOutpoint === currentToken.currentOutpoint) {
1190
- return false;
1191
- }
1192
- this.currentUMPToken = refreshed;
1193
- await this.setupRootInfrastructure(this.rootPrimaryKey);
1194
- this.saveSnapshot();
1195
- return true;
1196
- }
1197
- /**
1198
- * Destroys the wallet state, clearing keys, tokens, and profiles.
1199
- */
1200
- destroy() {
1201
- this.underlying = undefined;
1202
- this.rootPrivilegedKeyManager = undefined;
1203
- this.authenticated = false;
1204
- this.rootPrimaryKey = undefined;
1205
- this.currentUMPToken = undefined;
1206
- this.presentationKey = undefined;
1207
- this.recoveryKey = undefined;
1208
- this.profiles = [];
1209
- this.activeProfileId = exports.DEFAULT_PROFILE_ID;
1210
- this.authenticationMode = 'presentation-key-and-password';
1211
- this.authenticationFlow = 'unknown';
1212
- }
1213
- // --- Profile Management Methods ---
1214
- /**
1215
- * Lists all available profiles, including the default profile.
1216
- * @returns Array of profile info objects, including an 'active' flag.
1217
- */
1218
- listProfiles() {
1219
- if (!this.authenticated) {
1220
- throw new Error('Not authenticated.');
1221
- }
1222
- const profileList = [
1223
- // Default profile
1224
- {
1225
- id: exports.DEFAULT_PROFILE_ID,
1226
- name: 'default',
1227
- createdAt: null, // Default profile doesn't have a creation timestamp in the same way
1228
- active: this.activeProfileId.every(x => x === 0),
1229
- identityKey: new sdk_1.PrivateKey(this.rootPrimaryKey).toPublicKey().toString()
1230
- },
1231
- // Other profiles
1232
- ...this.profiles.map(p => ({
1233
- id: p.id,
1234
- name: p.name,
1235
- createdAt: p.createdAt,
1236
- active: this.activeProfileId.every((x, i) => x === p.id[i]),
1237
- identityKey: new sdk_1.PrivateKey(this.XOR(this.rootPrimaryKey, p.primaryPad)).toPublicKey().toString()
1238
- }))
1239
- ];
1240
- return profileList;
1241
- }
1242
- /**
1243
- * Adds a new profile with the given name.
1244
- * Generates necessary pads and updates the UMP token.
1245
- * Does not switch to the new profile automatically.
1246
- *
1247
- * @param name The desired name for the new profile.
1248
- * @returns The ID of the newly created profile.
1249
- */
1250
- async addProfile(name) {
1251
- if (!this.authenticated || (this.rootPrimaryKey == null) || (this.currentUMPToken == null) || (this.rootPrivilegedKeyManager == null)) {
1252
- throw new Error('Wallet not fully initialized or authenticated.');
1253
- }
1254
- // Ensure name is unique (including 'default')
1255
- if (name === 'default' || this.profiles.some(p => p.name.toLowerCase() === name.toLowerCase())) {
1256
- throw new Error(`Profile name "${name}" is already in use.`);
1257
- }
1258
- const newProfile = {
1259
- name,
1260
- id: (0, sdk_1.Random)(16),
1261
- primaryPad: (0, sdk_1.Random)(32),
1262
- privilegedPad: (0, sdk_1.Random)(32),
1263
- createdAt: Math.floor(Date.now() / 1000)
1264
- };
1265
- this.profiles.push(newProfile);
1266
- // Update the UMP token with the new profile list
1267
- await this.updateAuthFactors(this.currentUMPToken.passwordSalt,
1268
- // Need to re-derive/decrypt factors needed for re-encryption
1269
- await this.getFactor('passwordKey'), await this.getFactor('presentationKey'), await this.getFactor('recoveryKey'), this.rootPrimaryKey, await this.getFactor('privilegedKey'), // Get ROOT privileged key
1270
- this.profiles // Pass the updated profile list
1271
- );
1272
- return newProfile.id;
1273
- }
1274
- /**
1275
- * Deletes a profile by its ID.
1276
- * Cannot delete the default profile. If the active profile is deleted,
1277
- * it switches back to the default profile.
1278
- *
1279
- * @param profileId The 16-byte ID of the profile to delete.
1280
- */
1281
- async deleteProfile(profileId) {
1282
- if (!this.authenticated || (this.rootPrimaryKey == null) || (this.currentUMPToken == null) || (this.rootPrivilegedKeyManager == null)) {
1283
- throw new Error('Wallet not fully initialized or authenticated.');
1284
- }
1285
- if (profileId.every(x => x === 0)) {
1286
- throw new Error('Cannot delete the default profile.');
1287
- }
1288
- const profileIndex = this.profiles.findIndex(p => p.id.every((x, i) => x === profileId[i]));
1289
- if (profileIndex === -1) {
1290
- throw new Error('Profile not found.');
1291
- }
1292
- // Remove the profile
1293
- this.profiles.splice(profileIndex, 1);
1294
- // If the deleted profile was active, switch to default
1295
- if (this.activeProfileId.every((x, i) => x === profileId[i])) {
1296
- await this.switchProfile(exports.DEFAULT_PROFILE_ID); // This rebuilds the wallet
1297
- }
1298
- // Update the UMP token
1299
- await this.updateAuthFactors(this.currentUMPToken.passwordSalt, await this.getFactor('passwordKey'), await this.getFactor('presentationKey'), await this.getFactor('recoveryKey'), this.rootPrimaryKey, await this.getFactor('privilegedKey'), // Get ROOT privileged key
1300
- this.profiles // Pass updated list
1301
- );
1302
- }
1303
- /**
1304
- * Switches the active profile. This re-derives keys and rebuilds the underlying wallet.
1305
- *
1306
- * @param profileId The 16-byte ID of the profile to switch to (use DEFAULT_PROFILE_ID for default).
1307
- */
1308
- async switchProfile(profileId) {
1309
- if (!this.authenticated || (this.rootPrimaryKey == null) || (this.rootPrivilegedKeyManager == null)) {
1310
- throw new Error('Cannot switch profile: Wallet not authenticated or root keys missing.');
1311
- }
1312
- let profilePrimaryKey;
1313
- let profilePrivilegedPad; // Pad for the target profile
1314
- if (profileId.every(x => x === 0)) {
1315
- // Switching to default profile
1316
- profilePrimaryKey = this.rootPrimaryKey;
1317
- profilePrivilegedPad = undefined; // No pad for default
1318
- this.activeProfileId = exports.DEFAULT_PROFILE_ID;
1319
- }
1320
- else {
1321
- // Switching to a non-default profile
1322
- const profile = this.profiles.find(p => p.id.every((x, i) => x === profileId[i]));
1323
- if (profile == null) {
1324
- throw new Error('Profile not found.');
1325
- }
1326
- profilePrimaryKey = this.XOR(this.rootPrimaryKey, profile.primaryPad);
1327
- profilePrivilegedPad = profile.privilegedPad;
1328
- this.activeProfileId = profileId;
1329
- }
1330
- // Create a *profile-specific* PrivilegedKeyManager.
1331
- // It uses the ROOT manager internally but applies the profile's pad.
1332
- const profilePrivilegedKeyManager = new PrivilegedKeyManager_1.PrivilegedKeyManager(async (reason) => {
1333
- // Request the ROOT privileged key using the root manager
1334
- const rootPrivileged = await this.rootPrivilegedKeyManager.getPrivilegedKey(reason);
1335
- const rootPrivilegedBytes = rootPrivileged.toArray();
1336
- // Apply the profile's pad if applicable
1337
- const profilePrivilegedBytes = (profilePrivilegedPad == null)
1338
- ? rootPrivilegedBytes
1339
- : this.XOR(rootPrivilegedBytes, profilePrivilegedPad);
1340
- return new sdk_1.PrivateKey(profilePrivilegedBytes);
1341
- });
1342
- // Build the underlying wallet for the specific profile
1343
- this.underlying = await this.walletBuilder(profilePrimaryKey, profilePrivilegedKeyManager, // Pass the profile-specific manager
1344
- this.activeProfileId // Pass the ID of the profile being activated
1345
- );
1346
- }
1347
- // --- Key Management Methods ---
1348
- /**
1349
- * Changes the user's password. Re-wraps keys and updates the UMP token.
1350
- */
1351
- async changePassword(newPassword) {
1352
- if (!this.authenticated || (this.currentUMPToken == null) || (this.rootPrimaryKey == null) || (this.rootPrivilegedKeyManager == null)) {
1353
- throw new Error('Not authenticated or missing required data.');
1354
- }
1355
- const passwordSalt = (0, sdk_1.Random)(32);
1356
- // Preserve current token's KDF metadata (or use manager's kdfConfig for legacy tokens)
1357
- const kdfToUse = this.currentUMPToken.passwordKdf ?? this.kdfConfig;
1358
- const tempTokenForKdf = {
1359
- passwordSalt,
1360
- passwordKdf: kdfToUse
1361
- };
1362
- const newPasswordKey = await derivePasswordKey(tempTokenForKdf, sdk_1.Utils.toArray(newPassword, 'utf8'));
1363
- // Decrypt existing factors needed for re-encryption, using the *root* privileged key manager
1364
- const recoveryKey = await this.getFactor('recoveryKey');
1365
- const presentationKey = await this.getFactor('presentationKey');
1366
- const rootPrivilegedKey = await this.getFactor('privilegedKey'); // Get ROOT privileged key
1367
- await this.updateAuthFactors(passwordSalt, newPasswordKey, presentationKey, recoveryKey, this.rootPrimaryKey, rootPrivilegedKey, // Pass the explicitly fetched root key
1368
- this.profiles // Preserve existing profiles
1369
- );
1370
- }
1371
- /**
1372
- * Retrieves the current recovery key. Requires privileged access.
1373
- */
1374
- async getRecoveryKey() {
1375
- if (!this.authenticated || (this.currentUMPToken == null) || (this.rootPrivilegedKeyManager == null)) {
1376
- throw new Error('Not authenticated or missing required data.');
1377
- }
1378
- return await this.getFactor('recoveryKey');
1379
- }
1380
- /**
1381
- * Changes the user's recovery key. Prompts user to save the new key.
1382
- */
1383
- async changeRecoveryKey() {
1384
- if (!this.authenticated || (this.currentUMPToken == null) || (this.rootPrimaryKey == null) || (this.rootPrivilegedKeyManager == null)) {
1385
- throw new Error('Not authenticated or missing required data.');
1386
- }
1387
- // Decrypt existing factors needed
1388
- const passwordKey = await this.getFactor('passwordKey');
1389
- const presentationKey = await this.getFactor('presentationKey');
1390
- const rootPrivilegedKey = await this.getFactor('privilegedKey'); // Get ROOT privileged key
1391
- // Generate and save new recovery key
1392
- const newRecoveryKey = (0, sdk_1.Random)(32);
1393
- await this.recoveryKeySaver(newRecoveryKey);
1394
- await this.updateAuthFactors(this.currentUMPToken.passwordSalt, passwordKey, presentationKey, newRecoveryKey, // Use the new key
1395
- this.rootPrimaryKey, rootPrivilegedKey, this.profiles // Preserve profiles
1396
- );
1397
- }
1398
- /**
1399
- * Changes the user's presentation key.
1400
- */
1401
- async changePresentationKey(newPresentationKey) {
1402
- if (!this.authenticated || (this.currentUMPToken == null) || (this.rootPrimaryKey == null) || (this.rootPrivilegedKeyManager == null)) {
1403
- throw new Error('Not authenticated or missing required data.');
1404
- }
1405
- if (newPresentationKey.length !== 32) {
1406
- throw new Error('Presentation key must be 32 bytes.');
1407
- }
1408
- // Decrypt existing factors
1409
- const recoveryKey = await this.getFactor('recoveryKey');
1410
- const passwordKey = await this.getFactor('passwordKey');
1411
- const rootPrivilegedKey = await this.getFactor('privilegedKey'); // Get ROOT privileged key
1412
- await this.updateAuthFactors(this.currentUMPToken.passwordSalt, passwordKey, newPresentationKey, // Use the new key
1413
- recoveryKey, this.rootPrimaryKey, rootPrivilegedKey, this.profiles // Preserve profiles
1414
- );
1415
- // Update the temporarily stored key if it was set
1416
- if (this.presentationKey != null) {
1417
- this.presentationKey = newPresentationKey;
1418
- }
1419
- }
1420
- // --- Internal Helper Methods ---
1421
- /**
1422
- * Performs XOR operation on two byte arrays.
1423
- */
1424
- XOR(n1, n2) {
1425
- if (n1.length !== n2.length) {
1426
- // Provide more context in error
1427
- throw new Error(`XOR length mismatch: ${n1.length} vs ${n2.length}`);
1428
- }
1429
- const r = new Array(n1.length);
1430
- for (let i = 0; i < n1.length; i++) {
1431
- r[i] = n1[i] ^ n2[i];
1432
- }
1433
- return r;
1434
- }
1435
- /**
1436
- * Helper to decrypt a specific factor (key) stored encrypted in the UMP token.
1437
- * Requires the root privileged key manager.
1438
- * @param factorName Name of the factor to decrypt ('passwordKey', 'presentationKey', 'recoveryKey', 'privilegedKey').
1439
- * @param getRoot If true and factorName is 'privilegedKey', returns the root privileged key bytes directly.
1440
- * @returns The decrypted key bytes.
1441
- */
1442
- async getFactor(factorName) {
1443
- if (!this.authenticated || (this.currentUMPToken == null) || (this.rootPrivilegedKeyManager == null)) {
1444
- throw new Error(`Cannot get factor "${factorName}": Wallet not ready.`);
1445
- }
1446
- const protocolID = [2, 'admin key wrapping']; // Protocol used for encrypting factors
1447
- const keyID = '1'; // Key ID used
1448
- try {
1449
- switch (factorName) {
1450
- case 'passwordKey':
1451
- return (await this.rootPrivilegedKeyManager.decrypt({
1452
- ciphertext: this.currentUMPToken.passwordKeyEncrypted,
1453
- protocolID,
1454
- keyID
1455
- })).plaintext;
1456
- case 'presentationKey':
1457
- return (await this.rootPrivilegedKeyManager.decrypt({
1458
- ciphertext: this.currentUMPToken.presentationKeyEncrypted,
1459
- protocolID,
1460
- keyID
1461
- })).plaintext;
1462
- case 'recoveryKey':
1463
- return (await this.rootPrivilegedKeyManager.decrypt({
1464
- ciphertext: this.currentUMPToken.recoveryKeyEncrypted,
1465
- protocolID,
1466
- keyID
1467
- })).plaintext;
1468
- case 'privilegedKey': {
1469
- // This needs careful handling based on whether the ROOT or PROFILE key is needed.
1470
- // This helper is mostly used for UMP updates, which need the ROOT key.
1471
- // We retrieve the PrivateKey object first.
1472
- const pk = await this.rootPrivilegedKeyManager.getPrivilegedKey('UMP token update', true); // Force retrieval of root key
1473
- return pk.toArray(); // Return bytes
1474
- }
1475
- default:
1476
- throw new Error(`Unknown factor name: ${factorName}`);
1477
- }
1478
- }
1479
- catch (error) {
1480
- this.telemetry.capture({
1481
- name: 'wallet-toolbox.authentication.factor-decryption.failed',
1482
- component: 'wallet-toolbox.cwi-manager',
1483
- severity: 'error',
1484
- attributes: { factor: factorName },
1485
- error
1486
- });
1487
- const message = error instanceof Error ? error.message : 'Unknown error';
1488
- throw new Error(`Failed to decrypt factor "${factorName}": ${message}`, { cause: error });
1489
- }
1490
- }
1491
- /**
1492
- * Recomputes UMP token fields with updated factors and profiles, then publishes the update.
1493
- * This operation requires the *root* privileged key and the *default* profile wallet.
1494
- */
1495
- async updateAuthFactors(passwordSalt, passwordKey, presentationKey, recoveryKey, rootPrimaryKey, rootPrivilegedKey, // Explicitly pass the root key bytes
1496
- profiles // Pass current/new profiles list
1497
- ) {
1498
- if (!this.authenticated || (this.rootPrimaryKey == null) || (this.currentUMPToken == null)) {
1499
- throw new Error('Wallet is not properly authenticated or missing data for update.');
1500
- }
1501
- // Ensure we have the OLD token to consume
1502
- const oldTokenToConsume = { ...this.currentUMPToken };
1503
- if (!oldTokenToConsume.currentOutpoint) {
1504
- throw new Error('Cannot update UMP token: Old token has no outpoint.');
1505
- }
1506
- // Derive symmetrical encryption keys using XOR for the *root* keys
1507
- const presentationPassword = new sdk_1.SymmetricKey(this.XOR(presentationKey, passwordKey));
1508
- const presentationRecovery = new sdk_1.SymmetricKey(this.XOR(presentationKey, recoveryKey));
1509
- const recoveryPassword = new sdk_1.SymmetricKey(this.XOR(recoveryKey, passwordKey));
1510
- const primaryPassword = new sdk_1.SymmetricKey(this.XOR(rootPrimaryKey, passwordKey)); // Use rootPrimaryKey
1511
- // Build a temporary privileged key manager using the explicit ROOT privileged key
1512
- const tempRootPrivilegedKeyManager = new PrivilegedKeyManager_1.PrivilegedKeyManager(async () => new sdk_1.PrivateKey(rootPrivilegedKey));
1513
- // Encrypt profiles if provided
1514
- let profilesEncrypted;
1515
- if ((profiles != null) && profiles.length > 0) {
1516
- const profilesJson = JSON.stringify(profiles);
1517
- const profilesBytes = sdk_1.Utils.toArray(profilesJson, 'utf8');
1518
- profilesEncrypted = new sdk_1.SymmetricKey(rootPrimaryKey).encrypt(profilesBytes);
1519
- }
1520
- // Construct the new UMP token data.
1521
- // IMPORTANT: For non-password updates (e.g. add/remove profile), preserve legacy
1522
- // KDF layout exactly. Upgrading legacy tokens to v3 here would require re-deriving
1523
- // passwordKey from plaintext password, which we do not have in this code path.
1524
- const kdfMetadata = this.currentUMPToken.passwordKdf;
1525
- const newTokenData = {
1526
- passwordSalt,
1527
- passwordPresentationPrimary: presentationPassword.encrypt(rootPrimaryKey),
1528
- passwordRecoveryPrimary: recoveryPassword.encrypt(rootPrimaryKey),
1529
- presentationRecoveryPrimary: presentationRecovery.encrypt(rootPrimaryKey),
1530
- passwordPrimaryPrivileged: primaryPassword.encrypt(rootPrivilegedKey),
1531
- presentationRecoveryPrivileged: presentationRecovery.encrypt(rootPrivilegedKey),
1532
- presentationHash: sdk_1.Hash.sha256(presentationKey),
1533
- recoveryHash: sdk_1.Hash.sha256(recoveryKey),
1534
- presentationKeyEncrypted: (await tempRootPrivilegedKeyManager.encrypt({
1535
- plaintext: presentationKey,
1536
- protocolID: [2, 'admin key wrapping'],
1537
- keyID: '1'
1538
- })).ciphertext,
1539
- passwordKeyEncrypted: (await tempRootPrivilegedKeyManager.encrypt({
1540
- plaintext: passwordKey,
1541
- protocolID: [2, 'admin key wrapping'],
1542
- keyID: '1'
1543
- })).ciphertext,
1544
- recoveryKeyEncrypted: (await tempRootPrivilegedKeyManager.encrypt({
1545
- plaintext: recoveryKey,
1546
- protocolID: [2, 'admin key wrapping'],
1547
- keyID: '1'
1548
- })).ciphertext,
1549
- profilesEncrypted, // Add encrypted profiles
1550
- ...(kdfMetadata == null
1551
- ? {}
1552
- : {
1553
- umpVersion: 3,
1554
- passwordKdf: kdfMetadata
1555
- })
1556
- // currentOutpoint will be set after publishing
1557
- };
1558
- // We need the wallet built for the DEFAULT profile to publish the UMP token.
1559
- // If the current active profile is not default, temporarily switch, publish, then switch back.
1560
- const currentActiveId = this.activeProfileId;
1561
- let walletToUse = this.underlying;
1562
- if (!currentActiveId.every(x => x === 0)) {
1563
- this.telemetry.capture({
1564
- name: 'wallet-toolbox.ump.profile-switch.started',
1565
- component: 'wallet-toolbox.cwi-manager',
1566
- severity: 'debug',
1567
- attributes: { reason: 'token-update' }
1568
- });
1569
- await this.switchProfile(exports.DEFAULT_PROFILE_ID); // This rebuilds this.underlying
1570
- walletToUse = this.underlying;
1571
- }
1572
- if (walletToUse == null) {
1573
- throw new Error('Default profile wallet could not be activated for UMP token update.');
1574
- }
1575
- // Publish the new token on-chain, consuming the old one
1576
- try {
1577
- newTokenData.currentOutpoint = await this.UMPTokenInteractor.buildAndSend(walletToUse, this.adminOriginator, newTokenData, oldTokenToConsume // Consume the previous token
1578
- );
1579
- // Update the manager's state
1580
- this.currentUMPToken = newTokenData;
1581
- // Profiles are already updated in this.profiles if they were passed in
1582
- }
1583
- finally {
1584
- // Switch back if we temporarily switched
1585
- if (!currentActiveId.every(x => x === 0)) {
1586
- await this.switchProfile(currentActiveId);
1587
- this.telemetry.capture({
1588
- name: 'wallet-toolbox.ump.profile-switch.completed',
1589
- component: 'wallet-toolbox.cwi-manager',
1590
- severity: 'debug',
1591
- attributes: { reason: 'token-update' }
1592
- });
1593
- }
1594
- }
1595
- }
1596
- /**
1597
- * Serializes a UMP token to binary format (Version 3 with KDF metadata, Version 2 with profiles).
1598
- * V3 Layout: [1 byte version=3] + [11 * (varint len + bytes) for standard fields] + [1 byte profile_flag] + [IF flag=1 THEN varint len + profile bytes] + [1 byte kdf_flag] + [IF flag=1 THEN kdf metadata] + [varint len + outpoint bytes]
1599
- */
1600
- serializeUMPToken(token) {
1601
- if (!token.currentOutpoint) {
1602
- throw new Error('Token must have outpoint for serialization');
1603
- }
1604
- const writer = new sdk_1.Utils.Writer();
1605
- const hasKdfMetadata = token.umpVersion === 3 && token.passwordKdf;
1606
- writer.writeUInt8(hasKdfMetadata ? 3 : 2); // Version 3 for KDF, 2 for legacy
1607
- const writeArray = (arr) => {
1608
- writer.writeVarIntNum(arr.length);
1609
- writer.write(arr);
1610
- };
1611
- // Write standard fields in specific order
1612
- writeArray(token.passwordSalt); // 0
1613
- writeArray(token.passwordPresentationPrimary); // 1
1614
- writeArray(token.passwordRecoveryPrimary); // 2
1615
- writeArray(token.presentationRecoveryPrimary); // 3
1616
- writeArray(token.passwordPrimaryPrivileged); // 4
1617
- writeArray(token.presentationRecoveryPrivileged); // 5
1618
- writeArray(token.presentationHash); // 6
1619
- writeArray(token.recoveryHash); // 7
1620
- writeArray(token.presentationKeyEncrypted); // 8
1621
- writeArray(token.passwordKeyEncrypted); // 9
1622
- writeArray(token.recoveryKeyEncrypted); // 10
1623
- // Write optional profiles field
1624
- if ((token.profilesEncrypted != null) && token.profilesEncrypted.length > 0) {
1625
- writer.writeUInt8(1); // Flag indicating profiles present
1626
- writeArray(token.profilesEncrypted);
1627
- }
1628
- else {
1629
- writer.writeUInt8(0); // Flag indicating no profiles
1630
- }
1631
- // V3: Write KDF metadata
1632
- if (hasKdfMetadata) {
1633
- writer.writeUInt8(1); // Flag indicating KDF metadata present
1634
- writer.writeUInt8(token.umpVersion); // On-chain UMP version
1635
- const algorithmBytes = sdk_1.Utils.toArray(token.passwordKdf.algorithm, 'utf8');
1636
- writeArray(algorithmBytes);
1637
- // Serialize KDF params as JSON
1638
- const kdfParams = {
1639
- iterations: token.passwordKdf.iterations
1640
- };
1641
- if (token.passwordKdf.memoryKiB !== undefined) {
1642
- kdfParams.memoryKiB = token.passwordKdf.memoryKiB;
1643
- }
1644
- if (token.passwordKdf.parallelism !== undefined) {
1645
- kdfParams.parallelism = token.passwordKdf.parallelism;
1646
- }
1647
- if (token.passwordKdf.hashLength !== undefined) {
1648
- kdfParams.hashLength = token.passwordKdf.hashLength;
1649
- }
1650
- const kdfParamsBytes = sdk_1.Utils.toArray(JSON.stringify(kdfParams), 'utf8');
1651
- writeArray(kdfParamsBytes);
1652
- }
1653
- else if (writer.toArray()[0] === 3) {
1654
- // Version 3 without KDF metadata (shouldn't happen, but handle gracefully)
1655
- writer.writeUInt8(0); // Flag indicating no KDF metadata
1656
- }
1657
- // Write outpoint string
1658
- const outpointBytes = sdk_1.Utils.toArray(token.currentOutpoint, 'utf8');
1659
- writer.writeVarIntNum(outpointBytes.length);
1660
- writer.write(outpointBytes);
1661
- return writer.toArray();
1662
- }
1663
- /**
1664
- * Deserializes a UMP token from binary format (Handles Version 1, 2, and 3).
1665
- */
1666
- deserializeUMPToken(bin) {
1667
- const reader = new sdk_1.Utils.Reader(bin);
1668
- const version = reader.readUInt8();
1669
- if (version !== 1 && version !== 2 && version !== 3) {
1670
- throw new Error(`Unsupported UMP token serialization version: ${version}`);
1671
- }
1672
- const readArray = () => {
1673
- const length = reader.readVarIntNum();
1674
- if (length <= 0 || length > exports.MAX_STATE_SNAPSHOT_BYTES) {
1675
- throw new Error('UMP token field exceeds allowed bounds.');
1676
- }
1677
- return reader.read(length);
1678
- };
1679
- // Read standard fields (order matches serialization)
1680
- const passwordSalt = readArray(); // 0
1681
- const passwordPresentationPrimary = readArray(); // 1
1682
- const passwordRecoveryPrimary = readArray(); // 2
1683
- const presentationRecoveryPrimary = readArray(); // 3
1684
- const passwordPrimaryPrivileged = readArray(); // 4
1685
- const presentationRecoveryPrivileged = readArray(); // 5
1686
- const presentationHash = readArray(); // 6
1687
- const recoveryHash = readArray(); // 7
1688
- const presentationKeyEncrypted = readArray(); // 8
1689
- const passwordKeyEncrypted = readArray(); // 9
1690
- const recoveryKeyEncrypted = readArray(); // 10
1691
- // Read optional profiles (V2 and V3)
1692
- let profilesEncrypted;
1693
- if (version >= 2) {
1694
- const profilesFlag = reader.readUInt8();
1695
- if (profilesFlag === 1) {
1696
- profilesEncrypted = readArray();
1697
- }
1698
- }
1699
- // Read KDF metadata (V3 only)
1700
- let umpVersion;
1701
- let passwordKdf;
1702
- if (version === 3) {
1703
- const kdfFlag = reader.readUInt8();
1704
- if (kdfFlag === 1) {
1705
- umpVersion = reader.readUInt8(); // On-chain UMP version
1706
- const algorithmBytes = readArray();
1707
- const algorithm = sdk_1.Utils.toUTF8(algorithmBytes);
1708
- const kdfParamsBytes = readArray();
1709
- const kdfParamsJson = sdk_1.Utils.toUTF8(kdfParamsBytes);
1710
- const kdfParams = JSON.parse(kdfParamsJson);
1711
- passwordKdf = {
1712
- algorithm,
1713
- iterations: kdfParams.iterations,
1714
- memoryKiB: kdfParams.memoryKiB,
1715
- parallelism: kdfParams.parallelism,
1716
- hashLength: kdfParams.hashLength
1717
- };
1718
- if (!isValidKdfConfig(passwordKdf)) {
1719
- throw new Error('Serialized UMP token contains unsupported or unsafe KDF parameters.');
1720
- }
1721
- }
1722
- }
1723
- // Read outpoint string
1724
- const outpointLen = reader.readVarIntNum();
1725
- const outpointBytes = reader.read(outpointLen);
1726
- const currentOutpoint = sdk_1.Utils.toUTF8(outpointBytes);
1727
- if (currentOutpoint.length > 128 || !/^[^\s.:]+[.:][0-9]+$/.test(currentOutpoint)) {
1728
- throw new Error('Serialized UMP token contains an invalid outpoint.');
1729
- }
1730
- const token = {
1731
- passwordSalt,
1732
- passwordPresentationPrimary,
1733
- passwordRecoveryPrimary,
1734
- presentationRecoveryPrimary,
1735
- passwordPrimaryPrivileged,
1736
- presentationRecoveryPrivileged,
1737
- presentationHash,
1738
- recoveryHash,
1739
- presentationKeyEncrypted,
1740
- passwordKeyEncrypted,
1741
- recoveryKeyEncrypted,
1742
- profilesEncrypted,
1743
- currentOutpoint,
1744
- umpVersion,
1745
- passwordKdf
1746
- };
1747
- return token;
1748
- }
1749
- /**
1750
- * Sets up the root key infrastructure after authentication or loading from snapshot.
1751
- * Initializes the root primary key, root privileged key manager, loads profiles,
1752
- * and sets the authenticated flag. Does NOT switch profile initially.
1753
- *
1754
- * @param rootPrimaryKey The user's root primary key (32 bytes).
1755
- * @param ephemeralRootPrivilegedKey Optional root privileged key (e.g., during recovery flows).
1756
- */
1757
- async setupRootInfrastructure(rootPrimaryKey, ephemeralRootPrivilegedKey) {
1758
- if (this.currentUMPToken == null) {
1759
- throw new Error('A UMP token must exist before setting up root infrastructure!');
1760
- }
1761
- this.rootPrimaryKey = rootPrimaryKey;
1762
- // Store ephemeral key if provided, for one-time use by the manager
1763
- let oneTimePrivilegedKey = (ephemeralRootPrivilegedKey == null)
1764
- ? undefined
1765
- : new sdk_1.PrivateKey(ephemeralRootPrivilegedKey);
1766
- // Create the ROOT PrivilegedKeyManager
1767
- this.rootPrivilegedKeyManager = new PrivilegedKeyManager_1.PrivilegedKeyManager(async (reason) => {
1768
- // 1. Use one-time key if available (for recovery)
1769
- if (oneTimePrivilegedKey != null) {
1770
- const tempKey = oneTimePrivilegedKey;
1771
- oneTimePrivilegedKey = undefined; // Consume it
1772
- return tempKey;
1773
- }
1774
- // 2. Otherwise, derive from password
1775
- const password = await this.passwordRetriever(reason, async (passwordCandidate) => {
1776
- try {
1777
- const derivedPasswordKey = await derivePasswordKey(this.currentUMPToken, sdk_1.Utils.toArray(passwordCandidate, 'utf8'));
1778
- const privilegedDecryptor = this.XOR(this.rootPrimaryKey, derivedPasswordKey);
1779
- const decryptedPrivileged = new sdk_1.SymmetricKey(privilegedDecryptor).decrypt(this.currentUMPToken.passwordPrimaryPrivileged);
1780
- return !!decryptedPrivileged; // Test passes if decryption works
1781
- }
1782
- catch (_intentionallyIgnored) {
1783
- // Decryption failure means the password candidate is wrong — this is the
1784
- // expected rejection path for an incorrect password. Returning false causes
1785
- // the password-retriever loop to prompt the user again rather than crashing.
1786
- return false;
1787
- }
1788
- });
1789
- // Decrypt the root privileged key using the confirmed password (with token-driven KDF)
1790
- const derivedPasswordKey = await derivePasswordKey(this.currentUMPToken, sdk_1.Utils.toArray(password, 'utf8'));
1791
- const privilegedDecryptor = this.XOR(this.rootPrimaryKey, derivedPasswordKey);
1792
- const rootPrivilegedBytes = new sdk_1.SymmetricKey(privilegedDecryptor).decrypt(this.currentUMPToken.passwordPrimaryPrivileged);
1793
- return new sdk_1.PrivateKey(rootPrivilegedBytes); // Return the ROOT key object
1794
- });
1795
- // Decrypt and load profiles if present in the token
1796
- this.profiles = []; // Clear existing profiles before loading
1797
- if ((this.currentUMPToken.profilesEncrypted != null) && this.currentUMPToken.profilesEncrypted.length > 0) {
1798
- try {
1799
- const decryptedProfileBytes = new sdk_1.SymmetricKey(rootPrimaryKey).decrypt(this.currentUMPToken.profilesEncrypted);
1800
- const profilesJson = sdk_1.Utils.toUTF8(decryptedProfileBytes);
1801
- const profiles = JSON.parse(profilesJson);
1802
- if (!Array.isArray(profiles) || profiles.length > 1000 || !profiles.every(isValidProfile)) {
1803
- throw new Error('Decrypted profile data is invalid or exceeds supported bounds.');
1804
- }
1805
- this.profiles = profiles;
1806
- }
1807
- catch (error) {
1808
- this.profiles = [];
1809
- this.telemetry.capture({
1810
- name: 'wallet-toolbox.profile.load-failed',
1811
- component: 'wallet-toolbox.cwi-manager',
1812
- severity: 'error',
1813
- error
1814
- });
1815
- const message = error instanceof Error ? error.message : 'Unknown error';
1816
- throw new Error(`Failed to load profiles: ${message}`, { cause: error });
1817
- }
1818
- }
1819
- this.authenticated = true;
1820
- // Note: We don't call switchProfile here anymore.
1821
- // It's called by the auth methods (providePassword/provideRecoveryKey) or loadSnapshot after this.
1822
- }
1823
- /*
1824
- * ---------------------------------------------------------------------------------------
1825
- * Standard WalletInterface methods proxying to the *active* underlying wallet.
1826
- * Includes authentication checks and admin originator protection.
1827
- * ---------------------------------------------------------------------------------------
1828
- */
1829
- checkAuthAndUnderlying(originator) {
1830
- if (!this.authenticated) {
1831
- throw new Error('User is not authenticated.');
1832
- }
1833
- if (this.underlying == null) {
1834
- // This might happen if authentication succeeded but profile switching failed
1835
- throw new Error('Underlying wallet for the active profile is not initialized.');
1836
- }
1837
- if (originator === this.adminOriginator) {
1838
- throw new Error('External applications are not allowed to use the admin originator.');
1839
- }
1840
- }
1841
- // Example proxy method (repeat pattern for all others)
1842
- async getPublicKey(args, originator) {
1843
- this.checkAuthAndUnderlying(originator);
1844
- return await this.underlying.getPublicKey(args, originator);
1845
- }
1846
- async revealCounterpartyKeyLinkage(args, originator) {
1847
- this.checkAuthAndUnderlying(originator);
1848
- return await this.underlying.revealCounterpartyKeyLinkage(args, originator);
1849
- }
1850
- async revealSpecificKeyLinkage(args, originator) {
1851
- this.checkAuthAndUnderlying(originator);
1852
- return await this.underlying.revealSpecificKeyLinkage(args, originator);
1853
- }
1854
- async encrypt(args, originator) {
1855
- this.checkAuthAndUnderlying(originator);
1856
- return await this.underlying.encrypt(args, originator);
1857
- }
1858
- async decrypt(args, originator) {
1859
- this.checkAuthAndUnderlying(originator);
1860
- return await this.underlying.decrypt(args, originator);
1861
- }
1862
- async createHmac(args, originator) {
1863
- this.checkAuthAndUnderlying(originator);
1864
- return await this.underlying.createHmac(args, originator);
1865
- }
1866
- async verifyHmac(args, originator) {
1867
- this.checkAuthAndUnderlying(originator);
1868
- return await this.underlying.verifyHmac(args, originator);
1869
- }
1870
- async createSignature(args, originator) {
1871
- this.checkAuthAndUnderlying(originator);
1872
- return await this.underlying.createSignature(args, originator);
1873
- }
1874
- async verifySignature(args, originator) {
1875
- this.checkAuthAndUnderlying(originator);
1876
- return await this.underlying.verifySignature(args, originator);
1877
- }
1878
- async createAction(args, originator) {
1879
- this.checkAuthAndUnderlying(originator);
1880
- return await this.underlying.createAction(args, originator);
1881
- }
1882
- async signAction(args, originator) {
1883
- this.checkAuthAndUnderlying(originator);
1884
- return await this.underlying.signAction(args, originator);
1885
- }
1886
- async abortAction(args, originator) {
1887
- this.checkAuthAndUnderlying(originator);
1888
- return await this.underlying.abortAction(args, originator);
1889
- }
1890
- async listActions(args, originator) {
1891
- this.checkAuthAndUnderlying(originator);
1892
- return await this.underlying.listActions(args, originator);
1893
- }
1894
- async internalizeAction(args, originator) {
1895
- this.checkAuthAndUnderlying(originator);
1896
- return await this.underlying.internalizeAction(args, originator);
1897
- }
1898
- async listOutputs(args, originator) {
1899
- this.checkAuthAndUnderlying(originator);
1900
- return await this.underlying.listOutputs(args, originator);
1901
- }
1902
- async relinquishOutput(args, originator) {
1903
- this.checkAuthAndUnderlying(originator);
1904
- return await this.underlying.relinquishOutput(args, originator);
1905
- }
1906
- async acquireCertificate(args, originator) {
1907
- this.checkAuthAndUnderlying(originator);
1908
- return await this.underlying.acquireCertificate(args, originator);
1909
- }
1910
- async listCertificates(args, originator) {
1911
- this.checkAuthAndUnderlying(originator);
1912
- return await this.underlying.listCertificates(args, originator);
1913
- }
1914
- async proveCertificate(args, originator) {
1915
- this.checkAuthAndUnderlying(originator);
1916
- return await this.underlying.proveCertificate(args, originator);
1917
- }
1918
- async relinquishCertificate(args, originator) {
1919
- this.checkAuthAndUnderlying(originator);
1920
- return await this.underlying.relinquishCertificate(args, originator);
1921
- }
1922
- async discoverByIdentityKey(args, originator) {
1923
- this.checkAuthAndUnderlying(originator);
1924
- return await this.underlying.discoverByIdentityKey(args, originator);
1925
- }
1926
- async discoverByAttributes(args, originator) {
1927
- this.checkAuthAndUnderlying(originator);
1928
- return await this.underlying.discoverByAttributes(args, originator);
1929
- }
1930
- async isAuthenticated(_, originator) {
1931
- if (!this.authenticated) {
1932
- throw new Error('User is not authenticated.');
1933
- }
1934
- if (originator === this.adminOriginator) {
1935
- throw new Error('External applications are not allowed to use the admin originator.');
1936
- }
1937
- return { authenticated: true };
1938
- }
1939
- async waitForAuthentication(_, originator) {
1940
- if (originator === this.adminOriginator) {
1941
- throw new Error('External applications are not allowed to use the admin originator.');
1942
- }
1943
- while (!this.authenticated || (this.underlying == null)) {
1944
- await new Promise(resolve => setTimeout(resolve, 100));
1945
- }
1946
- return await this.underlying.waitForAuthentication({}, originator);
1947
- }
1948
- async getHeight(_, originator) {
1949
- this.checkAuthAndUnderlying(originator);
1950
- return await this.underlying.getHeight({}, originator);
1951
- }
1952
- async getHeaderForHeight(args, originator) {
1953
- this.checkAuthAndUnderlying(originator);
1954
- return await this.underlying.getHeaderForHeight(args, originator);
1955
- }
1956
- async getNetwork(_, originator) {
1957
- this.checkAuthAndUnderlying(originator);
1958
- return await this.underlying.getNetwork({}, originator);
1959
- }
1960
- async getVersion(_, originator) {
1961
- this.checkAuthAndUnderlying(originator);
1962
- return await this.underlying.getVersion({}, originator);
1963
- }
1964
- }
1965
- exports.CWIStyleWalletManager = CWIStyleWalletManager;
1966
- //# sourceMappingURL=CWIStyleWalletManager.js.map