NATSotp.mfa.factor-bind创建 MFA 因素

创建处于待确认状态的 TOTP 因素并生成秘钥;秘钥只存在 otp_service,对调用方仅返回 otpauth URI。

Request Payload

消息格式:JSON

NameData TypeRequiredDescription
userIdstringYes用户 ID
typestringYes因素类型:totp
type RequestBody = {
  /** 用户 ID */
  userId: string
  /** 因素类型:totp */
  type: string
}
{
  "userId": "01JD8SEGQ0P9N2XK4L7VDH3T6C",
  "type": "totp"
}

Response Payload

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

NameData TypeRequiredDescription
factorIdstringYes因素 ID
typestringYes因素类型
statusstringYes固定为 pending
otpauthUrlstringYes验证器扫码 / 录入的 otpauth URI
expiresAtstringYes待确认状态过期时间
type ResponseBody = {
  /** 因素 ID */
  factorId: string
  /** 因素类型 */
  type: string
  /** 固定为 pending */
  status: string
  /** 验证器扫码 / 录入的 otpauth URI */
  otpauthUrl: string
  /** 待确认状态过期时间 */
  expiresAt: string
}
{
  "factorId": "01JD8SKH5N6P9W5XP9T4WDJ7U0C",
  "type": "totp",
  "status": "pending",
  "otpauthUrl": "otpauth://totp/Xeegam%20Passport:chenlin?secret=JBSWY3DPEHPK3PXP&issuer=Xeegam%20Passport",
  "expiresAt": "2026-10-14T08:50:00Z"
}

Response Code

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

code Meaning Notes
0 成功 创建 MFA 因素
2205 因素类型已存在

Examples

{ "userId": "01JD8SEGQ0P9N2XK4L7VDH3T6C", "type": "totp" }
{
  "id": "01JD8SVFJ1U7W4XT",
  "code": 0,
  "messages": [],
  "result": {
    "factorId": "01JD8SKH5N6P9W5XP9T4WDJ7U0C",
    "type": "totp",
    "status": "pending",
    "otpauthUrl": "otpauth://totp/Xeegam%20Passport:chenlin?secret=JBSWY3DPEHPK3PXP&issuer=Xeegam%20Passport",
    "expiresAt": "2026-10-14T08:50:00Z"
  }
}