| 
									
										
										
										
											2016-06-23 22:22:03 +02:00
										 |  |  | import "typings-global"; | 
					
						
							|  |  |  | import * as plugins from "./npmci.plugins"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 02:54:55 +02:00
										 |  |  | let sshRegex = /^(.*)\|?(.*)\|?(.*)/ | 
					
						
							|  |  |  | let sshInstance:plugins.smartssh.SshInstance; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-23 22:22:03 +02:00
										 |  |  | export let ssh = () => { | 
					
						
							| 
									
										
										
										
											2016-06-24 02:54:55 +02:00
										 |  |  |     sshInstance = new plugins.smartssh.SshInstance(); | 
					
						
							| 
									
										
										
										
											2016-06-23 22:22:03 +02:00
										 |  |  |     plugins.smartparam.forEachMinimatch(process.env,"NPMCI_SSHKEY_*",evaluateSshkey); | 
					
						
							| 
									
										
										
										
											2016-06-25 02:55:36 +02:00
										 |  |  |     sshInstance.writeToDisk(); | 
					
						
							| 
									
										
										
										
											2016-06-23 22:22:03 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 02:54:55 +02:00
										 |  |  | export let evaluateSshkey = (sshkeyEnvVarArg) => { | 
					
						
							|  |  |  |     let resultArray = sshRegex.exec(sshkeyEnvVarArg); | 
					
						
							|  |  |  |     let sshKey = new plugins.smartssh.SshKey(); | 
					
						
							|  |  |  |      | 
					
						
							| 
									
										
										
										
											2016-06-25 03:19:29 +02:00
										 |  |  |     if(resultArray[1] && resultArray[1] != "undefined") sshKey.privKeyBase64 = resultArray[1]; | 
					
						
							| 
									
										
										
										
											2016-06-24 02:54:55 +02:00
										 |  |  |     let publicKey:string; | 
					
						
							| 
									
										
										
										
											2016-06-25 03:19:29 +02:00
										 |  |  |     if(resultArray[2] && resultArray[2] != "undefined") sshKey.pubKeyBase64 = resultArray[2]; | 
					
						
							| 
									
										
										
										
											2016-06-24 02:54:55 +02:00
										 |  |  |     let host:string; | 
					
						
							|  |  |  |     if(resultArray[3] && resultArray[3] != "undefined") sshKey.host = resultArray[1]; | 
					
						
							| 
									
										
										
										
											2016-06-23 22:22:03 +02:00
										 |  |  |      | 
					
						
							| 
									
										
										
										
											2016-06-24 02:54:55 +02:00
										 |  |  |     sshInstance.addKey(sshKey); | 
					
						
							| 
									
										
										
										
											2016-06-23 22:22:03 +02:00
										 |  |  | }; |