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.37b6cc16.chunk.js

2 lines
11 KiB
JavaScript

(this.webpackJsonpclient=this.webpackJsonpclient||[]).push([[0],{30:function(e,t,n){},35:function(e,t,n){"use strict";n.r(t);var s=n(0),r=n.n(s),i=n(9),c=n.n(i),a=(n(29),n(12)),l=n(13),o=n(18),d=n(17),h=n(24),j=n(7),u=n(10),b=(n(30),n(11)),f=n(14),O=n(16),p=n(19),w=n(15),x=n(1),v=function(e){Object(o.a)(n,e);var t=Object(d.a)(n);function n(e){var s;return Object(a.a)(this,n),(s=t.call(this,e)).state={show:!1,rule:{method:"ALL",url:"",action:"1"}},s.handleClose=s.handleClose.bind(Object(f.a)(s)),s.handleShow=s.handleShow.bind(Object(f.a)(s)),s.handleSave=s.handleSave.bind(Object(f.a)(s)),s}return Object(l.a)(n,[{key:"handleClose",value:function(){this.setState({show:!1})}},{key:"handleShow",value:function(){this.setState({show:!0})}},{key:"handleSave",value:function(){var e=this.state.rule,t=[];e.url&&t.push({method:"ALL"===e.method?"":e.method,url:e.url,action:parseInt(e.action)}),this.props.onSave(t),this.handleClose()}},{key:"render",value:function(){var e=this,t=this.state.rule;return Object(x.jsxs)("div",{children:[Object(x.jsx)(u.a,{size:"sm",onClick:this.handleShow,children:"BreakPoint"}),Object(x.jsxs)(O.a,{show:this.state.show,onHide:this.handleClose,children:[Object(x.jsx)(O.a.Header,{closeButton:!0,children:Object(x.jsx)(O.a.Title,{children:"Set BreakPoint"})}),Object(x.jsx)(O.a.Body,{children:Object(x.jsxs)(j.a,{children:[Object(x.jsxs)(j.a.Group,{as:p.a,children:[Object(x.jsx)(j.a.Label,{column:!0,sm:2,children:"Method"}),Object(x.jsx)(w.a,{sm:10,children:Object(x.jsxs)(j.a.Control,{as:"select",value:t.method,onChange:function(n){e.setState({rule:Object(b.a)(Object(b.a)({},t),{},{method:n.target.value})})},children:[Object(x.jsx)("option",{children:"ALL"}),Object(x.jsx)("option",{children:"GET"}),Object(x.jsx)("option",{children:"POST"}),Object(x.jsx)("option",{children:"PUT"}),Object(x.jsx)("option",{children:"DELETE"})]})})]}),Object(x.jsxs)(j.a.Group,{as:p.a,children:[Object(x.jsx)(j.a.Label,{column:!0,sm:2,children:"URL"}),Object(x.jsx)(w.a,{sm:10,children:Object(x.jsx)(j.a.Control,{value:t.url,onChange:function(n){e.setState({rule:Object(b.a)(Object(b.a)({},t),{},{url:n.target.value})})}})})]}),Object(x.jsxs)(j.a.Group,{as:p.a,children:[Object(x.jsx)(j.a.Label,{column:!0,sm:2,children:"Action"}),Object(x.jsx)(w.a,{sm:10,children:Object(x.jsxs)(j.a.Control,{as:"select",value:t.action,onChange:function(n){e.setState({rule:Object(b.a)(Object(b.a)({},t),{},{action:n.target.value})})},children:[Object(x.jsx)("option",{value:"1",children:"Request"}),Object(x.jsx)("option",{value:"2",children:"Response"}),Object(x.jsx)("option",{value:"3",children:"Both"})]})})]})]})}),Object(x.jsxs)(O.a.Footer,{children:[Object(x.jsx)(u.a,{variant:"secondary",onClick:this.handleClose,children:"Close"}),Object(x.jsx)(u.a,{variant:"primary",onClick:this.handleSave,children:"Save Changes"})]})]})]})}}]),n}(r.a.Component),m=function(){function e(){Object(a.a)(this,e),this.items=[],this._map=new Map,this.filterText="",this.filterTimer=null,this.num=0,this.max=1e3}return Object(l.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}(),y=function(e){return!!e&&(!!e.header&&(!!e.header["Content-Type"]&&/text|javascript|json/.test(e.header["Content-Type"].join(""))))},g=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},k=n(23),C={request:1,requestBody:2,response:3,responseBody:4},S=Object.keys(C).map((function(e){return C[e]})),L=Object.keys(C).reduce((function(e,t){return e[C[t]]=t,e}),{}),T=11,N=12,M=21,R=function(e){Object(o.a)(n,e);var t=Object(d.a)(n);function n(e){var s;return Object(a.a)(this,n),(s=t.call(this,e)).flowMgr=new m,s.state={flows:s.flowMgr.showList(),flow:null,flowTab:"Headers"},s.ws=null,s}return Object(l.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,39));if(1!==t[0])return null;var n=t[1];if(!S.includes(n))return null;var s=(new TextDecoder).decode(e.slice(2,38)),r=1===t[38],i={type:L[n],id:s,waitIntercept:r};if(39===e.byteLength)return i;if(n===C.requestBody||n===C.responseBody)return i.content=e.slice(39),i;var c=(new TextDecoder).decode(e.slice(39));try{c=JSON.parse(c)}catch(a){return null}return i.content=c,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 r=t.flowMgr.get(n.id);if(!r)return;r.waitIntercept=n.waitIntercept,r.request.body=n.content,t.setState({flows:t.state.flows})}else if("response"===n.type){var i=t.flowMgr.get(n.id);if(!i)return;i.waitIntercept=n.waitIntercept,i.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 r=n.request,i=n.response||{};return Object(x.jsxs)("div",{className:"flow-detail",children:[Object(x.jsxs)("div",{className:"header-tabs",children:[Object(x.jsx)("span",{onClick:function(){e.setState({flow:null})},children:"x"}),Object(x.jsx)("span",{className:"Headers"===s?"selected":null,onClick:function(){e.setState({flowTab:"Headers"})},children:"Headers"}),Object(x.jsx)("span",{className:"Preview"===s?"selected":null,onClick:function(){e.setState({flowTab:"Preview"})},children:"Preview"}),Object(x.jsx)("span",{className:"Response"===s?"selected":null,onClick:function(){e.setState({flowTab:"Response"})},children:"Response"}),n.waitIntercept?Object(x.jsxs)("div",{className:"flow-wait-area",children:[Object(x.jsx)(u.a,{size:"sm",onClick:function(){var t=function(e,t){var n,s;if(e===T){var r=t.request;s=r.body,n=Object(k.a)(r,["body"])}else{if(e!==N)throw new Error("invalid message type");var i=t.response;s=i.body,n=Object(k.a)(i,["body"])}var c=s&&s.byteLength?s.byteLength:0,a=(new TextEncoder).encode(JSON.stringify(n)),l=42+a.byteLength+4+c,o=new ArrayBuffer(l),d=new Uint8Array(o);d[0]=1,d[1]=e,d.set((new TextEncoder).encode(t.id),2),d.set(a,42),c&&d.set(s,42+a.byteLength+4);var h=new DataView(o);return h.setUint32(38,a.byteLength),h.setUint32(42+a.byteLength,c),d}(T,n);e.ws.send(t),n.waitIntercept=!1,e.setState({flows:e.state.flows})},children:"Continue"}),Object(x.jsx)(u.a,{size:"sm",children:"Drop"})]}):null]}),Object(x.jsxs)("div",{style:{padding:"20px"},children:["Headers"!==s?null:Object(x.jsxs)("div",{children:[Object(x.jsxs)("div",{className:"header-block",children:[Object(x.jsx)("p",{children:"General"}),Object(x.jsxs)("div",{className:"header-block-content",children:[Object(x.jsxs)("p",{children:["Request URL: ",r.url]}),Object(x.jsxs)("p",{children:["Request Method: ",r.method]}),Object(x.jsxs)("p",{children:["Status Code: ","".concat(i.statusCode||"(pending)")]})]})]}),i.header?Object(x.jsxs)("div",{className:"header-block",children:[Object(x.jsx)("p",{children:"Response Headers"}),Object(x.jsx)("div",{className:"header-block-content",children:Object.keys(i.header).map((function(e){return Object(x.jsxs)("p",{children:[e,": ",i.header[e].join(" ")]},e)}))})]}):null,Object(x.jsxs)("div",{className:"header-block",children:[Object(x.jsx)("p",{children:"Request Headers"}),Object(x.jsx)("div",{className:"header-block-content",children:r.header?Object.keys(r.header).map((function(e){return Object(x.jsxs)("p",{children:[e,": ",r.header[e].join(" ")]},e)})):null})]}),r.body&&r.body.byteLength?Object(x.jsxs)("div",{className:"header-block",children:[Object(x.jsx)("p",{children:"Request Body"}),Object(x.jsx)("div",{className:"header-block-content",children:Object(x.jsx)("p",{children:y(r)?(new TextDecoder).decode(r.body):"Not text"})})]}):null]}),"Response"!==s?null:i.body&&i.body.byteLength?y(i)?Object(x.jsx)("div",{children:(new TextDecoder).decode(i.body)}):Object(x.jsx)("div",{children:"Not text response"}):Object(x.jsx)("div",{children:"No response"})]})]})}},{key:"render",value:function(){var e=this,t=this.state.flows;return Object(x.jsxs)("div",{className:"main-table-wrap",children:[Object(x.jsxs)("div",{className:"top-control",children:[Object(x.jsx)("div",{children:Object(x.jsx)(u.a,{size:"sm",onClick:function(){e.flowMgr.clear(),e.setState({flows:e.flowMgr.showList(),flow:null})},children:"Clear"})}),Object(x.jsx)("div",{children:Object(x.jsx)(j.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(x.jsx)(v,{onSave:function(t){var n=function(e,t){if(e!==M)throw new Error("invalid message type");var n=(new TextEncoder).encode(JSON.stringify(t)),s=new Uint8Array(2+n.byteLength);return s[0]=1,s[1]=e,s.set(n,2),s}(M,t);e.ws.send(n)}})]}),Object(x.jsxs)(h.a,{striped:!0,bordered:!0,size:"sm",children:[Object(x.jsx)("thead",{children:Object(x.jsxs)("tr",{children:[Object(x.jsx)("th",{children:"No"}),Object(x.jsx)("th",{children:"Host"}),Object(x.jsx)("th",{children:"Path"}),Object(x.jsx)("th",{children:"Method"}),Object(x.jsx)("th",{children:"Status"}),Object(x.jsx)("th",{children:"Size"})]})}),Object(x.jsx)("tbody",{children:t.map((function(t){var n=t.request.url,s=new URL(n),r=s.host;r.length>35&&(r=r.slice(0,35)+"...");var i=s.pathname+s.search;i.length>65&&(i=i.slice(0,65)+"...");var c=t.request,a=t.response||{},l=[];return e.state.flow&&e.state.flow.id===t.id&&l.push("tr-selected"),t.waitIntercept&&l.push("tr-wait-intercept"),Object(x.jsxs)("tr",{className:l.length?l.join(" "):null,onClick:function(){e.setState({flow:t})},children:[Object(x.jsx)("td",{children:t.no}),Object(x.jsx)("td",{children:r}),Object(x.jsx)("td",{children:i}),Object(x.jsx)("td",{children:c.method}),Object(x.jsx)("td",{children:a.statusCode||"(pending)"}),Object(x.jsx)("td",{children:g(a)})]},t.id)}))})]}),this.renderFlow()]})}}]),n}(r.a.Component),B=function(e){e&&e instanceof Function&&n.e(3).then(n.bind(null,37)).then((function(t){var n=t.getCLS,s=t.getFID,r=t.getFCP,i=t.getLCP,c=t.getTTFB;n(e),s(e),r(e),i(e),c(e)}))};c.a.render(Object(x.jsx)(r.a.StrictMode,{children:Object(x.jsx)(R,{})}),document.getElementById("root")),B()}},[[35,1,2]]]);
//# sourceMappingURL=main.37b6cc16.chunk.js.map