dexbot 1.4.11 → 1.4.12
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/README.md +4 -4
- package/dist/analysis/chart_utils.d.ts.map +1 -1
- package/dist/analysis/chart_utils.js +9 -18
- package/dist/analysis/chart_utils.js.map +1 -1
- package/dist/analysis/math_utils.d.ts.map +1 -1
- package/dist/analysis/math_utils.js +6 -16
- package/dist/analysis/math_utils.js.map +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +31 -38
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +1 -1
- package/dist/analysis/trend_detection/hurst_analyzer.js +7 -10
- package/dist/analysis/trend_detection/hurst_analyzer.js.map +1 -1
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js +10 -14
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +1 -1
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js +10 -15
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +1 -1
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js +7 -10
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +1 -1
- package/dist/bot.d.ts.map +1 -1
- package/dist/bot.js +4 -12
- package/dist/bot.js.map +1 -1
- package/dist/credential-daemon.d.ts +0 -1
- package/dist/credential-daemon.d.ts.map +1 -1
- package/dist/credential-daemon.js +3 -123
- package/dist/credential-daemon.js.map +1 -1
- package/dist/dexbot.d.ts +0 -87
- package/dist/dexbot.d.ts.map +1 -1
- package/dist/dexbot.js +11 -14
- package/dist/dexbot.js.map +1 -1
- package/dist/market_adapter/ama_signal_runner.js +8 -9
- package/dist/market_adapter/ama_signal_runner.js.map +1 -1
- package/dist/market_adapter/candle_utils.js +1 -7
- package/dist/market_adapter/candle_utils.js.map +1 -1
- package/dist/market_adapter/core/asymmetric_bounds.js +1 -4
- package/dist/market_adapter/core/asymmetric_bounds.js.map +1 -1
- package/dist/market_adapter/core/config_normalizers.js +5 -9
- package/dist/market_adapter/core/config_normalizers.js.map +1 -1
- package/dist/market_adapter/core/kibana_candles.js +8 -15
- package/dist/market_adapter/core/kibana_candles.js.map +1 -1
- package/dist/market_adapter/core/kibana_client.js +7 -13
- package/dist/market_adapter/core/kibana_client.js.map +1 -1
- package/dist/market_adapter/core/kibana_market_candles.js +6 -12
- package/dist/market_adapter/core/kibana_market_candles.js.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.js +92 -102
- package/dist/market_adapter/core/market_adapter_service.js.map +1 -1
- package/dist/market_adapter/core/strategies/ama.js +5 -10
- package/dist/market_adapter/core/strategies/ama.js.map +1 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.js +21 -24
- package/dist/market_adapter/core/strategies/ama_slope_model.js.map +1 -1
- package/dist/market_adapter/core/strategies/atr/calculator.js +3 -5
- package/dist/market_adapter/core/strategies/atr/calculator.js.map +1 -1
- package/dist/market_adapter/core/strategies/collateral_manager.js +4 -6
- package/dist/market_adapter/core/strategies/collateral_manager.js.map +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.js +15 -22
- package/dist/market_adapter/core/strategies/regime_gate.js.map +1 -1
- package/dist/market_adapter/index.d.ts +23 -23
- package/dist/market_adapter/index.d.ts.map +1 -1
- package/dist/market_adapter/index.js +24 -82
- package/dist/market_adapter/index.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +2 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +59 -98
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
- package/dist/market_adapter/inputs/kibana_source.js +11 -17
- package/dist/market_adapter/inputs/kibana_source.js.map +1 -1
- package/dist/market_adapter/interval_utils.js +1 -2
- package/dist/market_adapter/interval_utils.js.map +1 -1
- package/dist/market_adapter/log_format.js +1 -7
- package/dist/market_adapter/log_format.js.map +1 -1
- package/dist/market_adapter/lp_chart_core.js +20 -22
- package/dist/market_adapter/lp_chart_core.js.map +1 -1
- package/dist/market_adapter/lp_chart_runner.d.ts +1 -1
- package/dist/market_adapter/lp_chart_runner.d.ts.map +1 -1
- package/dist/market_adapter/lp_chart_runner.js +41 -57
- package/dist/market_adapter/lp_chart_runner.js.map +1 -1
- package/dist/market_adapter/lp_chart_strategy_loader.js +30 -34
- package/dist/market_adapter/lp_chart_strategy_loader.js.map +1 -1
- package/dist/market_adapter/market_adapter.d.ts +2 -2
- package/dist/market_adapter/market_adapter.d.ts.map +1 -1
- package/dist/market_adapter/market_adapter.js +157 -221
- package/dist/market_adapter/market_adapter.js.map +1 -1
- package/dist/market_adapter/merge_lp_data.js +17 -18
- package/dist/market_adapter/merge_lp_data.js.map +1 -1
- package/dist/market_adapter/test_helpers.js +3 -14
- package/dist/market_adapter/test_helpers.js.map +1 -1
- package/dist/market_adapter/utils/adapter_client.js +7 -16
- package/dist/market_adapter/utils/adapter_client.js.map +1 -1
- package/dist/market_adapter/utils/atomic_write.js +3 -5
- package/dist/market_adapter/utils/atomic_write.js.map +1 -1
- package/dist/market_adapter/utils/chain.d.ts.map +1 -1
- package/dist/market_adapter/utils/chain.js +9 -17
- package/dist/market_adapter/utils/chain.js.map +1 -1
- package/dist/market_adapter/utils/data_discovery.js +8 -10
- package/dist/market_adapter/utils/data_discovery.js.map +1 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +1 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js +11 -14
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +1 -1
- package/dist/market_adapter/utils/file_lock.js +14 -19
- package/dist/market_adapter/utils/file_lock.js.map +1 -1
- package/dist/market_adapter/utils/native_history.js +8 -14
- package/dist/market_adapter/utils/native_history.js.map +1 -1
- package/dist/market_adapter/utils/paths.js +3 -6
- package/dist/market_adapter/utils/paths.js.map +1 -1
- package/dist/modules/account_bots.d.ts +1 -1
- package/dist/modules/account_bots.d.ts.map +1 -1
- package/dist/modules/account_bots.js +90 -97
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/account_orders.d.ts +0 -9
- package/dist/modules/account_orders.d.ts.map +1 -1
- package/dist/modules/account_orders.js +26 -121
- package/dist/modules/account_orders.js.map +1 -1
- package/dist/modules/authority_resolver.js +12 -18
- package/dist/modules/authority_resolver.js.map +1 -1
- package/dist/modules/bitshares-native/chain_client.js +16 -21
- package/dist/modules/bitshares-native/chain_client.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js +12 -72
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.js +13 -40
- package/dist/modules/bitshares-native/crypto/ecc.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.js +5 -6
- package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +1 -1
- package/dist/modules/bitshares-native/index.d.ts +8 -8
- package/dist/modules/bitshares-native/index.d.ts.map +1 -1
- package/dist/modules/bitshares-native/index.js +11 -68
- package/dist/modules/bitshares-native/index.js.map +1 -1
- package/dist/modules/bitshares-native/lru_cache.js +3 -6
- package/dist/modules/bitshares-native/lru_cache.js.map +1 -1
- package/dist/modules/bitshares-native/resolvers.js +9 -11
- package/dist/modules/bitshares-native/resolvers.js.map +1 -1
- package/dist/modules/bitshares-native/serial/chain_constants.js +3 -28
- package/dist/modules/bitshares-native/serial/chain_constants.js.map +1 -1
- package/dist/modules/bitshares-native/serial/index.d.ts +4 -4
- package/dist/modules/bitshares-native/serial/index.d.ts.map +1 -1
- package/dist/modules/bitshares-native/serial/index.js +5 -46
- package/dist/modules/bitshares-native/serial/index.js.map +1 -1
- package/dist/modules/bitshares-native/serial/operations.d.ts +98 -98
- package/dist/modules/bitshares-native/serial/operations.d.ts.map +1 -1
- package/dist/modules/bitshares-native/serial/operations.js +372 -473
- package/dist/modules/bitshares-native/serial/operations.js.map +1 -1
- package/dist/modules/bitshares-native/serial/serializer.js +3 -8
- package/dist/modules/bitshares-native/serial/serializer.js.map +1 -1
- package/dist/modules/bitshares-native/serial/types.js +9 -74
- package/dist/modules/bitshares-native/serial/types.js.map +1 -1
- package/dist/modules/bitshares-native/signing_client.d.ts.map +1 -1
- package/dist/modules/bitshares-native/signing_client.js +11 -48
- package/dist/modules/bitshares-native/signing_client.js.map +1 -1
- package/dist/modules/bitshares-native/subscriptions.d.ts.map +1 -1
- package/dist/modules/bitshares-native/subscriptions.js +24 -27
- package/dist/modules/bitshares-native/subscriptions.js.map +1 -1
- package/dist/modules/bitshares-native/transport.d.ts.map +1 -1
- package/dist/modules/bitshares-native/transport.js +14 -26
- package/dist/modules/bitshares-native/transport.js.map +1 -1
- package/dist/modules/bitshares-native/tx/builder.js +29 -72
- package/dist/modules/bitshares-native/tx/builder.js.map +1 -1
- package/dist/modules/bitshares-native/tx/tx_cache.js +12 -21
- package/dist/modules/bitshares-native/tx/tx_cache.js.map +1 -1
- package/dist/modules/bitshares_client.d.ts +21 -0
- package/dist/modules/bitshares_client.d.ts.map +1 -1
- package/dist/modules/bitshares_client.js +32 -86
- package/dist/modules/bitshares_client.js.map +1 -1
- package/dist/modules/bot_settings.d.ts.map +1 -1
- package/dist/modules/bot_settings.js +30 -49
- package/dist/modules/bot_settings.js.map +1 -1
- package/dist/modules/bots_file_lock.d.ts.map +1 -1
- package/dist/modules/bots_file_lock.js +5 -13
- package/dist/modules/bots_file_lock.js.map +1 -1
- package/dist/modules/broadcast_failure.js +1 -3
- package/dist/modules/broadcast_failure.js.map +1 -1
- package/dist/modules/chain_keys.d.ts +4 -9
- package/dist/modules/chain_keys.d.ts.map +1 -1
- package/dist/modules/chain_keys.js +77 -182
- package/dist/modules/chain_keys.js.map +1 -1
- package/dist/modules/chain_orders.d.ts +2 -2
- package/dist/modules/chain_orders.d.ts.map +1 -1
- package/dist/modules/chain_orders.js +81 -144
- package/dist/modules/chain_orders.js.map +1 -1
- package/dist/modules/config.d.ts.map +1 -1
- package/dist/modules/config.js +23 -28
- package/dist/modules/config.js.map +1 -1
- package/dist/modules/constants.d.ts +2 -9
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +38 -73
- package/dist/modules/constants.js.map +1 -1
- package/dist/modules/cr_planner.js +15 -26
- package/dist/modules/cr_planner.js.map +1 -1
- package/dist/modules/credential_policy.d.ts +3 -6
- package/dist/modules/credential_policy.d.ts.map +1 -1
- package/dist/modules/credential_policy.js +62 -153
- package/dist/modules/credential_policy.js.map +1 -1
- package/dist/modules/credential_runtime.d.ts +1 -1
- package/dist/modules/credential_runtime.d.ts.map +1 -1
- package/dist/modules/credential_runtime.js +34 -41
- package/dist/modules/credential_runtime.js.map +1 -1
- package/dist/modules/credential_session_cache.d.ts +1 -1
- package/dist/modules/credential_session_cache.d.ts.map +1 -1
- package/dist/modules/credential_session_cache.js +5 -42
- package/dist/modules/credential_session_cache.js.map +1 -1
- package/dist/modules/credit_runtime.d.ts.map +1 -1
- package/dist/modules/credit_runtime.js +126 -162
- package/dist/modules/credit_runtime.js.map +1 -1
- package/dist/modules/crypto/browser_provider.d.ts +1 -1
- package/dist/modules/crypto/browser_provider.d.ts.map +1 -1
- package/dist/modules/crypto/browser_provider.js +7 -11
- package/dist/modules/crypto/browser_provider.js.map +1 -1
- package/dist/modules/crypto/index.d.ts +6 -6
- package/dist/modules/crypto/index.d.ts.map +1 -1
- package/dist/modules/crypto/index.js +12 -30
- package/dist/modules/crypto/index.js.map +1 -1
- package/dist/modules/crypto/node_provider.d.ts +1 -1
- package/dist/modules/crypto/node_provider.d.ts.map +1 -1
- package/dist/modules/crypto/node_provider.js +3 -5
- package/dist/modules/crypto/node_provider.js.map +1 -1
- package/dist/modules/crypto/provider.js +1 -2
- package/dist/modules/crypto/pure_ripemd160.js +1 -3
- package/dist/modules/crypto/pure_ripemd160.js.map +1 -1
- package/dist/modules/crypto/pure_scrypt.js +1 -4
- package/dist/modules/crypto/pure_scrypt.js.map +1 -1
- package/dist/modules/crypto/pure_secp256k1.d.ts +1 -1
- package/dist/modules/crypto/pure_secp256k1.d.ts.map +1 -1
- package/dist/modules/crypto/pure_secp256k1.js +1 -16
- package/dist/modules/crypto/pure_secp256k1.js.map +1 -1
- package/dist/modules/crypto/sync.d.ts.map +1 -1
- package/dist/modules/crypto/sync.js +16 -17
- package/dist/modules/crypto/sync.js.map +1 -1
- package/dist/modules/daemon_node_health.js +14 -16
- package/dist/modules/daemon_node_health.js.map +1 -1
- package/dist/modules/dexbot_class.d.ts +19 -14
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +127 -164
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_cow_runtime.d.ts +28 -27
- package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_cow_runtime.js +55 -45
- package/dist/modules/dexbot_cow_runtime.js.map +1 -1
- package/dist/modules/dexbot_credential_client.d.ts +6 -2
- package/dist/modules/dexbot_credential_client.d.ts.map +1 -1
- package/dist/modules/dexbot_credential_client.js +21 -31
- package/dist/modules/dexbot_credential_client.js.map +1 -1
- package/dist/modules/dexbot_fill_runtime.d.ts +23 -23
- package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_fill_runtime.js +119 -77
- package/dist/modules/dexbot_fill_runtime.js.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts +46 -38
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.js +81 -81
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
- package/dist/modules/dexbot_startup_runtime.d.ts +3 -3
- package/dist/modules/dexbot_startup_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_startup_runtime.js +43 -81
- package/dist/modules/dexbot_startup_runtime.js.map +1 -1
- package/dist/modules/dexbot_state_recovery.d.ts +11 -11
- package/dist/modules/dexbot_state_recovery.js +32 -78
- package/dist/modules/dexbot_state_recovery.js.map +1 -1
- package/dist/modules/env.js +3 -7
- package/dist/modules/env.js.map +1 -1
- package/dist/modules/fund_registry.d.ts.map +1 -1
- package/dist/modules/fund_registry.js +12 -24
- package/dist/modules/fund_registry.js.map +1 -1
- package/dist/modules/general_settings.js +10 -16
- package/dist/modules/general_settings.js.map +1 -1
- package/dist/modules/graceful_shutdown.d.ts.map +1 -1
- package/dist/modules/graceful_shutdown.js +12 -19
- package/dist/modules/graceful_shutdown.js.map +1 -1
- package/dist/modules/key_store.d.ts.map +1 -1
- package/dist/modules/key_store.js +27 -65
- package/dist/modules/key_store.js.map +1 -1
- package/dist/modules/launcher/bot_supervisor.d.ts +1 -1
- package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -1
- package/dist/modules/launcher/bot_supervisor.js +89 -118
- package/dist/modules/launcher/bot_supervisor.js.map +1 -1
- package/dist/modules/launcher/child_env.js +1 -5
- package/dist/modules/launcher/child_env.js.map +1 -1
- package/dist/modules/launcher/credential_bootstrap.js +22 -31
- package/dist/modules/launcher/credential_bootstrap.js.map +1 -1
- package/dist/modules/launcher/credential_daemon.js +37 -75
- package/dist/modules/launcher/credential_daemon.js.map +1 -1
- package/dist/modules/launcher/credential_secret.js +2 -37
- package/dist/modules/launcher/credential_secret.js.map +1 -1
- package/dist/modules/launcher/foreign_cred_daemon.js +25 -31
- package/dist/modules/launcher/foreign_cred_daemon.js.map +1 -1
- package/dist/modules/launcher/headless_password.js +10 -12
- package/dist/modules/launcher/headless_password.js.map +1 -1
- package/dist/modules/launcher/launch_modes.js +3 -9
- package/dist/modules/launcher/launch_modes.js.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts +1 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.js +25 -35
- package/dist/modules/launcher/market_adapter_runtime.js.map +1 -1
- package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +1 -1
- package/dist/modules/launcher/market_adapter_watchdog.js +42 -45
- package/dist/modules/launcher/market_adapter_watchdog.js.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts +1 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.js +67 -138
- package/dist/modules/launcher/monolithic_runtime.js.map +1 -1
- package/dist/modules/launcher/runtime_entry.d.ts +1 -11
- package/dist/modules/launcher/runtime_entry.d.ts.map +1 -1
- package/dist/modules/launcher/runtime_entry.js +12 -15
- package/dist/modules/launcher/runtime_entry.js.map +1 -1
- package/dist/modules/launcher/status_reporting.d.ts +1 -1
- package/dist/modules/launcher/status_reporting.d.ts.map +1 -1
- package/dist/modules/launcher/status_reporting.js +15 -36
- package/dist/modules/launcher/status_reporting.js.map +1 -1
- package/dist/modules/launcher/supervisor_control.js +4 -9
- package/dist/modules/launcher/supervisor_control.js.map +1 -1
- package/dist/modules/logger.d.ts +1 -1
- package/dist/modules/logger.d.ts.map +1 -1
- package/dist/modules/logger.js +3 -38
- package/dist/modules/logger.js.map +1 -1
- package/dist/modules/market_adapter_whitelist.js +9 -18
- package/dist/modules/market_adapter_whitelist.js.map +1 -1
- package/dist/modules/node_failure_ledger.js +1 -3
- package/dist/modules/node_failure_ledger.js.map +1 -1
- package/dist/modules/node_health_cache.d.ts.map +1 -1
- package/dist/modules/node_health_cache.js +15 -25
- package/dist/modules/node_health_cache.js.map +1 -1
- package/dist/modules/node_manager.d.ts +1 -1
- package/dist/modules/node_manager.d.ts.map +1 -1
- package/dist/modules/node_manager.js +44 -43
- package/dist/modules/node_manager.js.map +1 -1
- package/dist/modules/order/accounting.d.ts.map +1 -1
- package/dist/modules/order/accounting.js +102 -118
- package/dist/modules/order/accounting.js.map +1 -1
- package/dist/modules/order/async_lock.d.ts +3 -15
- package/dist/modules/order/async_lock.d.ts.map +1 -1
- package/dist/modules/order/async_lock.js +6 -26
- package/dist/modules/order/async_lock.js.map +1 -1
- package/dist/modules/order/export.js +34 -75
- package/dist/modules/order/export.js.map +1 -1
- package/dist/modules/order/format.d.ts +1 -3
- package/dist/modules/order/format.d.ts.map +1 -1
- package/dist/modules/order/format.js +4 -24
- package/dist/modules/order/format.js.map +1 -1
- package/dist/modules/order/grid.d.ts +3 -3
- package/dist/modules/order/grid.d.ts.map +1 -1
- package/dist/modules/order/grid.js +206 -262
- package/dist/modules/order/grid.js.map +1 -1
- package/dist/modules/order/grid_reconcile.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile.js +77 -94
- package/dist/modules/order/grid_reconcile.js.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.js +117 -149
- package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
- package/dist/modules/order/index.d.ts.map +1 -1
- package/dist/modules/order/index.js +11 -45
- package/dist/modules/order/index.js.map +1 -1
- package/dist/modules/order/logger.js +28 -69
- package/dist/modules/order/logger.js.map +1 -1
- package/dist/modules/order/logger_state.d.ts.map +1 -1
- package/dist/modules/order/logger_state.js +3 -4
- package/dist/modules/order/logger_state.js.map +1 -1
- package/dist/modules/order/manager.d.ts +10 -0
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +131 -151
- package/dist/modules/order/manager.js.map +1 -1
- package/dist/modules/order/processed_fill_store.js +2 -7
- package/dist/modules/order/processed_fill_store.js.map +1 -1
- package/dist/modules/order/strategy.js +23 -25
- package/dist/modules/order/strategy.js.map +1 -1
- package/dist/modules/order/sync_engine.d.ts +27 -0
- package/dist/modules/order/sync_engine.d.ts.map +1 -1
- package/dist/modules/order/sync_engine.js +232 -181
- package/dist/modules/order/sync_engine.js.map +1 -1
- package/dist/modules/order/utils/math.d.ts +1 -25
- package/dist/modules/order/utils/math.d.ts.map +1 -1
- package/dist/modules/order/utils/math.js +49 -172
- package/dist/modules/order/utils/math.js.map +1 -1
- package/dist/modules/order/utils/order.d.ts +46 -2
- package/dist/modules/order/utils/order.d.ts.map +1 -1
- package/dist/modules/order/utils/order.js +165 -143
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/order/utils/system.d.ts +3 -1
- package/dist/modules/order/utils/system.d.ts.map +1 -1
- package/dist/modules/order/utils/system.js +152 -211
- package/dist/modules/order/utils/system.js.map +1 -1
- package/dist/modules/order/utils/timeout.js +1 -4
- package/dist/modules/order/utils/timeout.js.map +1 -1
- package/dist/modules/order/utils/validate.js +91 -142
- package/dist/modules/order/utils/validate.js.map +1 -1
- package/dist/modules/order/utils/withPoolRef.js +21 -61
- package/dist/modules/order/utils/withPoolRef.js.map +1 -1
- package/dist/modules/order/working_grid.js +6 -9
- package/dist/modules/order/working_grid.js.map +1 -1
- package/dist/modules/path_api.d.ts.map +1 -1
- package/dist/modules/path_api.js +8 -11
- package/dist/modules/path_api.js.map +1 -1
- package/dist/modules/paths.d.ts.map +1 -1
- package/dist/modules/paths.js +61 -67
- package/dist/modules/paths.js.map +1 -1
- package/dist/modules/process_discovery.js +13 -21
- package/dist/modules/process_discovery.js.map +1 -1
- package/dist/modules/runtime.js +7 -11
- package/dist/modules/runtime.js.map +1 -1
- package/dist/modules/runtime_settings.d.ts.map +1 -1
- package/dist/modules/runtime_settings.js +14 -16
- package/dist/modules/runtime_settings.js.map +1 -1
- package/dist/modules/settings_merge.js +1 -3
- package/dist/modules/settings_merge.js.map +1 -1
- package/dist/modules/socket_json_client.js +3 -5
- package/dist/modules/socket_json_client.js.map +1 -1
- package/dist/modules/storage/browser_adapter.js +1 -4
- package/dist/modules/storage/browser_adapter.js.map +1 -1
- package/dist/modules/storage/index.d.ts +3 -2
- package/dist/modules/storage/index.d.ts.map +1 -1
- package/dist/modules/storage/index.js +5 -8
- package/dist/modules/storage/index.js.map +1 -1
- package/dist/modules/storage/node_adapter.d.ts +3 -4
- package/dist/modules/storage/node_adapter.d.ts.map +1 -1
- package/dist/modules/storage/node_adapter.js +12 -16
- package/dist/modules/storage/node_adapter.js.map +1 -1
- package/dist/modules/storage/types.js +1 -2
- package/dist/modules/types.d.ts +0 -6
- package/dist/modules/types.d.ts.map +1 -1
- package/dist/modules/types.js +1 -2
- package/dist/modules/types.js.map +1 -1
- package/dist/modules/utils/base58check.js +8 -15
- package/dist/modules/utils/base58check.js.map +1 -1
- package/dist/modules/utils/build_dir.js +3 -7
- package/dist/modules/utils/build_dir.js.map +1 -1
- package/dist/modules/utils/errors.js +1 -5
- package/dist/modules/utils/errors.js.map +1 -1
- package/dist/modules/utils/math_utils.d.ts +1 -1
- package/dist/modules/utils/math_utils.d.ts.map +1 -1
- package/dist/modules/utils/math_utils.js +2 -7
- package/dist/modules/utils/math_utils.js.map +1 -1
- package/dist/modules/validate_profiles.d.ts.map +1 -1
- package/dist/modules/validate_profiles.js +18 -25
- package/dist/modules/validate_profiles.js.map +1 -1
- package/dist/pm2.d.ts +4 -70
- package/dist/pm2.d.ts.map +1 -1
- package/dist/pm2.js +106 -132
- package/dist/pm2.js.map +1 -1
- package/dist/scripts/analyze-git.js +13 -17
- package/dist/scripts/analyze-git.js.map +1 -1
- package/dist/scripts/analyze-orders.d.ts.map +1 -1
- package/dist/scripts/analyze-orders.js +48 -63
- package/dist/scripts/analyze-orders.js.map +1 -1
- package/dist/scripts/diagnose-kibana-candles.d.ts.map +1 -1
- package/dist/scripts/diagnose-kibana-candles.js +2 -1
- package/dist/scripts/diagnose-kibana-candles.js.map +1 -1
- package/dist/scripts/diagnose-pool-history.d.ts.map +1 -1
- package/dist/scripts/diagnose-pool-history.js +2 -1
- package/dist/scripts/diagnose-pool-history.js.map +1 -1
- package/dist/scripts/divergence-calc.d.ts.map +1 -1
- package/dist/scripts/divergence-calc.js +2 -2
- package/dist/scripts/divergence-calc.js.map +1 -1
- package/dist/scripts/fix-err-message.js +17 -22
- package/dist/scripts/fix-err-message.js.map +1 -1
- package/dist/scripts/generate_lp_chart.d.ts.map +1 -1
- package/dist/scripts/generate_lp_chart.js +7 -15
- package/dist/scripts/generate_lp_chart.js.map +1 -1
- package/dist/scripts/generate_mainnet_corpus_report.d.ts.map +1 -1
- package/dist/scripts/generate_mainnet_corpus_report.js +3 -2
- package/dist/scripts/generate_mainnet_corpus_report.js.map +1 -1
- package/dist/scripts/generate_market_adapter_whitelist.d.ts.map +1 -1
- package/dist/scripts/generate_market_adapter_whitelist.js +18 -24
- package/dist/scripts/generate_market_adapter_whitelist.js.map +1 -1
- package/dist/scripts/native_release_gates.js +15 -19
- package/dist/scripts/native_release_gates.js.map +1 -1
- package/dist/scripts/print_grid.d.ts.map +1 -1
- package/dist/scripts/print_grid.js +2 -2
- package/dist/scripts/print_grid.js.map +1 -1
- package/dist/scripts/run-tests.js +12 -17
- package/dist/scripts/run-tests.js.map +1 -1
- package/dist/scripts/runner.d.ts.map +1 -1
- package/dist/scripts/runner.js +18 -20
- package/dist/scripts/runner.js.map +1 -1
- package/dist/scripts/sync-version.js +2 -2
- package/dist/scripts/sync-version.js.map +1 -1
- package/dist/scripts/test-credit-renewal.d.ts.map +1 -1
- package/dist/scripts/test-credit-renewal.js +4 -3
- package/dist/scripts/test-credit-renewal.js.map +1 -1
- package/dist/scripts/update.js +77 -89
- package/dist/scripts/update.js.map +1 -1
- package/dist/scripts/validate_bots.d.ts.map +1 -1
- package/dist/scripts/validate_bots.js +2 -2
- package/dist/scripts/validate_bots.js.map +1 -1
- package/dist/scripts/verify-browser-bundle.js +12 -17
- package/dist/scripts/verify-browser-bundle.js.map +1 -1
- package/dist/unlock.d.ts +0 -30
- package/dist/unlock.d.ts.map +1 -1
- package/dist/unlock.js +95 -143
- package/dist/unlock.js.map +1 -1
- package/package.json +5 -8
- package/scripts/README.md +1 -1
- package/scripts/create-bot-symlinks.sh +2 -2
- package/dist/modules/utils/fs_utils.d.ts +0 -18
- package/dist/modules/utils/fs_utils.d.ts.map +0 -1
- package/dist/modules/utils/fs_utils.js +0 -32
- package/dist/modules/utils/fs_utils.js.map +0 -1
- package/dist/scripts/migrate_bot_keys.d.ts +0 -3
- package/dist/scripts/migrate_bot_keys.d.ts.map +0 -1
- package/dist/scripts/migrate_bot_keys.js +0 -225
- package/dist/scripts/migrate_bot_keys.js.map +0 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* modules/chain_keys.ts - Authentication and Key Management
|
|
4
3
|
*
|
|
@@ -20,7 +19,6 @@
|
|
|
20
19
|
* - Raw 64-character hexadecimal private keys
|
|
21
20
|
*
|
|
22
21
|
* Security: Master password never stored; only a derived vault key is kept in memory.
|
|
23
|
-
* Legacy SHA-256 password hashes are supported only to migrate existing vaults.
|
|
24
22
|
* All newly written private keys use the v2 vault format.
|
|
25
23
|
*
|
|
26
24
|
* ===============================================================================
|
|
@@ -82,79 +80,18 @@
|
|
|
82
80
|
*
|
|
83
81
|
* ===============================================================================
|
|
84
82
|
*/
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
98
|
-
}) : function(o, v) {
|
|
99
|
-
o["default"] = v;
|
|
100
|
-
});
|
|
101
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
102
|
-
var ownKeys = function(o) {
|
|
103
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
104
|
-
var ar = [];
|
|
105
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
106
|
-
return ar;
|
|
107
|
-
};
|
|
108
|
-
return ownKeys(o);
|
|
109
|
-
};
|
|
110
|
-
return function (mod) {
|
|
111
|
-
if (mod && mod.__esModule) return mod;
|
|
112
|
-
var result = {};
|
|
113
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
114
|
-
__setModuleDefault(result, mod);
|
|
115
|
-
return result;
|
|
116
|
-
};
|
|
117
|
-
})();
|
|
118
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
119
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
120
|
-
};
|
|
121
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
122
|
-
exports.MasterPasswordError = void 0;
|
|
123
|
-
exports.validatePrivateKey = validatePrivateKey;
|
|
124
|
-
exports.loadAccounts = loadAccounts;
|
|
125
|
-
exports.saveAccounts = saveAccounts;
|
|
126
|
-
exports.checkKeysFileSecurity = checkKeysFileSecurity;
|
|
127
|
-
exports.encrypt = encrypt;
|
|
128
|
-
exports.decrypt = decrypt;
|
|
129
|
-
exports.deriveVaultKey = deriveVaultKey;
|
|
130
|
-
exports.createDaemonSigningToken = createDaemonSigningToken;
|
|
131
|
-
exports.createSessionSecret = createSessionSecret;
|
|
132
|
-
exports.createVaultSecret = createVaultSecret;
|
|
133
|
-
exports.isVaultSecret = isVaultSecret;
|
|
134
|
-
exports.isDaemonSigningToken = isDaemonSigningToken;
|
|
135
|
-
exports.unlockWithPassword = unlockWithPassword;
|
|
136
|
-
exports.main = main;
|
|
137
|
-
exports.authenticate = authenticate;
|
|
138
|
-
exports.getPrivateKey = getPrivateKey;
|
|
139
|
-
exports.resolvePrivateKey = resolvePrivateKey;
|
|
140
|
-
exports.isMasterPasswordFailure = isMasterPasswordFailure;
|
|
141
|
-
exports.isDaemonReady = isDaemonReady;
|
|
142
|
-
exports.isDaemonResponsive = isDaemonResponsive;
|
|
143
|
-
exports.waitForDaemon = waitForDaemon;
|
|
144
|
-
exports.probeAccountInDaemon = probeAccountInDaemon;
|
|
145
|
-
exports.pingDaemon = pingDaemon;
|
|
146
|
-
const path_api_1 = require("./path_api");
|
|
147
|
-
const system_1 = require("./order/utils/system");
|
|
148
|
-
const constants_1 = require("./constants");
|
|
149
|
-
const paths_1 = require("./paths");
|
|
150
|
-
const logger_1 = __importDefault(require("./logger"));
|
|
151
|
-
const storage_1 = require("./storage");
|
|
152
|
-
const fs_utils_1 = require("./utils/fs_utils");
|
|
153
|
-
const socket_json_client_1 = require("./socket_json_client");
|
|
154
|
-
const authority_resolver_1 = require("./authority_resolver");
|
|
155
|
-
const config_1 = require("./config");
|
|
156
|
-
const base58check = __importStar(require("./utils/base58check"));
|
|
157
|
-
const sync_1 = require("./crypto/sync");
|
|
83
|
+
import { createRequire } from 'node:module';
|
|
84
|
+
const require = createRequire(import.meta.url);
|
|
85
|
+
import { path } from './path_api.js';
|
|
86
|
+
import { readInput, readPassword, sleep } from './order/utils/system.js';
|
|
87
|
+
import { TIMING, CREDENTIAL_PROMPTS } from './constants.js';
|
|
88
|
+
import { PATHS } from './paths.js';
|
|
89
|
+
import { getStorage } from './storage/index.js';
|
|
90
|
+
import { sendSocketJsonRequest } from './socket_json_client.js';
|
|
91
|
+
import { resolvePrivateKey as resolveAuthKey } from './authority_resolver.js';
|
|
92
|
+
import { Config } from './config.js';
|
|
93
|
+
import * as base58check from './utils/base58check.js';
|
|
94
|
+
import { randomBytes, hkdfSync, scryptSync, createHmac, timingSafeEqual, createCipheriv, createDecipheriv, } from './crypto/sync.js';
|
|
158
95
|
let _net;
|
|
159
96
|
function getNet() {
|
|
160
97
|
if (_net === undefined) {
|
|
@@ -170,11 +107,11 @@ function getNet() {
|
|
|
170
107
|
}
|
|
171
108
|
return _net;
|
|
172
109
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const storage =
|
|
177
|
-
const
|
|
110
|
+
import { getCredentialReadyFilePath, getCredentialSocketPath, assertPrivatePathSecurity, } from './credential_runtime.js';
|
|
111
|
+
import { getErrorMessage } from './utils/errors.js';
|
|
112
|
+
import { hasProcess } from './env.js';
|
|
113
|
+
const storage = getStorage();
|
|
114
|
+
const { ensureDir } = storage;
|
|
178
115
|
const VAULT_VERSION = 2;
|
|
179
116
|
const VAULT_SALT_BYTES = 16;
|
|
180
117
|
const VAULT_RECORD_SALT_BYTES = 16;
|
|
@@ -185,7 +122,7 @@ const VAULT_KEY_BYTES = 32;
|
|
|
185
122
|
// strong default; only DEXBOT_VAULT_SCRYPT_N (or a small N) lowers it.
|
|
186
123
|
const _vaultScryptNOverride = (() => {
|
|
187
124
|
try {
|
|
188
|
-
if (!
|
|
125
|
+
if (!hasProcess())
|
|
189
126
|
return undefined;
|
|
190
127
|
const raw = process.env?.DEXBOT_VAULT_SCRYPT_N;
|
|
191
128
|
if (!raw)
|
|
@@ -211,16 +148,16 @@ const VAULT_SECRET_KIND = 'dexbot-vault-secret';
|
|
|
211
148
|
const VAULT_SESSION_SECRET_KIND = 'dexbot-session-secret';
|
|
212
149
|
const VAULT_DAEMON_SIGNING_TOKEN_KIND = 'dexbot-daemon-signing-token';
|
|
213
150
|
// Profiles key file (ignored) only
|
|
214
|
-
const PROFILES_KEYS_FILE =
|
|
215
|
-
?
|
|
216
|
-
:
|
|
151
|
+
const PROFILES_KEYS_FILE = Config.DEXBOT_KEYS_FILE
|
|
152
|
+
? path.resolve(Config.DEXBOT_KEYS_FILE)
|
|
153
|
+
: PATHS.PROFILES.KEYS_JSON();
|
|
217
154
|
/**
|
|
218
155
|
* Ensures that the profiles/keys directory exists.
|
|
219
156
|
* @private
|
|
220
157
|
*/
|
|
221
158
|
function ensureProfilesKeysDirectory() {
|
|
222
|
-
const dir =
|
|
223
|
-
|
|
159
|
+
const dir = path.dirname(PROFILES_KEYS_FILE);
|
|
160
|
+
ensureDir(dir);
|
|
224
161
|
}
|
|
225
162
|
function toBuffer(value, encoding = 'hex') {
|
|
226
163
|
if (Buffer.isBuffer(value)) {
|
|
@@ -262,13 +199,13 @@ function createVaultSecret(vaultKey, extra = {}) {
|
|
|
262
199
|
vaultKeyHex: keyBuffer.toString('hex'),
|
|
263
200
|
};
|
|
264
201
|
}
|
|
265
|
-
function createSessionSecret(vaultKey, sessionSalt =
|
|
202
|
+
function createSessionSecret(vaultKey, sessionSalt = randomBytes(VAULT_SALT_BYTES)) {
|
|
266
203
|
const keyBuffer = resolveVaultKey(vaultKey);
|
|
267
204
|
const saltBuffer = toBuffer(sessionSalt);
|
|
268
205
|
if (!keyBuffer || !saltBuffer) {
|
|
269
206
|
throw new Error('Vault secret and session salt are required');
|
|
270
207
|
}
|
|
271
|
-
const sessionKey = Buffer.from(
|
|
208
|
+
const sessionKey = Buffer.from(hkdfSync('sha256', keyBuffer, saltBuffer, VAULT_SESSION_INFO, VAULT_KEY_BYTES));
|
|
272
209
|
return {
|
|
273
210
|
kind: VAULT_SESSION_SECRET_KIND,
|
|
274
211
|
version: VAULT_VERSION,
|
|
@@ -283,7 +220,7 @@ function createDaemonSigningToken(accountName, options = {}) {
|
|
|
283
220
|
return {
|
|
284
221
|
kind: VAULT_DAEMON_SIGNING_TOKEN_KIND,
|
|
285
222
|
accountName,
|
|
286
|
-
socketPath: options.socketPath ||
|
|
223
|
+
socketPath: options.socketPath || getCredentialSocketPath(options),
|
|
287
224
|
sessionId: options.sessionId || null,
|
|
288
225
|
botHmacSecret: options.botHmacSecret || null,
|
|
289
226
|
};
|
|
@@ -292,8 +229,8 @@ function isDaemonSigningToken(value) {
|
|
|
292
229
|
return !!(value && typeof value === 'object' && value.kind === VAULT_DAEMON_SIGNING_TOKEN_KIND && typeof value.accountName === 'string');
|
|
293
230
|
}
|
|
294
231
|
function deriveVaultKey(password, vaultSalt) {
|
|
295
|
-
const saltBuffer = toBuffer(vaultSalt) ||
|
|
296
|
-
return
|
|
232
|
+
const saltBuffer = toBuffer(vaultSalt) || randomBytes(VAULT_SALT_BYTES);
|
|
233
|
+
return scryptSync(password, saltBuffer, VAULT_KEY_BYTES, VAULT_SCRYPT_PARAMS);
|
|
297
234
|
}
|
|
298
235
|
function deriveRecordKey(vaultKey, recordSalt) {
|
|
299
236
|
const keyBuffer = resolveVaultKey(vaultKey);
|
|
@@ -301,14 +238,14 @@ function deriveRecordKey(vaultKey, recordSalt) {
|
|
|
301
238
|
if (!keyBuffer || !saltBuffer) {
|
|
302
239
|
throw new Error('Vault key and record salt are required');
|
|
303
240
|
}
|
|
304
|
-
return Buffer.from(
|
|
241
|
+
return Buffer.from(hkdfSync('sha256', keyBuffer, saltBuffer, VAULT_RECORD_INFO, VAULT_KEY_BYTES));
|
|
305
242
|
}
|
|
306
243
|
function createVaultVerifier(vaultKey) {
|
|
307
244
|
const keyBuffer = resolveVaultKey(vaultKey);
|
|
308
245
|
if (!keyBuffer) {
|
|
309
246
|
throw new Error('Vault key is required');
|
|
310
247
|
}
|
|
311
|
-
return
|
|
248
|
+
return createHmac('sha256', keyBuffer).update(VAULT_VERIFIER_LABEL).digest('hex');
|
|
312
249
|
}
|
|
313
250
|
function timingSafeEqualHex(leftHex, rightHex) {
|
|
314
251
|
if (typeof leftHex !== 'string' || typeof rightHex !== 'string' || leftHex.length !== rightHex.length) {
|
|
@@ -319,7 +256,7 @@ function timingSafeEqualHex(leftHex, rightHex) {
|
|
|
319
256
|
if (left.length !== right.length) {
|
|
320
257
|
return false;
|
|
321
258
|
}
|
|
322
|
-
return
|
|
259
|
+
return timingSafeEqual(left, right);
|
|
323
260
|
}
|
|
324
261
|
function normalizeAccountsData(data = {}) {
|
|
325
262
|
const accountsSource = data.accounts && typeof data.accounts === 'object'
|
|
@@ -329,7 +266,6 @@ function normalizeAccountsData(data = {}) {
|
|
|
329
266
|
vaultVersion: Number(data.vaultVersion) || 0,
|
|
330
267
|
vaultSalt: typeof data.vaultSalt === 'string' ? data.vaultSalt : '',
|
|
331
268
|
vaultVerifier: typeof data.vaultVerifier === 'string' ? data.vaultVerifier : '',
|
|
332
|
-
masterPasswordHash: typeof data.masterPasswordHash === 'string' ? data.masterPasswordHash : '',
|
|
333
269
|
accounts: accountsSource,
|
|
334
270
|
};
|
|
335
271
|
}
|
|
@@ -356,9 +292,6 @@ function verifyModernPassword(password, accountsData) {
|
|
|
356
292
|
const secret = deriveModernSecretFromPassword(password, accountsData);
|
|
357
293
|
return timingSafeEqualHex(createVaultVerifier(secret), accountsData.vaultVerifier);
|
|
358
294
|
}
|
|
359
|
-
function isVersionedEncryptedPayload(encrypted) {
|
|
360
|
-
return String(encrypted || '').startsWith('v2:');
|
|
361
|
-
}
|
|
362
295
|
/**
|
|
363
296
|
* Encrypt text using the v2 AES-256-GCM vault format.
|
|
364
297
|
* @param {string} text - Plain text to encrypt
|
|
@@ -370,10 +303,10 @@ function encrypt(text, secret) {
|
|
|
370
303
|
if (!vaultKey) {
|
|
371
304
|
throw new Error('A derived vault secret is required to encrypt v2 key data');
|
|
372
305
|
}
|
|
373
|
-
const salt =
|
|
306
|
+
const salt = randomBytes(VAULT_RECORD_SALT_BYTES);
|
|
374
307
|
const key = deriveRecordKey(vaultKey, salt);
|
|
375
|
-
const iv =
|
|
376
|
-
const cipher =
|
|
308
|
+
const iv = randomBytes(VAULT_IV_BYTES);
|
|
309
|
+
const cipher = createCipheriv('aes-256-gcm', key, iv);
|
|
377
310
|
let encrypted = cipher.update(text, 'utf8', 'hex');
|
|
378
311
|
encrypted += cipher.final('hex');
|
|
379
312
|
const authTag = cipher.getAuthTag();
|
|
@@ -388,33 +321,22 @@ function encrypt(text, secret) {
|
|
|
388
321
|
*/
|
|
389
322
|
function decrypt(encrypted, secret) {
|
|
390
323
|
const parts = String(encrypted || '').split(':');
|
|
391
|
-
if (parts.length
|
|
392
|
-
throw new Error('Invalid encrypted payload');
|
|
393
|
-
}
|
|
394
|
-
const isVersioned = parts.length === 5 && parts[0] === 'v2';
|
|
395
|
-
if (!isVersioned && parts.length !== 4) {
|
|
324
|
+
if (parts.length !== 5 || parts[0] !== 'v2') {
|
|
396
325
|
throw new Error('Unsupported encrypted payload version');
|
|
397
326
|
}
|
|
398
|
-
const
|
|
399
|
-
const
|
|
400
|
-
const
|
|
401
|
-
const
|
|
402
|
-
const salt = toBuffer(parts[saltIndex]);
|
|
403
|
-
const iv = toBuffer(parts[ivIndex]);
|
|
404
|
-
const authTag = toBuffer(parts[authTagIndex]);
|
|
405
|
-
const encryptedText = parts[payloadIndex];
|
|
327
|
+
const salt = toBuffer(parts[1]);
|
|
328
|
+
const iv = toBuffer(parts[2]);
|
|
329
|
+
const authTag = toBuffer(parts[3]);
|
|
330
|
+
const encryptedText = parts[4];
|
|
406
331
|
if (!salt || !iv || !authTag || typeof encryptedText !== 'string') {
|
|
407
332
|
throw new Error('Invalid encrypted payload');
|
|
408
333
|
}
|
|
409
|
-
if (!isVersioned) {
|
|
410
|
-
throw new Error('Legacy encrypted data requires migration before decrypt');
|
|
411
|
-
}
|
|
412
334
|
const vaultKey = resolveVaultKey(secret);
|
|
413
335
|
if (!vaultKey) {
|
|
414
336
|
throw new Error('A derived vault secret is required to decrypt v2 key data');
|
|
415
337
|
}
|
|
416
338
|
const key = deriveRecordKey(vaultKey, salt);
|
|
417
|
-
const decipher =
|
|
339
|
+
const decipher = createDecipheriv('aes-256-gcm', key, iv);
|
|
418
340
|
decipher.setAuthTag(authTag);
|
|
419
341
|
let decrypted = decipher.update(encryptedText, 'hex', 'utf8');
|
|
420
342
|
decrypted += decipher.final('utf8');
|
|
@@ -466,7 +388,7 @@ function validatePrivateKey(key) {
|
|
|
466
388
|
return { valid: false, reason: `PVT_K1_ key decoded to ${payload.length} bytes, expected 32` };
|
|
467
389
|
}
|
|
468
390
|
catch (err) {
|
|
469
|
-
return { valid: false, reason: `PVT_K1_ key has invalid base58check encoding: ${
|
|
391
|
+
return { valid: false, reason: `PVT_K1_ key has invalid base58check encoding: ${getErrorMessage(err)}` };
|
|
470
392
|
}
|
|
471
393
|
}
|
|
472
394
|
// Hex private key (64 hex chars) - accept optionally
|
|
@@ -478,7 +400,7 @@ function validatePrivateKey(key) {
|
|
|
478
400
|
/**
|
|
479
401
|
* Load stored accounts from profiles/keys.json.
|
|
480
402
|
* Returns empty structure if file doesn't exist or is corrupted.
|
|
481
|
-
* @returns {Object} { vaultVersion: number, vaultSalt: string, vaultVerifier: string,
|
|
403
|
+
* @returns {Object} { vaultVersion: number, vaultSalt: string, vaultVerifier: string, accounts: Object }
|
|
482
404
|
*/
|
|
483
405
|
function loadAccounts() {
|
|
484
406
|
try {
|
|
@@ -486,18 +408,17 @@ function loadAccounts() {
|
|
|
486
408
|
}
|
|
487
409
|
catch (error) {
|
|
488
410
|
if (error.code !== 'ENOENT' && !(error instanceof SyntaxError)) {
|
|
489
|
-
console.error('Error loading accounts file, resetting to default:',
|
|
411
|
+
console.error('Error loading accounts file, resetting to default:', getErrorMessage(error));
|
|
490
412
|
}
|
|
491
413
|
return normalizeAccountsData();
|
|
492
414
|
}
|
|
493
415
|
}
|
|
494
416
|
function setupModernVault(accountsData, password) {
|
|
495
|
-
const vaultSalt =
|
|
417
|
+
const vaultSalt = randomBytes(VAULT_SALT_BYTES);
|
|
496
418
|
const vaultKey = deriveVaultKey(password, vaultSalt);
|
|
497
419
|
accountsData.vaultVersion = VAULT_VERSION;
|
|
498
420
|
accountsData.vaultSalt = vaultSalt.toString('hex');
|
|
499
421
|
accountsData.vaultVerifier = createVaultVerifier(vaultKey);
|
|
500
|
-
delete accountsData.masterPasswordHash;
|
|
501
422
|
return createVaultSecret(vaultKey);
|
|
502
423
|
}
|
|
503
424
|
/**
|
|
@@ -505,38 +426,20 @@ function setupModernVault(accountsData, password) {
|
|
|
505
426
|
* the current user. Returns silently if the file doesn't exist yet (it will be
|
|
506
427
|
* created correctly by saveAccounts).
|
|
507
428
|
*
|
|
508
|
-
*
|
|
509
|
-
* fix), auto-remediate to 0o600 and log a warning. This prevents the first run
|
|
510
|
-
* after upgrade from crashing with "Unexpected permissions".
|
|
511
|
-
*
|
|
429
|
+
* Fails closed on any violation (world-readable mode, symlink, wrong owner).
|
|
512
430
|
* Should be called early in every entry point that may read or write keys.json.
|
|
513
431
|
*/
|
|
514
432
|
function checkKeysFileSecurity() {
|
|
515
433
|
if (!storage.exists(PROFILES_KEYS_FILE))
|
|
516
434
|
return;
|
|
517
|
-
|
|
518
|
-
(0, credential_runtime_1.assertPrivatePathSecurity)(PROFILES_KEYS_FILE, { expectedType: 'file', requiredMode: 0o600 });
|
|
519
|
-
}
|
|
520
|
-
catch (err) {
|
|
521
|
-
// Auto-remediate legacy 0o644 mode (the state per the security audit)
|
|
522
|
-
const stat = storage.lstat(PROFILES_KEYS_FILE);
|
|
523
|
-
const mode = stat.mode & 0o777;
|
|
524
|
-
if (mode === 0o644 && !stat.isSymbolicLink()) {
|
|
525
|
-
storage.chmod(PROFILES_KEYS_FILE, 0o600);
|
|
526
|
-
chainKeysLogger.warn(`[security] Auto-fixed ${PROFILES_KEYS_FILE} permissions from 0o644 to 0o600. Run: chmod 600 profiles/keys.json`);
|
|
527
|
-
return;
|
|
528
|
-
}
|
|
529
|
-
// For any other security issue (symlink, wrong owner, unexpected mode),
|
|
530
|
-
// fail closed — this is a real security violation, not a migration artifact.
|
|
531
|
-
throw err;
|
|
532
|
-
}
|
|
435
|
+
assertPrivatePathSecurity(PROFILES_KEYS_FILE, { expectedType: 'file', requiredMode: 0o600 });
|
|
533
436
|
}
|
|
534
437
|
/**
|
|
535
438
|
* Unlock the key vault with a master password.
|
|
536
439
|
* Uses modern scrypt v2 vault format with HMAC verification.
|
|
537
440
|
* @param {string} password - Master password
|
|
538
|
-
* @param {import('./types').KeysFile} [accountsData=loadAccounts()] - Accounts data object
|
|
539
|
-
* @returns {import('./types').VaultSecret} Derived vault secret
|
|
441
|
+
* @param {import('./types.js').KeysFile} [accountsData=loadAccounts()] - Accounts data object
|
|
442
|
+
* @returns {import('./types.js').VaultSecret} Derived vault secret
|
|
540
443
|
* @throws {MasterPasswordError} If password is incorrect
|
|
541
444
|
* @throws {Error} If vault format is unsupported
|
|
542
445
|
*/
|
|
@@ -564,7 +467,6 @@ class MasterPasswordError extends Error {
|
|
|
564
467
|
this.code = MasterPasswordError.code;
|
|
565
468
|
}
|
|
566
469
|
}
|
|
567
|
-
exports.MasterPasswordError = MasterPasswordError;
|
|
568
470
|
/**
|
|
569
471
|
* Check if an error is a master password authentication failure.
|
|
570
472
|
* @param {Error} err - Error to check
|
|
@@ -573,7 +475,7 @@ exports.MasterPasswordError = MasterPasswordError;
|
|
|
573
475
|
function isMasterPasswordFailure(err) {
|
|
574
476
|
return !!(err && (err instanceof MasterPasswordError || err.code === MasterPasswordError.code));
|
|
575
477
|
}
|
|
576
|
-
const MASTER_PASSWORD_MAX_ATTEMPTS =
|
|
478
|
+
const MASTER_PASSWORD_MAX_ATTEMPTS = CREDENTIAL_PROMPTS.MAX_MASTER_PASSWORD_ATTEMPTS;
|
|
577
479
|
let masterPasswordAttempts = 0;
|
|
578
480
|
/**
|
|
579
481
|
* Prompts the user for the master password with retry tracking.
|
|
@@ -587,7 +489,7 @@ async function _promptPassword() {
|
|
|
587
489
|
}
|
|
588
490
|
masterPasswordAttempts += 1;
|
|
589
491
|
// Use readPassword instead of readlineSync to support Delete key and consistent masking
|
|
590
|
-
return await
|
|
492
|
+
return await readPassword('Enter master password: ');
|
|
591
493
|
}
|
|
592
494
|
/**
|
|
593
495
|
* Authenticate and return a derived vault secret.
|
|
@@ -642,9 +544,6 @@ function getPrivateKey(accountName, vaultSecret) {
|
|
|
642
544
|
if (!account) {
|
|
643
545
|
throw new Error(`Account '${accountName}' not found.`);
|
|
644
546
|
}
|
|
645
|
-
if (!isVersionedEncryptedPayload(account.encryptedKey)) {
|
|
646
|
-
throw new Error('Legacy encrypted data should have been migrated during unlock');
|
|
647
|
-
}
|
|
648
547
|
return decrypt(account.encryptedKey, vaultSecret);
|
|
649
548
|
}
|
|
650
549
|
/**
|
|
@@ -676,7 +575,7 @@ async function resolvePrivateKey(accountName, vaultSecret, chainClient) {
|
|
|
676
575
|
return [];
|
|
677
576
|
}
|
|
678
577
|
};
|
|
679
|
-
return (
|
|
578
|
+
return resolveAuthKey(accountName, chainClient, tryGetKey, listNames, 0, pubKeyCache);
|
|
680
579
|
}
|
|
681
580
|
/**
|
|
682
581
|
* Display stored account names to console.
|
|
@@ -707,7 +606,7 @@ async function selectKeyName(accounts, promptText) {
|
|
|
707
606
|
return null;
|
|
708
607
|
}
|
|
709
608
|
names.forEach((name, index) => console.log(` ${index + 1}. ${name}`));
|
|
710
|
-
const raw = (await
|
|
609
|
+
const raw = (await readInput(`${promptText} [1-${names.length}]: `)).trim();
|
|
711
610
|
if (raw === '\x1b')
|
|
712
611
|
return '\x1b';
|
|
713
612
|
const idx = Number(raw) - 1;
|
|
@@ -725,11 +624,11 @@ async function selectKeyName(accounts, promptText) {
|
|
|
725
624
|
* @returns {Promise<Object|Buffer|null>} The new vault secret, or the old one if failed/cancelled.
|
|
726
625
|
*/
|
|
727
626
|
async function changeMasterPassword(accountsData, currentSecret) {
|
|
728
|
-
if (!hasModernVault(accountsData)
|
|
627
|
+
if (!hasModernVault(accountsData)) {
|
|
729
628
|
console.log('No master password is set yet.');
|
|
730
629
|
return currentSecret;
|
|
731
630
|
}
|
|
732
|
-
const oldPassword = await
|
|
631
|
+
const oldPassword = await readPassword('Enter current master password: ');
|
|
733
632
|
if (oldPassword === '\x1b')
|
|
734
633
|
return currentSecret;
|
|
735
634
|
if (!verifyCurrentPassword(oldPassword, accountsData)) {
|
|
@@ -737,10 +636,10 @@ async function changeMasterPassword(accountsData, currentSecret) {
|
|
|
737
636
|
return currentSecret;
|
|
738
637
|
}
|
|
739
638
|
const oldSecret = deriveModernSecretFromPassword(oldPassword, accountsData);
|
|
740
|
-
const newPassword = await
|
|
639
|
+
const newPassword = await readPassword('Enter new master password: ');
|
|
741
640
|
if (newPassword === '\x1b')
|
|
742
641
|
return currentSecret;
|
|
743
|
-
const confirmPassword = await
|
|
642
|
+
const confirmPassword = await readPassword('Confirm new master password: ');
|
|
744
643
|
if (confirmPassword === '\x1b')
|
|
745
644
|
return currentSecret;
|
|
746
645
|
if (newPassword !== confirmPassword) {
|
|
@@ -761,7 +660,7 @@ async function changeMasterPassword(accountsData, currentSecret) {
|
|
|
761
660
|
// Clear any partially-decrypted keys before returning
|
|
762
661
|
for (const key of Object.keys(decryptedKeys))
|
|
763
662
|
delete decryptedKeys[key];
|
|
764
|
-
console.log('Failed to decrypt stored keys with the current master password:',
|
|
663
|
+
console.log('Failed to decrypt stored keys with the current master password:', getErrorMessage(error));
|
|
765
664
|
return currentSecret;
|
|
766
665
|
}
|
|
767
666
|
const newSecret = setupModernVault(accountsData, newPassword);
|
|
@@ -791,12 +690,8 @@ function saveAccounts(data) {
|
|
|
791
690
|
vaultVersion: data && Number(data.vaultVersion) ? Number(data.vaultVersion) : 0,
|
|
792
691
|
vaultSalt: data && typeof data.vaultSalt === 'string' ? data.vaultSalt : '',
|
|
793
692
|
vaultVerifier: data && typeof data.vaultVerifier === 'string' ? data.vaultVerifier : '',
|
|
794
|
-
masterPasswordHash: data && typeof data.masterPasswordHash === 'string' ? data.masterPasswordHash : '',
|
|
795
693
|
accounts: data && data.accounts && typeof data.accounts === 'object' ? data.accounts : {},
|
|
796
694
|
};
|
|
797
|
-
if (!serialized.masterPasswordHash) {
|
|
798
|
-
delete serialized.masterPasswordHash;
|
|
799
|
-
}
|
|
800
695
|
if (!serialized.vaultSalt) {
|
|
801
696
|
delete serialized.vaultSalt;
|
|
802
697
|
}
|
|
@@ -823,8 +718,8 @@ async function main() {
|
|
|
823
718
|
// Check if master password is set
|
|
824
719
|
if (!hasModernVault(accountsData)) {
|
|
825
720
|
console.log('No master password set. Please set one:');
|
|
826
|
-
const password1 = await
|
|
827
|
-
const password2 = await
|
|
721
|
+
const password1 = await readPassword('Enter master password: ');
|
|
722
|
+
const password2 = await readPassword('Confirm master password: ');
|
|
828
723
|
if (password1 !== password2) {
|
|
829
724
|
console.log('Passwords do not match!');
|
|
830
725
|
return;
|
|
@@ -841,7 +736,7 @@ async function main() {
|
|
|
841
736
|
}
|
|
842
737
|
catch (err) {
|
|
843
738
|
if (err instanceof MasterPasswordError) {
|
|
844
|
-
console.log(
|
|
739
|
+
console.log(getErrorMessage(err));
|
|
845
740
|
return;
|
|
846
741
|
}
|
|
847
742
|
throw err;
|
|
@@ -856,7 +751,7 @@ async function main() {
|
|
|
856
751
|
console.log('5. Test decryption');
|
|
857
752
|
console.log('6. Change master password');
|
|
858
753
|
console.log('7. Exit (or press Enter)');
|
|
859
|
-
const choiceRaw = await
|
|
754
|
+
const choiceRaw = await readInput('Choose an option: ');
|
|
860
755
|
console.log('');
|
|
861
756
|
if (choiceRaw === '\x1b' || choiceRaw.trim() === '') {
|
|
862
757
|
console.log('Keymanager closed!');
|
|
@@ -864,14 +759,14 @@ async function main() {
|
|
|
864
759
|
}
|
|
865
760
|
const choice = choiceRaw.trim();
|
|
866
761
|
if (choice === '1') {
|
|
867
|
-
const accountNameRaw = await
|
|
762
|
+
const accountNameRaw = await readInput('Enter account name: ');
|
|
868
763
|
if (accountNameRaw === '\x1b')
|
|
869
764
|
continue;
|
|
870
765
|
const accountName = accountNameRaw.trim();
|
|
871
766
|
if (!accountName) {
|
|
872
767
|
continue;
|
|
873
768
|
}
|
|
874
|
-
const privateKeyRaw = await
|
|
769
|
+
const privateKeyRaw = await readPassword('Enter private key: ');
|
|
875
770
|
if (privateKeyRaw === '\x1b')
|
|
876
771
|
continue;
|
|
877
772
|
const privateKey = privateKeyRaw.replace(/\s+/g, '');
|
|
@@ -890,7 +785,7 @@ async function main() {
|
|
|
890
785
|
const accountName = await selectKeyName(accountsData.accounts, 'Select key to modify');
|
|
891
786
|
if (accountName === '\x1b' || !accountName)
|
|
892
787
|
continue;
|
|
893
|
-
const privateKeyRaw = await
|
|
788
|
+
const privateKeyRaw = await readPassword('Enter private key: ');
|
|
894
789
|
if (privateKeyRaw === '\x1b')
|
|
895
790
|
continue;
|
|
896
791
|
const privateKey = privateKeyRaw.replace(/\s+/g, '');
|
|
@@ -909,7 +804,7 @@ async function main() {
|
|
|
909
804
|
const accountName = await selectKeyName(accountsData.accounts, 'Select key to remove');
|
|
910
805
|
if (accountName === '\x1b' || !accountName)
|
|
911
806
|
continue;
|
|
912
|
-
const confirm = (await
|
|
807
|
+
const confirm = (await readInput(`Remove '${accountName}'? (y/n): `)).trim().toLowerCase();
|
|
913
808
|
if (confirm === '\x1b')
|
|
914
809
|
continue;
|
|
915
810
|
if (confirm === 'y') {
|
|
@@ -955,7 +850,7 @@ async function main() {
|
|
|
955
850
|
*/
|
|
956
851
|
function isDaemonReady(options = {}) {
|
|
957
852
|
try {
|
|
958
|
-
return storage.exists(
|
|
853
|
+
return storage.exists(getCredentialReadyFilePath(options)) && storage.exists(getCredentialSocketPath(options));
|
|
959
854
|
}
|
|
960
855
|
catch {
|
|
961
856
|
return false;
|
|
@@ -981,7 +876,7 @@ function isDaemonResponsive(options = {}, timeout = 2000) {
|
|
|
981
876
|
catch {
|
|
982
877
|
return resolve(false);
|
|
983
878
|
}
|
|
984
|
-
const socketPath =
|
|
879
|
+
const socketPath = getCredentialSocketPath(options);
|
|
985
880
|
const socket = net.createConnection(socketPath);
|
|
986
881
|
let settled = false;
|
|
987
882
|
let responseBuffer = '';
|
|
@@ -1030,14 +925,14 @@ function isDaemonResponsive(options = {}, timeout = 2000) {
|
|
|
1030
925
|
* @returns {Promise<void>} Resolves when daemon is ready
|
|
1031
926
|
* @throws {Error} If daemon doesn't start within timeout
|
|
1032
927
|
*/
|
|
1033
|
-
async function waitForDaemon(maxWaitMs =
|
|
928
|
+
async function waitForDaemon(maxWaitMs = TIMING.DAEMON_STARTUP_TIMEOUT_MS, options = {}) {
|
|
1034
929
|
const startTime = Date.now();
|
|
1035
|
-
const checkInterval =
|
|
930
|
+
const checkInterval = TIMING.CHECK_INTERVAL_MS; // Check every 100ms
|
|
1036
931
|
while (Date.now() - startTime < maxWaitMs) {
|
|
1037
932
|
if (isDaemonReady(options)) {
|
|
1038
933
|
return;
|
|
1039
934
|
}
|
|
1040
|
-
await
|
|
935
|
+
await sleep(checkInterval);
|
|
1041
936
|
}
|
|
1042
937
|
throw new Error(`Daemon did not start within ${maxWaitMs}ms`);
|
|
1043
938
|
}
|
|
@@ -1052,9 +947,9 @@ async function waitForDaemon(maxWaitMs = constants_1.TIMING.DAEMON_STARTUP_TIMEO
|
|
|
1052
947
|
* @param {function} extractResult - Callback: (response) => resolved value; throw to reject
|
|
1053
948
|
* @returns {Promise<*>} Resolved value from extractResult
|
|
1054
949
|
*/
|
|
1055
|
-
function sendDaemonRequest(requestType, accountName, timeout =
|
|
1056
|
-
return
|
|
1057
|
-
socketPath:
|
|
950
|
+
function sendDaemonRequest(requestType, accountName, timeout = TIMING.DAEMON_PING_TIMEOUT_MS, options = {}, label = 'request', extractResult = null) {
|
|
951
|
+
return sendSocketJsonRequest({
|
|
952
|
+
socketPath: getCredentialSocketPath(options),
|
|
1058
953
|
timeoutMs: timeout,
|
|
1059
954
|
writePayload: (socket) => {
|
|
1060
955
|
socket.write(JSON.stringify({ type: requestType, accountName }) + '\n');
|
|
@@ -1064,7 +959,7 @@ function sendDaemonRequest(requestType, accountName, timeout = constants_1.TIMIN
|
|
|
1064
959
|
case 'timeout':
|
|
1065
960
|
return new Error(`Daemon ${label} timeout`);
|
|
1066
961
|
case 'connection':
|
|
1067
|
-
return new Error(`Daemon connection failed: ${
|
|
962
|
+
return new Error(`Daemon connection failed: ${getErrorMessage(detail)}`);
|
|
1068
963
|
case 'invalid':
|
|
1069
964
|
return new Error(`Invalid daemon ${label} response`);
|
|
1070
965
|
default:
|
|
@@ -1098,7 +993,7 @@ function sendDaemonRequest(requestType, accountName, timeout = constants_1.TIMIN
|
|
|
1098
993
|
* @param {Object} options - Optional socket path overrides
|
|
1099
994
|
* @returns {Promise<boolean>} Resolves with true if daemon responds
|
|
1100
995
|
*/
|
|
1101
|
-
function pingDaemon(accountName, timeout =
|
|
996
|
+
function pingDaemon(accountName, timeout = TIMING.DAEMON_PING_TIMEOUT_MS, options = {}) {
|
|
1102
997
|
return sendDaemonRequest('ping', accountName, timeout, options, 'ping', (response) => {
|
|
1103
998
|
if (response.success && response.pong)
|
|
1104
999
|
return true;
|
|
@@ -1112,12 +1007,12 @@ function pingDaemon(accountName, timeout = constants_1.TIMING.DAEMON_PING_TIMEOU
|
|
|
1112
1007
|
* @param {Object} options - Optional socket path overrides
|
|
1113
1008
|
* @returns {Promise<string|null>} Resolves with sessionId if account is available, rejects otherwise
|
|
1114
1009
|
*/
|
|
1115
|
-
function probeAccountInDaemon(accountName, timeout =
|
|
1010
|
+
function probeAccountInDaemon(accountName, timeout = TIMING.DAEMON_PING_TIMEOUT_MS, options = {}) {
|
|
1116
1011
|
return sendDaemonRequest('probe-account', accountName, timeout, options, 'probe', (response) => {
|
|
1117
1012
|
if (response.success)
|
|
1118
1013
|
return response.sessionId || null;
|
|
1119
1014
|
throw new Error(response.error || 'Daemon probe failed');
|
|
1120
1015
|
});
|
|
1121
1016
|
}
|
|
1122
|
-
|
|
1017
|
+
export { validatePrivateKey, loadAccounts, saveAccounts, checkKeysFileSecurity, encrypt, decrypt, deriveVaultKey, createDaemonSigningToken, createSessionSecret, createVaultSecret, isVaultSecret, isDaemonSigningToken, unlockWithPassword, main, authenticate, getPrivateKey, resolvePrivateKey, isMasterPasswordFailure, MasterPasswordError, isDaemonReady, isDaemonResponsive, waitForDaemon, probeAccountInDaemon, pingDaemon };
|
|
1123
1018
|
//# sourceMappingURL=chain_keys.js.map
|