 butlerx
					
					6 years ago
						butlerx
					
					6 years ago
					
				 
				
			 
		 
		
			
				
					
					No known key found for this signature in database
					
						
							GPG Key ID: B37CA765BAA89170
						
					
				
			
		
		
		
	
		
			
				 5 changed files with 
23 additions and 
9 deletions
			 
			
		 
		
			
				- 
					
					
					 
					.eslintrc.js
				
- 
					
					
					 
					.github/workflows/publish.yml
				
- 
					
					
					 
					package.json
				
- 
					
					
					 
					src/client/download.ts
				
- 
					
					
					 
					src/client/index.ts
				
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -21,6 +21,11 @@ module.exports = { | 
			
		
	
		
			
				
					|  |  |  |     'no-use-before-define': ['error', { functions: false }], | 
			
		
	
		
			
				
					|  |  |  |     '@typescript-eslint/no-use-before-define': ['error', { functions: false }], | 
			
		
	
		
			
				
					|  |  |  |     'import/prefer-default-export': 'off', | 
			
		
	
		
			
				
					|  |  |  |     'lines-between-class-members': [ | 
			
		
	
		
			
				
					|  |  |  |       'error', | 
			
		
	
		
			
				
					|  |  |  |       'always', | 
			
		
	
		
			
				
					|  |  |  |       { exceptAfterSingleLine: true }, | 
			
		
	
		
			
				
					|  |  |  |     ], | 
			
		
	
		
			
				
					|  |  |  |     'import/extensions': [ | 
			
		
	
		
			
				
					|  |  |  |       'error', | 
			
		
	
		
			
				
					|  |  |  |       'always', | 
			
		
	
	
		
			
				
					|  |  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -21,6 +21,8 @@ jobs: | 
			
		
	
		
			
				
					|  |  |  |         run: yarn lint | 
			
		
	
		
			
				
					|  |  |  |       - run: yarn build | 
			
		
	
		
			
				
					|  |  |  |         name: Compile Typescript | 
			
		
	
		
			
				
					|  |  |  |       - run: yarn test | 
			
		
	
		
			
				
					|  |  |  |         name: Run tests | 
			
		
	
		
			
				
					|  |  |  |       - name: Publish | 
			
		
	
		
			
				
					|  |  |  |         uses: mikeal/merge-release@master | 
			
		
	
		
			
				
					|  |  |  |         env: | 
			
		
	
	
		
			
				
					|  |  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -1,6 +1,6 @@ | 
			
		
	
		
			
				
					|  |  |  | { | 
			
		
	
		
			
				
					|  |  |  |   "name": "wetty", | 
			
		
	
		
			
				
					|  |  |  |   "version": "1.2.2", | 
			
		
	
		
			
				
					|  |  |  |   "version": "1.2.3", | 
			
		
	
		
			
				
					|  |  |  |   "description": "WeTTY = Web + TTY. Terminal access in browser over http/https", | 
			
		
	
		
			
				
					|  |  |  |   "homepage": "https://github.com/butlerx/wetty", | 
			
		
	
		
			
				
					|  |  |  |   "repository": { | 
			
		
	
	
		
			
				
					|  |  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -2,8 +2,14 @@ const DEFAULT_FILE_BEGIN = '\u001b[5i'; | 
			
		
	
		
			
				
					|  |  |  | const DEFAULT_FILE_END = '\u001b[4i'; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | export class FileDownloader { | 
			
		
	
		
			
				
					|  |  |  |   fileBuffer: string[]; | 
			
		
	
		
			
				
					|  |  |  |   fileBegin: string; | 
			
		
	
		
			
				
					|  |  |  |   fileEnd: string; | 
			
		
	
		
			
				
					|  |  |  |   partialFileBegin: string; | 
			
		
	
		
			
				
					|  |  |  |   onCompleteFileCallback: Function; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |   constructor( | 
			
		
	
		
			
				
					|  |  |  |     onCompleteFileCallback: (file: string) => any, | 
			
		
	
		
			
				
					|  |  |  |     onCompleteFileCallback: (file: string) => void, | 
			
		
	
		
			
				
					|  |  |  |     fileBegin: string = DEFAULT_FILE_BEGIN, | 
			
		
	
		
			
				
					|  |  |  |     fileEnd: string = DEFAULT_FILE_END | 
			
		
	
		
			
				
					|  |  |  |   ) { | 
			
		
	
	
		
			
				
					|  |  | @ -87,10 +93,13 @@ export class FileDownloader { | 
			
		
	
		
			
				
					|  |  |  |     ) { | 
			
		
	
		
			
				
					|  |  |  |       return data; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |     return data.split('').map(this.bufferCharacter.bind(this)).join('') | 
			
		
	
		
			
				
					|  |  |  |     return data | 
			
		
	
		
			
				
					|  |  |  |       .split('') | 
			
		
	
		
			
				
					|  |  |  |       .map(this.bufferCharacter.bind(this)) | 
			
		
	
		
			
				
					|  |  |  |       .join(''); | 
			
		
	
		
			
				
					|  |  |  |   } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |   onCompleteFile(bufferCharacters: string) { | 
			
		
	
		
			
				
					|  |  |  |   onCompleteFile(bufferCharacters: string): void { | 
			
		
	
		
			
				
					|  |  |  |     this.onCompleteFileCallback(bufferCharacters); | 
			
		
	
		
			
				
					|  |  |  |   } | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
	
		
			
				
					|  |  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -1,8 +1,8 @@ | 
			
		
	
		
			
				
					|  |  |  | import { Terminal } from 'xterm'; | 
			
		
	
		
			
				
					|  |  |  | import { isNull } from 'lodash'; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import { dom, library } from "@fortawesome/fontawesome-svg-core"; | 
			
		
	
		
			
				
					|  |  |  | import { faCogs } from "@fortawesome/free-solid-svg-icons/faCogs"; | 
			
		
	
		
			
				
					|  |  |  | import { dom, library } from '@fortawesome/fontawesome-svg-core'; | 
			
		
	
		
			
				
					|  |  |  | import { faCogs } from '@fortawesome/free-solid-svg-icons/faCogs'; | 
			
		
	
		
			
				
					|  |  |  | import Toastify from 'toastify-js'; | 
			
		
	
		
			
				
					|  |  |  | import * as fileType from 'file-type'; | 
			
		
	
		
			
				
					|  |  |  | import { socket } from './socket'; | 
			
		
	
	
		
			
				
					|  |  | @ -78,9 +78,7 @@ socket.on('connect', () => { | 
			
		
	
		
			
				
					|  |  |  |   term.focus(); | 
			
		
	
		
			
				
					|  |  |  |   mobileKeyboard(); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |   const fileDownloader = new FileDownloader(function ( | 
			
		
	
		
			
				
					|  |  |  |     bufferCharacters: string | 
			
		
	
		
			
				
					|  |  |  |   ) { | 
			
		
	
		
			
				
					|  |  |  |   const fileDownloader = new FileDownloader((bufferCharacters: string) => { | 
			
		
	
		
			
				
					|  |  |  |     let fileCharacters = bufferCharacters; | 
			
		
	
		
			
				
					|  |  |  |     // Try to decode it as base64, if it fails we assume it's not base64
 | 
			
		
	
		
			
				
					|  |  |  |     try { | 
			
		
	
	
		
			
				
					|  |  | 
 |