Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/containers/TwoFactor/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { act, fireEvent, render, waitFor } from '@testing-library/react-native';

import TwoFactor from '.';
import { isTwoFactorCancelled, twoFactor } from '../../lib/services/twoFactor';
import { twoFactor } from '../../lib/services/twoFactor/twoFactor';
import { isTwoFactorCancelled } from '../../lib/services/twoFactor/twoFactorCancelled';

jest.mock('../../lib/services/restApi', () => ({
sendEmailCode: jest.fn()
Expand Down
3 changes: 1 addition & 2 deletions app/containers/TwoFactor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import { useMasterDetail } from '../../lib/hooks/useMasterDetail';
import Toast from '../Toast';
import { showToast } from '../../lib/methods/helpers/showToast';
import log from '../../lib/methods/helpers/log';

export const TWO_FACTOR = 'TWO_FACTOR';
import { TWO_FACTOR } from '../../lib/constants/twoFactor';

interface IMethodsProp {
text: string;
Expand Down
1 change: 1 addition & 0 deletions app/lib/constants/twoFactor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const TWO_FACTOR = 'TWO_FACTOR';
2 changes: 1 addition & 1 deletion app/lib/methods/helpers/handleSaveUserProfileError.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import I18n from '../../../i18n';
import { showErrorAlert } from '.';
import { isTwoFactorCancelled } from '../../services/twoFactorCancelled';
import { isTwoFactorCancelled } from '../../services/twoFactor/twoFactorCancelled';

const handleSaveUserProfileError = (e: any, action: string) => {
if (isTwoFactorCancelled(e)) {
Expand Down
2 changes: 1 addition & 1 deletion app/lib/methods/helpers/info.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Alert } from 'react-native';

import I18n from '../../../i18n';
import { isTwoFactorCancelled } from '../../services/twoFactorCancelled';
import { isTwoFactorCancelled } from '../../services/twoFactor/twoFactorCancelled';

export const showErrorAlert = (message: string, title?: string, onPress = () => {}): void =>
Alert.alert(title || '', message, [{ text: 'OK', onPress }], { cancelable: true });
Expand Down
2 changes: 1 addition & 1 deletion app/lib/methods/helpers/log/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getCrashlytics as crashlytics } from '@react-native-firebase/crashlytic
import bugsnag from '@bugsnag/react-native';

import events from './events';
import { isTwoFactorCancelled } from '../../../services/twoFactorCancelled';
import { isTwoFactorCancelled } from '../../../services/twoFactor/twoFactorCancelled';

export { events };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jest.mock('../../helpers/log', () => ({
default: jest.fn()
}));

jest.mock('../../../services/twoFactor', () => ({
jest.mock('../../../services/twoFactor/twoFactor', () => ({
twoFactor: jest.fn()
}));

Expand Down
2 changes: 1 addition & 1 deletion app/lib/services/__tests__/connect.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jest.mock('../voip/MediaSessionInstance', () => ({
}
}));

jest.mock('../twoFactor', () => ({
jest.mock('../twoFactor/twoFactor', () => ({
twoFactor: jest.fn()
}));

Expand Down
2 changes: 1 addition & 1 deletion app/lib/services/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import log from '../methods/helpers/log';
import { setActiveUsers } from '../../actions/activeUsers';
import protectedFunction from '../methods/helpers/protectedFunction';
import database from '../database';
import { twoFactor } from './twoFactor';
import { twoFactor } from './twoFactor/twoFactor';
import { store } from '../store/auxStore';
import { loginRequest, logout, setLoginServices, setUser } from '../../actions/login';
import { waitForLoginReady } from './waitForLoginReady';
Expand Down
7 changes: 3 additions & 4 deletions app/lib/services/sdk.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sdk from './sdk';
import { TwoFactorCancelledError, isTwoFactorCancelled } from './twoFactor';
import { TwoFactorCancelledError, isTwoFactorCancelled } from './twoFactor/twoFactorCancelled';

const mockInnerMethodCall = jest.fn();
const mockInnerPost = jest.fn();
Expand All @@ -13,10 +13,9 @@ jest.mock('@rocket.chat/sdk', () => ({
settings: { customHeaders: {} }
}));

jest.mock('../../containers/TwoFactor', () => ({ TWO_FACTOR: 'TWO_FACTOR' }));
jest.mock('../constants/twoFactor', () => ({ TWO_FACTOR: 'TWO_FACTOR' }));

jest.mock('./twoFactor', () => ({
...jest.requireActual('./twoFactor'),
jest.mock('./twoFactor/twoFactor', () => ({
twoFactor: (...args: unknown[]) => mockTwoFactor(...args)
}));

Expand Down
2 changes: 1 addition & 1 deletion app/lib/services/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { type ICallback, type ICurrentLogin, type ILoginCredentials, type ISubsc
import EJSON from 'ejson';
import isEmpty from 'lodash/isEmpty';

import { twoFactor } from './twoFactor';
import { twoFactor } from './twoFactor/twoFactor';
import { isSsl } from '../methods/helpers/isSsl';
import { store as reduxStore } from '../store/auxStore';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { settings } from '@rocket.chat/sdk';

import { TWO_FACTOR } from '../../containers/TwoFactor';
import EventEmitter from '../methods/helpers/events';
import { type ILoginCredentials } from '../../definitions';
import { TWO_FACTOR } from '../../constants/twoFactor';
import EventEmitter from '../../methods/helpers/events';
import { type ILoginCredentials } from '../../../definitions';
import { TwoFactorCancelledError } from './twoFactorCancelled';

export { TwoFactorCancelledError, isTwoFactorCancelled } from './twoFactorCancelled';

interface ITwoFactor {
method: string;
invalid: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Alert } from 'react-native';
import bugsnag from '@bugsnag/react-native';

import log from './log';
import { showErrorAlertWithEMessage } from './info';
import handleSaveUserProfileError from './handleSaveUserProfileError';
import log from '../../methods/helpers/log';
import { showErrorAlertWithEMessage } from '../../methods/helpers/info';
import handleSaveUserProfileError from '../../methods/helpers/handleSaveUserProfileError';
import { handleLoginErrors } from '../../../views/LoginView/handleLoginErrors';
import { TwoFactorCancelledError } from '../../services/twoFactorCancelled';
import { TwoFactorCancelledError } from './twoFactorCancelled';

jest.mock('../../../i18n', () => ({
t: (key: string) => key,
Expand Down
2 changes: 1 addition & 1 deletion app/sagas/__tests__/foregroundResume.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jest.mock('../../lib/services/voip/MediaSessionStore', () => ({
mediaSessionStore: { getCurrentInstance: jest.fn(() => null) }
}));

jest.mock('../../lib/services/twoFactor', () => ({
jest.mock('../../lib/services/twoFactor/twoFactor', () => ({
twoFactor: jest.fn()
}));

Expand Down
2 changes: 1 addition & 1 deletion app/sagas/__tests__/selectServer.sdkHost.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jest.mock('../../lib/methods/helpers/log', () => ({
logServerVersion: jest.fn()
}));

jest.mock('../../lib/services/twoFactor', () => ({
jest.mock('../../lib/services/twoFactor/twoFactor', () => ({
twoFactor: jest.fn()
}));

Expand Down
2 changes: 1 addition & 1 deletion app/sagas/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { getIsMasterDetail } from '../lib/hooks/useMasterDetail';
import { getEnterpriseModules, isOmnichannelModuleAvailable, isVoipModuleAvailable } from '../lib/methods/enterpriseModules';
import { getPermissions } from '../lib/methods/getPermissions';
import { getRoles } from '../lib/methods/getRoles';
import { isTwoFactorCancelled } from '../lib/services/twoFactor';
import { isTwoFactorCancelled } from '../lib/services/twoFactor/twoFactorCancelled';
import { getSlashCommands } from '../lib/methods/getSlashCommands';
import { getUserPresence, refreshDmUsersPresence, subscribeUsersPresence } from '../lib/methods/getUsersPresence';
import { logout, removeServerData, removeServerDatabase } from '../lib/methods/logout';
Expand Down
2 changes: 1 addition & 1 deletion app/views/ChangeAvatarView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import ImagePicker, { type Image } from '../../lib/methods/helpers/ImagePicker/I
import { compareServerVersion, isImageURL, useDebounce } from '../../lib/methods/helpers';
import { ControlledFormTextInput } from '../../containers/TextInput';
import { HeaderBackButton } from '../../containers/Header/components/HeaderBackButton';
import { isTwoFactorCancelled } from '../../lib/services/twoFactor';
import { isTwoFactorCancelled } from '../../lib/services/twoFactor/twoFactorCancelled';

enum AvatarStateActions {
CHANGE_AVATAR = 'CHANGE_AVATAR',
Expand Down
2 changes: 1 addition & 1 deletion app/views/ChangeAvatarView/submitHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import I18n from '../../i18n';
import { isTwoFactorCancelled } from '../../lib/services/twoFactorCancelled';
import { isTwoFactorCancelled } from '../../lib/services/twoFactor/twoFactorCancelled';

export const handleError = (e: any, action: string) => {
if (isTwoFactorCancelled(e)) {
Expand Down
7 changes: 3 additions & 4 deletions app/views/ChangePasswordView/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { useDispatch } from 'react-redux';
import ChangePasswordView from './index';
import { useAppSelector } from '../../lib/hooks/useAppSelector';
import { saveUserProfile } from '../../lib/services/restApi';
import { twoFactor } from '../../lib/services/twoFactor';
import { TwoFactorCancelledError } from '../../lib/services/twoFactor';
import { twoFactor } from '../../lib/services/twoFactor/twoFactor';
import { TwoFactorCancelledError } from '../../lib/services/twoFactor/twoFactorCancelled';
import handleSaveUserProfileError from '../../lib/methods/helpers/handleSaveUserProfileError';
import { TwoFactorMethods } from '../../definitions/ITotp';

Expand All @@ -22,8 +22,7 @@ jest.mock('../../lib/services/restApi', () => ({
setPassword: jest.fn()
}));

jest.mock('../../lib/services/twoFactor', () => ({
...jest.requireActual('../../lib/services/twoFactor'),
jest.mock('../../lib/services/twoFactor/twoFactor', () => ({
twoFactor: jest.fn()
}));

Expand Down
3 changes: 2 additions & 1 deletion app/views/ChangePasswordView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { type NativeStackNavigationProp } from '@react-navigation/native-stack';
import { useDispatch } from 'react-redux';
import { sha256 } from 'js-sha256';

import { twoFactor, isTwoFactorCancelled } from '../../lib/services/twoFactor';
import { twoFactor } from '../../lib/services/twoFactor/twoFactor';
import { isTwoFactorCancelled } from '../../lib/services/twoFactor/twoFactorCancelled';
import { type ProfileStackParamList } from '../../stacks/types';
import { ControlledFormTextInput } from '../../containers/TextInput';
import { useAppSelector } from '../../lib/hooks/useAppSelector';
Expand Down
2 changes: 1 addition & 1 deletion app/views/E2EEToggleRoomView/resetRoomKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Encryption } from '../../lib/encryption';
import log from '../../lib/methods/helpers/log';
import { showToast } from '../../lib/methods/helpers/showToast';
import { e2eResetRoomKey } from '../../lib/services/restApi';
import { isTwoFactorCancelled } from '../../lib/services/twoFactor';
import { isTwoFactorCancelled } from '../../lib/services/twoFactor/twoFactorCancelled';

export const resetRoomKey = (rid: string) => {
Alert.alert(
Expand Down
2 changes: 1 addition & 1 deletion app/views/E2EEncryptionSecurityView/ChangePassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import log, { events, logEvent } from '../../lib/methods/helpers/log';
import { FormTextInput } from '../../containers/TextInput';
import Button from '../../containers/Button';
import { Encryption } from '../../lib/encryption';
import { isTwoFactorCancelled } from '../../lib/services/twoFactor';
import { isTwoFactorCancelled } from '../../lib/services/twoFactor/twoFactorCancelled';
import { showConfirmationAlert, showErrorAlert } from '../../lib/methods/helpers/info';
import EventEmitter from '../../lib/methods/helpers/events';
import { LISTENER } from '../../containers/Toast';
Expand Down
2 changes: 1 addition & 1 deletion app/views/E2EEncryptionSecurityView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Button from '../../containers/Button';
import { logout } from '../../actions/login';
import { showConfirmationAlert, showErrorAlert } from '../../lib/methods/helpers/info';
import { e2eResetOwnKey } from '../../lib/services/restApi';
import { isTwoFactorCancelled } from '../../lib/services/twoFactor';
import { isTwoFactorCancelled } from '../../lib/services/twoFactor/twoFactorCancelled';
import { type SettingsStackParamList } from '../../stacks/types';
import ChangePassword from './ChangePassword';
import { styles } from './styles';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import sharedStyles from '../../../Styles';
import FooterButtons from './FooterButtons';
import AlertText from './AlertText';
import { deleteOwnAccount } from '../../../../lib/services/restApi';
import { isTwoFactorCancelled } from '../../../../lib/services/twoFactor';
import { isTwoFactorCancelled } from '../../../../lib/services/twoFactor/twoFactorCancelled';
import { deleteAccount } from '../../../../actions/login';
import { CustomIcon } from '../../../../containers/CustomIcon';
import { useTheme } from '../../../../theme';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import sharedStyles from '../../../Styles';
import FooterButtons from './FooterButtons';
import ConfirmDeleteAccountContent from './ConfirmDeleteAccountContent';
import { deleteOwnAccount } from '../../../../lib/services/restApi';
import { isTwoFactorCancelled } from '../../../../lib/services/twoFactor';
import { isTwoFactorCancelled } from '../../../../lib/services/twoFactor/twoFactorCancelled';
import { deleteAccount } from '../../../../actions/login';
import { CustomIcon } from '../../../../containers/CustomIcon';
import { useTheme } from '../../../../theme';
Expand Down
7 changes: 3 additions & 4 deletions app/views/ProfileView/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { sha256 } from 'js-sha256';
import ProfileView from './index';
import { useAppSelector } from '../../lib/hooks/useAppSelector';
import { saveUserProfile } from '../../lib/services/restApi';
import { twoFactor } from '../../lib/services/twoFactor';
import { TwoFactorCancelledError } from '../../lib/services/twoFactorCancelled';
import { twoFactor } from '../../lib/services/twoFactor/twoFactor';
import { TwoFactorCancelledError } from '../../lib/services/twoFactor/twoFactorCancelled';
import handleSaveUserProfileError from '../../lib/methods/helpers/handleSaveUserProfileError';
import EventEmitter from '../../lib/methods/helpers/events';
import { setUser } from '../../actions/login';
Expand All @@ -28,8 +28,7 @@ jest.mock('../../lib/services/restApi', () => ({
saveUserProfile: jest.fn()
}));

jest.mock('../../lib/services/twoFactor', () => ({
...jest.requireActual('../../lib/services/twoFactor'),
jest.mock('../../lib/services/twoFactor/twoFactor', () => ({
twoFactor: jest.fn()
}));

Expand Down
3 changes: 2 additions & 1 deletion app/views/ProfileView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import EventEmitter from '../../lib/methods/helpers/events';
import { events, logEvent } from '../../lib/methods/helpers/log';
import scrollPersistTaps from '../../lib/methods/helpers/scrollPersistTaps';
import { saveUserProfile } from '../../lib/services/restApi';
import { twoFactor, isTwoFactorCancelled } from '../../lib/services/twoFactor';
import { twoFactor } from '../../lib/services/twoFactor/twoFactor';
import { isTwoFactorCancelled } from '../../lib/services/twoFactor/twoFactorCancelled';
import { getUserSelector } from '../../selectors/login';
import { type ProfileStackParamList } from '../../stacks/types';
import { useTheme } from '../../theme';
Expand Down
2 changes: 1 addition & 1 deletion app/views/ProfileView/methods/logoutOtherLocations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import EventEmitter from '../../../lib/methods/helpers/events';
import { showConfirmationAlert } from '../../../lib/methods/helpers';
import { events, logEvent } from '../../../lib/methods/helpers/log';
import { logoutOtherLocations as logoutOtherLocationsService } from '../../../lib/services/restApi';
import { isTwoFactorCancelled } from '../../../lib/services/twoFactor';
import { isTwoFactorCancelled } from '../../../lib/services/twoFactor/twoFactorCancelled';

const logoutOtherLocations = () => {
logEvent(events.PL_OTHER_LOCATIONS);
Expand Down
2 changes: 1 addition & 1 deletion app/views/SetUsernameView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { showErrorAlert } from '../lib/methods/helpers';
import scrollPersistTaps from '../lib/methods/helpers/scrollPersistTaps';
import sharedStyles from './Styles';
import { getUsernameSuggestion, saveUserProfile } from '../lib/services/restApi';
import { isTwoFactorCancelled } from '../lib/services/twoFactor';
import { isTwoFactorCancelled } from '../lib/services/twoFactor/twoFactorCancelled';
import { useAppSelector } from '../lib/hooks/useAppSelector';

const styles = StyleSheet.create({
Expand Down
Loading