const assert=require('assert'),{createHarness}=require('./harness.cjs') ;(async()=>{ const h=createHarness(),{sharingRequest}=h.load('utils/sharing-runtime'),url='https://synthetic.invalid/user/sharing/code' for(const [response,pattern] of [ [{statusCode:404,data:{}},/HTTP 404/], [{statusCode:200,data:{code:1,error_key:'qr_wechat_rejected',upstream_code:41030,message:'secret'}},/微信码 41030/], [{statusCode:200,data:{code:1,error_key:'qr_token_refresh'}},/凭证更新失败/], [{statusCode:200,data:{code:1,message:'生成分享码失败,请稍后重试'}},/生成分享码失败/], [{statusCode:200,data:{code:1,message:'SYNTHETIC_PRIVATE_SECRET'}},/核查接口版本/] ]){h.flags.response=response;await assert.rejects(sharingRequest(url,'POST',{kind:'invite'}),e=>pattern.test(e.message)&&!e.message.includes('secret')&&!e.message.includes('PRIVATE'))} console.log('PASS: QR HTTP/WeChat/credential/legacy failures distinguishable without leaking raw responses.') })().catch(e=>{console.error(e.stack);process.exitCode=1})