diff --git a/src/screens/WebLoginScreen/index.tsx b/src/screens/WebLoginScreen/index.tsx index 146784c41..dc55116a6 100644 --- a/src/screens/WebLoginScreen/index.tsx +++ b/src/screens/WebLoginScreen/index.tsx @@ -31,12 +31,12 @@ function WebLoginScreen({ route, navigation }: RootStackScreenProps<'WebLogin'>) return; } - const { mnemonic, token, newToken, privateKey } = params; + const { mnemonic, newToken, privateKey } = params; - if (!mnemonic || !token || !newToken) { + if (!mnemonic || !newToken) { setLoadingState('error'); setError(strings.screens.WebLoginScreen.missingParameters); - logger.error('WebLoginScreen: Missing required parameters', !mnemonic || !token || !newToken); + logger.error('WebLoginScreen: Missing required parameters', !mnemonic || !newToken); setTimeout(() => navigation.replace('SignIn'), 2000); return; } @@ -44,7 +44,6 @@ function WebLoginScreen({ route, navigation }: RootStackScreenProps<'WebLogin'>) try { const result = await authService.handleWebLogin({ mnemonic, - token, newToken, privateKey, }); diff --git a/src/services/AuthService.ts b/src/services/AuthService.ts index 0bb367f4c..8fd1444a7 100644 --- a/src/services/AuthService.ts +++ b/src/services/AuthService.ts @@ -1,6 +1,6 @@ import { logger } from '@internxt-mobile/services/common'; import { internxtMobileSDKConfig } from '@internxt/mobile-sdk'; -import { Keys, Password, TwoFactorAuthQR } from '@internxt/sdk'; +import { TwoFactorAuthQR } from '@internxt/sdk'; import { StorageTypes } from '@internxt/sdk/dist/drive'; import { UserSettings } from '@internxt/sdk/dist/shared/types/userSettings'; import * as bip39 from '@scure/bip39'; @@ -8,14 +8,13 @@ import { wordlist } from '@scure/bip39/wordlists/english.js'; import EventEmitter from 'events'; import { jwtDecode } from 'jwt-decode'; import { NetworkCacheModule } from '../../modules/network-cache'; -import { decryptText, decryptTextWithKey, encryptText, encryptTextWithKey, passToHash } from '../helpers'; +import { decryptText, encryptText, encryptTextWithKey, passToHash } from '../helpers'; import AesUtils from '../helpers/aesUtils'; import { getHeaders } from '../helpers/headers'; import { AsyncStorageKey } from '../types'; import analytics, { AnalyticsEventKey } from './AnalyticsService'; import appService from './AppService'; import asyncStorageService from './AsyncStorageService'; -import { keysService } from './common/keys'; import { SdkManager } from './common/sdk/SdkManager'; enum AuthEventKey { @@ -59,58 +58,7 @@ class AuthService { } } - public async doLogin(email: string, password: string, tfaCode?: string) { - const loginResult = await this.sdk.authV2.loginWithoutKeys( - { - email, - password, - tfaCode, - }, - { - encryptPasswordHash(password: Password, encryptedSalt: string): string { - const salt = decryptText(encryptedSalt); - const hashObj = passToHash({ password, salt }); - return encryptText(hashObj.hash); - }, - async generateKeys(): Promise { - const keys = { - privateKeyEncrypted: '', - publicKey: '', - revocationCertificate: '', - ecc: { - privateKeyEncrypted: '', - publicKey: '', - }, - kyber: { - publicKey: '', - privateKeyEncrypted: '', - }, - }; - return keys; - }, - }, - ); - - loginResult.user.mnemonic = decryptTextWithKey(loginResult.user.mnemonic, password); - - if (loginResult.user.privateKey) { - const decryptedPrivateKey = keysService.decryptPrivateKey(loginResult.user.privateKey, password); - loginResult.user.privateKey = Buffer.from(decryptedPrivateKey).toString('base64'); - } - - // Get the refreshed tokens, they contain expiration, the ones returned - // on the login doesn't have expiration - const refreshedTokens = await this.refreshAuthToken(loginResult.newToken); - - if (!refreshedTokens?.token || !refreshedTokens?.newToken) throw new Error('Unable to refresh auth tokens'); - return { - ...loginResult, - token: refreshedTokens.token, - newToken: refreshedTokens.newToken, - }; - } - - public async handleWebLogin(params: { mnemonic: string; token: string; newToken: string; privateKey?: string }) { + public async handleWebLogin(params: { mnemonic: string; newToken: string; privateKey?: string }) { try { const mnemonic = Buffer.from(params.mnemonic, 'base64').toString('utf-8'); const newToken = Buffer.from(params.newToken, 'base64').toString('utf-8'); diff --git a/src/services/common/keys/index.ts b/src/services/common/keys/index.ts deleted file mode 100644 index 79930834c..000000000 --- a/src/services/common/keys/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './keys.service'; diff --git a/src/services/common/keys/keys.service.ts b/src/services/common/keys/keys.service.ts deleted file mode 100644 index dc615381e..000000000 --- a/src/services/common/keys/keys.service.ts +++ /dev/null @@ -1,9 +0,0 @@ -import AesUtils from '../../../helpers/aesUtils'; - -export class KeysService { - decryptPrivateKey(privateKey: string, password: string): string { - return AesUtils.decrypt(privateKey, password); - } -} - -export const keysService = new KeysService();