(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{148:function(e,t,a){e.exports=a(318)},153:function(e,t,a){},155:function(e,t,a){},161:function(e,t){},163:function(e,t){},197:function(e,t){},198:function(e,t){},27:function(e,t,a){},318:function(e,t,a){"use strict";a.r(t);var n=a(0),c=a.n(n),l=a(82),r=a.n(l),i=(a(153),a(9)),s=a(331),o=a(335),u=a(327),m=a(329),d=a(317),p=(a(155),a(140)),h=a(141),E=a(157),f=new(function(){function e(){Object(p.a)(this,e),console.log("Datasource constructed"),this.socket=null,this.interval=null,this.queries={},this.subscriptions={},this.connected=!1,this.requestQueue=[],this.serverTimeOffset=0,this.serverLatency=[0];var t=function(){this.socket&&this.connected&&this.socket.send(JSON.stringify({action:"ping",time:Date.now()}))}.bind(this);setInterval(t,1e4)}return Object(h.a)(e,[{key:"connect",value:function(e,t){this.socket=new WebSocket(e),this.interval&&clearInterval(this.interval),this.interval=null;var a=function(){console.log("WS reconnecting"),this.connect(e,t)}.bind(this),n=function(){null==this.interval&&(this.interval=setInterval(a,5e3))}.bind(this);this.socket.onopen=function(){this.connected=!0,this.sendQueuedRequests(),console.log("WS connected"),t("connected")}.bind(this),this.socket.onclose=function(){this.connected=!1,console.log("WS disconnected"),t("disconnected"),n()}.bind(this),this.socket.onerror=function(e){console.error("WS error:",e),t("error")},this.socket.onmessage=function(e){console.debug("WS message: ",e.data);var t=JSON.parse(e.data);t.pong&&(this.serverLatency.push((Date.now()-t.pong)/2),this.serverLatency.length>10&&this.serverLatency.shift()),t._time&&(this.serverTimeOffset=Date.now()-t._time-this.serverLatency.reduce(function(e,t){return e+t},0)/this.serverLatency.length,delete t._time);var a=null;t._requestId?(a=this.queries[t._requestId],delete t._requestId):t._subscribeId&&(a=this.subscriptions[t._subscribeId],delete t._subscribeId),a&&(t._isNull?t=null:t._isTrue?t=!0:t._isFalse&&(t=!1),t&&t._error&&a[1]?a[1](t._error):a[0](t))}.bind(this)}},{key:"disconnect",value:function(){this.socket&&(this.socket.close(),this.socket=null)}},{key:"getWorkspace",value:function(e,t){return this.request({action:"get",what:"workspace",namespace:e,project:t})}},{key:"createWorkspace",value:function(e,t){return this.request({action:"create",what:"workspace",namespace:e,project:t})}},{key:"createAuthDev",value:function(e,t){return this.request({action:"create",what:"authdev",workspace:e,user:t})}},{key:"update",value:function(e,t,a){return this.request({action:"update",what:t,id:e,content:a})}},{key:"createAuthReq",value:function(e,t,a){var n=this;this.request({action:"create",what:"authreq",workspace:e,params:t}).then(function(e){n.subscriptions[e.id]=[a],a(e)}).catch(function(e){a(null)})}},{key:"subscribe",value:function(e,t){var a=this;null!==e&&this.request({action:"subscribe",id:e}).then(function(n){n?(console.log("Subscribed: ",e),a.subscriptions[e]=[t]):console.log("Subscription failed: ",e)}).catch(function(e){console.log("Subscription failed: ",e)})}},{key:"unsubscribe",value:function(e){null!==e&&(delete this.subscriptions[e],this.request({action:"unsubscribe",id:e}).then(function(t){console.log("Unsubscribed: ",e)}).catch(function(e){console.log("Unsubscribe failed: ",e)}))}},{key:"action",value:function(e,t,a){var n=this;this.request({action:"action",what:e,adId:t,reqId:a}).then(function(e){var a=n.subscriptions[t];e&&"id"in e&&e.id&&e.id==t&&a&&a[0](e)}).catch(function(e){})}},{key:"request",value:function(e){var t=E(32);e._requestId=t;var a=this.queries;return this.send(e),new Promise(function(e,n){var c=setTimeout(function(){a[t]&&(delete a[t],n("timeout"))},1e4);a[t]=[function(n){delete a[t],clearTimeout(c),e(n)},function(e){delete a[t],clearTimeout(c),n(e)}]})}},{key:"send",value:function(e){this.socket&&this.connected?this.socket.send(JSON.stringify(e)):this.requestQueue.push(e)}},{key:"sendQueuedRequests",value:function(){for(var e=this;this.requestQueue.length>0;){var t=this.requestQueue.shift();this.queries[t._requestId]?this.send(t):console.log("Query timed out")}Object.entries(this.subscriptions).map(function(t){var a=Object(i.a)(t,2),n=a[0];a[1];e.socket.send(JSON.stringify({action:"subscribe",id:n}))})}},{key:"secondsUntil",value:function(e){return Math.round((e-Date.now()+this.serverTimeOffset)/1e3)}}]),e}()),g=a(322),b=a(323),v=(a(27),a(332)),k=a(334),y=a(319),C=a(330),j=a(320),S=a(321),O=a(142),x=a.n(O).a.debounce(function(e,t,a){f.getWorkspace(e,t).then(function(e){console.log(e),a(null!==e)}).catch(function(e){return console.log(e)})},100),w=Object(v.a)(function(e){var t=Object(n.useState)(localStorage.getItem("namespace")||""),a=Object(i.a)(t,2),l=a[0],r=a[1],s=Object(n.useState)(localStorage.getItem("project")||""),o=Object(i.a)(s,2),u=o[0],m=o[1],d=Object(n.useState)(1),p=Object(i.a)(d,2),h=p[0],E=p[1],g=new RegExp("^[^/]{5,}$");function b(){localStorage.setItem("namespace",l),localStorage.setItem("project",u),E(4),e.history.push("/"+l+"/"+u)}function v(){localStorage.setItem("namespace",l),localStorage.setItem("project",u),E(4),f.createWorkspace(l,u).then(function(t){console.log(t),e.history.push("/"+l+"/"+u)})}return Object(n.useEffect)(function(){l.length<5||u.length<5?E(0):g.test(l)&&g.test(u)?(0===h&&E(1),x(l,u,function(e){return E(e?2:3)})):E(5)},[l,u]),c.a.createElement(k.a,null,c.a.createElement(y.a,null,"Namespace:"),c.a.createElement(C.a,{type:"text",value:l,onChange:function(e){r(e.target.value.trim())}}),c.a.createElement("span",{className:"explanation"},"Company/organization/nickname"),c.a.createElement("br",null),c.a.createElement("br",null),c.a.createElement(y.a,null,"Project:"),c.a.createElement(C.a,{type:"text",value:u,onChange:function(e){m(e.target.value.trim())}}),c.a.createElement("span",{className:"explanation"},"Arbitrary name for your workspace"),c.a.createElement("br",null),c.a.createElement("br",null),0===h?c.a.createElement(j.a,null,"Namespace and project must be at least 5 characters"):2===h?c.a.createElement(S.a,{bsStyle:"primary",onClick:b},"Open"):3===h?c.a.createElement(S.a,{bsStyle:"success",onClick:v},"Create"):5==h?c.a.createElement(j.a,null,"Namespace and project names must be URL friendly"):void 0)});function I(){return c.a.createElement(g.a,null,c.a.createElement(b.a,{xs:3}),c.a.createElement(b.a,{xs:6},c.a.createElement("p",{style:{border:"1px solid red",textAlign:"center",padding:5}},"This CIBA AD/CD Simulator is a debug tool for developing CIBA-compliant AS/OP.",c.a.createElement("br",null),"It is made available without any promise of privacy, availability, or reliability.",c.a.createElement("br",null)),c.a.createElement(w,null),c.a.createElement("h3",null,"About"),c.a.createElement("p",null,"The Authlete CIBA AD/CD Simulator, henceforth referred to as ",c.a.createElement("i",null,"cibasim"),", implements an Authentication Device and a Consumption Device according to the CIBA specification (as far as hitting a moving target is realistic)."),c.a.createElement("p",null,"Cibasim is meant as a tool for developers implementing a CIBA-compliant AS/OP. It is not a conformance test or a replacement for proper production systems."),c.a.createElement("p",null,"\u26a0\ufe0f All data entered into cibasim, including e.g. client secrets, should be treated as publicly accessible, as anyone can open any workspace if they know its name.",c.a.createElement("br",null),c.a.createElement("br",null),"\u26a0\ufe0f Data stored in cibasim is purged on a last recently used basis. Your workspace can be deleted at any time. However, at current usage it should be kept for months.",c.a.createElement("br",null),c.a.createElement("br",null),"\u26a0\ufe0f Upgrade/maintenance might occur at any time. Availability is not guaranteed."),c.a.createElement("h3",null,"Usage"),c.a.createElement("p",null,"First, create a workspace by filling in ",c.a.createElement("i",null,"namespace")," and ",c.a.createElement("i",null,"project")," above and clicking ",c.a.createElement("i",null,"Create"),". A workspace is fundamentally a collection of configuration for the AD and CD simulators to use. AD and CD simulators can be used independently. If preferred, you can create separate workspaces for AD and CD."),c.a.createElement("p",null)),c.a.createElement(b.a,{xs:3}))}var q=a(326),_=a(333),A=a(328),D=a(325),N=a(324),R=a(83),B=function(e){var t=f.secondsUntil(e.expire);t<0&&(t=0);var a=Object(n.useState)(t),l=Object(i.a)(a,2),r=l[0],s=l[1];Object(n.useEffect)(function(){var t=setInterval(function(){var a=f.secondsUntil(e.expire);(a<0||"active"!=e.status)&&(a=0,clearInterval(t)),s(a)},1e3);return function(){clearInterval(t)}},[e.reqId]);var o="active"==e.status||"allow"==e.status?"success":"default",u="active"==e.status||"deny"==e.status?"danger":"default",m="";"active"==e.status?m=Object(R.sprintf)("%02d:%02d",r/60,r%60):"allow"==e.status?m="Allowed":"deny"==e.status?m="Denied":"timeout"==e.status?m="Timed out":"abort"==e.status&&(m="Aborted");var d="";return"exec"==e.cbStatus?d="Callback: running":"done"==e.cbStatus?d="Callback: complete":"fail"==e.cbStatus&&(d="Callback: "+e.info),c.a.createElement(b.a,{xs:4},c.a.createElement(N.a,{style:{textAlign:"center"}},c.a.createElement("h4",null,e.msg),c.a.createElement("br",null),c.a.createElement("p",null,m),c.a.createElement(S.a,{bsStyle:o,disabled:"active"!=e.status||r<=0,onClick:function(){f.action("allow",e.adId,e.reqId)}},"Allow"),"\xa0",c.a.createElement(S.a,{bsStyle:u,disabled:"active"!=e.status||r<=0,onClick:function(){f.action("deny",e.adId,e.reqId)}},"Deny"),d))},L=a(147),W=a.n(L),F=function(e){var t=Object(n.useState)({id:null}),a=Object(i.a)(t,2),l=a[0],r=a[1],s=Object(n.useRef)(null);return Object(n.useEffect)(function(){f.createAuthDev(e.workspace.id,e.userId).then(function(e){r(null!==e?e:{id:null,failed:!0})}).catch(function(e){console.log("Failed to get authdev:",e)})},[e.workspace.id,e.userId]),Object(n.useEffect)(function(){return f.subscribe(l.id,function(e){r(e||{id:null,failed:!0})}),function(){f.unsubscribe(l.id)}},[l.id]),l.failed?c.a.createElement("p",null,"Failed! :("):l.id?(s&&s.current&&W.a.toCanvas(s.current,"https://cibasim.authlete.com/ad/"+l.id),c.a.createElement(c.a.Fragment,null,c.a.createElement(_.a,null,c.a.createElement(_.a.Item,{href:"/"},"Home"),c.a.createElement(_.a.Item,{href:"/".concat(e.workspace.namespace,"/").concat(e.workspace.project)},e.workspace.namespace,"/",e.workspace.project),c.a.createElement(_.a.Item,{active:!0},"Authentication Device: ",e.userId)),c.a.createElement("a",{href:"/ad/".concat(l.id)},c.a.createElement("canvas",{ref:s,style:{position:"fixed",top:"70px",right:"0px",transform:"scale(0.5, 0.5)"},title:"Link to mobile friendly AD"})),c.a.createElement("h3",null,"Authentication Requests"),c.a.createElement(g.a,null,Object.entries(l.requests).map(function(e){var t=Object(i.a)(e,2),a=t[0],n=t[1];return c.a.createElement(B,{key:a,adId:l.id,reqId:a,msg:n.msg,status:n.status,expire:n.expire,cbStatus:n.cb_status,info:n.info})})))):c.a.createElement("p",null,"Loading...")},T=function(e){var t=e.req,a="Unknown";switch(t.status){case"bc_sent":a="BC auth request sent";break;case"bc_fail":a="BC auth request failed";break;case"poll":a="Polling";break;case"ping":a="Received ping callback";break;case"wait":a="Waiting for callback";break;case"tk_fail":a="Token request failed";break;case"ps_fail":a="Pushed result indicates fail";break;case"done":a="Completed";break;case"deny":a="Access was denied";break;case"timeout":a="Timed out"}return c.a.createElement(b.a,{xs:6},c.a.createElement(N.a,null,c.a.createElement("span",{style:{position:"absolute",color:"red",cursor:"pointer",left:0,top:0,display:"inline-block",fontSize:"1.5em"},onClick:e.onClose},"\xd7"),c.a.createElement(g.a,null,c.a.createElement(b.a,{xs:4},"Status:"),c.a.createElement(b.a,{xs:8},a)),t.dc&&c.a.createElement(g.a,null,c.a.createElement(b.a,{xs:4},"device_code:"),c.a.createElement(b.a,{xs:8},t.dc)),t.uc&&c.a.createElement(g.a,null,c.a.createElement(b.a,{xs:4},"user_code:"),c.a.createElement(b.a,{xs:8},t.uc)),t.vu&&c.a.createElement(g.a,null,c.a.createElement(b.a,{xs:4},"verification_uri:"),c.a.createElement(b.a,{xs:8},c.a.createElement("a",{href:t.vu,class:"small",target:"_blank"},t.vu))),t.vuc&&c.a.createElement(g.a,null,c.a.createElement(b.a,{xs:4},"verification_uri_complete:"),c.a.createElement(b.a,{xs:8},c.a.createElement("a",{href:t.vuc,class:"small",target:"_blank"},t.vuc))),t.auth_req_id&&c.a.createElement(g.a,null,c.a.createElement(b.a,{xs:4},"auth_req_id:"),c.a.createElement(b.a,{xs:8},t.auth_req_id)),t.info&&c.a.createElement(g.a,null,c.a.createElement(b.a,{xs:4},"Info:"),c.a.createElement(b.a,{xs:8},t.info)),t.error&&c.a.createElement(g.a,null,c.a.createElement(b.a,{xs:4},"Error:"),c.a.createElement(b.a,{xs:8},t.error)),t.content&&c.a.createElement(g.a,null,c.a.createElement(b.a,{md:4},"Result:"),c.a.createElement(b.a,{md:8},c.a.createElement("pre",{style:{fontSize:"0.7em",whiteSpace:"pre-wrap"}},t.content?JSON.stringify(t.content):"")))))},U=function(e){var t=Object(n.useState)(localStorage.getItem(e.workspace.id+"-scope")||"openid"),a=Object(i.a)(t,2),l=a[0],r=a[1],s=Object(n.useState)(localStorage.getItem(e.workspace.id+"-acr")||"mod-pr"),o=Object(i.a)(s,2),u=o[0],m=o[1],d=Object(n.useState)(localStorage.getItem(e.workspace.id+"-hint")||""),p=Object(i.a)(d,2),h=p[0],E=p[1],v=Object(n.useState)(localStorage.getItem(e.workspace.id+"-hinttype")||"login_hint"),j=Object(i.a)(v,2),O=j[0],x=j[1],w=Object(n.useState)(localStorage.getItem(e.workspace.id+"-message")||""),I=Object(i.a)(w,2),q=I[0],N=I[1],R=Object(n.useState)(localStorage.getItem(e.workspace.id+"-code")||""),B=Object(i.a)(R,2),L=B[0],W=B[1],F=Object(n.useState)({}),U=Object(i.a)(F,2),P=U[0],H=U[1];function J(e){x(e.target.value)}function Q(e){P[e.id]=e,H(P)}return c.a.createElement(c.a.Fragment,null,c.a.createElement(_.a,null,c.a.createElement(_.a.Item,{href:"/"},"Home"),c.a.createElement(_.a.Item,{href:"/".concat(e.workspace.namespace,"/").concat(e.workspace.project)},e.workspace.namespace,"/",e.workspace.project),c.a.createElement(_.a.Item,{active:!0},"Consumption Device")),c.a.createElement(A.a,null,c.a.createElement(A.a.Heading,null,"Create Authentication Request"),c.a.createElement(A.a.Body,null,c.a.createElement(k.a,null,c.a.createElement(b.a,{xs:3},c.a.createElement(y.a,null,"Scopes:")),c.a.createElement(b.a,{xs:9},c.a.createElement(C.a,{type:"text",value:l,onChange:function(e){r(e.target.value)}})),"device"!=e.workspace.cdConfig.mode&&c.a.createElement(c.a.Fragment,null,c.a.createElement(b.a,{xs:3},c.a.createElement(y.a,null,"ACR Values:")),c.a.createElement(b.a,{xs:9},c.a.createElement(C.a,{type:"text",value:u,onChange:function(e){m(e.target.value)}})),c.a.createElement(b.a,{xs:12},c.a.createElement(y.a,null,"Hint:")),c.a.createElement(b.a,{xs:12},c.a.createElement(C.a,{componentClass:"textarea",value:h,onChange:function(e){E(e.target.value)}})),c.a.createElement(b.a,{xs:12},c.a.createElement(D.a,{name:"hinttype",value:"login_hint",inline:!0,checked:"login_hint"==O,onChange:J},"login_hint"),c.a.createElement(D.a,{name:"hinttype",value:"id_token_hint",inline:!0,checked:"id_token_hint"==O,onChange:J},"id_token_hint"),c.a.createElement(D.a,{name:"hinttype",value:"login_hint_token",inline:!0,checked:"login_hint_token"==O,onChange:J},"login_hint_token"),c.a.createElement("br",null),c.a.createElement("br",null)),c.a.createElement(b.a,{xs:4},c.a.createElement(y.a,null,"Binding Message:")),c.a.createElement(b.a,{xs:8},c.a.createElement(C.a,{type:"text",value:q,onChange:function(e){N(e.target.value)}})),c.a.createElement(b.a,{xs:4},c.a.createElement(y.a,null,"User Code:")),c.a.createElement(b.a,{xs:8},c.a.createElement(C.a,{type:"text",value:L,onChange:function(e){W(e.target.value)}}))),c.a.createElement(b.a,{xs:12},c.a.createElement(S.a,{bsStyle:"primary",onClick:function(){localStorage.setItem(e.workspace.id+"-scope",l),localStorage.setItem(e.workspace.id+"-acr",u),localStorage.setItem(e.workspace.id+"-hint",h),localStorage.setItem(e.workspace.id+"-hinttype",O),localStorage.setItem(e.workspace.id+"-message",q),localStorage.setItem(e.workspace.id+"-code",L),f.createAuthReq(e.workspace.id,{scope:l,acr:u,hint:h,hint_type:O,message:q,code:L},Q)},disabled:e.workspace.cdConfig.auth.length<12},"Send"))))),c.a.createElement("h3",null,"Authentication Requests"),c.a.createElement(g.a,null,Object.entries(P).map(function(e){var t=Object(i.a)(e,2),a=t[0],n=t[1];return c.a.createElement(T,{key:a,req:n,onClose:function(){return function(e){f.unsubscribe(e),delete P[e],H(P)}(a)}})})))},P=Object(v.a)(function(e){var t=Object(n.useState)({id:null}),a=Object(i.a)(t,2),l=a[0],r=a[1],s=Object(n.useState)(""),m=Object(i.a)(s,2),d=m[0],p=m[1],h=Object(n.useState)(""),E=Object(i.a)(h,2),v=E[0],j=E[1],O=Object(n.useState)(""),x=Object(i.a)(O,2),w=x[0],I=x[1],N=Object(n.useState)(""),R=Object(i.a)(N,2),B=R[0],L=R[1],W=Object(n.useState)(""),T=Object(i.a)(W,2),P=T[0],H=T[1],J=Object(n.useState)(""),Q=Object(i.a)(J,2),M=Q[0],z=Q[1],G=Object(n.useState)(""),$=Object(i.a)(G,2),V=$[0],Y=$[1],K=Object(n.useState)(""),X=Object(i.a)(K,2),Z=X[0],ee=X[1];function te(e){H(e.target.value)}function ae(e){Y(e.target.value)}return Object(n.useEffect)(function(){console.log("Getting workspace...",e.match.params.namespace,e.match.params.project),f.getWorkspace(e.match.params.namespace,e.match.params.project).then(function(e){console.log("Workspace: ",e),null!==e?(r(e),localStorage.setItem("namespace",e.namespace),localStorage.setItem("project",e.project)):r({id:null,notFound:!0})}).catch(function(e){console.log("Failed to get workspace:",e)})},[e.match.params.namespace,e.match.params.project]),Object(n.useEffect)(function(){return console.log("WS subscribing",l.id),f.subscribe(l.id,function(e){r(e||{id:null,notFound:!0}),j(e?e.adConfig.callback:""),I(e?e.cdConfig.auth:""),L(e?e.cdConfig.token:""),H(e&&e.cdConfig.mode||"push"),z(e&&e.cdConfig.client||""),Y(e?e.cdConfig.method:""),ee(e?e.cdConfig.secret:""),p(e&&localStorage.getItem(e.id+"-userid")||"")}),function(){f.unsubscribe(l.id)}},[l.id]),l.notFound?c.a.createElement("p",null,"Workspace not found. Go ",c.a.createElement(q.a,{to:"/"},"home"),"."):l.id?c.a.createElement(o.a,null,c.a.createElement(u.a,{exact:!0,path:"/:namespace/:project/ad/:userId",render:function(e){return c.a.createElement(F,Object.assign({},e,{workspace:l,userId:e.match.params.userId}))}}),c.a.createElement(u.a,{exact:!0,path:"/:namespace/:project/cd",render:function(e){return c.a.createElement(U,Object.assign({},e,{workspace:l}))}}),c.a.createElement(u.a,{exact:!0,path:"/:namespace/:project"},c.a.createElement(c.a.Fragment,null,c.a.createElement(_.a,null,c.a.createElement(_.a.Item,{href:"/"},"Home"),c.a.createElement(_.a.Item,{active:!0},l.namespace,"/",l.project)),c.a.createElement(A.a,null,c.a.createElement(A.a.Heading,null,"Authentication Device"),c.a.createElement(A.a.Body,null,c.a.createElement(k.a,null,c.a.createElement(b.a,{xs:2},c.a.createElement(y.a,null,"User ID:")),c.a.createElement(b.a,{xs:4},c.a.createElement(C.a,{type:"text",value:d,onChange:function(e){p(e.target.value.trim())}})),c.a.createElement(b.a,{xs:2},c.a.createElement(S.a,{bsStyle:"primary",onClick:function(){localStorage.setItem(l.id+"-userid",d),e.history.push(e.match.url+"/ad/"+d)},disabled:0==d.length},"Launch AD simulator")),c.a.createElement(b.a,{xs:4})),c.a.createElement(g.a,null,c.a.createElement(b.a,{xs:12},c.a.createElement("span",{className:"explanation"},"Arbitrary user ID that your AS/OP can use to initiate simulated authentication requests (subject/MSISDN, etc)"))))),c.a.createElement(A.a,null,c.a.createElement(A.a.Heading,null,"Consumption Device"),c.a.createElement(A.a.Body,null,c.a.createElement(k.a,null,c.a.createElement(b.a,{xs:2},c.a.createElement(S.a,{bsStyle:"primary",onClick:function(){e.history.push(e.match.url+"/cd")},disabled:l.cdConfig.auth.length<12},"Launch CD simulator"))))),c.a.createElement(A.a,null,c.a.createElement(A.a.Heading,null,"Configuration"),c.a.createElement(A.a.Body,null,c.a.createElement(k.a,null,c.a.createElement(g.a,null,c.a.createElement(b.a,{md:2},c.a.createElement(y.a,null,"AD Callback URL:")),c.a.createElement(b.a,{md:6},c.a.createElement(C.a,{type:"text",value:v,onChange:function(e){j(e.target.value.trim())}})),c.a.createElement(b.a,{md:4},c.a.createElement("span",{className:"explanation"},"Optional; required for AD simulator async mode"),c.a.createElement("br",null))),c.a.createElement(g.a,null,c.a.createElement(b.a,{md:12},c.a.createElement(S.a,{bsStyle:"danger",disabled:v==l.adConfig.callback,onClick:function(){f.update(l.id,"adConfig",{callback:v}).then(function(e){e&&(l.adConfig.callback=v,r(l))}).catch(function(e){console.log("AD config save error:",e)})}},"Save")))),c.a.createElement(k.a,null,c.a.createElement(g.a,null,c.a.createElement(b.a,{md:2},c.a.createElement(y.a,null,"BC Authentication Endpoint URL:")),c.a.createElement(b.a,{md:6},c.a.createElement(C.a,{type:"text",value:w,onChange:function(e){I(e.target.value.trim())}})),c.a.createElement(b.a,{md:4},c.a.createElement("span",{className:"explanation"},"Required for CD simulator"),c.a.createElement("br",null))),c.a.createElement(g.a,null,c.a.createElement(b.a,{md:2},c.a.createElement(y.a,null,"Token Endpoint URL:")),c.a.createElement(b.a,{md:6},c.a.createElement(C.a,{type:"text",value:B,onChange:function(e){var t=e.target.value.trim();L(t),t.length<12&&H("push")}})),c.a.createElement(b.a,{md:4},c.a.createElement("span",{className:"explanation"},"Required for poll and ping modes"),c.a.createElement("br",null))),c.a.createElement(g.a,null,c.a.createElement(b.a,{md:2},c.a.createElement(y.a,null,"Token Delivery Mode:")),c.a.createElement(b.a,{md:10},c.a.createElement(D.a,{name:"cdmode",value:"poll",inline:!0,checked:"poll"==P,disabled:B.length<12,onChange:te},"Poll"),c.a.createElement(D.a,{name:"cdmode",value:"ping",inline:!0,checked:"ping"==P,disabled:B.length<12,onChange:te},"Ping"),c.a.createElement(D.a,{name:"cdmode",value:"push",inline:!0,checked:"push"==P,onChange:te},"Push"),c.a.createElement(D.a,{name:"cdmode",value:"device",inline:!0,checked:"device"==P,onChange:te},"Device Flow"),c.a.createElement("br",null))),c.a.createElement(g.a,null,c.a.createElement(b.a,{md:2},c.a.createElement(y.a,null,"Client ID:")),c.a.createElement(b.a,{md:4},c.a.createElement(C.a,{type:"text",value:M,onChange:function(e){var t=e.target.value.trim();z(t),0==t.length&&Y("")}})),c.a.createElement(b.a,{md:6},c.a.createElement("span",{className:"explanation"},"Optional; will be included in CD authentication requests if provided"),c.a.createElement("br",null))),c.a.createElement(g.a,null,c.a.createElement(b.a,{md:2},c.a.createElement(y.a,null,"Client Authentication:")),c.a.createElement(b.a,{md:10},c.a.createElement(D.a,{name:"cdmethod",value:"",inline:!0,checked:""==V,onChange:ae},"None"),c.a.createElement(D.a,{name:"cdmethod",value:"basic",inline:!0,checked:"basic"==V,disabled:0==M.length,onChange:ae},"Basic"),c.a.createElement(D.a,{name:"cdmethod",value:"post",inline:!0,checked:"post"==V,disabled:0==M.length,onChange:ae},"Post"),c.a.createElement("br",null))),c.a.createElement(g.a,null,c.a.createElement(b.a,{md:2},c.a.createElement(y.a,null,"Client Secret:")),c.a.createElement(b.a,{md:6},c.a.createElement(C.a,{type:"text",value:Z,disabled:!["basic","post"].includes(V),onChange:function(e){ee(e.target.value.trim())}})),c.a.createElement(b.a,{md:4},c.a.createElement("span",{className:"explanation"},"Required for basic or post client authentication"),c.a.createElement("br",null))),c.a.createElement(g.a,null,c.a.createElement(b.a,{md:12},c.a.createElement(S.a,{bsStyle:"danger",disabled:w==l.cdConfig.auth&&B==l.cdConfig.token&&P==l.cdConfig.mode&&M==l.cdConfig.client&&V==l.cdConfig.method&&Z==l.cdConfig.secret,onClick:function(){f.update(l.id,"cdConfig",{auth:w,token:B,mode:P,client:M,method:V,secret:Z}).then(function(e){e&&(l.cdConfig.auth=w,l.cdConfig.token=B,l.cdConfig.mode=P,l.cdConfig.client=M,l.cdConfig.method=V,l.cdConfig.secret=Z,r(l))}).catch(function(e){console.log("CD config save error:",e)})}},"Save"))))))))):c.a.createElement("p",null,"Loading...")}),H=function(e){var t=Object(n.useState)({id:null}),a=Object(i.a)(t,2),l=a[0],r=a[1];if(Object(n.useEffect)(function(){return f.subscribe(e.match.params.adId,function(e){console.log(e),r(null!==e?e:{id:null,failed:!0})}),function(){f.unsubscribe(l.id)}},[e.match.params.adId]),l.failed)return c.a.createElement("p",null,"Failed! :(");if(!l.id)return c.a.createElement("p",null,"Loading...");var s=[];l.requests&&Object.entries(l.requests).map(function(e){var t=Object(i.a)(e,2),a=(t[0],t[1]);s.push(a)});var o=0==s.length?null:s[s.length-1];console.log(s),console.log(l);if(!o)return c.a.createElement("img",{src:"/authlete-logo.jpg",style:{position:"fixed",top:"45%",left:"50%",transform:"translate(-50%, -50%)",maxWidth:"80%",maxHeight:"80%"}});console.log(o.msg);var u=/^Client App \((.*)\).*\[Requested scopes\]: (.*)\[Binding message\]: (.*)$/.exec(o.msg);if(u)var m=u[1],d=u[2],p=u[3];else p=o.msg;return c.a.createElement("div",{className:"simple"},c.a.createElement("div",{className:"header"},"Authentication Request"),c.a.createElement("div",{className:"appname"},m),c.a.createElement("div",{className:"scopes"},d),c.a.createElement("div",{className:"message"},p))},J=function(){var e=Object(n.useState)("init"),t=Object(i.a)(e,2),a=(t[0],t[1]);return Object(n.useEffect)(function(){return f.connect("wss://cibasim.authlete.com/ws",function(e){a(e)}),function(){f.disconnect()}},[]),c.a.createElement(s.a,null,c.a.createElement(o.a,null,c.a.createElement(u.a,{path:"/ad/:adId",component:H}),c.a.createElement(u.a,null,c.a.createElement(c.a.Fragment,null,c.a.createElement(m.a,null,c.a.createElement(m.a.Brand,null,c.a.createElement("a",{href:"/"},"Authlete CIBA Simulator"))),c.a.createElement(d.a,null,c.a.createElement(u.a,{exact:!0,path:"/",component:I}),c.a.createElement(u.a,{path:"/:namespace/:project",component:P}))))))};r.a.render(c.a.createElement(J,null),document.getElementById("root"))}},[[148,2,1]]]); //# sourceMappingURL=main.042ff9fa.chunk.js.map