You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-mitmproxy/addon/web/client/build/static/js/main.7030457c.chunk.js

2 lines
8.7 KiB
JavaScript

(this.webpackJsonpclient=this.webpackJsonpclient||[]).push([[0],{23:function(e,t,n){},28:function(e,t,n){"use strict";n.r(t);var s=n(0),i=n.n(s),r=n(14),c=n.n(r),l=(n(22),n(7)),o=n(8),a=n(17),d=n(16),h=n(15),u=n(12),j=n(6),f=(n(23),function(){function e(){Object(l.a)(this,e),this.items=[],this._map=new Map,this.filterText="",this.filterTimer=null,this.num=0,this.max=1e3}return Object(o.a)(e,[{key:"showList",value:function(){var e=this;return this.filterText?this.items.filter((function(t){return t.request.url.includes(e.filterText)})):this.items}},{key:"add",value:function(e){if(e.no=++this.num,this.items.push(e),this._map.set(e.id,e),this.items.length>this.max){var t=this.items.shift();this._map.delete(t.id)}}},{key:"get",value:function(e){return this._map.get(e)}},{key:"changeFilter",value:function(e){this.filterText=e}},{key:"changeFilterLazy",value:function(e,t){var n=this;this.filterTimer&&(clearTimeout(this.filterTimer),this.filterTimer=null),this.filterTimer=setTimeout((function(){n.filterText=e,t()}),300)}},{key:"clear",value:function(){this.items=[],this._map=new Map}}]),e}()),b=function(e){return!!e&&(!!e.header&&(!!e.header["Content-Type"]&&/text|javascript|json/.test(e.header["Content-Type"].join(""))))},p=function(e){return e&&e.header?(e.header["Content-Length"]?t=parseInt(e.header["Content-Length"][0]):e&&e.body&&(t=e.body.byteLength),t?isNaN(t)||t<=0?"0":t<1024?"".concat(t," B"):t<1048576?"".concat((t/1024).toFixed(2)," KB"):"".concat((t/1048576).toFixed(2)," MB"):"0"):"0";var t},w={request:1,requestBody:2,response:3,responseBody:4},x=Object.keys(w).map((function(e){return w[e]})),O=Object.keys(w).reduce((function(e,t){return e[w[t]]=t,e}),{}),v=function(e,t,n){n=(new TextEncoder).encode(n);var s=new Uint8Array(39+n.byteLength);return s[0]=1,s[1]=e,s[2]=0,s.set((new TextEncoder).encode(t),3),s.set(n,39),s},m=n(1),y=function(e){Object(a.a)(n,e);var t=Object(d.a)(n);function n(e){var s;return Object(l.a)(this,n),(s=t.call(this,e)).flowMgr=new f,s.state={flows:s.flowMgr.showList(),flow:null,flowTab:"Headers",interceptUriInputing:"",interceptUri:""},s.ws=null,s}return Object(o.a)(n,[{key:"componentDidMount",value:function(){this.initWs()}},{key:"componentWillUnmount",value:function(){this.ws&&this.ws.close()}},{key:"initWs",value:function(){var e,t=this;this.ws||(e=new URL(document.URL).host,this.ws=new WebSocket("ws://".concat(e,"/echo")),this.ws.binaryType="arraybuffer",this.ws.onopen=function(){console.log("OPEN")},this.ws.onclose=function(){console.log("CLOSE")},this.ws.onmessage=function(e){var n=function(e){if(e.byteLength<39)return null;var t=new Int8Array(e.slice(0,3));if(1!==t[0])return null;var n=t[1];if(!x.includes(n))return null;var s=(new TextDecoder).decode(e.slice(3,39)),i={type:O[n],id:s,waitIntercept:1===t[2]};if(39===e.byteLength)return i;if(n===w.requestBody||n===w.responseBody)return i.content=e.slice(39),i;var r=(new TextDecoder).decode(e.slice(39));try{r=JSON.parse(r)}catch(c){return null}return i.content=r,i}(e.data);if(n){if("request"===n.type){var s={id:n.id,request:n.content,waitIntercept:n.waitIntercept};t.flowMgr.add(s),t.setState({flows:t.flowMgr.showList()})}else if("requestBody"===n.type){var i=t.flowMgr.get(n.id);if(!i)return;i.request.body=n.content,t.setState({flows:t.state.flows})}else if("response"===n.type){var r=t.flowMgr.get(n.id);if(!r)return;r.waitIntercept=n.waitIntercept,r.response=n.content,t.setState({flows:t.state.flows})}else if("responseBody"===n.type){var c=t.flowMgr.get(n.id);if(!c||!c.response)return;c.waitIntercept=n.waitIntercept,c.response.body=n.content,t.setState({flows:t.state.flows})}}else console.error("parse error:",e.data)},this.ws.onerror=function(e){console.log("ERROR:",e)})}},{key:"renderFlow",value:function(){var e=this,t=this.state,n=t.flow,s=t.flowTab;if(!n)return null;var i=n.request,r=n.response||{};return Object(m.jsxs)("div",{className:"flow-detail",children:[Object(m.jsxs)("div",{className:"header-tabs",children:[Object(m.jsx)("span",{onClick:function(){e.setState({flow:null})},children:"x"}),Object(m.jsx)("span",{className:"Headers"===s?"selected":null,onClick:function(){e.setState({flowTab:"Headers"})},children:"Headers"}),Object(m.jsx)("span",{className:"Preview"===s?"selected":null,onClick:function(){e.setState({flowTab:"Preview"})},children:"Preview"}),Object(m.jsx)("span",{className:"Response"===s?"selected":null,onClick:function(){e.setState({flowTab:"Response"})},children:"Response"}),n.waitIntercept?Object(m.jsxs)("div",{className:"flow-wait-area",children:[Object(m.jsx)(j.a,{size:"sm",onClick:function(){var t=v(11,n.id,JSON.stringify(n.request));e.ws.send(t),n.waitIntercept=!1,e.setState({flows:e.state.flows})},children:"Continue"}),Object(m.jsx)(j.a,{size:"sm",children:"Drop"})]}):null]}),Object(m.jsxs)("div",{style:{padding:"20px"},children:["Headers"!==s?null:Object(m.jsxs)("div",{children:[Object(m.jsxs)("div",{className:"header-block",children:[Object(m.jsx)("p",{children:"General"}),Object(m.jsxs)("div",{className:"header-block-content",children:[Object(m.jsxs)("p",{children:["Request URL: ",i.url]}),Object(m.jsxs)("p",{children:["Request Method: ",i.method]}),Object(m.jsxs)("p",{children:["Status Code: ","".concat(r.statusCode||"(pending)")]})]})]}),r.header?Object(m.jsxs)("div",{className:"header-block",children:[Object(m.jsx)("p",{children:"Response Headers"}),Object(m.jsx)("div",{className:"header-block-content",children:Object.keys(r.header).map((function(e){return Object(m.jsxs)("p",{children:[e,": ",r.header[e].join(" ")]},e)}))})]}):null,Object(m.jsxs)("div",{className:"header-block",children:[Object(m.jsx)("p",{children:"Request Headers"}),Object(m.jsx)("div",{className:"header-block-content",children:i.header?Object.keys(i.header).map((function(e){return Object(m.jsxs)("p",{children:[e,": ",i.header[e].join(" ")]},e)})):null})]}),i.body&&i.body.byteLength?Object(m.jsxs)("div",{className:"header-block",children:[Object(m.jsx)("p",{children:"Request Body"}),Object(m.jsx)("div",{className:"header-block-content",children:Object(m.jsx)("p",{children:b(i)?(new TextDecoder).decode(i.body):"Not text"})})]}):null]}),"Response"!==s?null:r.body&&r.body.byteLength?b(r)?Object(m.jsx)("div",{children:(new TextDecoder).decode(r.body)}):Object(m.jsx)("div",{children:"Not text response"}):Object(m.jsx)("div",{children:"No response"})]})]})}},{key:"render",value:function(){var e=this,t=this.state,n=t.flows,s=t.interceptUriInputing,i=t.interceptUri;return Object(m.jsxs)("div",{className:"main-table-wrap",children:[Object(m.jsxs)("div",{className:"top-control",children:[Object(m.jsx)("div",{children:Object(m.jsx)(j.a,{size:"sm",onClick:function(){e.flowMgr.clear(),e.setState({flows:e.flowMgr.showList(),flow:null})},children:"Clear"})}),Object(m.jsx)("div",{children:Object(m.jsx)(u.a.Control,{size:"sm",placeholder:"Filter",onChange:function(t){var n=t.target.value;e.flowMgr.changeFilterLazy(n,(function(){e.setState({flows:e.flowMgr.showList()})}))}})}),Object(m.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[Object(m.jsx)(u.a.Control,{size:"sm",placeholder:"Set interpect",value:s,onChange:function(t){e.setState({interceptUriInputing:t.target.value||""})}}),Object(m.jsx)(j.a,{size:"sm",onClick:function(){e.setState({interceptUri:s});var t=v(21,"00000000-0000-0000-0000-000000000000",s);e.ws.send(t)},children:"Set"}),i?Object(m.jsx)("span",{children:"Intercept:".concat(i)}):null]})]}),Object(m.jsxs)(h.a,{striped:!0,bordered:!0,size:"sm",children:[Object(m.jsx)("thead",{children:Object(m.jsxs)("tr",{children:[Object(m.jsx)("th",{children:"No"}),Object(m.jsx)("th",{children:"Host"}),Object(m.jsx)("th",{children:"Path"}),Object(m.jsx)("th",{children:"Method"}),Object(m.jsx)("th",{children:"Status"}),Object(m.jsx)("th",{children:"Size"})]})}),Object(m.jsx)("tbody",{children:n.map((function(t){var n=t.request.url,s=new URL(n),i=s.host;i.length>35&&(i=i.slice(0,35)+"...");var r=s.pathname+s.search;r.length>65&&(r=r.slice(0,65)+"...");var c=t.request,l=t.response||{},o=[];return e.state.flow&&e.state.flow.id===t.id&&o.push("tr-selected"),t.waitIntercept&&o.push("tr-wait-intercept"),Object(m.jsxs)("tr",{className:o.length?o.join(" "):null,onClick:function(){e.setState({flow:t})},children:[Object(m.jsx)("td",{children:t.no}),Object(m.jsx)("td",{children:i}),Object(m.jsx)("td",{children:r}),Object(m.jsx)("td",{children:c.method}),Object(m.jsx)("td",{children:l.statusCode||"(pending)"}),Object(m.jsx)("td",{children:p(l)})]},t.id)}))})]}),this.renderFlow()]})}}]),n}(i.a.Component),g=function(e){e&&e instanceof Function&&n.e(3).then(n.bind(null,29)).then((function(t){var n=t.getCLS,s=t.getFID,i=t.getFCP,r=t.getLCP,c=t.getTTFB;n(e),s(e),i(e),r(e),c(e)}))};c.a.render(Object(m.jsx)(i.a.StrictMode,{children:Object(m.jsx)(y,{})}),document.getElementById("root")),g()}},[[28,1,2]]]);
//# sourceMappingURL=main.7030457c.chunk.js.map