{"ast":null,"code":"\"use strict\";\n\nvar _regenerator = require(\"D:/DSP_Management/node_modules/@babel/runtime/helpers/regenerator.js\")[\"default\"];\nvar _asyncToGenerator = require(\"D:/DSP_Management/node_modules/@babel/runtime/helpers/asyncToGenerator.js\")[\"default\"];\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\nexports.responseInterceptor = void 0;\nvar zlib = require(\"zlib\");\n/**\n * Intercept responses from upstream.\n * Automatically decompress (deflate, gzip, brotli).\n * Give developer the opportunity to modify intercepted Buffer and http.ServerResponse\n *\n * NOTE: must set options.selfHandleResponse=true (prevent automatic call of res.end())\n */\nfunction responseInterceptor(interceptor) {\n  return /*#__PURE__*/function () {\n    var _proxyRes2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(proxyRes, req, res) {\n      var originalProxyRes, buffer, _proxyRes;\n      return _regenerator().w(function (_context2) {\n        while (1) switch (_context2.n) {\n          case 0:\n            originalProxyRes = proxyRes;\n            buffer = Buffer.from('', 'utf8'); // decompress proxy response\n            _proxyRes = decompress(proxyRes, proxyRes.headers['content-encoding']); // concat data stream\n            _proxyRes.on('data', function (chunk) {\n              return buffer = Buffer.concat([buffer, chunk]);\n            });\n            _proxyRes.on('end', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {\n              var interceptedBuffer, _t;\n              return _regenerator().w(function (_context) {\n                while (1) switch (_context.n) {\n                  case 0:\n                    // copy original headers\n                    copyHeaders(proxyRes, res);\n                    // call interceptor with intercepted response (buffer)\n                    _t = Buffer;\n                    _context.n = 1;\n                    return interceptor(buffer, originalProxyRes, req, res);\n                  case 1:\n                    interceptedBuffer = _t.from.call(_t, _context.v);\n                    // set correct content-length (with double byte character support)\n                    res.setHeader('content-length', Buffer.byteLength(interceptedBuffer, 'utf8'));\n                    res.write(interceptedBuffer);\n                    res.end();\n                  case 2:\n                    return _context.a(2);\n                }\n              }, _callee);\n            })));\n            _proxyRes.on('error', function (error) {\n              res.end(\"Error fetching proxied request: \".concat(error.message));\n            });\n          case 1:\n            return _context2.a(2);\n        }\n      }, _callee2);\n    }));\n    function proxyRes(_x, _x2, _x3) {\n      return _proxyRes2.apply(this, arguments);\n    }\n    return proxyRes;\n  }();\n}\nexports.responseInterceptor = responseInterceptor;\n/**\n * Streaming decompression of proxy response\n * source: https://github.com/apache/superset/blob/9773aba522e957ed9423045ca153219638a85d2f/superset-frontend/webpack.proxy-config.js#L116\n */\nfunction decompress(proxyRes, contentEncoding) {\n  var _proxyRes = proxyRes;\n  var decompress;\n  switch (contentEncoding) {\n    case 'gzip':\n      decompress = zlib.createGunzip();\n      break;\n    case 'br':\n      decompress = zlib.createBrotliDecompress();\n      break;\n    case 'deflate':\n      decompress = zlib.createInflate();\n      break;\n    default:\n      break;\n  }\n  if (decompress) {\n    _proxyRes.pipe(decompress);\n    _proxyRes = decompress;\n  }\n  return _proxyRes;\n}\n/**\n * Copy original headers\n * https://github.com/apache/superset/blob/9773aba522e957ed9423045ca153219638a85d2f/superset-frontend/webpack.proxy-config.js#L78\n */\nfunction copyHeaders(originalResponse, response) {\n  response.statusCode = originalResponse.statusCode;\n  response.statusMessage = originalResponse.statusMessage;\n  if (response.setHeader) {\n    var keys = Object.keys(originalResponse.headers);\n    // ignore chunked, brotli, gzip, deflate headers\n    keys = keys.filter(function (key) {\n      return !['content-encoding', 'transfer-encoding'].includes(key);\n    });\n    keys.forEach(function (key) {\n      var value = originalResponse.headers[key];\n      if (key === 'set-cookie') {\n        // remove cookie domain\n        value = Array.isArray(value) ? value : [value];\n        value = value.map(function (x) {\n          return x.replace(/Domain=[^;]+?/i, '');\n        });\n      }\n      response.setHeader(key, value);\n    });\n  } else {\n    response.headers = originalResponse.headers;\n  }\n}","map":{"version":3,"names":["_regenerator","require","_asyncToGenerator","Object","defineProperty","exports","value","responseInterceptor","zlib","interceptor","_proxyRes2","m","_callee2","proxyRes","req","res","originalProxyRes","buffer","_proxyRes","w","_context2","n","Buffer","from","decompress","headers","on","chunk","concat","_callee","interceptedBuffer","_t","_context","copyHeaders","call","v","setHeader","byteLength","write","end","a","error","message","_x","_x2","_x3","apply","arguments","contentEncoding","createGunzip","createBrotliDecompress","createInflate","pipe","originalResponse","response","statusCode","statusMessage","keys","filter","key","includes","forEach","Array","isArray","map","x","replace"],"sources":["D:/DSP_Management/node_modules/http-proxy-middleware/dist/handlers/response-interceptor.js"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.responseInterceptor = void 0;\nconst zlib = require(\"zlib\");\n/**\n * Intercept responses from upstream.\n * Automatically decompress (deflate, gzip, brotli).\n * Give developer the opportunity to modify intercepted Buffer and http.ServerResponse\n *\n * NOTE: must set options.selfHandleResponse=true (prevent automatic call of res.end())\n */\nfunction responseInterceptor(interceptor) {\n    return async function proxyRes(proxyRes, req, res) {\n        const originalProxyRes = proxyRes;\n        let buffer = Buffer.from('', 'utf8');\n        // decompress proxy response\n        const _proxyRes = decompress(proxyRes, proxyRes.headers['content-encoding']);\n        // concat data stream\n        _proxyRes.on('data', (chunk) => (buffer = Buffer.concat([buffer, chunk])));\n        _proxyRes.on('end', async () => {\n            // copy original headers\n            copyHeaders(proxyRes, res);\n            // call interceptor with intercepted response (buffer)\n            const interceptedBuffer = Buffer.from(await interceptor(buffer, originalProxyRes, req, res));\n            // set correct content-length (with double byte character support)\n            res.setHeader('content-length', Buffer.byteLength(interceptedBuffer, 'utf8'));\n            res.write(interceptedBuffer);\n            res.end();\n        });\n        _proxyRes.on('error', (error) => {\n            res.end(`Error fetching proxied request: ${error.message}`);\n        });\n    };\n}\nexports.responseInterceptor = responseInterceptor;\n/**\n * Streaming decompression of proxy response\n * source: https://github.com/apache/superset/blob/9773aba522e957ed9423045ca153219638a85d2f/superset-frontend/webpack.proxy-config.js#L116\n */\nfunction decompress(proxyRes, contentEncoding) {\n    let _proxyRes = proxyRes;\n    let decompress;\n    switch (contentEncoding) {\n        case 'gzip':\n            decompress = zlib.createGunzip();\n            break;\n        case 'br':\n            decompress = zlib.createBrotliDecompress();\n            break;\n        case 'deflate':\n            decompress = zlib.createInflate();\n            break;\n        default:\n            break;\n    }\n    if (decompress) {\n        _proxyRes.pipe(decompress);\n        _proxyRes = decompress;\n    }\n    return _proxyRes;\n}\n/**\n * Copy original headers\n * https://github.com/apache/superset/blob/9773aba522e957ed9423045ca153219638a85d2f/superset-frontend/webpack.proxy-config.js#L78\n */\nfunction copyHeaders(originalResponse, response) {\n    response.statusCode = originalResponse.statusCode;\n    response.statusMessage = originalResponse.statusMessage;\n    if (response.setHeader) {\n        let keys = Object.keys(originalResponse.headers);\n        // ignore chunked, brotli, gzip, deflate headers\n        keys = keys.filter((key) => !['content-encoding', 'transfer-encoding'].includes(key));\n        keys.forEach((key) => {\n            let value = originalResponse.headers[key];\n            if (key === 'set-cookie') {\n                // remove cookie domain\n                value = Array.isArray(value) ? value : [value];\n                value = value.map((x) => x.replace(/Domain=[^;]+?/i, ''));\n            }\n            response.setHeader(key, value);\n        });\n    }\n    else {\n        response.headers = originalResponse.headers;\n    }\n}\n"],"mappings":"AAAA,YAAY;;AAAC,IAAAA,YAAA,GAAAC,OAAA;AAAA,IAAAC,iBAAA,GAAAD,OAAA;AACbE,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,mBAAmB,GAAG,KAAK,CAAC;AACpC,IAAMC,IAAI,GAAGP,OAAO,CAAC,MAAM,CAAC;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASM,mBAAmBA,CAACE,WAAW,EAAE;EACtC;IAAA,IAAAC,UAAA,GAAAR,iBAAA,cAAAF,YAAA,GAAAW,CAAA,CAAO,SAAAC,SAAwBC,QAAQ,EAAEC,GAAG,EAAEC,GAAG;MAAA,IAAAC,gBAAA,EAAAC,MAAA,EAAAC,SAAA;MAAA,OAAAlB,YAAA,GAAAmB,CAAA,WAAAC,SAAA;QAAA,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