feat: use testkey for user profile update in onboarding for testing a display name

remove privateKeyBytesHex since we don't use it
pull/3083/head
yougotwill 8 months ago
parent e69ffc6bbe
commit 66fa34b165

@ -153,6 +153,11 @@ export const SessionJoinableRooms = (props: {
return null;
}
// There is a spinner in the overlay, so we don't need to show it when joining
if (props.alreadyJoining) {
return null;
}
return (
<Flex
container={true}

@ -5,7 +5,7 @@ import { SettingsKey } from '../../../data/settings-key';
import { mnDecode } from '../../../session/crypto/mnemonic';
import { ProfileManager } from '../../../session/profile_manager/ProfileManager';
import { StringUtils } from '../../../session/utils';
import { fromHex, toHex } from '../../../session/utils/String';
import { fromHex } from '../../../session/utils/String';
import LIBSESSION_CONSTANTS from '../../../session/utils/libsession/libsession_constants';
import { trigger } from '../../../shims/events';
import {
@ -14,13 +14,11 @@ import {
setDisplayName,
setDisplayNameError,
setHexGeneratedPubKey,
setPrivateKeyBytesHex,
setRecoveryPassword,
} from '../../../state/onboarding/ducks/registration';
import {
useDisplayName,
useDisplayNameError,
useOnboardPrivateKeyBytesHex,
useRecoveryPassword,
} from '../../../state/onboarding/selectors/registration';
import {
@ -59,7 +57,6 @@ async function signUp(signUpDetails: AccountDetails) {
}
export const CreateAccount = () => {
const privateKeyBytesHex = useOnboardPrivateKeyBytesHex();
const recoveryPassword = useRecoveryPassword();
const displayName = useDisplayName();
const displayNameError = useDisplayNameError();
@ -82,7 +79,6 @@ export const CreateAccount = () => {
const newHexPubKey = StringUtils.decode(keyPair.pubKey, 'hex');
dispatch(setRecoveryPassword(mnemonic));
dispatch(setPrivateKeyBytesHex(toHex(keyPair.ed25519KeyPair.privateKey)));
dispatch(setHexGeneratedPubKey(newHexPubKey)); // our 'frontend' account ID
}
};
@ -97,10 +93,6 @@ export const CreateAccount = () => {
}
try {
if (!privateKeyBytesHex) {
throw new Error('Private key not found');
}
const validName = await ProfileManager.updateOurProfileDisplayName(displayName, true);
await signUp({

@ -6,6 +6,7 @@ import { getConversationController } from '../conversations';
import { SyncUtils, UserUtils } from '../utils';
import { fromHexToArray, sanitizeSessionUsername, toHex } from '../utils/String';
import { AvatarDownload } from '../utils/job_runners/jobs/AvatarDownloadJob';
import { generateFakeECKeyPair } from '../../test/test-utils/utils';
export type Profile = {
displayName: string | undefined;
@ -95,11 +96,13 @@ async function updateProfileOfContact(
}
}
export async function updateOurProfileDisplayName(newName: string, onboarding?: boolean) {
export async function updateOurProfileDisplayName(newName: string, onboarding?: true) {
const cleanName = sanitizeSessionUsername(newName).trim();
if (onboarding) {
try {
const tempKeyPair = generateFakeECKeyPair();
await UserConfigWrapperActions.init(tempKeyPair.privateKeyData, null);
const userInfoName = await UserConfigWrapperActions.setUserInfo(
cleanName,
CONVERSATION_PRIORITIES.default,

@ -41,7 +41,6 @@ export type OnboardingState = {
progress: number;
recoveryPassword: string;
recoveryPasswordError: string | undefined;
privateKeyBytesHex: string | undefined;
hexGeneratedPubKey: string;
displayName: string;
displayNameError: string | undefined;
@ -55,7 +54,6 @@ const initialState: OnboardingState = {
progress: 0,
recoveryPassword: '',
recoveryPasswordError: undefined,
privateKeyBytesHex: undefined,
hexGeneratedPubKey: '',
displayName: '',
displayNameError: undefined,
@ -92,9 +90,6 @@ export const registrationSlice = createSlice({
setHexGeneratedPubKey(state, action: PayloadAction<string>) {
return { ...state, hexGeneratedPubKey: action.payload };
},
setPrivateKeyBytesHex(state, action: PayloadAction<string>) {
return { ...state, privateKeyBytesHex: action.payload };
},
setDisplayName(state, action: PayloadAction<string>) {
return { ...state, displayName: action.payload };
},
@ -114,7 +109,6 @@ export const {
setRecoveryPassword,
setRecoveryPasswordError,
setHexGeneratedPubKey,
setPrivateKeyBytesHex,
setDisplayName,
setDisplayNameError,
} = registrationSlice.actions;

@ -54,11 +54,6 @@ const getHexGeneratedPubKey = createSelector(
(state: OnboardingState): string => state.hexGeneratedPubKey
);
const getPrivateKeyBytesHex = createSelector(
getRegistration,
(state: OnboardingState): string | undefined => state.privateKeyBytesHex
);
const getDisplayName = createSelector(
getRegistration,
(state: OnboardingState): string => state.displayName
@ -103,10 +98,6 @@ export const useOnboardHexGeneratedPubKey = () => {
return useSelector(getHexGeneratedPubKey);
};
export const useOnboardPrivateKeyBytesHex = () => {
return useSelector(getPrivateKeyBytesHex);
};
export const useDisplayName = () => {
return useSelector(getDisplayName);
};

Loading…
Cancel
Save