trustbase-seller-backend 0.2.1 → 0.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trustbase-seller-backend",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "TrustBase Seller Backend (merchant edition) — 商品上链/订单/支付/质押 write API for TrustBase 保障链生态. 单卖家自托管形态: 签名 key 即卖家身份, 私钥不出门.",
5
5
  "main": "run-unified.js",
6
6
  "bin": {
@@ -708,7 +708,10 @@ async function submit(){
708
708
  document.getElementById('r-addr').textContent=j.tb_address;
709
709
  document.getElementById('result').style.display='block';
710
710
  document.getElementById('status').className='status-ok';
711
- document.getElementById('status').textContent='✅ 卖家身份已生成 (密钥已保存在本机 tb-keyring/)';
711
+ // 2026-09-26 资产安全: 助记词只在首次创建返回; 已有身份时 j.mnemonic 为空
712
+ document.getElementById('status').textContent=j.identity_created===false
713
+ ? '✅ 卖家身份已存在 (助记词仅首次创建时展示过)'
714
+ : '✅ 卖家身份已生成 (密钥已保存在本机 tb-keyring/)';
712
715
  if(j.mnemonic){
713
716
  _mn=j.mnemonic;
714
717
  var words=j.mnemonic.split(/\s+/);
package/routes/onboard.js CHANGED
@@ -211,17 +211,21 @@ function createOnboardRouter(deps) {
211
211
  db.prepare("INSERT INTO onboard_merchants (merchant_shortname, mobile_phone, category, tb_address, sub_mchid, created_at) VALUES (?,?,?,?,?,?)")
212
212
  .run(String(b.merchant_shortname), String(b.mobile_phone || ""), String(b.category || ""), identity.address, subMchid, Math.floor(Date.now() / 1000));
213
213
  console.log("[onboard] merchant:", b.merchant_shortname, "addr:", identity.address, identity.created ? "(新身份)" : "(已有身份)");
214
- // mnemonic 只经本机 localhost 返回给页面展示一次, 勿加进任何日志/远程调用
214
+ // 助记词只在首次创建身份时返回一次 (2026-09-26 资产安全修复):
215
+ // 已有身份时绝不回吐 — 本端点无鉴权, 重复调用返助记词 = LAN 任何人可拿走商户资产。
216
+ // 已有身份后重复提交幂等返回 (不含任何敏感信息)。
215
217
  res.json({
216
218
  ok: true,
217
219
  sub_mchid: subMchid,
218
220
  tb_address: identity.address,
219
- mnemonic: identity.mnemonic,
221
+ ...(identity.created ? { mnemonic: identity.mnemonic } : {}),
220
222
  identity_created: identity.created,
221
223
  grant_tct: 100,
222
224
  shop_base_url: shopBaseUrl(req),
223
- next_step: "下一步: 上架商品 (进入店铺后台), 或在认证完成后领取 100 TCT 引导金",
224
- message: "卖家身份已生成,完成微信认证后发放引导金",
225
+ next_step: identity.created
226
+ ? "下一步: 抄下助记词 (纸密钥), 然后上架商品或完成微信认证领 100 TCT 引导金"
227
+ : "身份已存在 (助记词仅创建时展示过一次), 继续入驻流程即可",
228
+ message: identity.created ? "卖家身份已生成,完成微信认证后发放引导金" : "卖家身份已存在",
225
229
  });
226
230
  } catch (e) {
227
231
  console.error("[onboard] error:", e && e.message);