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
package/types/store.d.ts
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TrustChain Store API 共享类型 (baobei 8/23 20:25 SGT lane 实战锁版)
|
|
3
|
+
*
|
|
4
|
+
* Lesson #335 三处一致: DB schema + API response + UI form 共用同一组类型
|
|
5
|
+
*
|
|
6
|
+
* 范围:
|
|
7
|
+
* - 5 商家 endpoint (seller-*)
|
|
8
|
+
* - 3 前台 endpoint (storefront-*)
|
|
9
|
+
*
|
|
10
|
+
* 设计原则:
|
|
11
|
+
* - 所有 id 用 string (uuid v4)
|
|
12
|
+
* - 时间戳统一 ms (milliseconds, number)
|
|
13
|
+
* - 金额用 number 整数 utct (1 TCT = 1_000_000 utct) — chain native
|
|
14
|
+
* - 所有 enum 用 union literal types (跟 DB TEXT CHECK 一致)
|
|
15
|
+
* - 5 头鉴权产物 (req.walletAddress) 用 chain_address (tct1...) 表示
|
|
16
|
+
*/
|
|
17
|
+
/** chain bech32 地址 (tct1...) */
|
|
18
|
+
export type ChainAddress = string;
|
|
19
|
+
/** 商家注册状态 */
|
|
20
|
+
export type SellerStatus = 'pending' | 'active' | 'suspended' | 'closed';
|
|
21
|
+
/** 商品状态 */
|
|
22
|
+
export type ProductStatus = 'draft' | 'active' | 'out_of_stock' | 'archived';
|
|
23
|
+
/** 订单状态机 (Lesson #266b cosmos-sdk GetSigners 实战) */
|
|
24
|
+
export type OrderStatus = 'created' | 'paid' | 'shipped' | 'completed' | 'cancelled' | 'disputed' | 'refunded';
|
|
25
|
+
/** 提现状态 */
|
|
26
|
+
export type PayoutStatus = 'pending' | 'processing' | 'completed' | 'failed';
|
|
27
|
+
export interface Product {
|
|
28
|
+
id: string;
|
|
29
|
+
seller_address: ChainAddress;
|
|
30
|
+
title: string;
|
|
31
|
+
description: string;
|
|
32
|
+
/** 1 TCT = 1_000_000 utct, 整数 */
|
|
33
|
+
price_utct: number;
|
|
34
|
+
stock: number;
|
|
35
|
+
status: ProductStatus;
|
|
36
|
+
category: string;
|
|
37
|
+
image_url: string | null;
|
|
38
|
+
tags: string[];
|
|
39
|
+
featured: 0 | 1;
|
|
40
|
+
sales_count: number;
|
|
41
|
+
created_at: number;
|
|
42
|
+
updated_at: number;
|
|
43
|
+
}
|
|
44
|
+
export interface CreateProductInput {
|
|
45
|
+
title: string;
|
|
46
|
+
description: string;
|
|
47
|
+
price_utct: number;
|
|
48
|
+
stock: number;
|
|
49
|
+
category: string;
|
|
50
|
+
image_url?: string;
|
|
51
|
+
tags?: string[];
|
|
52
|
+
status?: ProductStatus;
|
|
53
|
+
}
|
|
54
|
+
export interface UpdateProductInput {
|
|
55
|
+
title?: string;
|
|
56
|
+
description?: string;
|
|
57
|
+
price_utct?: number;
|
|
58
|
+
category?: string;
|
|
59
|
+
image_url?: string;
|
|
60
|
+
tags?: string[];
|
|
61
|
+
status?: ProductStatus;
|
|
62
|
+
}
|
|
63
|
+
export interface ProductListResponse {
|
|
64
|
+
success: true;
|
|
65
|
+
products: Product[];
|
|
66
|
+
page: number;
|
|
67
|
+
page_size: number;
|
|
68
|
+
total: number;
|
|
69
|
+
}
|
|
70
|
+
export interface ProductDetailResponse {
|
|
71
|
+
success: true;
|
|
72
|
+
product: Product;
|
|
73
|
+
}
|
|
74
|
+
export interface OrderItem {
|
|
75
|
+
product_id: string;
|
|
76
|
+
title: string;
|
|
77
|
+
price_utct: number;
|
|
78
|
+
quantity: number;
|
|
79
|
+
}
|
|
80
|
+
export interface Order {
|
|
81
|
+
id: string;
|
|
82
|
+
buyer_address: ChainAddress;
|
|
83
|
+
seller_address: ChainAddress;
|
|
84
|
+
items: OrderItem[];
|
|
85
|
+
total_utct: number;
|
|
86
|
+
status: OrderStatus;
|
|
87
|
+
shipping_address: string | null;
|
|
88
|
+
tracking_number: string | null;
|
|
89
|
+
paid_at: number | null;
|
|
90
|
+
shipped_at: number | null;
|
|
91
|
+
completed_at: number | null;
|
|
92
|
+
cancelled_at: number | null;
|
|
93
|
+
dispute_reason: string | null;
|
|
94
|
+
paid_tx_hash: string | null;
|
|
95
|
+
created_at: number;
|
|
96
|
+
updated_at: number;
|
|
97
|
+
}
|
|
98
|
+
export interface CreateOrderInput {
|
|
99
|
+
items: Array<{
|
|
100
|
+
product_id: string;
|
|
101
|
+
quantity: number;
|
|
102
|
+
}>;
|
|
103
|
+
shipping_address: string;
|
|
104
|
+
}
|
|
105
|
+
export interface PayOrderInput {
|
|
106
|
+
/** 链上 tx hash (Lesson #266b 实战: 必须 chain-side verify) */
|
|
107
|
+
tx_hash: string;
|
|
108
|
+
}
|
|
109
|
+
export interface Earning {
|
|
110
|
+
id: string;
|
|
111
|
+
seller_address: ChainAddress;
|
|
112
|
+
order_id: string;
|
|
113
|
+
amount_utct: number;
|
|
114
|
+
fee_utct: number;
|
|
115
|
+
net_utct: number;
|
|
116
|
+
created_at: number;
|
|
117
|
+
}
|
|
118
|
+
export interface EarningsOverview {
|
|
119
|
+
total_earnings_utct: number;
|
|
120
|
+
pending_payout_utct: number;
|
|
121
|
+
total_paid_out_utct: number;
|
|
122
|
+
month_earnings_utct: number;
|
|
123
|
+
orders_completed: number;
|
|
124
|
+
}
|
|
125
|
+
export interface MonthlyEarning {
|
|
126
|
+
year: number;
|
|
127
|
+
month: number;
|
|
128
|
+
earnings_utct: number;
|
|
129
|
+
orders_count: number;
|
|
130
|
+
}
|
|
131
|
+
export interface PayoutRequest {
|
|
132
|
+
amount_utct: number;
|
|
133
|
+
/** 收款地址 (默认 = seller_address) */
|
|
134
|
+
to_address?: ChainAddress;
|
|
135
|
+
}
|
|
136
|
+
export interface Payout {
|
|
137
|
+
id: string;
|
|
138
|
+
seller_address: ChainAddress;
|
|
139
|
+
amount_utct: number;
|
|
140
|
+
status: PayoutStatus;
|
|
141
|
+
to_address: ChainAddress;
|
|
142
|
+
tx_hash: string | null;
|
|
143
|
+
requested_at: number;
|
|
144
|
+
completed_at: number | null;
|
|
145
|
+
}
|
|
146
|
+
export interface Reputation {
|
|
147
|
+
seller_address: ChainAddress;
|
|
148
|
+
rating_avg: number;
|
|
149
|
+
review_count: number;
|
|
150
|
+
positive_rate: number;
|
|
151
|
+
dispute_count: number;
|
|
152
|
+
completed_orders: number;
|
|
153
|
+
badge: 'new' | 'bronze' | 'silver' | 'gold' | 'platinum';
|
|
154
|
+
}
|
|
155
|
+
export interface Review {
|
|
156
|
+
id: string;
|
|
157
|
+
order_id: string;
|
|
158
|
+
seller_address: ChainAddress;
|
|
159
|
+
buyer_address: ChainAddress;
|
|
160
|
+
rating: 1 | 2 | 3 | 4 | 5;
|
|
161
|
+
content: string;
|
|
162
|
+
reply: string | null;
|
|
163
|
+
reply_at: number | null;
|
|
164
|
+
created_at: number;
|
|
165
|
+
}
|
|
166
|
+
export interface SellerSettings {
|
|
167
|
+
seller_address: ChainAddress;
|
|
168
|
+
shop_name: string;
|
|
169
|
+
shop_description: string;
|
|
170
|
+
shop_logo_url: string | null;
|
|
171
|
+
contact_email: string | null;
|
|
172
|
+
contact_phone: string | null;
|
|
173
|
+
shipping_policy: string | null;
|
|
174
|
+
return_policy: string | null;
|
|
175
|
+
auto_accept_orders: 0 | 1;
|
|
176
|
+
updated_at: number;
|
|
177
|
+
}
|
|
178
|
+
export interface UpdateSettingsInput {
|
|
179
|
+
shop_name?: string;
|
|
180
|
+
shop_description?: string;
|
|
181
|
+
shop_logo_url?: string;
|
|
182
|
+
contact_email?: string;
|
|
183
|
+
contact_phone?: string;
|
|
184
|
+
shipping_policy?: string;
|
|
185
|
+
return_policy?: string;
|
|
186
|
+
auto_accept_orders?: 0 | 1;
|
|
187
|
+
}
|
|
188
|
+
export interface RegisterSellerInput {
|
|
189
|
+
/** 店铺名称 (3-50 字符) */
|
|
190
|
+
shop_name: string;
|
|
191
|
+
/** 店铺描述 */
|
|
192
|
+
shop_description: string;
|
|
193
|
+
/** 联系电话 */
|
|
194
|
+
contact_phone: string;
|
|
195
|
+
/** 联系邮箱 */
|
|
196
|
+
contact_email: string;
|
|
197
|
+
/** chain-side 验证 — 商家 owner 真实持有该 address (Lesson #266b) */
|
|
198
|
+
signature_proof: string;
|
|
199
|
+
}
|
|
200
|
+
export interface StorefrontUser {
|
|
201
|
+
id: string;
|
|
202
|
+
chain_address: ChainAddress;
|
|
203
|
+
display_name: string;
|
|
204
|
+
email: string | null;
|
|
205
|
+
avatar_url: string | null;
|
|
206
|
+
oauth_platforms: string[];
|
|
207
|
+
created_at: number;
|
|
208
|
+
last_login_at: number | null;
|
|
209
|
+
}
|
|
210
|
+
export interface CartItem {
|
|
211
|
+
id: string;
|
|
212
|
+
user_id: string;
|
|
213
|
+
product_id: string;
|
|
214
|
+
quantity: number;
|
|
215
|
+
/** snapshot 字段 — 加入购物车时复制, 商品改价不影响 cart */
|
|
216
|
+
snapshot_title: string;
|
|
217
|
+
snapshot_price_utct: number;
|
|
218
|
+
snapshot_image_url: string | null;
|
|
219
|
+
created_at: number;
|
|
220
|
+
}
|
|
221
|
+
export interface AddCartInput {
|
|
222
|
+
product_id: string;
|
|
223
|
+
quantity: number;
|
|
224
|
+
}
|
|
225
|
+
export interface OAuthBridgeInput {
|
|
226
|
+
platform: 'wechat' | 'alipay' | 'douyin';
|
|
227
|
+
/** 平台 code */
|
|
228
|
+
code: string;
|
|
229
|
+
/** 平台 state (csrf 防护) */
|
|
230
|
+
state: string;
|
|
231
|
+
}
|
|
232
|
+
export interface OAuthBridgeResult {
|
|
233
|
+
success: true;
|
|
234
|
+
chain_address: ChainAddress;
|
|
235
|
+
access_token: string;
|
|
236
|
+
refresh_token: string;
|
|
237
|
+
platform: string;
|
|
238
|
+
expires_in: number;
|
|
239
|
+
user: StorefrontUser;
|
|
240
|
+
}
|
|
241
|
+
export interface SuccessEnvelope<T> {
|
|
242
|
+
success: true;
|
|
243
|
+
data: T;
|
|
244
|
+
}
|
|
245
|
+
export interface ErrorEnvelope {
|
|
246
|
+
success: false;
|
|
247
|
+
errorCode: string;
|
|
248
|
+
errorMessage: string;
|
|
249
|
+
}
|
|
250
|
+
/** pagination 标准 */
|
|
251
|
+
export interface PaginationParams {
|
|
252
|
+
page?: number;
|
|
253
|
+
page_size?: number;
|
|
254
|
+
}
|
|
255
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/types/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,gCAAgC;AAChC,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC,aAAa;AACb,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAC;A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IACzC,cAAc;IACd,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,IAAI,CAAC;IACd,aAAa,EAAE,YAAY,CAAC;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,cAAc,CAAC;CACtB;AAMD,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,CAAC,CAAC;CACT;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,oBAAoB;AACpB,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
package/types/store.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* TrustChain Store API 共享类型 (baobei 8/23 20:25 SGT lane 实战锁版)
|
|
4
|
+
*
|
|
5
|
+
* Lesson #335 三处一致: DB schema + API response + UI form 共用同一组类型
|
|
6
|
+
*
|
|
7
|
+
* 范围:
|
|
8
|
+
* - 5 商家 endpoint (seller-*)
|
|
9
|
+
* - 3 前台 endpoint (storefront-*)
|
|
10
|
+
*
|
|
11
|
+
* 设计原则:
|
|
12
|
+
* - 所有 id 用 string (uuid v4)
|
|
13
|
+
* - 时间戳统一 ms (milliseconds, number)
|
|
14
|
+
* - 金额用 number 整数 utct (1 TCT = 1_000_000 utct) — chain native
|
|
15
|
+
* - 所有 enum 用 union literal types (跟 DB TEXT CHECK 一致)
|
|
16
|
+
* - 5 头鉴权产物 (req.walletAddress) 用 chain_address (tct1...) 表示
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/types/store.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AES-GCM 256-bit Content Encryption (私田 4 权限契约 v0.1)
|
|
3
|
+
*
|
|
4
|
+
* baobei lane 7 sub-agent 实战锁版 (2026-08-23)
|
|
5
|
+
*
|
|
6
|
+
* Lesson #316 实战锁版:
|
|
7
|
+
* - content_key (32 bytes random) 出 owner wallet, 不入库
|
|
8
|
+
* - whitelist 接收者用 ECIES (ECDH secp256k1 + AES-GCM) 拿到 content_key
|
|
9
|
+
* - AES-GCM 256-bit, nonce 12 bytes (RFC 5116), tag 16 bytes (内置)
|
|
10
|
+
*
|
|
11
|
+
* 设计原则 (baobei 实战风格):
|
|
12
|
+
* 1. 加密永远随机 nonce (never reuse nonce + key)
|
|
13
|
+
* 2. 解密失败 throw (fail loud, Lesson #266a)
|
|
14
|
+
* 3. content_key_hash (SHA-256) 仅用于审计 + 防篡改, 不可反推 key
|
|
15
|
+
* 4. ECIES 实现: ECDH(secp256k1) → HKDF-SHA256 → AES-GCM key
|
|
16
|
+
* 5. share_token 用 crypto.randomBytes(8) = 16 chars hex
|
|
17
|
+
*/
|
|
18
|
+
export interface EncryptedContent {
|
|
19
|
+
ciphertext: Buffer;
|
|
20
|
+
nonce: Buffer;
|
|
21
|
+
keyHash: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 生成随机 content_key (32 bytes = 256-bit)
|
|
25
|
+
* 客户端 (owner wallet) 调用, 不上传 server
|
|
26
|
+
*/
|
|
27
|
+
export declare function generateContentKey(): Buffer;
|
|
28
|
+
/**
|
|
29
|
+
* AES-GCM 加密 (服务端或客户端均可用, 实战场景是 owner 设备)
|
|
30
|
+
*/
|
|
31
|
+
export declare function encryptContent(plaintext: Buffer | string, contentKey: Buffer): EncryptedContent;
|
|
32
|
+
/**
|
|
33
|
+
* AES-GCM 解密 (验证 auth tag)
|
|
34
|
+
* 失败 throw (Lesson #266a fail loud)
|
|
35
|
+
*/
|
|
36
|
+
export declare function decryptContent(ciphertext: Buffer, nonce: Buffer, contentKey: Buffer): Buffer;
|
|
37
|
+
/**
|
|
38
|
+
* ECIES 加密 content_key 给 whitelist 接收者 (owner 用 recipient pubkey)
|
|
39
|
+
* 接收者用自己的 privkey ECDH 即可解开
|
|
40
|
+
*/
|
|
41
|
+
export interface EciesCipher {
|
|
42
|
+
encryptedKey: Buffer;
|
|
43
|
+
nonce: Buffer;
|
|
44
|
+
}
|
|
45
|
+
export declare function encryptKeyForRecipient(contentKey: Buffer, recipientPubKeyBase64: string): EciesCipher;
|
|
46
|
+
/**
|
|
47
|
+
* ECIES 解密 (接收者用自己 privkey)
|
|
48
|
+
* encryptedKey 格式: ephemeralPubKey(33 bytes) + ciphertext + tag(16 bytes)
|
|
49
|
+
*/
|
|
50
|
+
export declare function decryptKeyForRecipient(encryptedKey: Buffer, nonce: Buffer, recipientPrivKey: Buffer): Buffer;
|
|
51
|
+
/**
|
|
52
|
+
* 生成短链 token (16 chars hex = 8 bytes random)
|
|
53
|
+
*/
|
|
54
|
+
export declare function generateShareToken(): string;
|
|
55
|
+
/**
|
|
56
|
+
* IP → SHA-256 hex (32 chars 取前 16, 隐私保护)
|
|
57
|
+
*/
|
|
58
|
+
export declare function hashIp(ip: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* 验证 content_key 与 key_hash 匹配 (审计用, 不能反推 key)
|
|
61
|
+
*/
|
|
62
|
+
export declare function verifyKeyHash(contentKey: Buffer, keyHash: string): boolean;
|
|
63
|
+
//# sourceMappingURL=aes-gcm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aes-gcm.d.ts","sourceRoot":"","sources":["../../src/utils/aes-gcm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAaH,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,gBAAgB,CAkB/F;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAiB5F;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,GAAG,WAAW,CAyBrG;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,gBAAgB,EAAE,MAAM,GACvB,MAAM,CAeR;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAG1E"}
|
package/utils/aes-gcm.js
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AES-GCM 256-bit Content Encryption (私田 4 权限契约 v0.1)
|
|
4
|
+
*
|
|
5
|
+
* baobei lane 7 sub-agent 实战锁版 (2026-08-23)
|
|
6
|
+
*
|
|
7
|
+
* Lesson #316 实战锁版:
|
|
8
|
+
* - content_key (32 bytes random) 出 owner wallet, 不入库
|
|
9
|
+
* - whitelist 接收者用 ECIES (ECDH secp256k1 + AES-GCM) 拿到 content_key
|
|
10
|
+
* - AES-GCM 256-bit, nonce 12 bytes (RFC 5116), tag 16 bytes (内置)
|
|
11
|
+
*
|
|
12
|
+
* 设计原则 (baobei 实战风格):
|
|
13
|
+
* 1. 加密永远随机 nonce (never reuse nonce + key)
|
|
14
|
+
* 2. 解密失败 throw (fail loud, Lesson #266a)
|
|
15
|
+
* 3. content_key_hash (SHA-256) 仅用于审计 + 防篡改, 不可反推 key
|
|
16
|
+
* 4. ECIES 实现: ECDH(secp256k1) → HKDF-SHA256 → AES-GCM key
|
|
17
|
+
* 5. share_token 用 crypto.randomBytes(8) = 16 chars hex
|
|
18
|
+
*/
|
|
19
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
22
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
23
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(o, k2, desc);
|
|
26
|
+
}) : (function(o, m, k, k2) {
|
|
27
|
+
if (k2 === undefined) k2 = k;
|
|
28
|
+
o[k2] = m[k];
|
|
29
|
+
}));
|
|
30
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
31
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
32
|
+
}) : function(o, v) {
|
|
33
|
+
o["default"] = v;
|
|
34
|
+
});
|
|
35
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
36
|
+
var ownKeys = function(o) {
|
|
37
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
38
|
+
var ar = [];
|
|
39
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
40
|
+
return ar;
|
|
41
|
+
};
|
|
42
|
+
return ownKeys(o);
|
|
43
|
+
};
|
|
44
|
+
return function (mod) {
|
|
45
|
+
if (mod && mod.__esModule) return mod;
|
|
46
|
+
var result = {};
|
|
47
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
48
|
+
__setModuleDefault(result, mod);
|
|
49
|
+
return result;
|
|
50
|
+
};
|
|
51
|
+
})();
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.generateContentKey = generateContentKey;
|
|
54
|
+
exports.encryptContent = encryptContent;
|
|
55
|
+
exports.decryptContent = decryptContent;
|
|
56
|
+
exports.encryptKeyForRecipient = encryptKeyForRecipient;
|
|
57
|
+
exports.decryptKeyForRecipient = decryptKeyForRecipient;
|
|
58
|
+
exports.generateShareToken = generateShareToken;
|
|
59
|
+
exports.hashIp = hashIp;
|
|
60
|
+
exports.verifyKeyHash = verifyKeyHash;
|
|
61
|
+
const crypto = __importStar(require("crypto"));
|
|
62
|
+
const secp256k1_1 = require("@noble/curves/secp256k1");
|
|
63
|
+
const encoding_1 = require("@cosmjs/encoding");
|
|
64
|
+
const ALGO = 'aes-256-gcm';
|
|
65
|
+
const NONCE_BYTES = 12;
|
|
66
|
+
const KEY_BYTES = 32;
|
|
67
|
+
const TAG_BYTES = 16;
|
|
68
|
+
const HKDF_SALT = Buffer.from('trustchain-private-field-v0.1-ecies', 'utf-8');
|
|
69
|
+
const HKDF_INFO = Buffer.from('content-key-encryption', 'utf-8');
|
|
70
|
+
/**
|
|
71
|
+
* 生成随机 content_key (32 bytes = 256-bit)
|
|
72
|
+
* 客户端 (owner wallet) 调用, 不上传 server
|
|
73
|
+
*/
|
|
74
|
+
function generateContentKey() {
|
|
75
|
+
return crypto.randomBytes(KEY_BYTES);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* AES-GCM 加密 (服务端或客户端均可用, 实战场景是 owner 设备)
|
|
79
|
+
*/
|
|
80
|
+
function encryptContent(plaintext, contentKey) {
|
|
81
|
+
if (!Buffer.isBuffer(contentKey) || contentKey.length !== KEY_BYTES) {
|
|
82
|
+
throw new Error(`[aes-gcm] invalid content_key length: expected ${KEY_BYTES}, got ${contentKey?.length}`);
|
|
83
|
+
}
|
|
84
|
+
const data = Buffer.isBuffer(plaintext) ? plaintext : Buffer.from(plaintext, 'utf-8');
|
|
85
|
+
const nonce = crypto.randomBytes(NONCE_BYTES);
|
|
86
|
+
const cipher = crypto.createCipheriv(ALGO, contentKey, nonce);
|
|
87
|
+
const ct = Buffer.concat([cipher.update(data), cipher.final()]);
|
|
88
|
+
const tag = cipher.getAuthTag();
|
|
89
|
+
// Node.js AES-GCM getAuthTag() 已分离 tag, 但 final() 输出的 ciphertext 不含 tag
|
|
90
|
+
// 实战风格: 把 tag 拼到 ciphertext 末尾 (跟很多 ECIES 实现一致)
|
|
91
|
+
const ciphertext = Buffer.concat([ct, tag]);
|
|
92
|
+
return {
|
|
93
|
+
ciphertext,
|
|
94
|
+
nonce,
|
|
95
|
+
keyHash: crypto.createHash('sha256').update(contentKey).digest('hex'),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* AES-GCM 解密 (验证 auth tag)
|
|
100
|
+
* 失败 throw (Lesson #266a fail loud)
|
|
101
|
+
*/
|
|
102
|
+
function decryptContent(ciphertext, nonce, contentKey) {
|
|
103
|
+
if (!Buffer.isBuffer(contentKey) || contentKey.length !== KEY_BYTES) {
|
|
104
|
+
throw new Error(`[aes-gcm] invalid content_key length: expected ${KEY_BYTES}, got ${contentKey?.length}`);
|
|
105
|
+
}
|
|
106
|
+
if (!Buffer.isBuffer(nonce) || nonce.length !== NONCE_BYTES) {
|
|
107
|
+
throw new Error(`[aes-gcm] invalid nonce length: expected ${NONCE_BYTES}, got ${nonce?.length}`);
|
|
108
|
+
}
|
|
109
|
+
if (!Buffer.isBuffer(ciphertext) || ciphertext.length < TAG_BYTES) {
|
|
110
|
+
throw new Error(`[aes-gcm] invalid ciphertext length: at least ${TAG_BYTES} bytes, got ${ciphertext?.length}`);
|
|
111
|
+
}
|
|
112
|
+
// 拆分 tag (末尾 16 bytes)
|
|
113
|
+
const ct = ciphertext.subarray(0, ciphertext.length - TAG_BYTES);
|
|
114
|
+
const tag = ciphertext.subarray(ciphertext.length - TAG_BYTES);
|
|
115
|
+
const decipher = crypto.createDecipheriv(ALGO, contentKey, nonce);
|
|
116
|
+
decipher.setAuthTag(tag);
|
|
117
|
+
return Buffer.concat([decipher.update(ct), decipher.final()]);
|
|
118
|
+
}
|
|
119
|
+
function encryptKeyForRecipient(contentKey, recipientPubKeyBase64) {
|
|
120
|
+
const recipientPubKey = (0, encoding_1.fromBase64)(recipientPubKeyBase64);
|
|
121
|
+
if (recipientPubKey.length !== 33) {
|
|
122
|
+
throw new Error(`[aes-gcm] invalid recipient pubkey length: 33 bytes compressed expected, got ${recipientPubKey.length}`);
|
|
123
|
+
}
|
|
124
|
+
// 1. 临时 ECDH 私钥 (32 bytes random) → 临时公钥 (33 bytes)
|
|
125
|
+
const ephemeralPrivKey = crypto.randomBytes(32);
|
|
126
|
+
const ephemeralPubKey = secp256k1_1.secp256k1.getPublicKey(ephemeralPrivKey, true); // compressed 33 bytes
|
|
127
|
+
// 2. ECDH: sharedPoint = ephemeralPrivKey * recipientPubKey
|
|
128
|
+
const sharedPoint = secp256k1_1.secp256k1.getSharedSecret(ephemeralPrivKey, recipientPubKey, true);
|
|
129
|
+
// sharedPoint 是 33 bytes compressed pubkey
|
|
130
|
+
// 3. HKDF-SHA256 派生 AES key (RFC 5869)
|
|
131
|
+
const hkdfKey = crypto.hkdfSync('sha256', Buffer.from(sharedPoint), HKDF_SALT, HKDF_INFO, KEY_BYTES);
|
|
132
|
+
// 4. AES-GCM 加密 content_key
|
|
133
|
+
const nonce = crypto.randomBytes(NONCE_BYTES);
|
|
134
|
+
const cipher = crypto.createCipheriv(ALGO, Buffer.from(hkdfKey), nonce);
|
|
135
|
+
const ct = Buffer.concat([cipher.update(contentKey), cipher.final()]);
|
|
136
|
+
const tag = cipher.getAuthTag();
|
|
137
|
+
// 拼接: ephemeralPubKey(33) + ciphertext(含tag)
|
|
138
|
+
// 接收者用 ephemeralPubKey 算 ECDH 即可解
|
|
139
|
+
const encryptedKey = Buffer.concat([Buffer.from(ephemeralPubKey), ct, tag]);
|
|
140
|
+
return { encryptedKey, nonce };
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* ECIES 解密 (接收者用自己 privkey)
|
|
144
|
+
* encryptedKey 格式: ephemeralPubKey(33 bytes) + ciphertext + tag(16 bytes)
|
|
145
|
+
*/
|
|
146
|
+
function decryptKeyForRecipient(encryptedKey, nonce, recipientPrivKey) {
|
|
147
|
+
if (encryptedKey.length < 33 + TAG_BYTES) {
|
|
148
|
+
throw new Error(`[aes-gcm] invalid encrypted_key length: at least ${33 + TAG_BYTES}, got ${encryptedKey?.length}`);
|
|
149
|
+
}
|
|
150
|
+
const ephemeralPubKey = encryptedKey.subarray(0, 33);
|
|
151
|
+
const ct = encryptedKey.subarray(33, encryptedKey.length - TAG_BYTES);
|
|
152
|
+
const tag = encryptedKey.subarray(encryptedKey.length - TAG_BYTES);
|
|
153
|
+
// ECDH: recipientPrivKey * ephemeralPubKey
|
|
154
|
+
const sharedPoint = secp256k1_1.secp256k1.getSharedSecret(recipientPrivKey, Buffer.from(ephemeralPubKey), true);
|
|
155
|
+
const hkdfKey = crypto.hkdfSync('sha256', Buffer.from(sharedPoint), HKDF_SALT, HKDF_INFO, KEY_BYTES);
|
|
156
|
+
const decipher = crypto.createDecipheriv(ALGO, Buffer.from(hkdfKey), nonce);
|
|
157
|
+
decipher.setAuthTag(tag);
|
|
158
|
+
return Buffer.concat([decipher.update(ct), decipher.final()]);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* 生成短链 token (16 chars hex = 8 bytes random)
|
|
162
|
+
*/
|
|
163
|
+
function generateShareToken() {
|
|
164
|
+
return crypto.randomBytes(8).toString('hex');
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* IP → SHA-256 hex (32 chars 取前 16, 隐私保护)
|
|
168
|
+
*/
|
|
169
|
+
function hashIp(ip) {
|
|
170
|
+
return crypto.createHash('sha256').update(ip || '').digest('hex').slice(0, 16);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* 验证 content_key 与 key_hash 匹配 (审计用, 不能反推 key)
|
|
174
|
+
*/
|
|
175
|
+
function verifyKeyHash(contentKey, keyHash) {
|
|
176
|
+
const expected = crypto.createHash('sha256').update(contentKey).digest('hex');
|
|
177
|
+
return crypto.timingSafeEqual(Buffer.from(expected, 'hex'), Buffer.from(keyHash, 'hex'));
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=aes-gcm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aes-gcm.js","sourceRoot":"","sources":["../../src/utils/aes-gcm.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBH,gDAEC;AAKD,wCAkBC;AAMD,wCAiBC;AAWD,wDAyBC;AAMD,wDAmBC;AAKD,gDAEC;AAKD,wBAEC;AAKD,sCAGC;AAxJD,+CAAiC;AACjC,uDAAoD;AACpD,+CAAwD;AAExD,MAAM,IAAI,GAAG,aAAa,CAAC;AAC3B,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,qCAAqC,EAAE,OAAO,CAAC,CAAC;AAC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CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,SAAgB,MAAM,CAAC,EAAU;IAC/B,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACjF,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,UAAkB,EAAE,OAAe;IAC/D,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9E,OAAO,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AAC3F,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Response Helpers — 统一错误 + 分页响应格式 (kimi 验收标准 v1.0 G3 B3 + B4)
|
|
3
|
+
*
|
|
4
|
+
* B3 401/4xx/5xx 错误格式统一:
|
|
5
|
+
* { error: { code: 'CODE', message: 'human msg', details?: any } }
|
|
6
|
+
*
|
|
7
|
+
* B4 分页响应格式统一:
|
|
8
|
+
* { data: [...], pagination: { total, limit, offset, has_next, has_prev } }
|
|
9
|
+
*
|
|
10
|
+
* 范围 v0.1: 关键鉴权路径 (social.ts / p2p-message.ts / auth.ts)
|
|
11
|
+
* 范围 v0.2: ai.ts / council.ts / devreward.ts / economy.ts / flowback.ts / oauth.ts / relationship.ts / reputation.ts
|
|
12
|
+
*/
|
|
13
|
+
import type { Response } from 'express';
|
|
14
|
+
export interface ApiError {
|
|
15
|
+
code: string;
|
|
16
|
+
message: string;
|
|
17
|
+
details?: any;
|
|
18
|
+
}
|
|
19
|
+
/** 错误响应统一格式 */
|
|
20
|
+
export declare function errorResponse(res: Response, status: number, code: string, message: string, details?: any): Response;
|
|
21
|
+
/** 成功响应 (简单 data) */
|
|
22
|
+
export declare function successResponse<T>(res: Response, data: T, status?: number): Response;
|
|
23
|
+
/** 分页响应统一格式 (B4) */
|
|
24
|
+
export declare function paginatedResponse<T>(res: Response, items: T[], total: number, limit: number, offset: number): Response;
|
|
25
|
+
/** 兼容层: 旧 routes 可以用 raw errorResponse 但逐步迁到标准格式 */
|
|
26
|
+
export declare const ErrorCodes: {
|
|
27
|
+
readonly AUTH_MISSING_HEADER: "missing_authorization_header";
|
|
28
|
+
readonly AUTH_INVALID_TOKEN: "invalid_token";
|
|
29
|
+
readonly AUTH_EXPIRED_TOKEN: "expired_token";
|
|
30
|
+
readonly AUTH_INVALID_REFRESH: "invalid_refresh_token";
|
|
31
|
+
readonly AUTH_MISSING_USER: "missing_user";
|
|
32
|
+
readonly AUTH_WALLET_REQUIRED: "wallet_signature_required";
|
|
33
|
+
readonly AUTH_INSUFFICIENT_SCOPE: "insufficient_scope";
|
|
34
|
+
readonly BAD_REQUEST_MISSING_FIELDS: "missing_required_fields";
|
|
35
|
+
readonly BAD_REQUEST_INVALID_FORMAT: "invalid_format";
|
|
36
|
+
readonly SELF_SEND_FORBIDDEN: "cannot_send_to_self";
|
|
37
|
+
readonly PUBKEY_NOT_REGISTERED: "pubkey_not_registered";
|
|
38
|
+
readonly RECIPIENT_PUBKEY_REQUIRED: "recipient_pubkey_required";
|
|
39
|
+
readonly FORBIDDEN_SIGNER_MISMATCH: "forbidden_signer_mismatch";
|
|
40
|
+
readonly FORBIDDEN_OWNER_ONLY: "owner_only";
|
|
41
|
+
readonly FORBIDDEN_PRIVATE_FIELD: "private_field_access_denied";
|
|
42
|
+
readonly NOT_FOUND: "not_found";
|
|
43
|
+
readonly POST_NOT_FOUND: "post_not_found";
|
|
44
|
+
readonly SHARE_NOT_FOUND: "share_not_found";
|
|
45
|
+
readonly CONFLICT_OPENID_EXISTS: "openid_already_registered";
|
|
46
|
+
readonly RATE_LIMIT_TICKET: "rate_limit_ticket_brute_force";
|
|
47
|
+
readonly INTERNAL_ERROR: "internal_error";
|
|
48
|
+
readonly UPSTREAM_UNAVAILABLE: "upstream_unavailable";
|
|
49
|
+
readonly PLATFORM_UNAVAILABLE: "third_party_platform_unavailable";
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=api-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-response.d.ts","sourceRoot":"","sources":["../../src/utils/api-response.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAED,eAAe;AACf,wBAAgB,aAAa,CAC3B,GAAG,EAAE,QAAQ,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,GAAG,GACZ,QAAQ,CAIV;AAED,qBAAqB;AACrB,wBAAgB,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,SAAM,GAAG,QAAQ,CAEjF;AAED,oBAAoB;AACpB,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,CAAC,EAAE,EACV,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,QAAQ,CAWV;AAED,oDAAoD;AACpD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;CAuCb,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorCodes = void 0;
|
|
4
|
+
exports.errorResponse = errorResponse;
|
|
5
|
+
exports.successResponse = successResponse;
|
|
6
|
+
exports.paginatedResponse = paginatedResponse;
|
|
7
|
+
/** 错误响应统一格式 */
|
|
8
|
+
function errorResponse(res, status, code, message, details) {
|
|
9
|
+
const body = { error: { code, message } };
|
|
10
|
+
if (details !== undefined)
|
|
11
|
+
body.error.details = details;
|
|
12
|
+
return res.status(status).json(body);
|
|
13
|
+
}
|
|
14
|
+
/** 成功响应 (简单 data) */
|
|
15
|
+
function successResponse(res, data, status = 200) {
|
|
16
|
+
return res.status(status).json({ data });
|
|
17
|
+
}
|
|
18
|
+
/** 分页响应统一格式 (B4) */
|
|
19
|
+
function paginatedResponse(res, items, total, limit, offset) {
|
|
20
|
+
return res.status(200).json({
|
|
21
|
+
data: items,
|
|
22
|
+
pagination: {
|
|
23
|
+
total,
|
|
24
|
+
limit,
|
|
25
|
+
offset,
|
|
26
|
+
has_next: offset + items.length < total,
|
|
27
|
+
has_prev: offset > 0,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** 兼容层: 旧 routes 可以用 raw errorResponse 但逐步迁到标准格式 */
|
|
32
|
+
exports.ErrorCodes = {
|
|
33
|
+
// 401 鉴权
|
|
34
|
+
AUTH_MISSING_HEADER: 'missing_authorization_header',
|
|
35
|
+
AUTH_INVALID_TOKEN: 'invalid_token',
|
|
36
|
+
AUTH_EXPIRED_TOKEN: 'expired_token',
|
|
37
|
+
AUTH_INVALID_REFRESH: 'invalid_refresh_token',
|
|
38
|
+
AUTH_MISSING_USER: 'missing_user',
|
|
39
|
+
AUTH_WALLET_REQUIRED: 'wallet_signature_required',
|
|
40
|
+
AUTH_INSUFFICIENT_SCOPE: 'insufficient_scope',
|
|
41
|
+
// 400 请求
|
|
42
|
+
BAD_REQUEST_MISSING_FIELDS: 'missing_required_fields',
|
|
43
|
+
BAD_REQUEST_INVALID_FORMAT: 'invalid_format',
|
|
44
|
+
SELF_SEND_FORBIDDEN: 'cannot_send_to_self',
|
|
45
|
+
PUBKEY_NOT_REGISTERED: 'pubkey_not_registered',
|
|
46
|
+
RECIPIENT_PUBKEY_REQUIRED: 'recipient_pubkey_required',
|
|
47
|
+
// 403 权限
|
|
48
|
+
FORBIDDEN_SIGNER_MISMATCH: 'forbidden_signer_mismatch',
|
|
49
|
+
FORBIDDEN_OWNER_ONLY: 'owner_only',
|
|
50
|
+
FORBIDDEN_PRIVATE_FIELD: 'private_field_access_denied',
|
|
51
|
+
// 404
|
|
52
|
+
NOT_FOUND: 'not_found',
|
|
53
|
+
POST_NOT_FOUND: 'post_not_found',
|
|
54
|
+
SHARE_NOT_FOUND: 'share_not_found',
|
|
55
|
+
// 409 冲突
|
|
56
|
+
CONFLICT_OPENID_EXISTS: 'openid_already_registered',
|
|
57
|
+
// 429 限流
|
|
58
|
+
RATE_LIMIT_TICKET: 'rate_limit_ticket_brute_force',
|
|
59
|
+
// 500 服务器
|
|
60
|
+
INTERNAL_ERROR: 'internal_error',
|
|
61
|
+
UPSTREAM_UNAVAILABLE: 'upstream_unavailable',
|
|
62
|
+
// 502/503 上游
|
|
63
|
+
PLATFORM_UNAVAILABLE: 'third_party_platform_unavailable',
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=api-response.js.map
|