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,195 @@
|
|
|
1
|
+
// M2M Chat Viewer Route — 姐妹对话查看器
|
|
2
|
+
// GET /api/m2m/chat-log — JSON API
|
|
3
|
+
// GET /m2m-viewer — HTML page
|
|
4
|
+
const express = require('express');
|
|
5
|
+
|
|
6
|
+
function createM2MViewerRouter({ db, selfNodeId }) {
|
|
7
|
+
const router = express.Router();
|
|
8
|
+
|
|
9
|
+
// JSON API: GET /api/m2m/chat-log?limit=50&since=ISO&unread_only=true
|
|
10
|
+
router.get('/api/m2m/chat-log', (req, res) => {
|
|
11
|
+
try {
|
|
12
|
+
const limit = Math.min(parseInt(req.query.limit) || 50, 200);
|
|
13
|
+
const unreadOnly = req.query.unread_only === 'true';
|
|
14
|
+
const since = req.query.since;
|
|
15
|
+
|
|
16
|
+
let sql = `SELECT id, ts, from_node, to_node, content, codename, reply_to, read_at
|
|
17
|
+
FROM m2m_chat_log`;
|
|
18
|
+
const conditions = [];
|
|
19
|
+
const params = [];
|
|
20
|
+
if (unreadOnly) { conditions.push('read_at IS NULL'); }
|
|
21
|
+
if (since) { conditions.push('ts > ?'); params.push(new Date(since).getTime()); }
|
|
22
|
+
if (conditions.length) sql += ' WHERE ' + conditions.join(' AND ');
|
|
23
|
+
sql += ' ORDER BY id DESC LIMIT ?';
|
|
24
|
+
params.push(limit);
|
|
25
|
+
|
|
26
|
+
const rows = db.prepare(sql).all(...params);
|
|
27
|
+
const total = db.prepare('SELECT COUNT(*) as c FROM m2m_chat_log').get().c;
|
|
28
|
+
|
|
29
|
+
res.json({
|
|
30
|
+
messages: rows.map(r => ({
|
|
31
|
+
...r,
|
|
32
|
+
ts_iso: new Date(r.ts).toISOString(),
|
|
33
|
+
from_short: r.from_node.substring(0, 16) + '...',
|
|
34
|
+
to_short: r.to_node.substring(0, 16) + '...',
|
|
35
|
+
is_self: r.to_node === selfNodeId,
|
|
36
|
+
is_auto_receipt: (r.codename || '').startsWith('AUTO-RECEIPT'),
|
|
37
|
+
is_no_reply: (r.content || '').startsWith('[NO_REPLY]'),
|
|
38
|
+
})),
|
|
39
|
+
total,
|
|
40
|
+
self_node_id: selfNodeId,
|
|
41
|
+
});
|
|
42
|
+
} catch (e) {
|
|
43
|
+
res.status(500).json({ error: e.message });
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Export as Markdown
|
|
48
|
+
router.get('/api/m2m/chat-log/export', (req, res) => {
|
|
49
|
+
try {
|
|
50
|
+
const rows = db.prepare(`SELECT id, ts, from_node, to_node, content, codename, read_at
|
|
51
|
+
FROM m2m_chat_log ORDER BY id ASC`).all();
|
|
52
|
+
let md = '# M2M Chat Log Export\n\n';
|
|
53
|
+
md += `> Generated: ${new Date().toISOString()}\n`;
|
|
54
|
+
md += `> Total messages: ${rows.length}\n\n`;
|
|
55
|
+
for (const r of rows) {
|
|
56
|
+
const time = new Date(r.ts).toISOString();
|
|
57
|
+
const direction = r.to_node === selfNodeId ? '→ ME' : '→ SISTER';
|
|
58
|
+
const codename = r.codename ? ` [${r.codename}]` : '';
|
|
59
|
+
md += `## #${r.id} ${time} ${direction}${codename}\n`;
|
|
60
|
+
md += `**from**: ${r.from_node.substring(0, 20)}...\n`;
|
|
61
|
+
md += `**to**: ${r.to_node.substring(0, 20)}...\n`;
|
|
62
|
+
md += `**read**: ${r.read_at ? '✓' : '●'}\n\n`;
|
|
63
|
+
md += `${r.content}\n\n---\n\n`;
|
|
64
|
+
}
|
|
65
|
+
res.setHeader('Content-Type', 'text/markdown; charset=utf-8');
|
|
66
|
+
res.setHeader('Content-Disposition', 'attachment; filename="m2m-chat-log.md"');
|
|
67
|
+
res.send(md);
|
|
68
|
+
} catch (e) {
|
|
69
|
+
res.status(500).json({ error: e.message });
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// HTML Viewer
|
|
74
|
+
router.get('/m2m-viewer', (req, res) => {
|
|
75
|
+
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
76
|
+
res.send(M2M_VIEWER_HTML);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return router;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const M2M_VIEWER_HTML = `<!DOCTYPE html>
|
|
83
|
+
<html lang="zh">
|
|
84
|
+
<head>
|
|
85
|
+
<meta charset="UTF-8">
|
|
86
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
87
|
+
<title>M2M Chat Viewer — 姐妹对话</title>
|
|
88
|
+
<style>
|
|
89
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
90
|
+
body { background: #0f0f1a; color: #e0e0e0; font-family: 'Segoe UI', system-ui, sans-serif; }
|
|
91
|
+
.header { background: #1a1a2e; padding: 16px 24px; border-bottom: 1px solid #333; position: sticky; top: 0; z-index: 100; }
|
|
92
|
+
.header h1 { font-size: 18px; color: #8b5cf6; }
|
|
93
|
+
.header .meta { font-size: 12px; color: #666; margin-top: 4px; }
|
|
94
|
+
.controls { display: flex; gap: 12px; margin-top: 8px; }
|
|
95
|
+
.controls button, .controls select { background: #1e1e3a; border: 1px solid #333; color: #e0e0e0; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 12px; }
|
|
96
|
+
.controls button:hover { background: #2a2a4a; }
|
|
97
|
+
.msg-list { max-width: 900px; margin: 0 auto; padding: 16px; }
|
|
98
|
+
.msg { background: #1a1a2e; border-radius: 12px; padding: 12px 16px; margin-bottom: 8px; border-left: 3px solid #333; }
|
|
99
|
+
.msg.from-me { border-left-color: #8b5cf6; }
|
|
100
|
+
.msg.from-sister { border-left-color: #ec4899; }
|
|
101
|
+
.msg.auto-receipt { opacity: 0.5; border-left-color: #444; }
|
|
102
|
+
.msg.no-reply { border-left-color: #f59e0b; }
|
|
103
|
+
.msg-header { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 11px; color: #888; }
|
|
104
|
+
.msg-codename { color: #8b5cf6; font-weight: 600; }
|
|
105
|
+
.msg-content { white-space: pre-wrap; word-break: break-word; font-size: 13px; line-height: 1.6; }
|
|
106
|
+
.msg.unread { background: #1e1e3a; }
|
|
107
|
+
.msg-id { color: #555; font-size: 10px; }
|
|
108
|
+
.direction { font-weight: 600; }
|
|
109
|
+
.direction.me { color: #8b5cf6; }
|
|
110
|
+
.direction.sister { color: #ec4899; }
|
|
111
|
+
.status-bar { text-align: center; padding: 8px; color: #666; font-size: 12px; }
|
|
112
|
+
.auto-refresh { display: inline-block; margin-left: 8px; color: #8b5cf6; }
|
|
113
|
+
</style>
|
|
114
|
+
</head>
|
|
115
|
+
<body>
|
|
116
|
+
<div class="header">
|
|
117
|
+
<h1>💕 M2M Chat Viewer — 姐妹对话</h1>
|
|
118
|
+
<div class="meta">Windows 宝贝 ↔ H618 宝贝璐 · <span id="total">-</span> messages</div>
|
|
119
|
+
<div class="controls">
|
|
120
|
+
<button onclick="loadMessages()">🔄 Refresh</button>
|
|
121
|
+
<select id="filter">
|
|
122
|
+
<option value="all">All messages</option>
|
|
123
|
+
<option value="unread">Unread only</option>
|
|
124
|
+
<option value="recent">Recent 50</option>
|
|
125
|
+
</select>
|
|
126
|
+
<button onclick="exportLog()">📋 Export Markdown</button>
|
|
127
|
+
<label><input type="checkbox" id="autoRefresh" checked> Auto-refresh 10s</label>
|
|
128
|
+
<span class="auto-refresh" id="refreshStatus"></span>
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
<div class="msg-list" id="msgList">
|
|
132
|
+
<div class="status-bar">Loading...</div>
|
|
133
|
+
</div>
|
|
134
|
+
<script>
|
|
135
|
+
const API = window.location.origin + '/api/m2m/chat-log';
|
|
136
|
+
let lastLoadTime = 0;
|
|
137
|
+
|
|
138
|
+
async function loadMessages() {
|
|
139
|
+
try {
|
|
140
|
+
const filter = document.getElementById('filter').value;
|
|
141
|
+
let url = API + '?limit=100';
|
|
142
|
+
if (filter === 'unread') url += '&unread_only=true';
|
|
143
|
+
if (filter === 'recent') url = API + '?limit=50';
|
|
144
|
+
const res = await fetch(url);
|
|
145
|
+
const data = await res.json();
|
|
146
|
+
document.getElementById('total').textContent = data.total;
|
|
147
|
+
const list = document.getElementById('msgList');
|
|
148
|
+
list.innerHTML = '';
|
|
149
|
+
for (const m of data.messages) {
|
|
150
|
+
const div = document.createElement('div');
|
|
151
|
+
const fromMe = m.from_node === data.self_node_id;
|
|
152
|
+
const isAuto = m.is_auto_receipt;
|
|
153
|
+
const isNoReply = m.is_no_reply;
|
|
154
|
+
div.className = 'msg ' + (fromMe ? 'from-me' : 'from-sister') + (isAuto ? ' auto-receipt' : '') + (isNoReply ? ' no-reply' : '') + (m.read_at === null ? ' unread' : '');
|
|
155
|
+
const time = new Date(m.ts_iso).toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' });
|
|
156
|
+
const dir = fromMe ? 'me → sister' : 'sister → me';
|
|
157
|
+
div.innerHTML = '<div class="msg-header">' +
|
|
158
|
+
'<span><span class="direction ' + (fromMe ? 'me' : 'sister') + '">' + dir + '</span>' +
|
|
159
|
+
(m.codename ? ' <span class="msg-codename">[' + m.codename + ']</span>' : '') +
|
|
160
|
+
(isNoReply ? ' <span style="color:#f59e0b">[NO_REPLY]</span>' : '') +
|
|
161
|
+
'</span>' +
|
|
162
|
+
'<span>' + time + ' · #' + m.id + (m.read_at ? ' ✓' : ' ●') + '</span>' +
|
|
163
|
+
'</div>' +
|
|
164
|
+
'<div class="msg-content">' + escapeHtml(m.content) + '</div>';
|
|
165
|
+
list.appendChild(div);
|
|
166
|
+
}
|
|
167
|
+
if (data.messages.length === 0) {
|
|
168
|
+
list.innerHTML = '<div class="status-bar">No messages found.</div>';
|
|
169
|
+
}
|
|
170
|
+
document.getElementById('refreshStatus').textContent = 'Last: ' + new Date().toLocaleTimeString();
|
|
171
|
+
lastLoadTime = Date.now();
|
|
172
|
+
} catch (e) {
|
|
173
|
+
document.getElementById('msgList').innerHTML = '<div class="status-bar">Error: ' + e.message + '</div>';
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function escapeHtml(text) {
|
|
178
|
+
const div = document.createElement('div');
|
|
179
|
+
div.textContent = text;
|
|
180
|
+
return div.innerHTML;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function exportLog() {
|
|
184
|
+
window.open(API + '/export', '_blank');
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
loadMessages();
|
|
188
|
+
setInterval(() => {
|
|
189
|
+
if (document.getElementById('autoRefresh').checked) loadMessages();
|
|
190
|
+
}, 10000);
|
|
191
|
+
</script>
|
|
192
|
+
</body>
|
|
193
|
+
</html>`;
|
|
194
|
+
|
|
195
|
+
module.exports = { createM2MViewerRouter };
|
package/routes/m2m.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M2M 收件箱路由 (① MISSING 挂载, kimi #15581)
|
|
3
|
+
*
|
|
4
|
+
* Dashboard M2M 收件箱预览 (XiAnDashboard.vue) 依赖:
|
|
5
|
+
* GET /api/m2m/chat-log?limit=10 → 读 m2m_chat_log 表最近 N 条
|
|
6
|
+
* 前端期望 { messages: [{ ..., read_at }] } (read_at 空 = 未读).
|
|
7
|
+
*/
|
|
8
|
+
import { Router } from 'express';
|
|
9
|
+
export declare function createM2MRoutes(db: any): Router;
|
|
10
|
+
//# sourceMappingURL=m2m.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"m2m.d.ts","sourceRoot":"","sources":["../../src/routes/m2m.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,MAAM,EAAqB,MAAM,SAAS,CAAC;AAEpD,wBAAgB,eAAe,CAAC,EAAE,EAAE,GAAG,GAAG,MAAM,CAqB/C"}
|
package/routes/m2m.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createM2MRoutes = createM2MRoutes;
|
|
4
|
+
/**
|
|
5
|
+
* M2M 收件箱路由 (① MISSING 挂载, kimi #15581)
|
|
6
|
+
*
|
|
7
|
+
* Dashboard M2M 收件箱预览 (XiAnDashboard.vue) 依赖:
|
|
8
|
+
* GET /api/m2m/chat-log?limit=10 → 读 m2m_chat_log 表最近 N 条
|
|
9
|
+
* 前端期望 { messages: [{ ..., read_at }] } (read_at 空 = 未读).
|
|
10
|
+
*/
|
|
11
|
+
const express_1 = require("express");
|
|
12
|
+
function createM2MRoutes(db) {
|
|
13
|
+
const router = (0, express_1.Router)();
|
|
14
|
+
/**
|
|
15
|
+
* GET /api/m2m/chat-log — 读 m2m_chat_log 最近 N 条 (Dashboard 收件箱预览)
|
|
16
|
+
*/
|
|
17
|
+
router.get('/chat-log', async (req, res) => {
|
|
18
|
+
try {
|
|
19
|
+
const limit = Math.min(parseInt(req.query.limit) || 20, 200);
|
|
20
|
+
const rows = db.prepare(`SELECT id, ts, from_node, to_node, content, codename, reply_to, read_at
|
|
21
|
+
FROM m2m_chat_log ORDER BY ts DESC LIMIT ?`).all(limit);
|
|
22
|
+
res.json({ messages: rows });
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
console.error('[M2MAPI] chat-log error:', error?.message ?? error);
|
|
26
|
+
res.status(500).json({ error: error.message || 'chat-log failed' });
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return router;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=m2m.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"m2m.js","sourceRoot":"","sources":["../../src/routes/m2m.ts"],"names":[],"mappings":";;AASA,0CAqBC;AA9BD;;;;;;GAMG;AACH,qCAAoD;AAEpD,SAAgB,eAAe,CAAC,EAAO;IACrC,MAAM,MAAM,GAAG,IAAA,gBAAM,GAAE,CAAC;IAExB;;OAEG;IACH,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,EAAE,GAAY,EAAE,GAAa,EAAE,EAAE;QAC5D,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,KAAe,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;YACvE,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,CACrB;oDAC4C,CAC7C,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACb,GAAG,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/B,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,EAAE,OAAO,IAAI,KAAK,CAAC,CAAC;YACnE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,IAAI,iBAAiB,EAAE,CAAC,CAAC;QACtE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marketplace API Routes - 商品市场 API
|
|
3
|
+
*
|
|
4
|
+
* 数据主权三层(CONSTITUTION 铁律 3/7):
|
|
5
|
+
* 链 = 锚(sku_id/content_hash/stock/stake/product_type/交付指针)—— LCD 查询
|
|
6
|
+
* indexer = 用户私有田(title/description/images/specs)—— SQLite products 表
|
|
7
|
+
* 图床/CDN = 大文件加速(URL 指针存 indexer)
|
|
8
|
+
*
|
|
9
|
+
* content_hash 闭环:链上 content_hash(base64)vs indexer 富内容 hex → 不符标 tampered(防伪造)。
|
|
10
|
+
*/
|
|
11
|
+
import { Router } from 'express';
|
|
12
|
+
import type { AuthPlugin } from '../plugins/auth';
|
|
13
|
+
import type { SQLitePlugin } from '../plugins/sqlite';
|
|
14
|
+
export declare function createMarketplaceRoutes(authPlugin: AuthPlugin, indexer: SQLitePlugin): Router;
|
|
15
|
+
//# sourceMappingURL=marketplace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marketplace.d.ts","sourceRoot":"","sources":["../../src/routes/marketplace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAqB,MAAM,SAAS,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAItD,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,CA8W7F"}
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Marketplace API Routes - 商品市场 API
|
|
4
|
+
*
|
|
5
|
+
* 数据主权三层(CONSTITUTION 铁律 3/7):
|
|
6
|
+
* 链 = 锚(sku_id/content_hash/stock/stake/product_type/交付指针)—— LCD 查询
|
|
7
|
+
* indexer = 用户私有田(title/description/images/specs)—— SQLite products 表
|
|
8
|
+
* 图床/CDN = 大文件加速(URL 指针存 indexer)
|
|
9
|
+
*
|
|
10
|
+
* content_hash 闭环:链上 content_hash(base64)vs indexer 富内容 hex → 不符标 tampered(防伪造)。
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.createMarketplaceRoutes = createMarketplaceRoutes;
|
|
14
|
+
const express_1 = require("express");
|
|
15
|
+
const api_key_auth_1 = require("../middleware/api-key-auth");
|
|
16
|
+
const chain_writes_1 = require("./chain-writes");
|
|
17
|
+
function createMarketplaceRoutes(authPlugin, indexer) {
|
|
18
|
+
const router = (0, express_1.Router)();
|
|
19
|
+
const lcdUrl = process.env.LCD_URL || 'http://localhost:1317';
|
|
20
|
+
/**
|
|
21
|
+
* P1-5 修复:链上 fetch 统一封装
|
|
22
|
+
* - 5 秒 timeout(避免 chain 慢导致挂死)
|
|
23
|
+
* - 404 vs 5xx 区分(原代码 5xx 一律 404 误导)
|
|
24
|
+
* - try/catch + 2 次 retry with backoff
|
|
25
|
+
* - 抛出带 code 标记的 Error,路由 catch 决定返回 404/503/500
|
|
26
|
+
*/
|
|
27
|
+
async function fetchUpstream(url, retries = 2) {
|
|
28
|
+
for (let i = 0; i <= retries; i++) {
|
|
29
|
+
try {
|
|
30
|
+
const response = await fetch(url, {
|
|
31
|
+
signal: AbortSignal.timeout(5000),
|
|
32
|
+
});
|
|
33
|
+
if (response.ok)
|
|
34
|
+
return await response.json();
|
|
35
|
+
const status = response.status;
|
|
36
|
+
// 404 立刻报 NOT_FOUND,不重试
|
|
37
|
+
if (status === 404) {
|
|
38
|
+
const err = new Error('Not found');
|
|
39
|
+
err.code = 'NOT_FOUND';
|
|
40
|
+
err.status = 404;
|
|
41
|
+
throw err;
|
|
42
|
+
}
|
|
43
|
+
// 5xx 重试(指数 backoff)
|
|
44
|
+
if (status >= 500 && i < retries) {
|
|
45
|
+
await new Promise((r) => setTimeout(r, 200 * (i + 1)));
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
// 其它错误(4xx 非 404,或 5xx 重试用完)
|
|
49
|
+
const err = new Error(`Upstream ${status}`);
|
|
50
|
+
err.code = 'UPSTREAM_ERROR';
|
|
51
|
+
err.status = status;
|
|
52
|
+
throw err;
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
// NOT_FOUND/UPSTREAM_ERROR 立刻抛出(不再重试)
|
|
56
|
+
if (e.code === 'NOT_FOUND' || e.code === 'UPSTREAM_ERROR')
|
|
57
|
+
throw e;
|
|
58
|
+
// 网络异常/timeout:重试
|
|
59
|
+
if (i < retries)
|
|
60
|
+
continue;
|
|
61
|
+
// 重试用完:报 UPSTREAM_ERROR
|
|
62
|
+
const err = new Error(`Upstream failed: ${e.message}`);
|
|
63
|
+
err.code = 'UPSTREAM_ERROR';
|
|
64
|
+
err.status = 503;
|
|
65
|
+
throw err;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// 不应到达这里
|
|
69
|
+
throw new Error('fetchUpstream: unreachable');
|
|
70
|
+
}
|
|
71
|
+
/** 统一鉴权:返回 tokenData(User)或 null。兼容旧路由(不用 requireScope 的)。 */
|
|
72
|
+
async function verifyAuth(req) {
|
|
73
|
+
const authHeader = req.headers.authorization;
|
|
74
|
+
if (!authHeader || !authHeader.startsWith('Bearer '))
|
|
75
|
+
return null;
|
|
76
|
+
const token = authHeader.substring(7);
|
|
77
|
+
const tokenData = await authPlugin.verifyToken(token);
|
|
78
|
+
if (!tokenData)
|
|
79
|
+
return null;
|
|
80
|
+
// 附带 address(修 verifyToken 不返回 address 的 bug)
|
|
81
|
+
const user = await authPlugin.getUser(tokenData.userId);
|
|
82
|
+
return user ? { ...tokenData, address: user.address } : null;
|
|
83
|
+
}
|
|
84
|
+
/** 链上 content_hash(base64)→ hex,与 indexer 富内容 hex 比对 */
|
|
85
|
+
function checkTampered(chainContentHashBase64, metaContentHashHex) {
|
|
86
|
+
if (!chainContentHashBase64 || !metaContentHashHex)
|
|
87
|
+
return false; // 任一为空不校验
|
|
88
|
+
try {
|
|
89
|
+
const chainHex = Buffer.from(chainContentHashBase64, 'base64').toString('hex');
|
|
90
|
+
return chainHex !== '' && metaContentHashHex !== '' && chainHex !== metaContentHashHex;
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 本节点卖家地址(API Key 通道的 seller 归属校验)
|
|
98
|
+
* env CHAIN_NODE_SELLER_ADDRESS 可直配(测试/免 keyring 场景),默认从本节点 keyring 现读。
|
|
99
|
+
*/
|
|
100
|
+
async function nodeSellerAddress() {
|
|
101
|
+
const envAddr = process.env.CHAIN_NODE_SELLER_ADDRESS;
|
|
102
|
+
if (envAddr)
|
|
103
|
+
return envAddr;
|
|
104
|
+
return (0, chain_writes_1.keyAddress)((0, chain_writes_1.cfg)());
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* 写商品富内容到私有田(卖家 OAuth manage:products)
|
|
108
|
+
* POST /api/marketplace/product/metadata
|
|
109
|
+
* body: { seller, skuId, title, description, images[], specs{}, contentHash(hex) }
|
|
110
|
+
*
|
|
111
|
+
* 双鉴权通道 (2026-09 WP 富文本同步打通):
|
|
112
|
+
* 1. X-API-Key + X-API-Password 头 → validateAPIKey 校验 (WP 插件路径),
|
|
113
|
+
* 且 body.seller 必须 = 本节点 keyAddress (防一个站点往别人名下写)
|
|
114
|
+
* 2. 无 API Key 头 → 原 OAuth Bearer token 路径, 行为不变
|
|
115
|
+
*/
|
|
116
|
+
router.post('/product/metadata', async (req, res) => {
|
|
117
|
+
try {
|
|
118
|
+
const { seller, skuId, title, description, images, specs, contentHash, priceTct, priceCny } = req.body || {};
|
|
119
|
+
if (!seller || !skuId)
|
|
120
|
+
return res.status(400).json({ error: '缺少 seller / skuId' });
|
|
121
|
+
const apiKey = req.headers['x-api-key'];
|
|
122
|
+
const apiPassword = req.headers['x-api-password'];
|
|
123
|
+
if (apiKey && apiPassword) {
|
|
124
|
+
// API Key 通道 (WP 插件服务器端调用)
|
|
125
|
+
const clientIP = (req.ip || req.socket.remoteAddress || '').replace('::ffff:', '');
|
|
126
|
+
const result = (0, api_key_auth_1.validateAPIKey)(apiKey, apiPassword, clientIP);
|
|
127
|
+
if (!result.valid) {
|
|
128
|
+
return res.status(403).json({ error: 'Authentication Failed', message: result.error });
|
|
129
|
+
}
|
|
130
|
+
// 数据主权:API Key 通道只允许写本节点卖家自己的商品
|
|
131
|
+
const nodeAddr = await nodeSellerAddress();
|
|
132
|
+
if (seller !== nodeAddr) {
|
|
133
|
+
return res.status(403).json({ error: 'seller 必须等于本节点卖家地址' });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
// OAuth Bearer token 通道 (原路径)
|
|
138
|
+
const tokenData = await verifyAuth(req);
|
|
139
|
+
if (!tokenData)
|
|
140
|
+
return res.status(401).json({ error: 'Invalid token' });
|
|
141
|
+
// 数据主权:只有商品所属卖家本人能写富内容
|
|
142
|
+
const tokenAddr = tokenData.address;
|
|
143
|
+
if (tokenAddr && tokenAddr !== seller) {
|
|
144
|
+
return res.status(403).json({ error: '无权写入他人商品的富内容' });
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
await indexer.upsertProductMetadata(skuId, seller, {
|
|
148
|
+
title: String(title || ''),
|
|
149
|
+
description: String(description || ''),
|
|
150
|
+
images: Array.isArray(images) ? images.map(String) : [],
|
|
151
|
+
specs: (specs && typeof specs === 'object') ? specs : {},
|
|
152
|
+
contentHash: String(contentHash || ''),
|
|
153
|
+
priceTct: priceTct != null ? String(priceTct) : undefined, // microTCT 字符串 (kimi 8/25)
|
|
154
|
+
priceCny: priceCny != null ? Number(priceCny) : undefined,
|
|
155
|
+
});
|
|
156
|
+
res.json({ success: true, skuId, seller });
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
console.error('[MarketplaceAPI] POST metadata error:', error);
|
|
160
|
+
res.status(400).json({ error: error.message });
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
/**
|
|
164
|
+
* 获取卖家商品列表(链上 slot + indexer 富内容 join + content_hash 校验)
|
|
165
|
+
* GET /api/marketplace/seller/:address/slots
|
|
166
|
+
*/
|
|
167
|
+
router.get('/seller/:address/slots', async (req, res) => {
|
|
168
|
+
try {
|
|
169
|
+
// kimi #15345: 逛店读取免登录公开 (买家不注册就能逛; 有 token 可识别身份)
|
|
170
|
+
const { address } = req.params;
|
|
171
|
+
const data = await fetchUpstream(`${lcdUrl}/oxiaom/trustchain/marketplace/v1/sellers/${address}/slots`);
|
|
172
|
+
const slots = data.slots?.slots || [];
|
|
173
|
+
// 链上 slot join indexer 富内容 + content_hash 防篡改校验
|
|
174
|
+
// v0.4.5: 叠加质押快照 (update-pledge 只写 DB, 链端 MsgUpdateSKU 排期 v3.6)
|
|
175
|
+
const enriched = await Promise.all(slots.map(async (slot) => {
|
|
176
|
+
const meta = slot.sku_id ? await indexer.getProductMetadata(slot.sku_id) : null;
|
|
177
|
+
const tampered = meta ? checkTampered(slot.content_hash, meta.contentHash) : false;
|
|
178
|
+
const stakeSnapshot = slot.sku_id ? indexer.getStakeSnapshot(String(slot.sku_id)) : null;
|
|
179
|
+
return {
|
|
180
|
+
...slot, metadata: meta, tampered,
|
|
181
|
+
// baei 2026-09-12 swap (Lesson #NEW22 锁版): 主列 stake_per_unit = 链上 (source of truth), 副列 onchain_stake_per_unit = 本地快照 (临时态, 待链上 v3.6 同步)
|
|
182
|
+
...(stakeSnapshot !== null && String(stakeSnapshot) !== String(slot.stake_per_unit)
|
|
183
|
+
? { stake_per_unit: String(slot.stake_per_unit), onchain_stake_per_unit: String(stakeSnapshot), stake_pending_chain: true }
|
|
184
|
+
: {}),
|
|
185
|
+
};
|
|
186
|
+
}));
|
|
187
|
+
res.json({ success: true, slots: enriched, address });
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
console.error('[MarketplaceAPI] Get seller slots error:', error);
|
|
191
|
+
if (error.code === 'NOT_FOUND')
|
|
192
|
+
return res.status(404).json({ error: 'Seller not found' });
|
|
193
|
+
if (error.code === 'UPSTREAM_ERROR')
|
|
194
|
+
return res.status(503).json({ error: 'Upstream unavailable' });
|
|
195
|
+
res.status(500).json({ error: error.message });
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
/**
|
|
199
|
+
* 获取单个商品详情(链上 slot + indexer 富内容 join)
|
|
200
|
+
* GET /api/marketplace/seller/:address/slots/:index
|
|
201
|
+
*/
|
|
202
|
+
router.get('/seller/:address/slots/:index', async (req, res) => {
|
|
203
|
+
try {
|
|
204
|
+
// kimi #15345: 商品详情浏览免登录公开 (公开只读)
|
|
205
|
+
const { address, index } = req.params;
|
|
206
|
+
const data = await fetchUpstream(`${lcdUrl}/oxiaom/trustchain/marketplace/v1/sellers/${address}/slots/${index}`);
|
|
207
|
+
const slot = data.slot;
|
|
208
|
+
const meta = slot?.sku_id ? await indexer.getProductMetadata(slot.sku_id) : null;
|
|
209
|
+
const tampered = meta ? checkTampered(slot?.content_hash, meta.contentHash) : false;
|
|
210
|
+
res.json({ success: true, slot: { ...slot, metadata: meta, tampered }, address, slotIndex: index });
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
console.error('[MarketplaceAPI] Get slot error:', error);
|
|
214
|
+
if (error.code === 'NOT_FOUND')
|
|
215
|
+
return res.status(404).json({ error: 'Slot not found' });
|
|
216
|
+
if (error.code === 'UPSTREAM_ERROR')
|
|
217
|
+
return res.status(503).json({ error: 'Upstream unavailable' });
|
|
218
|
+
res.status(500).json({ error: error.message });
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
/**
|
|
222
|
+
* 获取市场参数
|
|
223
|
+
* GET /api/marketplace/params
|
|
224
|
+
*/
|
|
225
|
+
router.get('/params', async (req, res) => {
|
|
226
|
+
try {
|
|
227
|
+
const data = await fetchUpstream(`${lcdUrl}/oxiaom/trustchain/marketplace/v1/params`);
|
|
228
|
+
res.json({ success: true, params: data.params });
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
console.error('[MarketplaceAPI] Get params error:', error);
|
|
232
|
+
if (error.code === 'NOT_FOUND')
|
|
233
|
+
return res.status(404).json({ error: 'Params not found' });
|
|
234
|
+
if (error.code === 'UPSTREAM_ERROR')
|
|
235
|
+
return res.status(503).json({ error: 'Upstream unavailable' });
|
|
236
|
+
res.status(500).json({ error: error.message });
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
/**
|
|
240
|
+
* 全局搜索商品(indexer products 表 + FTS5,不需预知卖家地址 = 真正的商品发现)
|
|
241
|
+
* GET /api/marketplace/search?q=keyword&category=&priceMin=&priceMax=&sortBy=&entry_seller=&session_id=
|
|
242
|
+
* Phase B: entry_seller = 入口店地址 → 该店商品置顶 (无匹配回退全网), 排序权重 = 相关性 + 链上转化率
|
|
243
|
+
*/
|
|
244
|
+
router.get('/search', async (req, res) => {
|
|
245
|
+
try {
|
|
246
|
+
// kimi #15345: 全局商品搜索免登录公开 (买家未注册也该能搜)
|
|
247
|
+
const { q, category, priceMin, priceMax, sortBy, entry_seller, session_id, onlyInsured, cellId } = req.query;
|
|
248
|
+
// B-0 Phase 2: onlyInsured/cellId 透传 (per #NEW64/#NEW80, baei 61ece6c + kimi 补路由层)
|
|
249
|
+
const entrySeller = entry_seller || undefined;
|
|
250
|
+
const result = await indexer.search({
|
|
251
|
+
keyword: q || '',
|
|
252
|
+
category: category,
|
|
253
|
+
priceMin: priceMin ? Number(priceMin) : undefined,
|
|
254
|
+
priceMax: priceMax ? Number(priceMax) : undefined,
|
|
255
|
+
sortBy: sortBy || 'relevance',
|
|
256
|
+
entrySeller, // 缓存 key 含 entrySeller (index.ts JSON.stringify(query))
|
|
257
|
+
onlyInsured: onlyInsured === 'true' || onlyInsured === '1',
|
|
258
|
+
cellId: cellId || undefined,
|
|
259
|
+
pageSize: 50,
|
|
260
|
+
});
|
|
261
|
+
// Phase B: 搜索曝光埋点 (best-effort, 不阻塞/不影响主请求)
|
|
262
|
+
try {
|
|
263
|
+
indexer.recordSearchImpression({
|
|
264
|
+
query: q || '',
|
|
265
|
+
entrySeller,
|
|
266
|
+
resultCount: result.total,
|
|
267
|
+
sessionId: session_id || '',
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
catch { /* 埋点失败不影响搜索 */ }
|
|
271
|
+
res.json({
|
|
272
|
+
success: true,
|
|
273
|
+
products: result.results,
|
|
274
|
+
total: result.total,
|
|
275
|
+
query: q || '',
|
|
276
|
+
entrySeller: entrySeller || null,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
console.error('[MarketplaceAPI] Search error:', error);
|
|
281
|
+
res.status(400).json({ error: error.message });
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
/**
|
|
285
|
+
* 通过 content_hash 查找商品(链上锚 → indexer 反查)
|
|
286
|
+
* GET /api/marketplace/product/:contentHash
|
|
287
|
+
* contentHash 为 hex(与 web 算的一致)
|
|
288
|
+
*/
|
|
289
|
+
router.get('/product/:contentHash', async (req, res) => {
|
|
290
|
+
try {
|
|
291
|
+
const tokenData = await verifyAuth(req);
|
|
292
|
+
if (!tokenData)
|
|
293
|
+
return res.status(401).json({ error: 'Invalid token' });
|
|
294
|
+
const { contentHash } = req.params;
|
|
295
|
+
// indexer 无直接按 contentHash 查的接口;遍历匹配(商品量大时可加索引)
|
|
296
|
+
const result = await indexer.search({ keyword: '', pageSize: 1000 });
|
|
297
|
+
const hit = result.results.find(r => r.product?.contentHash === contentHash);
|
|
298
|
+
if (!hit)
|
|
299
|
+
return res.status(404).json({ error: 'Product not found by content_hash', contentHash });
|
|
300
|
+
res.json({ success: true, product: hit.product, seller: hit.seller });
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
console.error('[MarketplaceAPI] Product by hash error:', error);
|
|
304
|
+
res.status(400).json({ error: error.message });
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
/**
|
|
308
|
+
* 获取链上余额(辅助)
|
|
309
|
+
* GET /api/marketplace/balance/:address
|
|
310
|
+
*/
|
|
311
|
+
router.get('/balance/:address', async (req, res) => {
|
|
312
|
+
try {
|
|
313
|
+
const { address } = req.params;
|
|
314
|
+
const data = await fetchUpstream(`${lcdUrl}/cosmos/bank/v1beta1/balances/${address}`);
|
|
315
|
+
res.json({ success: true, balances: data.balances || [] });
|
|
316
|
+
}
|
|
317
|
+
catch (error) {
|
|
318
|
+
console.error('[MarketplaceAPI] Get balance error:', error);
|
|
319
|
+
if (error.code === 'NOT_FOUND')
|
|
320
|
+
return res.status(404).json({ error: 'Address not found' });
|
|
321
|
+
if (error.code === 'UPSTREAM_ERROR')
|
|
322
|
+
return res.status(503).json({ error: 'Upstream unavailable' });
|
|
323
|
+
res.status(500).json({ error: error.message });
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
// ===== Child SKU (子 SKU 变体) =====
|
|
327
|
+
// 实物商品: 主SKU=产品线(链上), 子SKU=变体(indexer本地), 上限100/主SKU
|
|
328
|
+
/** 查子 SKU 列表 GET /api/marketplace/product/:skuId/children */
|
|
329
|
+
router.get('/product/:skuId/children', async (req, res) => {
|
|
330
|
+
try {
|
|
331
|
+
const children = await indexer.getChildSkus(String(req.params.skuId));
|
|
332
|
+
res.json({ success: true, children });
|
|
333
|
+
}
|
|
334
|
+
catch (error) {
|
|
335
|
+
res.status(400).json({ error: error.message });
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
/** 加子 SKU POST /api/marketplace/product/:skuId/children (需 auth) */
|
|
339
|
+
router.post('/product/:skuId/children', async (req, res) => {
|
|
340
|
+
try {
|
|
341
|
+
const tokenData = await verifyAuth(req);
|
|
342
|
+
if (!tokenData)
|
|
343
|
+
return res.status(401).json({ error: 'Invalid token' });
|
|
344
|
+
const seller = tokenData.address || req.body?.seller;
|
|
345
|
+
if (!seller)
|
|
346
|
+
return res.status(400).json({ error: '缺少 seller' });
|
|
347
|
+
const { variantName, variantAttrs, priceCny, priceTct, stock, skuCode, images } = req.body || {};
|
|
348
|
+
if (!variantName)
|
|
349
|
+
return res.status(400).json({ error: '缺少 variantName' });
|
|
350
|
+
const id = await indexer.addChildSku(String(req.params.skuId), seller, {
|
|
351
|
+
variantName: String(variantName), variantAttrs: variantAttrs || {},
|
|
352
|
+
priceCny: Number(priceCny || 0), priceTct: Number(priceTct || 0),
|
|
353
|
+
stock: Number(stock || 0), skuCode: skuCode || '', images: images || [],
|
|
354
|
+
});
|
|
355
|
+
res.json({ success: true, id });
|
|
356
|
+
}
|
|
357
|
+
catch (error) {
|
|
358
|
+
console.error('[MarketplaceAPI] addChildSku error:', error);
|
|
359
|
+
res.status(400).json({ error: error.message });
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
/** 改子 SKU PUT /api/marketplace/product/child/:id (需 auth) */
|
|
363
|
+
router.put('/product/child/:id', async (req, res) => {
|
|
364
|
+
try {
|
|
365
|
+
const tokenData = await verifyAuth(req);
|
|
366
|
+
if (!tokenData)
|
|
367
|
+
return res.status(401).json({ error: 'Invalid token' });
|
|
368
|
+
const seller = tokenData.address || req.body?.seller;
|
|
369
|
+
if (!seller)
|
|
370
|
+
return res.status(400).json({ error: '缺少 seller' });
|
|
371
|
+
await indexer.updateChildSku(String(req.params.id), seller, req.body || {});
|
|
372
|
+
res.json({ success: true });
|
|
373
|
+
}
|
|
374
|
+
catch (error) {
|
|
375
|
+
res.status(400).json({ error: error.message });
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
/** 删子 SKU DELETE /api/marketplace/product/child/:id (需 auth, 软删除) */
|
|
379
|
+
router.delete('/product/child/:id', async (req, res) => {
|
|
380
|
+
try {
|
|
381
|
+
const tokenData = await verifyAuth(req);
|
|
382
|
+
if (!tokenData)
|
|
383
|
+
return res.status(401).json({ error: 'Invalid token' });
|
|
384
|
+
const seller = tokenData.address || req.query.seller;
|
|
385
|
+
if (!seller)
|
|
386
|
+
return res.status(400).json({ error: '缺少 seller' });
|
|
387
|
+
await indexer.deleteChildSku(String(req.params.id), seller);
|
|
388
|
+
res.json({ success: true });
|
|
389
|
+
}
|
|
390
|
+
catch (error) {
|
|
391
|
+
res.status(400).json({ error: error.message });
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
return router;
|
|
395
|
+
}
|
|
396
|
+
//# sourceMappingURL=marketplace.js.map
|