feat(auth): integrate Aliyun SMS verification flow with docs update

Wire auth verification-code delivery to Aliyun SMS with mock fallback, config validation, and a standalone SMS smoke-test script. Update deployment checklist and system status docs with required env vars and rollout notes.

Made-with: Cursor
This commit is contained in:
2026-03-09 20:30:52 +08:00
parent 5c5fec52c1
commit d30bf95815
9 changed files with 443 additions and 11 deletions

View File

@@ -0,0 +1,34 @@
/**
* 阿里云短信联调脚本
*
* 用法:
* npm run test:sms -- 13800138000 LOGIN
* npm run test:sms -- 13800138000 RESET_PASSWORD
*/
import { sendVerificationCodeSms } from '../src/common/sms/aliyunSms.service.js'
import { config } from '../src/config/env.js'
function usage(): never {
console.log('用法: npm run test:sms -- <手机号> [LOGIN|RESET_PASSWORD]')
process.exit(1)
}
async function main(): Promise<void> {
const phone = process.argv[2]
const type = (process.argv[3] || 'LOGIN') as 'LOGIN' | 'RESET_PASSWORD'
if (!phone || !/^1[3-9]\d{9}$/.test(phone)) usage()
if (type !== 'LOGIN' && type !== 'RESET_PASSWORD') usage()
if (config.smsProvider !== 'aliyun') {
console.error('当前 SMS_PROVIDER 不是 aliyun请先在 .env 中设置 SMS_PROVIDER=aliyun')
process.exit(1)
}
const code = Math.floor(100000 + Math.random() * 900000).toString()
await sendVerificationCodeSms(phone, code, type)
console.log(`短信发送完成,手机号: ${phone}, 类型: ${type}, 验证码: ${code}`)
}
void main()