@bopen-io/wallet-toolbox 1.7.18
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/.claude/settings.local.json +10 -0
- package/.env.template +22 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +40 -0
- package/.github/ISSUE_TEMPLATE/discussion.md +24 -0
- package/.github/pull_request_template.md +22 -0
- package/.github/workflows/push.yaml +145 -0
- package/.prettierrc +10 -0
- package/CHANGELOG.md +280 -0
- package/CONTRIBUTING.md +89 -0
- package/README.md +43 -0
- package/docs/README.md +85 -0
- package/docs/client.md +19627 -0
- package/docs/monitor.md +953 -0
- package/docs/open-rpc/index.html +46 -0
- package/docs/services.md +6377 -0
- package/docs/setup.md +1268 -0
- package/docs/storage.md +5367 -0
- package/docs/wallet.md +19626 -0
- package/jest.config.ts +25 -0
- package/license.md +28 -0
- package/out/tsconfig.all.tsbuildinfo +1 -0
- package/package.json +63 -0
- package/src/CWIStyleWalletManager.ts +1999 -0
- package/src/Setup.ts +579 -0
- package/src/SetupClient.ts +322 -0
- package/src/SetupWallet.ts +108 -0
- package/src/SimpleWalletManager.ts +526 -0
- package/src/Wallet.ts +1169 -0
- package/src/WalletAuthenticationManager.ts +153 -0
- package/src/WalletLogger.ts +213 -0
- package/src/WalletPermissionsManager.ts +3660 -0
- package/src/WalletSettingsManager.ts +114 -0
- package/src/__tests/CWIStyleWalletManager.test.d.ts.map +1 -0
- package/src/__tests/CWIStyleWalletManager.test.js.map +1 -0
- package/src/__tests/CWIStyleWalletManager.test.ts +675 -0
- package/src/__tests/WalletPermissionsManager.callbacks.test.ts +323 -0
- package/src/__tests/WalletPermissionsManager.checks.test.ts +844 -0
- package/src/__tests/WalletPermissionsManager.encryption.test.ts +412 -0
- package/src/__tests/WalletPermissionsManager.fixtures.ts +307 -0
- package/src/__tests/WalletPermissionsManager.flows.test.ts +462 -0
- package/src/__tests/WalletPermissionsManager.initialization.test.ts +300 -0
- package/src/__tests/WalletPermissionsManager.pmodules.test.ts +798 -0
- package/src/__tests/WalletPermissionsManager.proxying.test.ts +724 -0
- package/src/__tests/WalletPermissionsManager.tokens.test.ts +503 -0
- package/src/index.all.ts +27 -0
- package/src/index.client.ts +25 -0
- package/src/index.mobile.ts +21 -0
- package/src/index.ts +1 -0
- package/src/monitor/Monitor.ts +412 -0
- package/src/monitor/MonitorDaemon.ts +188 -0
- package/src/monitor/README.md +3 -0
- package/src/monitor/__test/MonitorDaemon.man.test.ts +45 -0
- package/src/monitor/tasks/TaskCheckForProofs.ts +243 -0
- package/src/monitor/tasks/TaskCheckNoSends.ts +73 -0
- package/src/monitor/tasks/TaskClock.ts +33 -0
- package/src/monitor/tasks/TaskFailAbandoned.ts +54 -0
- package/src/monitor/tasks/TaskMonitorCallHistory.ts +26 -0
- package/src/monitor/tasks/TaskNewHeader.ts +93 -0
- package/src/monitor/tasks/TaskPurge.ts +68 -0
- package/src/monitor/tasks/TaskReorg.ts +89 -0
- package/src/monitor/tasks/TaskReviewStatus.ts +48 -0
- package/src/monitor/tasks/TaskSendWaiting.ts +122 -0
- package/src/monitor/tasks/TaskSyncWhenIdle.ts +26 -0
- package/src/monitor/tasks/TaskUnFail.ts +151 -0
- package/src/monitor/tasks/WalletMonitorTask.ts +47 -0
- package/src/sdk/CertOpsWallet.ts +18 -0
- package/src/sdk/PrivilegedKeyManager.ts +372 -0
- package/src/sdk/README.md +13 -0
- package/src/sdk/WERR_errors.ts +234 -0
- package/src/sdk/WalletError.ts +170 -0
- package/src/sdk/WalletErrorFromJson.ts +80 -0
- package/src/sdk/WalletServices.interfaces.ts +700 -0
- package/src/sdk/WalletSigner.interfaces.ts +11 -0
- package/src/sdk/WalletStorage.interfaces.ts +606 -0
- package/src/sdk/__test/CertificateLifeCycle.test.ts +131 -0
- package/src/sdk/__test/PrivilegedKeyManager.test.ts +738 -0
- package/src/sdk/__test/WalletError.test.ts +318 -0
- package/src/sdk/__test/validationHelpers.test.ts +21 -0
- package/src/sdk/index.ts +10 -0
- package/src/sdk/types.ts +226 -0
- package/src/services/README.md +11 -0
- package/src/services/ServiceCollection.ts +248 -0
- package/src/services/Services.ts +603 -0
- package/src/services/__tests/ARC.man.test.ts +123 -0
- package/src/services/__tests/ARC.timeout.man.test.ts +79 -0
- package/src/services/__tests/ArcGorillaPool.man.test.ts +108 -0
- package/src/services/__tests/arcServices.test.ts +8 -0
- package/src/services/__tests/bitrails.test.ts +56 -0
- package/src/services/__tests/getMerklePath.test.ts +15 -0
- package/src/services/__tests/getRawTx.test.ts +13 -0
- package/src/services/__tests/postBeef.test.ts +104 -0
- package/src/services/__tests/verifyBeef.test.ts +50 -0
- package/src/services/chaintracker/BHServiceClient.ts +212 -0
- package/src/services/chaintracker/ChaintracksChainTracker.ts +71 -0
- package/src/services/chaintracker/__tests/ChaintracksChainTracker.test.ts +33 -0
- package/src/services/chaintracker/__tests/ChaintracksServiceClient.test.ts +29 -0
- package/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.ts +72 -0
- package/src/services/chaintracker/chaintracks/Api/BulkIngestorApi.ts +83 -0
- package/src/services/chaintracker/chaintracks/Api/BulkStorageApi.ts +92 -0
- package/src/services/chaintracker/chaintracks/Api/ChaintracksApi.ts +64 -0
- package/src/services/chaintracker/chaintracks/Api/ChaintracksClientApi.ts +189 -0
- package/src/services/chaintracker/chaintracks/Api/ChaintracksFetchApi.ts +18 -0
- package/src/services/chaintracker/chaintracks/Api/ChaintracksFsApi.ts +58 -0
- package/src/services/chaintracker/chaintracks/Api/ChaintracksStorageApi.ts +386 -0
- package/src/services/chaintracker/chaintracks/Api/LiveIngestorApi.ts +25 -0
- package/src/services/chaintracker/chaintracks/Chaintracks.ts +609 -0
- package/src/services/chaintracker/chaintracks/ChaintracksService.ts +199 -0
- package/src/services/chaintracker/chaintracks/ChaintracksServiceClient.ts +154 -0
- package/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.ts +176 -0
- package/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.ts +174 -0
- package/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.ts +18 -0
- package/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.ts +113 -0
- package/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainWs.ts +81 -0
- package/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.ts +86 -0
- package/src/services/chaintracker/chaintracks/Ingest/LiveIngestorTeranodeP2P.ts +59 -0
- package/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.ts +104 -0
- package/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainWs.ts +66 -0
- package/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.ts +566 -0
- package/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.ts +219 -0
- package/src/services/chaintracker/chaintracks/Ingest/__tests/BulkIngestorCDNBabbage.test.ts +54 -0
- package/src/services/chaintracker/chaintracks/Ingest/__tests/LiveIngestorWhatsOnChainPoll.test.ts +33 -0
- package/src/services/chaintracker/chaintracks/Ingest/__tests/WhatsOnChainServices.test.ts +124 -0
- package/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.ts +92 -0
- package/src/services/chaintracker/chaintracks/Storage/ChaintracksKnexMigrations.ts +104 -0
- package/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.ts +382 -0
- package/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.ts +574 -0
- package/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageKnex.ts +438 -0
- package/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageMemory.ts +29 -0
- package/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.ts +304 -0
- package/src/services/chaintracker/chaintracks/Storage/__tests/ChaintracksStorageIdb.test.ts +102 -0
- package/src/services/chaintracker/chaintracks/Storage/__tests/ChaintracksStorageKnex.test.ts +45 -0
- package/src/services/chaintracker/chaintracks/__tests/Chaintracks.test.ts +77 -0
- package/src/services/chaintracker/chaintracks/__tests/ChaintracksClientApi.test.ts +192 -0
- package/src/services/chaintracker/chaintracks/__tests/LocalCdnServer.ts +75 -0
- package/src/services/chaintracker/chaintracks/__tests/createIdbChaintracks.test.ts +62 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest349/mainNetBlockHeaders.json +1 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest349/mainNet_0.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest349/mainNet_1.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest349/mainNet_2.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest349/mainNet_3.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest379/mainNetBlockHeaders.json +1 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest379/mainNet_0.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest379/mainNet_1.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest379/mainNet_2.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest379/mainNet_3.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest399/mainNetBlockHeaders.json +1 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest399/mainNet_0.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest399/mainNet_1.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest399/mainNet_2.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest399/mainNet_3.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest402/mainNetBlockHeaders.json +1 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest402/mainNet_0.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest402/mainNet_1.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest402/mainNet_2.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest402/mainNet_3.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest402/mainNet_4.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest499/mainNetBlockHeaders.json +1 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest499/mainNet_0.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest499/mainNet_1.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest499/mainNet_2.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest499/mainNet_3.headers +0 -0
- package/src/services/chaintracker/chaintracks/__tests/data/cdnTest499/mainNet_4.headers +0 -0
- package/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.ts +92 -0
- package/src/services/chaintracker/chaintracks/createDefaultKnexChaintracksOptions.ts +111 -0
- package/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.ts +91 -0
- package/src/services/chaintracker/chaintracks/createIdbChaintracks.ts +60 -0
- package/src/services/chaintracker/chaintracks/createKnexChaintracks.ts +65 -0
- package/src/services/chaintracker/chaintracks/createNoDbChaintracks.ts +60 -0
- package/src/services/chaintracker/chaintracks/index.all.ts +12 -0
- package/src/services/chaintracker/chaintracks/index.client.ts +4 -0
- package/src/services/chaintracker/chaintracks/index.mobile.ts +37 -0
- package/src/services/chaintracker/chaintracks/util/BulkFileDataManager.ts +975 -0
- package/src/services/chaintracker/chaintracks/util/BulkFileDataReader.ts +60 -0
- package/src/services/chaintracker/chaintracks/util/BulkFilesReader.ts +336 -0
- package/src/services/chaintracker/chaintracks/util/BulkHeaderFile.ts +247 -0
- package/src/services/chaintracker/chaintracks/util/ChaintracksFetch.ts +69 -0
- package/src/services/chaintracker/chaintracks/util/ChaintracksFs.ts +141 -0
- package/src/services/chaintracker/chaintracks/util/HeightRange.ts +153 -0
- package/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.ts +76 -0
- package/src/services/chaintracker/chaintracks/util/__tests/BulkFileDataManager.test.ts +304 -0
- package/src/services/chaintracker/chaintracks/util/__tests/ChaintracksFetch.test.ts +60 -0
- package/src/services/chaintracker/chaintracks/util/__tests/HeightRange.test.ts +67 -0
- package/src/services/chaintracker/chaintracks/util/__tests/SingleWriterMultiReaderLock.test.ts +49 -0
- package/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.ts +573 -0
- package/src/services/chaintracker/chaintracks/util/dirtyHashes.ts +29 -0
- package/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.ts +432 -0
- package/src/services/chaintracker/index.all.ts +4 -0
- package/src/services/chaintracker/index.client.ts +4 -0
- package/src/services/chaintracker/index.mobile.ts +4 -0
- package/src/services/createDefaultWalletServicesOptions.ts +77 -0
- package/src/services/index.ts +1 -0
- package/src/services/processingErrors/arcSuccessError.json +76 -0
- package/src/services/providers/ARC.ts +350 -0
- package/src/services/providers/Bitails.ts +256 -0
- package/src/services/providers/SdkWhatsOnChain.ts +83 -0
- package/src/services/providers/WhatsOnChain.ts +883 -0
- package/src/services/providers/__tests/WhatsOnChain.test.ts +242 -0
- package/src/services/providers/__tests/exchangeRates.test.ts +18 -0
- package/src/services/providers/exchangeRates.ts +265 -0
- package/src/services/providers/getBeefForTxid.ts +369 -0
- package/src/signer/README.md +5 -0
- package/src/signer/WalletSigner.ts +17 -0
- package/src/signer/methods/acquireDirectCertificate.ts +52 -0
- package/src/signer/methods/buildSignableTransaction.ts +183 -0
- package/src/signer/methods/completeSignedTransaction.ts +117 -0
- package/src/signer/methods/createAction.ts +172 -0
- package/src/signer/methods/internalizeAction.ts +106 -0
- package/src/signer/methods/proveCertificate.ts +43 -0
- package/src/signer/methods/signAction.ts +54 -0
- package/src/storage/README.md +14 -0
- package/src/storage/StorageIdb.ts +2304 -0
- package/src/storage/StorageKnex.ts +1425 -0
- package/src/storage/StorageProvider.ts +810 -0
- package/src/storage/StorageReader.ts +194 -0
- package/src/storage/StorageReaderWriter.ts +432 -0
- package/src/storage/StorageSyncReader.ts +34 -0
- package/src/storage/WalletStorageManager.ts +943 -0
- package/src/storage/__test/StorageIdb.test.ts +43 -0
- package/src/storage/__test/WalletStorageManager.test.ts +275 -0
- package/src/storage/__test/adminStats.man.test.ts +89 -0
- package/src/storage/__test/getBeefForTransaction.test.ts +385 -0
- package/src/storage/index.all.ts +11 -0
- package/src/storage/index.client.ts +7 -0
- package/src/storage/index.mobile.ts +6 -0
- package/src/storage/methods/ListActionsSpecOp.ts +70 -0
- package/src/storage/methods/ListOutputsSpecOp.ts +129 -0
- package/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.ts +1057 -0
- package/src/storage/methods/__test/GenerateChange/randomValsUsed1.ts +20 -0
- package/src/storage/methods/__test/offsetKey.test.ts +274 -0
- package/src/storage/methods/attemptToPostReqsToNetwork.ts +389 -0
- package/src/storage/methods/createAction.ts +947 -0
- package/src/storage/methods/generateChange.ts +556 -0
- package/src/storage/methods/getBeefForTransaction.ts +139 -0
- package/src/storage/methods/getSyncChunk.ts +293 -0
- package/src/storage/methods/internalizeAction.ts +562 -0
- package/src/storage/methods/listActionsIdb.ts +183 -0
- package/src/storage/methods/listActionsKnex.ts +226 -0
- package/src/storage/methods/listCertificates.ts +73 -0
- package/src/storage/methods/listOutputsIdb.ts +203 -0
- package/src/storage/methods/listOutputsKnex.ts +263 -0
- package/src/storage/methods/offsetKey.ts +89 -0
- package/src/storage/methods/processAction.ts +420 -0
- package/src/storage/methods/purgeData.ts +251 -0
- package/src/storage/methods/purgeDataIdb.ts +10 -0
- package/src/storage/methods/reviewStatus.ts +101 -0
- package/src/storage/methods/reviewStatusIdb.ts +43 -0
- package/src/storage/methods/utils.Buffer.ts +33 -0
- package/src/storage/methods/utils.ts +56 -0
- package/src/storage/remoting/StorageClient.ts +567 -0
- package/src/storage/remoting/StorageMobile.ts +544 -0
- package/src/storage/remoting/StorageServer.ts +291 -0
- package/src/storage/remoting/__test/StorageClient.test.ts +113 -0
- package/src/storage/schema/KnexMigrations.ts +489 -0
- package/src/storage/schema/StorageIdbSchema.ts +150 -0
- package/src/storage/schema/entities/EntityBase.ts +210 -0
- package/src/storage/schema/entities/EntityCertificate.ts +188 -0
- package/src/storage/schema/entities/EntityCertificateField.ts +136 -0
- package/src/storage/schema/entities/EntityCommission.ts +148 -0
- package/src/storage/schema/entities/EntityOutput.ts +290 -0
- package/src/storage/schema/entities/EntityOutputBasket.ts +153 -0
- package/src/storage/schema/entities/EntityOutputTag.ts +121 -0
- package/src/storage/schema/entities/EntityOutputTagMap.ts +123 -0
- package/src/storage/schema/entities/EntityProvenTx.ts +319 -0
- package/src/storage/schema/entities/EntityProvenTxReq.ts +580 -0
- package/src/storage/schema/entities/EntitySyncState.ts +389 -0
- package/src/storage/schema/entities/EntityTransaction.ts +306 -0
- package/src/storage/schema/entities/EntityTxLabel.ts +121 -0
- package/src/storage/schema/entities/EntityTxLabelMap.ts +123 -0
- package/src/storage/schema/entities/EntityUser.ts +112 -0
- package/src/storage/schema/entities/MergeEntity.ts +73 -0
- package/src/storage/schema/entities/__tests/CertificateFieldTests.test.ts +353 -0
- package/src/storage/schema/entities/__tests/CertificateTests.test.ts +354 -0
- package/src/storage/schema/entities/__tests/CommissionTests.test.ts +371 -0
- package/src/storage/schema/entities/__tests/OutputBasketTests.test.ts +278 -0
- package/src/storage/schema/entities/__tests/OutputTagMapTests.test.ts +242 -0
- package/src/storage/schema/entities/__tests/OutputTagTests.test.ts +288 -0
- package/src/storage/schema/entities/__tests/OutputTests.test.ts +464 -0
- package/src/storage/schema/entities/__tests/ProvenTxReqTests.test.ts +340 -0
- package/src/storage/schema/entities/__tests/ProvenTxTests.test.ts +504 -0
- package/src/storage/schema/entities/__tests/SyncStateTests.test.ts +288 -0
- package/src/storage/schema/entities/__tests/TransactionTests.test.ts +604 -0
- package/src/storage/schema/entities/__tests/TxLabelMapTests.test.ts +361 -0
- package/src/storage/schema/entities/__tests/TxLabelTests.test.ts +198 -0
- package/src/storage/schema/entities/__tests/stampLogTests.test.ts +90 -0
- package/src/storage/schema/entities/__tests/usersTests.test.ts +340 -0
- package/src/storage/schema/entities/index.ts +16 -0
- package/src/storage/schema/tables/TableCertificate.ts +21 -0
- package/src/storage/schema/tables/TableCertificateField.ts +12 -0
- package/src/storage/schema/tables/TableCommission.ts +13 -0
- package/src/storage/schema/tables/TableMonitorEvent.ts +9 -0
- package/src/storage/schema/tables/TableOutput.ts +64 -0
- package/src/storage/schema/tables/TableOutputBasket.ts +12 -0
- package/src/storage/schema/tables/TableOutputTag.ts +10 -0
- package/src/storage/schema/tables/TableOutputTagMap.ts +9 -0
- package/src/storage/schema/tables/TableProvenTx.ts +14 -0
- package/src/storage/schema/tables/TableProvenTxReq.ts +65 -0
- package/src/storage/schema/tables/TableSettings.ts +17 -0
- package/src/storage/schema/tables/TableSyncState.ts +18 -0
- package/src/storage/schema/tables/TableTransaction.ts +54 -0
- package/src/storage/schema/tables/TableTxLabel.ts +10 -0
- package/src/storage/schema/tables/TableTxLabelMap.ts +9 -0
- package/src/storage/schema/tables/TableUser.ts +16 -0
- package/src/storage/schema/tables/index.ts +16 -0
- package/src/storage/sync/StorageMySQLDojoReader.ts +696 -0
- package/src/storage/sync/index.ts +1 -0
- package/src/utility/Format.ts +133 -0
- package/src/utility/README.md +3 -0
- package/src/utility/ReaderUint8Array.ts +187 -0
- package/src/utility/ScriptTemplateBRC29.ts +73 -0
- package/src/utility/__tests/utilityHelpers.noBuffer.test.ts +109 -0
- package/src/utility/aggregateResults.ts +68 -0
- package/src/utility/identityUtils.ts +159 -0
- package/src/utility/index.all.ts +7 -0
- package/src/utility/index.client.ts +7 -0
- package/src/utility/parseTxScriptOffsets.ts +29 -0
- package/src/utility/stampLog.ts +69 -0
- package/src/utility/tscProofToMerklePath.ts +48 -0
- package/src/utility/utilityHelpers.buffer.ts +34 -0
- package/src/utility/utilityHelpers.noBuffer.ts +60 -0
- package/src/utility/utilityHelpers.ts +275 -0
- package/src/wab-client/WABClient.ts +94 -0
- package/src/wab-client/__tests/WABClient.man.test.ts +59 -0
- package/src/wab-client/auth-method-interactors/AuthMethodInteractor.ts +47 -0
- package/src/wab-client/auth-method-interactors/DevConsoleInteractor.ts +73 -0
- package/src/wab-client/auth-method-interactors/PersonaIDInteractor.ts +35 -0
- package/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.ts +72 -0
- package/syncVersions.js +71 -0
- package/test/Wallet/StorageClient/storageClient.man.test.ts +75 -0
- package/test/Wallet/action/abortAction.test.ts +47 -0
- package/test/Wallet/action/createAction.test.ts +299 -0
- package/test/Wallet/action/createAction2.test.ts +1273 -0
- package/test/Wallet/action/createActionToGenerateBeefs.man.test.ts +293 -0
- package/test/Wallet/action/internalizeAction.a.test.ts +286 -0
- package/test/Wallet/action/internalizeAction.test.ts +682 -0
- package/test/Wallet/action/relinquishOutput.test.ts +37 -0
- package/test/Wallet/certificate/acquireCertificate.test.ts +298 -0
- package/test/Wallet/certificate/listCertificates.test.ts +346 -0
- package/test/Wallet/construct/Wallet.constructor.test.ts +57 -0
- package/test/Wallet/get/getHeaderForHeight.test.ts +82 -0
- package/test/Wallet/get/getHeight.test.ts +52 -0
- package/test/Wallet/get/getKnownTxids.test.ts +86 -0
- package/test/Wallet/get/getNetwork.test.ts +27 -0
- package/test/Wallet/get/getVersion.test.ts +27 -0
- package/test/Wallet/list/listActions.test.ts +279 -0
- package/test/Wallet/list/listActions2.test.ts +1381 -0
- package/test/Wallet/list/listCertificates.test.ts +118 -0
- package/test/Wallet/list/listOutputs.test.ts +447 -0
- package/test/Wallet/live/walletLive.man.test.ts +521 -0
- package/test/Wallet/local/localWallet.man.test.ts +93 -0
- package/test/Wallet/local/localWallet2.man.test.ts +277 -0
- package/test/Wallet/signAction/mountaintop.man.test.ts +130 -0
- package/test/Wallet/specOps/specOps.man.test.ts +220 -0
- package/test/Wallet/support/janitor.man.test.ts +40 -0
- package/test/Wallet/support/operations.man.test.ts +407 -0
- package/test/Wallet/support/reqErrorReview.2025.05.06.man.test.ts +347 -0
- package/test/Wallet/sync/Wallet.sync.test.ts +215 -0
- package/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.ts +203 -0
- package/test/Wallet/sync/setActive.test.ts +170 -0
- package/test/WalletClient/LocalKVStore.man.test.ts +114 -0
- package/test/WalletClient/WERR.man.test.ts +35 -0
- package/test/bsv-ts-sdk/LocalKVStore.test.ts +102 -0
- package/test/checkDB.ts +57 -0
- package/test/checkdb +0 -0
- package/test/examples/backup.man.test.ts +59 -0
- package/test/examples/pushdrop.test.ts +282 -0
- package/test/monitor/Monitor.test.ts +620 -0
- package/test/services/Services.test.ts +263 -0
- package/test/storage/KnexMigrations.test.ts +86 -0
- package/test/storage/StorageMySQLDojoReader.man.test.ts +60 -0
- package/test/storage/count.test.ts +177 -0
- package/test/storage/find.test.ts +195 -0
- package/test/storage/findLegacy.test.ts +67 -0
- package/test/storage/idb/allocateChange.test.ts +251 -0
- package/test/storage/idb/count.test.ts +158 -0
- package/test/storage/idb/find.test.ts +177 -0
- package/test/storage/idb/idbSpeed.test.ts +36 -0
- package/test/storage/idb/insert.test.ts +268 -0
- package/test/storage/idb/transactionAbort.test.ts +108 -0
- package/test/storage/idb/update.test.ts +999 -0
- package/test/storage/insert.test.ts +278 -0
- package/test/storage/update.test.ts +1021 -0
- package/test/storage/update2.test.ts +897 -0
- package/test/utils/TestUtilsWalletStorage.ts +2526 -0
- package/test/utils/localWalletMethods.ts +363 -0
- package/test/utils/removeFailedFromDatabase.sql +17 -0
- package/ts2md.json +44 -0
- package/tsconfig.all.json +31 -0
- package/tsconfig.client.json +29 -0
- package/tsconfig.json +17 -0
- package/tsconfig.mobile.json +28 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WABClient
|
|
3
|
+
*
|
|
4
|
+
* Provides high-level methods to:
|
|
5
|
+
* - Retrieve server info (supported auth methods, faucet info)
|
|
6
|
+
* - Generate a random presentation key
|
|
7
|
+
* - Start/Complete authentication with a chosen AuthMethodInteractor
|
|
8
|
+
* - Link/unlink methods
|
|
9
|
+
* - Request faucet
|
|
10
|
+
* - Delete user
|
|
11
|
+
*/
|
|
12
|
+
import { AuthMethodInteractor } from './auth-method-interactors/AuthMethodInteractor'
|
|
13
|
+
import { PrivateKey } from '@bsv/sdk'
|
|
14
|
+
|
|
15
|
+
export class WABClient {
|
|
16
|
+
constructor(private serverUrl: string) {}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Return the WAB server info
|
|
20
|
+
*/
|
|
21
|
+
public async getInfo() {
|
|
22
|
+
const res = await fetch(`${this.serverUrl}/info`)
|
|
23
|
+
return res.json()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Generate a random 256-bit presentation key as a hex string (client side).
|
|
28
|
+
*/
|
|
29
|
+
public generateRandomPresentationKey(): string {
|
|
30
|
+
return PrivateKey.fromRandom().toHex()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Start an Auth Method flow
|
|
35
|
+
*/
|
|
36
|
+
public async startAuthMethod(authMethod: AuthMethodInteractor, presentationKey: string, payload: any) {
|
|
37
|
+
return authMethod.startAuth(this.serverUrl, presentationKey, payload)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Complete an Auth Method flow
|
|
42
|
+
*/
|
|
43
|
+
public async completeAuthMethod(authMethod: AuthMethodInteractor, presentationKey: string, payload: any) {
|
|
44
|
+
return authMethod.completeAuth(this.serverUrl, presentationKey, payload)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* List user-linked methods
|
|
49
|
+
*/
|
|
50
|
+
public async listLinkedMethods(presentationKey: string) {
|
|
51
|
+
const res = await fetch(`${this.serverUrl}/user/linkedMethods`, {
|
|
52
|
+
method: 'POST',
|
|
53
|
+
headers: { 'Content-Type': 'application/json' },
|
|
54
|
+
body: JSON.stringify({ presentationKey })
|
|
55
|
+
})
|
|
56
|
+
return res.json()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Unlink a given Auth Method by ID
|
|
61
|
+
*/
|
|
62
|
+
public async unlinkMethod(presentationKey: string, authMethodId: number) {
|
|
63
|
+
const res = await fetch(`${this.serverUrl}/user/unlinkMethod`, {
|
|
64
|
+
method: 'POST',
|
|
65
|
+
headers: { 'Content-Type': 'application/json' },
|
|
66
|
+
body: JSON.stringify({ presentationKey, authMethodId })
|
|
67
|
+
})
|
|
68
|
+
return res.json()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Request faucet
|
|
73
|
+
*/
|
|
74
|
+
public async requestFaucet(presentationKey: string) {
|
|
75
|
+
const res = await fetch(`${this.serverUrl}/faucet/request`, {
|
|
76
|
+
method: 'POST',
|
|
77
|
+
headers: { 'Content-Type': 'application/json' },
|
|
78
|
+
body: JSON.stringify({ presentationKey })
|
|
79
|
+
})
|
|
80
|
+
return res.json()
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Delete user
|
|
85
|
+
*/
|
|
86
|
+
public async deleteUser(presentationKey: string) {
|
|
87
|
+
const res = await fetch(`${this.serverUrl}/user/delete`, {
|
|
88
|
+
method: 'POST',
|
|
89
|
+
headers: { 'Content-Type': 'application/json' },
|
|
90
|
+
body: JSON.stringify({ presentationKey })
|
|
91
|
+
})
|
|
92
|
+
return res.json()
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { _tu } from '../../../test/utils/TestUtilsWalletStorage'
|
|
2
|
+
import { WABClient } from '../WABClient'
|
|
3
|
+
import { TwilioPhoneInteractor } from '../auth-method-interactors/TwilioPhoneInteractor'
|
|
4
|
+
|
|
5
|
+
// This test suite requires the WAB server to be running on localhost:3000 or you can
|
|
6
|
+
// spin up a test environment or mock server. For demonstration, we'll keep it simple.
|
|
7
|
+
|
|
8
|
+
describe('WABClient', () => {
|
|
9
|
+
let client: WABClient
|
|
10
|
+
const serverUrl = 'http://localhost:3000' // Adjust if your server is different
|
|
11
|
+
const testPresentationKey = 'clientTestKey' + Date.now()
|
|
12
|
+
|
|
13
|
+
beforeAll(() => {
|
|
14
|
+
client = new WABClient(serverUrl)
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('00', () => {})
|
|
18
|
+
// Don't run any of these tests whe
|
|
19
|
+
if (_tu.noEnv('main')) return
|
|
20
|
+
|
|
21
|
+
it('should get server info', async () => {
|
|
22
|
+
const info = await client.getInfo()
|
|
23
|
+
expect(info.supportedAuthMethods).toContain('TwilioPhone')
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('should do Twilio phone flow', async () => {
|
|
27
|
+
const twilio = new TwilioPhoneInteractor()
|
|
28
|
+
|
|
29
|
+
const startRes = await client.startAuthMethod(twilio, testPresentationKey, {
|
|
30
|
+
phoneNumber: '+12223334444'
|
|
31
|
+
})
|
|
32
|
+
expect(startRes.success).toBe(true)
|
|
33
|
+
|
|
34
|
+
const completeRes = await client.completeAuthMethod(twilio, testPresentationKey, {
|
|
35
|
+
otp: '123456',
|
|
36
|
+
phoneNumber: '+12223334444'
|
|
37
|
+
})
|
|
38
|
+
expect(completeRes.success).toBe(true)
|
|
39
|
+
expect(completeRes.presentationKey).toBe(testPresentationKey)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('should request faucet', async () => {
|
|
43
|
+
const faucetRes = await client.requestFaucet(testPresentationKey)
|
|
44
|
+
expect(faucetRes.success).toBe(true)
|
|
45
|
+
expect(faucetRes.paymentData).toBeDefined()
|
|
46
|
+
expect(faucetRes.paymentData.amount).toBe(1000)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('should list linked methods', async () => {
|
|
50
|
+
const linked = await client.listLinkedMethods(testPresentationKey)
|
|
51
|
+
expect(linked.authMethods).toHaveLength(1)
|
|
52
|
+
expect(linked.authMethods[0].methodType).toBe('TwilioPhone')
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('can delete user', async () => {
|
|
56
|
+
const del = await client.deleteUser(testPresentationKey)
|
|
57
|
+
expect(del.success).toBe(true)
|
|
58
|
+
})
|
|
59
|
+
})
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AuthMethodInteractor
|
|
3
|
+
*
|
|
4
|
+
* A base interface/class for client-side logic to interact with a server
|
|
5
|
+
* for a specific Auth Method's flow (start, complete).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface AuthPayload {
|
|
9
|
+
[key: string]: any
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface StartAuthResponse {
|
|
13
|
+
success: boolean
|
|
14
|
+
message?: string
|
|
15
|
+
data?: any
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface CompleteAuthResponse {
|
|
19
|
+
success: boolean
|
|
20
|
+
message?: string
|
|
21
|
+
presentationKey?: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Abstract client-side interactor for an Auth Method
|
|
26
|
+
*/
|
|
27
|
+
export abstract class AuthMethodInteractor {
|
|
28
|
+
public abstract methodType: string
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Start the flow (e.g. request an OTP or create a session).
|
|
32
|
+
*/
|
|
33
|
+
public abstract startAuth(
|
|
34
|
+
serverUrl: string,
|
|
35
|
+
presentationKey: string,
|
|
36
|
+
payload: AuthPayload
|
|
37
|
+
): Promise<StartAuthResponse>
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Complete the flow (e.g. confirm OTP).
|
|
41
|
+
*/
|
|
42
|
+
public abstract completeAuth(
|
|
43
|
+
serverUrl: string,
|
|
44
|
+
presentationKey: string,
|
|
45
|
+
payload: AuthPayload
|
|
46
|
+
): Promise<CompleteAuthResponse>
|
|
47
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { AuthMethodInteractor, AuthPayload, StartAuthResponse, CompleteAuthResponse } from './AuthMethodInteractor'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* DevConsoleInteractor
|
|
5
|
+
*
|
|
6
|
+
* A client-side class that knows how to call the WAB server for DevConsole-based authentication.
|
|
7
|
+
* This is a development-only auth method that generates OTP codes and logs them to the console.
|
|
8
|
+
*/
|
|
9
|
+
export class DevConsoleInteractor extends AuthMethodInteractor {
|
|
10
|
+
public methodType = 'DevConsole'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Start the DevConsole authentication on the server.
|
|
14
|
+
* - The server will generate an OTP code and log it to the console for development use.
|
|
15
|
+
* @param serverUrl - The base URL of the WAB server (e.g. http://localhost:3000)
|
|
16
|
+
* @param presentationKey - The 256-bit key the client is attempting to authenticate with
|
|
17
|
+
* @param payload - { phoneNumber: string } (identifier for the authentication)
|
|
18
|
+
* @returns - { success, message, data }
|
|
19
|
+
*/
|
|
20
|
+
public async startAuth(serverUrl: string, presentationKey: string, payload: AuthPayload): Promise<StartAuthResponse> {
|
|
21
|
+
const res = await fetch(`${serverUrl}/auth/start`, {
|
|
22
|
+
method: 'POST',
|
|
23
|
+
headers: { 'Content-Type': 'application/json' },
|
|
24
|
+
body: JSON.stringify({
|
|
25
|
+
methodType: this.methodType,
|
|
26
|
+
presentationKey,
|
|
27
|
+
payload
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
if (!res.ok) {
|
|
32
|
+
return {
|
|
33
|
+
success: false,
|
|
34
|
+
message: `HTTP error ${res.status}`
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return res.json()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Complete the DevConsole authentication on the server.
|
|
43
|
+
* - The server will verify the OTP code that was generated and logged to the console.
|
|
44
|
+
* @param serverUrl - The base URL of the WAB server
|
|
45
|
+
* @param presentationKey - The 256-bit key
|
|
46
|
+
* @param payload - { phoneNumber: string, otp: string } (the identifier and OTP code from console)
|
|
47
|
+
* @returns - { success, message, presentationKey }
|
|
48
|
+
*/
|
|
49
|
+
public async completeAuth(
|
|
50
|
+
serverUrl: string,
|
|
51
|
+
presentationKey: string,
|
|
52
|
+
payload: AuthPayload
|
|
53
|
+
): Promise<CompleteAuthResponse> {
|
|
54
|
+
const res = await fetch(`${serverUrl}/auth/complete`, {
|
|
55
|
+
method: 'POST',
|
|
56
|
+
headers: { 'Content-Type': 'application/json' },
|
|
57
|
+
body: JSON.stringify({
|
|
58
|
+
methodType: this.methodType,
|
|
59
|
+
presentationKey,
|
|
60
|
+
payload
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
if (!res.ok) {
|
|
65
|
+
return {
|
|
66
|
+
success: false,
|
|
67
|
+
message: `HTTP error ${res.status}`
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return res.json()
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AuthMethodInteractor, AuthPayload, StartAuthResponse, CompleteAuthResponse } from './AuthMethodInteractor'
|
|
2
|
+
|
|
3
|
+
export class PersonaIDInteractor extends AuthMethodInteractor {
|
|
4
|
+
public methodType = 'PersonaID'
|
|
5
|
+
|
|
6
|
+
public async startAuth(serverUrl: string, presentationKey: string, payload: AuthPayload): Promise<StartAuthResponse> {
|
|
7
|
+
const res = await fetch(`${serverUrl}/auth/start`, {
|
|
8
|
+
method: 'POST',
|
|
9
|
+
headers: { 'Content-Type': 'application/json' },
|
|
10
|
+
body: JSON.stringify({
|
|
11
|
+
methodType: this.methodType,
|
|
12
|
+
presentationKey,
|
|
13
|
+
payload
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
return res.json()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public async completeAuth(
|
|
20
|
+
serverUrl: string,
|
|
21
|
+
presentationKey: string,
|
|
22
|
+
payload: AuthPayload
|
|
23
|
+
): Promise<CompleteAuthResponse> {
|
|
24
|
+
const res = await fetch(`${serverUrl}/auth/complete`, {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
headers: { 'Content-Type': 'application/json' },
|
|
27
|
+
body: JSON.stringify({
|
|
28
|
+
methodType: this.methodType,
|
|
29
|
+
presentationKey,
|
|
30
|
+
payload
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
return res.json()
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { AuthMethodInteractor, AuthPayload, StartAuthResponse, CompleteAuthResponse } from './AuthMethodInteractor'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TwilioPhoneInteractor
|
|
5
|
+
*
|
|
6
|
+
* A client-side class that knows how to call the WAB server for Twilio-based phone verification.
|
|
7
|
+
*/
|
|
8
|
+
export class TwilioPhoneInteractor extends AuthMethodInteractor {
|
|
9
|
+
public methodType = 'TwilioPhone'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Start the Twilio phone verification on the server.
|
|
13
|
+
* - The server will send an SMS code to the user’s phone, using Twilio Verify.
|
|
14
|
+
* @param serverUrl - The base URL of the WAB server (e.g. http://localhost:3000)
|
|
15
|
+
* @param presentationKey - The 256-bit key the client is attempting to authenticate with
|
|
16
|
+
* @param payload - { phoneNumber: string } (the phone number to verify)
|
|
17
|
+
* @returns - { success, message, data }
|
|
18
|
+
*/
|
|
19
|
+
public async startAuth(serverUrl: string, presentationKey: string, payload: AuthPayload): Promise<StartAuthResponse> {
|
|
20
|
+
const res = await fetch(`${serverUrl}/auth/start`, {
|
|
21
|
+
method: 'POST',
|
|
22
|
+
headers: { 'Content-Type': 'application/json' },
|
|
23
|
+
body: JSON.stringify({
|
|
24
|
+
methodType: this.methodType,
|
|
25
|
+
presentationKey,
|
|
26
|
+
payload
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
if (!res.ok) {
|
|
31
|
+
return {
|
|
32
|
+
success: false,
|
|
33
|
+
message: `HTTP error ${res.status}`
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return res.json()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Complete the Twilio phone verification on the server.
|
|
42
|
+
* - The server will verify the code with Twilio Verify’s verificationChecks endpoint.
|
|
43
|
+
* @param serverUrl - The base URL of the WAB server
|
|
44
|
+
* @param presentationKey - The 256-bit key
|
|
45
|
+
* @param payload - { phoneNumber: string, otp: string } (the code that was received via SMS)
|
|
46
|
+
* @returns - { success, message, presentationKey }
|
|
47
|
+
*/
|
|
48
|
+
public async completeAuth(
|
|
49
|
+
serverUrl: string,
|
|
50
|
+
presentationKey: string,
|
|
51
|
+
payload: AuthPayload
|
|
52
|
+
): Promise<CompleteAuthResponse> {
|
|
53
|
+
const res = await fetch(`${serverUrl}/auth/complete`, {
|
|
54
|
+
method: 'POST',
|
|
55
|
+
headers: { 'Content-Type': 'application/json' },
|
|
56
|
+
body: JSON.stringify({
|
|
57
|
+
methodType: this.methodType,
|
|
58
|
+
presentationKey,
|
|
59
|
+
payload
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
if (!res.ok) {
|
|
64
|
+
return {
|
|
65
|
+
success: false,
|
|
66
|
+
message: `HTTP error ${res.status}`
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return res.json()
|
|
71
|
+
}
|
|
72
|
+
}
|
package/syncVersions.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Synchronizes version numbers from root package.json to mobile and client package.json files
|
|
7
|
+
* and updates package-lock.json files by running npm install
|
|
8
|
+
*/
|
|
9
|
+
function syncVersions() {
|
|
10
|
+
try {
|
|
11
|
+
// Read the root package.json
|
|
12
|
+
const rootPackagePath = path.join(__dirname, 'package.json');
|
|
13
|
+
const rootPackage = JSON.parse(fs.readFileSync(rootPackagePath, 'utf8'));
|
|
14
|
+
const version = rootPackage.version;
|
|
15
|
+
|
|
16
|
+
console.log(`Root package version: ${version}`);
|
|
17
|
+
|
|
18
|
+
// Directories to update
|
|
19
|
+
const directoriesToUpdate = [
|
|
20
|
+
{ packagePath: './mobile/package.json', dir: './mobile' },
|
|
21
|
+
{ packagePath: './client/package.json', dir: './client' }
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
// Update each package.json file and run npm install
|
|
25
|
+
directoriesToUpdate.forEach(({ packagePath, dir }) => {
|
|
26
|
+
const fullPath = path.join(__dirname, packagePath);
|
|
27
|
+
const fullDirPath = path.join(__dirname, dir);
|
|
28
|
+
|
|
29
|
+
if (fs.existsSync(fullPath)) {
|
|
30
|
+
const packageData = JSON.parse(fs.readFileSync(fullPath, 'utf8'));
|
|
31
|
+
const oldVersion = packageData.version;
|
|
32
|
+
|
|
33
|
+
packageData.version = version;
|
|
34
|
+
fs.writeFileSync(fullPath, JSON.stringify(packageData, null, 2) + '\n');
|
|
35
|
+
|
|
36
|
+
console.log(`Updated ${packagePath}: ${oldVersion} → ${version}`);
|
|
37
|
+
|
|
38
|
+
// Run npm install to update package-lock.json
|
|
39
|
+
if (fs.existsSync(fullDirPath)) {
|
|
40
|
+
console.log(`Running npm install in ${dir}...`);
|
|
41
|
+
try {
|
|
42
|
+
execSync('npm install', {
|
|
43
|
+
cwd: fullDirPath,
|
|
44
|
+
stdio: 'inherit',
|
|
45
|
+
timeout: 60000 // 60 second timeout
|
|
46
|
+
});
|
|
47
|
+
console.log(`✓ npm install completed in ${dir}`);
|
|
48
|
+
} catch (installError) {
|
|
49
|
+
console.error(`✗ npm install failed in ${dir}:`, installError.message);
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
console.warn(`Warning: Directory ${dir} not found`);
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
console.warn(`Warning: ${packagePath} not found`);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
console.log('Version synchronization completed successfully!');
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error('Error synchronizing versions:', error.message);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Run the function if this script is executed directly
|
|
67
|
+
if (require.main === module) {
|
|
68
|
+
syncVersions();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports = syncVersions;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
import { sdk, StorageClient } from '../../../src/index.all'
|
|
3
|
+
import { _tu, TestWalletOnly } from '../../utils/TestUtilsWalletStorage'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* WARNING: This test hangs the commit to master automated test run cycle if included in regular tests...
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
describe('walletStorageClient test', () => {
|
|
10
|
+
jest.setTimeout(99999999)
|
|
11
|
+
|
|
12
|
+
const env = _tu.getEnv('test')
|
|
13
|
+
const testName = () => expect.getState().currentTestName || 'test'
|
|
14
|
+
|
|
15
|
+
const ctxs: TestWalletOnly[] = []
|
|
16
|
+
|
|
17
|
+
beforeAll(async () => {
|
|
18
|
+
//_tu.mockPostServicesAsSuccess(ctxs)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
afterAll(async () => {
|
|
22
|
+
for (const ctx of ctxs) {
|
|
23
|
+
await ctx.storage.destroy()
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
test('1 backup to client', async () => {
|
|
28
|
+
const ctx = await _tu.createLegacyWalletSQLiteCopy('walletStorageClient1')
|
|
29
|
+
ctxs.push(ctx)
|
|
30
|
+
const { wallet, storage } = ctx
|
|
31
|
+
|
|
32
|
+
{
|
|
33
|
+
const client = new StorageClient(wallet, 'https://staging-storage.babbage.systems')
|
|
34
|
+
await storage.addWalletStorageProvider(client)
|
|
35
|
+
await storage.updateBackups()
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
test('2 create storage client backup for test wallet', async () => {
|
|
40
|
+
const ctx = await _tu.createTestWalletWithStorageClient({
|
|
41
|
+
rootKeyHex: '1'.repeat(64),
|
|
42
|
+
endpointUrl: 'https://staging-storage.babbage.systems'
|
|
43
|
+
})
|
|
44
|
+
ctxs.push(ctx)
|
|
45
|
+
const { wallet, storage } = ctx
|
|
46
|
+
|
|
47
|
+
{
|
|
48
|
+
const auth = await storage.getAuth()
|
|
49
|
+
expect(auth.userId).toBeTruthy()
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
test('3 create storage client backup for main wallet', async () => {
|
|
54
|
+
const filePath = process.env.MY_MAIN_FILEPATH
|
|
55
|
+
const identityKey = process.env.MY_MAIN_IDENTITY || ''
|
|
56
|
+
const rootKeyHex = env.devKeys[identityKey]
|
|
57
|
+
expect(filePath && identityKey && rootKeyHex)
|
|
58
|
+
|
|
59
|
+
const chain: sdk.Chain = 'main'
|
|
60
|
+
|
|
61
|
+
const main = await _tu.createSQLiteTestWallet({
|
|
62
|
+
filePath,
|
|
63
|
+
databaseName: 'tone42',
|
|
64
|
+
chain,
|
|
65
|
+
rootKeyHex
|
|
66
|
+
})
|
|
67
|
+
ctxs.push(main)
|
|
68
|
+
|
|
69
|
+
{
|
|
70
|
+
const client = new StorageClient(main.wallet, 'https://storage.babbage.systems')
|
|
71
|
+
await main.storage.addWalletStorageProvider(client)
|
|
72
|
+
await main.storage.updateBackups()
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
})
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { AbortActionArgs } from '@bsv/sdk'
|
|
2
|
+
import { sdk } from '../../../src/index.client'
|
|
3
|
+
import { _tu, expectToThrowWERR, TestWalletNoSetup } from '../../utils/TestUtilsWalletStorage'
|
|
4
|
+
|
|
5
|
+
describe('abortAction tests', () => {
|
|
6
|
+
jest.setTimeout(99999999)
|
|
7
|
+
|
|
8
|
+
const env = _tu.getEnv('test')
|
|
9
|
+
|
|
10
|
+
beforeAll(async () => {})
|
|
11
|
+
|
|
12
|
+
afterAll(async () => {})
|
|
13
|
+
|
|
14
|
+
test('0 invalid params', async () => {
|
|
15
|
+
const ctxs: TestWalletNoSetup[] = []
|
|
16
|
+
if (env.runMySQL) ctxs.push(await _tu.createLegacyWalletMySQLCopy('abortActionTests'))
|
|
17
|
+
ctxs.push(await _tu.createLegacyWalletSQLiteCopy('abortActionTests'))
|
|
18
|
+
for (const { wallet } of ctxs) {
|
|
19
|
+
const invalidArgs: AbortActionArgs[] = [
|
|
20
|
+
{ reference: '' },
|
|
21
|
+
{ reference: '====' },
|
|
22
|
+
{ reference: 'a'.repeat(301) },
|
|
23
|
+
{ reference: 'a'.repeat(300) }
|
|
24
|
+
// Oh so many things to test...
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
for (const args of invalidArgs) {
|
|
28
|
+
await expectToThrowWERR(sdk.WERR_INVALID_PARAMETER, () => wallet.abortAction(args))
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
for (const ctx of ctxs) {
|
|
32
|
+
await ctx.storage.destroy()
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
test('1_abort reference 49f878d8405589', async () => {
|
|
37
|
+
const ctxs: TestWalletNoSetup[] = []
|
|
38
|
+
if (env.runMySQL) ctxs.push(await _tu.createLegacyWalletMySQLCopy('abortActionTests'))
|
|
39
|
+
ctxs.push(await _tu.createLegacyWalletSQLiteCopy('abortActionTests'))
|
|
40
|
+
for (const { wallet } of ctxs) {
|
|
41
|
+
await wallet.abortAction({ reference: 'Sfh42EBViQ==' })
|
|
42
|
+
}
|
|
43
|
+
for (const ctx of ctxs) {
|
|
44
|
+
await ctx.storage.destroy()
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
})
|