@bsv/wallet-toolbox-mobile 1.7.15 → 1.7.16

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 (678) hide show
  1. package/out/src/CWIStyleWalletManager.d.ts +439 -0
  2. package/out/src/CWIStyleWalletManager.d.ts.map +1 -0
  3. package/out/src/CWIStyleWalletManager.js +1317 -0
  4. package/out/src/CWIStyleWalletManager.js.map +1 -0
  5. package/out/src/SetupClient.d.ts +130 -0
  6. package/out/src/SetupClient.d.ts.map +1 -0
  7. package/out/src/SetupClient.js +226 -0
  8. package/out/src/SetupClient.js.map +1 -0
  9. package/out/src/SetupWallet.d.ts +103 -0
  10. package/out/src/SetupWallet.d.ts.map +1 -0
  11. package/out/src/SetupWallet.js +3 -0
  12. package/out/src/SetupWallet.js.map +1 -0
  13. package/out/src/SimpleWalletManager.d.ts +169 -0
  14. package/out/src/SimpleWalletManager.d.ts.map +1 -0
  15. package/out/src/SimpleWalletManager.js +315 -0
  16. package/out/src/SimpleWalletManager.js.map +1 -0
  17. package/out/src/Wallet.d.ts +206 -0
  18. package/out/src/Wallet.d.ts.map +1 -0
  19. package/out/src/Wallet.js +797 -0
  20. package/out/src/Wallet.js.map +1 -0
  21. package/out/src/WalletAuthenticationManager.d.ts +33 -0
  22. package/out/src/WalletAuthenticationManager.d.ts.map +1 -0
  23. package/out/src/WalletAuthenticationManager.js +113 -0
  24. package/out/src/WalletAuthenticationManager.js.map +1 -0
  25. package/out/src/WalletLogger.d.ts +65 -0
  26. package/out/src/WalletLogger.d.ts.map +1 -0
  27. package/out/src/WalletLogger.js +167 -0
  28. package/out/src/WalletLogger.js.map +1 -0
  29. package/out/src/WalletPermissionsManager.d.ts +760 -0
  30. package/out/src/WalletPermissionsManager.d.ts.map +1 -0
  31. package/out/src/WalletPermissionsManager.js +2679 -0
  32. package/out/src/WalletPermissionsManager.js.map +1 -0
  33. package/out/src/WalletSettingsManager.d.ts +53 -0
  34. package/out/src/WalletSettingsManager.d.ts.map +1 -0
  35. package/out/src/WalletSettingsManager.js +83 -0
  36. package/out/src/WalletSettingsManager.js.map +1 -0
  37. package/out/src/index.client.d.ts +23 -0
  38. package/out/src/index.client.d.ts.map +1 -0
  39. package/out/src/index.client.js +62 -0
  40. package/out/src/index.client.js.map +1 -0
  41. package/out/src/index.mobile.d.ts +20 -0
  42. package/out/src/index.mobile.d.ts.map +1 -0
  43. package/out/src/index.mobile.js +59 -0
  44. package/out/src/index.mobile.js.map +1 -0
  45. package/out/src/monitor/Monitor.d.ts +148 -0
  46. package/out/src/monitor/Monitor.d.ts.map +1 -0
  47. package/out/src/monitor/Monitor.js +317 -0
  48. package/out/src/monitor/Monitor.js.map +1 -0
  49. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts +53 -0
  50. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -0
  51. package/out/src/monitor/tasks/TaskCheckForProofs.js +213 -0
  52. package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -0
  53. package/out/src/monitor/tasks/TaskCheckNoSends.d.ts +33 -0
  54. package/out/src/monitor/tasks/TaskCheckNoSends.d.ts.map +1 -0
  55. package/out/src/monitor/tasks/TaskCheckNoSends.js +71 -0
  56. package/out/src/monitor/tasks/TaskCheckNoSends.js.map +1 -0
  57. package/out/src/monitor/tasks/TaskClock.d.ts +14 -0
  58. package/out/src/monitor/tasks/TaskClock.d.ts.map +1 -0
  59. package/out/src/monitor/tasks/TaskClock.js +28 -0
  60. package/out/src/monitor/tasks/TaskClock.js.map +1 -0
  61. package/out/src/monitor/tasks/TaskFailAbandoned.d.ts +20 -0
  62. package/out/src/monitor/tasks/TaskFailAbandoned.d.ts.map +1 -0
  63. package/out/src/monitor/tasks/TaskFailAbandoned.js +52 -0
  64. package/out/src/monitor/tasks/TaskFailAbandoned.js.map +1 -0
  65. package/out/src/monitor/tasks/TaskMonitorCallHistory.d.ts +12 -0
  66. package/out/src/monitor/tasks/TaskMonitorCallHistory.d.ts.map +1 -0
  67. package/out/src/monitor/tasks/TaskMonitorCallHistory.js +24 -0
  68. package/out/src/monitor/tasks/TaskMonitorCallHistory.js.map +1 -0
  69. package/out/src/monitor/tasks/TaskNewHeader.d.ts +50 -0
  70. package/out/src/monitor/tasks/TaskNewHeader.d.ts.map +1 -0
  71. package/out/src/monitor/tasks/TaskNewHeader.js +84 -0
  72. package/out/src/monitor/tasks/TaskNewHeader.js.map +1 -0
  73. package/out/src/monitor/tasks/TaskPurge.d.ts +45 -0
  74. package/out/src/monitor/tasks/TaskPurge.d.ts.map +1 -0
  75. package/out/src/monitor/tasks/TaskPurge.js +34 -0
  76. package/out/src/monitor/tasks/TaskPurge.js.map +1 -0
  77. package/out/src/monitor/tasks/TaskReorg.d.ts +43 -0
  78. package/out/src/monitor/tasks/TaskReorg.d.ts.map +1 -0
  79. package/out/src/monitor/tasks/TaskReorg.js +82 -0
  80. package/out/src/monitor/tasks/TaskReorg.js.map +1 -0
  81. package/out/src/monitor/tasks/TaskReviewStatus.d.ts +26 -0
  82. package/out/src/monitor/tasks/TaskReviewStatus.d.ts.map +1 -0
  83. package/out/src/monitor/tasks/TaskReviewStatus.js +43 -0
  84. package/out/src/monitor/tasks/TaskReviewStatus.js.map +1 -0
  85. package/out/src/monitor/tasks/TaskSendWaiting.d.ts +35 -0
  86. package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -0
  87. package/out/src/monitor/tasks/TaskSendWaiting.js +117 -0
  88. package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -0
  89. package/out/src/monitor/tasks/TaskSyncWhenIdle.d.ts +12 -0
  90. package/out/src/monitor/tasks/TaskSyncWhenIdle.d.ts.map +1 -0
  91. package/out/src/monitor/tasks/TaskSyncWhenIdle.js +22 -0
  92. package/out/src/monitor/tasks/TaskSyncWhenIdle.js.map +1 -0
  93. package/out/src/monitor/tasks/TaskUnFail.d.ts +41 -0
  94. package/out/src/monitor/tasks/TaskUnFail.d.ts.map +1 -0
  95. package/out/src/monitor/tasks/TaskUnFail.js +145 -0
  96. package/out/src/monitor/tasks/TaskUnFail.js.map +1 -0
  97. package/out/src/monitor/tasks/WalletMonitorTask.d.ts +40 -0
  98. package/out/src/monitor/tasks/WalletMonitorTask.d.ts.map +1 -0
  99. package/out/src/monitor/tasks/WalletMonitorTask.js +37 -0
  100. package/out/src/monitor/tasks/WalletMonitorTask.js.map +1 -0
  101. package/out/src/sdk/CertOpsWallet.d.ts +7 -0
  102. package/out/src/sdk/CertOpsWallet.d.ts.map +1 -0
  103. package/out/src/sdk/CertOpsWallet.js +3 -0
  104. package/out/src/sdk/CertOpsWallet.js.map +1 -0
  105. package/out/src/sdk/PrivilegedKeyManager.d.ts +125 -0
  106. package/out/src/sdk/PrivilegedKeyManager.d.ts.map +1 -0
  107. package/out/src/sdk/PrivilegedKeyManager.js +293 -0
  108. package/out/src/sdk/PrivilegedKeyManager.js.map +1 -0
  109. package/out/src/sdk/WERR_errors.d.ts +136 -0
  110. package/out/src/sdk/WERR_errors.d.ts.map +1 -0
  111. package/out/src/sdk/WERR_errors.js +218 -0
  112. package/out/src/sdk/WERR_errors.js.map +1 -0
  113. package/out/src/sdk/WalletError.d.ts +63 -0
  114. package/out/src/sdk/WalletError.d.ts.map +1 -0
  115. package/out/src/sdk/WalletError.js +169 -0
  116. package/out/src/sdk/WalletError.js.map +1 -0
  117. package/out/src/sdk/WalletErrorFromJson.d.ts +12 -0
  118. package/out/src/sdk/WalletErrorFromJson.d.ts.map +1 -0
  119. package/out/src/sdk/WalletErrorFromJson.js +69 -0
  120. package/out/src/sdk/WalletErrorFromJson.js.map +1 -0
  121. package/out/src/sdk/WalletServices.interfaces.d.ts +618 -0
  122. package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -0
  123. package/out/src/sdk/WalletServices.interfaces.js +3 -0
  124. package/out/src/sdk/WalletServices.interfaces.js.map +1 -0
  125. package/out/src/sdk/WalletSigner.interfaces.d.ts +10 -0
  126. package/out/src/sdk/WalletSigner.interfaces.d.ts.map +1 -0
  127. package/out/src/sdk/WalletSigner.interfaces.js +3 -0
  128. package/out/src/sdk/WalletSigner.interfaces.js.map +1 -0
  129. package/out/src/sdk/WalletStorage.interfaces.d.ts +522 -0
  130. package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -0
  131. package/out/src/sdk/WalletStorage.interfaces.js +3 -0
  132. package/out/src/sdk/WalletStorage.interfaces.js.map +1 -0
  133. package/out/src/sdk/index.d.ts +11 -0
  134. package/out/src/sdk/index.d.ts.map +1 -0
  135. package/out/src/sdk/index.js +29 -0
  136. package/out/src/sdk/index.js.map +1 -0
  137. package/out/src/sdk/types.d.ts +169 -0
  138. package/out/src/sdk/types.d.ts.map +1 -0
  139. package/out/src/sdk/types.js +90 -0
  140. package/out/src/sdk/types.js.map +1 -0
  141. package/out/src/services/ServiceCollection.d.ts +79 -0
  142. package/out/src/services/ServiceCollection.d.ts.map +1 -0
  143. package/out/src/services/ServiceCollection.js +192 -0
  144. package/out/src/services/ServiceCollection.js.map +1 -0
  145. package/out/src/services/Services.d.ts +71 -0
  146. package/out/src/services/Services.d.ts.map +1 -0
  147. package/out/src/services/Services.js +532 -0
  148. package/out/src/services/Services.js.map +1 -0
  149. package/out/src/services/chaintracker/BHServiceClient.d.ts +39 -0
  150. package/out/src/services/chaintracker/BHServiceClient.d.ts.map +1 -0
  151. package/out/src/services/chaintracker/BHServiceClient.js +174 -0
  152. package/out/src/services/chaintracker/BHServiceClient.js.map +1 -0
  153. package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts +15 -0
  154. package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts.map +1 -0
  155. package/out/src/services/chaintracker/ChaintracksChainTracker.js +53 -0
  156. package/out/src/services/chaintracker/ChaintracksChainTracker.js.map +1 -0
  157. package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.d.ts +55 -0
  158. package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.d.ts.map +1 -0
  159. package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.js +38 -0
  160. package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.js.map +1 -0
  161. package/out/src/services/chaintracker/chaintracks/Api/BulkIngestorApi.d.ts +70 -0
  162. package/out/src/services/chaintracker/chaintracks/Api/BulkIngestorApi.d.ts.map +1 -0
  163. package/out/src/services/chaintracker/chaintracks/Api/BulkIngestorApi.js +3 -0
  164. package/out/src/services/chaintracker/chaintracks/Api/BulkIngestorApi.js.map +1 -0
  165. package/out/src/services/chaintracker/chaintracks/Api/BulkStorageApi.d.ts +81 -0
  166. package/out/src/services/chaintracker/chaintracks/Api/BulkStorageApi.d.ts.map +1 -0
  167. package/out/src/services/chaintracker/chaintracks/Api/BulkStorageApi.js +3 -0
  168. package/out/src/services/chaintracker/chaintracks/Api/BulkStorageApi.js.map +1 -0
  169. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksApi.d.ts +54 -0
  170. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksApi.d.ts.map +1 -0
  171. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksApi.js +3 -0
  172. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksApi.js.map +1 -0
  173. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksClientApi.d.ts +163 -0
  174. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksClientApi.d.ts.map +1 -0
  175. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksClientApi.js +3 -0
  176. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksClientApi.js.map +1 -0
  177. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFetchApi.d.ts +18 -0
  178. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFetchApi.d.ts.map +1 -0
  179. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFetchApi.js +3 -0
  180. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFetchApi.js.map +1 -0
  181. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFsApi.d.ts +55 -0
  182. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFsApi.d.ts.map +1 -0
  183. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFsApi.js +3 -0
  184. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFsApi.js.map +1 -0
  185. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksStorageApi.d.ts +338 -0
  186. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksStorageApi.d.ts.map +1 -0
  187. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksStorageApi.js +3 -0
  188. package/out/src/services/chaintracker/chaintracks/Api/ChaintracksStorageApi.js.map +1 -0
  189. package/out/src/services/chaintracker/chaintracks/Api/LiveIngestorApi.d.ts +19 -0
  190. package/out/src/services/chaintracker/chaintracks/Api/LiveIngestorApi.d.ts.map +1 -0
  191. package/out/src/services/chaintracker/chaintracks/Api/LiveIngestorApi.js +3 -0
  192. package/out/src/services/chaintracker/chaintracks/Api/LiveIngestorApi.js.map +1 -0
  193. package/out/src/services/chaintracker/chaintracks/Chaintracks.d.ts +101 -0
  194. package/out/src/services/chaintracker/chaintracks/Chaintracks.d.ts.map +1 -0
  195. package/out/src/services/chaintracker/chaintracks/Chaintracks.js +550 -0
  196. package/out/src/services/chaintracker/chaintracks/Chaintracks.js.map +1 -0
  197. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts +38 -0
  198. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts.map +1 -0
  199. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js +139 -0
  200. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js.map +1 -0
  201. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.d.ts +60 -0
  202. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.d.ts.map +1 -0
  203. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.js +119 -0
  204. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.js.map +1 -0
  205. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.d.ts +76 -0
  206. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.d.ts.map +1 -0
  207. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.js +114 -0
  208. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.js.map +1 -0
  209. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.d.ts +13 -0
  210. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.d.ts.map +1 -0
  211. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.js +20 -0
  212. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.js.map +1 -0
  213. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.d.ts +62 -0
  214. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.d.ts.map +1 -0
  215. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.js +59 -0
  216. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.js.map +1 -0
  217. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.d.ts +62 -0
  218. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.d.ts.map +1 -0
  219. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.js +42 -0
  220. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.js.map +1 -0
  221. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.d.ts +51 -0
  222. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.d.ts.map +1 -0
  223. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js +55 -0
  224. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js.map +1 -0
  225. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.d.ts +171 -0
  226. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.d.ts.map +1 -0
  227. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.js +501 -0
  228. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.js.map +1 -0
  229. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.d.ts +89 -0
  230. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.d.ts.map +1 -0
  231. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.js +137 -0
  232. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.js.map +1 -0
  233. package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.d.ts +23 -0
  234. package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.d.ts.map +1 -0
  235. package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.js +68 -0
  236. package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.js.map +1 -0
  237. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.d.ts +68 -0
  238. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.d.ts.map +1 -0
  239. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js +290 -0
  240. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js.map +1 -0
  241. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.d.ts +92 -0
  242. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.d.ts.map +1 -0
  243. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.js +465 -0
  244. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.js.map +1 -0
  245. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.d.ts +37 -0
  246. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.d.ts.map +1 -0
  247. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.js +260 -0
  248. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.js.map +1 -0
  249. package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.d.ts +5 -0
  250. package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.d.ts.map +1 -0
  251. package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.js +68 -0
  252. package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.js.map +1 -0
  253. package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.d.ts +5 -0
  254. package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.d.ts.map +1 -0
  255. package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.js +68 -0
  256. package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.js.map +1 -0
  257. package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.d.ts +13 -0
  258. package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.d.ts.map +1 -0
  259. package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.js +27 -0
  260. package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.js.map +1 -0
  261. package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.d.ts +13 -0
  262. package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.d.ts.map +1 -0
  263. package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.js +27 -0
  264. package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.js.map +1 -0
  265. package/out/src/services/chaintracker/chaintracks/index.client.d.ts +4 -0
  266. package/out/src/services/chaintracker/chaintracks/index.client.d.ts.map +1 -0
  267. package/out/src/services/chaintracker/chaintracks/index.client.js +20 -0
  268. package/out/src/services/chaintracker/chaintracks/index.client.js.map +1 -0
  269. package/out/src/services/chaintracker/chaintracks/index.mobile.d.ts +30 -0
  270. package/out/src/services/chaintracker/chaintracks/index.mobile.d.ts.map +1 -0
  271. package/out/src/services/chaintracker/chaintracks/index.mobile.js +68 -0
  272. package/out/src/services/chaintracker/chaintracks/index.mobile.js.map +1 -0
  273. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.d.ts +155 -0
  274. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.d.ts.map +1 -0
  275. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js +848 -0
  276. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js.map +1 -0
  277. package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.d.ts +78 -0
  278. package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.d.ts.map +1 -0
  279. package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js +261 -0
  280. package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js.map +1 -0
  281. package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.d.ts +129 -0
  282. package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.d.ts.map +1 -0
  283. package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.js +145 -0
  284. package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.js.map +1 -0
  285. package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.d.ts +14 -0
  286. package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.d.ts.map +1 -0
  287. package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.js +67 -0
  288. package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.js.map +1 -0
  289. package/out/src/services/chaintracker/chaintracks/util/HeightRange.d.ts +90 -0
  290. package/out/src/services/chaintracker/chaintracks/util/HeightRange.d.ts.map +1 -0
  291. package/out/src/services/chaintracker/chaintracks/util/HeightRange.js +140 -0
  292. package/out/src/services/chaintracker/chaintracks/util/HeightRange.js.map +1 -0
  293. package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts +14 -0
  294. package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts.map +1 -0
  295. package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.js +88 -0
  296. package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.js.map +1 -0
  297. package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts +159 -0
  298. package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts.map +1 -0
  299. package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js +520 -0
  300. package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js.map +1 -0
  301. package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.d.ts +20 -0
  302. package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.d.ts.map +1 -0
  303. package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.js +31 -0
  304. package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.js.map +1 -0
  305. package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.d.ts +37 -0
  306. package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.d.ts.map +1 -0
  307. package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.js +432 -0
  308. package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.js.map +1 -0
  309. package/out/src/services/chaintracker/index.client.d.ts +4 -0
  310. package/out/src/services/chaintracker/index.client.d.ts.map +1 -0
  311. package/out/src/services/chaintracker/index.client.js +20 -0
  312. package/out/src/services/chaintracker/index.client.js.map +1 -0
  313. package/out/src/services/createDefaultWalletServicesOptions.d.ts +7 -0
  314. package/out/src/services/createDefaultWalletServicesOptions.d.ts.map +1 -0
  315. package/out/src/services/createDefaultWalletServicesOptions.js +65 -0
  316. package/out/src/services/createDefaultWalletServicesOptions.js.map +1 -0
  317. package/out/src/services/providers/ARC.d.ts +92 -0
  318. package/out/src/services/providers/ARC.d.ts.map +1 -0
  319. package/out/src/services/providers/ARC.js +270 -0
  320. package/out/src/services/providers/ARC.js.map +1 -0
  321. package/out/src/services/providers/Bitails.d.ts +50 -0
  322. package/out/src/services/providers/Bitails.d.ts.map +1 -0
  323. package/out/src/services/providers/Bitails.js +224 -0
  324. package/out/src/services/providers/Bitails.js.map +1 -0
  325. package/out/src/services/providers/SdkWhatsOnChain.d.ts +21 -0
  326. package/out/src/services/providers/SdkWhatsOnChain.d.ts.map +1 -0
  327. package/out/src/services/providers/SdkWhatsOnChain.js +67 -0
  328. package/out/src/services/providers/SdkWhatsOnChain.js.map +1 -0
  329. package/out/src/services/providers/WhatsOnChain.d.ts +130 -0
  330. package/out/src/services/providers/WhatsOnChain.d.ts.map +1 -0
  331. package/out/src/services/providers/WhatsOnChain.js +679 -0
  332. package/out/src/services/providers/WhatsOnChain.js.map +1 -0
  333. package/out/src/services/providers/exchangeRates.d.ts +12 -0
  334. package/out/src/services/providers/exchangeRates.d.ts.map +1 -0
  335. package/out/src/services/providers/exchangeRates.js +237 -0
  336. package/out/src/services/providers/exchangeRates.js.map +1 -0
  337. package/out/src/services/providers/getBeefForTxid.d.ts +4 -0
  338. package/out/src/services/providers/getBeefForTxid.d.ts.map +1 -0
  339. package/out/src/services/providers/getBeefForTxid.js +286 -0
  340. package/out/src/services/providers/getBeefForTxid.js.map +1 -0
  341. package/out/src/signer/WalletSigner.d.ts +11 -0
  342. package/out/src/signer/WalletSigner.d.ts.map +1 -0
  343. package/out/src/signer/WalletSigner.js +13 -0
  344. package/out/src/signer/WalletSigner.js.map +1 -0
  345. package/out/src/signer/methods/acquireDirectCertificate.d.ts +5 -0
  346. package/out/src/signer/methods/acquireDirectCertificate.d.ts.map +1 -0
  347. package/out/src/signer/methods/acquireDirectCertificate.js +45 -0
  348. package/out/src/signer/methods/acquireDirectCertificate.js.map +1 -0
  349. package/out/src/signer/methods/buildSignableTransaction.d.ts +15 -0
  350. package/out/src/signer/methods/buildSignableTransaction.d.ts.map +1 -0
  351. package/out/src/signer/methods/buildSignableTransaction.js +142 -0
  352. package/out/src/signer/methods/buildSignableTransaction.js.map +1 -0
  353. package/out/src/signer/methods/completeSignedTransaction.d.ts +10 -0
  354. package/out/src/signer/methods/completeSignedTransaction.d.ts.map +1 -0
  355. package/out/src/signer/methods/completeSignedTransaction.js +106 -0
  356. package/out/src/signer/methods/completeSignedTransaction.js.map +1 -0
  357. package/out/src/signer/methods/createAction.d.ts +14 -0
  358. package/out/src/signer/methods/createAction.d.ts.map +1 -0
  359. package/out/src/signer/methods/createAction.js +117 -0
  360. package/out/src/signer/methods/createAction.js.map +1 -0
  361. package/out/src/signer/methods/internalizeAction.d.ts +32 -0
  362. package/out/src/signer/methods/internalizeAction.d.ts.map +1 -0
  363. package/out/src/signer/methods/internalizeAction.js +93 -0
  364. package/out/src/signer/methods/internalizeAction.js.map +1 -0
  365. package/out/src/signer/methods/proveCertificate.d.ts +5 -0
  366. package/out/src/signer/methods/proveCertificate.d.ts.map +1 -0
  367. package/out/src/signer/methods/proveCertificate.js +29 -0
  368. package/out/src/signer/methods/proveCertificate.js.map +1 -0
  369. package/out/src/signer/methods/signAction.d.ts +11 -0
  370. package/out/src/signer/methods/signAction.d.ts.map +1 -0
  371. package/out/src/signer/methods/signAction.js +41 -0
  372. package/out/src/signer/methods/signAction.js.map +1 -0
  373. package/out/src/storage/StorageIdb.d.ts +210 -0
  374. package/out/src/storage/StorageIdb.d.ts.map +1 -0
  375. package/out/src/storage/StorageIdb.js +2297 -0
  376. package/out/src/storage/StorageIdb.js.map +1 -0
  377. package/out/src/storage/StorageProvider.d.ts +222 -0
  378. package/out/src/storage/StorageProvider.d.ts.map +1 -0
  379. package/out/src/storage/StorageProvider.js +567 -0
  380. package/out/src/storage/StorageProvider.js.map +1 -0
  381. package/out/src/storage/StorageReader.d.ts +77 -0
  382. package/out/src/storage/StorageReader.d.ts.map +1 -0
  383. package/out/src/storage/StorageReader.js +163 -0
  384. package/out/src/storage/StorageReader.js.map +1 -0
  385. package/out/src/storage/StorageReaderWriter.d.ts +102 -0
  386. package/out/src/storage/StorageReaderWriter.d.ts.map +1 -0
  387. package/out/src/storage/StorageReaderWriter.js +338 -0
  388. package/out/src/storage/StorageReaderWriter.js.map +1 -0
  389. package/out/src/storage/StorageSyncReader.d.ts +18 -0
  390. package/out/src/storage/StorageSyncReader.d.ts.map +1 -0
  391. package/out/src/storage/StorageSyncReader.js +71 -0
  392. package/out/src/storage/StorageSyncReader.js.map +1 -0
  393. package/out/src/storage/WalletStorageManager.d.ts +221 -0
  394. package/out/src/storage/WalletStorageManager.d.ts.map +1 -0
  395. package/out/src/storage/WalletStorageManager.js +819 -0
  396. package/out/src/storage/WalletStorageManager.js.map +1 -0
  397. package/out/src/storage/index.client.d.ts +8 -0
  398. package/out/src/storage/index.client.d.ts.map +1 -0
  399. package/out/src/storage/index.client.js +24 -0
  400. package/out/src/storage/index.client.js.map +1 -0
  401. package/out/src/storage/index.mobile.d.ts +7 -0
  402. package/out/src/storage/index.mobile.d.ts.map +1 -0
  403. package/out/src/storage/index.mobile.js +23 -0
  404. package/out/src/storage/index.mobile.js.map +1 -0
  405. package/out/src/storage/methods/ListActionsSpecOp.d.ts +18 -0
  406. package/out/src/storage/methods/ListActionsSpecOp.d.ts.map +1 -0
  407. package/out/src/storage/methods/ListActionsSpecOp.js +40 -0
  408. package/out/src/storage/methods/ListActionsSpecOp.js.map +1 -0
  409. package/out/src/storage/methods/ListOutputsSpecOp.d.ts +26 -0
  410. package/out/src/storage/methods/ListOutputsSpecOp.d.ts.map +1 -0
  411. package/out/src/storage/methods/ListOutputsSpecOp.js +75 -0
  412. package/out/src/storage/methods/ListOutputsSpecOp.js.map +1 -0
  413. package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts +41 -0
  414. package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -0
  415. package/out/src/storage/methods/attemptToPostReqsToNetwork.js +324 -0
  416. package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -0
  417. package/out/src/storage/methods/createAction.d.ts +13 -0
  418. package/out/src/storage/methods/createAction.d.ts.map +1 -0
  419. package/out/src/storage/methods/createAction.js +732 -0
  420. package/out/src/storage/methods/createAction.js.map +1 -0
  421. package/out/src/storage/methods/generateChange.d.ts +96 -0
  422. package/out/src/storage/methods/generateChange.d.ts.map +1 -0
  423. package/out/src/storage/methods/generateChange.js +405 -0
  424. package/out/src/storage/methods/generateChange.js.map +1 -0
  425. package/out/src/storage/methods/getBeefForTransaction.d.ts +23 -0
  426. package/out/src/storage/methods/getBeefForTransaction.d.ts.map +1 -0
  427. package/out/src/storage/methods/getBeefForTransaction.js +109 -0
  428. package/out/src/storage/methods/getBeefForTransaction.js.map +1 -0
  429. package/out/src/storage/methods/getSyncChunk.d.ts +10 -0
  430. package/out/src/storage/methods/getSyncChunk.d.ts.map +1 -0
  431. package/out/src/storage/methods/getSyncChunk.js +272 -0
  432. package/out/src/storage/methods/getSyncChunk.js.map +1 -0
  433. package/out/src/storage/methods/internalizeAction.d.ts +31 -0
  434. package/out/src/storage/methods/internalizeAction.d.ts.map +1 -0
  435. package/out/src/storage/methods/internalizeAction.js +462 -0
  436. package/out/src/storage/methods/internalizeAction.js.map +1 -0
  437. package/out/src/storage/methods/listActionsIdb.d.ts +5 -0
  438. package/out/src/storage/methods/listActionsIdb.d.ts.map +1 -0
  439. package/out/src/storage/methods/listActionsIdb.js +155 -0
  440. package/out/src/storage/methods/listActionsIdb.js.map +1 -0
  441. package/out/src/storage/methods/listCertificates.d.ts +5 -0
  442. package/out/src/storage/methods/listCertificates.d.ts.map +1 -0
  443. package/out/src/storage/methods/listCertificates.js +68 -0
  444. package/out/src/storage/methods/listCertificates.js.map +1 -0
  445. package/out/src/storage/methods/listOutputsIdb.d.ts +5 -0
  446. package/out/src/storage/methods/listOutputsIdb.d.ts.map +1 -0
  447. package/out/src/storage/methods/listOutputsIdb.js +185 -0
  448. package/out/src/storage/methods/listOutputsIdb.js.map +1 -0
  449. package/out/src/storage/methods/offsetKey.d.ts +24 -0
  450. package/out/src/storage/methods/offsetKey.d.ts.map +1 -0
  451. package/out/src/storage/methods/offsetKey.js +67 -0
  452. package/out/src/storage/methods/offsetKey.js.map +1 -0
  453. package/out/src/storage/methods/processAction.d.ts +54 -0
  454. package/out/src/storage/methods/processAction.d.ts.map +1 -0
  455. package/out/src/storage/methods/processAction.js +267 -0
  456. package/out/src/storage/methods/processAction.js.map +1 -0
  457. package/out/src/storage/methods/purgeDataIdb.d.ts +4 -0
  458. package/out/src/storage/methods/purgeDataIdb.d.ts.map +1 -0
  459. package/out/src/storage/methods/purgeDataIdb.js +9 -0
  460. package/out/src/storage/methods/purgeDataIdb.js.map +1 -0
  461. package/out/src/storage/methods/reviewStatusIdb.d.ts +20 -0
  462. package/out/src/storage/methods/reviewStatusIdb.d.ts.map +1 -0
  463. package/out/src/storage/methods/reviewStatusIdb.js +35 -0
  464. package/out/src/storage/methods/reviewStatusIdb.js.map +1 -0
  465. package/out/src/storage/methods/utils.d.ts +25 -0
  466. package/out/src/storage/methods/utils.d.ts.map +1 -0
  467. package/out/src/storage/methods/utils.js +53 -0
  468. package/out/src/storage/methods/utils.js.map +1 -0
  469. package/out/src/storage/remoting/StorageClient.d.ts +292 -0
  470. package/out/src/storage/remoting/StorageClient.d.ts.map +1 -0
  471. package/out/src/storage/remoting/StorageClient.js +497 -0
  472. package/out/src/storage/remoting/StorageClient.js.map +1 -0
  473. package/out/src/storage/remoting/StorageMobile.d.ts +292 -0
  474. package/out/src/storage/remoting/StorageMobile.d.ts.map +1 -0
  475. package/out/src/storage/remoting/StorageMobile.js +477 -0
  476. package/out/src/storage/remoting/StorageMobile.js.map +1 -0
  477. package/out/src/storage/schema/StorageIdbSchema.d.ts +133 -0
  478. package/out/src/storage/schema/StorageIdbSchema.d.ts.map +1 -0
  479. package/out/src/storage/schema/StorageIdbSchema.js +3 -0
  480. package/out/src/storage/schema/StorageIdbSchema.js.map +1 -0
  481. package/out/src/storage/schema/entities/EntityBase.d.ts +106 -0
  482. package/out/src/storage/schema/entities/EntityBase.d.ts.map +1 -0
  483. package/out/src/storage/schema/entities/EntityBase.js +100 -0
  484. package/out/src/storage/schema/entities/EntityBase.js.map +1 -0
  485. package/out/src/storage/schema/entities/EntityCertificate.d.ts +44 -0
  486. package/out/src/storage/schema/entities/EntityCertificate.d.ts.map +1 -0
  487. package/out/src/storage/schema/entities/EntityCertificate.js +162 -0
  488. package/out/src/storage/schema/entities/EntityCertificate.js.map +1 -0
  489. package/out/src/storage/schema/entities/EntityCertificateField.d.ts +33 -0
  490. package/out/src/storage/schema/entities/EntityCertificateField.d.ts.map +1 -0
  491. package/out/src/storage/schema/entities/EntityCertificateField.js +112 -0
  492. package/out/src/storage/schema/entities/EntityCertificateField.js.map +1 -0
  493. package/out/src/storage/schema/entities/EntityCommission.d.ts +38 -0
  494. package/out/src/storage/schema/entities/EntityCommission.d.ts.map +1 -0
  495. package/out/src/storage/schema/entities/EntityCommission.js +127 -0
  496. package/out/src/storage/schema/entities/EntityCommission.js.map +1 -0
  497. package/out/src/storage/schema/entities/EntityOutput.d.ts +68 -0
  498. package/out/src/storage/schema/entities/EntityOutput.d.ts.map +1 -0
  499. package/out/src/storage/schema/entities/EntityOutput.js +264 -0
  500. package/out/src/storage/schema/entities/EntityOutput.js.map +1 -0
  501. package/out/src/storage/schema/entities/EntityOutputBasket.d.ts +36 -0
  502. package/out/src/storage/schema/entities/EntityOutputBasket.d.ts.map +1 -0
  503. package/out/src/storage/schema/entities/EntityOutputBasket.js +133 -0
  504. package/out/src/storage/schema/entities/EntityOutputBasket.js.map +1 -0
  505. package/out/src/storage/schema/entities/EntityOutputTag.d.ts +32 -0
  506. package/out/src/storage/schema/entities/EntityOutputTag.d.ts.map +1 -0
  507. package/out/src/storage/schema/entities/EntityOutputTag.js +104 -0
  508. package/out/src/storage/schema/entities/EntityOutputTag.js.map +1 -0
  509. package/out/src/storage/schema/entities/EntityOutputTagMap.d.ts +29 -0
  510. package/out/src/storage/schema/entities/EntityOutputTagMap.d.ts.map +1 -0
  511. package/out/src/storage/schema/entities/EntityOutputTagMap.js +98 -0
  512. package/out/src/storage/schema/entities/EntityOutputTagMap.js.map +1 -0
  513. package/out/src/storage/schema/entities/EntityProvenTx.d.ts +87 -0
  514. package/out/src/storage/schema/entities/EntityProvenTx.d.ts.map +1 -0
  515. package/out/src/storage/schema/entities/EntityProvenTx.js +278 -0
  516. package/out/src/storage/schema/entities/EntityProvenTx.js.map +1 -0
  517. package/out/src/storage/schema/entities/EntityProvenTxReq.d.ts +139 -0
  518. package/out/src/storage/schema/entities/EntityProvenTxReq.d.ts.map +1 -0
  519. package/out/src/storage/schema/entities/EntityProvenTxReq.js +524 -0
  520. package/out/src/storage/schema/entities/EntityProvenTxReq.js.map +1 -0
  521. package/out/src/storage/schema/entities/EntitySyncState.d.ts +69 -0
  522. package/out/src/storage/schema/entities/EntitySyncState.d.ts.map +1 -0
  523. package/out/src/storage/schema/entities/EntitySyncState.js +334 -0
  524. package/out/src/storage/schema/entities/EntitySyncState.js.map +1 -0
  525. package/out/src/storage/schema/entities/EntityTransaction.d.ts +71 -0
  526. package/out/src/storage/schema/entities/EntityTransaction.d.ts.map +1 -0
  527. package/out/src/storage/schema/entities/EntityTransaction.js +255 -0
  528. package/out/src/storage/schema/entities/EntityTransaction.js.map +1 -0
  529. package/out/src/storage/schema/entities/EntityTxLabel.d.ts +32 -0
  530. package/out/src/storage/schema/entities/EntityTxLabel.d.ts.map +1 -0
  531. package/out/src/storage/schema/entities/EntityTxLabel.js +104 -0
  532. package/out/src/storage/schema/entities/EntityTxLabel.js.map +1 -0
  533. package/out/src/storage/schema/entities/EntityTxLabelMap.d.ts +29 -0
  534. package/out/src/storage/schema/entities/EntityTxLabelMap.d.ts.map +1 -0
  535. package/out/src/storage/schema/entities/EntityTxLabelMap.js +98 -0
  536. package/out/src/storage/schema/entities/EntityTxLabelMap.js.map +1 -0
  537. package/out/src/storage/schema/entities/EntityUser.d.ts +30 -0
  538. package/out/src/storage/schema/entities/EntityUser.d.ts.map +1 -0
  539. package/out/src/storage/schema/entities/EntityUser.js +99 -0
  540. package/out/src/storage/schema/entities/EntityUser.js.map +1 -0
  541. package/out/src/storage/schema/entities/MergeEntity.d.ts +34 -0
  542. package/out/src/storage/schema/entities/MergeEntity.d.ts.map +1 -0
  543. package/out/src/storage/schema/entities/MergeEntity.js +63 -0
  544. package/out/src/storage/schema/entities/MergeEntity.js.map +1 -0
  545. package/out/src/storage/schema/entities/index.d.ts +17 -0
  546. package/out/src/storage/schema/entities/index.d.ts.map +1 -0
  547. package/out/src/storage/schema/entities/index.js +33 -0
  548. package/out/src/storage/schema/entities/index.js.map +1 -0
  549. package/out/src/storage/schema/tables/TableCertificate.d.ts +20 -0
  550. package/out/src/storage/schema/tables/TableCertificate.d.ts.map +1 -0
  551. package/out/src/storage/schema/tables/TableCertificate.js +3 -0
  552. package/out/src/storage/schema/tables/TableCertificate.js.map +1 -0
  553. package/out/src/storage/schema/tables/TableCertificateField.d.ts +12 -0
  554. package/out/src/storage/schema/tables/TableCertificateField.d.ts.map +1 -0
  555. package/out/src/storage/schema/tables/TableCertificateField.js +3 -0
  556. package/out/src/storage/schema/tables/TableCertificateField.js.map +1 -0
  557. package/out/src/storage/schema/tables/TableCommission.d.ts +13 -0
  558. package/out/src/storage/schema/tables/TableCommission.d.ts.map +1 -0
  559. package/out/src/storage/schema/tables/TableCommission.js +3 -0
  560. package/out/src/storage/schema/tables/TableCommission.js.map +1 -0
  561. package/out/src/storage/schema/tables/TableMonitorEvent.d.ts +9 -0
  562. package/out/src/storage/schema/tables/TableMonitorEvent.d.ts.map +1 -0
  563. package/out/src/storage/schema/tables/TableMonitorEvent.js +3 -0
  564. package/out/src/storage/schema/tables/TableMonitorEvent.js.map +1 -0
  565. package/out/src/storage/schema/tables/TableOutput.d.ts +36 -0
  566. package/out/src/storage/schema/tables/TableOutput.d.ts.map +1 -0
  567. package/out/src/storage/schema/tables/TableOutput.js +31 -0
  568. package/out/src/storage/schema/tables/TableOutput.js.map +1 -0
  569. package/out/src/storage/schema/tables/TableOutputBasket.d.ts +12 -0
  570. package/out/src/storage/schema/tables/TableOutputBasket.d.ts.map +1 -0
  571. package/out/src/storage/schema/tables/TableOutputBasket.js +3 -0
  572. package/out/src/storage/schema/tables/TableOutputBasket.js.map +1 -0
  573. package/out/src/storage/schema/tables/TableOutputTag.d.ts +10 -0
  574. package/out/src/storage/schema/tables/TableOutputTag.d.ts.map +1 -0
  575. package/out/src/storage/schema/tables/TableOutputTag.js +3 -0
  576. package/out/src/storage/schema/tables/TableOutputTag.js.map +1 -0
  577. package/out/src/storage/schema/tables/TableOutputTagMap.d.ts +9 -0
  578. package/out/src/storage/schema/tables/TableOutputTagMap.d.ts.map +1 -0
  579. package/out/src/storage/schema/tables/TableOutputTagMap.js +3 -0
  580. package/out/src/storage/schema/tables/TableOutputTagMap.js.map +1 -0
  581. package/out/src/storage/schema/tables/TableProvenTx.d.ts +14 -0
  582. package/out/src/storage/schema/tables/TableProvenTx.d.ts.map +1 -0
  583. package/out/src/storage/schema/tables/TableProvenTx.js +3 -0
  584. package/out/src/storage/schema/tables/TableProvenTx.js.map +1 -0
  585. package/out/src/storage/schema/tables/TableProvenTxReq.d.ts +64 -0
  586. package/out/src/storage/schema/tables/TableProvenTxReq.d.ts.map +1 -0
  587. package/out/src/storage/schema/tables/TableProvenTxReq.js +3 -0
  588. package/out/src/storage/schema/tables/TableProvenTxReq.js.map +1 -0
  589. package/out/src/storage/schema/tables/TableSettings.d.ts +17 -0
  590. package/out/src/storage/schema/tables/TableSettings.d.ts.map +1 -0
  591. package/out/src/storage/schema/tables/TableSettings.js +3 -0
  592. package/out/src/storage/schema/tables/TableSettings.js.map +1 -0
  593. package/out/src/storage/schema/tables/TableSyncState.d.ts +18 -0
  594. package/out/src/storage/schema/tables/TableSyncState.d.ts.map +1 -0
  595. package/out/src/storage/schema/tables/TableSyncState.js +3 -0
  596. package/out/src/storage/schema/tables/TableSyncState.js.map +1 -0
  597. package/out/src/storage/schema/tables/TableTransaction.d.ts +37 -0
  598. package/out/src/storage/schema/tables/TableTransaction.d.ts.map +1 -0
  599. package/out/src/storage/schema/tables/TableTransaction.js +21 -0
  600. package/out/src/storage/schema/tables/TableTransaction.js.map +1 -0
  601. package/out/src/storage/schema/tables/TableTxLabel.d.ts +10 -0
  602. package/out/src/storage/schema/tables/TableTxLabel.d.ts.map +1 -0
  603. package/out/src/storage/schema/tables/TableTxLabel.js +3 -0
  604. package/out/src/storage/schema/tables/TableTxLabel.js.map +1 -0
  605. package/out/src/storage/schema/tables/TableTxLabelMap.d.ts +9 -0
  606. package/out/src/storage/schema/tables/TableTxLabelMap.d.ts.map +1 -0
  607. package/out/src/storage/schema/tables/TableTxLabelMap.js +3 -0
  608. package/out/src/storage/schema/tables/TableTxLabelMap.js.map +1 -0
  609. package/out/src/storage/schema/tables/TableUser.d.ts +16 -0
  610. package/out/src/storage/schema/tables/TableUser.d.ts.map +1 -0
  611. package/out/src/storage/schema/tables/TableUser.js +3 -0
  612. package/out/src/storage/schema/tables/TableUser.js.map +1 -0
  613. package/out/src/storage/schema/tables/index.d.ts +17 -0
  614. package/out/src/storage/schema/tables/index.d.ts.map +1 -0
  615. package/out/src/storage/schema/tables/index.js +33 -0
  616. package/out/src/storage/schema/tables/index.js.map +1 -0
  617. package/out/src/utility/ReaderUint8Array.d.ts +28 -0
  618. package/out/src/utility/ReaderUint8Array.d.ts.map +1 -0
  619. package/out/src/utility/ReaderUint8Array.js +166 -0
  620. package/out/src/utility/ReaderUint8Array.js.map +1 -0
  621. package/out/src/utility/ScriptTemplateBRC29.d.ts +25 -0
  622. package/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -0
  623. package/out/src/utility/ScriptTemplateBRC29.js +48 -0
  624. package/out/src/utility/ScriptTemplateBRC29.js.map +1 -0
  625. package/out/src/utility/aggregateResults.d.ts +8 -0
  626. package/out/src/utility/aggregateResults.d.ts.map +1 -0
  627. package/out/src/utility/aggregateResults.js +59 -0
  628. package/out/src/utility/aggregateResults.js.map +1 -0
  629. package/out/src/utility/identityUtils.d.ts +31 -0
  630. package/out/src/utility/identityUtils.d.ts.map +1 -0
  631. package/out/src/utility/identityUtils.js +116 -0
  632. package/out/src/utility/identityUtils.js.map +1 -0
  633. package/out/src/utility/index.client.d.ts +7 -0
  634. package/out/src/utility/index.client.d.ts.map +1 -0
  635. package/out/src/utility/index.client.js +23 -0
  636. package/out/src/utility/index.client.js.map +1 -0
  637. package/out/src/utility/parseTxScriptOffsets.d.ts +14 -0
  638. package/out/src/utility/parseTxScriptOffsets.d.ts.map +1 -0
  639. package/out/src/utility/parseTxScriptOffsets.js +26 -0
  640. package/out/src/utility/parseTxScriptOffsets.js.map +1 -0
  641. package/out/src/utility/stampLog.d.ts +18 -0
  642. package/out/src/utility/stampLog.d.ts.map +1 -0
  643. package/out/src/utility/stampLog.js +72 -0
  644. package/out/src/utility/stampLog.js.map +1 -0
  645. package/out/src/utility/tscProofToMerklePath.d.ts +8 -0
  646. package/out/src/utility/tscProofToMerklePath.d.ts.map +1 -0
  647. package/out/src/utility/tscProofToMerklePath.js +41 -0
  648. package/out/src/utility/tscProofToMerklePath.js.map +1 -0
  649. package/out/src/utility/utilityHelpers.d.ts +138 -0
  650. package/out/src/utility/utilityHelpers.d.ts.map +1 -0
  651. package/out/src/utility/utilityHelpers.js +294 -0
  652. package/out/src/utility/utilityHelpers.js.map +1 -0
  653. package/out/src/utility/utilityHelpers.noBuffer.d.ts +26 -0
  654. package/out/src/utility/utilityHelpers.noBuffer.d.ts.map +1 -0
  655. package/out/src/utility/utilityHelpers.noBuffer.js +64 -0
  656. package/out/src/utility/utilityHelpers.noBuffer.js.map +1 -0
  657. package/out/src/wab-client/WABClient.d.ts +49 -0
  658. package/out/src/wab-client/WABClient.d.ts.map +1 -0
  659. package/out/src/wab-client/WABClient.js +80 -0
  660. package/out/src/wab-client/WABClient.js.map +1 -0
  661. package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts +34 -0
  662. package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts.map +1 -0
  663. package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js +16 -0
  664. package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js.map +1 -0
  665. package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.d.ts +29 -0
  666. package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.d.ts.map +1 -0
  667. package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.js +70 -0
  668. package/out/src/wab-client/auth-method-interactors/DevConsoleInteractor.js.map +1 -0
  669. package/out/src/wab-client/auth-method-interactors/PersonaIDInteractor.d.ts +7 -0
  670. package/out/src/wab-client/auth-method-interactors/PersonaIDInteractor.d.ts.map +1 -0
  671. package/out/src/wab-client/auth-method-interactors/PersonaIDInteractor.js +36 -0
  672. package/out/src/wab-client/auth-method-interactors/PersonaIDInteractor.js.map +1 -0
  673. package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.d.ts +28 -0
  674. package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.d.ts.map +1 -0
  675. package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.js +69 -0
  676. package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.js.map +1 -0
  677. package/out/tsconfig.mobile.tsbuildinfo +1 -0
  678. package/package.json +1 -1
@@ -0,0 +1,1317 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CWIStyleWalletManager = exports.OverlayUMPTokenInteractor = exports.DEFAULT_PROFILE_ID = exports.PBKDF2_NUM_ROUNDS = void 0;
4
+ const sdk_1 = require("@bsv/sdk");
5
+ const PrivilegedKeyManager_1 = require("./sdk/PrivilegedKeyManager");
6
+ /**
7
+ * Number of rounds used in PBKDF2 for deriving password keys.
8
+ */
9
+ exports.PBKDF2_NUM_ROUNDS = 7777;
10
+ /**
11
+ * PBKDF-2 that prefers the browser / Node 20+ WebCrypto implementation and
12
+ * silently falls back to the existing JS code.
13
+ *
14
+ * @param passwordBytes Raw password bytes.
15
+ * @param salt Salt bytes.
16
+ * @param iterations Number of rounds.
17
+ * @param keyLen Desired key length in bytes.
18
+ * @param hash Digest algorithm (default "sha512").
19
+ * @returns Derived key bytes.
20
+ */
21
+ async function pbkdf2NativeOrJs(passwordBytes, salt, iterations, keyLen, hash = 'sha512') {
22
+ var _a;
23
+ // ----- fast-path: WebCrypto (both browser & recent Node expose globalThis.crypto.subtle)
24
+ const subtle = (_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.crypto) === null || _a === void 0 ? void 0 : _a.subtle;
25
+ if (subtle) {
26
+ try {
27
+ const baseKey = await subtle.importKey('raw', new Uint8Array(passwordBytes), { name: 'PBKDF2' },
28
+ /*extractable*/ false, ['deriveBits']);
29
+ const bits = await subtle.deriveBits({
30
+ name: 'PBKDF2',
31
+ salt: new Uint8Array(salt),
32
+ iterations,
33
+ hash: hash.toUpperCase()
34
+ }, baseKey, keyLen * 8);
35
+ return Array.from(new Uint8Array(bits));
36
+ }
37
+ catch (err) {
38
+ //console.warn('[pbkdf2] WebCrypto path failed → falling back to JS implementation', err)
39
+ /* fall through */
40
+ }
41
+ }
42
+ // ----- slow-path: old JavaScript implementation
43
+ return sdk_1.Hash.pbkdf2(passwordBytes, salt, iterations, keyLen, hash);
44
+ }
45
+ /**
46
+ * Unique Identifier for the default profile (16 zero bytes).
47
+ */
48
+ exports.DEFAULT_PROFILE_ID = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
49
+ /**
50
+ * @class OverlayUMPTokenInteractor
51
+ *
52
+ * A concrete implementation of the UMPTokenInteractor interface that interacts
53
+ * with Overlay Services and the UMP (User Management Protocol) topic. This class
54
+ * is responsible for:
55
+ *
56
+ * 1) Locating UMP tokens via overlay lookups (ls_users).
57
+ * 2) Creating and publishing new or updated UMP token outputs on-chain under
58
+ * the "tm_users" topic.
59
+ * 3) Consuming (spending) an old token if provided.
60
+ */
61
+ class OverlayUMPTokenInteractor {
62
+ /**
63
+ * Construct a new OverlayUMPTokenInteractor.
64
+ *
65
+ * @param resolver A LookupResolver instance for performing overlay queries (ls_users).
66
+ * @param broadcaster A SHIPBroadcaster instance for sharing new or updated tokens across the `tm_users` overlay.
67
+ */
68
+ constructor(resolver = new sdk_1.LookupResolver(), broadcaster = new sdk_1.SHIPBroadcaster(['tm_users'])) {
69
+ this.resolver = resolver;
70
+ this.broadcaster = broadcaster;
71
+ }
72
+ /**
73
+ * Finds a UMP token on-chain by the given presentation key hash, if it exists.
74
+ * Uses the ls_users overlay service to perform the lookup.
75
+ *
76
+ * @param hash The 32-byte SHA-256 hash of the presentation key.
77
+ * @returns A UMPToken object (including currentOutpoint) if found, otherwise undefined.
78
+ */
79
+ async findByPresentationKeyHash(hash) {
80
+ // Query ls_users for the given presentationHash
81
+ const question = {
82
+ service: 'ls_users',
83
+ query: { presentationHash: sdk_1.Utils.toHex(hash) }
84
+ };
85
+ const answer = await this.resolver.query(question);
86
+ return this.parseLookupAnswer(answer);
87
+ }
88
+ /**
89
+ * Finds a UMP token on-chain by the given recovery key hash, if it exists.
90
+ * Uses the ls_users overlay service to perform the lookup.
91
+ *
92
+ * @param hash The 32-byte SHA-256 hash of the recovery key.
93
+ * @returns A UMPToken object (including currentOutpoint) if found, otherwise undefined.
94
+ */
95
+ async findByRecoveryKeyHash(hash) {
96
+ const question = {
97
+ service: 'ls_users',
98
+ query: { recoveryHash: sdk_1.Utils.toHex(hash) }
99
+ };
100
+ const answer = await this.resolver.query(question);
101
+ return this.parseLookupAnswer(answer);
102
+ }
103
+ /**
104
+ * Creates or updates (replaces) a UMP token on-chain. If `oldTokenToConsume` is provided,
105
+ * it is spent in the same transaction that creates the new token output. The new token is
106
+ * then broadcast and published under the `tm_users` topic using a SHIP broadcast, ensuring
107
+ * overlay participants see the updated token.
108
+ *
109
+ * @param wallet The wallet used to build and sign the transaction (MUST be operating under the DEFAULT profile).
110
+ * @param adminOriginator The domain/FQDN of the administrative originator (wallet operator).
111
+ * @param token The new UMPToken to create on-chain.
112
+ * @param oldTokenToConsume Optionally, an existing token to consume/spend in the same transaction.
113
+ * @returns The outpoint of the newly created UMP token (e.g. "abcd1234...ef.0").
114
+ */
115
+ async buildAndSend(wallet, // This wallet MUST be the one built for the default profile
116
+ adminOriginator, token, oldTokenToConsume) {
117
+ // 1) Construct the data fields for the new UMP token.
118
+ const fields = [];
119
+ fields[0] = token.passwordSalt;
120
+ fields[1] = token.passwordPresentationPrimary;
121
+ fields[2] = token.passwordRecoveryPrimary;
122
+ fields[3] = token.presentationRecoveryPrimary;
123
+ fields[4] = token.passwordPrimaryPrivileged;
124
+ fields[5] = token.presentationRecoveryPrivileged;
125
+ fields[6] = token.presentationHash;
126
+ fields[7] = token.recoveryHash;
127
+ fields[8] = token.presentationKeyEncrypted;
128
+ fields[9] = token.passwordKeyEncrypted;
129
+ fields[10] = token.recoveryKeyEncrypted;
130
+ // Optional field (11) for encrypted profiles
131
+ if (token.profilesEncrypted) {
132
+ fields[11] = token.profilesEncrypted;
133
+ }
134
+ // 2) Create a PushDrop script referencing these fields, locked with the admin key.
135
+ const script = await new sdk_1.PushDrop(wallet, adminOriginator).lock(fields, [2, 'admin user management token'], // protocolID
136
+ '1', // keyID
137
+ 'self', // counterparty
138
+ /*forSelf=*/ true,
139
+ /*includeSignature=*/ true);
140
+ // 3) Prepare the createAction call. If oldTokenToConsume is provided, gather the outpoint.
141
+ const inputs = [];
142
+ let inputToken;
143
+ if (oldTokenToConsume === null || oldTokenToConsume === void 0 ? void 0 : oldTokenToConsume.currentOutpoint) {
144
+ inputToken = await this.findByOutpoint(oldTokenToConsume.currentOutpoint);
145
+ // If there is no token on the overlay, we can't consume it. Just start over with a new token.
146
+ if (!inputToken) {
147
+ oldTokenToConsume = undefined;
148
+ // Otherwise, add the input
149
+ }
150
+ else {
151
+ inputs.push({
152
+ outpoint: oldTokenToConsume.currentOutpoint,
153
+ unlockingScriptLength: 73, // typical signature length
154
+ inputDescription: 'Consume old UMP token'
155
+ });
156
+ }
157
+ }
158
+ const outputs = [
159
+ {
160
+ lockingScript: script.toHex(),
161
+ satoshis: 1,
162
+ outputDescription: 'New UMP token output'
163
+ }
164
+ ];
165
+ // 4) Build the partial transaction via createAction.
166
+ let createResult;
167
+ try {
168
+ createResult = await wallet.createAction({
169
+ description: oldTokenToConsume ? 'Renew UMP token (consume old, create new)' : 'Create new UMP token',
170
+ inputs,
171
+ outputs,
172
+ inputBEEF: inputToken === null || inputToken === void 0 ? void 0 : inputToken.beef,
173
+ options: {
174
+ randomizeOutputs: false,
175
+ acceptDelayedBroadcast: false
176
+ }
177
+ }, adminOriginator);
178
+ }
179
+ catch (e) {
180
+ console.error('Error with UMP token update. Attempting a last-ditch effort to get a new one', e);
181
+ createResult = await wallet.createAction({
182
+ description: 'Recover UMP token',
183
+ outputs,
184
+ options: {
185
+ randomizeOutputs: false,
186
+ acceptDelayedBroadcast: false
187
+ }
188
+ }, adminOriginator);
189
+ }
190
+ // If the transaction is fully processed by the wallet
191
+ if (!createResult.signableTransaction) {
192
+ const finalTxid = createResult.txid || (createResult.tx ? sdk_1.Transaction.fromAtomicBEEF(createResult.tx).id('hex') : undefined);
193
+ if (!finalTxid) {
194
+ throw new Error('No signableTransaction and no final TX found.');
195
+ }
196
+ // Now broadcast to `tm_users` using SHIP
197
+ const broadcastTx = sdk_1.Transaction.fromAtomicBEEF(createResult.tx);
198
+ const result = await this.broadcaster.broadcast(broadcastTx);
199
+ console.log('BROADCAST RESULT', result);
200
+ return `${finalTxid}.0`;
201
+ }
202
+ // 5) If oldTokenToConsume is present, we must sign the input referencing it.
203
+ // (If there's no old token, there's nothing to sign for the input.)
204
+ let finalTxid = '';
205
+ const reference = createResult.signableTransaction.reference;
206
+ const partialTx = sdk_1.Transaction.fromBEEF(createResult.signableTransaction.tx);
207
+ if (oldTokenToConsume === null || oldTokenToConsume === void 0 ? void 0 : oldTokenToConsume.currentOutpoint) {
208
+ // Unlock the old token with a matching PushDrop unlocker
209
+ const unlocker = new sdk_1.PushDrop(wallet, adminOriginator).unlock([2, 'admin user management token'], '1', 'self');
210
+ const unlockingScript = await unlocker.sign(partialTx, 0);
211
+ // Provide it to the wallet
212
+ const signResult = await wallet.signAction({
213
+ reference,
214
+ spends: {
215
+ 0: {
216
+ unlockingScript: unlockingScript.toHex()
217
+ }
218
+ }
219
+ }, adminOriginator);
220
+ finalTxid = signResult.txid || (signResult.tx ? sdk_1.Transaction.fromAtomicBEEF(signResult.tx).id('hex') : '');
221
+ if (!finalTxid) {
222
+ throw new Error('Could not finalize transaction for renewed UMP token.');
223
+ }
224
+ // 6) Broadcast to `tm_users`
225
+ const finalAtomicTx = signResult.tx;
226
+ if (!finalAtomicTx) {
227
+ throw new Error('Final transaction data missing after signing renewed UMP token.');
228
+ }
229
+ const broadcastTx = sdk_1.Transaction.fromAtomicBEEF(finalAtomicTx);
230
+ const result = await this.broadcaster.broadcast(broadcastTx);
231
+ console.log('BROADCAST RESULT', result);
232
+ return `${finalTxid}.0`;
233
+ }
234
+ else {
235
+ // Fallback for creating a new token (no input spending)
236
+ const signResult = await wallet.signAction({ reference, spends: {} }, adminOriginator);
237
+ finalTxid = signResult.txid || (signResult.tx ? sdk_1.Transaction.fromAtomicBEEF(signResult.tx).id('hex') : '');
238
+ if (!finalTxid) {
239
+ throw new Error('Failed to finalize new UMP token transaction.');
240
+ }
241
+ const finalAtomicTx = signResult.tx;
242
+ if (!finalAtomicTx) {
243
+ throw new Error('Final transaction data missing after signing new UMP token.');
244
+ }
245
+ const broadcastTx = sdk_1.Transaction.fromAtomicBEEF(finalAtomicTx);
246
+ const result = await this.broadcaster.broadcast(broadcastTx);
247
+ console.log('BROADCAST RESULT', result);
248
+ return `${finalTxid}.0`;
249
+ }
250
+ }
251
+ /**
252
+ * Attempts to parse a LookupAnswer from the UMP lookup service. If successful,
253
+ * extracts the token fields from the resulting transaction and constructs
254
+ * a UMPToken object.
255
+ *
256
+ * @param answer The LookupAnswer returned by a query to ls_users.
257
+ * @returns The parsed UMPToken or `undefined` if none found/decodable.
258
+ */
259
+ parseLookupAnswer(answer) {
260
+ var _a;
261
+ if (answer.type !== 'output-list') {
262
+ return undefined;
263
+ }
264
+ if (!answer.outputs || answer.outputs.length === 0) {
265
+ return undefined;
266
+ }
267
+ const { beef, outputIndex } = answer.outputs[0];
268
+ try {
269
+ const tx = sdk_1.Transaction.fromBEEF(beef);
270
+ const outpoint = `${tx.id('hex')}.${outputIndex}`;
271
+ const decoded = sdk_1.PushDrop.decode(tx.outputs[outputIndex].lockingScript);
272
+ // Expecting 11 or more fields for UMP
273
+ if (!decoded.fields || decoded.fields.length < 11) {
274
+ console.warn(`Unexpected number of fields in UMP token: ${(_a = decoded.fields) === null || _a === void 0 ? void 0 : _a.length}`);
275
+ return undefined;
276
+ }
277
+ // Build the UMP token from these fields, preserving outpoint
278
+ const t = {
279
+ // Order matches buildAndSend and serialize/deserialize
280
+ passwordSalt: decoded.fields[0],
281
+ passwordPresentationPrimary: decoded.fields[1],
282
+ passwordRecoveryPrimary: decoded.fields[2],
283
+ presentationRecoveryPrimary: decoded.fields[3],
284
+ passwordPrimaryPrivileged: decoded.fields[4],
285
+ presentationRecoveryPrivileged: decoded.fields[5],
286
+ presentationHash: decoded.fields[6],
287
+ recoveryHash: decoded.fields[7],
288
+ presentationKeyEncrypted: decoded.fields[8],
289
+ passwordKeyEncrypted: decoded.fields[9],
290
+ recoveryKeyEncrypted: decoded.fields[10],
291
+ profilesEncrypted: decoded.fields[12] ? decoded.fields[11] : undefined, // If there's a signature in field 12, use field 11
292
+ currentOutpoint: outpoint
293
+ };
294
+ return t;
295
+ }
296
+ catch (e) {
297
+ console.error('Failed to parse or decode UMP token:', e);
298
+ return undefined;
299
+ }
300
+ }
301
+ /**
302
+ * Finds by outpoint for unlocking / spending previous tokens.
303
+ * @param outpoint The outpoint we are searching by
304
+ * @returns The result so that we can use it to unlock the transaction
305
+ */
306
+ async findByOutpoint(outpoint) {
307
+ const results = await this.resolver.query({
308
+ service: 'ls_users',
309
+ query: {
310
+ outpoint
311
+ }
312
+ });
313
+ if (results.type !== 'output-list') {
314
+ return undefined;
315
+ }
316
+ if (!results.outputs || !results.outputs.length) {
317
+ return undefined;
318
+ }
319
+ return results.outputs[0];
320
+ }
321
+ }
322
+ exports.OverlayUMPTokenInteractor = OverlayUMPTokenInteractor;
323
+ /**
324
+ * Manages a "CWI-style" wallet that uses a UMP token and a
325
+ * multi-key authentication scheme (password, presentation key, and recovery key),
326
+ * supporting multiple user profiles under a single account.
327
+ */
328
+ class CWIStyleWalletManager {
329
+ /**
330
+ * Constructs a new CWIStyleWalletManager.
331
+ *
332
+ * @param adminOriginator The domain name of the administrative originator.
333
+ * @param walletBuilder A function that can build an underlying wallet instance for a profile.
334
+ * @param interactor An instance of UMPTokenInteractor.
335
+ * @param recoveryKeySaver A function to persist a new recovery key.
336
+ * @param passwordRetriever A function to request the user's password.
337
+ * @param newWalletFunder Optional function to fund a new wallet.
338
+ * @param stateSnapshot Optional previously saved state snapshot.
339
+ */
340
+ constructor(adminOriginator, walletBuilder, interactor = new OverlayUMPTokenInteractor(), recoveryKeySaver, passwordRetriever, newWalletFunder, stateSnapshot) {
341
+ /**
342
+ * Current mode of authentication.
343
+ */
344
+ this.authenticationMode = 'presentation-key-and-password';
345
+ /**
346
+ * Indicates new user or existing user flow.
347
+ */
348
+ this.authenticationFlow = 'new-user';
349
+ /**
350
+ * The currently active profile ID (null or DEFAULT_PROFILE_ID means default profile).
351
+ */
352
+ this.activeProfileId = exports.DEFAULT_PROFILE_ID;
353
+ /**
354
+ * List of loaded non-default profiles.
355
+ */
356
+ this.profiles = [];
357
+ this.adminOriginator = adminOriginator;
358
+ this.walletBuilder = walletBuilder;
359
+ this.UMPTokenInteractor = interactor;
360
+ this.recoveryKeySaver = recoveryKeySaver;
361
+ this.passwordRetriever = passwordRetriever;
362
+ this.authenticated = false;
363
+ this.newWalletFunder = newWalletFunder;
364
+ // If a saved snapshot is provided, attempt to load it.
365
+ // Note: loadSnapshot now returns a promise. We don't await it here,
366
+ // as the constructor must be synchronous. The caller should check
367
+ // `this.authenticated` after construction if a snapshot was provided.
368
+ if (stateSnapshot) {
369
+ this.loadSnapshot(stateSnapshot).catch(err => {
370
+ console.error('Failed to load snapshot during construction:', err);
371
+ // Clear potentially partially loaded state
372
+ this.destroy();
373
+ });
374
+ }
375
+ }
376
+ // --- Authentication Methods ---
377
+ /**
378
+ * Provides the presentation key.
379
+ */
380
+ async providePresentationKey(key) {
381
+ if (this.authenticated) {
382
+ throw new Error('User is already authenticated');
383
+ }
384
+ if (this.authenticationMode === 'recovery-key-and-password') {
385
+ throw new Error('Presentation key is not needed in this mode');
386
+ }
387
+ const hash = sdk_1.Hash.sha256(key);
388
+ const token = await this.UMPTokenInteractor.findByPresentationKeyHash(hash);
389
+ if (!token) {
390
+ // No token found -> New user
391
+ this.authenticationFlow = 'new-user';
392
+ this.presentationKey = key;
393
+ }
394
+ else {
395
+ // Found token -> existing user
396
+ this.authenticationFlow = 'existing-user';
397
+ this.presentationKey = key;
398
+ this.currentUMPToken = token;
399
+ }
400
+ }
401
+ /**
402
+ * Provides the password.
403
+ */
404
+ async providePassword(password) {
405
+ if (this.authenticated) {
406
+ throw new Error('User is already authenticated');
407
+ }
408
+ if (this.authenticationMode === 'presentation-key-and-recovery-key') {
409
+ throw new Error('Password is not needed in this mode');
410
+ }
411
+ if (this.authenticationFlow === 'existing-user') {
412
+ // Existing user flow
413
+ if (!this.currentUMPToken) {
414
+ throw new Error('Provide presentation or recovery key first.');
415
+ }
416
+ const derivedPasswordKey = await pbkdf2NativeOrJs(sdk_1.Utils.toArray(password, 'utf8'), this.currentUMPToken.passwordSalt, exports.PBKDF2_NUM_ROUNDS, 32, 'sha512');
417
+ let rootPrimaryKey;
418
+ let rootPrivilegedKey; // Only needed for recovery mode
419
+ if (this.authenticationMode === 'presentation-key-and-password') {
420
+ if (!this.presentationKey)
421
+ throw new Error('No presentation key found!');
422
+ const xorKey = this.XOR(this.presentationKey, derivedPasswordKey);
423
+ rootPrimaryKey = new sdk_1.SymmetricKey(xorKey).decrypt(this.currentUMPToken.passwordPresentationPrimary);
424
+ }
425
+ else {
426
+ // 'recovery-key-and-password'
427
+ if (!this.recoveryKey)
428
+ throw new Error('No recovery key found!');
429
+ const primaryDecryptionKey = this.XOR(this.recoveryKey, derivedPasswordKey);
430
+ rootPrimaryKey = new sdk_1.SymmetricKey(primaryDecryptionKey).decrypt(this.currentUMPToken.passwordRecoveryPrimary);
431
+ const privilegedDecryptionKey = this.XOR(rootPrimaryKey, derivedPasswordKey);
432
+ rootPrivilegedKey = new sdk_1.SymmetricKey(privilegedDecryptionKey).decrypt(this.currentUMPToken.passwordPrimaryPrivileged);
433
+ }
434
+ // Build root infrastructure, load profiles, and switch to default profile initially
435
+ await this.setupRootInfrastructure(rootPrimaryKey, rootPrivilegedKey);
436
+ await this.switchProfile(this.activeProfileId);
437
+ }
438
+ else {
439
+ // New user flow (only 'presentation-key-and-password')
440
+ if (this.authenticationMode !== 'presentation-key-and-password') {
441
+ throw new Error('New-user flow requires presentation key and password mode.');
442
+ }
443
+ if (!this.presentationKey) {
444
+ throw new Error('No presentation key provided for new-user flow.');
445
+ }
446
+ // Generate new keys/salt
447
+ const recoveryKey = (0, sdk_1.Random)(32);
448
+ await this.recoveryKeySaver(recoveryKey);
449
+ const passwordSalt = (0, sdk_1.Random)(32);
450
+ const passwordKey = await pbkdf2NativeOrJs(sdk_1.Utils.toArray(password, 'utf8'), passwordSalt, exports.PBKDF2_NUM_ROUNDS, 32, 'sha512');
451
+ const rootPrimaryKey = (0, sdk_1.Random)(32);
452
+ const rootPrivilegedKey = (0, sdk_1.Random)(32);
453
+ // Build XOR keys
454
+ const presentationPassword = new sdk_1.SymmetricKey(this.XOR(this.presentationKey, passwordKey));
455
+ const presentationRecovery = new sdk_1.SymmetricKey(this.XOR(this.presentationKey, recoveryKey));
456
+ const recoveryPassword = new sdk_1.SymmetricKey(this.XOR(recoveryKey, passwordKey));
457
+ const primaryPassword = new sdk_1.SymmetricKey(this.XOR(rootPrimaryKey, passwordKey));
458
+ // Temp manager for encryption
459
+ const tempPrivilegedKeyManager = new PrivilegedKeyManager_1.PrivilegedKeyManager(async () => new sdk_1.PrivateKey(rootPrivilegedKey));
460
+ // Build new UMP token (no profiles initially)
461
+ const newToken = {
462
+ passwordSalt,
463
+ passwordPresentationPrimary: presentationPassword.encrypt(rootPrimaryKey),
464
+ passwordRecoveryPrimary: recoveryPassword.encrypt(rootPrimaryKey),
465
+ presentationRecoveryPrimary: presentationRecovery.encrypt(rootPrimaryKey),
466
+ passwordPrimaryPrivileged: primaryPassword.encrypt(rootPrivilegedKey),
467
+ presentationRecoveryPrivileged: presentationRecovery.encrypt(rootPrivilegedKey),
468
+ presentationHash: sdk_1.Hash.sha256(this.presentationKey),
469
+ recoveryHash: sdk_1.Hash.sha256(recoveryKey),
470
+ presentationKeyEncrypted: (await tempPrivilegedKeyManager.encrypt({
471
+ plaintext: this.presentationKey,
472
+ protocolID: [2, 'admin key wrapping'],
473
+ keyID: '1'
474
+ })).ciphertext,
475
+ passwordKeyEncrypted: (await tempPrivilegedKeyManager.encrypt({
476
+ plaintext: passwordKey,
477
+ protocolID: [2, 'admin key wrapping'],
478
+ keyID: '1'
479
+ })).ciphertext,
480
+ recoveryKeyEncrypted: (await tempPrivilegedKeyManager.encrypt({
481
+ plaintext: recoveryKey,
482
+ protocolID: [2, 'admin key wrapping'],
483
+ keyID: '1'
484
+ })).ciphertext,
485
+ profilesEncrypted: undefined // No profiles yet
486
+ };
487
+ this.currentUMPToken = newToken;
488
+ // Setup root infrastructure and switch to default profile
489
+ await this.setupRootInfrastructure(rootPrimaryKey);
490
+ await this.switchProfile(exports.DEFAULT_PROFILE_ID);
491
+ // Fund the *default* wallet if funder provided
492
+ if (this.newWalletFunder && this.underlying) {
493
+ try {
494
+ await this.newWalletFunder(this.presentationKey, this.underlying, this.adminOriginator);
495
+ }
496
+ catch (e) {
497
+ console.error('Error funding new wallet:', e);
498
+ // Decide if this should halt the process or just log
499
+ }
500
+ }
501
+ // Publish the new UMP token *after* potentially funding
502
+ // We need the default profile wallet to sign the UMP creation TX
503
+ if (!this.underlying) {
504
+ throw new Error('Default profile wallet not built before attempting to publish UMP token.');
505
+ }
506
+ this.currentUMPToken.currentOutpoint = await this.UMPTokenInteractor.buildAndSend(this.underlying, // Use the default profile wallet
507
+ this.adminOriginator, newToken);
508
+ }
509
+ }
510
+ /**
511
+ * Provides the recovery key.
512
+ */
513
+ async provideRecoveryKey(recoveryKey) {
514
+ if (this.authenticated) {
515
+ throw new Error('Already authenticated');
516
+ }
517
+ if (this.authenticationFlow === 'new-user') {
518
+ throw new Error('Do not submit recovery key in new-user flow');
519
+ }
520
+ if (this.authenticationMode === 'presentation-key-and-password') {
521
+ throw new Error('No recovery key required in this mode');
522
+ }
523
+ else if (this.authenticationMode === 'recovery-key-and-password') {
524
+ // Wait for password
525
+ const hash = sdk_1.Hash.sha256(recoveryKey);
526
+ const token = await this.UMPTokenInteractor.findByRecoveryKeyHash(hash);
527
+ if (!token)
528
+ throw new Error('No user found with this recovery key');
529
+ this.recoveryKey = recoveryKey;
530
+ this.currentUMPToken = token;
531
+ }
532
+ else {
533
+ // 'presentation-key-and-recovery-key'
534
+ if (!this.presentationKey)
535
+ throw new Error('Provide the presentation key first');
536
+ if (!this.currentUMPToken)
537
+ throw new Error('Current UMP token not found');
538
+ const xorKey = this.XOR(this.presentationKey, recoveryKey);
539
+ const rootPrimaryKey = new sdk_1.SymmetricKey(xorKey).decrypt(this.currentUMPToken.presentationRecoveryPrimary);
540
+ const rootPrivilegedKey = new sdk_1.SymmetricKey(xorKey).decrypt(this.currentUMPToken.presentationRecoveryPrivileged);
541
+ // Build root infrastructure, load profiles, switch to default
542
+ await this.setupRootInfrastructure(rootPrimaryKey, rootPrivilegedKey);
543
+ await this.switchProfile(this.activeProfileId);
544
+ }
545
+ }
546
+ // --- State Management Methods ---
547
+ /**
548
+ * Saves the current wallet state (root key, UMP token, active profile) into an encrypted snapshot.
549
+ * Version 2 format: [1 byte version=2] + [32 byte snapshot key] + [16 byte activeProfileId] + [encrypted payload]
550
+ * Encrypted Payload: [32 byte rootPrimaryKey] + [varint token length + serialized UMP token]
551
+ *
552
+ * @returns Encrypted snapshot bytes.
553
+ */
554
+ saveSnapshot() {
555
+ if (!this.rootPrimaryKey || !this.currentUMPToken) {
556
+ throw new Error('No root primary key or current UMP token set');
557
+ }
558
+ const snapshotKey = (0, sdk_1.Random)(32);
559
+ const snapshotPreimageWriter = new sdk_1.Utils.Writer();
560
+ // Write root primary key
561
+ snapshotPreimageWriter.write(this.rootPrimaryKey);
562
+ // Write serialized UMP token (must have outpoint)
563
+ if (!this.currentUMPToken.currentOutpoint) {
564
+ throw new Error('UMP token cannot be saved without a current outpoint.');
565
+ }
566
+ const serializedToken = this.serializeUMPToken(this.currentUMPToken);
567
+ snapshotPreimageWriter.writeVarIntNum(serializedToken.length);
568
+ snapshotPreimageWriter.write(serializedToken);
569
+ // Encrypt the payload
570
+ const snapshotPreimage = snapshotPreimageWriter.toArray();
571
+ const snapshotPayload = new sdk_1.SymmetricKey(snapshotKey).encrypt(snapshotPreimage);
572
+ // Build final snapshot (Version 2)
573
+ const snapshotWriter = new sdk_1.Utils.Writer();
574
+ snapshotWriter.writeUInt8(2); // Version
575
+ snapshotWriter.write(snapshotKey);
576
+ snapshotWriter.write(this.activeProfileId); // Active profile ID
577
+ snapshotWriter.write(snapshotPayload); // Encrypted data
578
+ return snapshotWriter.toArray();
579
+ }
580
+ /**
581
+ * Loads a previously saved state snapshot. Restores root key, UMP token, profiles, and active profile.
582
+ * Handles Version 1 (legacy) and Version 2 formats.
583
+ *
584
+ * @param snapshot Encrypted snapshot bytes.
585
+ */
586
+ async loadSnapshot(snapshot) {
587
+ try {
588
+ const reader = new sdk_1.Utils.Reader(snapshot);
589
+ const version = reader.readUInt8();
590
+ let snapshotKey;
591
+ let encryptedPayload;
592
+ let activeProfileId = exports.DEFAULT_PROFILE_ID; // Default for V1
593
+ if (version === 1) {
594
+ snapshotKey = reader.read(32);
595
+ encryptedPayload = reader.read();
596
+ }
597
+ else if (version === 2) {
598
+ snapshotKey = reader.read(32);
599
+ activeProfileId = reader.read(16); // Read active profile ID
600
+ encryptedPayload = reader.read();
601
+ }
602
+ else {
603
+ throw new Error(`Unsupported snapshot version: ${version}`);
604
+ }
605
+ // Decrypt payload
606
+ const decryptedPayload = new sdk_1.SymmetricKey(snapshotKey).decrypt(encryptedPayload);
607
+ const payloadReader = new sdk_1.Utils.Reader(decryptedPayload);
608
+ // Read root primary key
609
+ const rootPrimaryKey = payloadReader.read(32);
610
+ // Read serialized UMP token
611
+ const tokenLen = payloadReader.readVarIntNum();
612
+ const tokenBytes = payloadReader.read(tokenLen);
613
+ const token = this.deserializeUMPToken(tokenBytes);
614
+ // Assign loaded data
615
+ this.currentUMPToken = token;
616
+ // Setup root infrastructure, load profiles, and switch to the loaded active profile
617
+ await this.setupRootInfrastructure(rootPrimaryKey); // Will automatically load profiles
618
+ await this.switchProfile(activeProfileId); // Switch to the profile saved in the snapshot
619
+ this.authenticationFlow = 'existing-user'; // Loading implies existing user
620
+ }
621
+ catch (error) {
622
+ this.destroy(); // Clear state on error
623
+ throw new Error(`Failed to load snapshot: ${error.message}`);
624
+ }
625
+ }
626
+ async syncUMPToken() {
627
+ if (!this.authenticated || !this.currentUMPToken || !this.rootPrimaryKey) {
628
+ throw new Error('Wallet not authenticated or missing UMP token.');
629
+ }
630
+ const currentToken = this.currentUMPToken;
631
+ let refreshed;
632
+ if (currentToken.presentationHash && currentToken.presentationHash.length) {
633
+ refreshed = await this.UMPTokenInteractor.findByPresentationKeyHash(currentToken.presentationHash);
634
+ }
635
+ if (!refreshed && currentToken.recoveryHash && currentToken.recoveryHash.length) {
636
+ refreshed = await this.UMPTokenInteractor.findByRecoveryKeyHash(currentToken.recoveryHash);
637
+ }
638
+ if (!refreshed) {
639
+ return false;
640
+ }
641
+ if (refreshed.currentOutpoint &&
642
+ currentToken.currentOutpoint &&
643
+ refreshed.currentOutpoint === currentToken.currentOutpoint) {
644
+ return false;
645
+ }
646
+ this.currentUMPToken = refreshed;
647
+ await this.setupRootInfrastructure(this.rootPrimaryKey);
648
+ this.saveSnapshot();
649
+ return true;
650
+ }
651
+ /**
652
+ * Destroys the wallet state, clearing keys, tokens, and profiles.
653
+ */
654
+ destroy() {
655
+ this.underlying = undefined;
656
+ this.rootPrivilegedKeyManager = undefined;
657
+ this.authenticated = false;
658
+ this.rootPrimaryKey = undefined;
659
+ this.currentUMPToken = undefined;
660
+ this.presentationKey = undefined;
661
+ this.recoveryKey = undefined;
662
+ this.profiles = [];
663
+ this.activeProfileId = exports.DEFAULT_PROFILE_ID;
664
+ this.authenticationMode = 'presentation-key-and-password';
665
+ this.authenticationFlow = 'new-user';
666
+ }
667
+ // --- Profile Management Methods ---
668
+ /**
669
+ * Lists all available profiles, including the default profile.
670
+ * @returns Array of profile info objects, including an 'active' flag.
671
+ */
672
+ listProfiles() {
673
+ if (!this.authenticated) {
674
+ throw new Error('Not authenticated.');
675
+ }
676
+ const profileList = [
677
+ // Default profile
678
+ {
679
+ id: exports.DEFAULT_PROFILE_ID,
680
+ name: 'default',
681
+ createdAt: null, // Default profile doesn't have a creation timestamp in the same way
682
+ active: this.activeProfileId.every(x => x === 0),
683
+ identityKey: new sdk_1.PrivateKey(this.rootPrimaryKey).toPublicKey().toString()
684
+ },
685
+ // Other profiles
686
+ ...this.profiles.map(p => ({
687
+ id: p.id,
688
+ name: p.name,
689
+ createdAt: p.createdAt,
690
+ active: this.activeProfileId.every((x, i) => x === p.id[i]),
691
+ identityKey: new sdk_1.PrivateKey(this.XOR(this.rootPrimaryKey, p.primaryPad)).toPublicKey().toString()
692
+ }))
693
+ ];
694
+ return profileList;
695
+ }
696
+ /**
697
+ * Adds a new profile with the given name.
698
+ * Generates necessary pads and updates the UMP token.
699
+ * Does not switch to the new profile automatically.
700
+ *
701
+ * @param name The desired name for the new profile.
702
+ * @returns The ID of the newly created profile.
703
+ */
704
+ async addProfile(name) {
705
+ if (!this.authenticated || !this.rootPrimaryKey || !this.currentUMPToken || !this.rootPrivilegedKeyManager) {
706
+ throw new Error('Wallet not fully initialized or authenticated.');
707
+ }
708
+ // Ensure name is unique (including 'default')
709
+ if (name === 'default' || this.profiles.some(p => p.name.toLowerCase() === name.toLowerCase())) {
710
+ throw new Error(`Profile name "${name}" is already in use.`);
711
+ }
712
+ const newProfile = {
713
+ name,
714
+ id: (0, sdk_1.Random)(16),
715
+ primaryPad: (0, sdk_1.Random)(32),
716
+ privilegedPad: (0, sdk_1.Random)(32),
717
+ createdAt: Math.floor(Date.now() / 1000)
718
+ };
719
+ this.profiles.push(newProfile);
720
+ // Update the UMP token with the new profile list
721
+ await this.updateAuthFactors(this.currentUMPToken.passwordSalt,
722
+ // Need to re-derive/decrypt factors needed for re-encryption
723
+ await this.getFactor('passwordKey'), await this.getFactor('presentationKey'), await this.getFactor('recoveryKey'), this.rootPrimaryKey, await this.getFactor('privilegedKey'), // Get ROOT privileged key
724
+ this.profiles // Pass the updated profile list
725
+ );
726
+ return newProfile.id;
727
+ }
728
+ /**
729
+ * Deletes a profile by its ID.
730
+ * Cannot delete the default profile. If the active profile is deleted,
731
+ * it switches back to the default profile.
732
+ *
733
+ * @param profileId The 16-byte ID of the profile to delete.
734
+ */
735
+ async deleteProfile(profileId) {
736
+ if (!this.authenticated || !this.rootPrimaryKey || !this.currentUMPToken || !this.rootPrivilegedKeyManager) {
737
+ throw new Error('Wallet not fully initialized or authenticated.');
738
+ }
739
+ if (profileId.every(x => x === 0)) {
740
+ throw new Error('Cannot delete the default profile.');
741
+ }
742
+ const profileIndex = this.profiles.findIndex(p => p.id.every((x, i) => x === profileId[i]));
743
+ if (profileIndex === -1) {
744
+ throw new Error('Profile not found.');
745
+ }
746
+ // Remove the profile
747
+ this.profiles.splice(profileIndex, 1);
748
+ // If the deleted profile was active, switch to default
749
+ if (this.activeProfileId.every((x, i) => x === profileId[i])) {
750
+ await this.switchProfile(exports.DEFAULT_PROFILE_ID); // This rebuilds the wallet
751
+ }
752
+ // Update the UMP token
753
+ 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
754
+ this.profiles // Pass updated list
755
+ );
756
+ }
757
+ /**
758
+ * Switches the active profile. This re-derives keys and rebuilds the underlying wallet.
759
+ *
760
+ * @param profileId The 16-byte ID of the profile to switch to (use DEFAULT_PROFILE_ID for default).
761
+ */
762
+ async switchProfile(profileId) {
763
+ if (!this.authenticated || !this.rootPrimaryKey || !this.rootPrivilegedKeyManager) {
764
+ throw new Error('Cannot switch profile: Wallet not authenticated or root keys missing.');
765
+ }
766
+ let profilePrimaryKey;
767
+ let profilePrivilegedPad; // Pad for the target profile
768
+ if (profileId.every(x => x === 0)) {
769
+ // Switching to default profile
770
+ profilePrimaryKey = this.rootPrimaryKey;
771
+ profilePrivilegedPad = undefined; // No pad for default
772
+ this.activeProfileId = exports.DEFAULT_PROFILE_ID;
773
+ }
774
+ else {
775
+ // Switching to a non-default profile
776
+ const profile = this.profiles.find(p => p.id.every((x, i) => x === profileId[i]));
777
+ if (!profile) {
778
+ throw new Error('Profile not found.');
779
+ }
780
+ profilePrimaryKey = this.XOR(this.rootPrimaryKey, profile.primaryPad);
781
+ profilePrivilegedPad = profile.privilegedPad;
782
+ this.activeProfileId = profileId;
783
+ }
784
+ // Create a *profile-specific* PrivilegedKeyManager.
785
+ // It uses the ROOT manager internally but applies the profile's pad.
786
+ const profilePrivilegedKeyManager = new PrivilegedKeyManager_1.PrivilegedKeyManager(async (reason) => {
787
+ // Request the ROOT privileged key using the root manager
788
+ const rootPrivileged = await this.rootPrivilegedKeyManager.getPrivilegedKey(reason);
789
+ const rootPrivilegedBytes = rootPrivileged.toArray();
790
+ // Apply the profile's pad if applicable
791
+ const profilePrivilegedBytes = profilePrivilegedPad
792
+ ? this.XOR(rootPrivilegedBytes, profilePrivilegedPad)
793
+ : rootPrivilegedBytes;
794
+ return new sdk_1.PrivateKey(profilePrivilegedBytes);
795
+ });
796
+ // Build the underlying wallet for the specific profile
797
+ this.underlying = await this.walletBuilder(profilePrimaryKey, profilePrivilegedKeyManager, // Pass the profile-specific manager
798
+ this.activeProfileId // Pass the ID of the profile being activated
799
+ );
800
+ }
801
+ // --- Key Management Methods ---
802
+ /**
803
+ * Changes the user's password. Re-wraps keys and updates the UMP token.
804
+ */
805
+ async changePassword(newPassword) {
806
+ if (!this.authenticated || !this.currentUMPToken || !this.rootPrimaryKey || !this.rootPrivilegedKeyManager) {
807
+ throw new Error('Not authenticated or missing required data.');
808
+ }
809
+ const passwordSalt = (0, sdk_1.Random)(32);
810
+ const newPasswordKey = await pbkdf2NativeOrJs(sdk_1.Utils.toArray(newPassword, 'utf8'), passwordSalt, exports.PBKDF2_NUM_ROUNDS, 32, 'sha512');
811
+ // Decrypt existing factors needed for re-encryption, using the *root* privileged key manager
812
+ const recoveryKey = await this.getFactor('recoveryKey');
813
+ const presentationKey = await this.getFactor('presentationKey');
814
+ const rootPrivilegedKey = await this.getFactor('privilegedKey'); // Get ROOT privileged key
815
+ await this.updateAuthFactors(passwordSalt, newPasswordKey, presentationKey, recoveryKey, this.rootPrimaryKey, rootPrivilegedKey, // Pass the explicitly fetched root key
816
+ this.profiles // Preserve existing profiles
817
+ );
818
+ }
819
+ /**
820
+ * Retrieves the current recovery key. Requires privileged access.
821
+ */
822
+ async getRecoveryKey() {
823
+ if (!this.authenticated || !this.currentUMPToken || !this.rootPrivilegedKeyManager) {
824
+ throw new Error('Not authenticated or missing required data.');
825
+ }
826
+ return this.getFactor('recoveryKey');
827
+ }
828
+ /**
829
+ * Changes the user's recovery key. Prompts user to save the new key.
830
+ */
831
+ async changeRecoveryKey() {
832
+ if (!this.authenticated || !this.currentUMPToken || !this.rootPrimaryKey || !this.rootPrivilegedKeyManager) {
833
+ throw new Error('Not authenticated or missing required data.');
834
+ }
835
+ // Decrypt existing factors needed
836
+ const passwordKey = await this.getFactor('passwordKey');
837
+ const presentationKey = await this.getFactor('presentationKey');
838
+ const rootPrivilegedKey = await this.getFactor('privilegedKey'); // Get ROOT privileged key
839
+ // Generate and save new recovery key
840
+ const newRecoveryKey = (0, sdk_1.Random)(32);
841
+ await this.recoveryKeySaver(newRecoveryKey);
842
+ await this.updateAuthFactors(this.currentUMPToken.passwordSalt, passwordKey, presentationKey, newRecoveryKey, // Use the new key
843
+ this.rootPrimaryKey, rootPrivilegedKey, this.profiles // Preserve profiles
844
+ );
845
+ }
846
+ /**
847
+ * Changes the user's presentation key.
848
+ */
849
+ async changePresentationKey(newPresentationKey) {
850
+ if (!this.authenticated || !this.currentUMPToken || !this.rootPrimaryKey || !this.rootPrivilegedKeyManager) {
851
+ throw new Error('Not authenticated or missing required data.');
852
+ }
853
+ if (newPresentationKey.length !== 32) {
854
+ throw new Error('Presentation key must be 32 bytes.');
855
+ }
856
+ // Decrypt existing factors
857
+ const recoveryKey = await this.getFactor('recoveryKey');
858
+ const passwordKey = await this.getFactor('passwordKey');
859
+ const rootPrivilegedKey = await this.getFactor('privilegedKey'); // Get ROOT privileged key
860
+ await this.updateAuthFactors(this.currentUMPToken.passwordSalt, passwordKey, newPresentationKey, // Use the new key
861
+ recoveryKey, this.rootPrimaryKey, rootPrivilegedKey, this.profiles // Preserve profiles
862
+ );
863
+ // Update the temporarily stored key if it was set
864
+ if (this.presentationKey) {
865
+ this.presentationKey = newPresentationKey;
866
+ }
867
+ }
868
+ // --- Internal Helper Methods ---
869
+ /**
870
+ * Performs XOR operation on two byte arrays.
871
+ */
872
+ XOR(n1, n2) {
873
+ if (n1.length !== n2.length) {
874
+ // Provide more context in error
875
+ throw new Error(`XOR length mismatch: ${n1.length} vs ${n2.length}`);
876
+ }
877
+ const r = new Array(n1.length);
878
+ for (let i = 0; i < n1.length; i++) {
879
+ r[i] = n1[i] ^ n2[i];
880
+ }
881
+ return r;
882
+ }
883
+ /**
884
+ * Helper to decrypt a specific factor (key) stored encrypted in the UMP token.
885
+ * Requires the root privileged key manager.
886
+ * @param factorName Name of the factor to decrypt ('passwordKey', 'presentationKey', 'recoveryKey', 'privilegedKey').
887
+ * @param getRoot If true and factorName is 'privilegedKey', returns the root privileged key bytes directly.
888
+ * @returns The decrypted key bytes.
889
+ */
890
+ async getFactor(factorName) {
891
+ if (!this.authenticated || !this.currentUMPToken || !this.rootPrivilegedKeyManager) {
892
+ throw new Error(`Cannot get factor "${factorName}": Wallet not ready.`);
893
+ }
894
+ const protocolID = [2, 'admin key wrapping']; // Protocol used for encrypting factors
895
+ const keyID = '1'; // Key ID used
896
+ try {
897
+ switch (factorName) {
898
+ case 'passwordKey':
899
+ return (await this.rootPrivilegedKeyManager.decrypt({
900
+ ciphertext: this.currentUMPToken.passwordKeyEncrypted,
901
+ protocolID,
902
+ keyID
903
+ })).plaintext;
904
+ case 'presentationKey':
905
+ return (await this.rootPrivilegedKeyManager.decrypt({
906
+ ciphertext: this.currentUMPToken.presentationKeyEncrypted,
907
+ protocolID,
908
+ keyID
909
+ })).plaintext;
910
+ case 'recoveryKey':
911
+ return (await this.rootPrivilegedKeyManager.decrypt({
912
+ ciphertext: this.currentUMPToken.recoveryKeyEncrypted,
913
+ protocolID,
914
+ keyID
915
+ })).plaintext;
916
+ case 'privilegedKey': {
917
+ // This needs careful handling based on whether the ROOT or PROFILE key is needed.
918
+ // This helper is mostly used for UMP updates, which need the ROOT key.
919
+ // We retrieve the PrivateKey object first.
920
+ const pk = await this.rootPrivilegedKeyManager.getPrivilegedKey('UMP token update', true); // Force retrieval of root key
921
+ return pk.toArray(); // Return bytes
922
+ }
923
+ default:
924
+ throw new Error(`Unknown factor name: ${factorName}`);
925
+ }
926
+ }
927
+ catch (error) {
928
+ console.error(`Error decrypting factor ${factorName}:`, error);
929
+ throw new Error(`Failed to decrypt factor "${factorName}": ${error.message}`);
930
+ }
931
+ }
932
+ /**
933
+ * Recomputes UMP token fields with updated factors and profiles, then publishes the update.
934
+ * This operation requires the *root* privileged key and the *default* profile wallet.
935
+ */
936
+ async updateAuthFactors(passwordSalt, passwordKey, presentationKey, recoveryKey, rootPrimaryKey, rootPrivilegedKey, // Explicitly pass the root key bytes
937
+ profiles // Pass current/new profiles list
938
+ ) {
939
+ if (!this.authenticated || !this.rootPrimaryKey || !this.currentUMPToken) {
940
+ throw new Error('Wallet is not properly authenticated or missing data for update.');
941
+ }
942
+ // Ensure we have the OLD token to consume
943
+ const oldTokenToConsume = { ...this.currentUMPToken };
944
+ if (!oldTokenToConsume.currentOutpoint) {
945
+ throw new Error('Cannot update UMP token: Old token has no outpoint.');
946
+ }
947
+ // Derive symmetrical encryption keys using XOR for the *root* keys
948
+ const presentationPassword = new sdk_1.SymmetricKey(this.XOR(presentationKey, passwordKey));
949
+ const presentationRecovery = new sdk_1.SymmetricKey(this.XOR(presentationKey, recoveryKey));
950
+ const recoveryPassword = new sdk_1.SymmetricKey(this.XOR(recoveryKey, passwordKey));
951
+ const primaryPassword = new sdk_1.SymmetricKey(this.XOR(rootPrimaryKey, passwordKey)); // Use rootPrimaryKey
952
+ // Build a temporary privileged key manager using the explicit ROOT privileged key
953
+ const tempRootPrivilegedKeyManager = new PrivilegedKeyManager_1.PrivilegedKeyManager(async () => new sdk_1.PrivateKey(rootPrivilegedKey));
954
+ // Encrypt profiles if provided
955
+ let profilesEncrypted;
956
+ if (profiles && profiles.length > 0) {
957
+ const profilesJson = JSON.stringify(profiles);
958
+ const profilesBytes = sdk_1.Utils.toArray(profilesJson, 'utf8');
959
+ profilesEncrypted = new sdk_1.SymmetricKey(rootPrimaryKey).encrypt(profilesBytes);
960
+ }
961
+ // Construct the new UMP token data
962
+ const newTokenData = {
963
+ passwordSalt,
964
+ passwordPresentationPrimary: presentationPassword.encrypt(rootPrimaryKey),
965
+ passwordRecoveryPrimary: recoveryPassword.encrypt(rootPrimaryKey),
966
+ presentationRecoveryPrimary: presentationRecovery.encrypt(rootPrimaryKey),
967
+ passwordPrimaryPrivileged: primaryPassword.encrypt(rootPrivilegedKey),
968
+ presentationRecoveryPrivileged: presentationRecovery.encrypt(rootPrivilegedKey),
969
+ presentationHash: sdk_1.Hash.sha256(presentationKey),
970
+ recoveryHash: sdk_1.Hash.sha256(recoveryKey),
971
+ presentationKeyEncrypted: (await tempRootPrivilegedKeyManager.encrypt({
972
+ plaintext: presentationKey,
973
+ protocolID: [2, 'admin key wrapping'],
974
+ keyID: '1'
975
+ })).ciphertext,
976
+ passwordKeyEncrypted: (await tempRootPrivilegedKeyManager.encrypt({
977
+ plaintext: passwordKey,
978
+ protocolID: [2, 'admin key wrapping'],
979
+ keyID: '1'
980
+ })).ciphertext,
981
+ recoveryKeyEncrypted: (await tempRootPrivilegedKeyManager.encrypt({
982
+ plaintext: recoveryKey,
983
+ protocolID: [2, 'admin key wrapping'],
984
+ keyID: '1'
985
+ })).ciphertext,
986
+ profilesEncrypted // Add encrypted profiles
987
+ // currentOutpoint will be set after publishing
988
+ };
989
+ // We need the wallet built for the DEFAULT profile to publish the UMP token.
990
+ // If the current active profile is not default, temporarily switch, publish, then switch back.
991
+ const currentActiveId = this.activeProfileId;
992
+ let walletToUse = this.underlying;
993
+ if (!currentActiveId.every(x => x === 0)) {
994
+ console.log('Temporarily switching to default profile to update UMP token...');
995
+ await this.switchProfile(exports.DEFAULT_PROFILE_ID); // This rebuilds this.underlying
996
+ walletToUse = this.underlying;
997
+ }
998
+ if (!walletToUse) {
999
+ throw new Error('Default profile wallet could not be activated for UMP token update.');
1000
+ }
1001
+ // Publish the new token on-chain, consuming the old one
1002
+ try {
1003
+ newTokenData.currentOutpoint = await this.UMPTokenInteractor.buildAndSend(walletToUse, this.adminOriginator, newTokenData, oldTokenToConsume // Consume the previous token
1004
+ );
1005
+ // Update the manager's state
1006
+ this.currentUMPToken = newTokenData;
1007
+ // Profiles are already updated in this.profiles if they were passed in
1008
+ }
1009
+ finally {
1010
+ // Switch back if we temporarily switched
1011
+ if (!currentActiveId.every(x => x === 0)) {
1012
+ console.log('Switching back to original profile...');
1013
+ await this.switchProfile(currentActiveId);
1014
+ }
1015
+ }
1016
+ }
1017
+ /**
1018
+ * Serializes a UMP token to binary format (Version 2 with optional profiles).
1019
+ * Layout: [1 byte version=2] + [11 * (varint len + bytes) for standard fields] + [1 byte profile_flag] + [IF flag=1 THEN varint len + profile bytes] + [varint len + outpoint bytes]
1020
+ */
1021
+ serializeUMPToken(token) {
1022
+ if (!token.currentOutpoint) {
1023
+ throw new Error('Token must have outpoint for serialization');
1024
+ }
1025
+ const writer = new sdk_1.Utils.Writer();
1026
+ writer.writeUInt8(2); // Version 2
1027
+ const writeArray = (arr) => {
1028
+ writer.writeVarIntNum(arr.length);
1029
+ writer.write(arr);
1030
+ };
1031
+ // Write standard fields in specific order
1032
+ writeArray(token.passwordSalt); // 0
1033
+ writeArray(token.passwordPresentationPrimary); // 1
1034
+ writeArray(token.passwordRecoveryPrimary); // 2
1035
+ writeArray(token.presentationRecoveryPrimary); // 3
1036
+ writeArray(token.passwordPrimaryPrivileged); // 4
1037
+ writeArray(token.presentationRecoveryPrivileged); // 5
1038
+ writeArray(token.presentationHash); // 6
1039
+ writeArray(token.recoveryHash); // 7
1040
+ writeArray(token.presentationKeyEncrypted); // 8
1041
+ writeArray(token.passwordKeyEncrypted); // 9 - Swapped order vs original doc comment
1042
+ writeArray(token.recoveryKeyEncrypted); // 10
1043
+ // Write optional profiles field
1044
+ if (token.profilesEncrypted && token.profilesEncrypted.length > 0) {
1045
+ writer.writeUInt8(1); // Flag indicating profiles present
1046
+ writeArray(token.profilesEncrypted);
1047
+ }
1048
+ else {
1049
+ writer.writeUInt8(0); // Flag indicating no profiles
1050
+ }
1051
+ // Write outpoint string
1052
+ const outpointBytes = sdk_1.Utils.toArray(token.currentOutpoint, 'utf8');
1053
+ writer.writeVarIntNum(outpointBytes.length);
1054
+ writer.write(outpointBytes);
1055
+ return writer.toArray();
1056
+ }
1057
+ /**
1058
+ * Deserializes a UMP token from binary format (Handles Version 1 and 2).
1059
+ */
1060
+ deserializeUMPToken(bin) {
1061
+ const reader = new sdk_1.Utils.Reader(bin);
1062
+ const version = reader.readUInt8();
1063
+ if (version !== 1 && version !== 2) {
1064
+ throw new Error(`Unsupported UMP token serialization version: ${version}`);
1065
+ }
1066
+ const readArray = () => {
1067
+ const length = reader.readVarIntNum();
1068
+ return reader.read(length);
1069
+ };
1070
+ // Read standard fields (order matches serialization V2)
1071
+ const passwordSalt = readArray(); // 0
1072
+ const passwordPresentationPrimary = readArray(); // 1
1073
+ const passwordRecoveryPrimary = readArray(); // 2
1074
+ const presentationRecoveryPrimary = readArray(); // 3
1075
+ const passwordPrimaryPrivileged = readArray(); // 4
1076
+ const presentationRecoveryPrivileged = readArray(); // 5
1077
+ const presentationHash = readArray(); // 6
1078
+ const recoveryHash = readArray(); // 7
1079
+ const presentationKeyEncrypted = readArray(); // 8
1080
+ const passwordKeyEncrypted = readArray(); // 9
1081
+ const recoveryKeyEncrypted = readArray(); // 10
1082
+ // Read optional profiles (only in V2)
1083
+ let profilesEncrypted;
1084
+ if (version === 2) {
1085
+ const profilesFlag = reader.readUInt8();
1086
+ if (profilesFlag === 1) {
1087
+ profilesEncrypted = readArray();
1088
+ }
1089
+ }
1090
+ // Read outpoint string
1091
+ const outpointLen = reader.readVarIntNum();
1092
+ const outpointBytes = reader.read(outpointLen);
1093
+ const currentOutpoint = sdk_1.Utils.toUTF8(outpointBytes);
1094
+ const token = {
1095
+ passwordSalt,
1096
+ passwordPresentationPrimary,
1097
+ passwordRecoveryPrimary,
1098
+ presentationRecoveryPrimary,
1099
+ passwordPrimaryPrivileged,
1100
+ presentationRecoveryPrivileged,
1101
+ presentationHash,
1102
+ recoveryHash,
1103
+ presentationKeyEncrypted,
1104
+ passwordKeyEncrypted, // Corrected order
1105
+ recoveryKeyEncrypted,
1106
+ profilesEncrypted, // May be undefined
1107
+ currentOutpoint
1108
+ };
1109
+ return token;
1110
+ }
1111
+ /**
1112
+ * Sets up the root key infrastructure after authentication or loading from snapshot.
1113
+ * Initializes the root primary key, root privileged key manager, loads profiles,
1114
+ * and sets the authenticated flag. Does NOT switch profile initially.
1115
+ *
1116
+ * @param rootPrimaryKey The user's root primary key (32 bytes).
1117
+ * @param ephemeralRootPrivilegedKey Optional root privileged key (e.g., during recovery flows).
1118
+ */
1119
+ async setupRootInfrastructure(rootPrimaryKey, ephemeralRootPrivilegedKey) {
1120
+ if (!this.currentUMPToken) {
1121
+ throw new Error('A UMP token must exist before setting up root infrastructure!');
1122
+ }
1123
+ this.rootPrimaryKey = rootPrimaryKey;
1124
+ // Store ephemeral key if provided, for one-time use by the manager
1125
+ let oneTimePrivilegedKey = ephemeralRootPrivilegedKey
1126
+ ? new sdk_1.PrivateKey(ephemeralRootPrivilegedKey)
1127
+ : undefined;
1128
+ // Create the ROOT PrivilegedKeyManager
1129
+ this.rootPrivilegedKeyManager = new PrivilegedKeyManager_1.PrivilegedKeyManager(async (reason) => {
1130
+ // 1. Use one-time key if available (for recovery)
1131
+ if (oneTimePrivilegedKey) {
1132
+ const tempKey = oneTimePrivilegedKey;
1133
+ oneTimePrivilegedKey = undefined; // Consume it
1134
+ return tempKey;
1135
+ }
1136
+ // 2. Otherwise, derive from password
1137
+ const password = await this.passwordRetriever(reason, (passwordCandidate) => {
1138
+ try {
1139
+ const derivedPasswordKey = sdk_1.Hash.pbkdf2(sdk_1.Utils.toArray(passwordCandidate, 'utf8'), this.currentUMPToken.passwordSalt, exports.PBKDF2_NUM_ROUNDS, 32, 'sha512');
1140
+ const privilegedDecryptor = this.XOR(this.rootPrimaryKey, derivedPasswordKey);
1141
+ const decryptedPrivileged = new sdk_1.SymmetricKey(privilegedDecryptor).decrypt(this.currentUMPToken.passwordPrimaryPrivileged);
1142
+ return !!decryptedPrivileged; // Test passes if decryption works
1143
+ }
1144
+ catch (e) {
1145
+ return false;
1146
+ }
1147
+ });
1148
+ // Decrypt the root privileged key using the confirmed password
1149
+ const derivedPasswordKey = await pbkdf2NativeOrJs(sdk_1.Utils.toArray(password, 'utf8'), this.currentUMPToken.passwordSalt, exports.PBKDF2_NUM_ROUNDS, 32, 'sha512');
1150
+ const privilegedDecryptor = this.XOR(this.rootPrimaryKey, derivedPasswordKey);
1151
+ const rootPrivilegedBytes = new sdk_1.SymmetricKey(privilegedDecryptor).decrypt(this.currentUMPToken.passwordPrimaryPrivileged);
1152
+ return new sdk_1.PrivateKey(rootPrivilegedBytes); // Return the ROOT key object
1153
+ });
1154
+ // Decrypt and load profiles if present in the token
1155
+ this.profiles = []; // Clear existing profiles before loading
1156
+ if (this.currentUMPToken.profilesEncrypted && this.currentUMPToken.profilesEncrypted.length > 0) {
1157
+ try {
1158
+ const decryptedProfileBytes = new sdk_1.SymmetricKey(rootPrimaryKey).decrypt(this.currentUMPToken.profilesEncrypted);
1159
+ const profilesJson = sdk_1.Utils.toUTF8(decryptedProfileBytes);
1160
+ this.profiles = JSON.parse(profilesJson);
1161
+ }
1162
+ catch (error) {
1163
+ console.error('Failed to decrypt or parse profiles:', error);
1164
+ // Decide if this should be fatal or just log and continue without profiles
1165
+ this.profiles = []; // Ensure profiles are empty on error
1166
+ // Optionally re-throw or handle more gracefully
1167
+ throw new Error(`Failed to load profiles: ${error.message}`);
1168
+ }
1169
+ }
1170
+ this.authenticated = true;
1171
+ // Note: We don't call switchProfile here anymore.
1172
+ // It's called by the auth methods (providePassword/provideRecoveryKey) or loadSnapshot after this.
1173
+ }
1174
+ /*
1175
+ * ---------------------------------------------------------------------------------------
1176
+ * Standard WalletInterface methods proxying to the *active* underlying wallet.
1177
+ * Includes authentication checks and admin originator protection.
1178
+ * ---------------------------------------------------------------------------------------
1179
+ */
1180
+ checkAuthAndUnderlying(originator) {
1181
+ if (!this.authenticated) {
1182
+ throw new Error('User is not authenticated.');
1183
+ }
1184
+ if (!this.underlying) {
1185
+ // This might happen if authentication succeeded but profile switching failed
1186
+ throw new Error('Underlying wallet for the active profile is not initialized.');
1187
+ }
1188
+ if (originator === this.adminOriginator) {
1189
+ throw new Error('External applications are not allowed to use the admin originator.');
1190
+ }
1191
+ }
1192
+ // Example proxy method (repeat pattern for all others)
1193
+ async getPublicKey(args, originator) {
1194
+ this.checkAuthAndUnderlying(originator);
1195
+ return this.underlying.getPublicKey(args, originator);
1196
+ }
1197
+ async revealCounterpartyKeyLinkage(args, originator) {
1198
+ this.checkAuthAndUnderlying(originator);
1199
+ return this.underlying.revealCounterpartyKeyLinkage(args, originator);
1200
+ }
1201
+ async revealSpecificKeyLinkage(args, originator) {
1202
+ this.checkAuthAndUnderlying(originator);
1203
+ return this.underlying.revealSpecificKeyLinkage(args, originator);
1204
+ }
1205
+ async encrypt(args, originator) {
1206
+ this.checkAuthAndUnderlying(originator);
1207
+ return this.underlying.encrypt(args, originator);
1208
+ }
1209
+ async decrypt(args, originator) {
1210
+ this.checkAuthAndUnderlying(originator);
1211
+ return this.underlying.decrypt(args, originator);
1212
+ }
1213
+ async createHmac(args, originator) {
1214
+ this.checkAuthAndUnderlying(originator);
1215
+ return this.underlying.createHmac(args, originator);
1216
+ }
1217
+ async verifyHmac(args, originator) {
1218
+ this.checkAuthAndUnderlying(originator);
1219
+ return this.underlying.verifyHmac(args, originator);
1220
+ }
1221
+ async createSignature(args, originator) {
1222
+ this.checkAuthAndUnderlying(originator);
1223
+ return this.underlying.createSignature(args, originator);
1224
+ }
1225
+ async verifySignature(args, originator) {
1226
+ this.checkAuthAndUnderlying(originator);
1227
+ return this.underlying.verifySignature(args, originator);
1228
+ }
1229
+ async createAction(args, originator) {
1230
+ this.checkAuthAndUnderlying(originator);
1231
+ return this.underlying.createAction(args, originator);
1232
+ }
1233
+ async signAction(args, originator) {
1234
+ this.checkAuthAndUnderlying(originator);
1235
+ return this.underlying.signAction(args, originator);
1236
+ }
1237
+ async abortAction(args, originator) {
1238
+ this.checkAuthAndUnderlying(originator);
1239
+ return this.underlying.abortAction(args, originator);
1240
+ }
1241
+ async listActions(args, originator) {
1242
+ this.checkAuthAndUnderlying(originator);
1243
+ return this.underlying.listActions(args, originator);
1244
+ }
1245
+ async internalizeAction(args, originator) {
1246
+ this.checkAuthAndUnderlying(originator);
1247
+ return this.underlying.internalizeAction(args, originator);
1248
+ }
1249
+ async listOutputs(args, originator) {
1250
+ this.checkAuthAndUnderlying(originator);
1251
+ return this.underlying.listOutputs(args, originator);
1252
+ }
1253
+ async relinquishOutput(args, originator) {
1254
+ this.checkAuthAndUnderlying(originator);
1255
+ return this.underlying.relinquishOutput(args, originator);
1256
+ }
1257
+ async acquireCertificate(args, originator) {
1258
+ this.checkAuthAndUnderlying(originator);
1259
+ return this.underlying.acquireCertificate(args, originator);
1260
+ }
1261
+ async listCertificates(args, originator) {
1262
+ this.checkAuthAndUnderlying(originator);
1263
+ return this.underlying.listCertificates(args, originator);
1264
+ }
1265
+ async proveCertificate(args, originator) {
1266
+ this.checkAuthAndUnderlying(originator);
1267
+ return this.underlying.proveCertificate(args, originator);
1268
+ }
1269
+ async relinquishCertificate(args, originator) {
1270
+ this.checkAuthAndUnderlying(originator);
1271
+ return this.underlying.relinquishCertificate(args, originator);
1272
+ }
1273
+ async discoverByIdentityKey(args, originator) {
1274
+ this.checkAuthAndUnderlying(originator);
1275
+ return this.underlying.discoverByIdentityKey(args, originator);
1276
+ }
1277
+ async discoverByAttributes(args, originator) {
1278
+ this.checkAuthAndUnderlying(originator);
1279
+ return this.underlying.discoverByAttributes(args, originator);
1280
+ }
1281
+ async isAuthenticated(_, originator) {
1282
+ if (!this.authenticated) {
1283
+ throw new Error('User is not authenticated.');
1284
+ }
1285
+ if (originator === this.adminOriginator) {
1286
+ throw new Error('External applications are not allowed to use the admin originator.');
1287
+ }
1288
+ return { authenticated: true };
1289
+ }
1290
+ async waitForAuthentication(_, originator) {
1291
+ if (originator === this.adminOriginator) {
1292
+ throw new Error('External applications are not allowed to use the admin originator.');
1293
+ }
1294
+ while (!this.authenticated || !this.underlying) {
1295
+ await new Promise(resolve => setTimeout(resolve, 100));
1296
+ }
1297
+ return await this.underlying.waitForAuthentication({}, originator);
1298
+ }
1299
+ async getHeight(_, originator) {
1300
+ this.checkAuthAndUnderlying(originator);
1301
+ return this.underlying.getHeight({}, originator);
1302
+ }
1303
+ async getHeaderForHeight(args, originator) {
1304
+ this.checkAuthAndUnderlying(originator);
1305
+ return this.underlying.getHeaderForHeight(args, originator);
1306
+ }
1307
+ async getNetwork(_, originator) {
1308
+ this.checkAuthAndUnderlying(originator);
1309
+ return this.underlying.getNetwork({}, originator);
1310
+ }
1311
+ async getVersion(_, originator) {
1312
+ this.checkAuthAndUnderlying(originator);
1313
+ return this.underlying.getVersion({}, originator);
1314
+ }
1315
+ }
1316
+ exports.CWIStyleWalletManager = CWIStyleWalletManager;
1317
+ //# sourceMappingURL=CWIStyleWalletManager.js.map