后端迁移会话凭证渲染模块

This commit is contained in:
yml
2026-05-21 15:17:18 +08:00
parent 52c0c101a6
commit ae31fe2797
4 changed files with 77 additions and 14 deletions
@@ -0,0 +1,65 @@
import fs from 'node:fs/promises'
import { BAIDU_BEIJING_TIME_URL, type RedeemProofMode } from './session-proof-constants.js'
type RedeemResultFilePayload = {
proofMode: RedeemProofMode
sessionId?: string
activityUrl: string
code: string
finalResult?: {
role?: {
area?: string
}
[key: string]: unknown
} | null
attempts?: unknown[]
screenshotPath: string
htmlPath?: string
redeemPageScreenshotPath?: string
beijingTimeScreenshotPath?: string
beijingTimePageUrl?: string
beijingTimeError?: string
}
export async function writeRedeemResultFile(
resultPath: string,
{
proofMode,
sessionId,
activityUrl,
code,
finalResult,
attempts,
screenshotPath,
htmlPath = '',
redeemPageScreenshotPath = '',
beijingTimeScreenshotPath = '',
beijingTimePageUrl = BAIDU_BEIJING_TIME_URL,
beijingTimeError = '',
}: RedeemResultFilePayload,
): Promise<void> {
await fs.writeFile(
resultPath,
JSON.stringify(
{
proofMode,
sessionId,
activityUrl,
code,
area: finalResult?.role?.area || '',
final: finalResult,
attempts,
redeemPageScreenshotPath,
beijingTimeScreenshotPath,
beijingTimePageUrl,
beijingTimeError,
screenshotPath,
htmlPath,
},
null,
2,
),
'utf8',
)
}