@seasonkoh/webaz 0.1.23 → 0.1.25

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.
Files changed (187) hide show
  1. package/README.md +2 -0
  2. package/dist/layer0-foundation/L0-1-database/db-backends/pg-backend.js +51 -0
  3. package/dist/layer0-foundation/L0-1-database/db-backends/sql-dialect-datetime.js +437 -0
  4. package/dist/layer0-foundation/L0-1-database/db-backends/sql-placeholders.js +98 -0
  5. package/dist/layer0-foundation/L0-1-database/db.js +65 -0
  6. package/dist/layer0-foundation/L0-2-state-machine/order-chain.js +13 -11
  7. package/dist/layer0-foundation/L0-2-state-machine/transitions.js +1 -1
  8. package/dist/layer0-foundation/L0-5-manifest/manifest.js +13 -11
  9. package/dist/layer1-agent/L1-1-mcp-server/server.js +198 -83
  10. package/dist/layer1-agent/L1-2-external-anchor/anchor-engine.js +14 -12
  11. package/dist/layer2-business/L2-6-notifications/notification-engine.js +8 -5
  12. package/dist/layer2-business/L2-7-snf/snf-engine.js +16 -14
  13. package/dist/layer2-business/L2-8-feedback/build-feedback-engine.js +18 -10
  14. package/dist/layer2-business/L2-9-contribution/build-reputation-engine.js +37 -23
  15. package/dist/layer2-business/L2-9-contribution/build-task-agent-metadata-store.js +173 -0
  16. package/dist/layer2-business/L2-9-contribution/build-task-participation.js +47 -0
  17. package/dist/layer2-business/L2-9-contribution/build-task-read.js +222 -0
  18. package/dist/layer2-business/L2-9-contribution/build-tasks-engine.js +10 -2
  19. package/dist/layer2-business/L2-9-contribution/canonical-contribution-target.js +16 -0
  20. package/dist/layer2-business/L2-9-contribution/contribution-display-envelope.js +40 -0
  21. package/dist/layer2-business/L2-9-contribution/contribution-score-contract.js +36 -0
  22. package/dist/layer2-business/L2-9-contribution/contribution-score-evidence.js +61 -0
  23. package/dist/layer2-business/L2-9-contribution/github-credential/canonical.js +60 -0
  24. package/dist/layer2-business/L2-9-contribution/github-credential/github-credential.schema.js +140 -0
  25. package/dist/layer2-business/L2-9-contribution/github-credential/github-fetch-adapter.js +437 -0
  26. package/dist/layer2-business/L2-9-contribution/github-credential/self-consistency.js +38 -0
  27. package/dist/layer2-business/L2-9-contribution/github-credential/verifier.js +231 -0
  28. package/dist/layer2-business/L2-9-contribution/github-credential-ingestion-engine.js +145 -0
  29. package/dist/layer2-business/L2-9-contribution/github-credential-store.js +115 -0
  30. package/dist/layer2-business/L2-9-contribution/identity-binding-engine.js +134 -0
  31. package/dist/layer2-business/L2-9-contribution/identity-binding-store.js +101 -0
  32. package/dist/layer2-business/L2-9-contribution/identity-claim-challenge-engine.js +126 -0
  33. package/dist/layer2-business/L2-9-contribution/identity-claim-challenge-store.js +30 -0
  34. package/dist/layer2-business/L2-9-contribution/identity-claim-engine.js +109 -0
  35. package/dist/layer2-business/L2-9-contribution/identity-claim-fact-precondition.js +22 -0
  36. package/dist/layer2-business/L2-9-contribution/identity-claim-proof-verifier.js +97 -0
  37. package/dist/layer2-business/L2-9-contribution/identity-claim-read.js +59 -0
  38. package/dist/layer2-business/L2-9-contribution/task-proposal-store.js +129 -0
  39. package/dist/layer2-business/L2-notes/note-photo-storage.js +4 -2
  40. package/dist/layer3-trust/L3-1-dispute-engine/dispute-engine.js +17 -15
  41. package/dist/layer3-trust/L3-1-dispute-engine/evidence-storage.js +11 -8
  42. package/dist/layer4-economics/L4-3-reputation/reputation-engine.js +9 -8
  43. package/dist/layer4-economics/L4-4-skill-market/skill-engine.js +11 -8
  44. package/dist/layer4-economics/L4-4-skill-market/skill-listing-engine.js +22 -16
  45. package/dist/pwa/acp-feed.js +13 -1
  46. package/dist/pwa/contract-fingerprint.js +2 -0
  47. package/dist/pwa/endpoint-actions.js +5 -1
  48. package/dist/pwa/goal-index.js +8 -8
  49. package/dist/pwa/human-presence.js +62 -0
  50. package/dist/pwa/public/app.js +575 -68
  51. package/dist/pwa/public/i18n.js +29 -20
  52. package/dist/pwa/public/index.html +1 -0
  53. package/dist/pwa/public/openapi.json +2 -2
  54. package/dist/pwa/rate-limit.js +22 -0
  55. package/dist/pwa/routes/account-deletion.js +15 -13
  56. package/dist/pwa/routes/addresses.js +10 -9
  57. package/dist/pwa/routes/admin-admins.js +13 -14
  58. package/dist/pwa/routes/admin-analytics.js +109 -69
  59. package/dist/pwa/routes/admin-catalog.js +13 -11
  60. package/dist/pwa/routes/admin-editor-picks.js +15 -10
  61. package/dist/pwa/routes/admin-events.js +5 -3
  62. package/dist/pwa/routes/admin-health.js +2 -1
  63. package/dist/pwa/routes/admin-moderation.js +26 -29
  64. package/dist/pwa/routes/admin-ops.js +22 -21
  65. package/dist/pwa/routes/admin-protocol-params.js +16 -19
  66. package/dist/pwa/routes/admin-reports.js +23 -21
  67. package/dist/pwa/routes/admin-tokenomics.js +26 -25
  68. package/dist/pwa/routes/admin-users-lifecycle.js +37 -40
  69. package/dist/pwa/routes/admin-users-query.js +54 -53
  70. package/dist/pwa/routes/admin-verifier-flow.js +82 -41
  71. package/dist/pwa/routes/admin-verifier-whitelist.js +55 -27
  72. package/dist/pwa/routes/admin-wallet-ops.js +7 -5
  73. package/dist/pwa/routes/agent-buy.js +46 -22
  74. package/dist/pwa/routes/agent-governance.js +52 -56
  75. package/dist/pwa/routes/ai.js +7 -5
  76. package/dist/pwa/routes/analytics.js +43 -41
  77. package/dist/pwa/routes/anchors.js +19 -20
  78. package/dist/pwa/routes/announcements.js +13 -13
  79. package/dist/pwa/routes/arbitrator.js +97 -31
  80. package/dist/pwa/routes/auction.js +153 -114
  81. package/dist/pwa/routes/auth-login.js +6 -4
  82. package/dist/pwa/routes/auth-read.js +11 -9
  83. package/dist/pwa/routes/auth-register.js +35 -20
  84. package/dist/pwa/routes/auth-sessions.js +12 -11
  85. package/dist/pwa/routes/blocklist.js +16 -15
  86. package/dist/pwa/routes/build-feedback.js +10 -9
  87. package/dist/pwa/routes/build-reputation.js +6 -2
  88. package/dist/pwa/routes/build-tasks.js +45 -13
  89. package/dist/pwa/routes/buyer-feeds.js +27 -25
  90. package/dist/pwa/routes/cart.js +16 -15
  91. package/dist/pwa/routes/charity.js +212 -150
  92. package/dist/pwa/routes/chat.js +42 -43
  93. package/dist/pwa/routes/checkin-tasks.js +10 -9
  94. package/dist/pwa/routes/checkout-helpers.js +12 -10
  95. package/dist/pwa/routes/claim-initiators.js +34 -14
  96. package/dist/pwa/routes/claim-verify.js +86 -53
  97. package/dist/pwa/routes/claim-voting.js +43 -18
  98. package/dist/pwa/routes/contribution-identity.js +147 -0
  99. package/dist/pwa/routes/contribution-score.js +19 -0
  100. package/dist/pwa/routes/coupons.js +19 -16
  101. package/dist/pwa/routes/dashboards.js +18 -16
  102. package/dist/pwa/routes/dispute-cases.js +25 -24
  103. package/dist/pwa/routes/disputes-read.js +45 -51
  104. package/dist/pwa/routes/disputes-write.js +124 -61
  105. package/dist/pwa/routes/evidence.js +9 -9
  106. package/dist/pwa/routes/external-anchors.js +13 -12
  107. package/dist/pwa/routes/feedback.js +29 -33
  108. package/dist/pwa/routes/flash-sales.js +18 -16
  109. package/dist/pwa/routes/follows.js +25 -24
  110. package/dist/pwa/routes/governance-auto-deactivate.js +21 -9
  111. package/dist/pwa/routes/governance-onboarding.js +70 -59
  112. package/dist/pwa/routes/group-buys.js +22 -22
  113. package/dist/pwa/routes/growth.js +33 -30
  114. package/dist/pwa/routes/import-product.js +12 -10
  115. package/dist/pwa/routes/kyc.js +9 -8
  116. package/dist/pwa/routes/leaderboard.js +20 -18
  117. package/dist/pwa/routes/listings.js +23 -22
  118. package/dist/pwa/routes/logistics.js +10 -8
  119. package/dist/pwa/routes/manifests.js +27 -27
  120. package/dist/pwa/routes/me-data.js +23 -21
  121. package/dist/pwa/routes/notifications.js +7 -6
  122. package/dist/pwa/routes/offers.js +30 -12
  123. package/dist/pwa/routes/orders-action.js +33 -17
  124. package/dist/pwa/routes/orders-create.js +75 -20
  125. package/dist/pwa/routes/orders-read.js +21 -20
  126. package/dist/pwa/routes/p2p-products.js +30 -18
  127. package/dist/pwa/routes/payments-governance.js +61 -56
  128. package/dist/pwa/routes/peers.js +9 -8
  129. package/dist/pwa/routes/pin-receipts.js +13 -13
  130. package/dist/pwa/routes/products-aliases.js +12 -10
  131. package/dist/pwa/routes/products-claims.js +36 -17
  132. package/dist/pwa/routes/products-create.js +53 -38
  133. package/dist/pwa/routes/products-crud.js +17 -16
  134. package/dist/pwa/routes/products-links.js +49 -26
  135. package/dist/pwa/routes/products-list.js +6 -4
  136. package/dist/pwa/routes/products-meta.js +40 -39
  137. package/dist/pwa/routes/products-update.js +19 -5
  138. package/dist/pwa/routes/profile-credentials.js +14 -16
  139. package/dist/pwa/routes/profile-identity.js +14 -13
  140. package/dist/pwa/routes/profile-location.js +7 -6
  141. package/dist/pwa/routes/profile-placement.js +19 -17
  142. package/dist/pwa/routes/profile-prefs.js +11 -11
  143. package/dist/pwa/routes/promoter.js +55 -49
  144. package/dist/pwa/routes/public-build-tasks.js +19 -0
  145. package/dist/pwa/routes/public-utils.js +108 -46
  146. package/dist/pwa/routes/push.js +16 -15
  147. package/dist/pwa/routes/ratings.js +30 -30
  148. package/dist/pwa/routes/recover-key.js +13 -12
  149. package/dist/pwa/routes/referral.js +37 -32
  150. package/dist/pwa/routes/reputation.js +3 -2
  151. package/dist/pwa/routes/returns.js +76 -73
  152. package/dist/pwa/routes/reviews.js +41 -18
  153. package/dist/pwa/routes/rewards-apply.js +16 -15
  154. package/dist/pwa/routes/rewards-auto-downgrade.js +9 -7
  155. package/dist/pwa/routes/rewards-escrow-expire.js +7 -5
  156. package/dist/pwa/routes/rfqs.js +163 -85
  157. package/dist/pwa/routes/search.js +16 -14
  158. package/dist/pwa/routes/secondhand.js +25 -22
  159. package/dist/pwa/routes/seller-quota.js +24 -26
  160. package/dist/pwa/routes/share-redirects.js +59 -55
  161. package/dist/pwa/routes/shareables-interactions.js +34 -35
  162. package/dist/pwa/routes/shareables.js +55 -51
  163. package/dist/pwa/routes/shop-referral.js +57 -0
  164. package/dist/pwa/routes/shops.js +20 -18
  165. package/dist/pwa/routes/signaling.js +10 -9
  166. package/dist/pwa/routes/skill-market.js +16 -16
  167. package/dist/pwa/routes/skills.js +15 -14
  168. package/dist/pwa/routes/snf.js +14 -13
  169. package/dist/pwa/routes/tags.js +10 -9
  170. package/dist/pwa/routes/task-proposals.js +45 -0
  171. package/dist/pwa/routes/trial.js +69 -51
  172. package/dist/pwa/routes/trusted-kpi.js +20 -18
  173. package/dist/pwa/routes/url-claim.js +67 -28
  174. package/dist/pwa/routes/users-public.js +62 -60
  175. package/dist/pwa/routes/variants.js +12 -13
  176. package/dist/pwa/routes/verifier-user.js +61 -21
  177. package/dist/pwa/routes/verify-tasks.js +49 -25
  178. package/dist/pwa/routes/waitlist.js +16 -15
  179. package/dist/pwa/routes/wallet-read.js +74 -36
  180. package/dist/pwa/routes/wallet-write.js +12 -9
  181. package/dist/pwa/routes/webauthn.js +25 -26
  182. package/dist/pwa/routes/webhooks.js +26 -26
  183. package/dist/pwa/routes/welcome.js +45 -50
  184. package/dist/pwa/routes/wishlist-qa.js +29 -32
  185. package/dist/pwa/server.js +237 -81
  186. package/dist/version.js +1 -1
  187. package/package.json +47 -2
@@ -419,7 +419,6 @@ const _EN = {
419
419
  '已授予': 'Granted',
420
420
  '未授予': 'Not granted',
421
421
  '授予': 'Grant',
422
- '已解锁分享奖励资格': 'Eligible for share rewards',
423
422
  '分享奖励待解锁': 'Share rewards locked',
424
423
  'Admin 强制授予': 'Admin grant override',
425
424
  '笔订单 — 可拿分享佣金': 'orders — can earn 3-tier commission',
@@ -1089,6 +1088,7 @@ const _EN = {
1089
1088
  // ── Growth tasks (Promoter page) ────────────────────────────
1090
1089
  '成为分享达人的路线图。可领取/跳过/放弃,按自己节奏走。': 'Roadmap to become a share pro. Claim / skip / drop — go at your own pace.',
1091
1090
  '推荐领取': 'Recommended',
1091
+ '查看更多推荐': 'Show more',
1092
1092
  '已跳过': 'Skipped',
1093
1093
  '查看全部可领取': 'View all available',
1094
1094
  '🎉 所有当前任务已完成,下一关任务正在路上': '🎉 All current tasks done — next chapter on the way',
@@ -1217,6 +1217,10 @@ const _EN = {
1217
1217
  '点击复制,去 TikTok/小红书 引流': 'Click to copy — share on TikTok/Xiaohongshu',
1218
1218
  '口令已复制,去 TikTok / 小红书 口播吧!': 'Anchor copied — go promote it on TikTok / Xiaohongshu!',
1219
1219
  '复制失败,请手动复制': 'Copy failed — please copy manually',
1220
+ '推荐店铺': 'Recommend this shop',
1221
+ '店铺推荐只锚定推荐关系;只有你真实成交过的同款商品,后续成交才可能形成商品推荐关系': 'A shop referral only anchors the referral relationship; only products you have actually purchased (completed) can later form a product referral relationship',
1222
+ '店铺推荐链接已复制 — 商品分润仍需你真实成交过同款并 opt-in': 'Shop referral link copied — product commission still requires your own completed purchase of the same item plus the share-commission opt-in',
1223
+ '邀请码暂不可用,请刷新或联系支持': 'Invite code unavailable — refresh or contact support',
1220
1224
  '匿名聚合': 'Anonymous',
1221
1225
  '新品发现': 'New Finds',
1222
1226
  '新近上架': 'Just listed',
@@ -1589,13 +1593,11 @@ const _EN = {
1589
1593
  '你被': 'You\'re invited by',
1590
1594
  '邀请来 WebAZ': '— welcome to WebAZ',
1591
1595
  '邀请你': 'invites you to',
1592
- '注册即拿邀请奖励,TA 也得佣金 — 双方共赢': 'Register and you both win — referral bonus for you, commission share for them',
1593
1596
  '注册解锁全部功能': 'Register to unlock all features',
1594
1597
  '回到原页': 'Back to original',
1595
1598
  '完成 3 步开始使用': 'Complete 3 steps to start',
1596
1599
  '设置默认配送地址(智能下单需要)': 'Set default shipping address (required for smart-order)',
1597
1600
  '设置登录密码(备用凭证,可选)': 'Set login password (backup credential, optional)',
1598
- '完成首笔购买,解锁分享奖励': 'Complete first purchase to unlock share rewards',
1599
1601
  '先去填资料': 'Set up profile first',
1600
1602
  '稍后再说,先逛逛': 'Maybe later — just browse',
1601
1603
  '立即保存你的 API Key': 'Save your API Key now',
@@ -3558,7 +3560,6 @@ const _EN = {
3558
3560
  // ─── 拼接片段(避免 EN 显示中文)─────
3559
3561
  ' 的赔付金额': ' compensation',
3560
3562
  ' 的邀请,TA 也获得分润。后会有期 ~': '\'s invitation — they earn revenue share too. See you ~',
3561
- '注册即拿邀请奖励,TA 也得分润 — 双方共赢': 'Register to claim invite reward — they earn revenue share too. Win-win.',
3562
3563
 
3563
3564
  // Buyer #me 扩展 — Phase 4 入口补齐
3564
3565
  '市场与交易': 'Market & Trade',
@@ -4254,6 +4255,13 @@ const _EN = {
4254
4255
  '无需注册即可留言提问;我们会逐一阅读。': 'No signup needed — leave a question / idea; we read each one.',
4255
4256
  '无需登录 · 留下问题/建议/想法,我们会逐一回应': 'No login required · leave questions / ideas / suggestions, we respond to each',
4256
4257
  '选一个开始的方式': 'Pick a way to start',
4258
+ '开始使用 WebAZ': 'Get started with WebAZ',
4259
+ '注册 / 登录': 'Sign up / Log in',
4260
+ '浏览公开任务板': 'Browse the public task board',
4261
+ '提建议(无需登录)': 'Suggest an idea (no login)',
4262
+ '通过邀请进入会记录归因;分享分润需登录后单独申请。': 'Joining via an invite records attribution; share-commission requires a separate application after login.',
4263
+ '完成首笔购买后,可申请分享分润。': 'After your first purchase, you can apply for share-commission.',
4264
+ '仅在私密设备打开;不要截图、转发或发送给任何人。': 'Open only on a private device; never screenshot, forward, or send it to anyone.',
4257
4265
  '「建议」无需注册即可投递;我们会逐一阅读。': 'Ideas can be submitted without signup — we read each one.',
4258
4266
  '无需登录 · 协议会记录并回应': 'No login required · protocol records and responds',
4259
4267
  '描述你的建议 / 想法 / 痛点 / bug …(10-2000 字)': 'Describe your idea / pain point / bug … (10-2000 chars)',
@@ -4569,16 +4577,17 @@ const _EN = {
4569
4577
  '已自动加入「我的分享」': 'Auto added to "My Shares"',
4570
4578
  '完成该商品的购买后再分享': 'Share after completing the purchase of this item',
4571
4579
  '待补': 'Missing',
4572
- '前往 #me 申请共建身份': 'Go to #me to apply for builder identity',
4580
+ '前往 #me 申请分享分润': 'Go to #me to opt in to revenue sharing',
4573
4581
  '联系我们': 'Contact us',
4574
4582
  '合作 / 反馈 / 合规咨询': 'Partnerships / feedback / compliance',
4575
- '申请共建身份': 'Apply for builder identity',
4576
- '共建身份': 'Builder identity',
4577
- '共建身份管理': 'Manage builder identity',
4578
- '已是共建身份': 'Already opted in',
4583
+ '申请分享分润': 'Opt in to revenue sharing',
4584
+ '分享分润身份': 'Revenue-share opt-in',
4585
+ '分享分润管理': 'Manage revenue sharing',
4586
+ '已开通分享分润': 'Already opted in',
4579
4587
  '你已 opted-in。如需查看状态或退出,前往 ': 'You are opted in. To view status or opt out, go to ',
4580
4588
  '本流程与购物无关': 'This flow is not part of shopping',
4581
4589
  '你可以随时退出,不影响任何已下单或未来订单。本流程涉及经济关系登记(三级佣金 + 积分配对),请仔细阅读全部条款。': 'You can leave anytime without affecting any past or future orders. This is an economic-relationship registration (3-tier commission + points-matching) — please read all terms carefully.',
4590
+ '注:本「分享分润 / rewards opt-in」仅为 commission / PV / escrow 经济关系登记,不是贡献资格,与贡献任务(#contribute/tasks)/ 我的共建 无关。RFC-002 同意书可能沿用更早措辞,以本 UI 含义为准。': 'Note: this “share-commission / rewards opt-in” is only a commission / PV / escrow economic-relationship registration — NOT contribution eligibility, and unrelated to the contribution funnel (#contribute/tasks) / My contributions. RFC-002’s consent text may retain older wording; this note governs the UI meaning.',
4582
4591
  '门槛(全部通过才能申请)': 'Eligibility (all must pass to apply)',
4583
4592
  '已完成订单': 'Completed orders',
4584
4593
  'Passkey 已注册': 'Passkey registered',
@@ -4592,23 +4601,23 @@ const _EN = {
4592
4601
  '请通过 Passkey / 生物识别确认...': 'Please confirm via Passkey / biometric...',
4593
4602
  'Passkey 签发失败:': 'Passkey signature failed:',
4594
4603
  '提交中...': 'Submitting...',
4595
- '✅ 共建身份激活成功': '✅ Builder identity activated',
4604
+ '✅ 分享分润开通成功': '✅ Revenue sharing activated',
4596
4605
  '已从 escrow 拨回:': 'Restored from escrow:',
4597
4606
  '笔': 'entries',
4598
- '共建身份激活中': 'Active',
4607
+ '分享分润已开通': 'Active',
4599
4608
  '未激活': 'Never activated',
4600
4609
  '已自动降级(consent 未确认)': 'Auto-downgraded (consent not re-confirmed)',
4601
4610
  '已退出': 'Deactivated',
4602
4611
  'Consent version': 'Consent version',
4603
4612
  '待领 escrow': 'Pending escrow',
4604
- 'opt-in 后这笔钱会拨回钱包。30 天未领过期入公益。': 'These will be restored to your wallet on opt-in. Unclaimed escrow expires to charity after 30 days.',
4605
- '历史过期入公益': 'Historical (expired to charity)',
4606
- '退出共建身份后,未来 commission 直接入公益(无 escrow)。可随时再申请。': 'After deactivation, future commission goes directly to charity (no escrow). You can re-apply anytime.',
4607
- '退出共建身份': 'Deactivate',
4613
+ 'opt-in 后这笔钱会拨回钱包。30 天未领过期入协议公池。': 'These will be restored to your wallet on opt-in. Unclaimed escrow expires to the protocol reserve (commission_reserve) after 30 days.',
4614
+ '历史过期入协议公池': 'Historical (expired to reserve)',
4615
+ '退出分享分润后,未来 commission 进入协议公池(commission_reserve),不是慈善基金。可随时重新开通。': 'After opting out, future commission goes to the protocol reserve (commission_reserve), not the charity fund. You can re-opt-in anytime.',
4616
+ '退出分享分润': 'Opt out of revenue sharing',
4608
4617
  '重新申请': 'Re-apply',
4609
4618
  '协议依据:': 'Protocol spec:',
4610
- '确认退出共建身份?未来 commission 将直接入公益,可随时再申请。': 'Confirm opt-out? Future commission goes directly to charity. You can re-apply anytime.',
4611
- '✅ 已退出共建身份': '✅ Deactivated',
4619
+ '确认退出分享分润?未来 commission 将进入协议公池(commission_reserve,非慈善基金),可随时重新开通。': 'Confirm opt-out? Future commission goes to the protocol reserve (commission_reserve), not charity. You can re-opt-in anytime.',
4620
+ '✅ 已退出分享分润': '✅ Opted out',
4612
4621
  '申请制 · 含锁仓金': 'opt-in · with escrow',
4613
4622
  '点击复制 →': 'Click to copy →',
4614
4623
  '已申请公开': 'Public application submitted',
@@ -6047,9 +6056,9 @@ const _EN = {
6047
6056
  '提案': 'Proposal',
6048
6057
  '共建信誉': 'Co-build reputation',
6049
6058
  // RFC-004 体验补:无锚点受理 → 引导绑 Passkey 领取(转化,而非困惑)
6050
- '这条贡献已被采纳 —— 绑定 Passkey 即可领取建设信誉(奖励需锚定可问责真人)': 'This contribution was accepted — bind a Passkey to claim its co-build reputation (rewards must anchor to an accountable human)',
6051
- '绑定 Passkey 领取': 'Bind Passkey to claim',
6052
- '已绑定,建设信誉已补发': 'Passkey bound — co-build reputation has been granted',
6059
+ '这条贡献已被采纳 —— 绑定 Passkey 即可记入建设信誉(建设信誉需锚定可问责真人)': 'This contribution was accepted — bind a Passkey to record it into your build reputation (build reputation must anchor to an accountable human)',
6060
+ '绑定 Passkey 记入建设信誉': 'Bind Passkey to record build reputation',
6061
+ '已绑定,建设信誉已记入': 'Passkey bound — build reputation recorded',
6053
6062
  // RFC-006 Gap 2:贡献者看板
6054
6063
  '我的共建': 'My contributions',
6055
6064
  '你的建设贡献(独立于交易信誉 — 不影响 verifier/仲裁准入)': 'Your building contributions (separate from trade reputation — does NOT gate verifier/arbitrator)',
@@ -37,6 +37,7 @@
37
37
  <p><strong>For AI agents:</strong> browse, compare, order and track fulfillment via the Model Context Protocol (MCP). Protocol state is public at <a href="/.well-known/webaz-protocol.json">/.well-known/webaz-protocol.json</a>; the integration contract is at <a href="/.well-known/webaz-integration.json">/.well-known/webaz-integration.json</a>.</p>
38
38
  <p><strong>Status:</strong> pre-launch — WAZ is a simulated test currency; no real money settles yet.</p>
39
39
  <p><strong>Browse now — no account needed:</strong> <a href="/#discover">/#discover</a> · <strong>Want in?</strong> Pre-launch is invite-gated; request an invite (leave your email) at <a href="/#welcome">/#welcome</a>.</p>
40
+ <p><strong>Follow the launch:</strong> live protocol pulse (real counts + milestones) at <a href="/.well-known/webaz-launch-pulse.json">/.well-known/webaz-launch-pulse.json</a> — watch it wake up.</p>
40
41
  <p style="color:#6b7280;font-size:14px">Source repo opens at public launch — <a href="https://github.com/seasonsagents-art/webaz">github.com/seasonsagents-art/webaz</a> may 404 until then; the full machine-readable spec is already public at <a href="/.well-known/webaz-integration.json">/.well-known/webaz-integration.json</a>.</p>
41
42
  <p style="color:#6b7280;font-size:14px">This page is an interactive app and needs JavaScript for full functionality.</p>
42
43
  </main>
@@ -4011,7 +4011,7 @@
4011
4011
  },
4012
4012
  "sponsor_hint": {
4013
4013
  "type": "string",
4014
- "description": "推荐人 user_id / permanent_code(三层归属用)"
4014
+ "description": "推荐人邀请码:6-7 位 permanent_code,可带 -L/-R 分边(三层归属用;注册邀请不再接受 user_id / @handle)"
4015
4015
  },
4016
4016
  "coupon_code": {
4017
4017
  "type": "string"
@@ -5598,7 +5598,7 @@
5598
5598
  },
5599
5599
  "/i/:code": {
5600
5600
  "get": {
5601
- "summary": "解析后 302 到 /?ref=<短码>[&side=left|right](保留原形态,URL 友好;后端 resolveUserRef 解析)",
5601
+ "summary": "302 到 /?ref=<permanent_code>[&side=left|right](invite-code only:后端 resolveInviteCodeRef 仅解析 6-7 位 permanent_code,可带 -L/-R;@handle / usr_xxx → 404)",
5602
5602
  "tags": [],
5603
5603
  "security": []
5604
5604
  }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Minimal in-memory sliding-window rate limiter for anonymous/public endpoints (no api_key to key on).
3
+ * `createSlidingWindowLimiter(limit, windowMs)` returns `(key) => boolean`: records the call and returns
4
+ * true while the key has ≤ limit hits in the trailing window, false once it exceeds. Per-process (fine for
5
+ * the current single-host pre-launch deployment); a multi-replica deployment would back it with a store.
6
+ */
7
+ export function createSlidingWindowLimiter(limit, windowMs) {
8
+ const hits = new Map();
9
+ return (key) => {
10
+ const now = Date.now();
11
+ const recent = (hits.get(key) ?? []).filter(t => now - t < windowMs);
12
+ recent.push(now);
13
+ hits.set(key, recent);
14
+ // opportunistic prune so the map doesn't grow unbounded across many distinct keys
15
+ if (hits.size > 10_000)
16
+ for (const [k, v] of hits) {
17
+ if (v.every(t => now - t >= windowMs))
18
+ hits.delete(k);
19
+ }
20
+ return recent.length <= limit;
21
+ };
22
+ }
@@ -1,26 +1,28 @@
1
+ import { dbOne, dbRun } from '../../layer0-foundation/L0-1-database/db.js'; // RFC-016 异步 DB seam
1
2
  export function registerAccountDeletionRoutes(app, deps) {
2
- const { db, auth } = deps;
3
- app.post('/api/me/delete-request', (req, res) => {
3
+ // db 已走 RFC-016 异步 seam(dbOne/dbRun),不再直接用 deps.db
4
+ const { auth } = deps;
5
+ app.post('/api/me/delete-request', async (req, res) => {
4
6
  const user = auth(req, res);
5
7
  if (!user)
6
8
  return;
7
9
  const uid = user.id;
8
10
  const reason = String((req.body || {}).reason || '').slice(0, 500);
9
11
  const blockers = [];
10
- const pendingOrders = db.prepare(`SELECT COUNT(*) as n FROM orders WHERE (buyer_id = ? OR seller_id = ?) AND status NOT IN ('completed', 'confirmed', 'cancelled', 'refunded_full', 'refunded_partial')`).get(uid, uid).n;
12
+ const pendingOrders = (await dbOne(`SELECT COUNT(*) as n FROM orders WHERE (buyer_id = ? OR seller_id = ?) AND status NOT IN ('completed', 'confirmed', 'cancelled', 'refunded_full', 'refunded_partial')`, [uid, uid])).n;
11
13
  if (pendingOrders > 0)
12
14
  blockers.push(`你有 ${pendingOrders} 个未完成订单,请先处理`);
13
15
  // #1017 fix: dispute_cases 是已结公开判例(无 status 列);查"未结争议"应走 disputes 表
14
- const openDisputes = db.prepare(`SELECT COUNT(*) as n FROM disputes WHERE (initiator_id = ? OR defendant_id = ?) AND status NOT IN ('resolved', 'closed')`).get(uid, uid).n;
16
+ const openDisputes = (await dbOne(`SELECT COUNT(*) as n FROM disputes WHERE (initiator_id = ? OR defendant_id = ?) AND status NOT IN ('resolved', 'closed')`, [uid, uid])).n;
15
17
  if (openDisputes > 0)
16
18
  blockers.push(`你有 ${openDisputes} 个未结争议,请先处理`);
17
- const wallet = db.prepare(`SELECT balance FROM wallets WHERE user_id = ?`).get(uid);
19
+ const wallet = await dbOne(`SELECT balance FROM wallets WHERE user_id = ?`, [uid]);
18
20
  if (wallet && wallet.balance > 0.01)
19
21
  blockers.push(`钱包余额 ${wallet.balance} WAZ — 请先提现`);
20
22
  if (blockers.length > 0)
21
23
  return void res.status(400).json({ error: '账号注销前请先处理', blockers });
22
- db.prepare(`INSERT OR REPLACE INTO account_deletion_requests (user_id, requested_at, reason, cancelled_at, pii_wiped_at) VALUES (?, datetime('now'), ?, NULL, NULL)`).run(uid, reason);
23
- db.prepare(`UPDATE users SET feed_visible = 0, deleted_requested_at = datetime('now') WHERE id = ?`).run(uid);
24
+ await dbRun(`INSERT OR REPLACE INTO account_deletion_requests (user_id, requested_at, reason, cancelled_at, pii_wiped_at) VALUES (?, datetime('now'), ?, NULL, NULL)`, [uid, reason]);
25
+ await dbRun(`UPDATE users SET feed_visible = 0, deleted_requested_at = datetime('now') WHERE id = ?`, [uid]);
24
26
  res.json({
25
27
  ok: true,
26
28
  cooldown_days: 7,
@@ -28,26 +30,26 @@ export function registerAccountDeletionRoutes(app, deps) {
28
30
  notice: '账号已进入注销冷却期。7 天内可撤销,14 天后 PII 永久擦除(笔记/订单匿名化保留)。',
29
31
  });
30
32
  });
31
- app.post('/api/me/delete-cancel', (req, res) => {
33
+ app.post('/api/me/delete-cancel', async (req, res) => {
32
34
  const user = auth(req, res);
33
35
  if (!user)
34
36
  return;
35
37
  const uid = user.id;
36
- const req_row = db.prepare(`SELECT * FROM account_deletion_requests WHERE user_id = ? AND cancelled_at IS NULL AND pii_wiped_at IS NULL`).get(uid);
38
+ const req_row = await dbOne(`SELECT * FROM account_deletion_requests WHERE user_id = ? AND cancelled_at IS NULL AND pii_wiped_at IS NULL`, [uid]);
37
39
  if (!req_row)
38
40
  return void res.status(404).json({ error: 'no active deletion request' });
39
41
  const reqTs = new Date(req_row.requested_at.replace(' ', 'T') + 'Z').getTime();
40
42
  if (Date.now() - reqTs > 7 * 86400_000)
41
43
  return void res.status(400).json({ error: '冷却期已过,无法撤销' });
42
- db.prepare(`UPDATE account_deletion_requests SET cancelled_at = datetime('now') WHERE user_id = ?`).run(uid);
43
- db.prepare(`UPDATE users SET feed_visible = 1, deleted_requested_at = NULL WHERE id = ?`).run(uid);
44
+ await dbRun(`UPDATE account_deletion_requests SET cancelled_at = datetime('now') WHERE user_id = ?`, [uid]);
45
+ await dbRun(`UPDATE users SET feed_visible = 1, deleted_requested_at = NULL WHERE id = ?`, [uid]);
44
46
  res.json({ ok: true, message: '账号注销已撤销' });
45
47
  });
46
- app.get('/api/me/delete-status', (req, res) => {
48
+ app.get('/api/me/delete-status', async (req, res) => {
47
49
  const user = auth(req, res);
48
50
  if (!user)
49
51
  return;
50
- const row = db.prepare(`SELECT requested_at, cancelled_at, pii_wiped_at, reason FROM account_deletion_requests WHERE user_id = ?`).get(user.id);
52
+ const row = await dbOne(`SELECT requested_at, cancelled_at, pii_wiped_at, reason FROM account_deletion_requests WHERE user_id = ?`, [user.id]);
51
53
  res.json({ deletion_request: row || null });
52
54
  });
53
55
  }
@@ -1,16 +1,17 @@
1
+ import { dbOne, dbAll } from '../../layer0-foundation/L0-1-database/db.js'; // RFC-016 异步 DB seam
1
2
  export function registerAddressesRoutes(app, deps) {
2
3
  const { db, generateId, auth, isTrustedRole, errorRes } = deps;
3
- app.get('/api/addresses', (req, res) => {
4
+ app.get('/api/addresses', async (req, res) => {
4
5
  const user = auth(req, res);
5
6
  if (!user)
6
7
  return;
7
8
  if (isTrustedRole(user))
8
9
  return void errorRes(res, 403, 'TRUSTED_ROLE_NO_TRADE', '受信角色无购物功能');
9
- const rows = db.prepare(`SELECT id, label, recipient, phone, region, detail, is_default, created_at
10
- FROM user_addresses WHERE user_id = ? ORDER BY is_default DESC, created_at DESC LIMIT 50`).all(user.id);
10
+ const rows = await dbAll(`SELECT id, label, recipient, phone, region, detail, is_default, created_at
11
+ FROM user_addresses WHERE user_id = ? ORDER BY is_default DESC, created_at DESC LIMIT 50`, [user.id]);
11
12
  res.json({ items: rows });
12
13
  });
13
- app.post('/api/addresses', (req, res) => {
14
+ app.post('/api/addresses', async (req, res) => {
14
15
  const user = auth(req, res);
15
16
  if (!user)
16
17
  return;
@@ -22,7 +23,7 @@ export function registerAddressesRoutes(app, deps) {
22
23
  if (String(label).length > 30 || String(recipient).length > 60 || String(detail).length > 200) {
23
24
  return void res.status(400).json({ error: '字段超长(标签≤30, 收件人≤60, 详址≤200)' });
24
25
  }
25
- const cnt = db.prepare('SELECT COUNT(*) as n FROM user_addresses WHERE user_id = ?').get(user.id).n;
26
+ const cnt = (await dbOne('SELECT COUNT(*) as n FROM user_addresses WHERE user_id = ?', [user.id])).n;
26
27
  if (cnt >= 20)
27
28
  return void res.status(400).json({ error: '地址数量已达上限 (20)' });
28
29
  const id = generateId('adr');
@@ -35,11 +36,11 @@ export function registerAddressesRoutes(app, deps) {
35
36
  })();
36
37
  res.json({ success: true, id });
37
38
  });
38
- app.patch('/api/addresses/:id', (req, res) => {
39
+ app.patch('/api/addresses/:id', async (req, res) => {
39
40
  const user = auth(req, res);
40
41
  if (!user)
41
42
  return;
42
- const row = db.prepare('SELECT user_id FROM user_addresses WHERE id = ?').get(req.params.id);
43
+ const row = await dbOne('SELECT user_id FROM user_addresses WHERE id = ?', [req.params.id]);
43
44
  if (!row)
44
45
  return void res.status(404).json({ error: '地址不存在' });
45
46
  if (row.user_id !== user.id)
@@ -82,11 +83,11 @@ export function registerAddressesRoutes(app, deps) {
82
83
  })();
83
84
  res.json({ success: true });
84
85
  });
85
- app.delete('/api/addresses/:id', (req, res) => {
86
+ app.delete('/api/addresses/:id', async (req, res) => {
86
87
  const user = auth(req, res);
87
88
  if (!user)
88
89
  return;
89
- const row = db.prepare('SELECT user_id, is_default FROM user_addresses WHERE id = ?').get(req.params.id);
90
+ const row = await dbOne('SELECT user_id, is_default FROM user_addresses WHERE id = ?', [req.params.id]);
90
91
  if (!row)
91
92
  return void res.status(404).json({ error: '地址不存在' });
92
93
  if (row.user_id !== user.id)
@@ -1,17 +1,18 @@
1
+ import { dbOne, dbAll, dbRun } from '../../layer0-foundation/L0-1-database/db.js'; // RFC-016 异步 DB seam
1
2
  export function registerAdminAdminsRoutes(app, deps) {
2
3
  const { db, generateId, requireAdmin, requireRootAdmin, isRootAdmin, getAdminPermissions, ADMIN_PERMISSIONS } = deps;
3
4
  // GET 全部 admin 列表
4
- app.get('/api/admin/admins', (req, res) => {
5
+ app.get('/api/admin/admins', async (req, res) => {
5
6
  const me = requireAdmin(req, res);
6
7
  if (!me)
7
8
  return;
8
- const items = db.prepare(`
9
+ const items = await dbAll(`
9
10
  SELECT id, name, handle, role, admin_type, admin_scope, admin_permissions, email, created_at,
10
11
  (SELECT MAX(created_at) FROM admin_audit_log WHERE admin_id = users.id) AS last_action_at
11
12
  FROM users
12
13
  WHERE role = 'admin' OR (roles IS NOT NULL AND roles LIKE '%admin%')
13
14
  ORDER BY admin_type DESC, created_at ASC
14
- `).all();
15
+ `, []);
15
16
  // 普通 admin 视角下 email 脱敏
16
17
  const masked = items.map((u) => {
17
18
  const enriched = { ...u, admin_permissions: u.admin_type === 'root' ? ['all'] : (() => { try {
@@ -31,7 +32,7 @@ export function registerAdminAdminsRoutes(app, deps) {
31
32
  });
32
33
  });
33
34
  // POST 创建 admin(仅 root)
34
- app.post('/api/admin/admins', (req, res) => {
35
+ app.post('/api/admin/admins', async (req, res) => {
35
36
  const root = requireRootAdmin(req, res);
36
37
  if (!root)
37
38
  return;
@@ -60,7 +61,7 @@ export function registerAdminAdminsRoutes(app, deps) {
60
61
  return void res.json({ error: 'admin_type 无效' });
61
62
  if (!['global', 'china', 'us', 'eu', 'india', 'singapore', 'global_north'].includes(adminScope))
62
63
  return void res.json({ error: 'admin_scope 无效' });
63
- const target = db.prepare(`SELECT id, role, roles, admin_type FROM users WHERE id = ?`).get(targetUserId);
64
+ const target = await dbOne(`SELECT id, role, roles, admin_type FROM users WHERE id = ?`, [targetUserId]);
64
65
  if (!target)
65
66
  return void res.json({ error: '用户不存在' });
66
67
  if (target.admin_type)
@@ -87,7 +88,7 @@ export function registerAdminAdminsRoutes(app, deps) {
87
88
  res.json({ ok: true, user_id: targetUserId, admin_type: adminType, admin_scope: adminScope, admin_permissions: adminPerms });
88
89
  });
89
90
  // PATCH 更新权限(root only)
90
- app.patch('/api/admin/admins/:id/permissions', (req, res) => {
91
+ app.patch('/api/admin/admins/:id/permissions', async (req, res) => {
91
92
  const root = requireRootAdmin(req, res);
92
93
  if (!root)
93
94
  return;
@@ -102,33 +103,31 @@ export function registerAdminAdminsRoutes(app, deps) {
102
103
  for (const p of adminPerms)
103
104
  if (!validPerms.has(p))
104
105
  return void res.json({ error: `权限 "${p}" 无效` });
105
- const target = db.prepare(`SELECT id, admin_type FROM users WHERE id = ?`).get(targetId);
106
+ const target = await dbOne(`SELECT id, admin_type FROM users WHERE id = ?`, [targetId]);
106
107
  if (!target?.admin_type)
107
108
  return void res.json({ error: '该用户不是 admin' });
108
109
  if (target.admin_type === 'root')
109
110
  return void res.json({ error: 'root admin 权限不可手动调整(永远是 all)' });
110
111
  if (adminPerms.length === 0)
111
112
  return void res.json({ error: '至少保留一项权限' });
112
- db.prepare(`UPDATE users SET admin_permissions = ?${adminScope ? ', admin_scope = ?' : ''} WHERE id = ?`)
113
- .run(JSON.stringify(adminPerms), ...(adminScope ? [adminScope, targetId] : [targetId]));
114
- db.prepare(`INSERT INTO admin_audit_log (id, admin_id, action, target_type, target_id, detail) VALUES (?,?,?,?,?,?)`)
115
- .run(generateId('audit'), root.id, 'admin_update_perms', 'user', targetId, JSON.stringify({ admin_permissions: adminPerms, admin_scope: adminScope }));
113
+ await dbRun(`UPDATE users SET admin_permissions = ?${adminScope ? ', admin_scope = ?' : ''} WHERE id = ?`, [JSON.stringify(adminPerms), ...(adminScope ? [adminScope, targetId] : [targetId])]);
114
+ await dbRun(`INSERT INTO admin_audit_log (id, admin_id, action, target_type, target_id, detail) VALUES (?,?,?,?,?,?)`, [generateId('audit'), root.id, 'admin_update_perms', 'user', targetId, JSON.stringify({ admin_permissions: adminPerms, admin_scope: adminScope })]);
116
115
  res.json({ ok: true, admin_permissions: adminPerms, admin_scope: adminScope });
117
116
  });
118
117
  // DELETE 撤销 admin(root only;不能撤自己;至少保留 1 个 root)
119
- app.delete('/api/admin/admins/:id', (req, res) => {
118
+ app.delete('/api/admin/admins/:id', async (req, res) => {
120
119
  const root = requireRootAdmin(req, res);
121
120
  if (!root)
122
121
  return;
123
122
  const targetId = req.params.id;
124
123
  if (targetId === root.id)
125
124
  return void res.json({ error: '不能撤销自己' });
126
- const target = db.prepare(`SELECT id, name, admin_type FROM users WHERE id = ?`).get(targetId);
125
+ const target = await dbOne(`SELECT id, name, admin_type FROM users WHERE id = ?`, [targetId]);
127
126
  if (!target || !target.admin_type)
128
127
  return void res.json({ error: '该用户不是 admin' });
129
128
  // 保护:至少保留 1 个 root
130
129
  if (target.admin_type === 'root') {
131
- const rootCount = db.prepare(`SELECT COUNT(1) as n FROM users WHERE admin_type = 'root'`).get().n;
130
+ const rootCount = (await dbOne(`SELECT COUNT(1) as n FROM users WHERE admin_type = 'root'`, [])).n;
132
131
  if (rootCount <= 1)
133
132
  return void res.json({ error: '至少保留 1 个 root admin,不可撤销最后一个' });
134
133
  }