@ -3,7 +3,6 @@ import { useDispatch } from 'react-redux';
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				import  useMount  from  'react-use/lib/useMount' ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				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  }  from  '../../../session/utils/String' ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				import  LIBSESSION_CONSTANTS  from  '../../../session/utils/libsession/libsession_constants' ; 
 
			
		 
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
			
			 
			 
			
				@ -29,7 +28,6 @@ import {
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				  sessionGenerateKeyPair , 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				}  from  '../../../util/accountManager' ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				import  {  Storage ,  setSignWithRecoveryPhrase  }  from  '../../../util/storage' ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				import  {  UserConfigWrapperActions  }  from  '../../../webworker/workers/browser/libsession_worker_interface' ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				import  {  Flex  }  from  '../../basic/Flex' ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				import  {  SpacerLG ,  SpacerSM  }  from  '../../basic/Text' ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				import  {  SessionInput  }  from  '../../inputs' ; 
 
			
		 
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
			
			 
			 
			
				@ -101,32 +99,20 @@ export const CreateAccount = () => {
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      if  ( ! privateKeyBytes )  { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        throw  new  Error ( 'Private key not found' ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      // validate display name using libsession
 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      // eslint-disable-next-line max-len
 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      // TODO [libsession validation] if we try and use a different display name after entering one that is already too long we get an error because the user config has been initialised. I call .free() in the finally but that doesn't help
 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      await  UserConfigWrapperActions . init ( privateKeyBytes ,  null ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      const  validName  =  await  ProfileManager . updateOurProfileDisplayName ( displayName ,  true ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      await  signUp ( { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        displayName : validName  , 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        displayName , 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        recoveryPassword , 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      } ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      dispatch ( setAccountCreationStep ( AccountCreation . Done ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    }  catch  ( err )  { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      let  errorString  =  err . message  ||  String ( err ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      // Note error substring is taken from libsession-util
 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      if  ( err . message  &&  err . message . includes ( 'exceeds maximum length' ) )  { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        errorString  =  window . i18n ( 'displayNameTooLong' ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      const  errorString  =  err . message  ||  String ( err ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      window . log . error ( 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        ` [onboarding] create account: signUpWithDetails failed! Error:  ${ errorString } ` 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      dispatch ( setAccountCreationStep ( AccountCreation . DisplayName ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      dispatch ( setDisplayNameError ( errorString ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    }  finally  { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				      await  UserConfigWrapperActions . free ( ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				  } ;