1 line
3.0 KiB
Plaintext
1 line
3.0 KiB
Plaintext
{"version":3,"sources":["../../src/classes/HttpsProxyAgent.js"],"names":["HttpsProxyAgent","Agent","constructor","args","protocol","defaultPort","createConnection","configuration","callback","socket","net","connect","proxy","port","hostname","on","error","once","secureSocket","tls","rejectUnauthorized","servername","host","connectMessage","authorization","Buffer","from","toString","write"],"mappings":";;;;;;;AAEA;;AACA;;AAKA;;;;AAEA,MAAMA,eAAN,SAA8BC,cAA9B,CAAoC;AAClC;AACAC,EAAAA,WAAW,CAAE,GAAGC,IAAL,EAAc;AACvB,UAAM,GAAGA,IAAT;AAEA,SAAKC,QAAL,GAAgB,QAAhB;AACA,SAAKC,WAAL,GAAmB,GAAnB;AACD;;AAEDC,EAAAA,gBAAgB,CAAEC,aAAF,EAA8CC,QAA9C,EAAgF;AAC9F,UAAMC,MAAM,GAAGC,aAAIC,OAAJ,CACbJ,aAAa,CAACK,KAAd,CAAoBC,IADP,EAEbN,aAAa,CAACK,KAAd,CAAoBE,QAFP,CAAf;;AAKAL,IAAAA,MAAM,CAACM,EAAP,CAAU,OAAV,EAAoBC,KAAD,IAAW;AAC5BR,MAAAA,QAAQ,CAACQ,KAAD,CAAR;AACD,KAFD;AAIAP,IAAAA,MAAM,CAACQ,IAAP,CAAY,MAAZ,EAAoB,MAAM;AACxB,YAAMC,YAAY,GAAGC,aAAIR,OAAJ,CAAY;AAC/BS,QAAAA,kBAAkB,EAAE,KADW;AAE/BC,QAAAA,UAAU,EAAEd,aAAa,CAACe,IAFK;AAG/Bb,QAAAA;AAH+B,OAAZ,CAArB;;AAMAD,MAAAA,QAAQ,CAAC,IAAD,EAAOU,YAAP,CAAR;AACD,KARD;AAUA,QAAIK,cAAc,GAAG,EAArB;AAEAA,IAAAA,cAAc,IAAI,aAAahB,aAAa,CAACe,IAA3B,GAAkC,GAAlC,GAAwCf,aAAa,CAACM,IAAtD,GAA6D,eAA/E;AACAU,IAAAA,cAAc,IAAI,WAAWhB,aAAa,CAACe,IAAzB,GAAgC,GAAhC,GAAsCf,aAAa,CAACM,IAApD,GAA2D,MAA7E;;AAEA,QAAIN,aAAa,CAACK,KAAd,CAAoBY,aAAxB,EAAuC;AACrCD,MAAAA,cAAc,IAAI,gCAAgCE,MAAM,CAACC,IAAP,CAAYnB,aAAa,CAACK,KAAd,CAAoBY,aAAhC,EAA+CG,QAA/C,CAAwD,QAAxD,CAAhC,GAAoG,MAAtH;AACD;;AAEDJ,IAAAA,cAAc,IAAI,MAAlB;AAEAd,IAAAA,MAAM,CAACmB,KAAP,CAAaL,cAAb;AACD;;AAzCiC;;eA4CrBvB,e","sourcesContent":["// @flow\n\nimport net from 'net';\nimport tls from 'tls';\nimport type {\n ConnectionCallbackType,\n ConnectionConfigurationType,\n} from '../types';\nimport Agent from './Agent';\n\nclass HttpsProxyAgent extends Agent {\n // eslint-disable-next-line unicorn/prevent-abbreviations\n constructor (...args: *) {\n super(...args);\n\n this.protocol = 'https:';\n this.defaultPort = 443;\n }\n\n createConnection (configuration: ConnectionConfigurationType, callback: ConnectionCallbackType) {\n const socket = net.connect(\n configuration.proxy.port,\n configuration.proxy.hostname,\n );\n\n socket.on('error', (error) => {\n callback(error);\n });\n\n socket.once('data', () => {\n const secureSocket = tls.connect({\n rejectUnauthorized: false,\n servername: configuration.host,\n socket,\n });\n\n callback(null, secureSocket);\n });\n\n let connectMessage = '';\n\n connectMessage += 'CONNECT ' + configuration.host + ':' + configuration.port + ' HTTP/1.1\\r\\n';\n connectMessage += 'Host: ' + configuration.host + ':' + configuration.port + '\\r\\n';\n\n if (configuration.proxy.authorization) {\n connectMessage += 'Proxy-Authorization: Basic ' + Buffer.from(configuration.proxy.authorization).toString('base64') + '\\r\\n';\n }\n\n connectMessage += '\\r\\n';\n\n socket.write(connectMessage);\n }\n}\n\nexport default HttpsProxyAgent;\n"],"file":"HttpsProxyAgent.js"} |