| 
						
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -1,5 +1,5 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import ByteBuffer from 'bytebuffer';
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import { MAX_USERNAME_BYTES } from '../constants';
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import { MAX_NAME_LENGTH } from '../constants';
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				export type Encoding = 'base64' | 'hex' | 'binary' | 'utf8';
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				export type BufferType = ByteBuffer | Buffer | ArrayBuffer | Uint8Array;
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -57,7 +57,7 @@ const forbiddenDisplayCharRegex = /\uFFD2*/g;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				 * This does not trim it as otherwise, a user cannot type User A as when he hits the space, it gets trimmed right away.
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				 * The trimming should hence happen after calling this and on saving the display name.
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				 *
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				 * This functions makes sure that the MAX_USERNAME_BYTES is verified for utf8 byte length
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				 * This functions makes sure that the MAX_NAME_LENGTH is verified for utf8 byte length. MAX_NAME_LENGTH is the agreed character limit between platforms for libsession
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				 * @param inputName the input to sanitize
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				 * @returns a sanitized string, untrimmed
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				 */
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -65,7 +65,7 @@ export const sanitizeSessionUsername = (inputName: string) => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  const validChars = inputName.replace(forbiddenDisplayCharRegex, '');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  const lengthBytes = encode(validChars, 'utf8').byteLength;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  if (lengthBytes > MAX_USERNAME_BYTES) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  if (lengthBytes > MAX_NAME_LENGTH) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    throw new Error('Display name is too long');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
			
			 | 
			 | 
			
				
 
 |