diff --git a/src/endpoints/authentication/authentication.endpoint.ts b/src/endpoints/authentication/authentication.endpoint.ts index 3d4bcdf..3835be3 100644 --- a/src/endpoints/authentication/authentication.endpoint.ts +++ b/src/endpoints/authentication/authentication.endpoint.ts @@ -1,7 +1,6 @@ import { cast } from '@deepkit/type' import type { ChannelAuthorizationRequestParams } from 'pusher-js/types/src/core/auth/options' import { BaseEndpoint } from '../endpoint.base' -import type { TokensResponse } from './dto/tokens.response' import type { LoginErrorResponse, LoginResponse } from './dto/login.response' import type { UserResponse } from './dto/user.response' import type { PusherAuthenticationResponse } from './dto/pusher-authentication.response' @@ -15,25 +14,19 @@ import { buildBody } from '@/utils/build-body' * @category Endpoints */ export class AuthenticationEndpoint extends BaseEndpoint { - public async getTokens() { - const response = await this._apiClient.callKickApi({ endpoint: 'kick-token-provider' }) - if (response.status !== 200) - throw new KientApiError('Failed to retrieve pre-login tokens', { cause: response }) - - return cast(response.body) + public async getCsrfHeaders() { + await this._apiClient.callKickApi({ endpoint: 'sanctum/csrf' }) } public async login(credentials: LoginCredentials, kickAuthHeader: string = '') { this._apiClient.setKickAuthHeader(kickAuthHeader) - const tokens = await this.getTokens() + await this.getCsrfHeaders() const body = buildBody({ email: credentials.email, password: credentials.password, one_time_password: credentials.otc, isMobileRequest: true, - [tokens.nameFieldName]: '', - [tokens.validFromFieldName]: tokens.encryptedValidFrom, }) const response = await this._apiClient.callKickApi({ endpoint: 'mobile/login', diff --git a/src/endpoints/authentication/dto/login.input.ts b/src/endpoints/authentication/dto/login.input.ts index 0c55432..8bf7708 100644 --- a/src/endpoints/authentication/dto/login.input.ts +++ b/src/endpoints/authentication/dto/login.input.ts @@ -1,4 +1,4 @@ -export interface LoginInput extends Record { +export interface LoginInput { email: string password: string one_time_password?: string | number diff --git a/src/endpoints/authentication/dto/tokens.response.ts b/src/endpoints/authentication/dto/tokens.response.ts deleted file mode 100644 index 43f49e7..0000000 --- a/src/endpoints/authentication/dto/tokens.response.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface TokensResponse { - enabled: boolean - nameFieldName: string - unrandomizedNameFieldName: string - validFromFieldName: string - encryptedValidFrom: string -}