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