import type { FailedRefreshResponse, FailedSignInResponse, SignInCredential, SignInResponse, } from '@/@types/auth' import { AUTH_API_NAME } from '@/constants/app.constant' import apiService, { Config } from '@/services/api.service' const authConfig: Config = { apiName: AUTH_API_NAME, } export const signIn = (data: SignInCredential) => apiService.fetchData( { method: 'POST', url: '/connect/token', headers: { 'content-type': 'application/x-www-form-urlencoded' }, data: { username: data.userName, password: data.password, twoFactorCode: data.twoFactorCode, captchaResponse: data.captchaResponse, grant_type: 'password', scope: 'offline_access Platform', client_id: 'Platform_App', }, }, authConfig, ) export const refreshToken = (refresh_token: string) => apiService.fetchData( { method: 'POST', url: '/connect/token', headers: { 'content-type': 'application/x-www-form-urlencoded' }, data: { refresh_token, grant_type: 'refresh_token', scope: 'offline_access Platform', client_id: 'Platform_App', }, validateStatus: () => true, }, authConfig, ) export const signOut = (data: any) => apiService.fetchData( { method: 'POST', url: '/connect/revocat', headers: { 'content-type': 'application/x-www-form-urlencoded' }, data: new URLSearchParams({ token: data.token, client_id: 'Platform_App', token_type_hint: 'access_token', }).toString(), }, authConfig, )