NATSattempt.record记录因素结果并获取尝试工单

懒创建或续用尝试:首个因素验证时创建记录并绑定环境指纹,随后每个因素(无论成败)都经此记录并返回最新工单与状态。

Request Payload

消息格式:JSON

NameData TypeRequiredDescription
userIdstringYes用户 ID
factorstringYespassword / otp / mfa / captcha / third-party
passedbooleanYes该因素是否通过
fingerprintstringYes环境指纹(调用方由 IP / UA 等计算)
existingTicketIdstringNo既有尝试工单(续用场景携带,首因素不携带)
type RequestBody = {
  /** 用户 ID */
  userId: string
  /** password / otp / mfa / captcha / third-party */
  factor: string
  /** 该因素是否通过 */
  passed: boolean
  /** 环境指纹(调用方由 IP / UA 等计算) */
  fingerprint: string
  /** 既有尝试工单(续用场景携带,首因素不携带) */
  existingTicketId?: string
}
{
  "userId": "01JD8SEGQ0P9N2XK4L7VDH3T6C",
  "factor": "password",
  "passed": true,
  "fingerprint": "fp_c41a9e07d2b8"
}

Response Payload

回复使用统一信封 {id, code, messages, result},其 result:

NameData TypeRequiredDescription
attemptTicketIdstringYes尝试工单(后续因素继续携带)
statusstringYespending 未达标 / satisfied 已达标
scorenumberYes当前累加分数
thresholdnumberYes阈值
verifiedFactorsarrayYes已通过的因素
nextFactorsarrayYes仍可选的下一因素
expiresAtstringYes工单过期时间
type ResponseBody = {
  /** 尝试工单(后续因素继续携带) */
  attemptTicketId: string
  /** pending 未达标 / satisfied 已达标 */
  status: string
  /** 当前累加分数 */
  score: number
  /** 阈值 */
  threshold: number
  /** 已通过的因素 */
  verifiedFactors: string[]
  /** 仍可选的下一因素 */
  nextFactors: string[]
  /** 工单过期时间 */
  expiresAt: string
}
{
  "attemptTicketId": "atk_9f2c7be14d0a53e8",
  "status": "pending",
  "score": 40,
  "threshold": 60,
  "verifiedFactors": [
    "password"
  ],
  "nextFactors": [
    "otp",
    "mfa",
    "captcha"
  ],
  "expiresAt": "2026-10-14T08:10:00Z"
}

Response Code

回复使用统一信封 {id, code, messages, result},其 code 字段:

code Meaning Notes
0 成功 记录因素结果并获取尝试工单
2008 环境指纹不匹配 携带的既有工单与本次指纹不符,拒绝合并
2007 尝试已被冻结 连续失败达到上限

Examples

{
  "userId": "01JD8SEGQ0P9N2XK4L7VDH3T6C",
  "factor": "password",
  "passed": true,
  "fingerprint": "fp_c41a9e07d2b8"
}
{
  "id": "01JD8SVNR9C5E2FB",
  "code": 0,
  "messages": [],
  "result": {
    "attemptTicketId": "atk_9f2c7be14d0a53e8",
    "status": "pending",
    "score": 40,
    "threshold": 60,
    "verifiedFactors": ["password"],
    "nextFactors": ["otp", "mfa", "captcha"],
    "expiresAt": "2026-10-14T08:10:00Z"
  }
}

Remarks

失败因素也计入记录但不得分。