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,528 @@
|
|
|
1
|
+
// 订单生命周期端点契约测试 (v3.9.4 / D2: ship / confirm / cancel / dispute + create 停用)
|
|
2
|
+
//
|
|
3
|
+
// 覆盖 routes/order.js 的四条 POST:
|
|
4
|
+
// - 正向: 打桩"链" + 真 cosmjs 签名 (JS 直签通道) → **从签名后的 TxRaw 字节里解出** msg 类型/字段,
|
|
5
|
+
// 并用独立重构的 SignDoc 做 secp256k1 验签 (证明签名者 = 本机卖家 key = submitter/seller 字段);
|
|
6
|
+
// - 负向: 缺字段 / 字段非法 / 未授权 / 订单不属于本店 / 状态不符 → 4xx 且**不发链**;
|
|
7
|
+
// - 链上拒: 502 + hint 分类 + raw_log 原样;
|
|
8
|
+
// - create: 410 Gone (改用 /api/orders)。
|
|
9
|
+
// 不连真链、不碰真机。
|
|
10
|
+
//
|
|
11
|
+
// 运行: node --test test-order-lifecycle-v394.js
|
|
12
|
+
|
|
13
|
+
const assert = require('node:assert');
|
|
14
|
+
const http = require('node:http');
|
|
15
|
+
const express = require('express');
|
|
16
|
+
const Database = require('better-sqlite3');
|
|
17
|
+
const test = require('node:test');
|
|
18
|
+
const { TxRaw, TxBody, AuthInfo, SignDoc } = require('cosmjs-types/cosmos/tx/v1beta1/tx');
|
|
19
|
+
|
|
20
|
+
const chainSigner = require('./core/chain-signer');
|
|
21
|
+
const orderIntent = require('./core/order-intent');
|
|
22
|
+
|
|
23
|
+
const VECTOR_MNEMONIC = 'economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone';
|
|
24
|
+
const SIGNER_ADDR = 'tct1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmw38fjc'; // 本机卖家 (签名者)
|
|
25
|
+
const BUYER_ADDR = 'tct1rmmed4yuddn64nx79c39yh2tuvz934d03zc4ul'; // 订单买家
|
|
26
|
+
const OTHER_ADDR = 'tct1m083grl0az2shvc9za2sk4zyx8x4a2ynn48ccr'; // 第三方 (既非买家也非卖家)
|
|
27
|
+
|
|
28
|
+
process.env.SIGN_MODE = 'js';
|
|
29
|
+
process.env.SELLER_MNEMONIC = VECTOR_MNEMONIC;
|
|
30
|
+
process.env.CHAIN_ID = 'trustchain-1';
|
|
31
|
+
process.env.CHAIN_TX_POLL_INTERVAL_MS = '5';
|
|
32
|
+
|
|
33
|
+
// ---------------------------------------------------------------- 打桩的"链"
|
|
34
|
+
|
|
35
|
+
function createStubChain() {
|
|
36
|
+
const state = { order: null, orderUnavailable: false, reject: null, broadcasts: [], rpcMethods: [] };
|
|
37
|
+
const server = http.createServer((req, res) => {
|
|
38
|
+
let raw = '';
|
|
39
|
+
req.on('data', (d) => { raw += d; });
|
|
40
|
+
req.on('end', () => {
|
|
41
|
+
const url = new URL(req.url || '/', 'http://stub');
|
|
42
|
+
const send = (code, obj) => {
|
|
43
|
+
res.writeHead(code, { 'content-type': 'application/json' });
|
|
44
|
+
res.end(JSON.stringify(obj));
|
|
45
|
+
};
|
|
46
|
+
if (req.method === 'GET') {
|
|
47
|
+
// ---- LCD: 订单查询 ----
|
|
48
|
+
if (url.pathname.startsWith('/oxiaom/trustchain/order/v1/orders/')) {
|
|
49
|
+
if (state.orderUnavailable)
|
|
50
|
+
return send(503, { message: 'stub: order query unavailable' });
|
|
51
|
+
if (!state.order)
|
|
52
|
+
return send(404, { code: 5, message: 'order not found' });
|
|
53
|
+
return send(200, { order: state.order });
|
|
54
|
+
}
|
|
55
|
+
// ---- LCD: 账户 (queryAccount) ----
|
|
56
|
+
if (url.pathname.startsWith('/cosmos/auth/v1beta1/accounts/')) {
|
|
57
|
+
return send(200, { account: { base_account: { account_number: '82', sequence: '0' } } });
|
|
58
|
+
}
|
|
59
|
+
// ---- LCD: tx 查询 (事件里的 submitter / submit_path) ----
|
|
60
|
+
if (url.pathname.startsWith('/cosmos/tx/v1beta1/txs/')) {
|
|
61
|
+
const hash = url.pathname.split('/').pop();
|
|
62
|
+
return send(200, {
|
|
63
|
+
tx_response: {
|
|
64
|
+
height: '500', code: 0, raw_log: '', txhash: hash,
|
|
65
|
+
events: [
|
|
66
|
+
{ type: 'confirm_order', attributes: [{ key: 'order_id', value: '7' }, { key: 'submitter', value: SIGNER_ADDR }, { key: 'submit_path', value: 'seller' }] },
|
|
67
|
+
{ type: 'dispute_order', attributes: [{ key: 'order_id', value: '7' }, { key: 'disputer', value: BUYER_ADDR }, { key: 'submitter', value: SIGNER_ADDR }, { key: 'submit_path', value: 'seller' }] },
|
|
68
|
+
{ type: 'ship_order', attributes: [{ key: 'order_id', value: '7' }, { key: 'seller', value: SIGNER_ADDR }] },
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return send(404, { message: 'not found' });
|
|
74
|
+
}
|
|
75
|
+
// ---- CometBFT JSON-RPC ----
|
|
76
|
+
let rpc = {};
|
|
77
|
+
try { rpc = JSON.parse(raw || '{}'); } catch (_) { /* ignore */ }
|
|
78
|
+
const id = rpc.id === undefined ? 1 : rpc.id;
|
|
79
|
+
const ok = (result) => send(200, { jsonrpc: '2.0', id, result });
|
|
80
|
+
state.rpcMethods.push(rpc.method);
|
|
81
|
+
if (rpc.method === 'status') {
|
|
82
|
+
return ok({
|
|
83
|
+
node_info: {
|
|
84
|
+
protocol_version: { p2p: '8', block: '11', app: '0' },
|
|
85
|
+
id: 'a'.repeat(40), listen_addr: 'tcp://127.0.0.1:26656', network: 'trustchain-1',
|
|
86
|
+
version: '0.37.0', channels: '40202122233038606100', moniker: 'stub',
|
|
87
|
+
other: { tx_index: 'on', rpc_address: 'tcp://127.0.0.1:26657' },
|
|
88
|
+
},
|
|
89
|
+
sync_info: {
|
|
90
|
+
latest_block_hash: 'AA'.repeat(32), latest_app_hash: 'BB'.repeat(32), latest_block_height: '500',
|
|
91
|
+
latest_block_time: '2026-01-01T00:00:00.000Z', catching_up: false,
|
|
92
|
+
},
|
|
93
|
+
validator_info: {
|
|
94
|
+
address: 'CC'.repeat(20),
|
|
95
|
+
pub_key: { type: 'tendermint/PubKeyEd25519', value: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=' },
|
|
96
|
+
voting_power: '0',
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (rpc.method === 'genesis' || rpc.method === 'genesis_chunked') {
|
|
101
|
+
return ok({
|
|
102
|
+
genesis: {
|
|
103
|
+
genesis_time: '2026-01-01T00:00:00.000Z', chain_id: 'trustchain-1', initial_height: '1',
|
|
104
|
+
consensus_params: {
|
|
105
|
+
block: { max_bytes: '22020096', max_gas: '-1' },
|
|
106
|
+
evidence: { max_age_num_blocks: '100000', max_age_duration: '172800000000000', max_bytes: '1048576' },
|
|
107
|
+
validator: { pub_key_types: ['ed25519'] },
|
|
108
|
+
},
|
|
109
|
+
validators: [], app_hash: '', app_state: {},
|
|
110
|
+
},
|
|
111
|
+
chunks: [],
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if (rpc.method === 'abci_info') {
|
|
115
|
+
return ok({ response: { data: '', version: '0.37.0', app_version: '1', last_block_height: '500', last_block_app_hash: 'CC' } });
|
|
116
|
+
}
|
|
117
|
+
if (rpc.method === 'broadcast_tx_sync') {
|
|
118
|
+
state.broadcasts.push(rpc.params && rpc.params.tx);
|
|
119
|
+
if (state.reject)
|
|
120
|
+
return ok({ code: state.reject.code, log: state.reject.log, codespace: 'order', hash: 'A'.repeat(64) });
|
|
121
|
+
return ok({ code: 0, log: '', codespace: '', hash: 'B'.repeat(64) });
|
|
122
|
+
}
|
|
123
|
+
console.error('[stub-chain] 未打桩的 RPC 方法:', rpc.method);
|
|
124
|
+
return send(200, { jsonrpc: '2.0', id, error: { code: -32601, message: 'method not found: ' + rpc.method } });
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
return { server, state };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// ---------------------------------------------------------------- 解码 + 验签
|
|
131
|
+
|
|
132
|
+
/** 从签名后的 tx (base64 TxRaw) 解出 memo + 每条 msg (看链上真正收到什么) */
|
|
133
|
+
function decodeSignedTx(txBase64) {
|
|
134
|
+
const txRaw = TxRaw.decode(Buffer.from(txBase64, 'base64'));
|
|
135
|
+
const body = TxBody.decode(txRaw.bodyBytes);
|
|
136
|
+
const authInfo = AuthInfo.decode(txRaw.authInfoBytes);
|
|
137
|
+
const registry = chainSigner.makeRegistry();
|
|
138
|
+
return {
|
|
139
|
+
txRaw,
|
|
140
|
+
memo: body.memo,
|
|
141
|
+
authInfo,
|
|
142
|
+
messages: body.messages.map((m) => ({ typeUrl: m.typeUrl, value: registry.decode({ typeUrl: m.typeUrl, value: m.value }) })),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* 独立验签 (cosmos SIGN_MODE_DIRECT): 用助记词重新派生 pubkey, 校验签名对重构 SignDoc 的 sha256。
|
|
148
|
+
* 这一步证明的是"这笔 tx 确实由本机卖家 key 签的" —— 也就是链上 signer 注解字段必须等于的那个地址。
|
|
149
|
+
*/
|
|
150
|
+
async function verifySignatureBySeller(txRaw, { accountNumber = 82, chainId = 'trustchain-1' } = {}) {
|
|
151
|
+
const { makeSignDoc } = require('@cosmjs/proto-signing');
|
|
152
|
+
const { Secp256k1, Secp256k1Signature, sha256, EnglishMnemonic, Bip39, Slip10, Slip10Curve, stringToPath } = require('@cosmjs/crypto');
|
|
153
|
+
const signDoc = makeSignDoc(txRaw.bodyBytes, txRaw.authInfoBytes, chainId, accountNumber);
|
|
154
|
+
const signDocBytes = SignDoc.encode(signDoc).finish();
|
|
155
|
+
const seed = await Bip39.mnemonicToSeed(new EnglishMnemonic(VECTOR_MNEMONIC));
|
|
156
|
+
const { privkey } = Slip10.derivePath(Slip10Curve.Secp256k1, seed, stringToPath("m/44'/118'/0'/0/0"));
|
|
157
|
+
const kp = await Secp256k1.makeKeypair(privkey);
|
|
158
|
+
const pubkey = Secp256k1.compressPubkey(kp.pubkey);
|
|
159
|
+
return Secp256k1.verifySignature(
|
|
160
|
+
Secp256k1Signature.fromFixedLength(Secp256k1.trimRecoveryByte(txRaw.signatures[0])),
|
|
161
|
+
sha256(signDocBytes),
|
|
162
|
+
pubkey,
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// ---------------------------------------------------------------- 夹具
|
|
167
|
+
|
|
168
|
+
function orderFixture(over = {}) {
|
|
169
|
+
return {
|
|
170
|
+
order_id: '7',
|
|
171
|
+
buyer: BUYER_ADDR,
|
|
172
|
+
seller: SIGNER_ADDR,
|
|
173
|
+
sku_id: 'sxo-1',
|
|
174
|
+
quantity: '1',
|
|
175
|
+
price_per_unit: '1000000',
|
|
176
|
+
total_amount: '1000000',
|
|
177
|
+
escrow_amount: '0',
|
|
178
|
+
status: 'ORDER_STATUS_SHIPPED',
|
|
179
|
+
created_at: '100',
|
|
180
|
+
shipped_at: '200',
|
|
181
|
+
confirmed_at: '0',
|
|
182
|
+
tracking_info: '',
|
|
183
|
+
dispute_reason: '',
|
|
184
|
+
resolution: '',
|
|
185
|
+
resolved_at: '0',
|
|
186
|
+
insurance_application_id: '',
|
|
187
|
+
is_insured: false,
|
|
188
|
+
source_chain: '',
|
|
189
|
+
payment_method: 'fiat',
|
|
190
|
+
psp_payment_id: '',
|
|
191
|
+
paid_at: '150',
|
|
192
|
+
settled: false,
|
|
193
|
+
...over,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const stub = createStubChain();
|
|
198
|
+
let apiUrl;
|
|
199
|
+
let db;
|
|
200
|
+
let appServer;
|
|
201
|
+
|
|
202
|
+
test.before(async () => {
|
|
203
|
+
await new Promise((r) => stub.server.listen(0, '127.0.0.1', r));
|
|
204
|
+
const base = `http://127.0.0.1:${stub.server.address().port}`;
|
|
205
|
+
process.env.CHAIN_RPC_URL = base;
|
|
206
|
+
process.env.CHAIN_LCD_URL = base;
|
|
207
|
+
process.env.LCD_URL = base;
|
|
208
|
+
process.env.RPC_URL = base;
|
|
209
|
+
|
|
210
|
+
db = new Database(':memory:');
|
|
211
|
+
const { createOrderRoutes } = require('./routes/order');
|
|
212
|
+
const authPlugin = {
|
|
213
|
+
verifyToken: async (token) => (token === 'good-token' ? { userId: 'operator-1' } : null),
|
|
214
|
+
};
|
|
215
|
+
const app = express();
|
|
216
|
+
app.use(express.json());
|
|
217
|
+
app.use('/api/order', createOrderRoutes(authPlugin, { db }));
|
|
218
|
+
await new Promise((r) => { appServer = app.listen(0, '127.0.0.1', r); });
|
|
219
|
+
apiUrl = `http://127.0.0.1:${appServer.address().port}`;
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
test.after(async () => {
|
|
223
|
+
await new Promise((r) => appServer.close(r));
|
|
224
|
+
await new Promise((r) => stub.server.close(r));
|
|
225
|
+
db.close();
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
async function post(path, body, { token = 'good-token' } = {}) {
|
|
229
|
+
const headers = { 'content-type': 'application/json' };
|
|
230
|
+
if (token)
|
|
231
|
+
headers.authorization = `Bearer ${token}`;
|
|
232
|
+
const res = await fetch(`${apiUrl}/api/order${path}`, { method: 'POST', headers, body: JSON.stringify(body || {}) });
|
|
233
|
+
return { status: res.status, body: await res.json().catch(() => null) };
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function reset(order, reject = null) {
|
|
237
|
+
stub.state.order = order;
|
|
238
|
+
stub.state.reject = reject;
|
|
239
|
+
stub.state.broadcasts.length = 0;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const lastTx = () => decodeSignedTx(stub.state.broadcasts[stub.state.broadcasts.length - 1]);
|
|
243
|
+
|
|
244
|
+
// ---------------------------------------------------------------- /ship
|
|
245
|
+
|
|
246
|
+
test('ship: 正向 — msg=seller/order_id/tracking_info (字段名不是 tracking_number), 签名者=本机卖家', async () => {
|
|
247
|
+
reset(orderFixture({ status: 'ORDER_STATUS_PAID' }));
|
|
248
|
+
const { status, body } = await post('/ship', { orderId: '7', trackingNumber: 'SF123456' });
|
|
249
|
+
assert.strictEqual(status, 200, JSON.stringify(body));
|
|
250
|
+
assert.ok(body.txhash);
|
|
251
|
+
assert.strictEqual(body.seller, SIGNER_ADDR);
|
|
252
|
+
|
|
253
|
+
const tx = lastTx();
|
|
254
|
+
assert.strictEqual(tx.messages.length, 1);
|
|
255
|
+
assert.strictEqual(tx.messages[0].typeUrl, '/trustchain.order.v1.MsgShipOrder');
|
|
256
|
+
assert.strictEqual(tx.messages[0].value.seller, SIGNER_ADDR);
|
|
257
|
+
assert.strictEqual(String(tx.messages[0].value.order_id), '7');
|
|
258
|
+
assert.strictEqual(tx.messages[0].value.tracking_info, 'SF123456', 'proto 字段是 tracking_info');
|
|
259
|
+
assert.strictEqual(tx.memo, '', 'ship 不带 memo');
|
|
260
|
+
assert.ok(await verifySignatureBySeller(tx.txRaw), '必须是本机卖家 key 的签名');
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
test('ship: 状态不是 PAID → 409 order_not_paid, 不发链', async () => {
|
|
264
|
+
reset(orderFixture({ status: 'ORDER_STATUS_PENDING' }));
|
|
265
|
+
const { status, body } = await post('/ship', { orderId: '7' });
|
|
266
|
+
assert.strictEqual(status, 409);
|
|
267
|
+
assert.strictEqual(body.error, 'order_not_paid');
|
|
268
|
+
assert.strictEqual(stub.state.broadcasts.length, 0);
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
// ---------------------------------------------------------------- /confirm
|
|
272
|
+
|
|
273
|
+
test('confirm: 正向 — buyer 取自链上订单, submitter=本机卖家, 签名者=卖家 (D2 signer 解析验证)', async () => {
|
|
274
|
+
reset(orderFixture({ status: 'ORDER_STATUS_SHIPPED' }));
|
|
275
|
+
const { status, body } = await post('/confirm', { orderId: '7', rating: 5, review: '很好' });
|
|
276
|
+
assert.strictEqual(status, 200, JSON.stringify(body));
|
|
277
|
+
assert.strictEqual(body.buyer, BUYER_ADDR);
|
|
278
|
+
assert.strictEqual(body.submitter, SIGNER_ADDR);
|
|
279
|
+
assert.strictEqual(body.submit_path, 'seller', '从 tx 事件里取到 submit_path');
|
|
280
|
+
|
|
281
|
+
const tx = lastTx();
|
|
282
|
+
assert.strictEqual(tx.messages[0].typeUrl, '/trustchain.order.v1.MsgConfirmOrder');
|
|
283
|
+
const v = tx.messages[0].value;
|
|
284
|
+
assert.strictEqual(v.buyer, BUYER_ADDR, 'buyer = 实际发起方记录 = 订单买家 (不是签名者)');
|
|
285
|
+
assert.strictEqual(v.submitter, SIGNER_ADDR, 'submitter = 签名者 = 本机卖家');
|
|
286
|
+
assert.notStrictEqual(v.buyer, v.submitter, '两个字段语义不同: buyer≠submitter');
|
|
287
|
+
assert.strictEqual(String(v.order_id), '7');
|
|
288
|
+
assert.strictEqual(String(v.rating), '5');
|
|
289
|
+
assert.strictEqual(v.review, '很好');
|
|
290
|
+
assert.strictEqual(tx.memo, '', 'confirm 不带 memo');
|
|
291
|
+
assert.ok(await verifySignatureBySeller(tx.txRaw), '签名者必须是本机卖家 (链上 submitter 白名单第 1 条)');
|
|
292
|
+
// auth_info 里的公钥也必须 = 本机卖家 (链上拿它对 submitter 字段做地址比对)
|
|
293
|
+
const { decodePubkey } = require('@cosmjs/proto-signing');
|
|
294
|
+
const { Secp256k1, EnglishMnemonic, Bip39, Slip10, Slip10Curve, stringToPath } = require('@cosmjs/crypto');
|
|
295
|
+
const seed = await Bip39.mnemonicToSeed(new EnglishMnemonic(VECTOR_MNEMONIC));
|
|
296
|
+
const { privkey } = Slip10.derivePath(Slip10Curve.Secp256k1, seed, stringToPath("m/44'/118'/0'/0/0"));
|
|
297
|
+
const kp = await Secp256k1.makeKeypair(privkey);
|
|
298
|
+
const expectedPubB64 = Buffer.from(Secp256k1.compressPubkey(kp.pubkey)).toString('base64');
|
|
299
|
+
const signerPub = decodePubkey(tx.authInfo.signerInfos[0].publicKey);
|
|
300
|
+
assert.strictEqual(signerPub.value, expectedPubB64, 'auth_info 公钥 = 本机卖家公钥 → 链上 address(submitter) 比对会通过');
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
test('confirm: buyer_address 与链上订单不符 → 400, 不发链 (不信 payload 的买家字段)', async () => {
|
|
304
|
+
reset(orderFixture({ status: 'ORDER_STATUS_SHIPPED' }));
|
|
305
|
+
const { status, body } = await post('/confirm', { orderId: '7', buyer_address: OTHER_ADDR });
|
|
306
|
+
assert.strictEqual(status, 400);
|
|
307
|
+
assert.strictEqual(body.error, 'buyer_mismatch');
|
|
308
|
+
assert.strictEqual(stub.state.broadcasts.length, 0);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
test('confirm: 状态不是 SHIPPED → 409 order_not_shipped, 不发链', async () => {
|
|
312
|
+
reset(orderFixture({ status: 'ORDER_STATUS_PAID' }));
|
|
313
|
+
const { status, body } = await post('/confirm', { orderId: '7' });
|
|
314
|
+
assert.strictEqual(status, 409);
|
|
315
|
+
assert.strictEqual(body.error, 'order_not_shipped');
|
|
316
|
+
assert.strictEqual(stub.state.broadcasts.length, 0);
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
test('confirm: 订单不属于本店 → 403 order_not_ours, 不发链', async () => {
|
|
320
|
+
reset(orderFixture({ status: 'ORDER_STATUS_SHIPPED', seller: OTHER_ADDR }));
|
|
321
|
+
const { status, body } = await post('/confirm', { orderId: '7' });
|
|
322
|
+
assert.strictEqual(status, 403);
|
|
323
|
+
assert.strictEqual(body.error, 'order_not_ours');
|
|
324
|
+
assert.strictEqual(stub.state.broadcasts.length, 0);
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
test('confirm: 订单不存在 (LCD 404) → 404 order_not_found', async () => {
|
|
328
|
+
reset(null);
|
|
329
|
+
const { status, body } = await post('/confirm', { orderId: '999' });
|
|
330
|
+
assert.strictEqual(status, 404);
|
|
331
|
+
assert.strictEqual(body.error, 'order_not_found');
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
test('confirm: rating 非法 → 400, 不发链', async () => {
|
|
335
|
+
reset(orderFixture({ status: 'ORDER_STATUS_SHIPPED' }));
|
|
336
|
+
const { status, body } = await post('/confirm', { orderId: '7', rating: '9' });
|
|
337
|
+
assert.strictEqual(status, 400);
|
|
338
|
+
assert.strictEqual(body.error, 'rating_invalid');
|
|
339
|
+
assert.strictEqual(stub.state.broadcasts.length, 0);
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
// ---------------------------------------------------------------- /cancel
|
|
343
|
+
|
|
344
|
+
test('cancel: 正向 — canceller 缺省记卖家, seller=签名者; proto 无 reason 字段', async () => {
|
|
345
|
+
reset(orderFixture({ status: 'ORDER_STATUS_PENDING' }));
|
|
346
|
+
const { status, body } = await post('/cancel', { orderId: '7', reason: '买家拍错了' });
|
|
347
|
+
assert.strictEqual(status, 200, JSON.stringify(body));
|
|
348
|
+
assert.strictEqual(body.canceller, SIGNER_ADDR);
|
|
349
|
+
assert.strictEqual(body.seller, SIGNER_ADDR);
|
|
350
|
+
assert.match(String(body.note), /reason/, 'reason 只本地记录, 要明确告知');
|
|
351
|
+
|
|
352
|
+
const tx = lastTx();
|
|
353
|
+
assert.strictEqual(tx.messages[0].typeUrl, '/trustchain.order.v1.MsgCancelOrder');
|
|
354
|
+
const v = tx.messages[0].value;
|
|
355
|
+
assert.strictEqual(v.canceller, SIGNER_ADDR);
|
|
356
|
+
assert.strictEqual(v.seller, SIGNER_ADDR, 'seller 字段 = 签名者 (keeper 校验必须 = 订单卖家)');
|
|
357
|
+
assert.strictEqual(String(v.order_id), '7');
|
|
358
|
+
assert.strictEqual(v.reason, undefined, 'MsgCancelOrder 没有 reason 字段 (不该被塞进去)');
|
|
359
|
+
assert.ok(await verifySignatureBySeller(tx.txRaw));
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
test('cancel: initiator=buyer → canceller 记买家 (卖家代买家取消)', async () => {
|
|
363
|
+
reset(orderFixture({ status: 'ORDER_STATUS_PENDING' }));
|
|
364
|
+
const { status, body } = await post('/cancel', { orderId: '7', initiator: 'buyer' });
|
|
365
|
+
assert.strictEqual(status, 200);
|
|
366
|
+
assert.strictEqual(body.canceller, BUYER_ADDR);
|
|
367
|
+
const v = lastTx().messages[0].value;
|
|
368
|
+
assert.strictEqual(v.canceller, BUYER_ADDR);
|
|
369
|
+
assert.strictEqual(v.seller, SIGNER_ADDR, '签名者仍是本机卖家');
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
test('cancel: 发起方既非买家也非卖家 → 400 party_not_in_order, 不发链', async () => {
|
|
373
|
+
reset(orderFixture({ status: 'ORDER_STATUS_PENDING' }));
|
|
374
|
+
const { status, body } = await post('/cancel', { orderId: '7', canceller: OTHER_ADDR });
|
|
375
|
+
assert.strictEqual(status, 400);
|
|
376
|
+
assert.strictEqual(body.error, 'party_not_in_order');
|
|
377
|
+
assert.strictEqual(stub.state.broadcasts.length, 0);
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
test('cancel: 状态不是 PENDING → 409 order_not_pending, 不发链', async () => {
|
|
381
|
+
reset(orderFixture({ status: 'ORDER_STATUS_SHIPPED' }));
|
|
382
|
+
const { status, body } = await post('/cancel', { orderId: '7' });
|
|
383
|
+
assert.strictEqual(status, 409);
|
|
384
|
+
assert.strictEqual(body.error, 'order_not_pending');
|
|
385
|
+
assert.strictEqual(stub.state.broadcasts.length, 0);
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
// ---------------------------------------------------------------- /dispute
|
|
389
|
+
|
|
390
|
+
test('dispute: 正向 — disputer 缺省记买家, submitter=卖家, memo=tb-auth:<64hex>, 意愿落库', async () => {
|
|
391
|
+
reset(orderFixture({ status: 'ORDER_STATUS_SHIPPED' }));
|
|
392
|
+
const evidence = 'ab'.repeat(32);
|
|
393
|
+
const { status, body } = await post('/dispute', { orderId: '7', reason: '货不对板', evidence_hash: evidence });
|
|
394
|
+
assert.strictEqual(status, 200, JSON.stringify(body));
|
|
395
|
+
assert.strictEqual(body.disputer, BUYER_ADDR, '缺省 = 卖家代买家立案');
|
|
396
|
+
assert.strictEqual(body.submitter, SIGNER_ADDR);
|
|
397
|
+
assert.strictEqual(body.submit_path, 'seller');
|
|
398
|
+
assert.strictEqual(body.evidence_hash, evidence);
|
|
399
|
+
assert.match(body.dispute_intent_hash, /^[0-9a-f]{64}$/);
|
|
400
|
+
assert.strictEqual(body.dispute_intent_memo, 'tb-auth:' + body.dispute_intent_hash);
|
|
401
|
+
|
|
402
|
+
const tx = lastTx();
|
|
403
|
+
assert.strictEqual(tx.messages[0].typeUrl, '/trustchain.order.v1.MsgDisputeOrder');
|
|
404
|
+
const v = tx.messages[0].value;
|
|
405
|
+
assert.strictEqual(v.disputer, BUYER_ADDR, 'disputer = 实际发起方 (不是签名者)');
|
|
406
|
+
assert.strictEqual(v.submitter, SIGNER_ADDR, 'submitter = 签名者');
|
|
407
|
+
assert.strictEqual(String(v.order_id), '7');
|
|
408
|
+
assert.strictEqual(v.reason, '货不对板');
|
|
409
|
+
assert.strictEqual(v.evidence_hash, evidence);
|
|
410
|
+
assert.strictEqual(tx.memo, body.dispute_intent_memo, 'memo 必须真的进 tx');
|
|
411
|
+
assert.ok(await verifySignatureBySeller(tx.txRaw));
|
|
412
|
+
|
|
413
|
+
// 意愿原文落库 + 可用原文复算回同一个 hash
|
|
414
|
+
const row = db.prepare('SELECT * FROM order_intent_log WHERE intent_hash = ?').get(body.dispute_intent_hash);
|
|
415
|
+
assert.ok(row, '申诉意愿必须落库');
|
|
416
|
+
assert.strictEqual(row.kind, 'tb.dispute.intent');
|
|
417
|
+
assert.strictEqual(row.order_id, '7');
|
|
418
|
+
assert.strictEqual(row.status, 'success');
|
|
419
|
+
assert.strictEqual(row.txhash, body.txhash);
|
|
420
|
+
const parsed = JSON.parse(row.intent_json);
|
|
421
|
+
assert.strictEqual(parsed.kind, 'tb.dispute.intent');
|
|
422
|
+
assert.strictEqual(parsed.evidence_hash, evidence);
|
|
423
|
+
const rehashed = orderIntent.buildDisputeIntentHash({
|
|
424
|
+
disputer: parsed.disputer, seller: parsed.seller, submitter: parsed.submitter,
|
|
425
|
+
order_id: parsed.order_id, reason: parsed.reason, evidence_hash: parsed.evidence_hash,
|
|
426
|
+
timestamp_ms: parsed.timestamp_ms,
|
|
427
|
+
});
|
|
428
|
+
assert.strictEqual(rehashed.hash, body.dispute_intent_hash, '原文复算 = 链上 memo 的 hash');
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
test('dispute: evidence_hash 非法 (不是 64 位小写 hex) → 400, 不发链', async () => {
|
|
432
|
+
reset(orderFixture({ status: 'ORDER_STATUS_SHIPPED' }));
|
|
433
|
+
for (const bad of ['xyz', 'AB'.repeat(32), 'ab'.repeat(31)]) {
|
|
434
|
+
const { status, body } = await post('/dispute', { orderId: '7', reason: 'x', evidence_hash: bad });
|
|
435
|
+
assert.strictEqual(status, 400, `${bad} 应被拒`);
|
|
436
|
+
assert.strictEqual(body.error, 'evidence_hash_invalid');
|
|
437
|
+
}
|
|
438
|
+
assert.strictEqual(stub.state.broadcasts.length, 0);
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
test('dispute: reason 缺失 → 400 reason_required, 不发链', async () => {
|
|
442
|
+
reset(orderFixture({ status: 'ORDER_STATUS_SHIPPED' }));
|
|
443
|
+
const { status, body } = await post('/dispute', { orderId: '7' });
|
|
444
|
+
assert.strictEqual(status, 400);
|
|
445
|
+
assert.strictEqual(body.error, 'reason_required');
|
|
446
|
+
assert.strictEqual(stub.state.broadcasts.length, 0);
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
test('dispute: 状态不允许 (PENDING) → 409 order_not_disputable, 不发链', async () => {
|
|
450
|
+
reset(orderFixture({ status: 'ORDER_STATUS_PENDING' }));
|
|
451
|
+
const { status, body } = await post('/dispute', { orderId: '7', reason: 'x' });
|
|
452
|
+
assert.strictEqual(status, 409);
|
|
453
|
+
assert.strictEqual(body.error, 'order_not_disputable');
|
|
454
|
+
assert.strictEqual(stub.state.broadcasts.length, 0);
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
test('dispute: CONFIRMED 但已结算 → 409 order_settled, 不发链', async () => {
|
|
458
|
+
reset(orderFixture({ status: 'ORDER_STATUS_CONFIRMED', settled: true }));
|
|
459
|
+
const { status, body } = await post('/dispute', { orderId: '7', reason: 'x' });
|
|
460
|
+
assert.strictEqual(status, 409);
|
|
461
|
+
assert.strictEqual(body.error, 'order_settled');
|
|
462
|
+
assert.strictEqual(stub.state.broadcasts.length, 0);
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
// ---------------------------------------------------------------- 链上拒绝
|
|
466
|
+
|
|
467
|
+
test('链上拒 (状态机) → 502 + hint=status_not_shipped + raw_log 原样回传', async () => {
|
|
468
|
+
reset(orderFixture({ status: 'ORDER_STATUS_SHIPPED' }),
|
|
469
|
+
{ code: 11, log: 'failed to execute message; message index: 0: order is not shipped, cannot confirm' });
|
|
470
|
+
const { status, body } = await post('/confirm', { orderId: '7' });
|
|
471
|
+
assert.strictEqual(status, 502);
|
|
472
|
+
assert.strictEqual(body.error, 'chain_tx_failed');
|
|
473
|
+
assert.strictEqual(body.hint, 'status_not_shipped');
|
|
474
|
+
assert.strictEqual(body.code, 11);
|
|
475
|
+
assert.match(body.raw_log, /order is not shipped, cannot confirm/, 'raw_log 必须原样, 不能吞');
|
|
476
|
+
stub.state.reject = null;
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
test('confirm: LCD 读不到订单 (fail-open) — 未带 buyer_address 时 503 拒发, 带了合法值则放行', async () => {
|
|
480
|
+
reset(orderFixture({ status: 'ORDER_STATUS_SHIPPED' }));
|
|
481
|
+
stub.state.orderUnavailable = true;
|
|
482
|
+
const noBuyer = await post('/confirm', { orderId: '7' });
|
|
483
|
+
assert.strictEqual(noBuyer.status, 503);
|
|
484
|
+
assert.strictEqual(noBuyer.body.error, 'order_lookup_unavailable');
|
|
485
|
+
assert.strictEqual(stub.state.broadcasts.length, 0, '宁可不发, 也不发一笔注定被链拒 (buyer 空) 的 tx');
|
|
486
|
+
const withBuyer = await post('/confirm', { orderId: '7', buyer_address: BUYER_ADDR });
|
|
487
|
+
assert.strictEqual(withBuyer.status, 200, JSON.stringify(withBuyer.body));
|
|
488
|
+
const v = lastTx().messages[0].value;
|
|
489
|
+
assert.strictEqual(v.buyer, BUYER_ADDR);
|
|
490
|
+
assert.strictEqual(v.submitter, SIGNER_ADDR);
|
|
491
|
+
stub.state.orderUnavailable = false;
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
test('链上拒 (submitter 不在白名单) → 502 + hint=submitter_not_allowed', async () => {
|
|
495
|
+
reset(orderFixture({ status: 'ORDER_STATUS_SHIPPED' }),
|
|
496
|
+
{ code: 5, log: "failed to execute message; message index: 0: only the order's seller, the dispute authority, or (after auto_confirm_timeout) any account can submit this; submitter=tct1xxx" });
|
|
497
|
+
const { status, body } = await post('/confirm', { orderId: '7' });
|
|
498
|
+
assert.strictEqual(status, 502);
|
|
499
|
+
assert.strictEqual(body.hint, 'submitter_not_allowed');
|
|
500
|
+
assert.match(body.raw_log, /only the order's seller/);
|
|
501
|
+
stub.state.reject = null;
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
// ---------------------------------------------------------------- 鉴权 / create 停用
|
|
505
|
+
|
|
506
|
+
test('未带 token / 错 token → 401 (操作员鉴权沿用 JWT 口径)', async () => {
|
|
507
|
+
reset(orderFixture({ status: 'ORDER_STATUS_PENDING' }));
|
|
508
|
+
assert.strictEqual((await post('/cancel', { orderId: '7' }, { token: '' })).status, 401);
|
|
509
|
+
assert.strictEqual((await post('/cancel', { orderId: '7' }, { token: 'bad' })).status, 401);
|
|
510
|
+
assert.strictEqual(stub.state.broadcasts.length, 0);
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
test('order_id 非数字 → 400 order_id_invalid, 不发链', async () => {
|
|
514
|
+
reset(orderFixture({ status: 'ORDER_STATUS_PENDING' }));
|
|
515
|
+
const { status, body } = await post('/cancel', { orderId: 'abc' });
|
|
516
|
+
assert.strictEqual(status, 400);
|
|
517
|
+
assert.strictEqual(body.error, 'order_id_invalid');
|
|
518
|
+
assert.strictEqual(stub.state.broadcasts.length, 0);
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
test('POST /create → 410 停用 + 指路 POST /api/orders (不做第二套下单)', async () => {
|
|
522
|
+
reset(orderFixture({ status: 'ORDER_STATUS_PENDING' }));
|
|
523
|
+
const { status, body } = await post('/create', { seller: SIGNER_ADDR, productId: 'sxo-1', amount: 1, price: 1 });
|
|
524
|
+
assert.strictEqual(status, 410);
|
|
525
|
+
assert.strictEqual(body.error, 'endpoint_gone');
|
|
526
|
+
assert.strictEqual(body.use, 'POST /api/orders');
|
|
527
|
+
assert.strictEqual(stub.state.broadcasts.length, 0, 'create 绝不发链');
|
|
528
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M0 私信止血 — 手动验证脚本
|
|
3
|
+
*
|
|
4
|
+
* 演示新模型(2026-07-30 M0 后):
|
|
5
|
+
* 1. 客户端自持钱包私钥(secp256k1)+ 消息私钥(RSA),服务端只注册公钥
|
|
6
|
+
* 2. 发送:客户端签名(X-Address/X-Pubkey/X-Signature/X-Timestamp/X-Nonce 五头)
|
|
7
|
+
* 3. 读取:服务端只回密文,解密在客户端
|
|
8
|
+
*
|
|
9
|
+
* 直接调插件层(不起 HTTP 服务);路由层的签名信封构造见 routes/p2p-message.ts 头注释。
|
|
10
|
+
* 运行: npx ts-node src/test-p2p-message.ts
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=test-p2p-message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-p2p-message.d.ts","sourceRoot":"","sources":["../src/test-p2p-message.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* M0 私信止血 — 手动验证脚本
|
|
4
|
+
*
|
|
5
|
+
* 演示新模型(2026-07-30 M0 后):
|
|
6
|
+
* 1. 客户端自持钱包私钥(secp256k1)+ 消息私钥(RSA),服务端只注册公钥
|
|
7
|
+
* 2. 发送:客户端签名(X-Address/X-Pubkey/X-Signature/X-Timestamp/X-Nonce 五头)
|
|
8
|
+
* 3. 读取:服务端只回密文,解密在客户端
|
|
9
|
+
*
|
|
10
|
+
* 直接调插件层(不起 HTTP 服务);路由层的签名信封构造见 routes/p2p-message.ts 头注释。
|
|
11
|
+
* 运行: npx ts-node src/test-p2p-message.ts
|
|
12
|
+
*/
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
46
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
const p2p_message_1 = require("./plugins/p2p-message");
|
|
48
|
+
const crypto = __importStar(require("crypto"));
|
|
49
|
+
async function testP2PMessage() {
|
|
50
|
+
console.log('🧪 M0 P2P Message — 新模型手动验证\n');
|
|
51
|
+
const p2pPlugin = new p2p_message_1.P2PMessagePlugin({ encryptionEnabled: true });
|
|
52
|
+
await p2pPlugin.init('./data/test-p2p-messages.db');
|
|
53
|
+
// 两个用户的链地址(演示用伪地址;真实场景由钱包 secp256k1 pubkey 派生)
|
|
54
|
+
const user1 = 'tct1user1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
|
|
55
|
+
const user2 = 'tct1user2bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb';
|
|
56
|
+
// ✅ M0:密钥对在客户端生成,私钥不出设备;服务端只注册公钥
|
|
57
|
+
console.log('1. 客户端生成消息密钥对(私钥自持)');
|
|
58
|
+
const user2Keys = crypto.generateKeyPairSync('rsa', {
|
|
59
|
+
modulusLength: 2048,
|
|
60
|
+
publicKeyEncoding: { type: 'spki', format: 'pem' },
|
|
61
|
+
privateKeyEncoding: { type: 'pkcs8', format: 'pem' }
|
|
62
|
+
});
|
|
63
|
+
p2pPlugin.registerPubkey(user2, user2Keys.publicKey);
|
|
64
|
+
console.log(' user2 公钥已注册到索引器(服务端无私钥)\n');
|
|
65
|
+
// ✅ M0:未注册公钥的接收者会被拒(不再"没公钥就存明文")
|
|
66
|
+
console.log('2. 反向用例:接收者未注册公钥 → 拒发');
|
|
67
|
+
try {
|
|
68
|
+
await p2pPlugin.sendMessage(user1, 'tct1nokeycccccccccccccccccccccccccccccccc', 'hello', 'text');
|
|
69
|
+
console.log(' ❌ 应该拒绝却成功了\n');
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
console.log(' ✅ 拒发:', e.message, '\n');
|
|
73
|
+
}
|
|
74
|
+
// 发送消息(真实场景 signature 由路由层验过的钱包签名传入)
|
|
75
|
+
console.log('3. 发送加密消息 user1 → user2');
|
|
76
|
+
const message1 = await p2pPlugin.sendMessage(user1, user2, 'Hello! This is a test message.', 'text', undefined, 'demo-sig');
|
|
77
|
+
console.log(' Message ID:', message1.id);
|
|
78
|
+
console.log(' Content (ciphertext):', message1.content.slice(0, 60) + '...\n');
|
|
79
|
+
// 服务端只回密文
|
|
80
|
+
console.log('4. 服务端读取(只回密文,无明文路径)');
|
|
81
|
+
const messages = await p2pPlugin.getMessages(user1, user2);
|
|
82
|
+
const row = messages[0];
|
|
83
|
+
console.log(' 服务端返回 content:', row.content.slice(0, 60) + '...');
|
|
84
|
+
console.log(' ✅ 服务端无明文(M0:decryptedContent 字段已删)\n');
|
|
85
|
+
// 客户端解密(私钥在客户端)
|
|
86
|
+
console.log('5. 客户端用自持私钥解密');
|
|
87
|
+
const [encryptedKeyB64, encrypted] = row.content.split(':');
|
|
88
|
+
const keyMaterial = crypto.privateDecrypt(user2Keys.privateKey, Buffer.from(encryptedKeyB64, 'base64'));
|
|
89
|
+
const key = keyMaterial.slice(0, 32);
|
|
90
|
+
const iv = keyMaterial.slice(32, 48);
|
|
91
|
+
const authTag = keyMaterial.slice(48);
|
|
92
|
+
const decipher = crypto.createDecipheriv('aes-256-gcm', key, iv);
|
|
93
|
+
decipher.setAuthTag(authTag);
|
|
94
|
+
let plain = decipher.update(encrypted, 'hex', 'utf8');
|
|
95
|
+
plain += decipher.final('utf8');
|
|
96
|
+
console.log(' 解密结果:', plain);
|
|
97
|
+
console.log(' ✅ 与原文一致:', plain === 'Hello! This is a test message.');
|
|
98
|
+
// 会话与未读数
|
|
99
|
+
const conversations = await p2pPlugin.getConversations(user1);
|
|
100
|
+
const unreadCount = await p2pPlugin.getUnreadCount(user2);
|
|
101
|
+
console.log('6. 会话数:', conversations.length, '/ user2 未读:', unreadCount);
|
|
102
|
+
await p2pPlugin.close();
|
|
103
|
+
console.log('\n✅ M0 新模型验证完成');
|
|
104
|
+
}
|
|
105
|
+
testP2PMessage().catch(console.error);
|
|
106
|
+
//# sourceMappingURL=test-p2p-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-p2p-message.js","sourceRoot":"","sources":["../src/test-p2p-message.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uDAAyD;AACzD,+CAAiC;AAEjC,KAAK,UAAU,cAAc;IAC3B,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAE7C,MAAM,SAAS,GAAG,IAAI,8BAAgB,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;IACpE,MAAM,SAAS,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;IAEpD,+CAA+C;IAC/C,MAAM,KAAK,GAAG,4CAA4C,CAAC;IAC3D,MAAM,KAAK,GAAG,4CAA4C,CAAC;IAE3D,iCAAiC;IACjC,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACnC,MAAM,SAAS,GAAG,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE;QAClD,aAAa,EAAE,IAAI;QACnB,iBAAiB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE;QAClD,kBAAkB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE;KACrD,CAAC,CAAC;IACH,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACrD,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;IAE5C,iCAAiC;IACjC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACrC,IAAI,CAAC;QACH,MAAM,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,2CAA2C,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QACjG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACjC,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,qCAAqC;IACrC,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,WAAW,CAC1C,KAAK,EAAE,KAAK,EAAE,gCAAgC,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,CAC9E,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC;IAEjF,UAAU;IACV,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;IACpC,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC3D,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACxB,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC;IACnE,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;IAEvD,gBAAgB;IAChB,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC7B,MAAM,CAAC,eAAe,EAAE,SAAS,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5D,MAAM,WAAW,GAAG,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC,CAAC;IACxG,MAAM,GAAG,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACrC,MAAM,EAAE,GAAG,WAAW,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACrC,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACtC,MAAM,QAAQ,GAAG,MAAM,CAAC,gBAAgB,CAAC,aAAa,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IACjE,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC7B,IAAI,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IACtD,KAAK,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAC/B,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,KAAK,gCAAgC,CAAC,CAAC;IAEvE,SAAS;IACT,MAAM,aAAa,GAAG,MAAM,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC9D,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC1D,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;IAEzE,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;IACxB,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AAChC,CAAC;AAED,cAAc,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|