diff --git a/lib/actions/user-actions.js b/lib/actions/user-actions.js --- a/lib/actions/user-actions.js +++ b/lib/actions/user-actions.js @@ -25,8 +25,8 @@ import type { LogInInfo, LogInResult, - RegisterResult, - RegisterInfo, + LegacyRegisterResult, + LegacyRegisterInfo, UpdateUserSettingsRequest, PolicyAcknowledgmentRequest, ClaimUsernameResponse, @@ -285,21 +285,21 @@ ]); } -const keyserverRegisterActionTypes = Object.freeze({ - started: 'KEYSERVER_REGISTER_STARTED', - success: 'KEYSERVER_REGISTER_SUCCESS', - failed: 'KEYSERVER_REGISTER_FAILED', +const legacyKeyserverRegisterActionTypes = Object.freeze({ + started: 'LEGACY_KEYSERVER_REGISTER_STARTED', + success: 'LEGACY_KEYSERVER_REGISTER_SUCCESS', + failed: 'LEGACY_KEYSERVER_REGISTER_FAILED', }); -const registerCallSingleKeyserverEndpointOptions = { +const legacyKeyserverRegisterCallSingleKeyserverEndpointOptions = { timeout: permissionsAndAuthRelatedRequestTimeout, }; -const keyserverRegister = +const legacyKeyserverRegister = ( callSingleKeyserverEndpoint: CallSingleKeyserverEndpoint, ): (( - registerInfo: RegisterInfo, + registerInfo: LegacyRegisterInfo, options?: CallSingleKeyserverEndpointOptions, - ) => Promise) => + ) => Promise) => async (registerInfo, options) => { const deviceTokenUpdateRequest = registerInfo.deviceTokenUpdateRequest[authoritativeKeyserverID()]; @@ -313,7 +313,7 @@ platformDetails: getConfig().platformDetails, }, { - ...registerCallSingleKeyserverEndpointOptions, + ...legacyKeyserverRegisterCallSingleKeyserverEndpointOptions, ...options, }, ); @@ -870,8 +870,8 @@ legacyLogInActionTypes, useLogOut, logOutActionTypes, - keyserverRegister, - keyserverRegisterActionTypes, + legacyKeyserverRegister, + legacyKeyserverRegisterActionTypes, searchUsers, searchUsersActionTypes, exactSearchUser, diff --git a/lib/reducers/calendar-filters-reducer.js b/lib/reducers/calendar-filters-reducer.js --- a/lib/reducers/calendar-filters-reducer.js +++ b/lib/reducers/calendar-filters-reducer.js @@ -15,7 +15,7 @@ keyserverAuthActionTypes, deleteKeyserverAccountActionTypes, legacyLogInActionTypes, - keyserverRegisterActionTypes, + legacyKeyserverRegisterActionTypes, } from '../actions/user-actions.js'; import { extractKeyserverIDFromID } from '../keyserver-conn/keyserver-call-utils.js'; import { setNewSessionActionType } from '../keyserver-conn/keyserver-conn-types.js'; @@ -54,7 +54,7 @@ if ( action.type === legacyLogInActionTypes.success || action.type === legacySiweAuthActionTypes.success || - action.type === keyserverRegisterActionTypes.success + action.type === legacyKeyserverRegisterActionTypes.success ) { return defaultCalendarFilters; } else if ( diff --git a/lib/reducers/integrity-reducer.js b/lib/reducers/integrity-reducer.js --- a/lib/reducers/integrity-reducer.js +++ b/lib/reducers/integrity-reducer.js @@ -6,7 +6,7 @@ import { keyserverAuthActionTypes, legacyLogInActionTypes, - keyserverRegisterActionTypes, + legacyKeyserverRegisterActionTypes, } from '../actions/user-actions.js'; import { extractKeyserverIDFromID } from '../keyserver-conn/keyserver-call-utils.js'; import { @@ -82,7 +82,7 @@ } else if ( action.type === legacyLogInActionTypes.success || action.type === legacySiweAuthActionTypes.success || - action.type === keyserverRegisterActionTypes.success || + action.type === legacyKeyserverRegisterActionTypes.success || (action.type === setClientDBStoreActionType && !!action.payload.threadStore && state.threadHashingStatus !== 'completed') diff --git a/lib/reducers/keyserver-reducer.js b/lib/reducers/keyserver-reducer.js --- a/lib/reducers/keyserver-reducer.js +++ b/lib/reducers/keyserver-reducer.js @@ -21,7 +21,7 @@ logOutActionTypes, deleteKeyserverAccountActionTypes, deleteAccountActionTypes, - keyserverRegisterActionTypes, + legacyKeyserverRegisterActionTypes, legacyLogInActionTypes, } from '../actions/user-actions.js'; import { extractKeyserverIDFromID } from '../keyserver-conn/keyserver-call-utils.js'; @@ -325,7 +325,7 @@ keyserverStore: processStoreOps(state, [operation]), keyserverStoreOperations: [operation], }; - } else if (action.type === keyserverRegisterActionTypes.success) { + } else if (action.type === legacyKeyserverRegisterActionTypes.success) { const operation: ReplaceKeyserverOperation = { type: 'replace_keyserver', payload: { diff --git a/lib/reducers/master-reducer.js b/lib/reducers/master-reducer.js --- a/lib/reducers/master-reducer.js +++ b/lib/reducers/master-reducer.js @@ -27,7 +27,7 @@ import { addKeyserverActionType } from '../actions/keyserver-actions.js'; import { legacySiweAuthActionTypes } from '../actions/siwe-actions.js'; import { - keyserverRegisterActionTypes, + legacyKeyserverRegisterActionTypes, legacyLogInActionTypes, keyserverAuthActionTypes, } from '../actions/user-actions.js'; @@ -92,7 +92,7 @@ if ( action.type !== incrementalStateSyncActionType && action.type !== fullStateSyncActionType && - action.type !== keyserverRegisterActionTypes.success && + action.type !== legacyKeyserverRegisterActionTypes.success && action.type !== legacyLogInActionTypes.success && action.type !== legacySiweAuthActionTypes.success && action.type !== keyserverAuthActionTypes.success && diff --git a/lib/reducers/message-reducer.js b/lib/reducers/message-reducer.js --- a/lib/reducers/message-reducer.js +++ b/lib/reducers/message-reducer.js @@ -50,7 +50,7 @@ keyserverAuthActionTypes, deleteKeyserverAccountActionTypes, legacyLogInActionTypes, - keyserverRegisterActionTypes, + legacyKeyserverRegisterActionTypes, } from '../actions/user-actions.js'; import { setNewSessionActionType } from '../keyserver-conn/keyserver-conn-types.js'; import { @@ -920,7 +920,7 @@ }, newThreadInfos, ); - } else if (action.type === keyserverRegisterActionTypes.success) { + } else if (action.type === legacyKeyserverRegisterActionTypes.success) { const truncationStatuses: { [string]: MessageTruncationStatus } = {}; for (const messageInfo of action.payload.rawMessageInfos) { truncationStatuses[messageInfo.threadID] = diff --git a/lib/reducers/nav-reducer.js b/lib/reducers/nav-reducer.js --- a/lib/reducers/nav-reducer.js +++ b/lib/reducers/nav-reducer.js @@ -5,7 +5,7 @@ import { identityRegisterActionTypes, legacyLogInActionTypes, - keyserverRegisterActionTypes, + legacyKeyserverRegisterActionTypes, logOutActionTypes, deleteAccountActionTypes, identityLogInActionTypes, @@ -26,7 +26,7 @@ if ( action.type === legacyLogInActionTypes.started || action.type === legacySiweAuthActionTypes.started || - action.type === keyserverRegisterActionTypes.started || + action.type === legacyKeyserverRegisterActionTypes.started || action.type === fullStateSyncActionType || action.type === incrementalStateSyncActionType ) { diff --git a/lib/reducers/theme-reducer.js b/lib/reducers/theme-reducer.js --- a/lib/reducers/theme-reducer.js +++ b/lib/reducers/theme-reducer.js @@ -4,7 +4,7 @@ import { updateThemeInfoActionType } from '../actions/theme-actions.js'; import { legacyLogInActionTypes, - keyserverRegisterActionTypes, + legacyKeyserverRegisterActionTypes, } from '../actions/user-actions.js'; import { setNewSessionActionType } from '../keyserver-conn/keyserver-conn-types.js'; import type { BaseAction } from '../types/redux-types.js'; @@ -22,7 +22,7 @@ if ( action.type === legacyLogInActionTypes.success || action.type === legacySiweAuthActionTypes.success || - action.type === keyserverRegisterActionTypes.success + action.type === legacyKeyserverRegisterActionTypes.success ) { return defaultGlobalThemeInfo; } else if ( diff --git a/lib/reducers/thread-reducer.js b/lib/reducers/thread-reducer.js --- a/lib/reducers/thread-reducer.js +++ b/lib/reducers/thread-reducer.js @@ -22,7 +22,7 @@ keyserverAuthActionTypes, deleteKeyserverAccountActionTypes, legacyLogInActionTypes, - keyserverRegisterActionTypes, + legacyKeyserverRegisterActionTypes, updateSubscriptionActionTypes, } from '../actions/user-actions.js'; import { @@ -109,7 +109,7 @@ } else if ( action.type === legacyLogInActionTypes.success || action.type === legacySiweAuthActionTypes.success || - action.type === keyserverRegisterActionTypes.success + action.type === legacyKeyserverRegisterActionTypes.success ) { const newThreadInfos = action.payload.threadInfos; const threadStoreOperations = [ diff --git a/lib/reducers/user-reducer.js b/lib/reducers/user-reducer.js --- a/lib/reducers/user-reducer.js +++ b/lib/reducers/user-reducer.js @@ -16,7 +16,7 @@ keyserverAuthActionTypes, logOutActionTypes, legacyLogInActionTypes, - keyserverRegisterActionTypes, + legacyKeyserverRegisterActionTypes, setUserSettingsActionTypes, updateUserAvatarActionTypes, } from '../actions/user-actions.js'; @@ -67,7 +67,7 @@ } else if ( action.type === legacyLogInActionTypes.success || action.type === legacySiweAuthActionTypes.success || - action.type === keyserverRegisterActionTypes.success || + action.type === legacyKeyserverRegisterActionTypes.success || action.type === logOutActionTypes.success || action.type === deleteAccountActionTypes.success ) { @@ -273,7 +273,7 @@ } else if ( action.type === legacyLogInActionTypes.success || action.type === legacySiweAuthActionTypes.success || - action.type === keyserverRegisterActionTypes.success + action.type === legacyKeyserverRegisterActionTypes.success ) { const newUserInfos = _keyBy(userInfo => userInfo.id)( action.payload.userInfos, diff --git a/lib/types/account-types.js b/lib/types/account-types.js --- a/lib/types/account-types.js +++ b/lib/types/account-types.js @@ -51,7 +51,7 @@ +currentUserInfo: LoggedOutUserInfo, }; -export type RegisterInfo = { +export type LegacyRegisterInfo = { ...LogInExtraInfo, +username: string, +password: string, @@ -87,7 +87,7 @@ }, }; -export type RegisterResult = { +export type LegacyRegisterResult = { +currentUserInfo: LoggedInUserInfo, +rawMessageInfos: $ReadOnlyArray, +threadInfos: RawThreadInfos, diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js --- a/lib/types/redux-types.js +++ b/lib/types/redux-types.js @@ -5,7 +5,7 @@ KeyserverLogOutResult, LogInStartingPayload, LogInResult, - RegisterResult, + LegacyRegisterResult, DefaultNotificationPayload, ClaimUsernameResponse, KeyserverAuthResult, @@ -407,19 +407,19 @@ +loadingInfo: LoadingInfo, } | { - +type: 'KEYSERVER_REGISTER_STARTED', + +type: 'LEGACY_KEYSERVER_REGISTER_STARTED', +loadingInfo: LoadingInfo, +payload: LogInStartingPayload, } | { - +type: 'KEYSERVER_REGISTER_FAILED', + +type: 'LEGACY_KEYSERVER_REGISTER_FAILED', +error: true, +payload: Error, +loadingInfo: LoadingInfo, } | { - +type: 'KEYSERVER_REGISTER_SUCCESS', - +payload: RegisterResult, + +type: 'LEGACY_KEYSERVER_REGISTER_SUCCESS', + +payload: LegacyRegisterResult, +loadingInfo: LoadingInfo, } | { diff --git a/native/account/register-panel.react.js b/native/account/legacy-register-panel.react.js rename from native/account/register-panel.react.js rename to native/account/legacy-register-panel.react.js --- a/native/account/register-panel.react.js +++ b/native/account/legacy-register-panel.react.js @@ -14,8 +14,8 @@ import { setDataLoadedActionType } from 'lib/actions/client-db-store-actions.js'; import { - keyserverRegisterActionTypes, - keyserverRegister, + legacyKeyserverRegisterActionTypes, + legacyKeyserverRegister, getOlmSessionInitializationDataActionTypes, } from 'lib/actions/user-actions.js'; import { useLegacyAshoatKeyserverCall } from 'lib/keyserver-conn/legacy-keyserver-call.js'; @@ -26,9 +26,9 @@ import { validUsernameRegex } from 'lib/shared/account-utils.js'; import { useInitialNotificationsEncryptedMessage } from 'lib/shared/crypto-utils.js'; import type { - RegisterInfo, + LegacyRegisterInfo, LogInExtraInfo, - RegisterResult, + LegacyRegisterResult, LogInStartingPayload, } from 'lib/types/account-types.js'; import type { LoadingStatus } from 'lib/types/loading-types.js'; @@ -56,16 +56,16 @@ import Alert from '../utils/alert.js'; import { type StateContainer } from '../utils/state-container.js'; -type WritableRegisterState = { +type WritableLegacyRegisterState = { usernameInputText: string, passwordInputText: string, confirmPasswordInputText: string, }; -export type RegisterState = $ReadOnly; +export type LegacyRegisterState = $ReadOnly; type BaseProps = { +setActiveAlert: (activeAlert: boolean) => void, +opacityValue: Animated.Node, - +registerState: StateContainer, + +legacyRegisterState: StateContainer, }; type Props = { ...BaseProps, @@ -73,13 +73,15 @@ +logInExtraInfo: () => Promise, +dispatch: Dispatch, +dispatchActionPromise: DispatchActionPromise, - +register: (registerInfo: RegisterInfo) => Promise, + +legacyRegister: ( + registerInfo: LegacyRegisterInfo, + ) => Promise, +getInitialNotificationsEncryptedMessage: () => Promise, }; type State = { +confirmPasswordFocused: boolean, }; -class RegisterPanel extends React.PureComponent { +class LegacyRegisterPanel extends React.PureComponent { state: State = { confirmPasswordFocused: false, }; @@ -93,7 +95,7 @@ if ( Platform.OS !== 'ios' || this.state.confirmPasswordFocused || - this.props.registerState.state.confirmPasswordInputText.length > 0 + this.props.legacyRegisterState.state.confirmPasswordInputText.length > 0 ) { confirmPasswordTextInputExtraProps = { secureTextEntry: true, @@ -136,7 +138,7 @@ /> { - this.props.registerState.setState({ usernameInputText: text }); + this.props.legacyRegisterState.setState({ usernameInputText: text }); }; onChangePasswordInputText = (text: string) => { - const stateUpdate: Partial = {}; + const stateUpdate: Partial = {}; stateUpdate.passwordInputText = text; if (this.passwordBeingAutoFilled) { this.passwordBeingAutoFilled = false; stateUpdate.confirmPasswordInputText = text; } - this.props.registerState.setState(stateUpdate); + this.props.legacyRegisterState.setState(stateUpdate); }; onPasswordKeyPress = (event: KeyPressEvent) => { @@ -258,14 +262,14 @@ key.length > 1 && key !== 'Backspace' && key !== 'Enter' && - this.props.registerState.state.confirmPasswordInputText.length === 0 + this.props.legacyRegisterState.state.confirmPasswordInputText.length === 0 ) { this.passwordBeingAutoFilled = true; } }; onChangeConfirmPasswordInputText = (text: string) => { - this.props.registerState.setState({ confirmPasswordInputText: text }); + this.props.legacyRegisterState.setState({ confirmPasswordInputText: text }); }; onConfirmPasswordFocus = () => { @@ -274,7 +278,7 @@ onSubmit = async () => { this.props.setActiveAlert(true); - if (this.props.registerState.state.passwordInputText === '') { + if (this.props.legacyRegisterState.state.passwordInputText === '') { Alert.alert( 'Empty password', 'Password cannot be empty', @@ -282,8 +286,8 @@ { cancelable: false }, ); } else if ( - this.props.registerState.state.passwordInputText !== - this.props.registerState.state.confirmPasswordInputText + this.props.legacyRegisterState.state.passwordInputText !== + this.props.legacyRegisterState.state.confirmPasswordInputText ) { Alert.alert( 'Passwords don’t match', @@ -292,7 +296,7 @@ { cancelable: false }, ); } else if ( - this.props.registerState.state.usernameInputText.search( + this.props.legacyRegisterState.state.usernameInputText.search( validUsernameRegex, ) === -1 ) { @@ -310,8 +314,8 @@ const initialNotificationsEncryptedMessage = await this.props.getInitialNotificationsEncryptedMessage(); void this.props.dispatchActionPromise( - keyserverRegisterActionTypes, - this.registerAction({ + legacyKeyserverRegisterActionTypes, + this.legacyRegisterAction({ ...extraInfo, initialNotificationsEncryptedMessage, }), @@ -323,7 +327,7 @@ onPasswordAlertAcknowledged = () => { this.props.setActiveAlert(false); - this.props.registerState.setState( + this.props.legacyRegisterState.setState( { passwordInputText: '', confirmPasswordInputText: '', @@ -337,7 +341,7 @@ onUsernameAlertAcknowledged = () => { this.props.setActiveAlert(false); - this.props.registerState.setState( + this.props.legacyRegisterState.setState( { usernameInputText: '', }, @@ -348,12 +352,14 @@ ); }; - async registerAction(extraInfo: LogInExtraInfo): Promise { + async legacyRegisterAction( + extraInfo: LogInExtraInfo, + ): Promise { try { - const result = await this.props.register({ + const result = await this.props.legacyRegister({ ...extraInfo, - username: this.props.registerState.state.usernameInputText, - password: this.props.registerState.state.passwordInputText, + username: this.props.legacyRegisterState.state.usernameInputText, + password: this.props.legacyRegisterState.state.passwordInputText, }); this.props.setActiveAlert(false); this.props.dispatch({ @@ -364,7 +370,7 @@ }); await setNativeCredentials({ username: result.currentUserInfo.username, - password: this.props.registerState.state.passwordInputText, + password: this.props.legacyRegisterState.state.passwordInputText, }); return result; } catch (e) { @@ -403,7 +409,7 @@ onUnknownErrorAlertAcknowledged = () => { this.props.setActiveAlert(false); - this.props.registerState.setState( + this.props.legacyRegisterState.setState( { usernameInputText: '', passwordInputText: '', @@ -465,13 +471,15 @@ }); const registerLoadingStatusSelector = createLoadingStatusSelector( - keyserverRegisterActionTypes, + legacyKeyserverRegisterActionTypes, ); const olmSessionInitializationDataLoadingStatusSelector = createLoadingStatusSelector(getOlmSessionInitializationDataActionTypes); -const ConnectedRegisterPanel: React.ComponentType = - React.memo(function ConnectedRegisterPanel(props: BaseProps) { +const ConnectedLegacyRegisterPanel: React.ComponentType = + React.memo(function ConnectedLegacyRegisterPanel( + props: BaseProps, + ) { const registerLoadingStatus = useSelector(registerLoadingStatusSelector); const olmSessionInitializationDataLoadingStatus = useSelector( olmSessionInitializationDataLoadingStatusSelector, @@ -485,18 +493,20 @@ const dispatch = useDispatch(); const dispatchActionPromise = useDispatchActionPromise(); - const callRegister = useLegacyAshoatKeyserverCall(keyserverRegister); + const callLegacyRegister = useLegacyAshoatKeyserverCall( + legacyKeyserverRegister, + ); const getInitialNotificationsEncryptedMessage = useInitialNotificationsEncryptedMessage(authoritativeKeyserverID); return ( - , - +registerState: StateContainer, + +legacyRegisterState: StateContainer, }; class LoggedOutModal extends React.PureComponent { keyboardShowListener: ?EventSubscription; @@ -281,12 +281,15 @@ }, }), ); - const setRegisterState = setStateForContainer( + const setLegacyRegisterState = setStateForContainer< + State, + LegacyRegisterState, + >( this.guardedSetState, - (change: Partial) => (fullState: State) => ({ - registerState: { - ...fullState.registerState, - state: { ...fullState.registerState.state, ...change }, + (change: Partial) => (fullState: State) => ({ + legacyRegisterState: { + ...fullState.legacyRegisterState, + state: { ...fullState.legacyRegisterState.state, ...change }, }, }), ); @@ -302,13 +305,13 @@ }, setState: setLogInState, }, - registerState: { + legacyRegisterState: { state: { usernameInputText: '', passwordInputText: '', confirmPasswordInputText: '', }, - setState: setRegisterState, + setState: setLegacyRegisterState, }, }; this.nextMode = initialMode; @@ -613,10 +616,10 @@ ); } else if (this.state.mode === 'register') { panel = ( - ); } else if (this.state.mode === 'prompt') { diff --git a/native/account/registration/registration-server-call.js b/native/account/registration/registration-server-call.js --- a/native/account/registration/registration-server-call.js +++ b/native/account/registration/registration-server-call.js @@ -5,8 +5,8 @@ import { setDataLoadedActionType } from 'lib/actions/client-db-store-actions.js'; import { setSyncedMetadataEntryActionType } from 'lib/actions/synced-metadata-actions.js'; import { - keyserverRegisterActionTypes, - keyserverRegister, + legacyKeyserverRegisterActionTypes, + legacyKeyserverRegister, useIdentityPasswordRegister, identityRegisterActionTypes, } from 'lib/actions/user-actions.js'; @@ -89,7 +89,9 @@ const logInExtraInfo = useSelector(nativeLogInExtraInfoSelector); const dispatchActionPromise = useDispatchActionPromise(); - const callKeyserverRegister = useLegacyAshoatKeyserverCall(keyserverRegister); + const callLegacyKeyserverRegister = useLegacyAshoatKeyserverCall( + legacyKeyserverRegister, + ); const callIdentityPasswordRegister = useIdentityPasswordRegister(); const identityRegisterUsernameAccount = React.useCallback( @@ -138,15 +140,15 @@ [callIdentityPasswordRegister, dispatchActionPromise], ); - const keyserverRegisterUsernameAccount = React.useCallback( + const legacyKeyserverRegisterUsernameAccount = React.useCallback( async ( accountSelection: UsernameAccountSelection, keyserverURL: string, ) => { const extraInfo = await logInExtraInfo(); - const keyserverRegisterPromise = (async () => { + const legacyKeyserverRegisterPromise = (async () => { try { - return await callKeyserverRegister( + return await callLegacyKeyserverRegister( { ...extraInfo, username: accountSelection.username, @@ -182,14 +184,14 @@ } })(); void dispatchActionPromise( - keyserverRegisterActionTypes, - keyserverRegisterPromise, + legacyKeyserverRegisterActionTypes, + legacyKeyserverRegisterPromise, undefined, ({ calendarQuery: extraInfo.calendarQuery }: LogInStartingPayload), ); - await keyserverRegisterPromise; + await legacyKeyserverRegisterPromise; }, - [logInExtraInfo, callKeyserverRegister, dispatchActionPromise], + [logInExtraInfo, callLegacyKeyserverRegister, dispatchActionPromise], ); const legacySiweServerCall = useLegacySIWEServerCall(); @@ -216,7 +218,7 @@ accountSelection.accountType === 'username' && !usingCommServicesAccessToken ) { - await keyserverRegisterUsernameAccount( + await legacyKeyserverRegisterUsernameAccount( accountSelection, keyserverURL, ); @@ -291,7 +293,7 @@ ), [ currentStep, - keyserverRegisterUsernameAccount, + legacyKeyserverRegisterUsernameAccount, identityRegisterUsernameAccount, legacySiweServerCall, dispatch,