Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sitecore-jss/sitecore-jss-proxy

Package Overview
Dependencies
Maintainers
4
Versions
1399
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sitecore-jss/sitecore-jss-proxy - npm Package Compare versions

Comparing version 5.0.2 to 6.0.0

test/config.js

2

dist/index.js

@@ -1,1 +0,1 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:!0}),exports.rewriteRequestPath=exports.removeEmptyAnalyticsCookie=void 0;var _httpProxyMiddleware=require('http-proxy-middleware'),_httpProxyMiddleware2=_interopRequireDefault(_httpProxyMiddleware),_setCookieParser=require('set-cookie-parser'),_setCookieParser2=_interopRequireDefault(_setCookieParser),_zlib=require('zlib'),_zlib2=_interopRequireDefault(_zlib),_util=require('./util');function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var removeEmptyAnalyticsCookie=exports.removeEmptyAnalyticsCookie=function(a){var b=_setCookieParser2.default.parse(a.headers['set-cookie']);if(b){var c=b.findIndex(function(a){return'SC_ANALYTICS_GLOBAL_COOKIE'===a.name});if(-1!==c){var d=b[c];d&&''===d.value&&(b.splice(c,1),a.headers['set-cookie']=b)}}},renderAppToResponse=function(a,b,c,d,e){var f=c.write,g=c.end;delete a.headers['content-length'],a.headers['content-type']='text/html; charset=utf-8';var h=a.headers['content-encoding'];h&&(-1!==h.indexOf('gzip')||-1!==h.indexOf('deflate'))&&delete a.headers['content-encoding'];var i=new Buffer('');c.write=function(a,b){if(i=Buffer.isBuffer(a)?Buffer.concat([i,a]):Buffer.concat([i,new Buffer(a,b)]),10485760<i.length)throw new Error('Document too large')},c.end=function(){var j;if(h&&(-1!==h.indexOf('gzip')||-1!==h.indexOf('deflate'))){var l=_zlib2.default.unzipSync(i);l&&(j=l.toString('utf-8'))}else j=i.toString('utf-8');var k=(0,_util.tryParseJson)(j)||null;d(function handleResult(b,d){var h=new Buffer(d.html);a.headers['content-length']=h.length,e.debug&&console.log('FINAL response headers for output',JSON.stringify(a.headers,!0,2)),f.call(c,h),g.call(c)},b.originalUrl,k,{})}},handleProxyResponse=function(a,b,c,d,e){removeEmptyAnalyticsCookie(a),e.debug&&(console.log('request url',b.url),console.log('request query',b.query),console.log('request original url',b.originalUrl),console.log('RAW request headers',JSON.stringify(b.headers,!0,2)),console.log('RAW response headers from the target',JSON.stringify(a.headers,!0,2)));e.pathRewriteExcludeRoutes.find(function(a){return-1!==b.originalUrl.indexOf(a)})||renderAppToResponse(a,b,c,d,e)},rewriteRequestPath=exports.rewriteRequestPath=function(a,b,c,d){if(c.pathRewriteExcludeRoutes.find(function(b){return-1!==a.indexOf(b)}))return a;if(-1!==a.indexOf(c.layoutServiceRoute))return a;var e,f=a.indexOf('?');-1<f&&(e=(0,_util.buildQueryString)(b.query),a=a.slice(0,f));var g;if(d){var i=d(a);i&&(a=i.sitecoreRoute?i.sitecoreRoute:'/',!a.startsWith('/')&&(a='/'+a),g=i.lang)}var h=c.layoutServiceRoute+'?item='+encodeURIComponent(a);return g&&(h=h+'&sc_lang='+g),e&&(h=h+'&'+e),h},createOptions=function(a,b,c){return{target:b.apiHost,changeOrigin:!0,ws:!0,pathRewrite:function pathRewrite(a,d){return rewriteRequestPath(a,d,b,c)},logLevel:'debug',onProxyRes:function onProxyRes(c,d,e){return handleProxyResponse(c,d,e,a,b)}}};exports.default=function(a,b,c){var d=createOptions(a,b,c);return(0,_httpProxyMiddleware2.default)(d)};
'use strict';var _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_httpProxyMiddleware=require('http-proxy-middleware'),_httpProxyMiddleware2=_interopRequireDefault(_httpProxyMiddleware),_setCookieParser=require('set-cookie-parser'),_setCookieParser2=_interopRequireDefault(_setCookieParser),_zlib=require('zlib'),_zlib2=_interopRequireDefault(_zlib),_util=require('./util');Object.defineProperty(exports,'__esModule',{value:!0}),exports.rewriteRequestPath=exports.removeEmptyAnalyticsCookie=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var removeEmptyAnalyticsCookie=exports.removeEmptyAnalyticsCookie=function(a){var b=_setCookieParser2.default.parse(a.headers['set-cookie']);if(b){var c=b.findIndex(function(a){return'SC_ANALYTICS_GLOBAL_COOKIE'===a.name});if(-1!==c){var d=b[c];d&&''===d.value&&(b.splice(c,1),a.headers['set-cookie']=b)}}},renderAppToResponse=function(a,b,c,d,e){var f=c.writeHead,g=c.write,h=c.end;delete a.headers['content-length'],a.headers['content-type']='text/html; charset=utf-8';var i=a.headers['content-encoding'];i&&(-1!==i.indexOf('gzip')||-1!==i.indexOf('deflate'))&&delete a.headers['content-encoding'],c.writeHead=function(){};var j=new Buffer('');c.write=function(a,b){if(j=Buffer.isBuffer(a)?Buffer.concat([j,a]):Buffer.concat([j,new Buffer(a,b)]),10485760<j.length)throw new Error('Document too large')},c.end=function(){var k;if(i&&(-1!==i.indexOf('gzip')||-1!==i.indexOf('deflate'))){var n=_zlib2.default.unzipSync(j);n&&(k=n.toString('utf-8'))}else k=j.toString('utf-8');var l=(0,_util.tryParseJson)(k)||null,m=function(b,d){var i=new Buffer(d.html);a.headers['content-length']=i.length,e.debug&&console.log('FINAL response headers for output',JSON.stringify(a.headers,!0,2)),f.apply(c,[a.statusCode,a.headers]),g.call(c,i),h.call(c)};try{d(m,b.originalUrl,l,{})}catch(a){console.error(a);var o={statusCode:500,content:'Internal Server Error'};e.onError&&(o=e.onError(a)),f.apply(c,[o.statusCode,{}]),g.call(c,new Buffer(o.content)),h.call(c)}}},handleProxyResponse=function(a,b,c,d,e){removeEmptyAnalyticsCookie(a),e.debug&&(console.log('request url',b.url),console.log('request query',b.query),console.log('request original url',b.originalUrl),console.log('RAW request headers',JSON.stringify(b.headers,!0,2)),console.log('RAW response headers from the target',JSON.stringify(a.headers,!0,2)));e.pathRewriteExcludeRoutes.find(function(a){return-1!==b.originalUrl.indexOf(a)})||renderAppToResponse(a,b,c,d,e)},rewriteRequestPath=exports.rewriteRequestPath=function(a,b,c,d){if(c.pathRewriteExcludeRoutes.find(function(b){return-1!==a.indexOf(b)}))return a;if(-1!==a.indexOf(c.layoutServiceRoute))return a;var e,f=a.indexOf('?');-1<f&&(e=(0,_util.buildQueryString)(b.query),a=a.slice(0,f));var g;if(d){var i=d(a);i&&(a=i.sitecoreRoute?i.sitecoreRoute:'/',!a.startsWith('/')&&(a='/'+a),g=i.lang)}var h=c.layoutServiceRoute+'?item='+encodeURIComponent(a)+'&sc_apikey='+c.apiKey;return g&&(h=h+'&sc_lang='+g),e&&(h=h+'&'+e),h},createOptions=function(a,b,c){return _extends({target:b.apiHost,changeOrigin:!0,ws:!0,pathRewrite:function pathRewrite(a,d){return rewriteRequestPath(a,d,b,c)},logLevel:b.debug?'debug':'info',onProxyRes:function onProxyRes(c,d,e){return handleProxyResponse(c,d,e,a,b)}},b.proxyOptions)};exports.default=function(a,b,c){var d=createOptions(a,b,c);return(0,_httpProxyMiddleware2.default)(d)};
{
"name": "@sitecore-jss/sitecore-jss-proxy",
"version": "5.0.2",
"version": "6.0.0",
"description": "Proxy middleware for express.js server.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc