¶ MFA API
¶ MFA check
Check if phone number or email address can be used for MFA
func mfaCheck(phone: String?, email: String?, completion: @escaping(Int, String?, Bool?) -> Void)
param
phone
phone number to be checked. can be nullemail
email address to be checked. can be null
example
AuthClient().mfaCheck(phone: "188xxxx8888", email: nil) { code, message, ok in
if (code == 200) {
if (ok) {
}
}
}
AuthClient().mfaCheck(phone: nil, email: "abc@gmail.com") { code, message, ok in
if (code == 200) {
if (ok) {
}
}
}
¶ SMS
MFA by SMS
func mfaVerifyByPhone(phone: String, code: String, completion: @escaping(Int, String?, UserInfo?) -> Void)
param
phone
phone numbercode
SMS verification code
example
AuthClient().mfaVerifyByPhone(phone: "188xxxx8888", code: "1234") { code, message, userInfo in
// userInfo
}
MFA by email
func mfaVerifyByEmail(email: String, code: String, completion: @escaping(Int, String?, UserInfo?) -> Void)
param
email
email addresscode
email verification code
example
AuthClient().mfaVerifyByEmail(email: "abc@gmail.com", code: "1234") { code, message, userInfo in
// userInfo
}
¶ TOTP
MFA by TOTP (Time-based One Time Password)
func mfaVerifyByOTP(code: String, completion: @escaping(Int, String?, UserInfo?) -> Void)
param
code
TOTP code
example
AuthClient().mfaVerifyByTOTP(code: "1234") { code, message, userInfo in
// userInfo
}
¶ Recovery code
MFA by recovery code. When user binds TOTP, a recovery code will be generated. User should save this code securely and pass it as parameter for this API
When MFA succeed, a new recovery code will be generated, the old one becomes invalid
func mfaVerifyByRecoveryCode(code: String, completion: @escaping(Int, String?, UserInfo?) -> Void)
param
code
recovery code
example
AuthClient().mfaVerifyByRecoveryCode(code: "1234") { code, message, userInfo in
// userInfo
}
¶ Upload face photo
Upload a photo before face recognition, this interface returns the Key
value of the photo, used for face verification.
func uploadFaceImage(_ image: UIImage,_ isPrivate: Bool = true, completion: @escaping (Int, String?) -> Void)
param
- image photo
example
AuthClient().uploadFaceImage(image) { code, key in
// key: Face recognition parameter
}
¶ Bind face photo
First face verification binding face. Before calling this interface, you need to call the Upload face photo interface to get the photo key
value
func mfaAssociateByFace(photoKeyA: String, photoKeyB: String, completion: @escaping(Int, String?, UserInfo?) -> Void)
param
- photoKeyA The Key from the first photo
- photoKeyB The Key from the second photo
example
AuthClient().mfaAssociateByFace(photoKeyA: "photoKeyA", photoKeyB: "photoKeyB") { code, message, userInfo in
// userInfo
}
¶ Face verification
Multi-factor authentication through face recognition. Before calling this interface, you need to call the upload face photo interface to get the photo key
value
func mfaVerifyByFace(photoKey: String, completion: @escaping(Int, String?, UserInfo?) -> Void)
param
- photoKey Key
example
AuthClient().mfaVerifyByFace(photoKey: "photoKey") { code, message, userInfo in
// userInfo、
}