trustbase-seller-backend 0.1.5
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/.agents/skills/wechatpay-payment-integration/SKILL.md +165 -0
- package/.agents/skills/wechatpay-payment-integration/references/APIv3/346/216/245/345/217/243/345/212/250/346/200/201/346/216/222/351/232/234.md +234 -0
- package/.agents/skills/wechatpay-payment-integration/references/wechatpay-dev-cli/344/275/277/347/224/250/350/257/264/346/230/216.md +74 -0
- package/.agents/skills/wechatpay-payment-integration/references//345/237/272/347/241/200/346/246/202/345/277/265/345/217/212/344/270/232/345/212/241/344/273/213/347/273/215.md +109 -0
- package/.agents/skills/wechatpay-payment-integration/references//345/246/202/344/275/225/347/220/206/350/247/243/347/224/250/346/210/267/351/227/256/351/242/230.md +55 -0
- package/.agents/skills/wechatpay-payment-integration/references//346/216/245/345/205/245/350/264/250/351/207/217/346/243/200/346/237/245/346/270/205/345/215/225.md +70 -0
- package/.agents/skills/wechatpay-payment-integration/references//346/226/207/346/241/243/346/243/200/347/264/242/344/270/216/351/227/256/347/255/224.md +99 -0
- package/.agents/skills/wechatpay-payment-integration/scripts/bash/extract_and_sign.sh +231 -0
- package/.agents/skills/wechatpay-payment-integration/scripts/powershell/extract_and_sign.ps1 +199 -0
- package/.agents/skills/wechatpay-payment-integration/scripts/wechatpay-resource-sync.py +646 -0
- package/.env.example +70 -0
- package/MERCHANT-EDITION.md +56 -0
- package/README.md +99 -0
- package/api/__tests__/test-utils.d.ts +33 -0
- package/api/__tests__/test-utils.d.ts.map +1 -0
- package/api/__tests__/test-utils.js +90 -0
- package/api/__tests__/test-utils.js.map +1 -0
- package/api/db/case-library-types.d.ts +47 -0
- package/api/db/case-library-types.d.ts.map +1 -0
- package/api/db/case-library-types.js +105 -0
- package/api/db/case-library-types.js.map +1 -0
- package/api/db/case-library.db.d.ts +5 -0
- package/api/db/case-library.db.d.ts.map +1 -0
- package/api/db/case-library.db.js +127 -0
- package/api/db/case-library.db.js.map +1 -0
- package/api/email.d.ts +56 -0
- package/api/email.d.ts.map +1 -0
- package/api/email.js +307 -0
- package/api/email.js.map +1 -0
- package/api/index.d.ts +22 -0
- package/api/index.d.ts.map +1 -0
- package/api/index.js +41 -0
- package/api/index.js.map +1 -0
- package/api/integration-helpers.d.ts +153 -0
- package/api/integration-helpers.d.ts.map +1 -0
- package/api/integration-helpers.js +361 -0
- package/api/integration-helpers.js.map +1 -0
- package/api/lib/case-summary.d.ts +10 -0
- package/api/lib/case-summary.d.ts.map +1 -0
- package/api/lib/case-summary.js +30 -0
- package/api/lib/case-summary.js.map +1 -0
- package/api/middleware/p2p-auth.d.ts +140 -0
- package/api/middleware/p2p-auth.d.ts.map +1 -0
- package/api/middleware/p2p-auth.js +510 -0
- package/api/middleware/p2p-auth.js.map +1 -0
- package/api/middleware/tool-policy.d.ts +47 -0
- package/api/middleware/tool-policy.d.ts.map +1 -0
- package/api/middleware/tool-policy.js +156 -0
- package/api/middleware/tool-policy.js.map +1 -0
- package/api/oauth-adapters.d.ts +192 -0
- package/api/oauth-adapters.d.ts.map +1 -0
- package/api/oauth-adapters.js +456 -0
- package/api/oauth-adapters.js.map +1 -0
- package/api/oauth-bridge.d.ts +56 -0
- package/api/oauth-bridge.d.ts.map +1 -0
- package/api/oauth-bridge.js +624 -0
- package/api/oauth-bridge.js.map +1 -0
- package/api/oauth-router.d.ts +36 -0
- package/api/oauth-router.d.ts.map +1 -0
- package/api/oauth-router.js +54 -0
- package/api/oauth-router.js.map +1 -0
- package/api/p2p-mcp.d.ts +69 -0
- package/api/p2p-mcp.d.ts.map +1 -0
- package/api/p2p-mcp.js +286 -0
- package/api/p2p-mcp.js.map +1 -0
- package/api/payment-store.d.ts +56 -0
- package/api/payment-store.d.ts.map +1 -0
- package/api/payment-store.js +163 -0
- package/api/payment-store.js.map +1 -0
- package/api/payment.d.ts +14 -0
- package/api/payment.d.ts.map +1 -0
- package/api/payment.js +216 -0
- package/api/payment.js.map +1 -0
- package/api/pwa-stats.d.ts +67 -0
- package/api/pwa-stats.d.ts.map +1 -0
- package/api/pwa-stats.js +269 -0
- package/api/pwa-stats.js.map +1 -0
- package/api/riskcontrol-adapters.d.ts +114 -0
- package/api/riskcontrol-adapters.d.ts.map +1 -0
- package/api/riskcontrol-adapters.js +210 -0
- package/api/riskcontrol-adapters.js.map +1 -0
- package/api/riskcontrol-event-whitelist.d.ts +81 -0
- package/api/riskcontrol-event-whitelist.d.ts.map +1 -0
- package/api/riskcontrol-event-whitelist.js +181 -0
- package/api/riskcontrol-event-whitelist.js.map +1 -0
- package/api/riskcontrol-rules.d.ts +105 -0
- package/api/riskcontrol-rules.d.ts.map +1 -0
- package/api/riskcontrol-rules.js +399 -0
- package/api/riskcontrol-rules.js.map +1 -0
- package/api/riskcontrol-scoring.d.ts +72 -0
- package/api/riskcontrol-scoring.d.ts.map +1 -0
- package/api/riskcontrol-scoring.js +335 -0
- package/api/riskcontrol-scoring.js.map +1 -0
- package/api/riskcontrol-service.d.ts +60 -0
- package/api/riskcontrol-service.d.ts.map +1 -0
- package/api/riskcontrol-service.js +206 -0
- package/api/riskcontrol-service.js.map +1 -0
- package/api/riskcontrol-stream.d.ts +112 -0
- package/api/riskcontrol-stream.d.ts.map +1 -0
- package/api/riskcontrol-stream.js +230 -0
- package/api/riskcontrol-stream.js.map +1 -0
- package/api/riskcontrol-v5-e2e-test.d.ts +15 -0
- package/api/riskcontrol-v5-e2e-test.d.ts.map +1 -0
- package/api/riskcontrol-v5-e2e-test.js +204 -0
- package/api/riskcontrol-v5-e2e-test.js.map +1 -0
- package/api/riskcontrol-v5-router.d.ts +48 -0
- package/api/riskcontrol-v5-router.d.ts.map +1 -0
- package/api/riskcontrol-v5-router.js +226 -0
- package/api/riskcontrol-v5-router.js.map +1 -0
- package/api/riskcontrol-webhook.d.ts +88 -0
- package/api/riskcontrol-webhook.d.ts.map +1 -0
- package/api/riskcontrol-webhook.js +326 -0
- package/api/riskcontrol-webhook.js.map +1 -0
- package/api/routes/case-library.d.ts +4 -0
- package/api/routes/case-library.d.ts.map +1 -0
- package/api/routes/case-library.js +91 -0
- package/api/routes/case-library.js.map +1 -0
- package/api/seller-earnings.d.ts +23 -0
- package/api/seller-earnings.d.ts.map +1 -0
- package/api/seller-earnings.js +258 -0
- package/api/seller-earnings.js.map +1 -0
- package/api/seller-orders.d.ts +25 -0
- package/api/seller-orders.d.ts.map +1 -0
- package/api/seller-orders.js +398 -0
- package/api/seller-orders.js.map +1 -0
- package/api/seller-products-chain.d.ts +31 -0
- package/api/seller-products-chain.d.ts.map +1 -0
- package/api/seller-products-chain.js +308 -0
- package/api/seller-products-chain.js.map +1 -0
- package/api/seller-products.d.ts +30 -0
- package/api/seller-products.d.ts.map +1 -0
- package/api/seller-products.js +453 -0
- package/api/seller-products.js.map +1 -0
- package/api/seller-reputation.d.ts +21 -0
- package/api/seller-reputation.d.ts.map +1 -0
- package/api/seller-reputation.js +204 -0
- package/api/seller-reputation.js.map +1 -0
- package/api/seller-router.d.ts +33 -0
- package/api/seller-router.d.ts.map +1 -0
- package/api/seller-router.js +53 -0
- package/api/seller-router.js.map +1 -0
- package/api/seller-settings.d.ts +23 -0
- package/api/seller-settings.d.ts.map +1 -0
- package/api/seller-settings.js +279 -0
- package/api/seller-settings.js.map +1 -0
- package/api/shipping-store.d.ts +44 -0
- package/api/shipping-store.d.ts.map +1 -0
- package/api/shipping-store.js +154 -0
- package/api/shipping-store.js.map +1 -0
- package/api/shipping.d.ts +16 -0
- package/api/shipping.d.ts.map +1 -0
- package/api/shipping.js +239 -0
- package/api/shipping.js.map +1 -0
- package/api/social-endpoint-verify.d.ts +8 -0
- package/api/social-endpoint-verify.d.ts.map +1 -0
- package/api/social-endpoint-verify.js +152 -0
- package/api/social-endpoint-verify.js.map +1 -0
- package/api/social-posts.d.ts +65 -0
- package/api/social-posts.d.ts.map +1 -0
- package/api/social-posts.js +534 -0
- package/api/social-posts.js.map +1 -0
- package/api/social-router.d.ts +36 -0
- package/api/social-router.d.ts.map +1 -0
- package/api/social-router.js +56 -0
- package/api/social-router.js.map +1 -0
- package/api/social-shares.d.ts +40 -0
- package/api/social-shares.d.ts.map +1 -0
- package/api/social-shares.js +379 -0
- package/api/social-shares.js.map +1 -0
- package/api/social-whitelist.d.ts +41 -0
- package/api/social-whitelist.d.ts.map +1 -0
- package/api/social-whitelist.js +261 -0
- package/api/social-whitelist.js.map +1 -0
- package/api/storefront-orders.d.ts +23 -0
- package/api/storefront-orders.d.ts.map +1 -0
- package/api/storefront-orders.js +349 -0
- package/api/storefront-orders.js.map +1 -0
- package/api/storefront-products.d.ts +21 -0
- package/api/storefront-products.d.ts.map +1 -0
- package/api/storefront-products.js +181 -0
- package/api/storefront-products.js.map +1 -0
- package/api/storefront-router.d.ts +33 -0
- package/api/storefront-router.d.ts.map +1 -0
- package/api/storefront-router.js +47 -0
- package/api/storefront-router.js.map +1 -0
- package/api/storefront-user.d.ts +23 -0
- package/api/storefront-user.d.ts.map +1 -0
- package/api/storefront-user.js +336 -0
- package/api/storefront-user.js.map +1 -0
- package/api/test-db-helper.d.ts +29 -0
- package/api/test-db-helper.d.ts.map +1 -0
- package/api/test-db-helper.js +107 -0
- package/api/test-db-helper.js.map +1 -0
- package/api/traffic.d.ts +22 -0
- package/api/traffic.d.ts.map +1 -0
- package/api/traffic.js +112 -0
- package/api/traffic.js.map +1 -0
- package/api/wc-credentials.d.ts +34 -0
- package/api/wc-credentials.d.ts.map +1 -0
- package/api/wc-credentials.js +296 -0
- package/api/wc-credentials.js.map +1 -0
- package/api/wc-tracker-receiver.d.ts +47 -0
- package/api/wc-tracker-receiver.d.ts.map +1 -0
- package/api/wc-tracker-receiver.js +264 -0
- package/api/wc-tracker-receiver.js.map +1 -0
- package/api/wc-v3.d.ts +40 -0
- package/api/wc-v3.d.ts.map +1 -0
- package/api/wc-v3.js +694 -0
- package/api/wc-v3.js.map +1 -0
- package/bin/tb-doctor.js +32 -0
- package/bin/tb-seller-backend.js +42 -0
- package/check.d.ts +2 -0
- package/check.d.ts.map +1 -0
- package/check.js +19 -0
- package/check.js.map +1 -0
- package/config/export-import.d.ts +108 -0
- package/config/export-import.d.ts.map +1 -0
- package/config/export-import.js +234 -0
- package/config/export-import.js.map +1 -0
- package/config/manager.d.ts +73 -0
- package/config/manager.d.ts.map +1 -0
- package/config/manager.js +246 -0
- package/config/manager.js.map +1 -0
- package/config/profile.d.ts +42 -0
- package/config/profile.d.ts.map +1 -0
- package/config/profile.js +111 -0
- package/config/profile.js.map +1 -0
- package/core/address.js +23 -0
- package/core/advanced-performance.d.ts +149 -0
- package/core/advanced-performance.d.ts.map +1 -0
- package/core/advanced-performance.js +374 -0
- package/core/advanced-performance.js.map +1 -0
- package/core/alerting.d.ts +91 -0
- package/core/alerting.d.ts.map +1 -0
- package/core/alerting.js +379 -0
- package/core/alerting.js.map +1 -0
- package/core/app-store.d.ts +77 -0
- package/core/app-store.d.ts.map +1 -0
- package/core/app-store.js +207 -0
- package/core/app-store.js.map +1 -0
- package/core/boot-env.js +39 -0
- package/core/business-scope-schema.d.ts +60 -0
- package/core/business-scope-schema.d.ts.map +1 -0
- package/core/business-scope-schema.js +165 -0
- package/core/business-scope-schema.js.map +1 -0
- package/core/cache.d.ts +53 -0
- package/core/cache.d.ts.map +1 -0
- package/core/cache.js +130 -0
- package/core/cache.js.map +1 -0
- package/core/chain-listener.d.ts +47 -0
- package/core/chain-listener.d.ts.map +1 -0
- package/core/chain-listener.js +254 -0
- package/core/chain-listener.js.map +1 -0
- package/core/chain-reject.js +107 -0
- package/core/chain-signer.js +258 -0
- package/core/cleanup.d.ts +42 -0
- package/core/cleanup.d.ts.map +1 -0
- package/core/cleanup.js +144 -0
- package/core/cleanup.js.map +1 -0
- package/core/cluster.d.ts +78 -0
- package/core/cluster.d.ts.map +1 -0
- package/core/cluster.js +215 -0
- package/core/cluster.js.map +1 -0
- package/core/community-review.d.ts +82 -0
- package/core/community-review.d.ts.map +1 -0
- package/core/community-review.js +201 -0
- package/core/community-review.js.map +1 -0
- package/core/connection-pool.d.ts +72 -0
- package/core/connection-pool.d.ts.map +1 -0
- package/core/connection-pool.js +173 -0
- package/core/connection-pool.js.map +1 -0
- package/core/consistency.d.ts +130 -0
- package/core/consistency.d.ts.map +1 -0
- package/core/consistency.js +340 -0
- package/core/consistency.js.map +1 -0
- package/core/content-ai.d.ts +303 -0
- package/core/content-ai.d.ts.map +1 -0
- package/core/content-ai.js +344 -0
- package/core/content-ai.js.map +1 -0
- package/core/content-backfill.d.ts +55 -0
- package/core/content-backfill.d.ts.map +1 -0
- package/core/content-backfill.js +174 -0
- package/core/content-backfill.js.map +1 -0
- package/core/conversion-rate-sync.d.ts +97 -0
- package/core/conversion-rate-sync.d.ts.map +1 -0
- package/core/conversion-rate-sync.js +195 -0
- package/core/conversion-rate-sync.js.map +1 -0
- package/core/coverage-backup.d.ts +87 -0
- package/core/coverage-backup.d.ts.map +1 -0
- package/core/coverage-backup.js +265 -0
- package/core/coverage-backup.js.map +1 -0
- package/core/db-installer.d.ts +108 -0
- package/core/db-installer.d.ts.map +1 -0
- package/core/db-installer.js +414 -0
- package/core/db-installer.js.map +1 -0
- package/core/device-analyzer.d.ts +96 -0
- package/core/device-analyzer.d.ts.map +1 -0
- package/core/device-analyzer.js +235 -0
- package/core/device-analyzer.js.map +1 -0
- package/core/discovery.d.ts +165 -0
- package/core/discovery.d.ts.map +1 -0
- package/core/discovery.js +363 -0
- package/core/discovery.js.map +1 -0
- package/core/distributed.d.ts +172 -0
- package/core/distributed.d.ts.map +1 -0
- package/core/distributed.js +422 -0
- package/core/distributed.js.map +1 -0
- package/core/doctor.js +249 -0
- package/core/enforcement.d.ts +57 -0
- package/core/enforcement.d.ts.map +1 -0
- package/core/enforcement.js +115 -0
- package/core/enforcement.js.map +1 -0
- package/core/error-handler.d.ts +131 -0
- package/core/error-handler.d.ts.map +1 -0
- package/core/error-handler.js +291 -0
- package/core/error-handler.js.map +1 -0
- package/core/federated-learning.d.ts +124 -0
- package/core/federated-learning.d.ts.map +1 -0
- package/core/federated-learning.js +338 -0
- package/core/federated-learning.js.map +1 -0
- package/core/fingerprint.d.ts +95 -0
- package/core/fingerprint.d.ts.map +1 -0
- package/core/fingerprint.js +313 -0
- package/core/fingerprint.js.map +1 -0
- package/core/geoip.d.ts +67 -0
- package/core/geoip.d.ts.map +1 -0
- package/core/geoip.js +174 -0
- package/core/geoip.js.map +1 -0
- package/core/gossip.d.ts +141 -0
- package/core/gossip.d.ts.map +1 -0
- package/core/gossip.js +372 -0
- package/core/gossip.js.map +1 -0
- package/core/governance.d.ts +147 -0
- package/core/governance.d.ts.map +1 -0
- package/core/governance.js +351 -0
- package/core/governance.js.map +1 -0
- package/core/indexer-enhancements.d.ts +164 -0
- package/core/indexer-enhancements.d.ts.map +1 -0
- package/core/indexer-enhancements.js +429 -0
- package/core/indexer-enhancements.js.map +1 -0
- package/core/intrusion-detection.d.ts +79 -0
- package/core/intrusion-detection.d.ts.map +1 -0
- package/core/intrusion-detection.js +322 -0
- package/core/intrusion-detection.js.map +1 -0
- package/core/lifecycle.d.ts +118 -0
- package/core/lifecycle.d.ts.map +1 -0
- package/core/lifecycle.js +310 -0
- package/core/lifecycle.js.map +1 -0
- package/core/location.d.ts +99 -0
- package/core/location.d.ts.map +1 -0
- package/core/location.js +219 -0
- package/core/location.js.map +1 -0
- package/core/maxmind-integration.d.ts +68 -0
- package/core/maxmind-integration.d.ts.map +1 -0
- package/core/maxmind-integration.js +245 -0
- package/core/maxmind-integration.js.map +1 -0
- package/core/migration.d.ts +58 -0
- package/core/migration.d.ts.map +1 -0
- package/core/migration.js +223 -0
- package/core/migration.js.map +1 -0
- package/core/monitoring.d.ts +153 -0
- package/core/monitoring.d.ts.map +1 -0
- package/core/monitoring.js +406 -0
- package/core/monitoring.js.map +1 -0
- package/core/offsite-backup.d.ts +71 -0
- package/core/offsite-backup.d.ts.map +1 -0
- package/core/offsite-backup.js +341 -0
- package/core/offsite-backup.js.map +1 -0
- package/core/order-intent-store.js +83 -0
- package/core/order-intent.js +273 -0
- package/core/paths.js +116 -0
- package/core/performance.d.ts +173 -0
- package/core/performance.d.ts.map +1 -0
- package/core/performance.js +386 -0
- package/core/performance.js.map +1 -0
- package/core/product-flag.d.ts +364 -0
- package/core/product-flag.d.ts.map +1 -0
- package/core/product-flag.js +465 -0
- package/core/product-flag.js.map +1 -0
- package/core/protection.d.ts +139 -0
- package/core/protection.d.ts.map +1 -0
- package/core/protection.js +327 -0
- package/core/protection.js.map +1 -0
- package/core/region-adapter.d.ts +152 -0
- package/core/region-adapter.d.ts.map +1 -0
- package/core/region-adapter.js +505 -0
- package/core/region-adapter.js.map +1 -0
- package/core/region-configs.d.ts +12 -0
- package/core/region-configs.d.ts.map +1 -0
- package/core/region-configs.js +907 -0
- package/core/region-configs.js.map +1 -0
- package/core/review-antifraud.d.ts +80 -0
- package/core/review-antifraud.d.ts.map +1 -0
- package/core/review-antifraud.js +193 -0
- package/core/review-antifraud.js.map +1 -0
- package/core/rules-updater.d.ts +89 -0
- package/core/rules-updater.d.ts.map +1 -0
- package/core/rules-updater.js +261 -0
- package/core/rules-updater.js.map +1 -0
- package/core/runtime-data.js +203 -0
- package/core/security.d.ts +144 -0
- package/core/security.d.ts.map +1 -0
- package/core/security.js +390 -0
- package/core/security.js.map +1 -0
- package/core/seller-identity.js +78 -0
- package/core/session-manager.d.ts +93 -0
- package/core/session-manager.d.ts.map +1 -0
- package/core/session-manager.js +262 -0
- package/core/session-manager.js.map +1 -0
- package/core/state-sync.d.ts +121 -0
- package/core/state-sync.d.ts.map +1 -0
- package/core/state-sync.js +287 -0
- package/core/state-sync.js.map +1 -0
- package/core/testing.d.ts +97 -0
- package/core/testing.d.ts.map +1 -0
- package/core/testing.js +361 -0
- package/core/testing.js.map +1 -0
- package/core/trust-score.d.ts +51 -0
- package/core/trust-score.d.ts.map +1 -0
- package/core/trust-score.js +188 -0
- package/core/trust-score.js.map +1 -0
- package/core/trustworthiness.d.ts +140 -0
- package/core/trustworthiness.d.ts.map +1 -0
- package/core/trustworthiness.js +375 -0
- package/core/trustworthiness.js.map +1 -0
- package/core/types.d.ts +258 -0
- package/core/types.d.ts.map +1 -0
- package/core/types.js +9 -0
- package/core/types.js.map +1 -0
- package/core/upgrade-manager.d.ts +114 -0
- package/core/upgrade-manager.d.ts.map +1 -0
- package/core/upgrade-manager.js +264 -0
- package/core/upgrade-manager.js.map +1 -0
- package/core/upgrader.d.ts +107 -0
- package/core/upgrader.d.ts.map +1 -0
- package/core/upgrader.js +389 -0
- package/core/upgrader.js.map +1 -0
- package/core/websocket.d.ts +78 -0
- package/core/websocket.d.ts.map +1 -0
- package/core/websocket.js +292 -0
- package/core/websocket.js.map +1 -0
- package/council/hidden-weight.d.ts +45 -0
- package/council/hidden-weight.d.ts.map +1 -0
- package/council/hidden-weight.js +135 -0
- package/council/hidden-weight.js.map +1 -0
- package/db/email-migrations.sql +31 -0
- package/db/oauth-migrate.d.ts +39 -0
- package/db/oauth-migrate.d.ts.map +1 -0
- package/db/oauth-migrate.js +201 -0
- package/db/oauth-migrate.js.map +1 -0
- package/db/oauth-migrations.sql +92 -0
- package/db/social-migrate.d.ts +12 -0
- package/db/social-migrate.d.ts.map +1 -0
- package/db/social-migrate.js +102 -0
- package/db/social-migrate.js.map +1 -0
- package/db/social-migrations.sql +94 -0
- package/db/store-migrate.d.ts +33 -0
- package/db/store-migrate.d.ts.map +1 -0
- package/db/store-migrate.js +149 -0
- package/db/store-migrate.js.map +1 -0
- package/db/store-migrations.sql +242 -0
- package/debug.d.ts +2 -0
- package/debug.d.ts.map +1 -0
- package/debug.js +18 -0
- package/debug.js.map +1 -0
- package/event-listener.d.ts +93 -0
- package/event-listener.d.ts.map +1 -0
- package/event-listener.js +321 -0
- package/event-listener.js.map +1 -0
- package/event-whitelist.d.ts +79 -0
- package/event-whitelist.d.ts.map +1 -0
- package/event-whitelist.js +533 -0
- package/event-whitelist.js.map +1 -0
- package/index.d.ts +45 -0
- package/index.d.ts.map +1 -0
- package/index.js +361 -0
- package/index.js.map +1 -0
- package/init-node.d.ts +9 -0
- package/init-node.d.ts.map +1 -0
- package/init-node.js +230 -0
- package/init-node.js.map +1 -0
- package/mcp/ai-tools.d.ts +2 -0
- package/mcp/ai-tools.d.ts.map +1 -0
- package/mcp/ai-tools.js +266 -0
- package/mcp/ai-tools.js.map +1 -0
- package/mcp/auto-dispatch-tools.d.ts +2 -0
- package/mcp/auto-dispatch-tools.d.ts.map +1 -0
- package/mcp/auto-dispatch-tools.js +348 -0
- package/mcp/auto-dispatch-tools.js.map +1 -0
- package/mcp/business-scope-tools.d.ts +11 -0
- package/mcp/business-scope-tools.d.ts.map +1 -0
- package/mcp/business-scope-tools.js +179 -0
- package/mcp/business-scope-tools.js.map +1 -0
- package/mcp/buyer-tools.d.ts +67 -0
- package/mcp/buyer-tools.d.ts.map +1 -0
- package/mcp/buyer-tools.js +445 -0
- package/mcp/buyer-tools.js.map +1 -0
- package/mcp/interfaces.d.ts +1058 -0
- package/mcp/interfaces.d.ts.map +1 -0
- package/mcp/interfaces.js +13 -0
- package/mcp/interfaces.js.map +1 -0
- package/mcp/m2m-chat-tool.d.ts +50 -0
- package/mcp/m2m-chat-tool.d.ts.map +1 -0
- package/mcp/m2m-chat-tool.js +432 -0
- package/mcp/m2m-chat-tool.js.map +1 -0
- package/mcp/migrations.d.ts +30 -0
- package/mcp/migrations.d.ts.map +1 -0
- package/mcp/migrations.js +391 -0
- package/mcp/migrations.js.map +1 -0
- package/mcp/peer-tools.d.ts +163 -0
- package/mcp/peer-tools.d.ts.map +1 -0
- package/mcp/peer-tools.js +532 -0
- package/mcp/peer-tools.js.map +1 -0
- package/mcp/plugin-management-tools.d.ts +2 -0
- package/mcp/plugin-management-tools.d.ts.map +1 -0
- package/mcp/plugin-management-tools.js +327 -0
- package/mcp/plugin-management-tools.js.map +1 -0
- package/mcp/product-type-tools.d.ts +2 -0
- package/mcp/product-type-tools.d.ts.map +1 -0
- package/mcp/product-type-tools.js +470 -0
- package/mcp/product-type-tools.js.map +1 -0
- package/mcp/security-tools.d.ts +2 -0
- package/mcp/security-tools.d.ts.map +1 -0
- package/mcp/security-tools.js +313 -0
- package/mcp/security-tools.js.map +1 -0
- package/mcp/seller-query-tools.d.ts +2 -0
- package/mcp/seller-query-tools.d.ts.map +1 -0
- package/mcp/seller-query-tools.js +179 -0
- package/mcp/seller-query-tools.js.map +1 -0
- package/mcp/server.d.ts +11 -0
- package/mcp/server.d.ts.map +1 -0
- package/mcp/server.js +68 -0
- package/mcp/server.js.map +1 -0
- package/mcp/standalone-server.d.ts +34 -0
- package/mcp/standalone-server.d.ts.map +1 -0
- package/mcp/standalone-server.js +261 -0
- package/mcp/standalone-server.js.map +1 -0
- package/mcp/tools-integration.d.ts +31 -0
- package/mcp/tools-integration.d.ts.map +1 -0
- package/mcp/tools-integration.js +288 -0
- package/mcp/tools-integration.js.map +1 -0
- package/mcp/web-panel.d.ts +18 -0
- package/mcp/web-panel.d.ts.map +1 -0
- package/mcp/web-panel.js +1657 -0
- package/mcp/web-panel.js.map +1 -0
- package/middleware/api-key-auth.d.ts +64 -0
- package/middleware/api-key-auth.d.ts.map +1 -0
- package/middleware/api-key-auth.js +255 -0
- package/middleware/api-key-auth.js.map +1 -0
- package/middleware/scope-auth.d.ts +54 -0
- package/middleware/scope-auth.d.ts.map +1 -0
- package/middleware/scope-auth.js +153 -0
- package/middleware/scope-auth.js.map +1 -0
- package/middleware/security.d.ts +48 -0
- package/middleware/security.d.ts.map +1 -0
- package/middleware/security.js +217 -0
- package/middleware/security.js.map +1 -0
- package/middleware/wallet-auth.d.ts +54 -0
- package/middleware/wallet-auth.d.ts.map +1 -0
- package/middleware/wallet-auth.js +158 -0
- package/middleware/wallet-auth.js.map +1 -0
- package/oauth/chain-revocation-sink.d.ts +24 -0
- package/oauth/chain-revocation-sink.d.ts.map +1 -0
- package/oauth/chain-revocation-sink.js +47 -0
- package/oauth/chain-revocation-sink.js.map +1 -0
- package/oauth/gossip-sync.d.ts +25 -0
- package/oauth/gossip-sync.d.ts.map +1 -0
- package/oauth/gossip-sync.js +62 -0
- package/oauth/gossip-sync.js.map +1 -0
- package/oauth/issuer-keys.d.ts +31 -0
- package/oauth/issuer-keys.d.ts.map +1 -0
- package/oauth/issuer-keys.js +117 -0
- package/oauth/issuer-keys.js.map +1 -0
- package/oauth/peer-resolver.d.ts +25 -0
- package/oauth/peer-resolver.d.ts.map +1 -0
- package/oauth/peer-resolver.js +81 -0
- package/oauth/peer-resolver.js.map +1 -0
- package/oauth/revocation-store.d.ts +58 -0
- package/oauth/revocation-store.d.ts.map +1 -0
- package/oauth/revocation-store.js +86 -0
- package/oauth/revocation-store.js.map +1 -0
- package/oauth/token-v2.d.ts +101 -0
- package/oauth/token-v2.d.ts.map +1 -0
- package/oauth/token-v2.js +167 -0
- package/oauth/token-v2.js.map +1 -0
- package/oracle/c5-glue.js +603 -0
- package/oracle/ops-console.js +623 -0
- package/oracle/oracle-sync.d.ts +29 -0
- package/oracle/oracle-sync.d.ts.map +1 -0
- package/oracle/oracle-sync.js +445 -0
- package/oracle/oracle-sync.js.map +1 -0
- package/oracle/registry.d.ts +30 -0
- package/oracle/registry.d.ts.map +1 -0
- package/oracle/registry.js +62 -0
- package/oracle/registry.js.map +1 -0
- package/p2p/availability.d.ts +188 -0
- package/p2p/availability.d.ts.map +1 -0
- package/p2p/availability.js +574 -0
- package/p2p/availability.js.map +1 -0
- package/p2p/bootstrap.d.ts +42 -0
- package/p2p/bootstrap.d.ts.map +1 -0
- package/p2p/bootstrap.js +146 -0
- package/p2p/bootstrap.js.map +1 -0
- package/p2p/buyer-client.d.ts +98 -0
- package/p2p/buyer-client.d.ts.map +1 -0
- package/p2p/buyer-client.js +199 -0
- package/p2p/buyer-client.js.map +1 -0
- package/p2p/cdn-ddns.d.ts +208 -0
- package/p2p/cdn-ddns.d.ts.map +1 -0
- package/p2p/cdn-ddns.js +500 -0
- package/p2p/cdn-ddns.js.map +1 -0
- package/p2p/cluster-sync.d.ts +115 -0
- package/p2p/cluster-sync.d.ts.map +1 -0
- package/p2p/cluster-sync.js +330 -0
- package/p2p/cluster-sync.js.map +1 -0
- package/p2p/consistency-check.d.ts +30 -0
- package/p2p/consistency-check.d.ts.map +1 -0
- package/p2p/consistency-check.js +168 -0
- package/p2p/consistency-check.js.map +1 -0
- package/p2p/endpoint-registry.d.ts +41 -0
- package/p2p/endpoint-registry.d.ts.map +1 -0
- package/p2p/endpoint-registry.js +128 -0
- package/p2p/endpoint-registry.js.map +1 -0
- package/p2p/ipv6.d.ts +120 -0
- package/p2p/ipv6.d.ts.map +1 -0
- package/p2p/ipv6.js +425 -0
- package/p2p/ipv6.js.map +1 -0
- package/p2p/protocol.d.ts +100 -0
- package/p2p/protocol.d.ts.map +1 -0
- package/p2p/protocol.js +330 -0
- package/p2p/protocol.js.map +1 -0
- package/p2p/reliability.d.ts +56 -0
- package/p2p/reliability.d.ts.map +1 -0
- package/p2p/reliability.js +240 -0
- package/p2p/reliability.js.map +1 -0
- package/p2p/seller-service.d.ts +53 -0
- package/p2p/seller-service.d.ts.map +1 -0
- package/p2p/seller-service.js +276 -0
- package/p2p/seller-service.js.map +1 -0
- package/p2p/signing.d.ts +31 -0
- package/p2p/signing.d.ts.map +1 -0
- package/p2p/signing.js +95 -0
- package/p2p/signing.js.map +1 -0
- package/package.json +73 -0
- package/payment/api.d.ts +9 -0
- package/payment/api.d.ts.map +1 -0
- package/payment/api.js +141 -0
- package/payment/api.js.map +1 -0
- package/payment/gateway.d.ts +114 -0
- package/payment/gateway.d.ts.map +1 -0
- package/payment/gateway.js +231 -0
- package/payment/gateway.js.map +1 -0
- package/payments/alipay/index.d.ts +18 -0
- package/payments/alipay/index.d.ts.map +1 -0
- package/payments/alipay/index.js +55 -0
- package/payments/alipay/index.js.map +1 -0
- package/payments/base.d.ts +13 -0
- package/payments/base.d.ts.map +1 -0
- package/payments/base.js +28 -0
- package/payments/base.js.map +1 -0
- package/payments/index.d.ts +18 -0
- package/payments/index.d.ts.map +1 -0
- package/payments/index.js +66 -0
- package/payments/index.js.map +1 -0
- package/payments/template/index.d.ts +18 -0
- package/payments/template/index.d.ts.map +1 -0
- package/payments/template/index.js +57 -0
- package/payments/template/index.js.map +1 -0
- package/payments/types.d.ts +42 -0
- package/payments/types.d.ts.map +1 -0
- package/payments/types.js +3 -0
- package/payments/types.js.map +1 -0
- package/payments/wechat/index.d.ts +18 -0
- package/payments/wechat/index.d.ts.map +1 -0
- package/payments/wechat/index.js +54 -0
- package/payments/wechat/index.js.map +1 -0
- package/peer/chain-signer.d.ts +74 -0
- package/peer/chain-signer.d.ts.map +1 -0
- package/peer/chain-signer.js +149 -0
- package/peer/chain-signer.js.map +1 -0
- package/peer/config.d.ts +71 -0
- package/peer/config.d.ts.map +1 -0
- package/peer/config.js +61 -0
- package/peer/config.js.map +1 -0
- package/peer/index.d.ts +12 -0
- package/peer/index.d.ts.map +1 -0
- package/peer/index.js +46 -0
- package/peer/index.js.map +1 -0
- package/peer/key-store.d.ts +66 -0
- package/peer/key-store.d.ts.map +1 -0
- package/peer/key-store.js +163 -0
- package/peer/key-store.js.map +1 -0
- package/peer/proto-codec.d.ts +103 -0
- package/peer/proto-codec.d.ts.map +1 -0
- package/peer/proto-codec.js +423 -0
- package/peer/proto-codec.js.map +1 -0
- package/peer/registrar.d.ts +88 -0
- package/peer/registrar.d.ts.map +1 -0
- package/peer/registrar.js +271 -0
- package/peer/registrar.js.map +1 -0
- package/peer/registry.d.ts +31 -0
- package/peer/registry.d.ts.map +1 -0
- package/peer/registry.js +143 -0
- package/peer/registry.js.map +1 -0
- package/plugins/auth.d.ts +193 -0
- package/plugins/auth.d.ts.map +1 -0
- package/plugins/auth.js +923 -0
- package/plugins/auth.js.map +1 -0
- package/plugins/manager.d.ts +37 -0
- package/plugins/manager.d.ts.map +1 -0
- package/plugins/manager.js +83 -0
- package/plugins/manager.js.map +1 -0
- package/plugins/oauth.d.ts +249 -0
- package/plugins/oauth.d.ts.map +1 -0
- package/plugins/oauth.js +979 -0
- package/plugins/oauth.js.map +1 -0
- package/plugins/p2p-message.d.ts +133 -0
- package/plugins/p2p-message.d.ts.map +1 -0
- package/plugins/p2p-message.js +443 -0
- package/plugins/p2p-message.js.map +1 -0
- package/plugins/postgresql.d.ts +54 -0
- package/plugins/postgresql.d.ts.map +1 -0
- package/plugins/postgresql.js +743 -0
- package/plugins/postgresql.js.map +1 -0
- package/plugins/relationship.d.ts +141 -0
- package/plugins/relationship.d.ts.map +1 -0
- package/plugins/relationship.js +395 -0
- package/plugins/relationship.js.map +1 -0
- package/plugins/sqlite.d.ts +200 -0
- package/plugins/sqlite.d.ts.map +1 -0
- package/plugins/sqlite.js +2412 -0
- package/plugins/sqlite.js.map +1 -0
- package/port-manager/disguise/ssh.d.ts +19 -0
- package/port-manager/disguise/ssh.d.ts.map +1 -0
- package/port-manager/disguise/ssh.js +104 -0
- package/port-manager/disguise/ssh.js.map +1 -0
- package/port-manager/port-manager.d.ts +65 -0
- package/port-manager/port-manager.d.ts.map +1 -0
- package/port-manager/port-manager.js +164 -0
- package/port-manager/port-manager.js.map +1 -0
- package/port-manager/port-scanner.d.ts +22 -0
- package/port-manager/port-scanner.d.ts.map +1 -0
- package/port-manager/port-scanner.js +187 -0
- package/port-manager/port-scanner.js.map +1 -0
- package/port-manager/types.d.ts +51 -0
- package/port-manager/types.d.ts.map +1 -0
- package/port-manager/types.js +6 -0
- package/port-manager/types.js.map +1 -0
- package/proto/amino/amino.proto +84 -0
- package/proto/cosmos/base/v1beta1/coin.proto +61 -0
- package/proto/cosmos/msg/v1/msg.proto +30 -0
- package/proto/cosmos_proto/cosmos.proto +112 -0
- package/proto/gogoproto/gogo.proto +145 -0
- package/proto/google/protobuf/descriptor.proto +1218 -0
- package/proto/trustchain/economy/v1/params.proto +133 -0
- package/proto/trustchain/economy/v1/tx.proto +162 -0
- package/proto/trustchain/marketplace/v1/params.proto +64 -0
- package/proto/trustchain/marketplace/v1/product.proto +21 -0
- package/proto/trustchain/marketplace/v1/tx.proto +131 -0
- package/proto/trustchain/order/v1/params.proto +94 -0
- package/proto/trustchain/order/v1/tx.proto +156 -0
- package/proto/trustchain/serviceprovider/v1/paymentfact.proto +32 -0
- package/proto/trustchain/serviceprovider/v1/serviceprovider.proto +38 -0
- package/proto/trustchain/serviceprovider/v1/tx.proto +106 -0
- package/proto/trustchain/subchain/v1/params.proto +26 -0
- package/proto/trustchain/subchain/v1/pool.proto +53 -0
- package/proto/trustchain/subchain/v1/tx.proto +159 -0
- package/proto/trustchain/trustcoin/v1/business_scope.proto +126 -0
- package/proto/trustchain/trustcoin/v1/genesis.proto +33 -0
- package/proto/trustchain/trustcoin/v1/params.proto +86 -0
- package/proto/trustchain/trustcoin/v1/query.proto +95 -0
- package/proto/trustchain/trustcoin/v1/tx.proto +160 -0
- package/proto/trustchain/verification/v1/params.proto +46 -0
- package/proto/trustchain/verification/v1/tx.proto +126 -0
- package/proto/trustchain/verification/v1/verification.proto +105 -0
- package/relationship-chain-api.d.ts +13 -0
- package/relationship-chain-api.d.ts.map +1 -0
- package/relationship-chain-api.js +139 -0
- package/relationship-chain-api.js.map +1 -0
- package/relationship-chain.d.ts +90 -0
- package/relationship-chain.d.ts.map +1 -0
- package/relationship-chain.js +201 -0
- package/relationship-chain.js.map +1 -0
- package/routes/agent-pay.js +419 -0
- package/routes/agent-serviceprovider.js +183 -0
- package/routes/ai.d.ts +54 -0
- package/routes/ai.d.ts.map +1 -0
- package/routes/ai.js +293 -0
- package/routes/ai.js.map +1 -0
- package/routes/api-keys.d.ts +12 -0
- package/routes/api-keys.d.ts.map +1 -0
- package/routes/api-keys.js +163 -0
- package/routes/api-keys.js.map +1 -0
- package/routes/app-store.d.ts +12 -0
- package/routes/app-store.d.ts.map +1 -0
- package/routes/app-store.js +207 -0
- package/routes/app-store.js.map +1 -0
- package/routes/auth-management.d.ts +17 -0
- package/routes/auth-management.d.ts.map +1 -0
- package/routes/auth-management.js +257 -0
- package/routes/auth-management.js.map +1 -0
- package/routes/auth.d.ts +9 -0
- package/routes/auth.d.ts.map +1 -0
- package/routes/auth.js +846 -0
- package/routes/auth.js.map +1 -0
- package/routes/brand.d.ts +3 -0
- package/routes/brand.d.ts.map +1 -0
- package/routes/brand.js +109 -0
- package/routes/brand.js.map +1 -0
- package/routes/chain-registry.d.ts +11 -0
- package/routes/chain-registry.d.ts.map +1 -0
- package/routes/chain-registry.js +51 -0
- package/routes/chain-registry.js.map +1 -0
- package/routes/chain-writes-insurance.d.ts +17 -0
- package/routes/chain-writes-insurance.d.ts.map +1 -0
- package/routes/chain-writes-insurance.js +69 -0
- package/routes/chain-writes-insurance.js.map +1 -0
- package/routes/chain-writes-pledge.d.ts +34 -0
- package/routes/chain-writes-pledge.d.ts.map +1 -0
- package/routes/chain-writes-pledge.js +206 -0
- package/routes/chain-writes-pledge.js.map +1 -0
- package/routes/chain-writes-products.d.ts +66 -0
- package/routes/chain-writes-products.d.ts.map +1 -0
- package/routes/chain-writes-products.js +394 -0
- package/routes/chain-writes-products.js.map +1 -0
- package/routes/chain-writes.d.ts +78 -0
- package/routes/chain-writes.d.ts.map +1 -0
- package/routes/chain-writes.js +658 -0
- package/routes/chain-writes.js.map +1 -0
- package/routes/chain.d.ts +10 -0
- package/routes/chain.d.ts.map +1 -0
- package/routes/chain.js +45 -0
- package/routes/chain.js.map +1 -0
- package/routes/compliance.d.ts +3 -0
- package/routes/compliance.d.ts.map +1 -0
- package/routes/compliance.js +53 -0
- package/routes/compliance.js.map +1 -0
- package/routes/council.d.ts +3 -0
- package/routes/council.d.ts.map +1 -0
- package/routes/council.js +477 -0
- package/routes/council.js.map +1 -0
- package/routes/crosschain.d.ts +11 -0
- package/routes/crosschain.d.ts.map +1 -0
- package/routes/crosschain.js +39 -0
- package/routes/crosschain.js.map +1 -0
- package/routes/device.d.ts +3 -0
- package/routes/device.d.ts.map +1 -0
- package/routes/device.js +73 -0
- package/routes/device.js.map +1 -0
- package/routes/devreward.d.ts +54 -0
- package/routes/devreward.d.ts.map +1 -0
- package/routes/devreward.js +129 -0
- package/routes/devreward.js.map +1 -0
- package/routes/economy.d.ts +50 -0
- package/routes/economy.d.ts.map +1 -0
- package/routes/economy.js +273 -0
- package/routes/economy.js.map +1 -0
- package/routes/flowback.d.ts +32 -0
- package/routes/flowback.d.ts.map +1 -0
- package/routes/flowback.js +97 -0
- package/routes/flowback.js.map +1 -0
- package/routes/insurance.d.ts +10 -0
- package/routes/insurance.d.ts.map +1 -0
- package/routes/insurance.js +70 -0
- package/routes/insurance.js.map +1 -0
- package/routes/m2m-viewer.js +195 -0
- package/routes/m2m.d.ts +10 -0
- package/routes/m2m.d.ts.map +1 -0
- package/routes/m2m.js +31 -0
- package/routes/m2m.js.map +1 -0
- package/routes/marketplace.d.ts +15 -0
- package/routes/marketplace.d.ts.map +1 -0
- package/routes/marketplace.js +396 -0
- package/routes/marketplace.js.map +1 -0
- package/routes/node-config.d.ts +6 -0
- package/routes/node-config.d.ts.map +1 -0
- package/routes/node-config.js +500 -0
- package/routes/node-config.js.map +1 -0
- package/routes/oauth-revocation.d.ts +42 -0
- package/routes/oauth-revocation.d.ts.map +1 -0
- package/routes/oauth-revocation.js +99 -0
- package/routes/oauth-revocation.js.map +1 -0
- package/routes/oauth.d.ts +17 -0
- package/routes/oauth.d.ts.map +1 -0
- package/routes/oauth.js +700 -0
- package/routes/oauth.js.map +1 -0
- package/routes/onboard.html +352 -0
- package/routes/onboard.js +435 -0
- package/routes/order.d.ts +8 -0
- package/routes/order.d.ts.map +1 -0
- package/routes/order.js +607 -0
- package/routes/order.js.map +1 -0
- package/routes/p2p-api.d.ts +33 -0
- package/routes/p2p-api.d.ts.map +1 -0
- package/routes/p2p-api.js +274 -0
- package/routes/p2p-api.js.map +1 -0
- package/routes/p2p-message.d.ts +20 -0
- package/routes/p2p-message.d.ts.map +1 -0
- package/routes/p2p-message.js +237 -0
- package/routes/p2p-message.js.map +1 -0
- package/routes/peer.d.ts +22 -0
- package/routes/peer.d.ts.map +1 -0
- package/routes/peer.js +220 -0
- package/routes/peer.js.map +1 -0
- package/routes/plugins.d.ts +4 -0
- package/routes/plugins.d.ts.map +1 -0
- package/routes/plugins.js +138 -0
- package/routes/plugins.js.map +1 -0
- package/routes/port-manager.d.ts +6 -0
- package/routes/port-manager.d.ts.map +1 -0
- package/routes/port-manager.js +212 -0
- package/routes/port-manager.js.map +1 -0
- package/routes/relationship.d.ts +7 -0
- package/routes/relationship.d.ts.map +1 -0
- package/routes/relationship.js +314 -0
- package/routes/relationship.js.map +1 -0
- package/routes/relay.d.ts +3 -0
- package/routes/relay.d.ts.map +1 -0
- package/routes/relay.js +182 -0
- package/routes/relay.js.map +1 -0
- package/routes/reputation.d.ts +10 -0
- package/routes/reputation.d.ts.map +1 -0
- package/routes/reputation.js +141 -0
- package/routes/reputation.js.map +1 -0
- package/routes/reward.d.ts +3 -0
- package/routes/reward.d.ts.map +1 -0
- package/routes/reward.js +130 -0
- package/routes/reward.js.map +1 -0
- package/routes/security-monitoring.d.ts +12 -0
- package/routes/security-monitoring.d.ts.map +1 -0
- package/routes/security-monitoring.js +373 -0
- package/routes/security-monitoring.js.map +1 -0
- package/routes/shop.d.ts +8 -0
- package/routes/shop.d.ts.map +1 -0
- package/routes/shop.js +164 -0
- package/routes/shop.js.map +1 -0
- package/routes/social.d.ts +22 -0
- package/routes/social.d.ts.map +1 -0
- package/routes/social.js +95 -0
- package/routes/social.js.map +1 -0
- package/routes/subchain.d.ts +18 -0
- package/routes/subchain.d.ts.map +1 -0
- package/routes/subchain.js +106 -0
- package/routes/subchain.js.map +1 -0
- package/routes/trustcoin.d.ts +17 -0
- package/routes/trustcoin.d.ts.map +1 -0
- package/routes/trustcoin.js +149 -0
- package/routes/trustcoin.js.map +1 -0
- package/routes/twofa.d.ts +7 -0
- package/routes/twofa.d.ts.map +1 -0
- package/routes/twofa.js +105 -0
- package/routes/twofa.js.map +1 -0
- package/routes/verification.d.ts +8 -0
- package/routes/verification.d.ts.map +1 -0
- package/routes/verification.js +234 -0
- package/routes/verification.js.map +1 -0
- package/routes/wallet.d.ts +4 -0
- package/routes/wallet.d.ts.map +1 -0
- package/routes/wallet.js +770 -0
- package/routes/wallet.js.map +1 -0
- package/run-auth.d.ts +8 -0
- package/run-auth.d.ts.map +1 -0
- package/run-auth.js +82 -0
- package/run-auth.js.map +1 -0
- package/run-p2p-message.d.ts +8 -0
- package/run-p2p-message.d.ts.map +1 -0
- package/run-p2p-message.js +82 -0
- package/run-p2p-message.js.map +1 -0
- package/run-relationship.d.ts +12 -0
- package/run-relationship.d.ts.map +1 -0
- package/run-relationship.js +182 -0
- package/run-relationship.js.map +1 -0
- package/run-unified.d.ts +13 -0
- package/run-unified.d.ts.map +1 -0
- package/run-unified.js +1067 -0
- package/run-unified.js.map +1 -0
- package/run.d.ts +12 -0
- package/run.d.ts.map +1 -0
- package/run.js +889 -0
- package/run.js.map +1 -0
- package/search/ranking.d.ts +55 -0
- package/search/ranking.d.ts.map +1 -0
- package/search/ranking.js +67 -0
- package/search/ranking.js.map +1 -0
- package/shipping/base.d.ts +15 -0
- package/shipping/base.d.ts.map +1 -0
- package/shipping/base.js +39 -0
- package/shipping/base.js.map +1 -0
- package/shipping/index.d.ts +19 -0
- package/shipping/index.d.ts.map +1 -0
- package/shipping/index.js +72 -0
- package/shipping/index.js.map +1 -0
- package/shipping/sf-express/index.d.ts +23 -0
- package/shipping/sf-express/index.d.ts.map +1 -0
- package/shipping/sf-express/index.js +71 -0
- package/shipping/sf-express/index.js.map +1 -0
- package/shipping/template/index.d.ts +20 -0
- package/shipping/template/index.d.ts.map +1 -0
- package/shipping/template/index.js +74 -0
- package/shipping/template/index.js.map +1 -0
- package/shipping/types.d.ts +71 -0
- package/shipping/types.d.ts.map +1 -0
- package/shipping/types.js +6 -0
- package/shipping/types.js.map +1 -0
- package/shipping/virtual/index.d.ts +19 -0
- package/shipping/virtual/index.d.ts.map +1 -0
- package/shipping/virtual/index.js +54 -0
- package/shipping/virtual/index.js.map +1 -0
- package/shipping/yto/index.d.ts +18 -0
- package/shipping/yto/index.d.ts.map +1 -0
- package/shipping/yto/index.js +59 -0
- package/shipping/yto/index.js.map +1 -0
- package/shipping/zto/index.d.ts +18 -0
- package/shipping/zto/index.d.ts.map +1 -0
- package/shipping/zto/index.js +59 -0
- package/shipping/zto/index.js.map +1 -0
- package/skills-lock.json +11 -0
- package/src/db/email-migrations.sql +31 -0
- package/src/db/oauth-migrations.sql +92 -0
- package/src/db/social-migrations.sql +94 -0
- package/src/db/store-migrations.sql +242 -0
- package/test-api-key-revoke.js +167 -0
- package/test-auth-register-ratelimit.js +132 -0
- package/test-auth-tv2.d.ts +2 -0
- package/test-auth-tv2.d.ts.map +1 -0
- package/test-auth-tv2.js +174 -0
- package/test-auth-tv2.js.map +1 -0
- package/test-canonsign-cross.d.ts +2 -0
- package/test-canonsign-cross.d.ts.map +1 -0
- package/test-canonsign-cross.js +32 -0
- package/test-canonsign-cross.js.map +1 -0
- package/test-chain-signer.js +127 -0
- package/test-env-truthy.js +50 -0
- package/test-onboard-contract.js +94 -0
- package/test-ops-console-boundary.js +147 -0
- package/test-oracle-glue.js +232 -0
- package/test-order-create-v394.js +358 -0
- package/test-order-intent.js +245 -0
- package/test-order-lifecycle-v394.js +528 -0
- package/test-p2p-message.d.ts +13 -0
- package/test-p2p-message.d.ts.map +1 -0
- package/test-p2p-message.js +106 -0
- package/test-p2p-message.js.map +1 -0
- package/test-relationship-chain.d.ts +13 -0
- package/test-relationship-chain.d.ts.map +1 -0
- package/test-relationship-chain.js +103 -0
- package/test-relationship-chain.js.map +1 -0
- package/test-runtime-data-path.js +217 -0
- package/test-seller-identity.js +74 -0
- package/test-signing-paths.js +104 -0
- package/test-token-v2.d.ts +2 -0
- package/test-token-v2.d.ts.map +1 -0
- package/test-token-v2.js +172 -0
- package/test-token-v2.js.map +1 -0
- package/test-wallet-auth-nonce.d.ts +12 -0
- package/test-wallet-auth-nonce.d.ts.map +1 -0
- package/test-wallet-auth-nonce.js +126 -0
- package/test-wallet-auth-nonce.js.map +1 -0
- package/test-wallet-submatch.d.ts +13 -0
- package/test-wallet-submatch.d.ts.map +1 -0
- package/test-wallet-submatch.js +86 -0
- package/test-wallet-submatch.js.map +1 -0
- package/tls/self-signed.d.ts +12 -0
- package/tls/self-signed.d.ts.map +1 -0
- package/tls/self-signed.js +63 -0
- package/tls/self-signed.js.map +1 -0
- package/tools/brand.d.ts +11 -0
- package/tools/brand.d.ts.map +1 -0
- package/tools/brand.js +75 -0
- package/tools/brand.js.map +1 -0
- package/tools/chainregistry.d.ts +18 -0
- package/tools/chainregistry.d.ts.map +1 -0
- package/tools/chainregistry.js +175 -0
- package/tools/chainregistry.js.map +1 -0
- package/tools/compliance.d.ts +14 -0
- package/tools/compliance.d.ts.map +1 -0
- package/tools/compliance.js +45 -0
- package/tools/compliance.js.map +1 -0
- package/tools/council.d.ts +17 -0
- package/tools/council.d.ts.map +1 -0
- package/tools/council.js +75 -0
- package/tools/council.js.map +1 -0
- package/tools/device.d.ts +13 -0
- package/tools/device.d.ts.map +1 -0
- package/tools/device.js +45 -0
- package/tools/device.js.map +1 -0
- package/tools/devreward.d.ts +15 -0
- package/tools/devreward.d.ts.map +1 -0
- package/tools/devreward.js +190 -0
- package/tools/devreward.js.map +1 -0
- package/tools/economy.d.ts +14 -0
- package/tools/economy.d.ts.map +1 -0
- package/tools/economy.js +172 -0
- package/tools/economy.js.map +1 -0
- package/tools/flowback.d.ts +14 -0
- package/tools/flowback.d.ts.map +1 -0
- package/tools/flowback.js +146 -0
- package/tools/flowback.js.map +1 -0
- package/tools/insurance.d.ts +13 -0
- package/tools/insurance.d.ts.map +1 -0
- package/tools/insurance.js +45 -0
- package/tools/insurance.js.map +1 -0
- package/tools/marketplace.d.ts +12 -0
- package/tools/marketplace.d.ts.map +1 -0
- package/tools/marketplace.js +124 -0
- package/tools/marketplace.js.map +1 -0
- package/tools/order.d.ts +12 -0
- package/tools/order.d.ts.map +1 -0
- package/tools/order.js +94 -0
- package/tools/order.js.map +1 -0
- package/tools/recovery.d.ts +14 -0
- package/tools/recovery.d.ts.map +1 -0
- package/tools/recovery.js +158 -0
- package/tools/recovery.js.map +1 -0
- package/tools/relay.d.ts +15 -0
- package/tools/relay.d.ts.map +1 -0
- package/tools/relay.js +152 -0
- package/tools/relay.js.map +1 -0
- package/tools/reputation.d.ts +20 -0
- package/tools/reputation.d.ts.map +1 -0
- package/tools/reputation.js +50 -0
- package/tools/reputation.js.map +1 -0
- package/tools/reputation_seller_credit.d.ts +16 -0
- package/tools/reputation_seller_credit.d.ts.map +1 -0
- package/tools/reputation_seller_credit.js +106 -0
- package/tools/reputation_seller_credit.js.map +1 -0
- package/tools/reward.d.ts +14 -0
- package/tools/reward.d.ts.map +1 -0
- package/tools/reward.js +76 -0
- package/tools/reward.js.map +1 -0
- package/tools/shop.d.ts +14 -0
- package/tools/shop.d.ts.map +1 -0
- package/tools/shop.js +95 -0
- package/tools/shop.js.map +1 -0
- package/tools/verification.d.ts +12 -0
- package/tools/verification.d.ts.map +1 -0
- package/tools/verification.js +89 -0
- package/tools/verification.js.map +1 -0
- package/types/store.d.ts +255 -0
- package/types/store.d.ts.map +1 -0
- package/types/store.js +19 -0
- package/types/store.js.map +1 -0
- package/utils/aes-gcm.d.ts +63 -0
- package/utils/aes-gcm.d.ts.map +1 -0
- package/utils/aes-gcm.js +179 -0
- package/utils/aes-gcm.js.map +1 -0
- package/utils/api-response.d.ts +51 -0
- package/utils/api-response.d.ts.map +1 -0
- package/utils/api-response.js +65 -0
- package/utils/api-response.js.map +1 -0
- package/utils/base32.d.ts +5 -0
- package/utils/base32.d.ts.map +1 -0
- package/utils/base32.js +20 -0
- package/utils/base32.js.map +1 -0
- package/utils/crypto.d.ts +77 -0
- package/utils/crypto.d.ts.map +1 -0
- package/utils/crypto.js +164 -0
- package/utils/crypto.js.map +1 -0
- package/utils/encryption.d.ts +81 -0
- package/utils/encryption.d.ts.map +1 -0
- package/utils/encryption.js +247 -0
- package/utils/encryption.js.map +1 -0
- package/utils/env.js +20 -0
- package/utils/jwt.d.ts +110 -0
- package/utils/jwt.d.ts.map +1 -0
- package/utils/jwt.js +275 -0
- package/utils/jwt.js.map +1 -0
- package/utils/qrcode-reader.d.ts +22 -0
- package/utils/qrcode-reader.d.ts.map +1 -0
- package/utils/qrcode-reader.js +90 -0
- package/utils/qrcode-reader.js.map +1 -0
- package/utils/qrcode.d.ts +26 -0
- package/utils/qrcode.d.ts.map +1 -0
- package/utils/qrcode.js +92 -0
- package/utils/qrcode.js.map +1 -0
- package/utils/totp.d.ts +3 -0
- package/utils/totp.d.ts.map +1 -0
- package/utils/totp.js +58 -0
- package/utils/totp.js.map +1 -0
- package/utils/two-factor-auth.d.ts +16 -0
- package/utils/two-factor-auth.d.ts.map +1 -0
- package/utils/two-factor-auth.js +150 -0
- package/utils/two-factor-auth.js.map +1 -0
- package/verifyer/hsm.d.ts +70 -0
- package/verifyer/hsm.d.ts.map +1 -0
- package/verifyer/hsm.js +482 -0
- package/verifyer/hsm.js.map +1 -0
- package/verifyer/index.d.ts +81 -0
- package/verifyer/index.d.ts.map +1 -0
- package/verifyer/index.js +372 -0
- package/verifyer/index.js.map +1 -0
- package/ws/peer-monitor-broadcaster.d.ts +24 -0
- package/ws/peer-monitor-broadcaster.d.ts.map +1 -0
- package/ws/peer-monitor-broadcaster.js +56 -0
- package/ws/peer-monitor-broadcaster.js.map +1 -0
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* TrustChain Distributed Indexer
|
|
4
|
+
*
|
|
5
|
+
* 分布式索引架构
|
|
6
|
+
* 目标:并发能力从100/s → 1000/s
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.DistributedIndexer = exports.ShardStrategy = exports.DEFAULT_DISTRIBUTED_CONFIG = void 0;
|
|
10
|
+
const events_1 = require("events");
|
|
11
|
+
exports.DEFAULT_DISTRIBUTED_CONFIG = {
|
|
12
|
+
shards: [],
|
|
13
|
+
replicationFactor: 2,
|
|
14
|
+
queryTimeout: 5000,
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* 分片策略
|
|
18
|
+
*/
|
|
19
|
+
class ShardStrategy {
|
|
20
|
+
/**
|
|
21
|
+
* 根据SKU ID计算分片
|
|
22
|
+
*/
|
|
23
|
+
static getShardForProduct(skuId, totalShards) {
|
|
24
|
+
// 使用SKU ID的哈希值进行分片
|
|
25
|
+
const hash = this.hashString(skuId);
|
|
26
|
+
return hash % totalShards;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 根据卖家地址计算分片
|
|
30
|
+
*/
|
|
31
|
+
static getShardForSeller(address, totalShards) {
|
|
32
|
+
const hash = this.hashString(address);
|
|
33
|
+
return hash % totalShards;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 字符串哈希
|
|
37
|
+
*/
|
|
38
|
+
static hashString(str) {
|
|
39
|
+
let hash = 0;
|
|
40
|
+
for (let i = 0; i < str.length; i++) {
|
|
41
|
+
const char = str.charCodeAt(i);
|
|
42
|
+
hash = ((hash << 5) - hash) + char;
|
|
43
|
+
hash = hash & hash; // Convert to 32bit integer
|
|
44
|
+
}
|
|
45
|
+
return Math.abs(hash);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.ShardStrategy = ShardStrategy;
|
|
49
|
+
/**
|
|
50
|
+
* 分布式索引器
|
|
51
|
+
*/
|
|
52
|
+
class DistributedIndexer extends events_1.EventEmitter {
|
|
53
|
+
name = 'distributed-indexer';
|
|
54
|
+
displayName = 'Distributed Indexer';
|
|
55
|
+
tier = 3;
|
|
56
|
+
maxCapacity = 1000000;
|
|
57
|
+
config;
|
|
58
|
+
shards = new Map();
|
|
59
|
+
localIndexer;
|
|
60
|
+
constructor(config = exports.DEFAULT_DISTRIBUTED_CONFIG) {
|
|
61
|
+
super();
|
|
62
|
+
this.config = config;
|
|
63
|
+
// 初始化分片
|
|
64
|
+
for (const shard of config.shards) {
|
|
65
|
+
this.shards.set(shard.id, shard);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 设置本地索引器
|
|
70
|
+
*/
|
|
71
|
+
setLocalIndexer(indexer) {
|
|
72
|
+
this.localIndexer = indexer;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 启动分布式索引器
|
|
76
|
+
*/
|
|
77
|
+
async start() {
|
|
78
|
+
console.log('[Distributed] Starting distributed indexer');
|
|
79
|
+
console.log(`[Distributed] Shards: ${this.shards.size}`);
|
|
80
|
+
// 检查所有分片状态
|
|
81
|
+
await this.checkShardsHealth();
|
|
82
|
+
console.log('[Distributed] Started successfully');
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 停止分布式索引器
|
|
86
|
+
*/
|
|
87
|
+
async stop() {
|
|
88
|
+
console.log('[Distributed] Stopped');
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 检查分片健康状态
|
|
92
|
+
*/
|
|
93
|
+
async checkShardsHealth() {
|
|
94
|
+
for (const [id, shard] of this.shards) {
|
|
95
|
+
try {
|
|
96
|
+
const response = await fetch(`${shard.node}/health`, {
|
|
97
|
+
method: 'GET',
|
|
98
|
+
});
|
|
99
|
+
shard.status = response.ok ? 'active' : 'inactive';
|
|
100
|
+
console.log(`[Distributed] Shard ${id}: ${shard.status}`);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
shard.status = 'inactive';
|
|
104
|
+
console.error(`[Distributed] Shard ${id} health check failed: ${error.message}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 分布式搜索
|
|
110
|
+
*/
|
|
111
|
+
async search(query) {
|
|
112
|
+
const startTime = Date.now();
|
|
113
|
+
// 获取活跃的分片
|
|
114
|
+
const activeShards = Array.from(this.shards.values())
|
|
115
|
+
.filter(s => s.status === 'active');
|
|
116
|
+
if (activeShards.length === 0) {
|
|
117
|
+
console.warn('[Distributed] No active shards available, using local indexer');
|
|
118
|
+
if (this.localIndexer) {
|
|
119
|
+
return this.localIndexer.search(query);
|
|
120
|
+
}
|
|
121
|
+
return { total: 0, results: [], meta: { queryTimeMs: 0, indexerName: 'distributed-indexer', coverage: 'none' } };
|
|
122
|
+
}
|
|
123
|
+
// 并行查询所有分片
|
|
124
|
+
const queryPromises = activeShards.map(shard => this.queryShard(shard, query));
|
|
125
|
+
try {
|
|
126
|
+
// 等待所有查询完成(带超时)
|
|
127
|
+
const results = await Promise.allSettled(queryPromises.map(p => this.withTimeout(p, this.config.queryTimeout)));
|
|
128
|
+
// 合并结果
|
|
129
|
+
return this.mergeResults(results, startTime);
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
console.error(`[Distributed] Search failed: ${error.message}`);
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* 查询单个分片
|
|
138
|
+
*/
|
|
139
|
+
async queryShard(shard, query) {
|
|
140
|
+
const response = await fetch(`${shard.node}/api/search`, {
|
|
141
|
+
method: 'POST',
|
|
142
|
+
headers: { 'Content-Type': 'application/json' },
|
|
143
|
+
body: JSON.stringify(query),
|
|
144
|
+
});
|
|
145
|
+
if (!response.ok) {
|
|
146
|
+
throw new Error(`Shard ${shard.id} query failed: ${response.status}`);
|
|
147
|
+
}
|
|
148
|
+
return await response.json();
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* 合并搜索结果
|
|
152
|
+
*/
|
|
153
|
+
mergeResults(results, startTime) {
|
|
154
|
+
const mergedResults = [];
|
|
155
|
+
let totalCount = 0;
|
|
156
|
+
for (const result of results) {
|
|
157
|
+
if (result.status === 'fulfilled') {
|
|
158
|
+
mergedResults.push(...result.value.results);
|
|
159
|
+
totalCount += result.value.total;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// 按TrustScore排序
|
|
163
|
+
mergedResults.sort((a, b) => (b.trustScore || 0) - (a.trustScore || 0));
|
|
164
|
+
const latency = Date.now() - startTime;
|
|
165
|
+
return {
|
|
166
|
+
total: totalCount,
|
|
167
|
+
results: mergedResults,
|
|
168
|
+
meta: {
|
|
169
|
+
queryTimeMs: latency,
|
|
170
|
+
indexerName: 'distributed-indexer',
|
|
171
|
+
coverage: 'distributed',
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* 带超时的Promise
|
|
177
|
+
*/
|
|
178
|
+
withTimeout(promise, timeoutMs) {
|
|
179
|
+
return Promise.race([
|
|
180
|
+
promise,
|
|
181
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error('Query timeout')), timeoutMs)),
|
|
182
|
+
]);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* 索引商品(路由到对应分片)
|
|
186
|
+
*/
|
|
187
|
+
async indexProduct(product) {
|
|
188
|
+
const shardId = this.getShardIdForProduct(product.skuId);
|
|
189
|
+
const shard = this.shards.get(shardId);
|
|
190
|
+
if (!shard || shard.status === 'inactive') {
|
|
191
|
+
// 使用本地索引器
|
|
192
|
+
if (this.localIndexer) {
|
|
193
|
+
return this.localIndexer.indexProduct(product);
|
|
194
|
+
}
|
|
195
|
+
throw new Error(`No active shard for product ${product.skuId}`);
|
|
196
|
+
}
|
|
197
|
+
// 发送到对应分片
|
|
198
|
+
const response = await fetch(`${shard.node}/api/products`, {
|
|
199
|
+
method: 'POST',
|
|
200
|
+
headers: { 'Content-Type': 'application/json' },
|
|
201
|
+
body: JSON.stringify(product),
|
|
202
|
+
});
|
|
203
|
+
if (!response.ok) {
|
|
204
|
+
throw new Error(`Failed to index product on shard ${shardId}`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* 获取商品对应的分片ID
|
|
209
|
+
*/
|
|
210
|
+
getShardIdForProduct(skuId) {
|
|
211
|
+
const shardIndex = ShardStrategy.getShardForProduct(skuId, this.shards.size);
|
|
212
|
+
const shardArray = Array.from(this.shards.keys());
|
|
213
|
+
return shardArray[shardIndex] || shardArray[0];
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* 更新商品
|
|
217
|
+
*/
|
|
218
|
+
async updateProduct(product) {
|
|
219
|
+
return this.indexProduct(product);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* 删除商品
|
|
223
|
+
*/
|
|
224
|
+
async removeProduct(skuId) {
|
|
225
|
+
const shardId = this.getShardIdForProduct(skuId);
|
|
226
|
+
const shard = this.shards.get(shardId);
|
|
227
|
+
if (!shard || shard.status === 'inactive') {
|
|
228
|
+
if (this.localIndexer) {
|
|
229
|
+
return this.localIndexer.removeProduct(skuId);
|
|
230
|
+
}
|
|
231
|
+
throw new Error(`No active shard for product ${skuId}`);
|
|
232
|
+
}
|
|
233
|
+
const response = await fetch(`${shard.node}/api/products/${skuId}`, {
|
|
234
|
+
method: 'DELETE',
|
|
235
|
+
});
|
|
236
|
+
if (!response.ok) {
|
|
237
|
+
throw new Error(`Failed to remove product on shard ${shardId}`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* 索引卖家
|
|
242
|
+
*/
|
|
243
|
+
async indexSeller(seller) {
|
|
244
|
+
if (this.localIndexer) {
|
|
245
|
+
return this.localIndexer.indexSeller(seller);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* 更新卖家
|
|
250
|
+
*/
|
|
251
|
+
async updateSeller(seller) {
|
|
252
|
+
return this.indexSeller(seller);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* 索引评价
|
|
256
|
+
*/
|
|
257
|
+
async indexReview(review) {
|
|
258
|
+
if (this.localIndexer) {
|
|
259
|
+
return this.localIndexer.indexReview(review);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* 获取评价列表
|
|
264
|
+
*/
|
|
265
|
+
async getReviews(address, limit, offset) {
|
|
266
|
+
if (this.localIndexer) {
|
|
267
|
+
return this.localIndexer.getReviews(address, limit, offset);
|
|
268
|
+
}
|
|
269
|
+
return [];
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* 提交评价(写入本地)
|
|
273
|
+
*/
|
|
274
|
+
async addReview(review) {
|
|
275
|
+
if (this.localIndexer) {
|
|
276
|
+
return this.localIndexer.addReview(review);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* 索引订单
|
|
281
|
+
*/
|
|
282
|
+
async indexOrder(order) {
|
|
283
|
+
if (this.localIndexer) {
|
|
284
|
+
return this.localIndexer.indexOrder(order);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* 获取卖家信息
|
|
289
|
+
*/
|
|
290
|
+
async getSeller(address) {
|
|
291
|
+
if (this.localIndexer) {
|
|
292
|
+
return this.localIndexer.getSeller(address);
|
|
293
|
+
}
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* 获取商品信息
|
|
298
|
+
*/
|
|
299
|
+
async getProduct(skuId) {
|
|
300
|
+
const shardId = this.getShardIdForProduct(skuId);
|
|
301
|
+
const shard = this.shards.get(shardId);
|
|
302
|
+
if (!shard || shard.status === 'inactive') {
|
|
303
|
+
if (this.localIndexer) {
|
|
304
|
+
return this.localIndexer.getProduct(skuId);
|
|
305
|
+
}
|
|
306
|
+
return null;
|
|
307
|
+
}
|
|
308
|
+
const response = await fetch(`${shard.node}/api/products/${skuId}`);
|
|
309
|
+
if (!response.ok) {
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
return await response.json();
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* 获取统计信息
|
|
316
|
+
*/
|
|
317
|
+
async getStats() {
|
|
318
|
+
// 聚合所有分片的统计信息
|
|
319
|
+
const shardStats = await Promise.all(Array.from(this.shards.values())
|
|
320
|
+
.filter(s => s.status === 'active')
|
|
321
|
+
.map(shard => this.getShardStats(shard)));
|
|
322
|
+
// 合并统计信息
|
|
323
|
+
return this.aggregateStats(shardStats);
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* 获取分片统计信息
|
|
327
|
+
*/
|
|
328
|
+
async getShardStats(shard) {
|
|
329
|
+
try {
|
|
330
|
+
const response = await fetch(`${shard.node}/api/stats`);
|
|
331
|
+
return await response.json();
|
|
332
|
+
}
|
|
333
|
+
catch (error) {
|
|
334
|
+
return {
|
|
335
|
+
totalProducts: 0,
|
|
336
|
+
totalSellers: 0,
|
|
337
|
+
totalReviews: 0,
|
|
338
|
+
totalOrders: 0,
|
|
339
|
+
syncedHeight: 0,
|
|
340
|
+
indexerTier: 3,
|
|
341
|
+
dbSizeBytes: 0,
|
|
342
|
+
uptimeSeconds: 0,
|
|
343
|
+
queriesPerSecond: 0,
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* 聚合统计信息
|
|
349
|
+
*/
|
|
350
|
+
aggregateStats(stats) {
|
|
351
|
+
return {
|
|
352
|
+
totalProducts: stats.reduce((sum, s) => sum + s.totalProducts, 0),
|
|
353
|
+
totalSellers: stats.reduce((sum, s) => sum + s.totalSellers, 0),
|
|
354
|
+
totalReviews: stats.reduce((sum, s) => sum + s.totalReviews, 0),
|
|
355
|
+
totalOrders: stats.reduce((sum, s) => sum + s.totalOrders, 0),
|
|
356
|
+
syncedHeight: Math.max(...stats.map(s => s.syncedHeight)),
|
|
357
|
+
indexerTier: 3,
|
|
358
|
+
dbSizeBytes: stats.reduce((sum, s) => sum + s.dbSizeBytes, 0),
|
|
359
|
+
uptimeSeconds: Math.max(...stats.map(s => s.uptimeSeconds)),
|
|
360
|
+
queriesPerSecond: stats.reduce((sum, s) => sum + s.queriesPerSecond, 0),
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* 获取同步高度
|
|
365
|
+
*/
|
|
366
|
+
getSyncHeight() {
|
|
367
|
+
if (this.localIndexer) {
|
|
368
|
+
return this.localIndexer.getSyncHeight();
|
|
369
|
+
}
|
|
370
|
+
return 0;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* 同步区块事件
|
|
374
|
+
*/
|
|
375
|
+
async syncFromBlock(height, events) {
|
|
376
|
+
if (this.localIndexer) {
|
|
377
|
+
return this.localIndexer.syncFromBlock(height, events);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* 初始化
|
|
382
|
+
*/
|
|
383
|
+
async init() {
|
|
384
|
+
console.log('[Distributed] Initialized');
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* 销毁
|
|
388
|
+
*/
|
|
389
|
+
async destroy() {
|
|
390
|
+
console.log('[Distributed] Destroyed');
|
|
391
|
+
}
|
|
392
|
+
async clearAll() {
|
|
393
|
+
if (this.localIndexer && typeof this.localIndexer.clearAll === 'function') {
|
|
394
|
+
await this.localIndexer.clearAll();
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* 获取分布式状态
|
|
399
|
+
*/
|
|
400
|
+
getDistributedStatus() {
|
|
401
|
+
return {
|
|
402
|
+
shards: Array.from(this.shards.values()),
|
|
403
|
+
activeShards: Array.from(this.shards.values()).filter(s => s.status === 'active').length,
|
|
404
|
+
totalShards: this.shards.size,
|
|
405
|
+
replicationFactor: this.config.replicationFactor,
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* 处理查询(IndexerPlugin接口)
|
|
410
|
+
*/
|
|
411
|
+
async handleQuery(query) {
|
|
412
|
+
return this.search(query);
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* 获取状态(IndexerPlugin接口)
|
|
416
|
+
*/
|
|
417
|
+
getStatus() {
|
|
418
|
+
return this.getDistributedStatus();
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
exports.DistributedIndexer = DistributedIndexer;
|
|
422
|
+
//# sourceMappingURL=distributed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distributed.js","sourceRoot":"","sources":["../../src/core/distributed.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,mCAAsC;AAgBzB,QAAA,0BAA0B,GAA6B;IAClE,MAAM,EAAE,EAAE;IACV,iBAAiB,EAAE,CAAC;IACpB,YAAY,EAAE,IAAI;CACnB,CAAC;AAEF;;GAEG;AACH,MAAa,aAAa;IACxB;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,KAAa,EAAE,WAAmB;QAC1D,mBAAmB;QACnB,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACpC,OAAO,IAAI,GAAG,WAAW,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAC,OAAe,EAAE,WAAmB;QAC3D,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACtC,OAAO,IAAI,GAAG,WAAW,CAAC;IAC5B,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,UAAU,CAAC,GAAW;QACnC,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACpC,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC/B,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;YACnC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,2BAA2B;QACjD,CAAC;QACD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;CACF;AA9BD,sCA8BC;AAED;;G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;IACH,KAAK,CAAC,IAAI;QACR,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,IAAI,IAAI,CAAC,YAAY,IAAI,OAAQ,IAAI,CAAC,YAAoB,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC;YACnF,MAAO,IAAI,CAAC,YAAoB,CAAC,QAAQ,EAAE,CAAC;QAC9C,CAAC;IACH,CAAC;IAED;;OAEG;IACH,oBAAoB;QAClB,OAAO;YACL,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACxC,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,MAAM;YACxF,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;YAC7B,iBAAiB,EAAE,IAAI,CAAC,MAAM,CAAC,iBAAiB;SACjD,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,KAAkB;QAClC,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,oBAAoB,EAAE,CAAC;IACrC,CAAC;CACF;AA9aD,gDA8aC"}
|
package/core/doctor.js
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* doctor.js — 卖家后端启动自检 (人可读报告)
|
|
4
|
+
*
|
|
5
|
+
* 覆盖: base/keyring 解析结果 → 目录与身份文件 → JS 派生地址 vs CLI keyring 地址 (身份分裂)
|
|
6
|
+
* → 签名通道现状 (js/trustchaind) → LCD 可达性 → 卖家地址链上账户 (account_number/sequence)
|
|
7
|
+
*
|
|
8
|
+
* 入口: `tb-seller-doctor` / `tb-seller-backend doctor` / `node bin/tb-doctor.js`
|
|
9
|
+
* 只读: 不写密钥, 不广播交易, 不打印助记词 (只报"存在/词数")。
|
|
10
|
+
*/
|
|
11
|
+
const fs = require("fs");
|
|
12
|
+
const path = require("path");
|
|
13
|
+
const paths = require("./paths");
|
|
14
|
+
const runtimeData = require("./runtime-data");
|
|
15
|
+
const chainWrites = require("../routes/chain-writes");
|
|
16
|
+
const { mnemonicToAddress } = require("./seller-identity");
|
|
17
|
+
const { isTctAddress } = require("./address");
|
|
18
|
+
|
|
19
|
+
const PASS = "PASS";
|
|
20
|
+
const WARN = "WARN";
|
|
21
|
+
const FAIL = "FAIL";
|
|
22
|
+
|
|
23
|
+
function fmtTime(d = new Date()) {
|
|
24
|
+
const p = (n) => String(n).padStart(2, "0");
|
|
25
|
+
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function timed(fn) {
|
|
29
|
+
const t0 = Date.now();
|
|
30
|
+
try {
|
|
31
|
+
const value = await fn();
|
|
32
|
+
return { ok: true, value, ms: Date.now() - t0 };
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
return { ok: false, error: e, ms: Date.now() - t0 };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function lcdGet(url, timeoutMs = 6000) {
|
|
40
|
+
const resp = await fetch(url, { signal: AbortSignal.timeout(timeoutMs) });
|
|
41
|
+
if (!resp.ok)
|
|
42
|
+
throw new Error(`HTTP ${resp.status}`);
|
|
43
|
+
return await resp.json();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 跑一遍自检。返回 { ok, checks, text, json }
|
|
48
|
+
* ok=false 表示有 FAIL 项 (WARN 不算失败)。
|
|
49
|
+
*/
|
|
50
|
+
async function runDoctor() {
|
|
51
|
+
const checks = [];
|
|
52
|
+
const add = (level, name, detail) => checks.push({ level, name, detail });
|
|
53
|
+
|
|
54
|
+
const b = paths.base();
|
|
55
|
+
const keyring = paths.keyringDir();
|
|
56
|
+
const mnemonicFile = paths.mnemonicFile();
|
|
57
|
+
const addressFile = paths.addressFile();
|
|
58
|
+
|
|
59
|
+
// ---------- 路径 ----------
|
|
60
|
+
add(fs.existsSync(b.baseDir) ? PASS : FAIL, "base 目录", `${b.baseDir} (来源: ${b.source})`);
|
|
61
|
+
if (b.cwd !== b.baseDir) {
|
|
62
|
+
add(PASS, "进程 cwd", `${b.cwd} (与 base 不同 — 所有路径已按绝对路径解析, 不受 cwd 影响)`);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
add(PASS, "进程 cwd", `${b.cwd} (与 base 一致)`);
|
|
66
|
+
}
|
|
67
|
+
if (fs.existsSync(keyring)) {
|
|
68
|
+
let writable = true;
|
|
69
|
+
try {
|
|
70
|
+
fs.accessSync(keyring, fs.constants.W_OK);
|
|
71
|
+
}
|
|
72
|
+
catch (_) {
|
|
73
|
+
writable = false;
|
|
74
|
+
}
|
|
75
|
+
add(writable ? PASS : WARN, "keyring 目录", `${keyring}${writable ? "" : " (当前用户不可写: 入驻生成身份会失败)"}`);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
add(FAIL, "keyring 目录", `${keyring} 不存在 — 先完成入驻 (生成卖家身份) 或检查 TB_BASE_DIR/CHAIN_HOME`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// ---------- 运行时数据目录 (api-keys.json / .encryption-key 等落盘处) ----------
|
|
82
|
+
const rd = runtimeData.runtimeDataInfo();
|
|
83
|
+
let rdWritable = true;
|
|
84
|
+
try {
|
|
85
|
+
fs.accessSync(rd.dir, fs.constants.W_OK);
|
|
86
|
+
}
|
|
87
|
+
catch (_) {
|
|
88
|
+
rdWritable = false;
|
|
89
|
+
}
|
|
90
|
+
const rdLevel = rd.source === "legacy-fallback" ? WARN : PASS;
|
|
91
|
+
const rdNote = rd.source === "legacy-fallback"
|
|
92
|
+
? "⚠️ 仍在旧路径 (node_modules 下, npm 升级会被清掉) — 检查目录权限或显式设 TRUSTBASE_DATA_DIR"
|
|
93
|
+
: "npm 升级不影响 (node_modules 之外); 可用 TRUSTBASE_DATA_DIR 覆盖";
|
|
94
|
+
add(rdLevel, "运行时数据目录", `${rd.dir} (来源: ${rd.source}; ${rdNote})` +
|
|
95
|
+
(rdWritable ? "" : " — 当前用户不可写!") +
|
|
96
|
+
(rd.migration.moved.length ? `; 本次已从旧 node_modules/data 自动搬迁: ${rd.migration.moved.join(", ")}` : ""));
|
|
97
|
+
const legacyKeysLeft = path.join(runtimeData.legacyDataDir(), "api-keys.json");
|
|
98
|
+
if (fs.existsSync(legacyKeysLeft)) {
|
|
99
|
+
add(WARN, "旧数据残留", `${legacyKeysLeft} 仍存在 — 搬迁未完成 (见上行/启动日志), 确认新目录数据完好后可手动删除`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ---------- 身份文件 ----------
|
|
103
|
+
let mnemonic = null;
|
|
104
|
+
if (fs.existsSync(mnemonicFile)) {
|
|
105
|
+
mnemonic = fs.readFileSync(mnemonicFile, "utf8").trim();
|
|
106
|
+
const words = mnemonic ? mnemonic.split(/\s+/).length : 0;
|
|
107
|
+
let mode = "";
|
|
108
|
+
try {
|
|
109
|
+
mode = "0" + (fs.statSync(mnemonicFile).mode & 0o777).toString(8);
|
|
110
|
+
}
|
|
111
|
+
catch (_) { /* ignore */ }
|
|
112
|
+
add(words >= 12 ? PASS : FAIL, "mnemonic.txt", `存在 (${words} 词${mode ? ", 权限 " + mode : ""}; 内容不打印)`);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
add(FAIL, "mnemonic.txt", `${mnemonicFile} 不存在 — JS 直签不可用, SIGN_MODE=auto 会降级 CLI`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
let fileAddress = null;
|
|
119
|
+
if (fs.existsSync(addressFile)) {
|
|
120
|
+
const a = fs.readFileSync(addressFile, "utf8").trim();
|
|
121
|
+
if (isTctAddress(a)) {
|
|
122
|
+
fileAddress = a;
|
|
123
|
+
add(PASS, "address.txt", a);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
add(FAIL, "address.txt", `${addressFile} 内容不是合法 tct1 地址: ${a.slice(0, 40)}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
add(mnemonic ? WARN : FAIL, "address.txt", `${addressFile} 不存在${mnemonic ? " (有助记词, 入驻流程会现算补写)" : ""}`);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// 身份派生 (纯计算, 不写盘)
|
|
134
|
+
const jsAddress = mnemonic ? await mnemonicToAddress(mnemonic).catch((e) => {
|
|
135
|
+
add(FAIL, "身份派生", `助记词派生地址失败: ${e && e.message}`);
|
|
136
|
+
return null;
|
|
137
|
+
}) : null;
|
|
138
|
+
if (jsAddress) {
|
|
139
|
+
if (fileAddress && fileAddress !== jsAddress) {
|
|
140
|
+
add(FAIL, "身份一致性", `address.txt=${fileAddress} 与助记词派生=${jsAddress} 不一致 — address.txt 被改过或被别的助记词覆盖`);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
add(PASS, "身份一致性", `address.txt 与助记词派生一致 (${jsAddress})`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// ---------- 签名通道 ----------
|
|
148
|
+
const c = chainWrites.cfg();
|
|
149
|
+
const mode = chainWrites.signModeInfo(c);
|
|
150
|
+
if (mode.effective === "unavailable") {
|
|
151
|
+
add(FAIL, "签名通道", `SIGN_MODE=${mode.configured} 但 mnemonic.txt 不存在 (JS 直签不可用)`);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
add(PASS, "签名通道", `SIGN_MODE=${mode.configured} → 生效 ${mode.effective} (卖家身份 ${jsAddress || "?"})`);
|
|
155
|
+
}
|
|
156
|
+
add(PASS, "trustchaind --home", c.home + (c.home === keyring ? " (与 tb-keyring 一致)" : " (注意: 与 tb-keyring 不同)"));
|
|
157
|
+
|
|
158
|
+
// CLI keyring 地址 (JS 通道不需要它, 但两者不一致时必须暴露)
|
|
159
|
+
let cliAddress = null;
|
|
160
|
+
let cliError = null;
|
|
161
|
+
const cliProbe = await timed(() => chainWrites.cliKeyAddress(c));
|
|
162
|
+
if (cliProbe.ok) {
|
|
163
|
+
cliAddress = cliProbe.value;
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
cliError = cliProbe.error;
|
|
167
|
+
}
|
|
168
|
+
if (cliAddress && jsAddress && cliAddress !== jsAddress) {
|
|
169
|
+
add(WARN, "⚠️ 身份分裂", `JS 通道 ${jsAddress} / CLI 通道 ${cliAddress} — 链上交易身份以 JS 通道 ${jsAddress} 为准; ` +
|
|
170
|
+
`CLI keyring 里的 "${c.keyName}" (${cliAddress}) 与店铺身份无关, 不要用它的助记词恢复店铺`);
|
|
171
|
+
}
|
|
172
|
+
else if (cliAddress) {
|
|
173
|
+
add(PASS, "CLI keyring", `${c.keyName} → ${cliAddress} (与 JS 通道一致)`);
|
|
174
|
+
}
|
|
175
|
+
else if (mode.effective === "js") {
|
|
176
|
+
add(PASS, "CLI keyring", `未读到 CLI key "${c.keyName}" (JS 直签不需要; 原始错误: ${String((cliError && cliError.message) || cliError).slice(0, 80)})`);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
add(FAIL, "CLI keyring", `CLI 签名通道不可用: keys show "${c.keyName}" --home ${c.home} 失败 (${String((cliError && cliError.message) || cliError).slice(0, 120)})`);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// ---------- 链 ----------
|
|
183
|
+
const net = await timed(() => lcdGet(`${c.lcdUrl}/cosmos/base/tendermint/v1beta1/blocks/latest`));
|
|
184
|
+
if (net.ok) {
|
|
185
|
+
const h = net.value && net.value.block && net.value.block.header && net.value.block.header.height;
|
|
186
|
+
add(PASS, "LCD 可达", `${c.lcdUrl} (${net.ms}ms, 最新高度 ${h || "?"})`);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
add(FAIL, "LCD 可达", `${c.lcdUrl} 不可达: ${String((net.error && net.error.message) || net.error).slice(0, 120)}`);
|
|
190
|
+
}
|
|
191
|
+
const info = await timed(() => lcdGet(`${c.lcdUrl}/cosmos/base/tendermint/v1beta1/node_info`));
|
|
192
|
+
if (info.ok) {
|
|
193
|
+
const network = info.value && info.value.default_node_info && info.value.default_node_info.network;
|
|
194
|
+
if (network && network !== c.chainId) {
|
|
195
|
+
add(WARN, "chain-id", `LCD 报告 network=${network}, 配置 CHAIN_ID=${c.chainId} — 不一致会让交易签名被拒`);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
add(PASS, "chain-id", `${c.chainId}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (jsAddress) {
|
|
203
|
+
const acct = await timed(() => chainWrites.queryAccount(c, jsAddress));
|
|
204
|
+
if (acct.ok) {
|
|
205
|
+
add(PASS, "链上账户", `${jsAddress} account_number=${acct.value.accountNumber} sequence=${acct.value.sequence} (可发起链上交易)`);
|
|
206
|
+
}
|
|
207
|
+
else if (acct.error && acct.error.code === "account_not_found") {
|
|
208
|
+
add(FAIL, "链上账户", `${jsAddress} 尚未在链上创建 (没有手续费/未收到过任何资金) — 发起链上交易会失败, 需先充值少量 TCT 手续费`);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
add(FAIL, "链上账户", `LCD 查账户失败: ${String((acct.error && acct.error.message) || acct.error).slice(0, 120)}`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const failed = checks.filter((x) => x.level === FAIL);
|
|
216
|
+
const warned = checks.filter((x) => x.level === WARN);
|
|
217
|
+
const lines = [];
|
|
218
|
+
lines.push("TrustBase 卖家后端自检 (doctor)");
|
|
219
|
+
lines.push(`时间: ${fmtTime()}`);
|
|
220
|
+
lines.push("");
|
|
221
|
+
for (const ck of checks) {
|
|
222
|
+
const tag = ck.level === PASS ? "[PASS]" : ck.level === WARN ? "[WARN]" : "[FAIL]";
|
|
223
|
+
lines.push(`${tag} ${ck.name}: ${ck.detail}`);
|
|
224
|
+
}
|
|
225
|
+
lines.push("");
|
|
226
|
+
lines.push(`汇总: ${checks.length - failed.length - warned.length} 项通过, ${warned.length} 项警告, ${failed.length} 项失败`);
|
|
227
|
+
if (failed.length) {
|
|
228
|
+
lines.push("");
|
|
229
|
+
lines.push("需要处理:");
|
|
230
|
+
for (const ck of failed)
|
|
231
|
+
lines.push(` - ${ck.name}: ${ck.detail}`);
|
|
232
|
+
}
|
|
233
|
+
const text = lines.join("\n") + "\n";
|
|
234
|
+
return { ok: failed.length === 0, checks, text };
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** 启动日志一行摘要 (run-unified.js 调用; 不查网络, 不抛异常) */
|
|
238
|
+
function bootLine() {
|
|
239
|
+
try {
|
|
240
|
+
const b = paths.base();
|
|
241
|
+
const mode = chainWrites.signModeInfo();
|
|
242
|
+
return `[boot] base=${b.baseDir} (source=${b.source}, cwd=${b.cwd}) keyring=${mode.keyringDir} mnemonic=${mode.mnemonic ? "yes" : "no"} signMode=${mode.effective}`;
|
|
243
|
+
}
|
|
244
|
+
catch (e) {
|
|
245
|
+
return `[boot] 路径解析失败: ${(e && e.message) || e}`;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
module.exports = { runDoctor, bootLine, PASS, WARN, FAIL };
|