diff --git a/packages/apps/human-app/frontend/src/api/api-client.ts b/packages/apps/human-app/frontend/src/api/api-client.ts deleted file mode 100644 index 59d6dd5fe2..0000000000 --- a/packages/apps/human-app/frontend/src/api/api-client.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { createFetcher } from '@/api/fetcher'; -import { env } from '@/shared/env'; - -export const apiClient = createFetcher({ - baseUrl: env.VITE_API_URL, - options: () => { - const headers = new Headers({ 'Content-Type': 'application/json' }); - - return { - headers, - }; - }, -}); diff --git a/packages/apps/human-app/frontend/src/api/api-paths.ts b/packages/apps/human-app/frontend/src/api/api-paths.ts deleted file mode 100644 index 87596f3a44..0000000000 --- a/packages/apps/human-app/frontend/src/api/api-paths.ts +++ /dev/null @@ -1,102 +0,0 @@ -export const apiPaths = { - test: { - path: '/test', - }, - worker: { - signIn: { - path: '/auth/signin', - }, - signUp: { - path: '/auth/signup', - }, - obtainAccessToken: { - path: '/auth/refresh', - }, - sendResetLink: { - path: '/password-reset/forgot-password', - }, - resetPassword: { - path: '/password-reset/restore-password', - }, - verifyEmail: { - path: '/email-confirmation/email-verification', - withAuthRetry: true, - }, - resendEmailVerification: { - path: '/email-confirmation/resend-email-verification', - withAuthRetry: true, - }, - kycStart: { - path: '/kyc/start', - withAuthRetry: true, - }, - oracles: { - path: '/oracles', - }, - jobs: { - path: '/jobs', - }, - myJobs: { - path: '/assignment/job', - }, - assignJob: { - path: '/assignment/job', - }, - resignJob: { - path: '/assignment/resign-job', - }, - refreshJob: { - path: '/assignment/refresh', - }, - registerAddress: { - path: '/user/register-address', - withAuthRetry: true, - }, - signedAddress: { - path: '/kyc/on-chain', - withAuthRetry: true, - }, - enableHCaptchaLabeling: { - path: '/labeling/h-captcha/enable', - }, - verifyHCaptchaLabeling: { - path: '/labeling/h-captcha/verify', - }, - hCaptchaUserStats: { - path: '/labeling/h-captcha/user-stats', - }, - dailyHmtSpend: { - path: '/labeling/h-captcha/daily-hmt-spent', - }, - registrationInExchangeOracle: { - path: '/exchange-oracle-registration', - }, - uiConfig: { - path: '/ui-config', - }, - }, - operator: { - web3Auth: { - prepareSignature: { - path: '/prepare-signature', - }, - signUp: { - path: '/auth/web3/signup', - }, - signIn: { - path: '/auth/web3/signin', - }, - stats: { - path: '/stats', - }, - }, - disableOperator: { - path: '/disable-operator', - withAuthRetry: true, - }, - enableOperator: { - path: '/enable-operator', - withAuthRetry: true, - }, - }, -} as const; diff --git a/packages/apps/human-app/frontend/src/api/auth-service.ts b/packages/apps/human-app/frontend/src/api/auth-service.ts new file mode 100644 index 0000000000..cbca5247f3 --- /dev/null +++ b/packages/apps/human-app/frontend/src/api/auth-service.ts @@ -0,0 +1,117 @@ +import { jwtDecode } from 'jwt-decode'; +import { type SignInDto } from '@/modules/signin/worker/schemas'; +import { browserAuthProvider } from '@/shared/contexts/browser-auth-provider'; +import { + type AuthTokensSuccessResponse, + authTokensSuccessResponseSchema, +} from '@/shared/schemas'; +import { type BrowserAuthProvider } from '@/shared/types/browser-auth-provider'; +import { type HttpApiClient } from './http-api-client'; +import { commonApiPaths } from './common-api-paths'; + +export interface AuthProvider { + getAccessToken: () => Promise; + refreshAccessToken: () => Promise; +} + +const apiPaths = { + worker: { + signIn: { + path: '/auth/signin', + }, + }, +} as const; + +export class AuthService implements AuthProvider { + private readonly browserAuthProvider: BrowserAuthProvider = + browserAuthProvider; + + private static refreshPromise: Promise | null = + null; + + constructor(private readonly httpClient: HttpApiClient) {} + + async signIn(data: SignInDto): Promise { + const res = await this.httpClient.post( + apiPaths.worker.signIn.path, + { + successSchema: authTokensSuccessResponseSchema, + body: data, + } + ); + + this.browserAuthProvider.signIn(res, 'web2'); + } + + async getAccessToken(): Promise { + const accessToken = this.browserAuthProvider.getAccessToken(); + + if (!accessToken) { + return null; + } + + const decodedToken = jwtDecode<{ exp: number }>(accessToken); + const currentTime = Math.floor(Date.now() / 1000); + const tokenExpiration = decodedToken.exp; + + if (tokenExpiration && tokenExpiration - currentTime < 30) { + await this.refreshAccessToken(); + + const newAccessToken = this.browserAuthProvider.getAccessToken(); + + if (!newAccessToken) { + return null; + } + + return newAccessToken; + } + + return accessToken; + } + + async refreshAccessToken(): Promise { + const authType = this.browserAuthProvider.getAuthType(); + + if (!authType) { + throw new Error('Auth type not found'); + } + + if (!AuthService.refreshPromise) { + AuthService.refreshPromise = this.fetchTokenRefresh(); + } + + const tokens = await AuthService.refreshPromise; + + AuthService.refreshPromise = null; + + if (tokens === null) { + throw new Error('Failed to refresh access token'); + } + + browserAuthProvider.signIn(tokens, authType); + } + + private async fetchTokenRefresh(): Promise { + const refreshToken = this.browserAuthProvider.getRefreshToken(); + + if (!refreshToken) { + return null; + } + + try { + const response = await this.httpClient.post( + commonApiPaths.auth.refresh.path, + { + body: { + // eslint-disable-next-line camelcase + refresh_token: refreshToken, + }, + } + ); + + return response; + } catch (error) { + return null; + } + } +} diff --git a/packages/apps/human-app/frontend/src/api/authorized-http-api-client.ts b/packages/apps/human-app/frontend/src/api/authorized-http-api-client.ts new file mode 100644 index 0000000000..92a427d161 --- /dev/null +++ b/packages/apps/human-app/frontend/src/api/authorized-http-api-client.ts @@ -0,0 +1,41 @@ +import { env } from '@/shared/env'; +import { + HttpApiClient, + humanAppApiClient, + type RequestConfig, +} from './http-api-client'; +import { AuthService, type AuthProvider } from './auth-service'; + +export class AuthorizedHttpApiClient extends HttpApiClient { + constructor( + baseUrl: string, + private readonly authProvider: AuthProvider + ) { + super(baseUrl); + } + + protected async makeRequest( + method: string, + path: string, + config: RequestConfig + ): Promise { + const token = await this.authProvider.getAccessToken(); + + const _config = { + ...config, + headers: { + ...config.headers, + Authorization: `Bearer ${token}`, + }, + }; + + return super.makeRequest(method, path, _config); + } +} + +export const authService = new AuthService(humanAppApiClient); + +export const authorizedHumanAppApiClient = new AuthorizedHttpApiClient( + env.VITE_API_URL, + authService +); diff --git a/packages/apps/human-app/frontend/src/api/common-api-paths.ts b/packages/apps/human-app/frontend/src/api/common-api-paths.ts new file mode 100644 index 0000000000..ed28ab1e4b --- /dev/null +++ b/packages/apps/human-app/frontend/src/api/common-api-paths.ts @@ -0,0 +1,7 @@ +export const commonApiPaths = { + auth: { + refresh: { + path: '/auth/refresh', + }, + }, +} as const; diff --git a/packages/apps/human-app/frontend/src/api/fetch-refresh-token.ts b/packages/apps/human-app/frontend/src/api/fetch-refresh-token.ts deleted file mode 100644 index 2f99243801..0000000000 --- a/packages/apps/human-app/frontend/src/api/fetch-refresh-token.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { apiPaths } from '@/api/api-paths'; -import { browserAuthProvider } from '@/shared/contexts/browser-auth-provider'; -import { authTokensSuccessResponseSchema } from '@/shared/schemas'; - -export const fetchTokenRefresh = async (baseUrl: string) => { - const response = await fetch( - `${baseUrl}${apiPaths.worker.obtainAccessToken.path}`, - { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - // eslint-disable-next-line camelcase -- camel case defined by api - refresh_token: browserAuthProvider.getRefreshToken(), - }), - } - ); - - if (!response.ok) { - return null; - } - - const data: unknown = await response.json(); - - const refetchAccessTokenSuccess = authTokensSuccessResponseSchema.parse(data); - - return refetchAccessTokenSuccess; -}; diff --git a/packages/apps/human-app/frontend/src/api/fetcher.ts b/packages/apps/human-app/frontend/src/api/fetcher.ts deleted file mode 100644 index 275a9932e3..0000000000 --- a/packages/apps/human-app/frontend/src/api/fetcher.ts +++ /dev/null @@ -1,238 +0,0 @@ -import merge from 'lodash/merge'; -import { ZodError, type ZodType, type ZodTypeDef } from 'zod'; -import type { ResponseError } from '@/shared/types/global.type'; -import { browserAuthProvider } from '@/shared/contexts/browser-auth-provider'; -import { env } from '@/shared/env'; -import { normalizeBaseUrl } from '@/shared/helpers/url'; -import { type AuthTokensSuccessResponse } from '@/shared/schemas'; -import { fetchTokenRefresh } from './fetch-refresh-token'; - -const appendHeader = ( - fetcherOptionsWithDefaults: RequestInit | undefined, - newHeaders: Record -) => { - const headers = new Headers(fetcherOptionsWithDefaults?.headers); - - for (const [key, value] of Object.entries(newHeaders)) { - headers.set(key, value); - } - - return { - ...fetcherOptionsWithDefaults, - headers, - }; -}; - -export class FetchError extends Error { - status: number; - data: unknown; - - constructor({ - message, - data, - status, - }: { - message: string; - status: number; - data: unknown; - }) { - super(message); - this.status = status; - this.data = data; - } -} - -export type FetcherOptionsWithValidation = - Readonly<{ - options?: RequestInit; - successSchema: ZodType; - skipValidation?: false | undefined; - authenticated?: boolean; - withAuthRetry?: boolean; - baseUrl?: string; - }>; - -export type FetcherOptionsWithoutValidation = Readonly<{ - options?: RequestInit; - skipValidation: true; - authenticated?: boolean; - withAuthRetry?: boolean; - baseUrl?: string; -}>; - -export type FetcherOptions = - | FetcherOptionsWithValidation - | FetcherOptionsWithoutValidation; - -export type FetcherUrl = string | URL; - -let refreshPromise: Promise | null = null; - -export async function refreshToken(): Promise<{ - access_token: string; - refresh_token: string; -} | null> { - if (!refreshPromise) { - refreshPromise = fetchTokenRefresh(normalizeBaseUrl(env.VITE_API_URL)); - } - - const result = await refreshPromise; - - refreshPromise = null; - - if (result) { - browserAuthProvider.signIn(result, browserAuthProvider.authType); - } else { - browserAuthProvider.signOut({ triggerSignOutSubscriptions: true }); - } - - return result; -} - -export function createFetcher(defaultFetcherConfig?: { - options?: RequestInit | (() => RequestInit); - baseUrl: FetcherUrl | (() => FetcherUrl); -}) { - async function fetcher( - url: string | URL, - fetcherOptions: FetcherOptionsWithValidation, - abortSignal?: AbortSignal - ): Promise; - - async function fetcher( - url: FetcherUrl, - fetcherOptions: FetcherOptionsWithoutValidation, - abortSignal?: AbortSignal - ): Promise; - - async function fetcher( - url: FetcherUrl, - fetcherOptions: FetcherOptions, - abortSignal?: AbortSignal - // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents -- required unknown for correct type intellisense - ): Promise { - let fetcherOptionsWithDefaults = defaultFetcherConfig?.options - ? merge( - {}, - (() => { - const options = defaultFetcherConfig.options; - if (options instanceof Function) return options(); - return options; - })(), - fetcherOptions.options - ) - : fetcherOptions.options; - if (fetcherOptions.authenticated) { - fetcherOptionsWithDefaults = appendHeader(fetcherOptionsWithDefaults, { - Authorization: `Bearer ${browserAuthProvider.getAccessToken()}`, - }); - } - - if (abortSignal) { - fetcherOptionsWithDefaults = { - ...fetcherOptionsWithDefaults, - signal: abortSignal, - }; - } - - const baseUrl = (() => { - const currentUrl = fetcherOptions.baseUrl - ? () => fetcherOptions.baseUrl - : defaultFetcherConfig?.baseUrl; - if (currentUrl instanceof Function) return currentUrl(); - return currentUrl; - })(); - - function fetchUrlToString(fetchUrl: string | URL): string; - function fetchUrlToString(fetchUrl: undefined): undefined; - function fetchUrlToString( - fetchUrl: string | URL | undefined - ): string | undefined; - function fetchUrlToString( - fetchUrl: string | URL | undefined - ): string | undefined { - if (!fetchUrl) return undefined; - if (fetchUrl instanceof URL) return fetchUrl.href; - return fetchUrl; - } - - const fetcherUrl = (() => { - const urlAsString = fetchUrlToString(baseUrl); - if (!urlAsString) return url; - const normalizedUrl = fetchUrlToString(url).replace(/\//, ''); - const normalizedBaseUrl = normalizeBaseUrl(urlAsString); - - return `${normalizedBaseUrl}/${normalizedUrl}`; - })(); - - let response: Response | undefined; - - response = await fetch(fetcherUrl, fetcherOptionsWithDefaults); - - if ( - !response.ok && - response.status === 401 && - fetcherOptions.authenticated && - fetcherOptions.withAuthRetry - ) { - const refetchAccessTokenSuccess = await refreshToken(); - - if (!refetchAccessTokenSuccess) { - return; - } - - const newHeaders = appendHeader(fetcherOptionsWithDefaults, { - Authorization: `Bearer ${refetchAccessTokenSuccess.access_token}`, - }); - - response = await fetch(fetcherUrl, newHeaders); - - if (!response.ok) { - browserAuthProvider.signOut({ triggerSignOutSubscriptions: true }); - return; - } - } - - let data: unknown = null; - try { - data = await response.json(); - } catch { - try { - data = await response.text(); - } catch (error) { - data = null; - } - } - - if (!response.ok) { - throw new FetchError({ - status: response.status, - message: response.statusText, - data, - }); - } - - if (fetcherOptions.skipValidation) { - return data; - } - - try { - return fetcherOptions.successSchema.parse(data); - } catch (error) { - if (error instanceof ZodError) { - // eslint-disable-next-line no-console -- ... - console.error('Invalid response'); - error.errors.forEach((e) => { - // eslint-disable-next-line no-console -- ... - console.error(e); - }); - } - throw error; - } - } - - return fetcher; -} - -export const isFetcherError = (error: ResponseError): error is FetchError => - error instanceof FetchError; diff --git a/packages/apps/human-app/frontend/src/api/hooks/use-access-token-refresh.ts b/packages/apps/human-app/frontend/src/api/hooks/use-access-token-refresh.ts index 2f2a291eee..95a3f79409 100644 --- a/packages/apps/human-app/frontend/src/api/hooks/use-access-token-refresh.ts +++ b/packages/apps/human-app/frontend/src/api/hooks/use-access-token-refresh.ts @@ -5,21 +5,14 @@ import { browserAuthProvider } from '@/shared/contexts/browser-auth-provider'; import type { AuthType } from '@/shared/types/browser-auth-provider'; import { useWeb3Auth } from '@/modules/auth-web3/hooks/use-web3-auth'; import { routerPaths } from '@/router/router-paths'; -import { refreshToken } from '@/api/fetcher'; +import { authService } from '../authorized-http-api-client'; export function useAccessTokenRefresh() { const queryClient = useQueryClient(); const navigate = useNavigate(); - const { - signIn: signInWeb2, - signOut: web2SignOut, - user: web2User, - } = useAuth(); - const { - signIn: signInWeb3, - signOut: web3SignOut, - user: web3User, - } = useWeb3Auth(); + const { signOut: web2SignOut, user: web2User } = useAuth(); + + const { signOut: web3SignOut, user: web3User } = useWeb3Auth(); const mutation = useMutation({ mutationFn: async ({ @@ -30,18 +23,10 @@ export function useAccessTokenRefresh() { throwExpirationModalOnSignOut?: boolean; }) => { try { - const refetchAccessTokenSuccess = await refreshToken(); - - if (!refetchAccessTokenSuccess) { - throw new Error('Failed to refresh access token.'); - } - - if (authType === 'web2') { - signInWeb2(refetchAccessTokenSuccess); - } else { - signInWeb3(refetchAccessTokenSuccess); - } + await authService.refreshAccessToken(); } catch (error) { + // eslint-disable-next-line no-console + console.error(error); if (authType === 'web2' && web2User) { web2SignOut({ throwExpirationModal: false }); } diff --git a/packages/apps/human-app/frontend/src/api/hooks/use-prepare-signature.ts b/packages/apps/human-app/frontend/src/api/hooks/use-prepare-signature.ts deleted file mode 100644 index 506850b033..0000000000 --- a/packages/apps/human-app/frontend/src/api/hooks/use-prepare-signature.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { z } from 'zod'; -import { useQuery } from '@tanstack/react-query'; -import { apiClient } from '@/api/api-client'; -import { apiPaths } from '@/api/api-paths'; - -export enum PrepareSignatureType { - SIGN_UP = 'signup', - SIGN_IN = 'signin', - DISABLE_OPERATOR = 'disable_operator', - ENABLE_OPERATOR = 'enable_operator', - REGISTER_ADDRESS = 'register_address', -} - -export const prepareSignatureSuccessSchema = z.object({ - from: z.string(), - to: z.string(), - contents: z.string(), - nonce: z.unknown(), -}); - -export type SignatureData = z.infer; -export interface PrepareSignatureBody { - address: string; - type: PrepareSignatureType; -} - -export const prepareSignature = (body: PrepareSignatureBody) => { - return apiClient(apiPaths.operator.web3Auth.prepareSignature.path, { - successSchema: prepareSignatureSuccessSchema, - options: { method: 'POST', body: JSON.stringify(body) }, - }); -}; - -export function usePrepareSignature(body: PrepareSignatureBody) { - return useQuery({ - queryFn: () => prepareSignature(body), - refetchInterval: 0, - queryKey: ['prepareSignature'], - }); -} diff --git a/packages/apps/human-app/frontend/src/api/http-api-client.ts b/packages/apps/human-app/frontend/src/api/http-api-client.ts new file mode 100644 index 0000000000..92bb8a87a2 --- /dev/null +++ b/packages/apps/human-app/frontend/src/api/http-api-client.ts @@ -0,0 +1,161 @@ +import { ZodError, type ZodType } from 'zod'; +import { env } from '@/shared/env'; + +export class ApiClientError extends Error { + constructor( + public readonly message: string, + public readonly status: number, + public readonly data: unknown + ) { + super(message); + } +} + +export interface RequestConfig { + queryParams?: Record; + body?: + | string + | Record + | unknown[] + | ArrayBuffer + | Blob + | File + | FormData; + headers?: Record; + abortSignal?: AbortSignal; + successSchema?: ZodType; +} + +type HttpApiClientMethod = ( + path: string, + config?: Omit +) => Promise; + +type HttpApiClientMethodWithBody = ( + path: string, + config: RequestConfig +) => Promise; + +export class HttpApiClient { + constructor(protected baseUrl?: string) {} + protected async makeRequest( + method: string, + path: string, + config: RequestConfig + ): Promise { + const url = new URL(path, this.baseUrl); + + const { queryParams, body, headers, successSchema, abortSignal } = config; + + if (queryParams) { + Object.entries(queryParams).forEach(([key, value]) => { + if (!value) return; + + if (Array.isArray(value)) { + value + .filter((i) => i !== undefined) + .forEach((item) => { + url.searchParams.append(key, String(item)); + }); + return; + } + + url.searchParams.append(key, String(value)); + }); + } + + const lowercasedHeaders = Object.fromEntries( + Object.entries(headers ?? {}).map(([k, v]) => [k.toLowerCase(), v]) + ); + + const response = await fetch(url, { + method, + headers: { + 'content-type': 'application/json', + ...lowercasedHeaders, + }, + body: body ? JSON.stringify(body) : undefined, + signal: abortSignal, + }); + + const text = await response.text(); + + const responseBody: unknown = text.length > 0 ? JSON.parse(text) : null; + + if (!response.ok) { + const errorMessage = this.getErrorMessageForResponse( + responseBody, + response.statusText + ); + + throw new ApiClientError(errorMessage, response.status, responseBody); + } + + if (successSchema) { + try { + // Zod defaulty type is any, but parsing will return the correct type + // eslint-disable-next-line @typescript-eslint/no-unsafe-return + return successSchema.parse(responseBody); + } catch (error) { + if (error instanceof ZodError) { + // eslint-disable-next-line no-console + console.error('Response parsing error: ', error.errors); + throw new Error('Response schema validation error.'); + } + + // eslint-disable-next-line no-console + console.error('Unexpected error while parsing response body: ', error); + throw new Error(`Error parsing response body.`); + } + } + + return responseBody as T; + } + + private getErrorMessageForResponse( + responseBody: unknown, + statusText: string + ): string { + if (typeof responseBody === 'string') { + return responseBody; + } + + if (typeof responseBody === 'object' && responseBody !== null) { + if ('message' in responseBody) { + if (Array.isArray(responseBody.message)) { + return responseBody.message.join(', '); + } + + if (typeof responseBody.message === 'string') { + return responseBody.message; + } + } + + return 'Unknown request error.'; + } + + if (statusText.length) { + return statusText; + } + + return 'Unknown request error.'; + } + + get: HttpApiClientMethod = async (path, config = {}) => { + return this.makeRequest('GET', path, config); + }; + post: HttpApiClientMethodWithBody = async (path, config = {}) => { + return this.makeRequest('POST', path, config); + }; + patch: HttpApiClientMethodWithBody = async (path, config = {}) => { + return this.makeRequest('PATCH', path, config); + }; + put: HttpApiClientMethodWithBody = async (path, config = {}) => { + return this.makeRequest('PUT', path, config); + }; + delete: HttpApiClientMethod = async (path, config = {}) => { + return this.makeRequest('DELETE', path, config); + }; +} + +export const humanAppApiClient = new HttpApiClient(env.VITE_API_URL); diff --git a/packages/apps/human-app/frontend/src/api/index.ts b/packages/apps/human-app/frontend/src/api/index.ts new file mode 100644 index 0000000000..f7df62cc91 --- /dev/null +++ b/packages/apps/human-app/frontend/src/api/index.ts @@ -0,0 +1,7 @@ +export * from './authorized-http-api-client'; +export { + HttpApiClient, + ApiClientError, + humanAppApiClient, +} from './http-api-client'; +export * from './auth-service'; diff --git a/packages/apps/human-app/frontend/src/api/utils/test.schema.ts b/packages/apps/human-app/frontend/src/api/utils/test.schema.ts deleted file mode 100644 index 04c6b07050..0000000000 --- a/packages/apps/human-app/frontend/src/api/utils/test.schema.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { z } from 'zod'; -import { testDataSchema } from '@/shared/types/entity.type'; - -export const testSchema = z.object({ - requestId: z.string(), - timestamp: testDataSchema, -}); diff --git a/packages/apps/human-app/frontend/src/api/utils/test.service.ts b/packages/apps/human-app/frontend/src/api/utils/test.service.ts deleted file mode 100644 index d2d6facd50..0000000000 --- a/packages/apps/human-app/frontend/src/api/utils/test.service.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { useQuery } from '@tanstack/react-query'; -import { apiClient } from '../api-client'; -import { apiPaths } from '../api-paths'; -import { testSchema } from './test.schema'; - -function getTest() { - return apiClient(apiPaths.test.path, { - options: { method: 'GET' }, - successSchema: testSchema, - }); -} - -export function useGetTest() { - return useQuery({ - queryKey: ['test'], - retry: false, - queryFn: getTest, - }); -} diff --git a/packages/apps/human-app/frontend/src/modules/auth/index.ts b/packages/apps/human-app/frontend/src/modules/auth/index.ts deleted file mode 100644 index 0e551ad9cd..0000000000 --- a/packages/apps/human-app/frontend/src/modules/auth/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { useAuth, useAuthenticatedUser } from './hooks/index'; diff --git a/packages/apps/human-app/frontend/src/modules/homepage/components/operator-sign-in.tsx b/packages/apps/human-app/frontend/src/modules/homepage/components/operator-sign-in.tsx index 92d38e947b..2c215be780 100644 --- a/packages/apps/human-app/frontend/src/modules/homepage/components/operator-sign-in.tsx +++ b/packages/apps/human-app/frontend/src/modules/homepage/components/operator-sign-in.tsx @@ -7,7 +7,6 @@ import { useWalletConnect } from '@/shared/contexts/wallet-connect'; import { useWeb3Auth } from '@/modules/auth-web3/hooks/use-web3-auth'; import { routerPaths } from '@/router/router-paths'; import { getErrorMessageForError } from '@/shared/errors'; -import { PrepareSignatureType } from '@/api/hooks/use-prepare-signature'; import { useWeb3SignIn } from '../hooks'; export function OperatorSignIn() { @@ -22,7 +21,7 @@ export function OperatorSignIn() { useEffect(() => { if (isConnected && modalWasOpened.current) { - signInMutation({ address, type: PrepareSignatureType.SIGN_IN }); + signInMutation(); } }, [address, isConnected, signInMutation]); @@ -77,7 +76,7 @@ export function OperatorSignIn() {