1- // must be set before we import 'global-agent/bootstrap'
2- process . env . GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE = '' ;
3- process . env . HTTPS_PROXY =
4- process . env . HTTPS_PROXY ?? process . env . https_proxy ?? '' ;
5- process . env . HTTP_PROXY = process . env . HTTP_PROXY ?? process . env . http_proxy ?? '' ;
6- process . env . NO_PROXY = process . env . NO_PROXY ?? process . env . no_proxy ?? '' ;
7-
8- import 'global-agent/bootstrap' ;
91import * as path from 'path' ;
102import * as os from 'os' ;
113import * as fs from 'fs' ;
124import { spawnSync } from 'child_process' ;
135import * as https from 'https' ;
146import { createHash } from 'crypto' ;
157import * as Sentry from '@sentry/node' ;
8+ import { ProxyAgent } from 'proxy-agent' ;
169
1710export const versionFile = path . join ( __dirname , 'generated' , 'version' ) ;
1811export const shasumFile = path . join ( __dirname , 'generated' , 'sha256sums.txt' ) ;
@@ -24,9 +17,9 @@ const binaryDeploymentsFilePath = path.join(
2417export const integrationName = 'TS_BINARY_WRAPPER' ;
2518
2619export class WrapperConfiguration {
27- private version : string ;
28- private binaryName : string ;
29- private expectedSha256sum : string ;
20+ private readonly version : string ;
21+ private readonly binaryName : string ;
22+ private readonly expectedSha256sum : string ;
3023
3124 public constructor (
3225 version : string ,
@@ -257,7 +250,6 @@ export function downloadExecutable(
257250) : Promise < Error | undefined > {
258251 return new Promise < Error | undefined > ( function ( resolve ) {
259252 logErrorWithTimeStamps ( 'Starting download' ) ;
260- const options = new URL ( `${ downloadUrl } ?utm_source=${ integrationName } ` ) ;
261253 const temp = path . join ( __dirname , Date . now ( ) . toString ( ) ) ;
262254 const fileStream = fs . createWriteStream ( temp ) ;
263255 const shasum = createHash ( 'sha256' ) . setEncoding ( 'hex' ) ;
@@ -291,17 +283,20 @@ export function downloadExecutable(
291283 // finally rename the file and change permissions
292284 fs . renameSync ( temp , filename ) ;
293285 fs . chmodSync ( filename , 0o755 ) ;
294- logErrorWithTimeStamps ( 'Downloaded successfull ! ' ) ;
286+ logErrorWithTimeStamps ( 'Downloaded successful ! ' ) ;
295287 }
296288
297289 resolve ( undefined ) ;
298290 } ) ;
299291
292+ const url = new URL ( `${ downloadUrl } ?utm_source=${ integrationName } ` ) ;
293+
300294 logErrorWithTimeStamps (
301- "Downloading from '" + options . toString ( ) + "' to '" + filename + "'" ,
295+ "Downloading from '" + url . toString ( ) + "' to '" + filename + "'" ,
302296 ) ;
303297
304- const req = https . get ( options , ( res ) => {
298+ const agent = new ProxyAgent ( ) ;
299+ const req = https . get ( url , { agent } , ( res ) => {
305300 // response events
306301 res . on ( 'error' , cleanupAfterError ) . on ( 'end' , ( ) => {
307302 shasum . end ( ) ;
0 commit comments