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,658 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SequenceMismatchError = exports.HttpError = void 0;
|
|
7
|
+
exports.cfg = cfg;
|
|
8
|
+
exports.assertSafe = assertSafe;
|
|
9
|
+
exports.assertUint = assertUint;
|
|
10
|
+
exports.keyAddress = keyAddress;
|
|
11
|
+
exports.cliKeyAddress = cliKeyAddress;
|
|
12
|
+
exports.effectiveSignMode = effectiveSignMode;
|
|
13
|
+
exports.signModeInfo = signModeInfo;
|
|
14
|
+
exports.queryAccount = queryAccount;
|
|
15
|
+
exports.buildUnsignedTx = buildUnsignedTx;
|
|
16
|
+
exports.signAndBroadcast = signAndBroadcast;
|
|
17
|
+
exports.createChainWritesRouter = createChainWritesRouter;
|
|
18
|
+
exports.handleError = handleError;
|
|
19
|
+
/**
|
|
20
|
+
* chain-writes.ts — 链写入路由 (WooCommerce 插件 → 链上 MsgCreateOrder / MsgConfirmPayment)
|
|
21
|
+
*
|
|
22
|
+
* 背景: trustbase-store 插件 (lib/plugin/chain/hooks-order.php / hooks-payment.php)
|
|
23
|
+
* 会 POST 到卖家后端 /api/orders (下单 PENDING) 和 /api/payments (支付确认 PAID),
|
|
24
|
+
* 这两个端点此前不存在 (.123 实测 404), 本文件补齐。
|
|
25
|
+
*
|
|
26
|
+
* 签名路径 (tx CLI 在线查询路径有 bug, 必须绕, per 2026-09 实战锁版):
|
|
27
|
+
* 1. 手写 unsigned tx JSON (body.messages[0] = MsgXxx, body.memo = 可选意愿 memo,
|
|
28
|
+
* auth_info.fee 给定, signatures: [])
|
|
29
|
+
* 2. trustchaind tx sign <file> --offline --account-number N --sequence M --from <key>
|
|
30
|
+
* 3. trustchaind tx broadcast <signed-file> --node <rpc>
|
|
31
|
+
* 4. account_number/sequence 每次发送前 LCD 现查 (不缓存, 简单可靠);
|
|
32
|
+
* broadcast 报 account sequence mismatch → 重查重试一次。
|
|
33
|
+
*
|
|
34
|
+
* Msg JSON 字段映射 (proto/trustchain/order/v1/tx.proto 核实):
|
|
35
|
+
* - @type = /trustchain.order.v1.MsgCreateOrder / MsgConfirmPayment
|
|
36
|
+
* (proto package trustchain.order.v1; MsgConfirmPayment 的 amino.name
|
|
37
|
+
* trustchain/x/order/MsgConfirmPayment 只用于 amino 编码, proto JSON 用 @type)
|
|
38
|
+
* - JSON 字段名 = proto snake_case 原名 (cosmos jsonpb OrigName=true; uint64 → 字符串)
|
|
39
|
+
*
|
|
40
|
+
* v3.9.4 链侧口径 (方案 A「卖家代建单」, 与链升级同批上线, 详见 /api/orders 注释):
|
|
41
|
+
* - MsgCreateOrder / MsgConfirmOrder / MsgCancelOrder / MsgDisputeOrder 的 **signer = seller**
|
|
42
|
+
* (买家没有签名能力: 不装节点、浏览器不持私钥)
|
|
43
|
+
* - buyer 必须非空 / 合法 bech32 / ≠ seller, 且已注册 trustcoin 账户 (链上校验)
|
|
44
|
+
* - 下单 tx memo = "tb-auth:<sha256(整批订单意愿)>" (64 位小写 hex), 原文落 order_intent_log
|
|
45
|
+
*
|
|
46
|
+
* 支付幂等 (per #376): psp_payment_id 本地 sqlite chain_write_log 先查重,
|
|
47
|
+
* 已处理直接 200 + idempotent_replay=true (链上 PaidPayments 是第二道, 本地先挡)。
|
|
48
|
+
*/
|
|
49
|
+
const express_1 = require("express");
|
|
50
|
+
const child_process_1 = require("child_process");
|
|
51
|
+
const fs_1 = __importDefault(require("fs"));
|
|
52
|
+
const os_1 = __importDefault(require("os"));
|
|
53
|
+
const path_1 = __importDefault(require("path"));
|
|
54
|
+
const chain_signer_1 = require("../core/chain-signer");
|
|
55
|
+
const base_paths = require("../core/paths");
|
|
56
|
+
const orderIntent = require("../core/order-intent");
|
|
57
|
+
const intent_store_1 = require("../core/order-intent-store");
|
|
58
|
+
const chain_reject_1 = require("../core/chain-reject");
|
|
59
|
+
/** 配置全走 env, 每次请求现读 (测试可改 env, 无缓存状态) */
|
|
60
|
+
function cfg() {
|
|
61
|
+
const rpcUrl = process.env.CHAIN_RPC_URL || 'http://localhost:26657';
|
|
62
|
+
return {
|
|
63
|
+
bin: process.env.TRUSTCHAIND_BIN || 'trustchaind',
|
|
64
|
+
keyName: process.env.CHAIN_KEY_NAME || 'seller',
|
|
65
|
+
// 相对 CHAIN_HOME (如安装器写的 ./tb-keyring) 必须按 base 解析成绝对路径:
|
|
66
|
+
// 原样传给 trustchaind --home 时, CLI 按进程 cwd 解析 → cwd 一变就指向
|
|
67
|
+
// /tb-keyring 这种空 keyring, tx sign 直接失败 (2026-09-22 .215 实测故障)。
|
|
68
|
+
home: base_paths.resolveHome(process.env.CHAIN_HOME || '/root/.trustchain'),
|
|
69
|
+
chainId: process.env.CHAIN_ID || 'trustchain-1',
|
|
70
|
+
lcdUrl: process.env.CHAIN_LCD_URL || rpcUrl.replace(':26657', ':1317'),
|
|
71
|
+
rpcUrl,
|
|
72
|
+
feeAmount: process.env.CHAIN_TX_FEE_AMOUNT || '5000',
|
|
73
|
+
feeDenom: process.env.CHAIN_TX_FEE_DENOM || 'utct',
|
|
74
|
+
gasLimit: process.env.CHAIN_TX_GAS || '300000',
|
|
75
|
+
// 1 USD 兑多少 microTCT (price_per_unit 是 microTCT 纯数字串, 插件传的是 USD)
|
|
76
|
+
usdToMicroTct: process.env.CHAIN_USD_TO_MICROTCT_RATE || '1000000',
|
|
77
|
+
// N15 (2026-09-23): 服务商代扣 gas — 非空时商户 tx 的 fee.granter 指向 oracle,
|
|
78
|
+
// 手续费由 feegrant allowance 代付 (AllowedMsgAllowance 白名单+限额在 oracle 侧)。
|
|
79
|
+
// 无 grant/额度尽 → 广播被链拒后自动回退自付 (见 signAndBroadcastInner)。
|
|
80
|
+
feeGranter: (process.env.FEE_GRANTER_ADDR || '').trim(),
|
|
81
|
+
// 签名通道: js (cosmjs 直签) | trustchaind (CLI) | auto (js 优先, 缺助记词/签名失败降级 CLI)
|
|
82
|
+
signMode: (process.env.SIGN_MODE || 'auto').toLowerCase(),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** 白名单字符: 所有进 tx JSON 的 id/地址/金额字段, 防命令注入进链上内容 */
|
|
86
|
+
const SAFE_RE = /^[A-Za-z0-9._-]+$/;
|
|
87
|
+
const NUM_RE = /^\d+$/;
|
|
88
|
+
const EXEC_TIMEOUT_MS = 30_000;
|
|
89
|
+
class HttpError extends Error {
|
|
90
|
+
status;
|
|
91
|
+
code;
|
|
92
|
+
constructor(status, code, message) {
|
|
93
|
+
super(message);
|
|
94
|
+
this.status = status;
|
|
95
|
+
this.code = code;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.HttpError = HttpError;
|
|
99
|
+
function assertSafe(value, name, opts = {}) {
|
|
100
|
+
if (value === undefined || value === null || value === '') {
|
|
101
|
+
if (opts.optional)
|
|
102
|
+
return '';
|
|
103
|
+
throw new HttpError(400, 'invalid_param', `${name} 必填`);
|
|
104
|
+
}
|
|
105
|
+
const s = String(value);
|
|
106
|
+
const re = opts.numeric ? NUM_RE : SAFE_RE;
|
|
107
|
+
if (!re.test(s) || s.length > 128) {
|
|
108
|
+
throw new HttpError(400, 'invalid_param', `${name} 含非法字符 (白名单 [A-Za-z0-9._-])`);
|
|
109
|
+
}
|
|
110
|
+
return s;
|
|
111
|
+
}
|
|
112
|
+
function assertPositiveNumber(value, name) {
|
|
113
|
+
const n = typeof value === 'number' ? value : Number(value);
|
|
114
|
+
if (!Number.isFinite(n) || n <= 0) {
|
|
115
|
+
throw new HttpError(400, 'invalid_param', `${name} 必须是正数`);
|
|
116
|
+
}
|
|
117
|
+
return n;
|
|
118
|
+
}
|
|
119
|
+
function assertUint(value, name, opts = {}) {
|
|
120
|
+
const n = typeof value === 'number' ? value : Number(value);
|
|
121
|
+
const min = opts.min ?? 0;
|
|
122
|
+
if (!Number.isSafeInteger(n) || n < min) {
|
|
123
|
+
throw new HttpError(400, 'invalid_param', `${name} 必须是 >=${min} 的整数`);
|
|
124
|
+
}
|
|
125
|
+
return n;
|
|
126
|
+
}
|
|
127
|
+
function execFileAsync(bin, args) {
|
|
128
|
+
return new Promise((resolve, reject) => {
|
|
129
|
+
(0, child_process_1.execFile)(bin, args, { timeout: EXEC_TIMEOUT_MS }, (err, stdout, stderr) => {
|
|
130
|
+
if (err) {
|
|
131
|
+
err.stdout = stdout;
|
|
132
|
+
err.stderr = stderr;
|
|
133
|
+
return reject(err);
|
|
134
|
+
}
|
|
135
|
+
resolve(stdout);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/** 签名通道判定: js → 助记词必须存在; trustchaind → 恒 CLI; auto → 有助记词走 js, 否则 CLI */
|
|
140
|
+
function effectiveSignMode(c) {
|
|
141
|
+
if (c.signMode === 'js') {
|
|
142
|
+
if (!chain_signer_1.hasMnemonic())
|
|
143
|
+
throw new HttpError(500, 'sign_mode_unavailable', `SIGN_MODE=js 但助记词不存在 (查过 ${chain_signer_1.mnemonicPath()}), 请先完成入驻生成卖家身份`);
|
|
144
|
+
return 'js';
|
|
145
|
+
}
|
|
146
|
+
if (c.signMode === 'trustchaind')
|
|
147
|
+
return 'trustchaind';
|
|
148
|
+
return chain_signer_1.hasMnemonic() ? 'js' : 'trustchaind'; // auto
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* 签名通道现状快照 (启动日志/doctor 用, 不抛异常):
|
|
152
|
+
* { configured, effective: 'js'|'trustchaind'|'unavailable', mnemonic, keyringDir, home, keyName }
|
|
153
|
+
*/
|
|
154
|
+
function signModeInfo(c = cfg()) {
|
|
155
|
+
const mnemonic = chain_signer_1.hasMnemonic();
|
|
156
|
+
let effective;
|
|
157
|
+
if (c.signMode === 'js')
|
|
158
|
+
effective = mnemonic ? 'js' : 'unavailable';
|
|
159
|
+
else if (c.signMode === 'trustchaind')
|
|
160
|
+
effective = 'trustchaind';
|
|
161
|
+
else
|
|
162
|
+
effective = mnemonic ? 'js' : 'trustchaind'; // auto
|
|
163
|
+
return {
|
|
164
|
+
configured: c.signMode,
|
|
165
|
+
effective,
|
|
166
|
+
mnemonic,
|
|
167
|
+
keyringDir: base_paths.keyringDir(),
|
|
168
|
+
home: c.home,
|
|
169
|
+
keyName: c.keyName,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/** trustchaind keys show <key> -a → 签名账户地址 (CLI 通道) */
|
|
173
|
+
async function cliKeyAddress(c) {
|
|
174
|
+
const out = await execFileAsync(c.bin, [
|
|
175
|
+
'keys', 'show', c.keyName, '-a',
|
|
176
|
+
'--keyring-backend', 'test', '--home', c.home,
|
|
177
|
+
]);
|
|
178
|
+
const addr = out.trim();
|
|
179
|
+
if (!SAFE_RE.test(addr))
|
|
180
|
+
throw new Error(`keys show 返回非法地址: ${addr.slice(0, 32)}`);
|
|
181
|
+
return addr;
|
|
182
|
+
}
|
|
183
|
+
/** 签名账户地址: 按签名通道取 (js → tb-keyring 助记词派生; trustchaind → keys show) */
|
|
184
|
+
async function keyAddress(c) {
|
|
185
|
+
if (effectiveSignMode(c) === 'js')
|
|
186
|
+
return chain_signer_1.jsSignerAddress();
|
|
187
|
+
return cliKeyAddress(c);
|
|
188
|
+
}
|
|
189
|
+
/** LCD 现查 account_number + sequence (不缓存; 兼容 base_account 嵌套两种 LCD 形态) */
|
|
190
|
+
async function queryAccount(c, addr) {
|
|
191
|
+
const url = `${c.lcdUrl}/cosmos/auth/v1beta1/accounts/${addr}`;
|
|
192
|
+
const resp = await fetch(url, { signal: AbortSignal.timeout(5000) });
|
|
193
|
+
const data = await resp.json().catch(() => null);
|
|
194
|
+
if (resp.status === 404) {
|
|
195
|
+
// 地址还没上链 (从未收到过任何资金): 这是有意义的业务状态, 不是上游故障。
|
|
196
|
+
// 上层据此给用户可读提示 (发起链上交易需要一点手续费)。
|
|
197
|
+
throw new HttpError(404, 'account_not_found', `地址尚未在链上创建 (没有手续费/未收到过任何资金): ${addr}`);
|
|
198
|
+
}
|
|
199
|
+
if (!resp.ok || !data) {
|
|
200
|
+
throw new HttpError(502, 'lcd_upstream_error', `LCD 查账户失败 status=${resp.status} url=${url}`);
|
|
201
|
+
}
|
|
202
|
+
const acct = data.account?.base_account ?? data.account;
|
|
203
|
+
if (!acct || acct.account_number === undefined || acct.sequence === undefined) {
|
|
204
|
+
throw new HttpError(502, 'lcd_upstream_error', `LCD 账户响应缺 account_number/sequence: ${addr}`);
|
|
205
|
+
}
|
|
206
|
+
return { accountNumber: String(acct.account_number), sequence: String(acct.sequence) };
|
|
207
|
+
}
|
|
208
|
+
/** 手写 unsigned tx JSON (cosmos proto JSON 格式, snake_case 原名 + uint64 字符串)
|
|
209
|
+
* memo: v3.9.4 起下单走 "tb-auth:<sha256(整批订单意愿)>" (见 core/order-intent.js);
|
|
210
|
+
* 其它写路径留空串 —— 链侧只校验以 tb-auth: 开头的 memo。 */
|
|
211
|
+
function buildUnsignedTx(messages, c, memo) {
|
|
212
|
+
return {
|
|
213
|
+
body: {
|
|
214
|
+
messages,
|
|
215
|
+
memo: memo || '',
|
|
216
|
+
timeout_height: '0',
|
|
217
|
+
extension_options: [],
|
|
218
|
+
non_critical_extension_options: [],
|
|
219
|
+
},
|
|
220
|
+
auth_info: {
|
|
221
|
+
signer_infos: [],
|
|
222
|
+
fee: {
|
|
223
|
+
amount: [{ denom: c.feeDenom, amount: c.feeAmount }],
|
|
224
|
+
gas_limit: c.gasLimit,
|
|
225
|
+
payer: '',
|
|
226
|
+
// N15: 服务商代扣 gas (feegrant) — fee.granter 指向 oracle; 空串 = 自付
|
|
227
|
+
granter: c.feeGranter || '',
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
signatures: [],
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
function writeTempJson(prefix, obj) {
|
|
234
|
+
const file = path_1.default.join(os_1.default.tmpdir(), `${prefix}-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}.json`);
|
|
235
|
+
fs_1.default.writeFileSync(file, JSON.stringify(obj));
|
|
236
|
+
return file;
|
|
237
|
+
}
|
|
238
|
+
function cleanup(...files) {
|
|
239
|
+
for (const f of files) {
|
|
240
|
+
if (f)
|
|
241
|
+
fs_1.default.unlink(f, () => { });
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/** offline sign → broadcast; 返回链上结果 (code!=0 也返回, 由调用方判 502) */
|
|
245
|
+
/** 2026-09-20 kimi: 同账户发送串行化 — burst flush 并发 POST 会让多个 tx 带同一
|
|
246
|
+
* sequence 进 mempool, 后续的因冲突被静默逐出 (假成功根源之一)。单进程内
|
|
247
|
+
* promise 链排队, 全部写请求过同一把锁。 */
|
|
248
|
+
let sendQueue = Promise.resolve();
|
|
249
|
+
/** opts: { memo } —— memo 只在整笔 tx 上有一个 (见 buildUnsignedTx 注释) */
|
|
250
|
+
function signAndBroadcast(c, messages, account, opts) {
|
|
251
|
+
const run = () => signAndBroadcastInner(c, messages, account, opts);
|
|
252
|
+
const p = sendQueue.then(run, run);
|
|
253
|
+
sendQueue = p.then(() => undefined, () => undefined);
|
|
254
|
+
return p;
|
|
255
|
+
}
|
|
256
|
+
/** feegrant 代付被链拒的特征 (无 grant/超额/非白名单 msg) → 回退商户自付重试一次 */
|
|
257
|
+
const FEEGRANT_FAIL_RE = /granter|allowance|feegrant/i;
|
|
258
|
+
|
|
259
|
+
async function signAndBroadcastInner(c, messages, account, opts, useGranter = true) {
|
|
260
|
+
const memo = (opts && opts.memo) || '';
|
|
261
|
+
// N15: 生效 granter — useGranter 且配了 FEE_GRANTER_ADDR 才代付
|
|
262
|
+
const granterUsed = !!(useGranter && c.feeGranter);
|
|
263
|
+
const cEff = granterUsed ? c : { ...c, feeGranter: '' };
|
|
264
|
+
const fallbackNoGranter = (why) => {
|
|
265
|
+
console.warn(`[chain-writes] feegrant 代付失败 (${why}), 回退商户自付重试一次`);
|
|
266
|
+
return signAndBroadcastInner(c, messages, account, opts, false);
|
|
267
|
+
};
|
|
268
|
+
// JS 直签通道 (SIGN_MODE=js|auto): 成功直接返回; auto 模式下签名/广播异常降级 CLI
|
|
269
|
+
if (effectiveSignMode(c) === 'js') {
|
|
270
|
+
try {
|
|
271
|
+
const r = await chain_signer_1.jsSignAndBroadcast(cEff, messages, account, undefined, memo);
|
|
272
|
+
console.log(`[chain-writes] sign_mode=js txhash=${r.txhash} code=${r.code}${memo ? ` memo=${memo.slice(0, 24)}…` : ''}${granterUsed ? ` granter=${c.feeGranter.slice(0, 16)}…` : ''}`);
|
|
273
|
+
if (r.code !== 0 && granterUsed && FEEGRANT_FAIL_RE.test(r.raw_log)) return fallbackNoGranter(String(r.raw_log).slice(0, 120));
|
|
274
|
+
return r;
|
|
275
|
+
}
|
|
276
|
+
catch (e) {
|
|
277
|
+
// sequence mismatch 不重导到 CLI (CLI 也会 mismatch, 反而拖慢); 直接上抛走重查重试
|
|
278
|
+
const isMismatch = /account sequence mismatch/i.test(e?.message || '');
|
|
279
|
+
if (granterUsed && !isMismatch && FEEGRANT_FAIL_RE.test(`${e?.message || ""}`)) return fallbackNoGranter(String(e?.message || "").slice(0, 120));
|
|
280
|
+
if (c.signMode !== 'auto' || isMismatch)
|
|
281
|
+
throw e;
|
|
282
|
+
console.warn(`[chain-writes] JS 直签失败, 降级 trustchaind CLI: ${e?.message ?? e}`);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
let unsignedFile;
|
|
286
|
+
let signedFile;
|
|
287
|
+
try {
|
|
288
|
+
unsignedFile = writeTempJson('tct-unsigned', buildUnsignedTx(messages, cEff, memo));
|
|
289
|
+
const signed = await execFileAsync(c.bin, [
|
|
290
|
+
'tx', 'sign', unsignedFile,
|
|
291
|
+
'--keyring-backend', 'test',
|
|
292
|
+
'--home', c.home,
|
|
293
|
+
'--chain-id', c.chainId,
|
|
294
|
+
'--offline',
|
|
295
|
+
'--account-number', account.accountNumber,
|
|
296
|
+
'--sequence', account.sequence,
|
|
297
|
+
'--from', c.keyName,
|
|
298
|
+
]);
|
|
299
|
+
signedFile = writeTempJson('tct-signed', JSON.parse(signed));
|
|
300
|
+
let stdout;
|
|
301
|
+
try {
|
|
302
|
+
stdout = await execFileAsync(c.bin, [
|
|
303
|
+
'tx', 'broadcast', signedFile,
|
|
304
|
+
'--node', c.rpcUrl,
|
|
305
|
+
'--output', 'json',
|
|
306
|
+
]);
|
|
307
|
+
}
|
|
308
|
+
catch (e) {
|
|
309
|
+
// broadcast 失败时 stdout 里往往仍有 code!=0 的 JSON (CheckTx 拒绝)
|
|
310
|
+
const out = e?.stdout || '';
|
|
311
|
+
const parsed = tryParseBroadcast(out);
|
|
312
|
+
if (parsed) {
|
|
313
|
+
if (granterUsed && FEEGRANT_FAIL_RE.test(parsed.raw_log || '')) return fallbackNoGranter(String(parsed.raw_log).slice(0, 120));
|
|
314
|
+
return parsed;
|
|
315
|
+
}
|
|
316
|
+
const mismatch = /account sequence mismatch/i.test(`${out} ${e?.stderr || ''} ${e?.message || ''}`);
|
|
317
|
+
if (mismatch)
|
|
318
|
+
throw new SequenceMismatchError(e.message);
|
|
319
|
+
if (granterUsed && FEEGRANT_FAIL_RE.test(`${e?.stderr || ""} ${e?.message || ""}`)) return fallbackNoGranter(String(e?.stderr || e?.message || "").slice(0, 120));
|
|
320
|
+
throw e;
|
|
321
|
+
}
|
|
322
|
+
const parsed = tryParseBroadcast(stdout);
|
|
323
|
+
if (!parsed)
|
|
324
|
+
throw new Error(`broadcast 输出非 JSON: ${stdout.slice(0, 200)}`);
|
|
325
|
+
if (/account sequence mismatch/i.test(parsed.raw_log))
|
|
326
|
+
throw new SequenceMismatchError(parsed.raw_log);
|
|
327
|
+
// 2026-09-07 kimi: broadcast(sync) 返回的是 CheckTx 结果 — 交付期失败 (DeliverTx code!=0)
|
|
328
|
+
// 会漏报 (实测: max slots 满时 CheckTx code=0 但 DeliverTx code=1, 端点误报成功).
|
|
329
|
+
// 轮询 LCD 拿最终结果, 以它为准.
|
|
330
|
+
if (parsed.code === 0 && parsed.txhash) {
|
|
331
|
+
const final = await pollFinalTx(c, parsed.txhash);
|
|
332
|
+
if (final) {
|
|
333
|
+
if (final.code !== 0 && granterUsed && FEEGRANT_FAIL_RE.test(final.raw_log || '')) return fallbackNoGranter(String(final.raw_log).slice(0, 120));
|
|
334
|
+
return final;
|
|
335
|
+
}
|
|
336
|
+
// 2026-09-20 kimi: 15s 未入块不再按 CheckTx 假成功 — 实测 burst flush 时
|
|
337
|
+
// 同账户后续 tx 会因序列号冲突被 mempool 静默逐出 (永不入块), 假成功让
|
|
338
|
+
// 插件水位假同步。改抛 502 让调用方走重试队列 (幂等键防重)。
|
|
339
|
+
throw new HttpError(502, 'tx_delivery_timeout', `tx ${parsed.txhash} 未在 15s 内入块 (可能被 mempool 逐出), 请重试`);
|
|
340
|
+
}
|
|
341
|
+
if (parsed.code !== 0 && granterUsed && FEEGRANT_FAIL_RE.test(parsed.raw_log || '')) return fallbackNoGranter(String(parsed.raw_log).slice(0, 120));
|
|
342
|
+
return parsed;
|
|
343
|
+
}
|
|
344
|
+
finally {
|
|
345
|
+
cleanup(unsignedFile, signedFile);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
class SequenceMismatchError extends Error {
|
|
349
|
+
}
|
|
350
|
+
exports.SequenceMismatchError = SequenceMismatchError;
|
|
351
|
+
/** 轮询 LCD 拿交易最终交付结果 (DeliverTx)。最多 ~15s (5×3s)。查不到返回 null。 */
|
|
352
|
+
async function pollFinalTx(c, txhash) {
|
|
353
|
+
const intervalMs = Number(process.env.CHAIN_TX_POLL_INTERVAL_MS || 3000); // 测试可加速
|
|
354
|
+
for (let i = 0; i < 5; i++) {
|
|
355
|
+
await new Promise((r) => setTimeout(r, intervalMs));
|
|
356
|
+
try {
|
|
357
|
+
const resp = await fetch(`${c.lcdUrl}/cosmos/tx/v1beta1/txs/${txhash}`, {
|
|
358
|
+
signal: AbortSignal.timeout(8000),
|
|
359
|
+
});
|
|
360
|
+
if (resp.status === 404)
|
|
361
|
+
continue; // 还没入块
|
|
362
|
+
if (!resp.ok)
|
|
363
|
+
continue;
|
|
364
|
+
const j = (await resp.json());
|
|
365
|
+
const tr = j?.tx_response;
|
|
366
|
+
if (tr && tr.height && Number(tr.height) > 0) {
|
|
367
|
+
return {
|
|
368
|
+
txhash,
|
|
369
|
+
code: Number(tr.code ?? 0),
|
|
370
|
+
raw_log: String(tr.raw_log ?? ''),
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
catch {
|
|
375
|
+
// 网络抖动, 下轮再试
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
function tryParseBroadcast(out) {
|
|
381
|
+
try {
|
|
382
|
+
const j = JSON.parse(out.trim());
|
|
383
|
+
if (typeof j !== 'object' || j === null)
|
|
384
|
+
return null;
|
|
385
|
+
return {
|
|
386
|
+
txhash: String(j.txhash || j.tx_hash || ''),
|
|
387
|
+
code: Number(j.code ?? 0),
|
|
388
|
+
raw_log: String(j.raw_log ?? ''),
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
catch {
|
|
392
|
+
return null;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
/** 完整发送流程: LCD 查序号 → sign → broadcast; sequence mismatch 重查重试一次
|
|
396
|
+
*
|
|
397
|
+
* 2026-09-22 kimi: **查序号必须在本文件的串行队列内部做**。
|
|
398
|
+
* 旧实现先在队外查序号再入队 —— 并发两条写请求 (商品+质押 / burst flush) 会拿到同一个
|
|
399
|
+
* sequence: 第一条用 S 上链成功 (链上变 S+1), 第二条还用 S → CheckTx 直接报
|
|
400
|
+
* "account sequence mismatch: expected S+1, got S"。真机表现就是**稳定 -1 偏移**,
|
|
401
|
+
* 每一对并发请求必然重现 (不是偶发)。
|
|
402
|
+
* 现在队列内"查序号 → 签名 → 广播"原子成组: 下一条进队时, 上一条已经过 DeliverTx 轮询确认。
|
|
403
|
+
*/
|
|
404
|
+
exports.sendTxAs = sendTxAs;
|
|
405
|
+
async function sendTxAs(c, messages, addr, opts) {
|
|
406
|
+
const run = async () => {
|
|
407
|
+
let account;
|
|
408
|
+
try {
|
|
409
|
+
account = await queryAccount(c, addr);
|
|
410
|
+
}
|
|
411
|
+
catch (e) {
|
|
412
|
+
// N15: 0 余额新商户 (auth 账户都不存在) + feegrant 代付 → 首笔 tx 以账户号 0/0 发起
|
|
413
|
+
const isNotFound = (e && e.code === 'account_not_found') || /account_not_found/.test(String(e && e.message));
|
|
414
|
+
if (!isNotFound || !c.feeGranter)
|
|
415
|
+
throw e;
|
|
416
|
+
console.log(`[chain-writes] 地址未上链 + feegrant 代付, 以 account 0/0 发起首笔 tx: ${addr}`);
|
|
417
|
+
account = { accountNumber: '0', sequence: '0' };
|
|
418
|
+
}
|
|
419
|
+
try {
|
|
420
|
+
return await signAndBroadcastInner(c, messages, account, opts);
|
|
421
|
+
}
|
|
422
|
+
catch (e) {
|
|
423
|
+
if (!(e instanceof SequenceMismatchError))
|
|
424
|
+
throw e;
|
|
425
|
+
console.warn('[chain-writes] account sequence mismatch, 重查序号重试一次');
|
|
426
|
+
account = await queryAccount(c, addr);
|
|
427
|
+
return await signAndBroadcastInner(c, messages, account, opts);
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
const p = sendQueue.then(run, run);
|
|
431
|
+
sendQueue = p.then(() => undefined, () => undefined);
|
|
432
|
+
return p;
|
|
433
|
+
}
|
|
434
|
+
/** 签名者地址由当前密钥推导 (绝大多数写请求走这条) */
|
|
435
|
+
async function sendTx(c, messages, opts) {
|
|
436
|
+
return sendTxAs(c, messages, await keyAddress(c), opts);
|
|
437
|
+
}
|
|
438
|
+
function createChainWritesRouter(deps) {
|
|
439
|
+
const router = (0, express_1.Router)();
|
|
440
|
+
const { db } = deps;
|
|
441
|
+
/** 下单意愿存证 (v3.9.4 卖家代建单: memo = tb-auth:<sha256(意愿原文)>)
|
|
442
|
+
* 表/写入/回填都在 core/order-intent-store.js (申诉意愿 POST /api/order/dispute 共用同一张表) */
|
|
443
|
+
let intentTableReady = false;
|
|
444
|
+
function ensureIntentTable() {
|
|
445
|
+
if (intentTableReady)
|
|
446
|
+
return;
|
|
447
|
+
intent_store_1.ensureIntentTable(db);
|
|
448
|
+
intentTableReady = true;
|
|
449
|
+
}
|
|
450
|
+
/** 链上拒绝的 raw_log → hint (口径见 core/chain-reject.js; raw_log 永远原样回传, 不吞) */
|
|
451
|
+
const classifyChainReject = chain_reject_1.classifyChainReject;
|
|
452
|
+
/**
|
|
453
|
+
* POST /api/orders — WooCommerce order_completed → MsgCreateOrder (PENDING, per #377)
|
|
454
|
+
*
|
|
455
|
+
* ★ v3.9.4 链侧口径 (方案 A「卖家代建单」, 必须与本接口同批上线):
|
|
456
|
+
* - MsgCreateOrder 的 signer 语义 = **seller** (旧口径是 buyer)。卖家用自己的 key 签名上链,
|
|
457
|
+
* payload.seller_address 只做存在性校验, 真正进 msg 的 seller 一律取签名地址。
|
|
458
|
+
* - buyer **必须由调用方提供**真实买家 tct1 地址: 非空 / 合法 bech32 / ≠ 卖家自己,
|
|
459
|
+
* 且该买家需已注册 trustcoin 账户 (链上校验)。**不再回填卖家地址** ——
|
|
460
|
+
* 旧代码 buyer_address 空时回填签名者, 升级后会被链上直接拒 (buyer==seller)。
|
|
461
|
+
* - 买家意愿由 tx memo 承载: "tb-auth:<64 位小写 hex>", hex = **整批订单意愿**的 sha256
|
|
462
|
+
* (一笔 tx 一条 memo, 但可带多条 MsgCreateOrder)。原文 JSON 按 core/order-intent.js
|
|
463
|
+
* 的稳定口径序列化, 同时落库 order_intent_log 备查。
|
|
464
|
+
* - 订单收益/信誉一律以 MsgConfirmPaymentFact (真实支付事实) 为准 — 卖家自造订单拿不到好处,
|
|
465
|
+
* 这里的 memo 只是"买家意愿"的可验证凭据。
|
|
466
|
+
*
|
|
467
|
+
* payload 契约 (hooks-order.php 需要同步改: buyer_address 从"可空"改为"必填"):
|
|
468
|
+
* { order_id, buyer_address(必填 tct1 买家地址), seller_address, total_usd,
|
|
469
|
+
* items[{product_id, qty, subtotal_usd}], state,
|
|
470
|
+
* timestamp(毫秒 epoch; 也接受数字字符串/ISO8601; 重试请传同一个值),
|
|
471
|
+
* session_ref(可选; 也接受 session_token / session_id) }
|
|
472
|
+
* 响应: { txhash, code, chain_order_ids, buyer, order_intent_hash, order_intent_memo }
|
|
473
|
+
* 错误: 400 buyer_required / buyer_invalid / buyer_is_seller / invalid_param,
|
|
474
|
+
* 502 chain_tx_failed (带 hint + raw_log 原样)
|
|
475
|
+
* 映射: 每个 line item 一条 MsgCreateOrder (链上 msg 是单 sku 粒度), payment_method="fiat"
|
|
476
|
+
* (WooCommerce = 法币 PayPal 收款, 不锁 TCT escrow)。
|
|
477
|
+
*/
|
|
478
|
+
router.post('/orders', async (req, res) => {
|
|
479
|
+
const c = cfg();
|
|
480
|
+
try {
|
|
481
|
+
const b = req.body ?? {};
|
|
482
|
+
const orderId = assertSafe(b.order_id, 'order_id');
|
|
483
|
+
const seller = assertSafe(b.seller_address, 'seller_address');
|
|
484
|
+
assertPositiveNumber(b.total_usd, 'total_usd');
|
|
485
|
+
if (!Array.isArray(b.items) || b.items.length === 0) {
|
|
486
|
+
throw new HttpError(400, 'invalid_param', 'items 必填且非空数组');
|
|
487
|
+
}
|
|
488
|
+
const addr = await keyAddress(c);
|
|
489
|
+
// v3.9.4: 买家标识必须由调用方给真值 (缺失/非法/等于卖家 → 400, 不回填卖家)
|
|
490
|
+
const buyerCheck = orderIntent.validateBuyer(b.buyer_address, addr);
|
|
491
|
+
if (!buyerCheck.ok) {
|
|
492
|
+
console.warn(`[chain-writes] /api/orders 买家标识不合格 order=${orderId} code=${buyerCheck.code}`);
|
|
493
|
+
throw new HttpError(400, buyerCheck.code, buyerCheck.message);
|
|
494
|
+
}
|
|
495
|
+
const buyer = buyerCheck.buyer;
|
|
496
|
+
const rate = assertPositiveNumber(c.usdToMicroTct, 'CHAIN_USD_TO_MICROTCT_RATE');
|
|
497
|
+
const messages = b.items.map((item, i) => {
|
|
498
|
+
const skuId = assertSafe(item?.product_id, `items[${i}].product_id`);
|
|
499
|
+
const qty = assertUint(item?.qty, `items[${i}].qty`, { min: 1 });
|
|
500
|
+
const subtotal = assertPositiveNumber(item?.subtotal_usd, `items[${i}].subtotal_usd`);
|
|
501
|
+
return {
|
|
502
|
+
'@type': '/trustchain.order.v1.MsgCreateOrder',
|
|
503
|
+
buyer, // 真实买家标识 (payload 提供, 非签名者)
|
|
504
|
+
seller,
|
|
505
|
+
sku_id: skuId,
|
|
506
|
+
quantity: String(qty),
|
|
507
|
+
price_per_unit: String(Math.max(1, Math.round((subtotal / qty) * rate))),
|
|
508
|
+
shipping_address_hash: '',
|
|
509
|
+
source_chain: '',
|
|
510
|
+
payment_method: 'fiat',
|
|
511
|
+
referrer: '',
|
|
512
|
+
};
|
|
513
|
+
});
|
|
514
|
+
// 2026-09-22 kimi (v3.9.4 修订): MsgCreateOrder 的 signer 语义 = seller —
|
|
515
|
+
// 卖家身份一律以签名 key 为准 (外部平台 seller_address 填错会导致 tx sign
|
|
516
|
+
// "intended signer does not match" 拒签); buyer 保持调用方给的真实买家地址,
|
|
517
|
+
// **不再回填签名者** (升级后链上会拒 buyer==seller)。
|
|
518
|
+
for (const m of messages) {
|
|
519
|
+
m.seller = addr;
|
|
520
|
+
}
|
|
521
|
+
// 整批意愿: items 用已归一化的链上三元组 (sku_id/quantity/price_per_unit),
|
|
522
|
+
// 调用方带 timestamp 则用它 (重试同 payload → 同 hash → 幂等不留重复行)
|
|
523
|
+
const timestampMs = orderIntent.normalizeTimestampMs(b.timestamp);
|
|
524
|
+
// 会话/令牌引用: 主字段 session_ref, 兼容插件常见的 session_token / session_id 写法
|
|
525
|
+
const sessionRefRaw = b.session_ref ?? b.session_token ?? b.session_id;
|
|
526
|
+
const sessionRef = typeof sessionRefRaw === 'string' ? sessionRefRaw : '';
|
|
527
|
+
const intent = orderIntent.buildOrderIntentHash(messages.map((m) => ({
|
|
528
|
+
sku_id: m.sku_id,
|
|
529
|
+
quantity: m.quantity,
|
|
530
|
+
price_per_unit: m.price_per_unit,
|
|
531
|
+
})), { buyer, seller: addr, order_ref: orderId, timestamp_ms: timestampMs, session_ref: sessionRef });
|
|
532
|
+
if (!orderIntent.isValidAuthMemo(intent.memo))
|
|
533
|
+
throw new Error(`内部错误: 生成的 memo 不合链上格式 (${intent.memo.slice(0, 16)}…)`);
|
|
534
|
+
ensureIntentTable();
|
|
535
|
+
intent_store_1.recordIntent(db, {
|
|
536
|
+
intent_hash: intent.hash,
|
|
537
|
+
kind: 'tb.order.intent',
|
|
538
|
+
order_id: orderId,
|
|
539
|
+
buyer,
|
|
540
|
+
seller: addr,
|
|
541
|
+
session_ref: sessionRef,
|
|
542
|
+
memo: intent.memo,
|
|
543
|
+
intent_json: intent.canonical,
|
|
544
|
+
status: 'pending',
|
|
545
|
+
});
|
|
546
|
+
console.log(`[chain-writes] /api/orders 意愿存证 order=${orderId} buyer=${buyer} hash=${intent.hash.slice(0, 16)}… msgs=${messages.length}`);
|
|
547
|
+
// 2026-09-22 kimi: 序号查询挪进串行队列内部 (sendTxAs) —— 订单 burst 并发提交时,
|
|
548
|
+
// 旧写法在队外查序号会让多个 tx 带同一个 sequence 进 mempool。
|
|
549
|
+
const result = await sendTxAs(c, messages, addr, { memo: intent.memo });
|
|
550
|
+
if (result.code !== 0) {
|
|
551
|
+
const hint = classifyChainReject(result.raw_log);
|
|
552
|
+
console.error(`[chain-writes] /api/orders 链上拒绝 order=${orderId} code=${result.code} hint=${hint} raw_log=${result.raw_log}`);
|
|
553
|
+
// raw_log 原样回传 (不吞): 调用方据此区分 buyer 未注册 trustcoin 账户 / 地址非法 / 其它
|
|
554
|
+
return res.status(502).json({
|
|
555
|
+
error: 'chain_tx_failed',
|
|
556
|
+
code: result.code,
|
|
557
|
+
hint,
|
|
558
|
+
raw_log: result.raw_log,
|
|
559
|
+
txhash: result.txhash,
|
|
560
|
+
order_intent_hash: intent.hash,
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
db.prepare('INSERT OR REPLACE INTO chain_write_log (psp_payment_id, order_id, txhash, status) VALUES (?, ?, ?, ?)').run(`order:${orderId}`, orderId, result.txhash, 'success');
|
|
564
|
+
// 意愿表回填 txhash (失败只记日志: tx 已经上链, 不能因为本地记录把成功判成失败)
|
|
565
|
+
if (!intent_store_1.markIntentTx(db, intent.hash, result.txhash, 'success'))
|
|
566
|
+
console.warn('[chain-writes] /api/orders 意愿表回填 txhash 失败 (不影响上链结果)');
|
|
567
|
+
console.log(`[chain-writes] /api/orders 上链成功 order=${orderId} txhash=${result.txhash} msgs=${messages.length}`);
|
|
568
|
+
// 2026-09-20 kimi: 回传链上 order_id — MsgConfirmPayment 用的是链上自增
|
|
569
|
+
// order_id (create_order event), 不是平台侧订单号; 不回传插件无从确认。
|
|
570
|
+
// 拿不到 (LCD 抖动) 不阻塞, 返回空数组让调用方降级。
|
|
571
|
+
const chainOrderIds = [];
|
|
572
|
+
try {
|
|
573
|
+
const t = await fetch(`${c.lcdUrl}/cosmos/tx/v1beta1/txs/${result.txhash}`, { signal: AbortSignal.timeout(5000) });
|
|
574
|
+
const td = await t.json();
|
|
575
|
+
for (const ev of (td?.tx_response?.events ?? [])) {
|
|
576
|
+
if (ev?.type !== 'create_order')
|
|
577
|
+
continue;
|
|
578
|
+
const get = (k) => ev.attributes?.find((a) => a.key === k)?.value;
|
|
579
|
+
chainOrderIds.push({
|
|
580
|
+
msg_index: Number(get('msg_index') ?? 0),
|
|
581
|
+
order_id: get('order_id'),
|
|
582
|
+
sku_id: get('sku_id'),
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
chainOrderIds.sort((a, b) => a.msg_index - b.msg_index);
|
|
586
|
+
}
|
|
587
|
+
catch (e) {
|
|
588
|
+
console.warn(`[chain-writes] /api/orders 链上 order_id 解析失败 (不阻塞): ${e?.message ?? e}`);
|
|
589
|
+
}
|
|
590
|
+
// 回传意愿 hash/memo: 调用方可留存, 争议时可复算比对 (与链上 tx memo 一致)
|
|
591
|
+
return res.status(200).json({
|
|
592
|
+
txhash: result.txhash,
|
|
593
|
+
code: result.code,
|
|
594
|
+
chain_order_ids: chainOrderIds,
|
|
595
|
+
buyer,
|
|
596
|
+
order_intent_hash: intent.hash,
|
|
597
|
+
order_intent_memo: intent.memo,
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
catch (e) {
|
|
601
|
+
return handleError(res, e, '/api/orders');
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
/**
|
|
605
|
+
* POST /api/payments — WooCommerce payment_complete → MsgConfirmPayment (PENDING→PAID)
|
|
606
|
+
* payload 契约 (hooks-payment.php 一字不改):
|
|
607
|
+
* { order_id, payment_authority, psp_payment_id, amount_usd_cents, currency, seller_address, timestamp }
|
|
608
|
+
* 幂等 (per #376): psp_payment_id 在 chain_write_log 已 success → 200 + idempotent_replay=true
|
|
609
|
+
* authority 二态 (per #376): payment_authority 空 → seller_address 回退 (Phase A 卖家本人)
|
|
610
|
+
*/
|
|
611
|
+
router.post('/payments', async (req, res) => {
|
|
612
|
+
const c = cfg();
|
|
613
|
+
try {
|
|
614
|
+
const b = req.body ?? {};
|
|
615
|
+
const orderId = assertSafe(b.order_id, 'order_id', { numeric: true });
|
|
616
|
+
const pspPaymentId = assertSafe(b.psp_payment_id, 'psp_payment_id');
|
|
617
|
+
const seller = assertSafe(b.seller_address, 'seller_address', { optional: true });
|
|
618
|
+
const authority = assertSafe(b.payment_authority, 'payment_authority', { optional: true }) || seller;
|
|
619
|
+
if (!authority)
|
|
620
|
+
throw new HttpError(400, 'invalid_param', 'payment_authority 与 seller_address 至少其一必填');
|
|
621
|
+
assertUint(b.amount_usd_cents, 'amount_usd_cents', { min: 0 });
|
|
622
|
+
assertSafe(b.currency, 'currency');
|
|
623
|
+
// 幂等短路: 本地已处理 → 直接返回原 txhash (不发链)
|
|
624
|
+
const seen = db.prepare("SELECT txhash FROM chain_write_log WHERE psp_payment_id = ? AND status = 'success'").get(pspPaymentId);
|
|
625
|
+
if (seen) {
|
|
626
|
+
console.log(`[chain-writes] /api/payments 幂等重放 psp=${pspPaymentId} txhash=${seen.txhash}`);
|
|
627
|
+
return res.status(200).json({ txhash: seen.txhash, code: 0, idempotent_replay: true });
|
|
628
|
+
}
|
|
629
|
+
const messages = [{
|
|
630
|
+
'@type': '/trustchain.order.v1.MsgConfirmPayment',
|
|
631
|
+
authority: '__SIGNER__', // 2026-09-20 kimi: signer 语义 = authority, 一律以签名 key 为准 (防 payload 身份填错拒签)
|
|
632
|
+
order_id: orderId, // uint64 → proto JSON 字符串
|
|
633
|
+
psp_payment_id: pspPaymentId,
|
|
634
|
+
}];
|
|
635
|
+
messages[0].authority = await keyAddress(c);
|
|
636
|
+
const result = await sendTx(c, messages);
|
|
637
|
+
if (result.code !== 0) {
|
|
638
|
+
console.error(`[chain-writes] /api/payments 链上拒绝 order=${orderId} psp=${pspPaymentId} code=${result.code} raw_log=${result.raw_log}`);
|
|
639
|
+
return res.status(502).json({ error: 'chain_tx_failed', code: result.code, raw_log: result.raw_log, txhash: result.txhash });
|
|
640
|
+
}
|
|
641
|
+
db.prepare('INSERT OR REPLACE INTO chain_write_log (psp_payment_id, order_id, txhash, status) VALUES (?, ?, ?, ?)').run(pspPaymentId, orderId, result.txhash, 'success');
|
|
642
|
+
console.log(`[chain-writes] /api/payments 上链成功 order=${orderId} psp=${pspPaymentId} txhash=${result.txhash}`);
|
|
643
|
+
return res.status(200).json({ txhash: result.txhash, code: result.code, idempotent_replay: false });
|
|
644
|
+
}
|
|
645
|
+
catch (e) {
|
|
646
|
+
return handleError(res, e, '/api/payments');
|
|
647
|
+
}
|
|
648
|
+
});
|
|
649
|
+
return router;
|
|
650
|
+
}
|
|
651
|
+
function handleError(res, e, tag) {
|
|
652
|
+
if (e instanceof HttpError) {
|
|
653
|
+
return res.status(e.status).json({ error: e.code, message: e.message });
|
|
654
|
+
}
|
|
655
|
+
console.error(`[chain-writes] ${tag} 失败:`, e?.message ?? e);
|
|
656
|
+
return res.status(502).json({ error: 'chain_write_error', message: e?.message || String(e) });
|
|
657
|
+
}
|
|
658
|
+
//# sourceMappingURL=chain-writes.js.map
|