import request from "./request" ; import buildRaon from "./raon/buildRaon" ; export type SecondLoginResult = SecondLoginResultSuccess | SecondLoginResultFailure ; export interface SecondLoginResultSuccess { example success : true ; /** 설문 토큰 */ token : string ; } export interface SecondLoginResultFailure { example success : false ; /** 로그인 실패 횟수 */ failCount ? : number ; /** 남은 시간 */ remainingMinutes ? : number ; message : string ; } export async function secondLogin ( endpoint , token , password ) { const data = { deviceUuid : "" , makeSession : true , password : await buildRaon ( password ) } ; const response = await request ( '/v2/validatePassword' , 'POST' , data , endpoint , token ) ; const success = typeof response == "string" ; return success ? { success : true , token : response } : ( response [ 'isError' ] && response [ 'message' ] !== "비밀번호를 다시한번더 입력해주세요" ? { success : false , failCount : response [ 'data' ] [ 'failCnt' ] ? Number ( response [ 'data' ] [ 'failCnt' ] ) : 5 , remainingMinutes : response [ 'data' ] [ 'remainMinutes' ] ? Number ( response [ 'data' ] [ 'remainMinutes' ] ) : 0 , message : response [ 'message' ] } : { success : false , failCount : null , remainingMinutes : null , message : "가상키보드 오류" } ) ; }